本文整理汇总了C++中Entity::AttachComponent方法的典型用法代码示例。如果您正苦于以下问题:C++ Entity::AttachComponent方法的具体用法?C++ Entity::AttachComponent怎么用?C++ Entity::AttachComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entity
的用法示例。
在下文中一共展示了Entity::AttachComponent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BuildEntity
//-----------------------------------------------------------------------------------------------
void MissileBlueprint::BuildEntity( Entity& out_entity )
{
out_entity.typeID = TYPEID_Bullet;
MeshComponent* missileMesh = m_game->m_worldRenderingSystem->AcquireMeshComponent();
missileMesh->vertexDataIsFlyweight = true;
missileMesh->vertexData = &m_vertices;
missileMesh->material = m_material;
out_entity.AttachComponent( missileMesh );
PhysicsComponent* spacePhysics = m_game->m_physicsSystem->AcquireComponent();
spacePhysics->percentAcceleratedByGravity = 0.f;
out_entity.AttachComponent( spacePhysics );
CollisionComponent2D* missileCollider = m_game->m_collisionSystem->AcquireComponent();
missileCollider->group = 1;
missileCollider->SetColliderToCircle( m_colliderCenter, m_colliderRadius );
out_entity.AttachComponent( missileCollider );
TimedDestructionComponent* missileFailsafe = m_game->m_timedDestructionSystem->AcquireComponent();
missileFailsafe->secondsLeftUntilDestruction = 1.f;
out_entity.AttachComponent( missileFailsafe );
ScoringComponent* missileScore = m_game->m_scoringSystem->AcquireComponent();
missileScore->pointValue = 1;
out_entity.AttachComponent( missileScore );
}
示例2: BuildEntityIntoGame
//-----------------------------------------------------------------------------------------------
void ShipBlueprint::BuildEntityIntoGame( Entity& out_entity, const MeteoroidGame* game,
const FloatVector2& atPosition )
{
out_entity.typeID = TYPEID_Ship;
out_entity.position.x = atPosition.x;
out_entity.position.y = atPosition.y;
MeshComponent* shipMesh = game->m_worldRenderingSystem->AcquireMeshComponent();
shipMesh->vertexDataIsFlyweight = true;
shipMesh->vertexData = &m_vertices;
shipMesh->material = m_material;
out_entity.AttachComponent( shipMesh );
PhysicsComponent* shipPhysics = game->m_physicsSystem->AcquireComponent();
shipPhysics->percentAcceleratedByGravity = 0.f;
out_entity.AttachComponent( shipPhysics );
CollisionComponent2D* shipCollider = game->m_collisionSystem->AcquireComponent();
shipCollider->group = SHIP_COLLISION_GROUP;
shipCollider->SetColliderToCircle( m_colliderCenter, m_colliderRadius );
out_entity.AttachComponent( shipCollider );
WarpComponent* warpEngine = game->m_warpSystem->AcquireComponent();
warpEngine->secondsSinceLastWarp = warpEngine->secondsNeededBetweenWarps = 2.f;
out_entity.AttachComponent( warpEngine );
WeaponComponent* missilePort = game->m_weaponSystem->AcquireComponent();
missilePort->firingSound = AudioInterface::GetOrLoadSound( "Audio/laser.wav" );
missilePort->minSecondsBetweenShots = 0.75f;
out_entity.AttachComponent( missilePort );
}