Refactor the entity out.

This commit is contained in:
Zed A. Shaw 2024-10-02 17:29:49 -04:00
parent cac7017563
commit a7f6357e12
6 changed files with 126 additions and 111 deletions

33
entity.hpp Normal file
View file

@ -0,0 +1,33 @@
#pragma once
#include "fsm.hpp"
#include "map.hpp"
enum class EntityState {
START, HUNTING, DEAD
};
enum class EntityEvent {
GO, HIT
};
class Entity : public DeadSimpleFSM<EntityState, EntityEvent> {
public:
Point location;
int hp = 20;
int damage = 10;
Entity(Point loc) : location(loc) {
};
// disable copy
Entity(Entity &e) = delete;
void move(Point loc);
void event(EntityEvent ev);
// states
void START(EntityEvent ev);
void HUNTING(EntityEvent ev);
void DEAD(EntityEvent ev);
};