Peoplemon  0.1.0
Peoplemon 3 game source documentation
WanderBehavior.hpp
Go to the documentation of this file.
1 #ifndef CORE_COMPONENTS_WANDERBEHAVIOR_HPP
2 #define CORE_COMPONENTS_WANDERBEHAVIOR_HPP
3 
7 
8 namespace core
9 {
10 namespace component
11 {
19 public:
26  WanderBehavior(unsigned int radius, const sf::Vector2i& origin);
27 
35  void update(bl::tmap::Position& position, Controllable& controller, float dt);
36 
37 private:
38  struct WalkData {
39  bl::tmap::Direction dir;
40  unsigned short int total;
41  unsigned short int steps;
42 
43  WalkData();
44  };
45 
46  union Data {
47  WalkData walking;
48  StandingBehavior standing;
49  SpinBehavior spinning;
50 
51  Data();
52  } data;
53 
54  enum State : std::uint8_t {
55  Walking = 0,
56  Spinning = 1,
57  Standing = 2,
58  NUM_STATES = 2,
59  Paused = 3 // intentionally outside of possible states
60  };
61 
62  const sf::Vector2i origin;
63  const unsigned int radius;
64  State state;
65  float stateTime;
66  float transitionTime;
67 
68  void switchState();
69 };
70 
71 } // namespace component
72 } // namespace core
73 
74 #endif
Core classes and functionality for both the editor and game.
Adding this component to an entity allows it to be controlled.
Add this to an entity to make it spin in place.
AI behavior for standing in place facing a fixed direction.
Add this component to an entity to make it wander around.
WanderBehavior(unsigned int radius, const sf::Vector2i &origin)
Construct a new Wander Behavior component.
void update(bl::tmap::Position &position, Controllable &controller, float dt)
Updates the entity and wanders around.