1
This commit is contained in:
parent
9cf6a340f2
commit
6304a76047
@ -797,44 +797,17 @@ void Room::FindLocationWithAabb(Entity* target, const a8::Vec2& aabb_pos, AabbCo
|
|||||||
new_x = pos.x;
|
new_x = pos.x;
|
||||||
new_y = pos.y;
|
new_y = pos.y;
|
||||||
|
|
||||||
Entity* building = nullptr;
|
bool is_collision = false;
|
||||||
std::set<GridCell*> new_grid_list;
|
std::set<ColliderComponent*> colliders;
|
||||||
grid_service.GetAllCellsByXy(pos.x, pos.y, new_grid_list);
|
map_service.GetColliders(pos.x, pos.y, colliders);
|
||||||
for (auto& grid : new_grid_list) {
|
for (ColliderComponent* collider : colliders) {
|
||||||
for (Entity* entity : grid->entity_list) {
|
if (collider->IntersectEx(pos, aabb_box)) {
|
||||||
switch (entity->entity_type) {
|
is_collision = true;
|
||||||
case ET_Building:
|
|
||||||
{
|
|
||||||
if (entity->TestCollisionEx(pos, *aabb_box)) {
|
|
||||||
building = entity;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (building) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (building) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!is_collision) {
|
||||||
if (!building) {
|
break;
|
||||||
bool is_collision = false;
|
|
||||||
std::set<ColliderComponent*> colliders;
|
|
||||||
map_service.GetColliders(pos.x, pos.y, colliders);
|
|
||||||
for (ColliderComponent* collider : colliders) {
|
|
||||||
if (collider->IntersectEx(pos, &target_collider)) {
|
|
||||||
is_collision = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!is_collision) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user