Steeriously  0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
FleeComponent.hpp
1 #ifndef FleeComponent_HPP
2 #define FleeComponent_HPP
3 
4 #include <steeriously/Agent.hpp>
5 #include <steeriously/BehaviorData.hpp>
6 #include <steeriously/BehaviorHelpers.hpp>
7 #include <steeriously/Vector2.hpp>
8 
9 namespace steer
10 {
16  class FleeComponent : public steer::Agent
17  {
18  public:
20  virtual ~FleeComponent();
21 
27  void setWeight(const float weight) { m_weightFlee = weight; };
28 
33  float getWeight()const { return m_weightFlee; };
34 
39  void setRotation(float r) { m_rotation = r; };
40 
45  float getRotation() { return m_rotation; };
46 
47  //pure virtual - must implement see Agent.hpp
48  virtual bool on(steer::behaviorType behavior){return (m_iFlags & behavior) == behavior;};
49 
50  void fleeOn(){m_iFlags |= steer::behaviorType::flee;};
51 
52  bool isFleeOn(){return on(steer::behaviorType::flee);};
53  void fleeOff(){if(on(steer::behaviorType::flee)) m_iFlags ^=steer::behaviorType::flee;}
54 
55  //pure virtual - must implement see Agent.hpp
56  virtual Vector2 Calculate();
57 
58  void Update(float dt);
59 
60  private:
61  float m_weightFlee;
62  Uint32 m_iFlags;
63  float m_rotation;
64  };
65 }
66 
67 #endif // FleeComponent_HPP