1 #ifndef FlockingComponent_HPP
2 #define FlockingComponent_HPP
4 #include <steeriously/Agent.hpp>
5 #include <steeriously/SphereObstacle.hpp>
6 #include <steeriously/Wall.hpp>
25 void Update(
float dt);
33 void setNeighbors(std::vector<FlockingComponent*>* n) { m_neighbors = n; };
34 std::vector<FlockingComponent*>* getNeighbors() {
return m_neighbors; };
36 void setObstacles(std::vector<SphereObstacle*>* o) { m_obstacles = o; };
37 std::vector<SphereObstacle*>* getObstacles() {
return m_obstacles; };
39 void setWalls(std::vector<Wall*>* w) { m_walls = w; };
40 std::vector<Wall*>* getWalls() {
return m_walls; };
45 void alignmentOn() { m_iFlags |= steer::behaviorType::alignment; };
46 void separationOn() { m_iFlags |= steer::behaviorType::separation; };
47 void cohesionOn() { m_iFlags |= steer::behaviorType::cohesion; };
48 void seekOn() { m_iFlags |= steer::behaviorType::seek; };
49 void wanderOn() { m_iFlags |= steer::behaviorType::wander; };
50 void wallAvoidanceOn() { m_iFlags |= steer::behaviorType::wallAvoidance; };
51 void obstacleAvoidanceOn() { m_iFlags |= steer::behaviorType::obstacleAvoidance; };
53 void cohesionOff() {
if (
on(steer::behaviorType::cohesion)) m_iFlags ^= steer::behaviorType::cohesion; };
54 void separationOff() {
if (
on(steer::behaviorType::separation)) m_iFlags ^= steer::behaviorType::separation; };
55 void alignmentOff() {
if (
on(steer::behaviorType::alignment)) m_iFlags ^= steer::behaviorType::alignment; };
56 void seekOff() {
if (
on(steer::behaviorType::seek)) m_iFlags ^= steer::behaviorType::seek; };
57 void wanderOff() {
if (
on(steer::behaviorType::wander)) m_iFlags ^= steer::behaviorType::wander; };
58 void wallAvoidanceOff() {
if (
on(steer::behaviorType::wallAvoidance)) m_iFlags ^= steer::behaviorType::wallAvoidance; };
59 void obstacleAvoidanceOff() {
if (
on(steer::behaviorType::obstacleAvoidance)) m_iFlags ^= steer::behaviorType::obstacleAvoidance; };
61 bool isCohesionOn() {
return on(steer::behaviorType::cohesion); };
62 bool isSeparationOn() {
return on(steer::behaviorType::separation); };
63 bool isAlignmentOn() {
return on(steer::behaviorType::alignment); };
64 bool isSeekOn() {
return on(steer::behaviorType::seek); };
65 bool isWanderOn() {
return on(steer::behaviorType::wander); };
66 bool isWallAvoidanceOn() {
return on(steer::behaviorType::wallAvoidance); };
67 bool isObstacleAvoidanceOn() {
return on(steer::behaviorType::obstacleAvoidance); };
68 bool isFlockingOn() {
return isCohesionOn() && isAlignmentOn() && isSeparationOn() && isSeekOn() && isWanderOn() && isWallAvoidanceOn() && isObstacleAvoidanceOn(); };
78 obstacleAvoidanceOn();
89 obstacleAvoidanceOff();
92 bool targetAcquired();
98 virtual Vector2 calculateWeightedSum()
override;
102 float m_weightWander;
103 float m_weightAlignment;
104 float m_weightSeparation;
105 float m_weightCohesion;
106 float m_weightObstacleAvoidance;
107 float m_weightWallAvoidance;
110 std::vector<FlockingComponent*>* m_neighbors;
111 std::vector<SphereObstacle*>* m_obstacles;
112 std::vector<Wall*>* m_walls;
117 #endif // FlockingComponent_HPP