本文整理汇总了C++中CCopyEntity::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ CCopyEntity::Init方法的具体用法?C++ CCopyEntity::Init怎么用?C++ CCopyEntity::Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCopyEntity
的用法示例。
在下文中一共展示了CCopyEntity::Init方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetBaseEntity
//.........这里部分代码省略.........
BaseEntity& rBaseEntity = *(pBaseEntity);
// LOG_PRINT( "checking the initial position of " + rBaseEntity.GetNameString() );
// determine the entity group id
// priority (higher to lower):
// (id set to copy entity desc) -> (id set to base entity)
int entity_group_id = ENTITY_GROUP_INVALID_ID;
if( rCopyEntityDesc.sGroupID != ENTITY_GROUP_INVALID_ID )
{
entity_group_id = rCopyEntityDesc.sGroupID;
}
else
{
// try the group of base entity
entity_group_id = rBaseEntity.GetEntityGroupID();
}
if( false )
// if( !rBaseEntity.m_bNoClip )
// && rCopyEntityDesc.DontCreateIfOverlapIsDetected )
{ // check for overlaps with other entities
// to see if the new entity is in a valid position
// if( rCopyEnt.bvType == BVTYPE_AABB || rCopyEnt.bvType == BVTYPE_DOT )
// {
STrace tr;
tr.sTraceType = TRACETYPE_IGNORE_NOCLIP_ENTITIES;
tr.vEnd = rCopyEntityDesc.WorldPose.vPosition;
tr.bvType = rBaseEntity.m_BoundingVolumeType;
tr.aabb = rBaseEntity.m_aabb;
tr.GroupIndex = entity_group_id;
if( rBaseEntity.m_bNoClipAgainstMap )
tr.sTraceType |= TRACETYPE_IGNORE_MAP;
m_pStage->CheckPosition( tr );
if(tr.in_solid)
{
LOG_PRINT( " - cannot create a copy entity due to overlaps: " + string(rBaseEntityHandle.GetBaseEntityName()) );
return NULL; // specified position is invalid - cannot create entity
}
// }
}
// LOG_PRINT( "the copy entity of " + rBaseEntity.GetNameString() + " is in a valid position" );
// create an entity
shared_ptr<CCopyEntity> pNewEntitySharedPtr = m_pEntityFactory->CreateEntity( rCopyEntityDesc.TypeID );
if( !pNewEntitySharedPtr )
{
/// too many entities or no entity is defined for rCopyEntityDesc.TypeID
LOG_PRINT_ERROR( " - cannot create a copy entity of '" + string(rBaseEntityHandle.GetBaseEntityName()) + "'" );
return NULL;
}
CCopyEntity *pNewCopyEnt = pNewEntitySharedPtr.get();
pNewCopyEnt->m_TypeID = rCopyEntityDesc.TypeID;
// copy parameter values from base entity (entity attributes set)
SetBasicEntityAttributes( pNewCopyEnt, rBaseEntity );
// copy parameter values from entity desc
pNewCopyEnt->SetName( rCopyEntityDesc.strName );
pNewCopyEnt->SetWorldPose( rCopyEntityDesc.WorldPose );
pNewCopyEnt->Velocity() = rCopyEntityDesc.vVelocity;
pNewCopyEnt->fSpeed = rCopyEntityDesc.fSpeed;
pNewCopyEnt->m_MeshHandle = rCopyEntityDesc.MeshObjectHandle;
pNewCopyEnt->f1 = rCopyEntityDesc.f1;
pNewCopyEnt->f2 = rCopyEntityDesc.f2;
pNewCopyEnt->f3 = rCopyEntityDesc.f3;
pNewCopyEnt->f4 = rCopyEntityDesc.f4;
pNewCopyEnt->f5 = 0.0f;
pNewCopyEnt->s1 = rCopyEntityDesc.s1;
pNewCopyEnt->v1 = rCopyEntityDesc.v1;
pNewCopyEnt->v2 = rCopyEntityDesc.v2;
pNewCopyEnt->iExtraDataIndex = rCopyEntityDesc.iExtraDataIndex;
pNewCopyEnt->pUserData = rCopyEntityDesc.pUserData;
pNewCopyEnt->sState = 0;
pNewCopyEnt->bInSolid = false;
pNewCopyEnt->GroupIndex = entity_group_id;
// pNewCopyEnt->GroupIndex = rCopyEntityDesc.sGroupID;
pNewCopyEnt->touch_plane.dist = 0;
pNewCopyEnt->touch_plane.normal = Vector3(0,0,0);
InitEntity( pNewEntitySharedPtr, rCopyEntityDesc.pParent, pBaseEntity, rCopyEntityDesc.pPhysActorDesc );
pNewCopyEnt->Init( rCopyEntityDesc );
LOG_PRINT_VERBOSE( " - created a copy entity of " + rBaseEntity.GetNameString() );
return pNewCopyEnt;
}