本文整理汇总了C++中CElement::GetParentEntity方法的典型用法代码示例。如果您正苦于以下问题:C++ CElement::GetParentEntity方法的具体用法?C++ CElement::GetParentEntity怎么用?C++ CElement::GetParentEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CElement
的用法示例。
在下文中一共展示了CElement::GetParentEntity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoHitDetectionForColShape
//
// Handle the changing state of collision between one colshape and any entity
//
void CColManager::DoHitDetectionForColShape ( CColShape* pShape )
{
// Ensure colshape is enabled and not being deleted
if ( pShape->IsBeingDeleted () || !pShape->IsEnabled () )
return;
std::map < CElement*, int > entityList;
// Get all entities within the sphere
CSphere querySphere = pShape->GetWorldBoundingSphere ();
CElementResult result;
GetSpatialDatabase()->SphereQuery ( result, querySphere );
// Extract relevant types
for ( CElementResult::const_iterator it = result.begin () ; it != result.end (); ++it )
{
CElement* pEntity = *it;
switch ( pEntity->GetType () )
{
case CElement::COLSHAPE:
case CElement::SCRIPTFILE:
case CElement::RADAR_AREA:
case CElement::CONSOLE:
case CElement::TEAM:
case CElement::BLIP:
case CElement::DUMMY:
break;
default:
if ( pEntity->GetParentEntity () )
entityList[ pEntity ] = 1;
}
}
// Add existing colliders, so they can be disconnected if required
for ( list < CElement* > ::const_iterator it = pShape->CollidersBegin () ; it != pShape->CollidersEnd (); ++it )
{
entityList[ *it ] = 1;
}
// Test each entity against the colshape
for ( std::map < CElement*, int > ::const_iterator it = entityList.begin () ; it != entityList.end (); ++it )
{
CElement* pEntity = it->first;
CVector vecPosition =
pEntity->GetPosition ();
// Collided?
bool bHit = pShape->DoHitDetection ( vecPosition );
HandleHitDetectionResult ( bHit, pShape, pEntity );
}
}
示例2: Write
bool CEntityAddPacket::Write ( NetBitStreamInterface& BitStream ) const
{
SPositionSync position ( false );
// Check that we have any entities
if ( m_Entities.size () > 0 )
{
// Write the number of entities
unsigned int NumElements = m_Entities.size ();
BitStream.WriteCompressed ( NumElements );
// For each entity ...
CVector vecTemp;
vector < CElement* > ::const_iterator iter = m_Entities.begin ();
for ( ; iter != m_Entities.end (); iter++ )
{
// Entity id
CElement* pElement = *iter;
BitStream.Write ( pElement->GetID () );
// Entity type id
unsigned char ucEntityTypeID = static_cast < unsigned char > ( pElement->GetType () );
BitStream.Write ( ucEntityTypeID );
// Entity parent
CElement* pParent = pElement->GetParentEntity ();
ElementID ParentID = INVALID_ELEMENT_ID;
if ( pParent )
ParentID = pParent->GetID ();
BitStream.Write ( ParentID );
// Entity interior
BitStream.Write ( pElement->GetInterior () );
// Entity dimension
BitStream.WriteCompressed ( pElement->GetDimension () );
// Entity attached to
CElement* pElementAttachedTo = pElement->GetAttachedToElement ();
if ( pElementAttachedTo )
{
BitStream.WriteBit ( true );
BitStream.Write ( pElementAttachedTo->GetID () );
// Attached position and rotation
SPositionSync attachedPosition ( false );
SRotationDegreesSync attachedRotation ( false );
pElement->GetAttachedOffsets ( attachedPosition.data.vecPosition,
attachedRotation.data.vecRotation );
BitStream.Write ( &attachedPosition );
BitStream.Write ( &attachedRotation );
}
else
BitStream.WriteBit ( false );
// Entity collisions enabled
bool bCollisionsEnabled = true;
switch ( pElement->GetType() )
{
case CElement::VEHICLE:
{
CVehicle* pVehicle = static_cast < CVehicle* > ( pElement );
bCollisionsEnabled = pVehicle->GetCollisionEnabled ( );
break;
}
case CElement::OBJECT:
{
CObject* pObject = static_cast < CObject* > ( pElement );
bCollisionsEnabled = pObject->GetCollisionEnabled ( );
break;
}
case CElement::PED:
case CElement::PLAYER:
{
CPed* pPed = static_cast < CPed* > ( pElement );
bCollisionsEnabled = pPed->GetCollisionEnabled ( );
break;
}
}
BitStream.WriteBit ( bCollisionsEnabled );
// Write custom data
CCustomData* pCustomData = pElement->GetCustomDataPointer ();
assert ( pCustomData );
BitStream.WriteCompressed ( pCustomData->CountOnlySynchronized () );
map < string, SCustomData > :: const_iterator iter = pCustomData->IterBegin ();
for ( ; iter != pCustomData->IterEnd (); iter++ )
{
const char* szName = iter->first.c_str ();
const CLuaArgument* pArgument = &iter->second.Variable;
bool bSynchronized = iter->second.bSynchronized;
if ( bSynchronized )
{
unsigned char ucNameLength = static_cast < unsigned char > ( strlen ( szName ) );
BitStream.Write ( ucNameLength );
BitStream.Write ( szName, ucNameLength );
pArgument->WriteToBitStream ( BitStream );
//.........这里部分代码省略.........