本文整理汇总了C++中CEntity类的典型用法代码示例。如果您正苦于以下问题:C++ CEntity类的具体用法?C++ CEntity怎么用?C++ CEntity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: n_assert
int CPhysicsServer::GetEntitiesInShape(PShape Shape, const CFilterSet& ExcludeSet,
nArray<PEntity>& Result)
{
n_assert(CurrLevel);
Shape->Attach(CurrLevel->GetODEDynamicSpaceID());
Contacts.Reset();
Shape->Collide(ExcludeSet, Contacts);
Shape->Detach();
int OldResultSize = Result.Size();
//???stamp?
uint Stamp = GetUniqueStamp();
for (int i = 0; i < Contacts.Size(); i++)
{
CEntity* pEnt = Contacts[i].GetEntity();
if (pEnt && pEnt->GetStamp() != Stamp)
{
pEnt->SetStamp(Stamp);
Result.Append(pEnt);
}
}
return Result.Size() - OldResultSize;
}
示例2: saveIdEntity
void IdEntities::saveIdEntity(CHandle entity, int entity_id) {
if (entity_id >= 0) {
identified_entities[entity_id] = entity;
CEntity* e = entity;
e->setId(entity_id);
}
}
示例3: test_member_archive
void test_member_archive() {
CEntityQueue entity_queue;
CEntity &entity = entity_queue.get_head();
entity.mod_hp(100);
entity.mod_mp(50);
CEntity &entity2 = entity_queue.get_end();
entity2.mod_hp(1000);
entity2.mod_mp(30);
CEntity *pentity = entity_queue.get_middle();
if (pentity) {
pentity->mod_hp(3576);
pentity->mod_mp(876);
}
std::cout << "head hp is " << entity_queue.get_head().get_hp() << "head mp is " << entity_queue.get_head().get_mp() << std::endl;
std::cout << "head hp is " << entity_queue.get_end().get_hp() << "head mp is " << entity_queue.get_end().get_mp() << std::endl;
std::cout << "head hp is " << entity_queue.get_middle()->get_hp() << "head mp is " << entity_queue.get_middle()->get_mp() << std::endl;
std::stringstream ss;
boost::archive::binary_oarchive oa(ss);
oa << entity_queue;
CEntityQueue entity_queue2;
boost::archive::binary_iarchive ia(ss);
ia >> entity_queue2;
std::cout << "head hp is " << entity_queue2.get_head().get_hp() << "head mp is " << entity_queue2.get_head().get_mp() << std::endl;
std::cout << "head hp is " << entity_queue2.get_end().get_hp() << "head mp is " << entity_queue2.get_end().get_mp() << std::endl;
std::cout << "head hp is " << entity_queue.get_middle()->get_hp() << "head mp is " << entity_queue.get_middle()->get_mp() << std::endl;
}
示例4: moveTo
int moveTo(lua_State *l) {
LUA_BRIDGE_START;
LOGV("Lua call: textMessage");
if (lua_gettop(l) < 2) {
LOGW("Less argument count for moveTo call");
return -1;
}
const std::string id(lua_tostring(l, 1));
const Ogre::Vector3 position(Ogre::StringConverter::parseVector3(lua_tostring(l, 2)));
CEntity *pEntity = CGameStateManager::getSingleton().getChildRecursive(id);
if (!pEntity) {
LOGW("Entity '%s' was not found in entity tree.", id.c_str());
return 0;
}
luaHelper::CMoveToWait waiter(pEntity);
pEntity->moveToTarget(position);
while (true) {
LUA_WAIT(50);
if (waiter.hasReached()) {
break;
}
}
return 0; // 0 return values
}
示例5: EditEntity
int CEntitiesDialog::EditEntity( CEntityArray& Entities, int CurrentEntity, CFusionDoc* Doc)
{
// If more than one entity selected, make sure they're all the same type.
int nSel = 0;
CString EntityClassname;
int i;
pDoc = Doc;
mEntityArray = &Entities;
for (i = 0; i < mEntityArray->GetSize(); ++i)
{
CEntity *pEnt;
pEnt = &Entities[i];
if (pEnt->IsSelected ())
{
if (nSel == 0)
{
EntityClassname = pEnt->GetClassname ();
mCurrentEntity = i;
}
else
{
if (pEnt->GetClassname () != EntityClassname)
{
AfxMessageBox ("To edit multiple entities, they must all be of the same type.");
return CurrentEntity;
}
}
++nSel;
}
}
MultiEntityFlag = (nSel > 1);
if (MultiEntityFlag)
{
}
else
{
if (CurrentEntity != -1)
{
mCurrentEntity = CurrentEntity;
}
else
{
// Let's set entity 0 as selected if it exists...
mCurrentEntity = 0;
if (mEntityArray->GetSize() > 0)
{
pDoc->ResetAllSelectedEntities();
pDoc->SelectEntity (&(*mEntityArray)[mCurrentEntity]);
pDoc->mCurrentEntity = mCurrentEntity;
}
}
}
DoModal();
return mCurrentEntity;
}
示例6: switch
void CGrenadeControllerClient::process(const std::shared_ptr<CMessage>& message) {
if(!_explotionActive) {
switch( message->getMessageType() ) {
case Message::CONTACT_ENTER: {
std::shared_ptr<CMessageContactEnter> contactMsg = std::static_pointer_cast<CMessageContactEnter>(message);
Logic::TEntityID idPlayerHit = contactMsg->getEntity();
CEntity * playerHit = CServer::getSingletonPtr()->getMap()->getEntityByID(idPlayerHit);
_explotionActive=true;
// Si es el escudo del screamer mandar directamente esos daños a la
// entidad contra la que hemos golpeado (el escudo), sino, crear explosion
if(playerHit->getType() == "ScreamerShield") {
// Crear efecto y sonido de absorcion
// Eliminamos la entidad en diferido
CEntityFactory::getSingletonPtr()->deferredDeleteEntity(_entity,false);
}
else {
// Eliminamos la entidad en diferido
CEntityFactory::getSingletonPtr()->deferredDeleteEntity(_entity,false);
// Creamos la explosion
createExplotion();
}
break;
}
case Message::CONTACT_EXIT: {
std::cout << "CONTACT EXIT DE LA GRANADA, no deberia entrar nunca" << std::endl;
}
}
}
} // process
示例7: sq_totimer
CTimer* sq_totimer(SQVM* pVM, int idx)
{
CEntity* pEntity = sq_toentity(pVM, idx);
if( pEntity && pEntity->GetType() == ENTITY_TYPE_TIMER )
return dynamic_cast< CTimer* >( pEntity );
return NULL;
}
示例8: assert
int CEntityNatives::Create(SQVM* pVM)
{
CResource* pResource = g_pResourceManager->Get(pVM);
assert( pResource );
const char* szName;
sq_getstring(pVM,2,&szName);
if(CEntity::GetType(szName) == ENTITY_TYPE_CUSTOM)
{
CEntity* pEntity = new CEntity(ENTITY_TYPE_CUSTOM, pResource, szName);
if(pEntity->GetID() != INVALID_ENTITY_ID_LONG)
{
sq_pushentity(pVM,pEntity);
}
else
{
delete pEntity;
sq_pushnull(pVM);
}
}
else
sq_pushnull(pVM);
return 1;
}
示例9: process
void CIARunAway::process(const std::shared_ptr<Logic::IMessage> &message)
{
if (message->getType() == "CHANGE_TARGET")
{
CEntity* ent = dynamic_cast<CHANGE_TARGET*>(message.get())->getLogicEntity();
if(ent != NULL)
{
if(!ent->getIsDead())
{
_target = ent;
if (_target->getCenterPosition().x > _entity->getCenterPosition().x)
{
_direction = -1;
}
else
{
_direction = 1;
}
std::shared_ptr<Logic::TURN> m(new Logic::TURN());
m->setInt(_direction);
_entity->emitMessage(m);
}
}
}
} // process
示例10: process
void CLifeModifier::process(CMessage *message) {
CMessageUInt* rxMsg = static_cast<CMessageUInt*>(message);
CEntity* entity = _entity->getMap()->getEntityByID( rxMsg->getUInt() );
CMessageUInt *txMsg = new CMessageUInt();
//LifeModifier manda un mensaje al componente LIFE.cpp
// mensaje TIPO LIFE_MODIFIER. Action = DAMAGE, HEAL
txMsg->setType(Message::LIFE_MODIFIER);
//PT. se carga en el entero el modificador de vida (negativo o positivo)
//txMsg->setUInt( abs(_LIFE_MODIFIER) );
txMsg->setUInt(_LIFE_MODIFIER );
if (_LIFE_MODIFIER < 0)
txMsg->setAction(Message::DAMAGE);
else if(_LIFE_MODIFIER > 0)
txMsg->setAction(Message::HEAL);
//PT. It just worth sending message when it hurts or heals, when is 0 doesnt worthy
if(_LIFE_MODIFIER != 0 && _entity!=NULL)
entity->emitMessage(txMsg, this);
} // process
示例11: process
void CEnemyMeleeAttack::process(const std::shared_ptr<Logic::IMessage> &message)
{
if(message->getType() == "CONTROLLER_TOUCHED")
{
CEntity* other = dynamic_cast<CONTROLLER_TOUCHED*>(message.get())->getEntidad();
if(other->getEntityID() == _targetID && _entity->getTag() == "enemy" && canDoDamage())
{
ApplyDamage(other);
}
}
else if (message->getType() == "CHANGE_TARGET")
{
// Si no encuentra la palabra "Minion" en el tipo de entidad, entonces puede canibalizar
if (_entity->getType().find("Minion") == std::string::npos)
{
_target = dynamic_cast<CHANGE_TARGET*>(message.get())->getLogicEntity();
if (_target)
_targetID = _target->getEntityID();
}
}
} // process
示例12: SetHealthEx
//AVO: directly set entity health instead of going throuhg normal health property which operates on delta
void CScriptGameObject::SetHealthEx(float hp)
{
CEntity *obj = smart_cast<CEntity*>(&object());
if (!obj) return;
clamp(hp, -0.01f, 1.0f);
obj->SetfHealth(hp);
}
示例13: StartATM
void CBank::StartATM()
{
double time1, sim_time = executive->SimulationTime();
CDistribution dist;
CEntity * client;
if(atm_free){
if(!atm_queue->EhVazia()){
// Get call from queue
client = (CEntity *) atm_queue->ObterInfo();
atm_queue->Remover();
client->SetActivity(STARTATM);
// Collect stats on call waiting
client_wait.Add(time - client->start);
atm_wait.Add(time - client->start);
client->start = time;
if(_DEBUG_) printf("ATM Starts %f \n", time);
// Calculate call ending time
time1 = sim_time + dist.NormalLimited(atm_service_mean, atm_service_stddev, min_service, max_service);
// Schedule end of conversation time
executive->AddActivity(time1, ENDATM, client);
// atm isn't free
atm_free = false;
}
}
}
示例14: Lock
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CUICreateChar::Reset()
{
Lock(FALSE);
m_iSelectedJob = 0;
m_fZDelta = 0.0f;
m_fRotDelta = 0.0f;
m_ebCharName.ResetString();
// 카메라 설정, 캐릭터 위치 설정.
for(int i = 0; i < MAXJOB; ++i)
{
const int iMarker = _aiMarkerEntities[i];
CEntity *penMarker = m_pWorld->EntityFromID(iMarker);
penMarker->SetSkaModel(JobInfo().GetFileName(i));
g_CharacterAngle[i] = penMarker->GetPlacement().pl_OrientationAngle(1);
CModelInstance* pMI = penMarker->GetModelInstance();
if(pMI)
{
INDEX idAttackIdle = ska_GetIDFromStringTable( JobInfo().GetAnimationName( i, ANIM_IDLE ) );
pMI->AddAnimation(idAttackIdle, AN_LOOPING|AN_NORESTART|AN_CLEAR, 1, 0);
}
}
#if defined(G_BRAZIL)
CharWearing();
#endif
ChangeSelJob();
m_bIsShowMessageInfo = _pGameState->IsCreatableNightShadow();
}
示例15: Reset
void CGameWorld::Tick()
{
if(m_ResetRequested)
Reset();
if(!m_Paused)
{
if(GameServer()->m_pController->IsForceBalanced())
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, "Teams have been balanced");
// update all objects
for(int i = 0; i < NUM_ENTTYPES; i++)
for(CEntity *pEnt = m_apFirstEntityTypes[i]; pEnt; )
{
m_pNextTraverseEntity = pEnt->m_pNextTypeEntity;
pEnt->Tick();
pEnt = m_pNextTraverseEntity;
}
for(int i = 0; i < NUM_ENTTYPES; i++)
for(CEntity *pEnt = m_apFirstEntityTypes[i]; pEnt; )
{
m_pNextTraverseEntity = pEnt->m_pNextTypeEntity;
pEnt->TickDefered();
pEnt = m_pNextTraverseEntity;
}
}
RemoveEntities();
}