Hole don't kill instantly anymore

This commit is contained in:
Askou
2021-06-18 14:47:09 +02:00
parent 387734b7c5
commit a7f1c9da30
+9 -3
View File
@@ -39,10 +39,16 @@ namespace BBM
CollisionComponent::CollidedAxis collidedAxis)
{
auto *health = entity.tryGetComponent<HealthComponent>();
auto *movable = entity.tryGetComponent<MovableComponent>();
auto *wallPos = wall.tryGetComponent<PositionComponent>();
auto *entityPos = entity.tryGetComponent<PositionComponent>();
if (!health)
if (!health || !movable || !wallPos)
return;
health->takeDmg(health->getHealthPoint());
if (entityPos->position.distance(wallPos->position) < 0.3)
health->takeDmg(health->getHealthPoint());
else
movable->addForce((wallPos->position - entityPos->position) * 0.02);
}
void MapGenerator::wallCollision(WAL::Entity &entity,
@@ -336,7 +342,7 @@ namespace BBM
if (rnd > 0.98 && !hasHeight)
return HOLE;
if ((!hasHeight && rnd > 0.25) || rnd > 0.7)
return BREAKABLE;
return NOTHING;
return NOTHING;
}