First implementation of rules

TODO :
 - Fix target as getter (currently broken because of inheritance by rules)
 - Smart pointers for entity store ?
This commit is contained in:
Teo-CD 2019-06-09 23:26:46 +02:00
parent febe0827ad
commit 08e922b0d4
12 changed files with 257 additions and 20 deletions

View file

@ -45,21 +45,29 @@ public:
Entity(pro_maat::GridUnit x, pro_maat::GridUnit y, EntityType type, sf::Texture* texture, int width = 1,
int height = 1);
explicit Entity(const pugi::xml_node& entityNode, sf::Texture* texture);
virtual ~Entity() = default;
void move(Orientation orientation);
void update();
virtual void move(Orientation orientation);
virtual void update();
State getState() const;
virtual State getState() const;
const sf::RectangleShape& getShape() const;
virtual const sf::RectangleShape& getShape() const;
/// Returns the grid coordinates at the center of the entity
const pro_maat::GridPos getPosition() const;
virtual const pro_maat::GridPos getPosition() const;
// Don't like it : iterates over every square every tick
const std::vector<pro_maat::GridPos> getOccupiedSquares() const;
virtual const std::vector<pro_maat::GridPos> getOccupiedSquares() const;
// FIXME : Replace with getter
/// Position of the target of the current action on the map
pro_maat::GridPos target;
protected:
/// Empty constructor for derived class instanciation
Entity();
private:
static const std::map<std::string,EntityType> entityTypeLookup;
@ -75,6 +83,9 @@ private:
/// Used with rules : last to update has priority
pro_maat::GridPos nextTarget;
template<State targetState, EntityType targetType>
friend class Rule;
};