本文整理汇总了C++中CElement::GetDimension方法的典型用法代码示例。如果您正苦于以下问题:C++ CElement::GetDimension方法的具体用法?C++ CElement::GetDimension怎么用?C++ CElement::GetDimension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CElement
的用法示例。
在下文中一共展示了CElement::GetDimension方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Callback_OnLeave
void CPickup::Callback_OnLeave ( CColShape& Shape, CElement& Element )
{
if ( IS_PLAYER ( &Element ) )
{
CPlayer& Player = static_cast < CPlayer& > ( Element );
// Matching interior
if ( GetInterior () == Element.GetInterior () )
{
// Matching dimension
if ( GetDimension () == Element.GetDimension () )
{
// Is he alive?
if ( !Player.IsDead () )
{
// Call the onPickupHit event
CLuaArguments Arguments;
Arguments.PushElement ( &Player );
CallEvent ( "onPickupLeave", Arguments );
CLuaArguments Arguments2;
Arguments2.PushElement ( this ); // pickup
Element.CallEvent ( "onPlayerPickupLeave", Arguments2 );
}
}
}
}
}
示例2: Callback_OnLeave
void CMarker::Callback_OnLeave ( CColShape& Shape, CElement& Element )
{
// Matching interior?
if ( GetInterior () == Element.GetInterior () )
{
// Call the marker hit event
CLuaArguments Arguments;
Arguments.PushElement ( &Element ); // Hit element
Arguments.PushBoolean ( GetDimension () == Element.GetDimension () ); // Matching dimension?
CallEvent ( "onMarkerLeave", Arguments );
if ( IS_PLAYER ( &Element ) )
{
CLuaArguments Arguments2;
Arguments2.PushElement ( this ); // marker
Arguments2.PushBoolean ( GetDimension () == Element.GetDimension () ); // Matching dimension?
Element.CallEvent ( "onPlayerMarkerLeave", Arguments2 );
}
}
}
示例3: Callback_OnCollision
void CPickup::Callback_OnCollision ( CColShape& Shape, CElement& Element )
{
if ( IS_PLAYER ( &Element ) )
{
CPlayer& Player = static_cast < CPlayer& > ( Element );
// Is he alive?
if ( !Player.IsDead () )
{
// Matching interior
if ( GetInterior () == Element.GetInterior () )
{
// Matching dimension
if ( GetDimension () == Element.GetDimension () )
{
// Call the onPickupHit event
CLuaArguments Arguments;
Arguments.PushElement ( &Player );
bool bContinue1 = CallEvent ( "onPickupHit", Arguments );
CLuaArguments Arguments2;
Arguments2.PushElement ( this ); // pickup
bool bContinue2 = Element.CallEvent ( "onPlayerPickupHit", Arguments2 );
if ( bContinue1 && bContinue2 )
{
// Does it still exist?
if ( !IsBeingDeleted () )
{
// Can we USE the pickup?
if ( CanUse ( Player ) )
{
// USE the pickup
Use ( Player );
}
}
}
}
}
}
}
}
示例4: 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 );
//.........这里部分代码省略.........