コード例 #1
0
void playDelegate::preRender(void)
{
   if(!gameActive)
      return;

   // try to find a new palette to set in the game:
   if(!currentPalette)
   {
      SimGroup *group = (SimGroup *) manager->findObject("GhostGroup");
      if(group)
      {
         SimGroup::iterator i;
         for(i = group->begin(); i != group->end(); i++)
         {
            SimPalette *pal = dynamic_cast<SimPalette *>(*i);
            if(pal)
            {
               currentPalette = pal;
               deleteNotify(pal);
               hPal = pal->getPalette();
               pal->setInGame();
               break;
            }
         }  
      }
   }
}
コード例 #2
0
ファイル: VSoundEffect.cpp プロジェクト: AnteSim/Verve
VTorque::SoundSourceType *VTorque::playSound( SoundEffectType *pSoundProfile, SceneObjectType *pObject, const U32 &pPosition, const F32 &pPitch )
{
    if ( !pSoundProfile )
    {
        // Sanity!
        return NULL;
    }

#ifdef VT_EDITOR

    // Fetch Reference Transform.
    const MatrixF &transform = pObject->getTransform();

    // Play Sound.
    SFXSound *source = ( SFXSound* )SFX->playOnce( pSoundProfile, &transform );

    if ( source )
    {
        // Set Position.
        source->setPosition( pPosition );

        // Set Pitch.
        source->setPitch( pPitch );
    }

    // Return Source.
    return source;

#else

    // Fetch Client Group.
    SimGroup* clientGroup = Sim::getClientGroup();

    for ( SimGroup::iterator itr = clientGroup->begin(); itr != clientGroup->end(); itr++ )
    {
        NetConnection *connection = static_cast<NetConnection*>( *itr );
        if ( connection )
        {
            // Create Event.
            VSoundEffectNetEvent *event = new VSoundEffectNetEvent();

            // Setup Event.
            event->mProfile   = pSoundProfile;
            event->mPosition  = pPosition;
            event->mPitch     = pPitch;
            event->mIs3D      = true;
            event->mTransform = pObject->getTransform();

            // Post Event.
            connection->postNetEvent( event );
        }
    }

    return NULL;

#endif
}
コード例 #3
0
ファイル: VPostEffect.cpp プロジェクト: AnteSim/Verve
void VTorque::setPostEffectOn( PostEffectType *pPostEffect, const bool &pStatus )
{
    if ( !pPostEffect )
    {
        // Sanity!
        return;
    }

#ifdef VT_EDITOR

    if ( pStatus )
    {
        // Enable Effect.
        pPostEffect->enable();
    }
    else
    {
        // Disable Effect.
        pPostEffect->disable();
    }

#else

    // Fetch Name.
    StringTableEntry name = pPostEffect->getName();
    if ( !name || name == StringTable->insert( "" ) )
    {
        Con::warnf( "VTorque::setPostEffectOn() - Invalid Object Name." );
        return;
    }

    // Fetch Client Group.
    SimGroup* clientGroup = Sim::getClientGroup();

    for ( SimGroup::iterator itr = clientGroup->begin(); itr != clientGroup->end(); itr++ )
    {
        NetConnection *connection = static_cast<NetConnection*>( *itr );
        if ( connection )
        {
            // Create Event.
            VPostEffectNetEvent *event = new VPostEffectNetEvent();

            // Setup Event.
            event->mPostEffect = name;
            event->mEnabled    = pStatus;

            // Post Event.
            connection->postNetEvent( event );
        }
    }

#endif
}
コード例 #4
0
void Lightning::warningFlashes()
{
   AssertFatal(isServerObject(), "Error, client objects may not initiate lightning!");


   SimGroup* pClientGroup = Sim::getClientGroup();
   for (SimGroup::iterator itr = pClientGroup->begin(); itr != pClientGroup->end(); itr++) {
      NetConnection* nc = static_cast<NetConnection*>(*itr);
      if (nc != NULL)
      {
         LightningStrikeEvent* pEvent = new LightningStrikeEvent;
         pEvent->mLightning = this;

         nc->postNetEvent(pEvent);
      }
   }
}
コード例 #5
0
ファイル: VCamera.cpp プロジェクト: 7Sins/Verve
void VTorque::setCamera( SceneObjectType *pObject )
{
    // Fetch Game Base.
    GameBase *object = dynamic_cast<GameBase*>( pObject );

    // Fetch Client Group.
    SimGroup* clientGroup = Sim::getClientGroup();

    for ( SimGroup::iterator itr = clientGroup->begin(); itr != clientGroup->end(); itr++ )
    {
        GameConnection *connection = dynamic_cast<GameConnection*>( *itr );
        if ( connection )
        {
            // Set Camera Object.
            connection->setCameraObject( object );
        }
    }
}
コード例 #6
0
ファイル: stdGameProcess.cpp プロジェクト: andr3wmac/Torque6
void StdServerProcessList::advanceObjects()
{
   #ifdef TORQUE_DEBUG_NET_MOVES
   Con::printf("Advance server time...");
   #endif

   Parent::advanceObjects();

   // Credit all connections with the elapsed tick
   SimGroup *clientGroup = Sim::getClientGroup();
   for(SimGroup::iterator i = clientGroup->begin(); i != clientGroup->end(); i++)
   {
      if (GameConnection *con = dynamic_cast<GameConnection *>(*i))
      {
         con->mMoveList->advanceMove();
      }
   }

   #ifdef TORQUE_DEBUG_NET_MOVES
   Con::printf("---------");
   #endif
}
コード例 #7
0
void Lightning::strikeRandomPoint()
{
   AssertFatal(isServerObject(), "Error, client objects may not initiate lightning!");


   Point3F strikePoint( gRandGen.randF( 0.0f, 1.0f ), gRandGen.randF( 0.0f, 1.0f ), 0.0f );

   // check if an object is within target range

   strikePoint *= mObjScale;
   strikePoint += getPosition();
   strikePoint += Point3F( -mObjScale.x * 0.5f, -mObjScale.y * 0.5f, 0.0f );

   Box3F queryBox;
   F32 boxWidth = strikeRadius * 2.0f;

   queryBox.minExtents.set( -boxWidth * 0.5f, -boxWidth * 0.5f, -mObjScale.z * 0.5f );
   queryBox.maxExtents.set(  boxWidth * 0.5f,  boxWidth * 0.5f,  mObjScale.z * 0.5f );
   queryBox.minExtents += strikePoint;
   queryBox.maxExtents += strikePoint;

   SimpleQueryList sql;
   getContainer()->findObjects(queryBox, DAMAGEABLE_TYPEMASK,
                               SimpleQueryList::insertionCallback, &sql);

   SceneObject *highestObj = NULL;
   F32 highestPnt = 0.0f;

   for( U32 i = 0; i < sql.mList.size(); i++ )
   {
      Point3F objectCenter;
      sql.mList[i]->getObjBox().getCenter(&objectCenter);
      objectCenter.convolve(sql.mList[i]->getScale());
      sql.mList[i]->getTransform().mulP(objectCenter);

      // check if object can be struck

      RayInfo rayInfo;
      Point3F start = objectCenter;
      start.z = mObjScale.z * 0.5f + getPosition().z;
      Point3F end = objectCenter;
      end.z = -mObjScale.z * 0.5f + getPosition().z;
      bool rayHit = gServerContainer.castRay( start, end,
                                   (0xFFFFFFFF),
                                   &rayInfo);

      if( rayHit && rayInfo.object == sql.mList[i] )
      {
         if( !highestObj )
         {
            highestObj = sql.mList[i];
            highestPnt = objectCenter.z;
            continue;
         }

         if( objectCenter.z > highestPnt )
         {
            highestObj = sql.mList[i];
            highestPnt = objectCenter.z;
         }
      }


   }

   // hah haaaaa, we have a target!
   SceneObject *targetObj = NULL;
   if( highestObj )
   {
      F32 chance = gRandGen.randF();
      if( chance <= chanceToHitTarget )
      {
         Point3F objectCenter;
         highestObj->getObjBox().getCenter(&objectCenter);
         objectCenter.convolve(highestObj->getScale());
         highestObj->getTransform().mulP(objectCenter);

         bool playerInWarmup = false;
         Player *playerObj = dynamic_cast< Player * >(highestObj);
         if( playerObj )
         {
            if( !playerObj->getControllingClient() )
            {
               playerInWarmup = true;
            }
         }

         if( !playerInWarmup )
         {
            applyDamage_callback( objectCenter, VectorF( 0.0f, 0.0f, 1.0f ), highestObj );
            targetObj = highestObj;
         }
      }
   }

   SimGroup* pClientGroup = Sim::getClientGroup();
   for (SimGroup::iterator itr = pClientGroup->begin(); itr != pClientGroup->end(); itr++)
   {
      NetConnection* nc = static_cast<NetConnection*>(*itr);

      LightningStrikeEvent* pEvent = new LightningStrikeEvent;
      pEvent->mLightning = this;

      pEvent->mStart.x = strikePoint.x;
      pEvent->mStart.y = strikePoint.y;
      pEvent->mTarget = targetObj;

      nc->postNetEvent(pEvent);
   }


}