Преглед на файлове

Made CrowdAgent emit events from the attached Node as well as the
associated CrowdManager, to allow for simpler reaction of other
components on the same Node to crowd agent events.

Nick Royer преди 10 години
родител
ревизия
35ee321408
променени са 1 файла, в които са добавени 6 реда и са изтрити 0 реда
  1. 6 0
      Source/Urho3D/Navigation/CrowdAgent.cpp

+ 6 - 0
Source/Urho3D/Navigation/CrowdAgent.cpp

@@ -290,6 +290,9 @@ int CrowdAgent::AddAgentToCrowd(bool force)
             map[P_POSITION] = GetPosition();
             map[P_POSITION] = GetPosition();
             map[P_VELOCITY] = GetActualVelocity();
             map[P_VELOCITY] = GetActualVelocity();
             crowdManager_->SendEvent(E_CROWD_AGENT_FAILURE, map);
             crowdManager_->SendEvent(E_CROWD_AGENT_FAILURE, map);
+            Node* node = GetNode();
+            if (node)
+                node->SendEvent(E_CROWD_AGENT_FAILURE, map);
 
 
             // Reevaluate states as handling of event may have resulted in changes
             // Reevaluate states as handling of event may have resulted in changes
             previousAgentState_ = GetAgentState();
             previousAgentState_ = GetAgentState();
@@ -526,6 +529,7 @@ void CrowdAgent::OnCrowdUpdate(dtCrowdAgent* ag, float dt)
             map[P_ARRIVED] = HasArrived();
             map[P_ARRIVED] = HasArrived();
             map[P_TIMESTEP] = dt;
             map[P_TIMESTEP] = dt;
             crowdManager_->SendEvent(E_CROWD_AGENT_REPOSITION, map);
             crowdManager_->SendEvent(E_CROWD_AGENT_REPOSITION, map);
+            node_->SendEvent(E_CROWD_AGENT_REPOSITION, map);
 
 
             if (updateNodePosition_)
             if (updateNodePosition_)
             {
             {
@@ -550,6 +554,7 @@ void CrowdAgent::OnCrowdUpdate(dtCrowdAgent* ag, float dt)
             map[P_POSITION] = newPos;
             map[P_POSITION] = newPos;
             map[P_VELOCITY] = newVel;
             map[P_VELOCITY] = newVel;
             crowdManager_->SendEvent(E_CROWD_AGENT_STATE_CHANGED, map);
             crowdManager_->SendEvent(E_CROWD_AGENT_STATE_CHANGED, map);
+            node_->SendEvent(E_CROWD_AGENT_STATE_CHANGED, map);
 
 
             // Send a failure event if either state is a failed status
             // Send a failure event if either state is a failed status
             if (newAgentState == CA_STATE_INVALID || newTargetState == CA_TARGET_FAILED)
             if (newAgentState == CA_STATE_INVALID || newTargetState == CA_TARGET_FAILED)
@@ -562,6 +567,7 @@ void CrowdAgent::OnCrowdUpdate(dtCrowdAgent* ag, float dt)
                 map[P_POSITION] = newPos;
                 map[P_POSITION] = newPos;
                 map[P_VELOCITY] = newVel;
                 map[P_VELOCITY] = newVel;
                 crowdManager_->SendEvent(E_CROWD_AGENT_FAILURE, map);
                 crowdManager_->SendEvent(E_CROWD_AGENT_FAILURE, map);
+                node_->SendEvent(E_CROWD_AGENT_FAILURE, map);
             }
             }
 
 
             // State may have been altered during the handling of the event
             // State may have been altered during the handling of the event