void ComponentObjectApproachable::update(float) { ASSERT(world, "World has not been set yet"); const ActorSet &players = world->players; for (ActorSet::const_iterator i=players.begin(); i!=players.end(); ++i) { ActorPtr player = i->second; if (player->hasComponent("Physics")) { shared_ptr<Component> component; shared_ptr<ComponentPhysics> physics; component = player->getComponent("Physics"); physics = dynamic_pointer_cast<ComponentPhysics>(component); if (physics) { const float distance = vec3((physics->getPosition())-lastReportedPosition).getMagnitude(); const ActorID id = player->getUID(); if (distance <= thresholdTrigger) { playerApproaches(id); } else if (distance > thresholdRelease) { playerRecedes(id); } } } } }
DeathBehavior ComponentRenderAsModel::getDeathBehavior() const { DeathBehavior db = Disappear; ActorPtr actor = getActorPtr(); const ComponentDeathBehavior* c = dynamic_cast<const ComponentDeathBehavior*>(actor->getComponent("DeathBehavior")); if(c!=0) { db = c->getDeathBehavior(); } return db; }
DeathBehavior ComponentHealth::getDeathBehavior() const { ActorPtr actor = getActorPtr(); const ComponentDeathBehavior* c = dynamic_cast<const ComponentDeathBehavior*>(actor->getComponent("DeathBehavior")); if(c==0) { return Disappear; } else { return c->getDeathBehavior(); } }