完成碰撞检测
This commit is contained in:
parent
854e168ae7
commit
3ac23bdc69
@ -52,7 +52,7 @@ class Entity
|
||||
|
||||
int grid_id = 0;
|
||||
std::set<GridCell*> grid_list;
|
||||
Obstacle* last_collision_door = nullptr;
|
||||
Entity* last_collision_door = nullptr;
|
||||
|
||||
Entity();
|
||||
virtual ~Entity();
|
||||
|
@ -273,11 +273,35 @@ bool Human::IsCollision()
|
||||
return false;
|
||||
}
|
||||
|
||||
int detection_flags = 0;
|
||||
a8::SetBitFlag(detection_flags, ET_Obstacle);
|
||||
a8::SetBitFlag(detection_flags, ET_Building);
|
||||
std::vector<Entity*> objects;
|
||||
room->CollisionDetection(this, detection_flags, objects);
|
||||
for (auto& grid : grid_list) {
|
||||
for (Entity* entity : grid->entity_list) {
|
||||
switch (entity->entity_type) {
|
||||
case ET_Obstacle:
|
||||
{
|
||||
if (
|
||||
(last_collision_door == nullptr || last_collision_door != entity) &&
|
||||
TestCollision(entity)
|
||||
){
|
||||
objects.push_back(entity);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ET_Building:
|
||||
{
|
||||
if (TestCollision(entity)) {
|
||||
objects.push_back(entity);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return !objects.empty();
|
||||
}
|
||||
|
||||
|
@ -123,8 +123,6 @@ class Human : public Entity
|
||||
void FindLocation();
|
||||
void RefreshView();
|
||||
|
||||
protected:
|
||||
|
||||
protected:
|
||||
long long last_shot_frameno_ = 0;
|
||||
std::set<Entity*> new_objects;
|
||||
|
Loading…
x
Reference in New Issue
Block a user