void EntityManager::ResetManager() { //iterate through the first map map<ComponentTypes, map<unsigned int, IComponent*>>::iterator it = component_store_.begin(); //and for each nested map, iterate through them and delete their components for(; it != component_store_.end(); it++ ) { map<unsigned int, IComponent*> nested = it->second; map<unsigned int, IComponent*>::iterator nested_it = nested.begin(); for(; nested_it != nested.begin(); nested_it++ ) { KillEntity(nested_it->first); if(nested_it->second) { delete nested_it->second; nested_it->second = 0; } } } //clear the main map component_store_.clear(); //clear entities all_entities_.clear(); //reset lowest ID lowest_unassigned_entity_id_ = 1; }
//void CEntity::Hit (float perc, Fvector &dir, CObject* who, s16 element,Fvector position_in_object_space, float impulse, ALife::EHitType hit_type) void CEntity::Hit (SHit* pHDS) { // if (bDebug) Log("Process HIT: ", *cName()); // *** process hit calculations // Calc impulse Fvector vLocalDir; float m = pHDS->dir.magnitude(); VERIFY (m>EPS); // convert impulse into local coordinate system Fmatrix mInvXForm; mInvXForm.invert (XFORM()); mInvXForm.transform_dir (vLocalDir,pHDS->dir); vLocalDir.invert (); // hit impulse if(pHDS->impulse) HitImpulse (pHDS->impulse,pHDS->dir,vLocalDir); // @@@: WT // Calc amount (correct only on local player) float lost_health = CalcCondition(pHDS->damage()); // Signal hit if(BI_NONE!=pHDS->bone()) HitSignal(lost_health,vLocalDir,pHDS->who,pHDS->boneID); // If Local() - perform some logic if (Local() && !g_Alive() && !AlreadyDie() && (m_killer_id == ALife::_OBJECT_ID(-1))) { KillEntity (pHDS->whoID); } //must be last!!! @slipch inherited::Hit(pHDS); }
void CCar::ChangeCondition (float fDeltaCondition) { CEntity::CalcCondition(-fDeltaCondition); CDamagableItem::HitEffect(); if (Local() && !g_Alive() && !AlreadyDie()) KillEntity (Initiator()); // if(Owner()&&Owner()->ID()==Level().CurrentEntity()->ID()) // CurrentGameUI()->UIMainIngameWnd->CarPanel().SetCarHealth(GetfHealth()); }
void GameView::KillAllMonsters() { for (auto it = m_entities.begin(); it != m_entities.end(); ++it ) { auto pMonster = dynamic_cast<Monster*>(*it); if (pMonster) { KillEntity(pMonster); } } }