本文整理汇总了C++中NetConnection::postNetEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ NetConnection::postNetEvent方法的具体用法?C++ NetConnection::postNetEvent怎么用?C++ NetConnection::postNetEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetConnection
的用法示例。
在下文中一共展示了NetConnection::postNetEvent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VSoundEffectNetEvent
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
}
示例2: setPostEffectOn
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
}
示例3: warningFlashes
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);
}
}
}
示例4: strikeRandomPoint
//.........这里部分代码省略.........
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);
}
}