// // Created by trotfunky on 09/06/19. // #ifndef PROJECT_MAAT_RULES_H #define PROJECT_MAAT_RULES_H #include #include #include #include #include "Entity.h" /// Decorates entities with rules which will modify its behaviour class Rule : public Entity { public: // The Rule object takes ownership of the Entity* Rule(std::shared_ptr entity, State targetState, EntityType targetType, const std::vector>& entities, const std::vector& occupiedSquares, const pro_maat::GridPos& mapSize); /// Update according to the targetState and targetType void update() override; // Simply delegate the following function calls to the original entity void move(Orientation orientation) override; State getState() const override; EntityType getType() const override; const sf::RectangleShape& getShape() const override; pro_maat::GridPos getTarget() const override; const pro_maat::GridPos getPosition() const override; const std::vector getOccupiedSquares() const override; private: /// Finds the closest free square adjacent to the closest target entity type. /// Currently not thread-safe ! /// \return Suitable target square or current position if none was found. pro_maat::GridPos findTarget(); std::shared_ptr entity; const State targetState; const EntityType targetType; const std::vector>& entities; const std::vector& occupiedSquares; const pro_maat::GridPos& mapSize; }; #endif //PROJECT_MAAT_RULES_H