void ChaseSensor::beginContact(b2Fixture* otherFixture) { sf::FloatRect bounds = BoxBounds::boundsOfFixture(otherFixture); if (otherFixture->GetBody()->GetType() == b2_dynamicBody && chaseVictim == nullptr) { setVictim(otherFixture, bounds); chasing = true; } }
MessageState SquadAttack::handleMessage(AbstractMessage* message) { if(message->isType("gameobject-destroyed")) { GameObject* victim = message->getPayload<GameObject*>(); if(_victim == victim) { if(!isEnabled()) { cout << "SquadAttack::handleMessage(): Good effort! Victim died without me attacking!" << endl; } else { cout << "SquadAttack::handleMessage(): Target down." << endl; } resetVictim(); return HANDLED; } } if(message->isType("victim-change-sync")) { Data data = message->getPayload<Data>(); UID::Type uid = data("victim-uid"); GameObject* victim = NetworkRegistry::get(uid); cout << "victim-change-sync" << endl; if(victim != nullptr) { setVictim(victim); } else { cout << "Not set, reverse lookup failed. " << endl; // Network might be out of sync or have a race condition. // That's no big deal. } return CONSUMED; } if(message->isType("victim-reset-sync")) { cout << "victim-reset-sync" << endl; resetVictim(); return CONSUMED; } return AIState::handleMessage(message); }