void BallStateAspect::UpdateGoalState() { // check both goal box collider RecorderHandler::TParentList ball; mLeftGoalRecorder->FindParentsSupportingClass<Ball>(ball); if (! ball.empty()) { mGoalState = TI_LEFT; } else { mRightGoalRecorder->FindParentsSupportingClass<Ball>(ball); if (! ball.empty()) { mGoalState = TI_RIGHT; } else { mGoalState = TI_NONE; } } mLeftGoalRecorder->Clear(); mRightGoalRecorder->Clear(); }
void BallStateAspect::UpdateCollidingAgents() { mCollidingWithLeftTeamAgent = false; mCollidingWithRightTeamAgent = false; mCollidingAgents = list<boost::shared_ptr<AgentAspect> >(); // get a list of agents that collided with the ball since the last // update of the recorder and remember the first returned node as // the last agent that collided with the ball. RecorderHandler::TParentList agents; mBallRecorder->FindParentsSupportingClass<AgentAspect>(agents); if (agents.size() > 0) { mLastCollidingAgent = static_pointer_cast<AgentAspect> (agents.front().lock()); mLastAgentCollisionTime = mGameState->GetTime(); for (RecorderHandler::TParentList::iterator it = agents.begin(); it != agents.end(); ++it) { boost::shared_ptr<oxygen::AgentAspect> agent = static_pointer_cast<AgentAspect>(it->lock()); boost::shared_ptr<AgentState> agentState; if (!SoccerBase::GetAgentState(agent, agentState)) { GetLog()->Error() << "ERROR: (SoccerRuleAspect) Cannot" " get AgentState from an AgentAspect\n"; } else { mCollidingAgents.push_back(agent); TTeamIndex team = agentState->GetTeamIndex(); if (team == TI_LEFT) { mCollidingWithLeftTeamAgent = true; } else if (team == TI_RIGHT) { mCollidingWithRightTeamAgent = true; } } } } // empty the recorder buffer mBallRecorder->Clear(); }
void BallStateAspect::UpdateLastCollidingAgent() { // get a list of agents that collided with the ball since the last // update of the recorder and remember the first returned node as // the last agent that collided with the ball. RecorderHandler::TParentList agents; mBallRecorder->FindParentsSupportingClass<AgentAspect>(agents); if (agents.size() > 0) { mLastCollidingAgent = shared_static_cast<AgentAspect> (agents.front().lock()); mLastAgentCollisionTime = mGameState->GetTime(); } // empty the recorder buffer mBallRecorder->Clear(); }