feat(entities): andamiatge del sistema d'entitats (classes, factory, bus, YAML, placeholders, smoke tests)
This commit is contained in:
1 parent
984cc820c0
commit
96b71b0f65
48 files changed
+1957
No files matched your search
@@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "external/fkyaml_node.hpp"
|
||||
#include "game/entities/animation_component.hpp"
|
||||
#include "game/entities/interactable.hpp"
|
||||
|
||||
// Porta de sortida del nivell. Tres estats:
|
||||
// CLOSED → inicial; bloqueja el pas.
|
||||
// OPENING → animació d'obertura en curs. Quan el component acaba →
|
||||
// transita a OPEN.
|
||||
// OPEN → accessible. Al contacte amb el jugador publica
|
||||
// `level_complete` al bus (si n'hi ha).
|
||||
//
|
||||
// El que decideix quan s'obri és extern (`EntityManager` comptant sarcs
|
||||
// oberts) via `open()`. L'animació `opening` es fa servir com a
|
||||
// temporitzador de transició (s'espera a `completed()`); si només té un
|
||||
// frame i és loop=false, es completa immediatament al següent tick.
|
||||
class Door : public Interactable {
|
||||
public:
|
||||
enum class State : std::uint8_t { CLOSED,
|
||||
OPENING,
|
||||
OPEN };
|
||||
|
||||
explicit Door(const fkyaml::node& yaml);
|
||||
|
||||
void update(float delta_time) override;
|
||||
void onPlayerContact(Player* player) override;
|
||||
|
||||
// Passa de CLOSED → OPENING. Idempotent: crides posteriors en estat
|
||||
// OPENING/OPEN són no-op.
|
||||
void open();
|
||||
|
||||
[[nodiscard]] auto getState() const -> State { return state_; }
|
||||
|
||||
private:
|
||||
void setAnimation(const AnimationComponent& anim);
|
||||
|
||||
State state_{State::CLOSED};
|
||||
bool level_complete_emitted_{false};
|
||||
|
||||
// Les 3 animacions precalculades al ctor des del YAML. L'activa
|
||||
// s'assigna a `anim_` (heretat d'Entity) segons l'estat.
|
||||
AnimationComponent anim_closed_;
|
||||
AnimationComponent anim_opening_;
|
||||
AnimationComponent anim_open_;
|
||||
};
|
||||
Reference in new issue
Block a user