small cleanup

This commit is contained in:
h4570
2022-08-17 01:02:57 +02:00
parent fea2398699
commit 2e41332dca
9 changed files with 37 additions and 29 deletions
+8 -5
View File
@@ -11,13 +11,13 @@
#include "states/game/enemy/enemy.hpp"
#include <functional>
using Tyra::Color;
using Tyra::Math;
namespace Demo {
Enemy::Enemy(Engine* engine, const EnemyInfo& t_info) {
info = t_info;
utility = &engine->renderer.renderer3D.utility;
mesh = new DynamicMesh(*info.motherMesh);
@@ -87,20 +87,23 @@ void Enemy::update(const Heightmap& heightmap, const Vec4& playerPosition,
}
void Enemy::handlePlayerShoot(const PlayerShootAction& shootAction) {
if (!shootAction.isShooting) {
return;
}
// if (!shootAction.isShooting) {
// return;
// }
const auto& ray = shootAction.ray.value();
auto bbox =
mesh->getCurrentBoundingBox().getTransformed(mesh->getModelMatrix());
auto isOnEnemy = ray.intersectBox(bbox.min(), bbox.max());
float length = -1.0F;
auto isOnEnemy = ray.intersectBox(bbox.min(), bbox.max(), &length);
if (isOnEnemy) {
mesh->setPosition(spawnPoint);
TYRA_LOG("Enemy hit!");
} else {
if (length != -1.0F) TYRA_LOG("Distance: ", length);
}
}