Exemplo n.º 1
0
std::auto_ptr<Actor> SoldierSpawnTarget::GetCursor()
{
    std::auto_ptr<Actor> player( ActorFactory::Get()( mCursorId ) );
    Opt<IMoveComponent> moveC( player->Get<IMoveComponent>() );
    moveC->SetMoving( false );
    return player;
}
void WeaponItemSubSystem::AddProjectiles( Actor& actor, Projectiles_t& projectiles, Scatter& scatter, bool alt/*=false*/ )
{
    double actorOrientation = actor.Get<IPositionComponent>()->GetOrientation();
    int scat = int( scatter.GetCalculated() * 1000 );
    if( scat )
    {
        double realScatter = ( RandomGenerator::global()() % ( scat + 1 ) - scat / 2. );
        L2( "realScatter:%f\n", realScatter );
        actorOrientation += ( RandomGenerator::global()() % ( scat + 1 ) - scat / 2. ) * 0.001 * boost::math::double_constants::pi;
    }

    L2( "calculated and updated scatter:%f\n", scatter.GetCalculated() );
    Opt<IPositionComponent> actorPositionC = actor.Get<IPositionComponent>();
    for( Projectiles_t::iterator i = projectiles.begin(), e = projectiles.end(); i != e; ++i )
    {
        Actor& Proj = **i;
        SetProjectilePosition( Proj, actor );
        Opt<ShotCollisionComponent> shotCC = Proj.Get<ICollisionComponent>();
        if ( shotCC.IsValid() )
        {
            shotCC->SetParentGUID( actor.GetGUID() );
        }
        Opt<IOwnerComponent> ownerC = Proj.Get<IOwnerComponent>();
        if ( ownerC.IsValid() && ownerC->GetOwnerGUID() == -1 ) //if proj owner is set, then not the given actor is the owner
        {
            ownerC->SetOwnerGUID( actor.GetGUID() );
        }

        Opt<IPositionComponent> projPositionC = Proj.Get<IPositionComponent>();
        projPositionC->SetOrientation( projPositionC->GetOrientation() + actorOrientation );
        Opt<IMoveComponent> moveC( Proj.Get<IMoveComponent>() );
        if ( moveC.IsValid() )
        {
            moveC->SetHeading( projPositionC->GetOrientation() );
        }
        mScene.AddActor( &Proj );
    }
}