This commit is contained in:
aozhiwei 2019-03-28 19:17:44 +08:00
parent edefe4189e
commit 23e9ef0af5
4 changed files with 15 additions and 1 deletions

View File

@ -30,6 +30,7 @@ enum EntitySubType_e
};
class Room;
class Obstacle;
class ColliderComponent;
class MovementComponent;
class Entity
@ -45,6 +46,8 @@ class Entity
std::list<ColliderComponent*> colliders;
bool deleted = false;
Obstacle* last_collision_door = nullptr;
Entity() {};
virtual ~Entity();
virtual void Initialize() {};

View File

@ -14,6 +14,7 @@ struct HumanFrameData
};
class CircleCollider;
class Obstacle;
class Human : public Entity
{
public:

View File

@ -96,6 +96,9 @@ void Player::UpdateMove()
break;
}
}
if (last_collision_door && !TestCollision(last_collision_door)) {
last_collision_door = nullptr;
}
}
void Player::UpdateShot()
@ -193,6 +196,11 @@ void Player::ObstacleInteraction(Obstacle* entity)
for (auto& pair : room->human_hash_) {
pair.second->new_objects.insert(entity);
pair.second->part_objects.insert(entity);
if (entity->TestCollision(pair.second)) {
pair.second->last_collision_door = entity;
} else if (pair.second->last_collision_door == entity) {
pair.second->last_collision_door = nullptr;
}
}
}
}

View File

@ -285,7 +285,9 @@ void Room::CollisionDetection(Entity* sender, int detection_flags, std::vector<E
}
if (a8::HasBitFlag(detection_flags, ET_Obstacle) && pair.second->entity_type == ET_Obstacle) {
if (sender->entity_type == ET_Bullet || sender->entity_type == ET_Player) {
if (pair.second != sender && sender->TestCollision(pair.second)) {
if (pair.second != sender &&
(sender->last_collision_door == nullptr || sender->last_collision_door != pair.second) &&
sender->TestCollision(pair.second)) {
objects.push_back(pair.second);
}
}