feat(hazard): afegeix estat SPAWN a DynamicHazard
DynamicHazard guanya un mecanisme de SPAWN amb dues fases: SPAWNING (visible, sense moviment ni dany, comptador en pausa) i ACTIVE (lògica normal). `enterSpawn(duration_s)` deixa l'entitat congelada esperant indefinidament; `triggerSpawnExit()` arma el comptador i, en arribar a zero, transita a ACTIVE. Per defecte les noves DynamicHazard arrenquen en ACTIVE — backward-compat amb subclasses existents (RollingRock) que encara no usen el mecanisme. EntityManager::checkPlayerCollisions salta DynamicHazards en SPAWN: no disparen onPlayerContact, així no fan dany ni triggers durant la fase. Aquest commit només afegeix la infraestructura — cap subclasse l'usa encara, comportament del joc inalterat. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
b7811180ba
commit
a6b2b02930
2 files changed
+51
No files matched your search
@@ -18,6 +18,7 @@
|
||||
#include "game/entities/entity_factory.hpp"
|
||||
#include "game/entities/entity_loader.hpp"
|
||||
#include "game/entities/entity_manager.hpp"
|
||||
#include "game/entities/hazard.hpp"
|
||||
#include "game/entities/player.hpp"
|
||||
#include "game/map/map.hpp"
|
||||
#include "utils/defaults.hpp"
|
||||
@@ -68,6 +69,10 @@ void EntityManager::checkPlayerCollisions(const std::vector<Player*>& players) {
|
||||
// mai no es disparaven) i obrim la porta a hazards no-físics
|
||||
// com `Hole`.
|
||||
if (!entity->collides() && !entity->triggersOnOverlap()) { continue; }
|
||||
// DynamicHazard en SPAWN: visible però "no juga" — no dispara
|
||||
// onPlayerContact, així no fa dany ni triggers durant la fase
|
||||
// inicial de ROOM_INTRO (o futurs spawns en runtime).
|
||||
if (const auto* dh = dynamic_cast<const DynamicHazard*>(entity.get()); dh != nullptr && dh->isSpawning()) { continue; }
|
||||
const auto BOX = entity->getCollisionRect();
|
||||
const int E_HEIGHT = entity->getHeight();
|
||||
for (auto* p : players) {
|
||||
|
||||
Reference in new issue
Block a user