本文整理汇总了C++中CClientEntity类的典型用法代码示例。如果您正苦于以下问题:C++ CClientEntity类的具体用法?C++ CClientEntity怎么用?C++ CClientEntity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CClientEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetElementDimension
void CElementRPCs::SetElementDimension ( NetBitStreamInterface& bitStream )
{
ElementID ID;
unsigned short usDimension;
if ( bitStream.Read ( ID ) && bitStream.Read ( usDimension ) )
{
CClientEntity* pEntity = CElementIDs::GetElement ( ID );
if ( pEntity )
{
if ( pEntity->GetType () == CCLIENTTEAM )
{
CClientTeam* pTeam = static_cast < CClientTeam* > ( pEntity );
list < CClientPlayer* > ::const_iterator iter = pTeam->IterBegin ();
for ( ; iter != pTeam->IterEnd () ; iter++ )
{
CClientPlayer* pPlayer = *iter;
if ( pPlayer->IsLocalPlayer () )
{
// Update all of our streamers/managers to the local player's dimension
m_pClientGame->SetAllDimensions ( usDimension );
}
pPlayer->SetDimension ( usDimension );
}
}
else
{
if ( pEntity->GetType () == CCLIENTPLAYER )
{
CClientPlayer* pPlayer = static_cast < CClientPlayer* > ( pEntity );
if ( pPlayer->IsLocalPlayer () )
{
// Update all of our streamers/managers to the local player's dimension
m_pClientGame->SetAllDimensions ( usDimension );
}
}
pEntity->SetDimension ( usDimension );
}
}
}
}
示例2: Callback_OnLeave
void CClientMarker::Callback_OnLeave ( CClientColShape& Shape, CClientEntity& Entity )
{
if ( IS_PLAYER ( &Entity ) )
{
// Call the marker hit event
CLuaArguments Arguments;
Arguments.PushElement ( &Entity ); // player that hit it
Arguments.PushBoolean ( ( Shape.GetDimension () == Entity.GetDimension () ) ); // matching dimension?
CallEvent ( "onClientMarkerLeave", Arguments, true );
}
}
示例3: SetElementName
void CElementRPCs::SetElementName ( NetBitStreamInterface& bitStream )
{
ElementID ID;
unsigned short usNameLength;
if ( bitStream.Read ( ID ) && bitStream.Read ( usNameLength ) )
{
char* szName = new char [ usNameLength + 1 ];
szName [ usNameLength ] = 0;
if ( bitStream.Read ( szName, usNameLength ) )
{
CClientEntity* pEntity = CElementIDs::GetElement ( ID );
if ( pEntity )
{
pEntity->SetName ( szName );
}
}
delete [] szName;
}
}
示例4: AddEventHandler
int CLuaFunctionDefs::AddEventHandler ( lua_State* luaVM )
{
// bool addEventHandler ( string eventName, element attachedTo, function handlerFunction, [bool getPropagated = true] )
SString strName; CClientEntity* pEntity; CLuaFunctionRef iLuaFunction; bool bPropagated;
CScriptArgReader argStream ( luaVM );
argStream.ReadString ( strName );
argStream.ReadUserData ( pEntity );
argStream.ReadFunction ( iLuaFunction );
argStream.ReadBool ( bPropagated, true );
argStream.ReadFunctionComplete ();
if ( !argStream.HasErrors () )
{
// Grab our virtual machine
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
if ( pLuaMain )
{
// Check if the handle is in use
if ( pEntity->GetEventManager()->HandleExists ( pLuaMain, strName, iLuaFunction ) )
{
m_pScriptDebugging->LogCustom ( luaVM, 255, 0, 0, "addEventHandler: '%s' with this function is already handled", *strName );
lua_pushboolean ( luaVM, false );
return 1;
}
// Do it
if ( CStaticFunctionDefinitions::AddEventHandler ( *pLuaMain, strName, *pEntity, iLuaFunction, bPropagated ) )
{
lua_pushboolean ( luaVM, true );
return 1;
}
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, SString ( "Bad argument @ '%s' [%s]", "addEventHandler", *argStream.GetErrorMessage () ) );
// Failed
lua_pushboolean ( luaVM, false );
return 1;
}
示例5: AttachElements
void CElementRPCs::AttachElements ( NetBitStreamInterface& bitStream )
{
ElementID ID, usAttachedToID;
CVector vecPosition, vecRotation;
if ( bitStream.Read ( ID ) && bitStream.Read ( usAttachedToID ) &&
bitStream.Read ( vecPosition.fX ) &&
bitStream.Read ( vecPosition.fY ) &&
bitStream.Read ( vecPosition.fZ ) &&
bitStream.Read ( vecRotation.fX ) &&
bitStream.Read ( vecRotation.fY ) &&
bitStream.Read ( vecRotation.fZ ) )
{
CClientEntity* pEntity = CElementIDs::GetElement ( ID );
CClientEntity* pAttachedToEntity = CElementIDs::GetElement ( usAttachedToID );
if ( pEntity && pAttachedToEntity )
{
pEntity->SetAttachedOffsets ( vecPosition, vecRotation );
pEntity->AttachTo ( pAttachedToEntity );
}
}
}
示例6: SetElementData
void CElementRPCs::SetElementData ( NetBitStreamInterface& bitStream )
{
ElementID ID;
unsigned short usNameLength;
if ( bitStream.ReadCompressed ( ID ) && bitStream.ReadCompressed ( usNameLength ) )
{
char* szName = new char [ usNameLength + 1 ];
szName [ usNameLength ] = NULL;
CLuaArgument Argument;
if ( bitStream.Read ( szName, usNameLength ) && Argument.ReadFromBitStream ( bitStream ) )
{
CClientEntity* pEntity = CElementIDs::GetElement ( ID );
if ( pEntity )
{
pEntity->SetCustomData ( szName, Argument, NULL );
}
}
delete [] szName;
}
}
示例7: lua_toelement
CClientEntity* lua_toelement ( lua_State* luaVM, int iArgument )
{
if ( lua_type ( luaVM, iArgument ) == LUA_TLIGHTUSERDATA )
{
ElementID ID = TO_ELEMENTID ( lua_touserdata ( luaVM, iArgument ) );
CClientEntity* pEntity = CElementIDs::GetElement ( ID );
if ( !pEntity || pEntity->IsBeingDeleted () )
return NULL;
return pEntity;
}
else if ( lua_type ( luaVM, iArgument ) == LUA_TUSERDATA )
{
ElementID ID = TO_ELEMENTID ( * ( ( void ** ) lua_touserdata ( luaVM, iArgument ) ) );
CClientEntity* pEntity = CElementIDs::GetElement ( ID );
if ( !pEntity || pEntity->IsBeingDeleted () )
return NULL;
return pEntity;
}
return NULL;
}
示例8: argtype
int CLuaTaskDefs::setPlayerTask ( lua_State* luaVM )
{
// bool setPlayerTask ( ped thePed, taskinstance task )
// returns true on success or false on failure
// Verify types
if ( argtype ( 1, LUA_TLIGHTUSERDATA ) &&
argtype ( 2, LUA_TTABLE ) )
{
// Grab the player
// TODO: Support peds too
CClientEntity* pEntity = lua_toelement ( luaVM, 1 );
if ( pEntity )
{
// Player?
if ( pEntity->GetType () == CCLIENTPLAYER )
{
// Grab the player
CClientPlayer* pPlayer = static_cast < CClientPlayer* > ( pEntity );
// Read out the task data
CClientTask Task ( m_pManager );
if ( Task.Read ( luaVM, 2, true ) )
{
// Apply it on the player
bool bSuccess = Task.ApplyTask ( *pPlayer );
// Success
lua_pushboolean ( luaVM, bSuccess );
return 1;
}
}
}
}
// Failed
lua_pushboolean ( luaVM, false );
return 1;
}
示例9: SetElementParent
void CElementRPCs::SetElementParent ( NetBitStreamInterface& bitStream )
{
// Read out the entity id and parent id
ElementID ID, ParentID;
if ( bitStream.Read ( ID ) && bitStream.Read ( ParentID ) )
{
CClientEntity* pEntity = CElementIDs::GetElement ( ID );
CClientEntity* pParent = CElementIDs::GetElement ( ParentID );
if ( pEntity && pParent )
{
pEntity->SetParent ( pParent );
}
else
{
// TODO: raise an error
}
}
else
{
// TODO: raise an error
}
}
示例10: DetachElements
void CElementRPCs::DetachElements ( NetBitStreamInterface& bitStream )
{
ElementID ID;
unsigned char ucTimeContext;
if ( bitStream.Read ( ID ) &&
bitStream.Read ( ucTimeContext ) )
{
CClientEntity* pEntity = CElementIDs::GetElement ( ID );
if ( pEntity )
{
pEntity->SetSyncTimeContext ( ucTimeContext );
pEntity->AttachTo ( NULL );
CVector vecPosition;
if ( bitStream.Read ( vecPosition.fX ) &&
bitStream.Read ( vecPosition.fY ) &&
bitStream.Read ( vecPosition.fZ ) )
{
pEntity->SetPosition ( vecPosition );
}
}
}
}
示例11: assert
CClientEntity* CClientEntity::FindChildIndex ( const char* szName, unsigned int uiIndex, unsigned int& uiCurrentIndex, bool bRecursive )
{
assert ( szName );
// Look among our children
list < CClientEntity* > ::const_iterator iter = m_Children.begin ();
for ( ; iter != m_Children.end (); iter++ )
{
CClientEntity* pChild = *iter;
// Name matches?
if ( strcmp ( pChild->GetName (), szName ) == 0 )
{
// Does the index match? If it doesn't, increment it and keep searching
if ( uiIndex == uiCurrentIndex )
{
return pChild;
}
else
{
++uiCurrentIndex;
}
}
// Tell this child to search too if recursive
if ( bRecursive )
{
CClientEntity* pEntity = pChild->FindChildIndex ( szName, uiIndex, uiCurrentIndex, true );
if ( pEntity )
{
return pEntity;
}
}
}
// Doesn't exist within us
return NULL;
}
示例12: FlushUpdateQueue
///////////////////////////////////////////////////////////////
//
// CClientSpatialDatabaseImpl::FlushUpdateQueue
//
// Process all entities that have changed since the last call
//
///////////////////////////////////////////////////////////////
void CClientSpatialDatabaseImpl::FlushUpdateQueue ( void )
{
std::map < CClientEntity*, int > updateQueueCopy = m_UpdateQueue;
m_UpdateQueue.clear ();
for ( std::map < CClientEntity*, int >::iterator it = updateQueueCopy.begin (); it != updateQueueCopy.end (); ++it )
{
CClientEntity* pEntity = it->first;
// Get the new bounding box
SEntityInfo newInfo;
CSphere sphere = pEntity->GetWorldBoundingSphere ();
newInfo.box = CBox ( sphere.vecPosition, fabsf ( sphere.fRadius ) );
// Make everything 2D for now
newInfo.box.vecMin.fZ = SPATIAL_2D_Z;
newInfo.box.vecMax.fZ = SPATIAL_2D_Z;
// Get previous info
if ( SEntityInfo* pOldInfo = MapFind ( m_InfoMap, pEntity ) )
{
// Don't update if bounding box is the same
if ( pOldInfo->box == newInfo.box )
continue;
// Remove old bounding box from tree
m_Tree.Remove ( &pOldInfo->box.vecMin.fX, &pOldInfo->box.vecMax.fX, pEntity );
}
if ( !IsValidSphere ( sphere ) )
continue;
// Add new bounding box
m_Tree.Insert( &newInfo.box.vecMin.fX, &newInfo.box.vecMax.fX, pEntity );
// Update info map
MapSet ( m_InfoMap, pEntity, newInfo );
}
}
示例13: SetElementModel
void CElementRPCs::SetElementModel ( NetBitStreamInterface& bitStream )
{
ElementID ID;
unsigned short usModel;
if ( bitStream.Read ( ID ) &&
bitStream.Read ( usModel ) )
{
CClientEntity * pEntity = CElementIDs::GetElement ( ID );
if ( pEntity )
{
switch ( pEntity->GetType () )
{
case CCLIENTPED:
case CCLIENTPLAYER:
{
CClientPed* pPed = static_cast < CClientPed * > ( pEntity );
pPed->SetModel ( usModel );
break;
}
case CCLIENTVEHICLE:
{
CClientVehicle* pVehicle = static_cast < CClientVehicle * > ( pEntity );
pVehicle->SetModelBlocking ( usModel );
break;
}
case CCLIENTOBJECT:
{
CClientObject* pObject = static_cast < CClientObject * > ( pEntity );
pObject->SetModel ( usModel );
break;
}
}
}
}
}
示例14: GetTargetEntity
//
// Make player 'orbit camera' rotate to face this point
//
void CClientCamera::SetOrbitTarget ( const CVector& vecPosition )
{
if ( m_pCamera )
{
CClientEntity* pCameraTarget = GetTargetEntity ( );
if ( pCameraTarget != nullptr )
{
CVector vecTargetPosition;
pCameraTarget->GetPosition ( vecTargetPosition );
if ( pCameraTarget->GetType () == CCLIENTPLAYER )
vecTargetPosition.fZ += 0.6f;
CVector vecDirection = vecPosition - vecTargetPosition;
vecDirection.Normalize ();
float fAngleHorz = -atan2 ( vecDirection.fX, vecDirection.fY ) - PI / 2;
float fAngleVert = asin ( vecDirection.fZ );
CCam* pCam = m_pCamera->GetCam ( m_pCamera->GetActiveCam () );
pCam->SetDirection ( fAngleHorz, fAngleVert );
}
}
}
示例15: SetElementInterior
void CElementRPCs::SetElementInterior ( NetBitStreamInterface& bitStream )
{
ElementID ID;
unsigned char ucInterior, ucSetPosition;
if ( bitStream.Read ( ID ) && bitStream.Read ( ucInterior ) && bitStream.Read ( ucSetPosition ) )
{
CClientEntity* pEntity = CElementIDs::GetElement ( ID );
if ( pEntity )
{
pEntity->SetInterior ( ucInterior );
if ( ucSetPosition == 1 )
{
CVector vecPosition;
if ( bitStream.Read ( vecPosition.fX ) &&
bitStream.Read ( vecPosition.fY ) &&
bitStream.Read ( vecPosition.fZ ) )
{
pEntity->SetPosition ( vecPosition );
}
}
}
}
}