本文整理汇总了C++中Entity::GetName方法的典型用法代码示例。如果您正苦于以下问题:C++ Entity::GetName方法的具体用法?C++ Entity::GetName怎么用?C++ Entity::GetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entity
的用法示例。
在下文中一共展示了Entity::GetName方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnCollision
void BallEntity::OnCollision(const CollisionEvent &event)
{
if (event.GetType() == CollisionEventType::OnEnter)
{
Entity *other = event.GetOtherEntity();
// Confirm ball position
// pBody->SetTransform(pRSClient->sPacketData.vBall, pBody->GetAngle());
// Normalize
vDirection *= vDirection.Normalize();
if(other == NULL)
{
// Invert diection
vDirection.y *=-1;
}
if(other != NULL && other->GetName() == "PlayerRight")
{
// Invert diection
vDirection.x *=-1;
}
if(other != NULL && other->GetName() == "PlayerLeft")
{
// Invert diection
vDirection.x *=-1;
}
// Confirm ball position
// pRSClient->sPacketData.vBall = pBody->GetPosition();
// pRSClient->cSocket.Send(pRSClient->cAddress, &pRSClient->sPacketData, sizeof(pRSClient->sPacketData));
}
}
示例2: SoundOnSelect
void SoundOnSelect( VariantList* pVList )
{
Entity *pEntClicked = pVList->m_variant[1].GetEntity();
Config* config = Config::GetInstance();
if( pEntClicked->GetName() == GUI_IMAGEBUTTON_SOUND_BACK_BUTTON )
{
GetApp()->buttonClickSound();
SlideScreen( pEntClicked->GetParent(), false );
GetMessageManager()->CallEntityFunction( pEntClicked->GetParent(), 500, "OnDelete", NULL );
OptionsCreate( pEntClicked->GetParent()->GetParent() );
}
if( pEntClicked->GetName() == GUI_CHECKBOX_CHECKBOX_EFFECTS )
{
GetApp()->buttonClickSound();
config->setSoundEffects( !config->getSoundEffects() );
GetApp()->GetVar( "SoundEffects" )->Set( uint32(config->getSoundEffects() ) );
config->Save();
}
if( pEntClicked->GetName() == GUI_CHECKBOX_CHECKBOX_MUSIC )
{
GetApp()->buttonClickSound();
config->setMusic( !config->getMusic() );
GetApp()->GetVar( "Music" )->Set( uint32( config->getMusic() ) );
config->Save();
}
if( pEntClicked->GetName() == GUI_CHECKBOX_CHECKBOX_VIBRATION )
{
GetApp()->buttonClickSound();
config->setVibration( !config->getVibration() );
GetApp()->GetVar( "Vibration" )->Set( uint32( config->getVibration() ) );
config->Save();
if( config->getVibration() )
{
GetAudioManager()->Vibrate();
}
}
config->FreeInstance();
}
示例3: DestroyEntity
Void EntityManager::DestroyEntity( const GChar * strName )
{
Entity * pEntity = NULL;
Bool bRemoved = m_hEntityMap.Remove( strName, &pEntity );
Assert( bRemoved && pEntity != NULL );
WorldFn->RemoveChild( pEntity->GetName() );
SelectMemory( TEXT("Scratch") );
Delete( pEntity );
UnSelectMemory();
}
示例4: Visit
void SaveXmlComponentVisitor::Visit(Entity &entity)
{
(*file) << " " << XmlTag::startTagEntity << "\n"
<< " " << XmlTag::startTagId << entity.GetId() << XmlTag::endTagId << "\n"
<< " " << XmlTag::startTagText << entity.GetName() << XmlTag::endTagText << "\n"
<< " " << XmlTag::startTagPrimaryKey;
FindAttribute(entity.GetConnectComponents());
(*file) << XmlTag::endTagPrimaryKey << "\n"
<< " " << XmlTag::startTagPointX << entity.GetPointX() << XmlTag::endTagPointX << "\n"
<< " " << XmlTag::startTagPointY << entity.GetPointY() << XmlTag::endTagPointY << "\n"
<< " " << XmlTag::endTagAttribute << "\n";
}
示例5: OptionsOnSelect
void OptionsOnSelect( VariantList* pVList )
{
Entity* pEntClicked = pVList->m_variant[1].GetEntity();
Config* config = Config::GetInstance();
if( pEntClicked->GetName() == GUI_IMAGEBUTTON_OPTIONS_BACK_BUTTON )
{
GetApp()->buttonClickSound();
SlideScreen( pEntClicked->GetParent(), false );
GetMessageManager()->CallEntityFunction( pEntClicked->GetParent(), 500, "OnDelete", NULL );
MainMenuCreate( pEntClicked->GetParent()->GetParent() );
}
if( pEntClicked->GetName() == GUI_IMAGEBUTTON_OPTIONS_LANGUAGE_BUTTON )
{
GetApp()->buttonClickSound();
SlideScreen( pEntClicked->GetParent(), false );
GetMessageManager()->CallEntityFunction( pEntClicked->GetParent(), 500, "OnDelete", NULL );
LanguageCreate( pEntClicked->GetParent()->GetParent() );
}
if( pEntClicked->GetName() == GUI_IMAGEBUTTON_OPTIONS_SOUND_BUTTON )
{
GetApp()->buttonClickSound();
SlideScreen( pEntClicked->GetParent(), false );
GetMessageManager()->CallEntityFunction( pEntClicked->GetParent(), 500, "OnDelete", NULL );
SoundCreate( pEntClicked->GetParent()->GetParent() );
}
if( pEntClicked->GetName() == GUI_IMAGEBUTTON_OPTIONS_LEVEL_BUTTON )
{
GetApp()->buttonClickSound();
SlideScreen( pEntClicked->GetParent(), false );
GetMessageManager()->CallEntityFunction( pEntClicked->GetParent(), 500, "OnDelete", NULL );
LevelMenuCreate( pEntClicked->GetParent()->GetParent() );
}
config->FreeInstance();
}
示例6: LanguageOnSelect
void LanguageOnSelect( VariantList *pVList )
{
Entity *pEntClicked = pVList->m_variant[1].GetEntity();
Config* config = Config::GetInstance();
if( pEntClicked->GetName() == GUI_IMAGEBUTTON_LANGUAGE_BACK_BUTTON )
{
GetApp()->buttonClickSound();
SlideScreen( pEntClicked->GetParent(), false );
GetMessageManager()->CallEntityFunction( pEntClicked->GetParent(), 500, "OnDelete", NULL );
OptionsCreate( pEntClicked->GetParent()->GetParent() );
}
if( pEntClicked->GetName() == GUI_IMAGEBUTTON_FLAG_EN_BUTTON )
{
GetApp()->buttonClickSound();
config->setLang( convertCodeToId( LANG_NAMES[ LANG_EN ] ) );
config->Save();
config->ReloadLang( LANG_EN );
SlideScreen( pEntClicked->GetParent(), false );
GetMessageManager()->CallEntityFunction( pEntClicked->GetParent(), 500, "OnDelete", NULL );
OptionsCreate( pEntClicked->GetParent()->GetParent() );
}
if( pEntClicked->GetName() == GUI_IMAGEBUTTON_FLAG_RU_BUTTON )
{
GetApp()->buttonClickSound();
config->setLang( convertCodeToId( LANG_NAMES[ LANG_RU ] ) );
config->Save();
config->ReloadLang( LANG_RU );
SlideScreen( pEntClicked->GetParent(), false );
GetMessageManager()->CallEntityFunction( pEntClicked->GetParent(), 500, "OnDelete", NULL );
OptionsCreate( pEntClicked->GetParent()->GetParent() );
}
config->FreeInstance();
}
示例7: CopyGeometryRecursive
void DAEConvertWithSettingsAction::CopyGeometryRecursive( DAVA::Entity *srcEntity, DAVA::Entity *dstEntity )
{
CopyGeometry(srcEntity, dstEntity);
uint32 srcCount = srcEntity->GetChildrenCount();
uint32 dstCount = dstEntity->GetChildrenCount();
for(uint32 iSrc = 0, iDst = 0; iSrc < srcCount && iDst < dstCount; )
{
Entity * src = srcEntity->GetChild(iSrc);
Entity * dst = dstEntity->GetChild(iDst);
if(src->GetName() == dst->GetName())
{
CopyGeometryRecursive(src, dst);
++iSrc;
++iDst;
}
else
{
++iDst;
}
}
}
示例8: entity_FindAllByName
// .FindAllByName("name", 0) - returns a table with indexes 1->N containing all entities on the map with matching names.
// If the second parameter is supplied, it's a bool indicating whether to use wildcard matching or not
int entity_FindAllByName(lua_State* ls)
{
DEBUGOUT("entity_FindAllByName");
luaCountArgs(ls, 1);
ASSERT(game->mMap);
string name = lua_tostring(ls, 1);
bool useWildmatch = false;
int numArgs = lua_gettop(ls);
if (numArgs > 1)
useWildmatch = lua_tonumber(ls, 2);
//Construct a table to store all entities
lua_newtable(ls);
int top = lua_gettop(ls);
Entity* e;
int index = 1; //Table keys will be index numbers, starting at 1 (common for lua arrays)
for (int i = 0; i < game->mMap->mEntities.size(); ++i)
{
e = game->mMap->mEntities.at(i);
//if it matches the search, add to table
if ( (useWildmatch && wildmatch(name.c_str(), e->GetName().c_str()))
|| (!useWildmatch && e->GetName() == name) )
{
lua_pushnumber(ls, index);
lua_pushlightuserdata(ls, e);
lua_settable(ls, top);
++index;
}
}
return 1;
}
示例9:
bool D3D10Renderer::Render()
{
D3DXMATRIX viewMatrix;
BeginScene(0.1f, 0.1f, 0.1f, 1.0f);
m_camera->Render();
m_camera->GetViewMatrix(viewMatrix);
std::set<IntrusivePtr<Entity> > entitySet = m_scene->GetEntitySet();
Entity* ent = 0;
POSITION modelPosition;
DX10Model* model;
for(std::set<IntrusivePtr<Entity> > ::const_iterator it = entitySet.begin(); it != entitySet.end(); ++it)
{
ent = it->GetPtr();
modelPosition = ent->GetPosition();
D3DXMatrixTranslation(&m_worldMatrix, modelPosition.x, modelPosition.y, modelPosition.z);
model = m_modelFactory->GetModelByName(ent->GetName());
model->Render(m_device);
m_colorShader->Render(m_device, model->GetIndexCount(), m_worldMatrix, viewMatrix, m_projectionMatrix);
}
EndScene();
return true;
}
示例10: OnEntityLinkChanged
bool wxLinkProperty::OnEntityLinkChanged(uint entityID)
{
wxLinkProperty* pWxLinkProperty = wxLinkProperty::GetCurrentProperty();
pWxLinkProperty->SetLinkID(entityID);
Entity* pEntity = Engine::Instance()->GetContextStack();
if(entityID >= 0)
{
if(entityID != pEntity->GetID())
{
pEntity = pEntity->GetChildByID(entityID);
}
}
else
{
pEntity = NULL;
}
// Update the link property
if(pEntity)
{
std::stringstream ss;
ss << pEntity->GetName() << " [" << std::hex << entityID << "]";
pWxLinkProperty->SetValue(wxString(ss.str()));
}
else
{
pWxLinkProperty->SetValue("");
}
// notify editor
wxPropertyGridEvent event;
event.SetProperty(pWxLinkProperty);
ShootEditor::Instance()->GetObjectInspector()->OnPropertyChanged(event);
return true;
}
示例11: GameOnSelect
void GameOnSelect( VariantList* pVList )
{
Entity *pEntClicked = pVList->m_variant[1].GetEntity();
Tetris* tetris = Tetris::GetInstance();
Config* config = Config::GetInstance();
if( pEntClicked->GetName() == GUI_IMAGEBUTTON_GAMEPLAY_MENU_BUTTON )
{
GetApp()->buttonClickSound();
if( tetris->isEndGame() )
{
SlideScreen( pEntClicked->GetParent(), false );
GetMessageManager()->CallEntityFunction( pEntClicked->GetParent(), 500, "OnDelete", NULL );
GetApp()->setGame( false );
GetApp()->setContinueBtn( false );
if( tetris->getScoreInt() > config->getMinScore() )
{
GameState::SetState( new GS_Menu() );
InputBestScoreCreate( pEntClicked->GetParent()->GetParent() );
}
else
{
tetris->ResetEndGame();
GameState::SetState( new GS_Menu() );
MainMenuCreate( pEntClicked->GetParent()->GetParent() );
}
tetris->FreeInstance();
config->FreeInstance();
return;
}
GameState::SetState( new GS_Menu() );
if( config->getMusic() )
{
GetAudioManager()->StopMusic();
}
GetApp()->setGame( false );
SlideScreen( pEntClicked->GetParent(), false );
GetMessageManager()->CallEntityFunction( pEntClicked->GetParent(), 500, "OnDelete", NULL );
MainMenuCreate( pEntClicked->GetParent()->GetParent() );
}
if( pEntClicked->GetName() == GUI_IMAGEBUTTON_GAMEPLAY_DOWN && !tetris->isEndGame() )
{
if( config->getSoundEffects() )
{
GetAudioManager()->Play( GetApp()->getResourceInstance()->getItem(GetApp()->getResolutionType(), RES_TYPE_AUDIO, RES_ID_AUDIO_FIGURE_DOWN ) );
}
tetris->ClickForceDown();
}
if( pEntClicked->GetName() == GUI_IMAGEBUTTON_GAMEPLAY_LEFT && !tetris->isEndGame() )
{
buttonMoveSound();
tetris->ClickLeft();
}
if( pEntClicked->GetName() == GUI_IMAGEBUTTON_GAMEPLAY_RIGHT && !tetris->isEndGame() )
{
buttonMoveSound();
tetris->ClickRight();
}
if( pEntClicked->GetName() == GUI_IMAGEBUTTON_GAMEPLAY_ROTATE && !tetris->isEndGame() )
{
buttonMoveSound();
tetris->ClickRotate();
}
tetris->FreeInstance();
config->FreeInstance();
}
示例12: CopyEntity
void EntityFactory::CopyEntity(Entity* aTargetEntity, const std::string& aEntityTag)
{
if (myEntities.find(aEntityTag) == myEntities.end())
{
//#ifdef _DEBUG
// if (myEntityTags.find(aEntityTag) == myEntityTags.end())
// {
// std::string error = "[EntityFactory] No entity with name " + aEntityTag;
// DL_ASSERT(error);
// }
//
// LoadEntity(myEntityTags[aEntityTag], myDifficultScale);
//#else
std::string error = "[EntityFactory] No entity with name " + aEntityTag;
DL_ASSERT(error);
//#endif
}
auto it = myEntities.find(aEntityTag);
Entity* sourceEntity = it->second.myEntity;
aTargetEntity->SetName(sourceEntity->GetName());
if (aEntityTag.rfind("Asteroid") != std::string::npos
|| aEntityTag.rfind("asteroid") != std::string::npos
|| aEntityTag.rfind("Junk") != std::string::npos
|| aEntityTag.rfind("junk") != std::string::npos)
{
int value = CU::Math::RandomRange(1, 6);
aTargetEntity->SetShouldRotate(true);
if (value == 1)
aTargetEntity->SetShouldRotateX(true);
else if (value == 2)
aTargetEntity->SetShouldRotateY(true);
else if (value == 3)
aTargetEntity->SetShouldRotateZ(true);
else if (value == 4)
{
aTargetEntity->SetShouldRotateX(true);
aTargetEntity->SetShouldRotateY(true);
}
else if (value == 5)
{
aTargetEntity->SetShouldRotateY(true);
aTargetEntity->SetShouldRotateZ(true);
}
else if (value == 6)
{
aTargetEntity->SetShouldRotateZ(true);
aTargetEntity->SetShouldRotateX(true);
}
}
else
{
aTargetEntity->SetShouldRotate(sourceEntity->GetShouldRotate());
aTargetEntity->SetShouldRotateX(sourceEntity->GetShouldRotateX());
aTargetEntity->SetShouldRotateY(sourceEntity->GetShouldRotateY());
aTargetEntity->SetShouldRotateZ(sourceEntity->GetShouldRotateZ());
}
if (sourceEntity->GetComponent<CollisionComponent>() != nullptr)
{
eCollisionType collisionType = sourceEntity->GetComponent<CollisionComponent>()->GetCollisionType();
if (collisionType == eCollisionType::NORMAL)
{
aTargetEntity->AddComponent<CollisionComponent>();
}
else if (collisionType == eCollisionType::PLANET)
{
aTargetEntity->AddComponent<PlanetCollisionComponent>();
}
aTargetEntity->GetComponent<CollisionComponent>()->Init(it->second.myCollisionSphereRadius);
}
if (sourceEntity->GetComponent<GraphicsComponent>() != nullptr)
{
aTargetEntity->AddComponent<GraphicsComponent>();
switch (it->second.myGraphicsType)
{
case eEntityDataGraphicsType::MODEL:
aTargetEntity->GetComponent<GraphicsComponent>()->Init(it->second.myModelFile.c_str(),
it->second.myEffectFile.c_str());
break;
case eEntityDataGraphicsType::CUBE:
aTargetEntity->GetComponent<GraphicsComponent>()->InitCube(it->second.myWidth,
it->second.myHeight, it->second.myDepth);
break;
default:
break;
}
if (it->second.myScale != CU::Vector3f())
{
aTargetEntity->GetComponent<GraphicsComponent>()->SetScale(it->second.myScale);
if (aTargetEntity->GetComponent<CollisionComponent>() != nullptr)
//.........这里部分代码省略.........
示例13: MatchObjectInList
Entity* World::MatchObjectInList(const std::string &name, std::list<Entity*> *olist)
{
std::list<Entity*>::iterator it, itEnd;
std::string sub; //used for holding the subpart of the number.
std::string temp; //used for holding a temp copy of the name after it is trimmed.
std::string alias; //holds a copy of the alias.
Entity* obj = NULL; //the object we are currently examining/returning.
std::vector<std::string>* aliases = NULL; //a list of aliases.
std::vector<std::string>::iterator ait, aitEnd;
int number = 0; //used for holding the actual number.
int count = 0; //used for holding the number of objects found.
size_t marker; //used for holding the position of the '.'.
if (!olist->size())
{
return NULL;
}
//we check to see if the string has a '.', if so, there's a number.
marker = name.find_first_of(".");
//check to see if it is 1) at the beginning, or 2) at the end.
if ((marker == 0) || (marker == name.length()))
{
return NULL;
}
if (marker != std::string::npos) //we found something.
{
sub = name.substr(marker); //the subnumber.
temp = name.substr(marker+1); //trim off the x. bit
number = atoi(sub.c_str());
if (number == 0)
{
return NULL;
}
itEnd = olist->end();
for (it = olist->begin(); it != itEnd && count < number; ++it)
{
obj = *it;
if (obj->GetName().length() < temp.length()) //we check for a partial match
{
if (obj->GetName().substr(temp.length()) == temp)
{
count++; //we found a match, increase the counter.
continue;
}
}
if (obj->GetName() == temp) //full match
{
count++;
continue;
}
//now we check a list of aliases.
aliases = obj->GetAliases();
if (aliases->size())
{
aitEnd = aliases->end();
for (ait = aliases->begin(); ait != aitEnd; ++ait)
{
alias = (*ait);
if (alias.length() < temp.length()) //we check for a partial match
{
if (alias.substr(temp.length()) == temp)
{
count++; //we found a match, increase the counter.
continue;
}
}
if (alias == temp) //full match
{
count++;
continue;
}
}
}
}
if (count != (number -1))
{
return NULL;
}
else
{
return obj;
}
}
else
{
itEnd = olist->end();
for (it = olist->begin(); it != itEnd; ++it)
{
obj = *it;
if (obj->GetName().length() < temp.length()) //we check for a partial match
{
if (obj->GetName().substr(temp.length()) == temp)
{
return obj;
}
//.........这里部分代码省略.........
示例14: Explode
//! Makes an Actor explode
f32 SFXManager::Explode(Actor* pActor)
{
if(Object* pBaseExplosionVisitor = GetExplosionVisitor(pActor->GetTemplatePath()))
{
bool bIsPlayer = (pActor == Player::Instance());
bool bIsBoss = pActor->IsBoss();
const char* strExplosionEntity = bIsPlayer ? "common/playerexplosionentity.xml" : (bIsBoss ? "5/bossexplosionentity.xml" : "common/ExplosionEntity.xml");
Object* pBaseExplosionEntity = GetPreloadedObject(strExplosionEntity);
ExplosionVisitor* pExplosionVisitor = static_cast<ExplosionVisitor*>(pBaseExplosionVisitor->Copy());
Entity3D* pExplosionEntity = static_cast<Entity3D*>(pBaseExplosionEntity->Copy());
for(u32 i=0; i<pActor->GetMeshEntity()->GetComponentCount(); ++i)
{
if(Visitor* pVisitor = DYNAMIC_CAST(pActor->GetMeshEntity()->GetComponent(i), Visitor))
{
pVisitor->Leave();
}
}
for(u32 i=0; i<pActor->GetMeshEntity()->GetChildCount(); ++i)
{
Entity* pChild = pActor->GetMeshEntity()->GetChild(i);
if(!pChild->IsA(SubMesh::TypeID)
&& !pChild->IsA(ParticleGenerator::TypeID)
&& pChild->GetName() != "Explosion")
{
pActor->GetMeshEntity()->GetChild(i)->SetVisible(false);
}
}
// stop particle generation
std::vector< Handle<Entity> > particleEmitters;
pActor->GetChildrenByType("ParticleGenerator", particleEmitters);
for(u32 i=0; i<particleEmitters.size(); ++i)
{
static_cast<ParticleGenerator*>(particleEmitters[i].Get())->SetActive(false);
}
// add explosion visitor
pExplosionVisitor->SetDefaultIntensity(m_fExplosionIntensity);
pExplosionVisitor->SetDefaultDuration(m_fExplosionDuration);
pActor->GetMeshEntity()->AddComponent(pExplosionVisitor);
// add explosion entity
pExplosionEntity->SetScale(Vector3::One * pActor->GetExplosionScaleFactor());
pActor->AddChild(pExplosionEntity);
pExplosionEntity->SetPosition(pActor->GetMeshEntity()->GetPosition());
f32 fRotationRange = bIsBoss ? 0.0f : 30.0f;
pExplosionEntity->SetRotation(Vector3::Create(0.0f, Random::GetFloat(-fRotationRange, fRotationRange), 0.0f));
AudioManager::Instance()->Play(bIsBoss ? AudioManager::S_LongExplosion : AudioManager::S_Explosion);
// add camera shake
f32 fExplosionDuration = (pExplosionVisitor->GetDuration() < 0.0f) ? m_fExplosionDuration : pExplosionVisitor->GetDuration();
bool bMultipleExplosionsDetected = (m_fExplosionTracker < m_fExplosionDuration);
bool bForceShake = bIsPlayer || bIsBoss || pActor->GetShakeOnExplode();
f32 fForceShakeFactor = 2.0f;
if(bMultipleExplosionsDetected || bForceShake)
{
f32 fIntFactor = bForceShake ? fForceShakeFactor : 1.0f;
f32 fFreqFactor = bForceShake ? (1.0f/fForceShakeFactor) : 1.0f;
PlayerCamera::Instance()->Shake(m_fCameraShakeIntensity*fIntFactor, m_fCameraShakeFrequency*fFreqFactor, fExplosionDuration/2.0f);
}
m_fExplosionTracker = 0.0f;
if(pActor->GetResetRotationOnExplode())
{
pActor->SetRotation(Vector3::Zero);
}
return fExplosionDuration;
}
return -1.0f;
}