Vector2 AdapterEx::GetBotColonyCenter() { // We didn't calculate player colony center yet ? if (m_botColonyCenter == Vector2::Null()) { GameEntity *pPlayerBase = nullptr; vector<TID> playerBases; g_Game->Self()->GetBases(playerBases); // Player has at least one base, then we use the first one // Note that player having many bases it not supported by the engine if (!playerBases.empty()) pPlayerBase = g_Game->Self()->GetEntity(playerBases[0]); // No base! This is weird but for the case, we will select the first unit position as the player coloney center else { vector<TID> playerEntities; g_Game->Self()->Entities(playerEntities); // This can't happen, If the player has no entities, then he must be losing assert(!playerEntities.empty()); pPlayerBase = g_Game->Self()->GetEntity(playerEntities[0]); } m_botColonyCenter.X = pPlayerBase->Attr(EOATTR_PosX); m_botColonyCenter.Y = pPlayerBase->Attr(EOATTR_PosY); } return m_botColonyCenter; }
void EntityManager::animate (float delay) { if (!isEmpty()) { EntityList::iterator it; EntityList::iterator oldit = entityList.begin (); //bool isBegin = false; for (it = entityList.begin (); it != entityList.end () && !isEmpty();) { GameEntity *e = *it; oldit = it; it++; if (e->getDying()) { entityList.erase(oldit); e->onDying(); delete e; //e == NULL; mItems--; } // endif else e->animate(delay); } // end for } }
void HealSkillComponent::fireSkill(void) { if(this->_target != nullptr) { GameEntity* healingbolt = new GameEntity(this->_game, D3DXVECTOR3(5, 5, 5)); healingbolt->SetType(Projectile); healingbolt->setPosition(this->_entity->getPosition()); healingbolt->setDirection(D3DXVECTOR3(this->_entity->getDirection().x, 0, this->_entity->getDirection().z)); healingbolt->setVelocity(5); ScaledBoxGraphicsComponent* graphics = new ScaledBoxGraphicsComponent(this->_game, healingbolt, D3DCOLOR_RGBA(0,255,0,150)); RadiusBasedCollisionComponent* collision = new RadiusBasedCollisionComponent(this->_game, healingbolt, 10, this->_group, Heal); AIControllerComponent* aiController = new AIControllerComponent(this->_game, healingbolt); LinearPathfindingComponent* pathfinding = new LinearPathfindingComponent(this->_game, healingbolt, aiController); pathfinding->FollowEntity(this->_target); collision->SetTarget(this->_target); healingbolt->AddComponent(aiController); healingbolt->AddComponent(pathfinding); healingbolt->AddComponent(collision); healingbolt->AddGraphicsComponent(graphics); healingbolt->Initialize(); this->_children.push_back(healingbolt); } }
TID AdapterEx::AdaptBuildingForTraining(EntityClassType p_traineeType) { // Gets first building to train entity from type p_traineeType // If no empty building is found, last non-idle building will be returned GamePlayer *pPlayer; GameEntity *pEntity; vector<TID> entityIds; EntityClassType trainerType; TID id = INVALID_TID; trainerType = g_Game->Self()->TechTree()->SourceEntity(p_traineeType); pPlayer = g_Game->Self(); assert(pPlayer); pPlayer->Entities(entityIds); for (size_t i = 0, size = entityIds.size(); i < size; ++i) { pEntity = pPlayer->GetEntity(entityIds[i]); assert(pEntity); if (trainerType == pEntity->Type()) { id = pEntity->Id(); if (pEntity->Attr(EOATTR_State) == OBJSTATE_Idle) { id = pEntity->Id(); break; } } } return id; }
void GamePlayer::OnEntityCreate(Message* p_pMessage) { GameEntity *pEntity = nullptr; TID entityId; EntityCreateMessage *pCreateMsg = nullptr; pCreateMsg = (EntityCreateMessage*)p_pMessage; if (pCreateMsg->Data()->OwnerId == m_id) { entityId = pCreateMsg->Data()->EntityId; if (m_entities.Contains(entityId)) { LogError("Entity %d already exist in Player %s units", entityId, Enums[m_id]); return; } pEntity = FetchEntity(entityId); assert(pEntity); m_entities[entityId] = pEntity; LogInfo("[%s] Unit '%s':%d created at <%d, %d>", Enums[m_id], Enums[pEntity->Type()], pEntity->Id(), pEntity->Attr(EOATTR_PosX), pEntity->Attr(EOATTR_PosY)); g_IMSysMgr.RegisterGameObj(entityId, pCreateMsg->Data()->OwnerId); } }
//---------------------------------------------------------------------------------------------- bool TrainAction::SuccessConditionsSatisfied(RtsGame& game) { bool success = false; bool traineeBeingTrained = false; if (m_trainStarted) { // 1. Trainee unit object exist bool traineeExist = g_Assist.DoesEntityObjectExist(m_traineeId); if (traineeExist) { // 2. Trainee is ready and no more being constructed GameEntity* pTrainee = game.Self()->GetEntity(m_traineeId); _ASSERTE(pTrainee); ObjectStateType traineeState = (ObjectStateType)pTrainee->Attr(EOATTR_State); traineeBeingTrained = traineeState == OBJSTATE_BeingConstructed; if (!traineeBeingTrained) { LogInfo("Action %s succeeded to train trainee=%d from trainer=%d", ToString().c_str(), m_traineeId, m_trainerId); success = true; } } } return success; }
void InfluenceMap::RegisterGameObj(TID objId, PlayerType ownerId) { if (m_registeredObjects.count(objId) == 0) { RegObjEntry *pNewObj = new RegObjEntry; GameEntity *pGameObj = nullptr; GameType *pObjType = nullptr; pNewObj->ObjId = objId; pNewObj->OwnerId = ownerId; pNewObj->Stamped = false; pGameObj = g_Game->GetPlayer(ownerId)->GetEntity(objId); _ASSERTE(pGameObj); pNewObj->LastPosition = Vector2(-1, -1); pObjType = g_Game->GetEntityType((EntityClassType)pGameObj->TypeId()); _ASSERTE(pObjType); pNewObj->ObjWidth = pObjType->P(TP_Width) + pObjType->P(TP_BuildingExpansionIncrement); pNewObj->ObjHeight = pObjType->P(TP_Height); m_registeredObjects[objId] = pNewObj; } }
//-------------------------`--------------------------------------------------------------------- void BuildActionEx::HandleMessage(Message* p_pMsg, bool& p_consumed) { if(State() == ESTATE_Executing && p_pMsg->MessageTypeID() == MSG_EntityCreate) { EntityCreateMessage* pMsg = static_cast<EntityCreateMessage*>(p_pMsg); TID buildingId; GameEntity *pGameBuilding; Vector2 msgBuildPosition; if (pMsg->Data()->OwnerId != PLAYER_Self) return; assert(pMsg && pMsg->Data()); buildingId = pMsg->Data()->EntityId; pGameBuilding = g_Game->Self()->GetEntity(buildingId); assert(pGameBuilding); msgBuildPosition.X = pMsg->Data()->X; msgBuildPosition.Y = pMsg->Data()->Y; if (msgBuildPosition.X == _buildPosition.X && msgBuildPosition.Y == _buildPosition.Y) { _buildingId = pGameBuilding->Id(); _buildStarted = true; } } }
VideoComponent::VideoComponent(GameEntity* owner) : GameComponent(owner, "VideoComponent"), m_startTime(0), m_data(0x0), m_playing(false), m_material(0), m_resize(false), m_bgraData(0x0), m_pgf(0x0), m_videoTexture(0), m_samplerIndex(-1), m_originalSampler(0), m_autoStart(false), m_loop(false), m_startNextFrame(false), m_newData(false), m_hasAudio(false), m_camId(0) { VideoManager::instance()->addComponent(this); // We need our own access to the com library for not disturbing others (like the SapiComponent) CoInitializeEx(NULL, COINIT_MULTITHREADED); // Listen to cam changes owner->addListener(GameEvent::E_ACTIVE_CAM_CHANGE, this); // And get the current one // First the GameEngine id int camID = 0; GameEvent camEvent(GameEvent::E_GET_ACTIVE_CAM, &GameEventData(&camID), this); GameModules::gameWorld()->executeEvent(&camEvent); // Then the entity GameEntity* camEntity = GameModules::gameWorld()->entity(camID); if (camEntity) { // And finally the horde id, puh! GameEvent getHordeID(GameEvent::E_GET_SCENEGRAPH_ID, &m_camId, this); camEntity->executeEvent(&getHordeID); } m_hdd = DrawDibOpen(); m_hdc = CreateCompatibleDC(0); }
void BuildActionEx::FreeResources(RtsGame &game) { if (_builderId != INVALID_TID) { if (!_buildArea.IsNull() && _buildArea.IsLocked()) { // Special buildings (for example addons) are not associated with build positions so no need to assert in that case. _ASSERTE(game.GetEntityType((EntityClassType)_params[PARAM_EntityClassId])->P(TP_IsSpecialBuilding) || !_buildArea.IsNull()); _buildArea.Unlock(this); } if (!_requiredResources.IsNull() && _requiredResources.IsLocked()) { _requiredResources.Unlock(this); } if (_builderId != INVALID_TID) { GameEntity *pEntity = game.Self()->GetEntity(_builderId); if (pEntity && pEntity->IsLocked()) { pEntity->Unlock(this); } _builderId = INVALID_TID; } } }
bool IStrategizer::GatherResourceAction::AliveConditionsSatisfied(RtsGame* pRtsGame) { assert(PlanStepEx::State() == ESTATE_Executing); bool b_gathererExist = false; bool b_resourceExist = false; bool b_alive = false; // 1. Gatherer is still alive b_gathererExist = g_Assist.DoesEntityObjectExist(_gathererId); if (b_gathererExist) { GameEntity* pGameGatherer = pRtsGame->Self()->GetEntity(_gathererId); ObjectStateType gathererState = (ObjectStateType)pGameGatherer->Attr(EOATTR_State); // 2. Gatherer is gathering resource if(gathererState == OBJSTATE_Gathering) { // 3. There is still remaining resource to be gathered b_resourceExist = g_Assist.DoesEntityObjectExist(_resourceId, PLAYER_Neutral); // If resource doesn't exist a new unit should have been gathered by handleMessage // if no resource has been assigned, this means it failed to find suitable resource b_alive = b_resourceExist; } else { b_alive = true; } } return b_alive; }
//---------------------------------------------------------------------------------------------- bool AttackEntityAction::Execute(RtsGame& game, const WorldClock& p_clock) { EntityClassType attackerType = (EntityClassType)_params[PARAM_EntityClassId]; EntityClassType targetType = (EntityClassType)_params[PARAM_TargetEntityClassId]; AbstractAdapter *pAdapter = g_OnlineCaseBasedPlanner->Reasoner()->Adapter(); bool executed = false; // Adapt attacker m_attackerId = pAdapter->GetEntityObjectId(attackerType,AdapterEx::AttackerStatesRank); if (m_attackerId != INVALID_TID) { m_targetId = pAdapter->AdaptTargetEntity(targetType, Parameters()); if (m_targetId != INVALID_TID) { GameEntity* pAttacker = game.Self()->GetEntity(m_attackerId); _ASSERTE(pAttacker); pAttacker->Lock(this); executed = pAttacker->AttackEntity(m_targetId); } } return executed; }
//---------------------------------------------------------------------------------------------- void AttackEntityAction::OnFailure(RtsGame& game, const WorldClock& p_clock) { GameEntity* pAttacker = game.Self()->GetEntity(m_attackerId); if (pAttacker && pAttacker->IsLocked() && pAttacker->Owner() == this) pAttacker->Unlock(this); }
void MyGame::DestroySphereNode(SpherePhysicsNode* node) { node->CollisionCounterToZero(); for (vector<GameEntity*>::iterator i = allEntities.begin(); i != allEntities.end(); ++i) { if (&((*i)->GetPhysicsNode()) == node) { Renderer::GetRenderer().rootMutex.lock(); (*i)->DisconnectFromSystems(); Renderer::GetRenderer().rootMutex.unlock(); destroyedEntitiesMutex.lock(); destroyedEntities.push_back(*i); destroyedEntitiesMutex.unlock(); allEntities.erase(i); for (int i = 0; i < 27; i++) { int x = i % 3; --x; int z = (i / 3) % 3; --z; int y = (i / 9) % 3; --y; float size = node->GetRadius() / 3; GameEntity* newEntity = BuildSphereEntity(size, node->GetPosition() + (Vector3((float)x, (float)y, (float)z) * size)); newEntity->GetPhysicsNode().SetLinearVelocity(node->GetLinearVelocity() + (Vector3((float)x, (float)y, (float)z) * REMAINANT_SPEED)); allEntities.push_back(newEntity); } break; } } node->SetAngularVelocity(Vector3(0, 0, 0)); node->SetLinearVelocity(Vector3(0, 0, 0)); }
void SceneGraphComponent::attach(const Attach* data) { // Get the real horde id H3DNode otherNode = H3DRootNode; GameEntity* entity = GameModules::gameWorld()->entity(data->EntityID); if (entity && m_hordeID > 0) { SceneGraphComponent* component = static_cast<SceneGraphComponent*>(entity->component("Horde3D")); if (component) { component->setParentNode(m_hordeID, data); //otherNode = component->hordeId(); } } /*if(data->Child && strcmp(data->Child,"") != 0 ) { h3dFindNodes( m_hordeID, data->Child, H3DNodeTypes::Undefined ); H3DNode child = h3dGetNodeFindResult(0); h3dSetNodeParent(otherNode, child); } else { h3dSetNodeParent(otherNode, m_hordeID); } h3dSetNodeTransform(otherNode,data->Tx,data->Ty, data->Tz, data->Rx, data->Ry, data->Rz, data->Sx, data->Sy, data->Sz);*/ }
//---------------------------------------------------------------------------------------------- int BuildActionEx::ExecuteAux(unsigned long p_cycles) { EntityClassType builderType; EntityClassType buildingType; GameEntity *pGameBuilder; AbstractAdapter *pAdapter = g_OnlineCaseBasedPlanner->Reasoner()->Adapter(); int ret; builderType = g_Game->Self()->GetWorkerType(); buildingType = (EntityClassType)_params[PARAM_BuildingClassId]; // Initialize build state _buildStarted = false; // Adapt build position assert(pAdapter); _buildPosition = pAdapter->AdaptPositionForBuilding(buildingType); // Adapt builder _builderId = pAdapter->AdaptWorkerForBuild(); // Issue build order pGameBuilder = g_Game->Self()->GetEntity(_builderId); assert(pGameBuilder); pGameBuilder->Lock(); ret = pGameBuilder->Build(buildingType, _buildPosition.X, _buildPosition.Y); return ret; }
GameEntity* MyGame::ShotProjectile(float msec){ GameEntity* g = new MoveSphere(new Cube(), new MoveSpherePhy(Quaternion::AxisAngleToQuaterion(Vector3(0, 1, 0), 0.0f),Vector3(100,0,0))); SceneNode* s = &g->GetRenderNode(); PhysicsNode* p = &g->GetPhysicsNode(); Vector3 CamDir = gameCamera->GetCamDir(); s->SetColour(Vector4(0, 0, 1, 1)); s->type = 1; s->SetBoundingRadius(50); s->SetTransform(Matrix4::Translation(Vector3(1, 1, 1)) * Matrix4::Rotation( 270.0f, Vector3(1, 0, 0))); s->SetModelScale(Vector3(10,10,20)); p->SetDimension(s->GetModelScale()); m_speed = m_speed * 1000; p->SetInverseMass(9.0f); p->SetSphereRadius(50); p->AddForce(CamDir * 7000); p->SetPosition(gameCamera->GetPosition()); p->SetOrientation(Quaternion::EulerAnglesToQuaternion(gameCamera->GetPitch(), gameCamera->GetYaw(), 0.0)); p->isMissile = true; g->ConnectToSystems(); return g; }
void UpdateEntity(GameEntity& entity) { entity.Update(); entity.Play(); // In case of not currently playing. }
GameEntity* MyGame::BackFire(Vector3 pos) { GameEntity* g = new MoveSphere(new Cube(), new MoveSpherePhy(Quaternion::AxisAngleToQuaterion(Vector3(0, 1, 0), 90.0f), pos + Vector3(0, 0, 150))); SceneNode* s = &g->GetRenderNode(); PhysicsNode* p = &g->GetPhysicsNode(); Vector3 CamDir = gameCamera->GetCamDir(); s->SetTransform(Matrix4::Translation(Vector3(1, 1, 1)) * Matrix4::Rotation( 90.0f, Vector3(1, 0, 0))); s->SetColour(Vector4(0, 0, 1, 1)); s->type = 1; // For debug boxes. If 1 = debug boxes ON. s->SetBoundingRadius(50); s->SetModelScale(Vector3(10,10,20)); p->SetDimension(s->GetModelScale()); p->SetInverseMass(12.0f); p->SetSphereRadius(50); p->AddForce(-CamDir * 9000); p->SetOrientation(Quaternion::EulerAnglesToQuaternion(gameCamera->GetPitch(), gameCamera->GetYaw(), 0.0)); p->isMissile = true; p->isBackFire = true; g->ConnectToSystems(); return g; }
void GamePlayer::OnEntityDestroy(Message* p_pMessage) { EntityDestroyMessage *pDestroyMsg = nullptr; GameEntity *pEntity = nullptr; TID entityId; pDestroyMsg = (EntityDestroyMessage*)p_pMessage; if (pDestroyMsg->Data()->OwnerId == m_id) { entityId = pDestroyMsg->Data()->EntityId; assert(m_entities.Contains(entityId)); pEntity = GetEntity(entityId); pDestroyMsg->Data()->EntityType = pEntity->Type(); assert(pEntity); m_entities.erase(entityId); g_IMSysMgr.UnregisterGameObj(entityId); LogInfo("[%s] Unit '%s':%d destroyed", Enums[m_id], Enums[pEntity->Type()], pEntity->Id()); Toolbox::MemoryClean(pEntity); } }
void initialize(ApplicationBase* _app){ app = _app; //Load all resources rsrc1 = _app->_ResourceManager->LoadResource("spr1.png","spr1"); rsrc2 = _app->_ResourceManager->LoadResource("spr3.png","spr2"); rsrc3 = _app->_ResourceManager->LoadResource("ts_01.png","ts_01"); rsrc4 = _app->_ResourceManager->LoadResource("spr2.png","spr3"); //Get surface data from resources Log("rsrc1 = %i", rsrc1); Log("Rsrc1.size() = %i", rsrc1->GetSize()); spr1 = rsrc1->GetData(); spr2 = rsrc2->GetData(); spr3 = rsrc3->GetData(); spr4 = rsrc4->GetData(); //Get Resources here wrldTs = (*_app->_ResourceManager)["ts_01"]; SET_TLBR(gAnims[0],0.0f,0.0f,1.0f,1.0f); SET_TLBR(gAnims[1],0.0f,0.0f,1.0f,1.0f); gAnims[0].pSurf = spr1; gAnims[1].pSurf = spr2; gAnims[0].fAnimSpeed = 1.0f; gAnims[1].fAnimSpeed = 1.0f; gAnims[0].lpNext = &gAnims[1]; gAnims[1].lpNext = &gAnims[0]; sprAnim.setAnimation(&gAnims[0]); sprAnim.setGraphics(_app->_Graphics); entity.SetPos(32,32); entity.SetSurface(spr4); Log("Memory Usage: %f MBytes", ((float)_app->_ResourceManager->GetMemoryUsage())/(1024.0f*1024.0f)); };
void BuildActionEx::HandleMessage(RtsGame& game, Message* p_msg, bool& p_consumed) { if(PlanStepEx::State() == ESTATE_Executing && p_msg->MessageTypeID() == MSG_EntityCreate) { EntityCreateMessage* pMsg = static_cast<EntityCreateMessage*>(p_msg); TID buildingId; GameEntity *pGameBuilding; Vector2 msgBuildPosition; if (pMsg->Data()->OwnerId != PLAYER_Self) return; assert(pMsg && pMsg->Data()); buildingId = pMsg->Data()->EntityId; pGameBuilding = game.Self()->GetEntity(buildingId); assert(pGameBuilding); msgBuildPosition.X = pMsg->Data()->X; msgBuildPosition.Y = pMsg->Data()->Y; if (msgBuildPosition.X == _buildArea.Pos().X && msgBuildPosition.Y == _buildArea.Pos().Y && pGameBuilding->Type() == _params[PARAM_EntityClassId]) { _buildingId = pGameBuilding->Id(); _buildStarted = true; assert(!_requiredResources.IsNull()); _requiredResources.Unlock(this); } } }
bool ResearchAction::Execute(RtsGame& game, const WorldClock& p_clock) { // FIXME: because we don't have a goal for Research for now, we can use the action as a goal // at the same time, by not issuing the research action if it is already done if (game.Self()->TechTree()->ResearchDone((ResearchType)_params[PARAM_ResearchId])) return true; ResearchType researchType = (ResearchType)_params[PARAM_ResearchId]; GameEntity *pGameResearcher; AbstractAdapter *pAdapter = g_OnlineCaseBasedPlanner->Reasoner()->Adapter(); bool executed = false; // Adapt researcher m_researcherId = pAdapter->AdaptBuildingForResearch(researchType); if (m_researcherId != INVALID_TID) { // Issue research order pGameResearcher = game.Self()->GetEntity(m_researcherId); _ASSERTE(pGameResearcher); executed = pGameResearcher->Research(researchType); if (executed) { pGameResearcher->Lock(this); } } return executed; }
void PointBehavior::Apply(Boid& boid) { ofVec2f displacement; int count = 0; GameEntityState& boidState = boid.CurrentState(); for (RIterator it = GetRelevant(boid.Senses.EntitiesInRange); !it.End(); ++it) { count++; GameEntity* entity = it.Current(); // use next state if it has already been calculated, otherwise use GameEntityState& entityState = entity->NextState().IsReady ? entity->NextState() : entity->CurrentState(); ofVec2f offset = entityState.Position - boidState.Position; if (offset.length() < Range) { float inverseDistance = Range - offset.length(); offset.normalize(); ofVec2f weight = offset * inverseDistance * (IsAttractive ? 1: -1); displacement += weight; } } if (count <1) return; boid.NextState().Velocity += displacement * this->Factor; }
int Env::_keyHook(void) { int ch; int moved = 0; while ((ch = getch())) { if (ch == ERR) break ; if ((ch == K_UP || ch == K_DOWN || ch == K_LEFT || ch == K_RIGHT) && moved == 0) { if (ch == K_UP) this->_player->incPosXY(0, -1); else if (ch == K_DOWN) this->_player->incPosXY(0, 1); else if (ch == K_LEFT) this->_player->incPosXY(-1, 0); else if (ch == K_RIGHT) this->_player->incPosXY(1, 0); moved = 1; } else if (ch == K_SPACE) { GameEntity *bullet = new GameEntity(this->_player->getPosX()+1, this->_player->getPosY()); bullet->setMaxMinXY(MAP_LIMITS); bullet->setDirXY(1, 0); addBullet(*bullet); this->_player->shoots++; } else if (ch == ECHAP) return (-1); } return (0); }
TID AdapterEx::AdaptTargetEntity(EntityClassType p_targetType, const PlanStepParameters& p_parameters) { GamePlayer *pPlayer; GameEntity *pEntity; vector<TID> entityIds; TID adaptedTargetId = INVALID_TID; double bestDistance = numeric_limits<double>::max(); CellFeature *pTarGetCellFeatureFromWorldPosition = new CellFeature(p_parameters); pPlayer = g_Game->Enemy(); assert(pPlayer); pPlayer->Entities(entityIds); for (size_t i = 0, size = entityIds.size(); i < size; ++i) { pEntity = pPlayer->GetEntity(entityIds[i]); assert(pEntity); if (p_targetType == pEntity->Type()) { CellFeature *pCandidateCellFearure = g_Game->Map()->GetCellFeatureFromWorldPosition(pEntity->GetPosition()); double dist = pTarGetCellFeatureFromWorldPosition->GetDistance(pCandidateCellFearure); if (dist <= bestDistance) { bestDistance = dist; adaptedTargetId = pEntity->Id(); } } } return adaptedTargetId; }
bool TrainAction::Execute() { LogActivity(Execute); EntityClassType traineeType = (EntityClassType)_params[PARAM_EntityClassId]; GameEntity *pGameTrainer; AbstractAdapter *pAdapter = g_OnlineCaseBasedPlanner->Reasoner()->Adapter(); bool executed = false; // Adapt trainer m_trainerId = pAdapter->AdaptBuildingForTraining(traineeType); if (m_trainerId != INVALID_TID) { // Issue train order pGameTrainer = g_Game->Self()->GetEntity(m_trainerId); _ASSERTE(pGameTrainer); executed = pGameTrainer->Train(traineeType); if (executed) { pGameTrainer->Lock(this); } } return executed; }
float MountMg42::GetPriority() { if ( IsActive() || GetClient()->HasEntityFlag( ETQW_ENT_FLAG_MOUNTED ) ) return GetLastPriority(); BitFlag64 entFlags; GoalManager::Query qry( 0xe1a2b09c /* MOUNTMG42 */, GetClient() ); System::mInstance->mGoalManager->GetGoals( qry ); for ( uint32_t i = 0; i < qry.mList.size(); ++i ) { if ( BlackboardIsDelayed( qry.mList[ i ]->GetSerialNum() ) ) continue; GameEntity gunOwner = InterfaceFuncs::GetMountedPlayerOnMG42( GetClient(), qry.mList[ i ]->GetEntity() ); int gunHealth = InterfaceFuncs::GetGunHealth( GetClient(), qry.mList[ i ]->GetEntity() ); bool bBroken = InterfaceFuncs::IsMountableGunRepairable( GetClient(), qry.mList[ i ]->GetEntity() ); if ( bBroken ) continue; EntityInfo entInfo; if ( !IGame::GetEntityInfo( qry.mList[ i ]->GetEntity(), entInfo ) || !entInfo.mFlags.CheckFlag( ETQW_ENT_FLAG_ISMOUNTABLE ) ) continue; // Make sure nobody has it mounted. if ( ( !gunOwner.IsValid() || !GetClient()->IsAllied( gunOwner ) ) && ( gunHealth > 0 ) ) { mMapGoal = qry.mList[ i ]; break; } } return mMapGoal ? mMapGoal->GetPriorityForClient( GetClient() ) : 0.f; }
void Level1::Init() { //m_Background = new Surface("assets/backgrounds/spooky.png"); m_Background = new Surface("assets/backgrounds/background_city2.3.png"); if (m_Player == nullptr) { GameEntity *player = GameEntityFactory::getInstance().getGameEntity(eGameEntity::Player); m_Player = player; } //new level this->addEntities(m_Player);//(TODO: check if already is in this list??!) m_Player->setStartingPosition(100, 410 - 53 - 150); //set to world coordinates m_Camera->setEntityFocus(m_Player); //load xml loadXML(1); //change this to new level //TODO moet op de surface komen GameEntity* entityTutorial = GameEntityFactory::getInstance().getGameEntity(eGameEntity::Tutorial_Level1); entityTutorial->setStartingPosition(210, 20); this->addEntities(entityTutorial); SoundManager::getInstance().StopMusic(); SoundManager::getInstance().PlayMusic(eMusic::Street); }
void GameWorld::renameEntity(const unsigned int oldId, const EntityID& newId) { GameEntity* entityPtr = entity(oldId); if(entityPtr) { renameEntity( entityPtr->id(), newId ); } }