Refactor the entity out.
This commit is contained in:
parent
cac7017563
commit
a7f6357e12
6 changed files with 126 additions and 111 deletions
33
entity.hpp
Normal file
33
entity.hpp
Normal 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);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue