bool HealthMessageHandlerSubSystem::ProcessPending( Message const& message ) { HealthMessage msg = static_cast<HealthMessage const&>( message ); Opt<Actor> actor = mScene.GetActor( msg.mActorGUID ); Opt<IHealthComponent> healthC = actor->Get<IHealthComponent>(); if ( !healthC.IsValid() ) { L1( "no health_component found guid:%s\n", msg.mActorGUID ); return true; } L1( "executing %s: actorGUID %d \n", __FUNCTION__, msg.mActorGUID ); healthC->SetHP( msg.mHP ); healthC->GetMaxHP().mBase.Set( msg.mMaxHP ); healthC->GetMaxHP().mPercent.Set( msg.mMaxHPPercent / PRECISION ); healthC->GetMaxHP().mFlat.Set( msg.mMaxHPFlat ); return true; }
void ExplodeOnHitSystem::Update( double DeltaTime ) { for( auto actor : mScene.GetActorsFromMap( GetType_static() ) ) { Opt<IExplodeOnHitComponent> explodeOnHitC = actor->Get<IExplodeOnHitComponent>(); if ( !explodeOnHitC.IsValid() || !explodeOnHitC->IsExploded() ) { continue; } WeaponItemSubSystem::Projectiles_t projectiles; ExplodeOnDeathSystem::FillExplosionProjectiles( *explodeOnHitC.Get(), *actor, projectiles ); Scatter scatter; WeaponItemSubSystem::Get()->AddProjectiles( *actor, projectiles, scatter ); Opt<IHealthComponent> healthC = actor->Get<IHealthComponent>(); if( healthC.IsValid() ) { healthC->SetHP( 0 ); } } }
void ExplodeOnHitSystem::Update( double DeltaTime ) { for( ActorList_t::iterator it = mScene.GetActors().begin(), e = mScene.GetActors().end(); it != e; ++it ) { Actor& actor = **it; Opt<IExplodeOnHitComponent> explodeOnHitC = actor.Get<IExplodeOnHitComponent>(); if ( !explodeOnHitC.IsValid() || !explodeOnHitC->IsExploded() ) { continue; } WeaponItemSubSystem::Projectiles_t projectiles; ExplodeOnDeathSystem::FillExplosionProjectiles( *explodeOnHitC.Get(), actor, projectiles ); Scatter scatter; WeaponItemSubSystem::Get()->AddProjectiles( actor, projectiles, scatter ); Opt<IHealthComponent> healthC = actor.Get<IHealthComponent>(); if( healthC.IsValid() ) { healthC->SetHP( 0 ); } } }