void DebugRoom::Load() { Game::Get()->GetResourceManager()->LoadTexture("Debug Background","droom.png"); lpe::Background* bg = new lpe::Background(); bg->Add(Game::Get()->GetResourceManager()->GetTexture("Debug Background")); ApplyBackground(bg); AddHitboxVertex(0, 0, 0); AddHitboxVertex(60, 0, 0); AddHitboxVertex(100, 2000, 0); AddHitboxVertex(0, 2000, 0); /**//* AddHitboxVertex(50, 50, 0); AddHitboxVertex(110, 50, 0); AddHitboxVertex(150, 2050, 0); AddHitboxVertex(50, 2050, 0); /**/ AddHitboxVertex(60, 0, 1); AddHitboxVertex(1120, 0, 1); AddHitboxVertex(1120, 58, 1); AddHitboxVertex(60, 65, 1); AddHitboxVertex(1116, 0, 2); AddHitboxVertex(1370, 0, 2); AddHitboxVertex(1365, 558, 2); AddHitboxVertex(1118, 563, 2); /**/ CalculateHitboxes(); AddEntity(new Player(sf::Vector2f(180, 180)))->Load(); AddEntity(new TruffleMint(sf::Vector2f(200, 350)))->Load(); AddEntity(new TruffleMint(sf::Vector2f(350, 200)))->Load(); }
void GameView::GenerateMap() { Vector2 mapCenter((float)m_pTilemap->getWidth() * .5f, (float)m_pTilemap->getHeight() * .5f); m_pStockpile = new Stockpile(this, m_pTilemap->getWidth() / 2 + 1, m_pTilemap->getHeight() / 2 - 4); AddEntity(m_pStockpile); // Spawn a bunch of trees for (int i = 0; i < TREE_DENSITY; ++i) { auto center = onut::rand2f(Vector2::Zero, Vector2((float)m_pTilemap->getWidth(), (float)m_pTilemap->getHeight())); int count = onut::randi(2, 12); for (int j = 0; j < count; ++j) { auto pos = center += onut::rand2f(Vector2(-3), Vector2(3)); pos.x = std::round(pos.x) + .5f; pos.y = std::round(pos.y) + .5f; if (pos.x >= mapCenter.x - 3 && pos.y >= mapCenter.y - 3 && pos.x <= mapCenter.x + 3 && pos.y <= mapCenter.y + 3) continue; if (pos.x < 1.f || pos.y < 1.f || pos.x >(float)m_pTilemap->getWidth() - 1.f || pos.y >(float)m_pTilemap->getHeight() - 1.f) continue; auto pTile = GetTileAt(pos); if (!pTile) continue; if (pTile->isOccupied) continue; pTile->isOccupied = true; auto pTree = new Tree(this, pos); AddEntity(pTree); } } // Spawn a bunch of rockz for (int i = 0; i < ROCK_DENSITY; ++i) { auto center = onut::rand2f(Vector2::Zero, Vector2((float)m_pTilemap->getWidth(), (float)m_pTilemap->getHeight())); int count = onut::randi(2, 6); for (int j = 0; j < count; ++j) { auto pos = center += onut::rand2f(Vector2(-3), Vector2(3)); pos.x = std::round(pos.x) + .5f; pos.y = std::round(pos.y) + .5f; if (pos.x >= mapCenter.x - 3 && pos.y >= mapCenter.y - 3 && pos.x <= mapCenter.x + 3 && pos.y <= mapCenter.y + 3) continue; if (pos.x < 1.f || pos.y < 1.f || pos.x >(float)m_pTilemap->getWidth() - 1.f || pos.y >(float)m_pTilemap->getHeight() - 1.f) continue; auto pTile = GetTileAt(pos); if (!pTile) continue; if (pTile->isOccupied) continue; pTile->isOccupied = true; auto pRock = new Rock(this, pos); AddEntity(pRock); } } for (int i = 0; i < m_pTilemap->getWidth(); ++i) { GetTileAt(i, 0)->isOccupied = true; GetTileAt(0, i)->isOccupied = true; GetTileAt(i, m_pTilemap->getHeight() - 1)->isOccupied = true; GetTileAt(m_pTilemap->getWidth() - 1, i)->isOccupied = true; } }
VOID InsertTDIInterfaceEntity( PIP_INTERFACE Interface ) { AddEntity(IF_ENTITY, Interface, IF_MIB); AddEntity(AT_ENTITY, Interface, (Interface != Loopback) ? AT_ARP : AT_NULL); /* FIXME: This is probably wrong */ AddEntity(CL_NL_ENTITY, Interface, CL_NL_IP); }
/** Adds a scenegraph Entity to this vfcOctree Entity unless max nodes has been reached. If MAX_INITIAL_NODES_BEFORE_SUBDIVISION is reached, subdivision hasn't yet been done and MAX_SUBDIVISION hasn't been reached, subdivision occurs. */ bool PhysicsOctree::AddEntity(Entity * targetEntity) { // Check that it isn't already added! bool exists = entities.Exists(targetEntity); if (exists){ std::cout<<"\nAdding Entity to PhysicsOctree while it already exists!"; assert("Adding Entity to PhysicsOctree while it already exists!" && false); return false; } // If we have children, check if it fits in any of them. if (child[0]) { int result = OUTSIDE; for (int i = 0; i < MAX_CHILDREN; ++i) { result = child[i]->IsEntityInside(targetEntity); switch(result) { case OUTSIDE: // If the Entity is outside, just check next octree-section~ continue; case INTERSECT: // If intersecting, don't do anything. Check all children and handle intersections after this for-loop. break; case INSIDE: // If it is inside, continue down the chain and then return from hierrr. return child[i]->AddEntity(targetEntity); } } // If we arrived here, it's either intersecting or something, so add it to our current children since it can't go further down the tree. entities.Add(targetEntity); // Set pointer for the entity too now targetEntity->physics->octreeNode = this; return true; } /// End of trying to enter it into any of our children // Okay, no spot in children, check if we should subdivide it (if the children aren't already allocated, that is!) if (entities.Size() > MAX_INITIAL_NODES_BEFORE_SUBDIVISION && child[0] == NULL && this->subdivision < MAX_SUBDIVISION){ // Subdivide and then try push all our children down the tree further, so they don't get stuck here without reason. subdivide(); List<Entity*> tempList(entities); entities.Clear(); for (int j = 0; j < tempList.Size(); ++j){ AddEntity(tempList[j]); } // Return if we subdivided, just make sure we try to add our new child to the subdivision too. return AddEntity(targetEntity); } // Alright, children are out, just add it now then. entities.Add(targetEntity); targetEntity->physics->octreeNode = this; return true; }
void SkyboxTestScene::Initialize() { //Fonts //************************** m_pDebugFont = ContentManager::Load<SpriteFont>("Resources/Fonts/Consolas_32.fnt"); //Camera //************************** //auto cam = new OrbitCamera(); //AddEntity(cam); //Materials //************************** m_pMat = new TexPBRMaterial( "Resources/Textures/BaseColor.png", "Resources/Textures/Roughness.png", "Resources/Textures/Metalness.png", "Resources/Textures/AOMap.png", "Resources/Textures/NormalMap.png"); m_pMat->SetSpecular(0.5f); //Skybox //************************** //SetSkybox("Resources/Textures/CharlesRiver_Ref.hdr"); //SetSkybox("Resources/Textures/Harbour_3_Ref.hdr"); SetSkybox("Resources/Textures/Ice_Lake_Ref.hdr"); //SetSkybox("Resources/Textures/TropicalRuins_3k.hdr"); //SetSkybox("Resources/Textures/WinterForest_Ref.hdr"); //Models //************************* auto pModelComp = new ModelComponent("Resources/Models/helmet.dae"); pModelComp->SetMaterial(m_pMat); auto pHelmet = new Entity(); pHelmet->AddComponent(pModelComp); pHelmet->GetTransform()->Translate(vec3(0, 0, 0)); AddEntity(pHelmet); //Lights //************************** m_pLigEntity = new Entity(); m_pLight = new DirectionalLight(vec3(1, 1, 1), 0.99f); m_pLight->SetShadowEnabled(true); m_pLigEntity->AddComponent(new LightComponent( m_pLight)); m_pLigEntity->GetTransform()->Scale(0.1f, 0.1f, 0.1f); //m_pLigEntity->GetTransform()->SetRotation(glm::lookAtLH()) AddEntity(m_pLigEntity); SETTINGS->Window.VSync(true); }
void GameView::SpawnMonster() { if (Monster::count >= MAX_MONSTER_COUNT) return; for (int tries = 0; tries < 10; ++tries) { int side = onut::randi() % 4; Vector2 spawnPos; switch (side) { case 0: spawnPos = onut::rand2f(Vector2::Zero, Vector2((float)m_pTilemap->getWidth(), 2.5f)); break; case 1: spawnPos = onut::rand2f(Vector2::Zero, Vector2(2.5f, (float)m_pTilemap->getHeight())); break; case 2: spawnPos = onut::rand2f(Vector2((float)m_pTilemap->getWidth() - 2.5f, 0.f), Vector2(Vector2((float)m_pTilemap->getWidth(), (float)m_pTilemap->getHeight()))); break; case 3: spawnPos = onut::rand2f(Vector2(0.f, (float)m_pTilemap->getHeight() - 2.5f), Vector2(Vector2((float)m_pTilemap->getWidth(), (float)m_pTilemap->getHeight()))); break; } spawnPos.x = std::round(spawnPos.x) + .5f; spawnPos.y = std::round(spawnPos.y) + .5f; auto pTile = GetTileAt(spawnPos); if (!pTile) continue; if (!pTile->isOccupied) { auto pMonster = new Monster(MonsterType::CRAWLER, this, spawnPos); AddEntity(pMonster); break; } } }
bool ETHScene::ReadFromXMLFile(TiXmlElement *pRoot) { m_sceneProps.ReadFromXMLFile(pRoot); TiXmlNode *pNode = pRoot->FirstChild(GS_L("EntitiesInScene")); if (pNode) { TiXmlElement *pEntities = pNode->ToElement(); if (pEntities) { pNode = pEntities->FirstChild(GS_L("Entity")); if (pNode) { TiXmlElement *pEntityIter = pNode->ToElement(); if (pEntityIter) { do { ETHRenderEntity* entity = new ETHRenderEntity(pEntityIter, m_provider, ++m_idCounter); AddEntity(entity); pEntityIter = pEntityIter->NextSiblingElement(); } while (pEntityIter); } } } } return true; }
virtual void OnIterStart(SActivationInfo *pActInfo) { const int type = GetPortInt(pActInfo, EIP_Type); IEntitySystem *pEntitySystem = gEnv->pEntitySystem; if (pEntitySystem) { IEntityItPtr iter = pEntitySystem->GetEntityIterator(); if (iter) { iter->MoveFirst(); IEntity *pEntity = NULL; while (!iter->IsEnd()) { pEntity = iter->Next(); if (pEntity) { const EntityId id = pEntity->GetId(); const EEntityType entityType = GetEntityType(id); if (IsValidType(type, entityType)) { AddEntity(id); } } } } } }
Bullet* EntitySpawner::spawnBullet(int playerid, int teamid, int damage, WeaponType shooter, BulletCollisionHandler* handler, btRigidBody* bullet_body, btDiscreteDynamicsWorld* physicsWorld) { // Create Bullet and add to Entity Map //Bullet* fireProjectile = new Bullet(oid_bullet, playerid, teamid, damage, pos, velocity, rotation, physicsWorld); Bullet* fireProjectile = new Bullet(oid_bullet, playerid, teamid, damage, handler, bullet_body, physicsWorld); AddEntity(ClassId::BULLET, oid_bullet, fireProjectile); oid_bullet++; // Send Bullet Spawn packet btVector3 vec = fireProjectile->GetEntityPosition(); btQuaternion quat = fireProjectile->GetEntityRotation(); //printf("Created Bullet at (%f,%f,%f)\n", vec.getX(), vec.getY(), vec.getZ()); PosInfo out; out.cid = ClassId::BULLET; out.oid = fireProjectile->GetObjectId(); out.x = vec.getX(); out.y = vec.getY(); out.z = vec.getZ(); out.sub_id = shooter; out.rotw = quat.getW(); out.rotx = quat.getX(); out.roty = quat.getY(); out.rotz = quat.getZ(); ServerGame::instance()->sendSpawnPacket(out); return fireProjectile; }
Player* EntitySpawner::spawnPlayer(int teamid, PosInfo pos, btDiscreteDynamicsWorld* physicsWorld) { // Create player and add to Entity Map // note - need to create players with explicit id or else teams will depend on order they connected to the lobby Player* newPlayer = new Player(pos.id, pos.team_id, pos, physicsWorld); AddEntity(ClassId::PLAYER, pos.id, newPlayer); oid_player++; btQuaternion quat = newPlayer->GetEntityRotation(); // Send Player Spawn packet btVector3 vec = newPlayer->GetEntityPosition(); printf("Created player %d at (%f,%f,%f) on team %d\n", pos.id, vec.getX(), vec.getY(), vec.getZ(),pos.team_id ); // Send spawn info to the clients PosInfo out; out.cid = ClassId::PLAYER; out.oid = newPlayer->GetObjectId(); out.skin = pos.skin; out.team_id = pos.team_id; out.x = vec.getX(); out.y = vec.getY(); out.z = vec.getZ(); out.rotw = quat.getW(); out.rotx = quat.getX(); out.roty = quat.getY(); out.rotz = quat.getZ(); ServerGame::instance()->sendSpawnPacket(out); return newPlayer; }
bool ETHScene::ReadFromXMLFile(TiXmlElement *pRoot) { m_sceneProps.ReadFromXMLFile(pRoot); TiXmlNode *pNode = pRoot->FirstChild(GS_L("EntitiesInScene")); if (pNode) { TiXmlElement *pEntities = pNode->ToElement(); if (pEntities) { pNode = pEntities->FirstChild(GS_L("Entity")); if (pNode) { TiXmlElement *pEntityIter = pNode->ToElement(); if (pEntityIter) { do { ETHRenderEntity* entity = new ETHRenderEntity(pEntityIter, m_provider); AddEntity(entity); pEntityIter = pEntityIter->NextSiblingElement(); } while (pEntityIter); } } } } m_provider->GetShaderManager()->SetParallaxIntensity(m_sceneProps.parallaxIntensity); return true; }
void WBScene::Load( const IDataStream& Stream ) { XTRACE_FUNCTION; const uint Version = Stream.ReadUInt32(); if( Version >= VERSION_UID ) { m_UID = Stream.ReadUInt32(); } if( Version >= VERSION_LASTENTITYSCENEHANDLE ) { m_LastEntitySceneHandle = Stream.ReadUInt32(); } uint NumEntities = Stream.ReadUInt32(); for( uint EntityIndex = 0; EntityIndex < NumEntities; ++EntityIndex ) { WBEntity* pNewEntity = new WBEntity; pNewEntity->Load( Stream ); AddEntity( pNewEntity, pNewEntity->GetSceneHandle() ); WBWorld::GetInstance()->AddEntity( pNewEntity, pNewEntity->GetUID() ); pNewEntity->SendOnInitializedEvent(); } }
bool CMOOSNavEngine::AddAcousticBeacon(const string & sName, int nChan, double dfTAT, double dfX, double dfY, double dfZ) { ////////////////////////////////////////// // add a beacon CMOOSNavBeacon* pBeacon = new CMOOSNavBeacon; pBeacon->m_sName = sName; pBeacon->m_nID = GetNextID(); pBeacon->m_State.m_dfX = dfX; pBeacon->m_State.m_dfY = dfY; pBeacon->m_State.m_dfZ = dfZ; pBeacon->m_dfTAT = dfTAT; pBeacon->m_nChan = nChan; if(AddEntity(pBeacon)) { // MOOSTrace("Added Beacon :\n\t"); // pBeacon->Trace(); m_Beacons.push_front(pBeacon); } return true; }
void Scene::Load(pugi::xml_node *entityNode) { for (pugi::xml_node_iterator it = entityNode->begin(); it != entityNode->end(); ++it) { if (strcmp(it->name(), "layer") == 0) { int layer = it->attribute("layer_number").as_int(); for (pugi::xml_node_iterator it2 = it->begin(); it2 != it->end(); ++it2) { pugi::xml_node iterator_entity = *it2; if (strcmp(it2->name(), "entity") == 0) { Entity *entity = new Entity(&this); entity->Load(&iterator_entity, resourceManager); AddEntity(entity, layer); } } } } //m_entityManager.SetWorldSize(2); }
//--------------------------------------------------------------------------------------------- void TShowTankWoT_test::ShowTank(int index, Ogre::Vector3& pos) { // вставка Танка, прототип модели Ogre::SceneManager* pSM = TModuleLogic::Get()->GetC()->pGraphicEngine->GetGE()->GetSceneManager(); TOrient orGun (Ogre::Vector3(1,0,0), Ogre::Radian( 3.14f/2), Ogre::Vector3(10,-10,10), Ogre::Vector3(0, 3, 4) + pos); TOrient orHull (Ogre::Vector3(1,0,0), Ogre::Radian(-3.14f/2), Ogre::Vector3(10,-10,10), Ogre::Vector3(0, -10,-10) + pos); TOrient orChassisL(Ogre::Vector3(1,0,0), Ogre::Radian(-3.14f/2), Ogre::Vector3(10, 10,10), Ogre::Vector3(0, -20,-10) + pos); TOrient orChassisR(Ogre::Vector3(1,0,0), Ogre::Radian(-3.14f/2), Ogre::Vector3(10, 10,10), Ogre::Vector3(0, -20,-10) + pos); TOrient orTurret (Ogre::Vector3(1,0,0), Ogre::Radian(-3.14f/2), Ogre::Vector3(10,-10,10), Ogre::Vector3(0, 0,-10) + pos); TOrient orTrackL (Ogre::Vector3(1,0,0), Ogre::Radian(-3.14f/2), Ogre::Vector3(10, 10,10), Ogre::Vector3(0, -20,-10) + pos); TOrient orTrackR (Ogre::Vector3(1,0,0), Ogre::Radian(-3.14f/2), Ogre::Vector3(10, 10,10), Ogre::Vector3(0, -20,-10) + pos); char sHull[50], sTurret[50], sChassisL[50], sChassisR[50], sGun[50], sTrackL[50], sTrackR[50]; sprintf(sHull, "Hull%d", index); sprintf(sTurret, "Turret%d", index); sprintf(sChassisL, "ChassisL%d", index); sprintf(sChassisR, "ChassisR%d", index); sprintf(sGun, "Gun%d", index); sprintf(sTrackL, "TrackL%d", index); sprintf(sTrackR, "TrackR%d", index); AddEntity(pSM->createEntity(sHull, "KingTiger/Hull.mesh"), orHull, pSM); AddEntity(pSM->createEntity(sTurret, "KingTiger/Turret.mesh"), orTurret, pSM); AddEntity(pSM->createEntity(sChassisL, "KingTiger/ChassisL.mesh"),orChassisL, pSM); AddEntity(pSM->createEntity(sChassisR, "KingTiger/ChassisR.mesh"),orChassisR, pSM); AddEntity(pSM->createEntity(sGun, "KingTiger/Gun.mesh"), orGun, pSM); AddEntity(pSM->createEntity(sTrackL, "KingTiger/TrackL.mesh"), orTrackL, pSM); AddEntity(pSM->createEntity(sTrackR, "KingTiger/TrackR.mesh"), orTrackR, pSM); }
void CAIThread::OnEntityUpdateActive( const WORD nEntity ) { ASSERT( m_pBotDoc != NULL ); if ( m_pBotDoc->IsReady() ) { CEntity* pEntity = m_pBotDoc->GetEntity( nEntity ); AddEntity( pEntity ); } }
void GameView::CreateEntities() { m_pFireplace = new Fireplace(this, GetMapCenter()); AddEntity(m_pFireplace); // 4 dance pedestral for (int i = 0; i < 4; ++i) { Vector2 pedOffset; if (i == 0) pedOffset = Vector2(-2, -2); if (i == 1) pedOffset = Vector2(2, -2); if (i == 2) pedOffset = Vector2(2, 2); if (i == 3) pedOffset = Vector2(-2, 2); DancePedestral* pedes = new DancePedestral(this, GetMapCenter() + pedOffset, i); m_pedestrals.push_back(pedes); AddEntity(pedes); } }
void EntitySpawner::spawnCollectable(btDiscreteDynamicsWorld* curWorld, PowerupType p_type) { Powerup* pow = nullptr; switch(p_type) { case PowerupType::HEALTHGAIN: printf("spawned healthgain\n"); pow = new HealthGain(); break; case PowerupType::JUMPUP: printf("spawned jumpup\n"); pow = new JumpUp(); break; /*case PowerupType::SPEEDUP: printf("spawned speedup\n"); pow = new SpeedUp(); break;*/ default: { pow = nullptr; break; } } if (pow == nullptr) return; std::pair<int, int> p = getRandomLoc(); PosInfo pos; pos.x = p.first; pos.y = 90; pos.z = p.second; Collectable* ranCollectable = new Collectable(oid_collectable, pos, curWorld, pow); AddEntity(ClassId::COLLECTABLE, oid_collectable, ranCollectable); oid_collectable++; // Send Collectable Spawn packet btVector3 vec = ranCollectable->GetEntityPosition(); btQuaternion quat = ranCollectable->GetEntityRotation(); PosInfo out; out.cid = ClassId::COLLECTABLE; out.oid = ranCollectable->GetObjectId(); out.x = vec.getX(); out.y = vec.getY(); out.z = vec.getZ(); out.sub_id = CollectType::POWERUPCOLLECT; out.rotw = quat.getW(); out.rotx = quat.getX(); out.roty = quat.getY(); out.rotz = quat.getZ(); ServerGame::instance()->sendSpawnPacket(out); }
void ECEditorWindow::AddEntities(const EntityList &entities, bool selectAll) { // SetEntitySelected() will block entity list's signals, no need to do it here. ClearEntities(); foreach(const EntityPtr &entity, entities) { EntityListWidgetItem *item = AddEntity(entity, false); if (selectAll) SetEntitySelected(item, true, false); }
void ECEditorWindow::AddEntities(const QList<entity_id_t> &entities, bool select_all) { // SetEntitySelected() will block entity list's signals, no need to do it here. ClearEntities(); foreach(entity_id_t id, entities) { EntityListWidgetItem *item = AddEntity(id, false); if (select_all) SetEntitySelected(item, true); }
void CTacticalManager::PostSerialize() { // Radar needs player client entity to be set otherwise edge entity items won't show // ENTITY_EVENT_UNHIDE isn't called when loading, since state is already unhided, that usually triggers CActor::ProcessEvent with event type ENTITY_EVENT_UNHIDE // Call the hud event here instead const EntityId playerEntityID = gEnv->pGame->GetIGameFramework()->GetClientActorId(); AddEntity(playerEntityID, CTacticalManager::eTacticalEntity_Unit); SHUDEvent hudevent(eHUDEvent_AddEntity); hudevent.AddData(SHUDEventData((int)playerEntityID)); CHUDEventDispatcher::CallEvent(hudevent); }
bool CMOOSNavEngine::AddTheVehicle(STRING_LIST &sParams) { ////////////////////////////////////////// // add the vehicle itself! // overide this function to make more complex vehicles m_pTracked = new CMOOSNavVehicle; m_pTracked->m_nID = GetNextID(); m_pTracked->m_sName="TheAUV"; m_pTracked->SetEntityType(m_eVehicleType); m_pTracked->m_State.m_dfZ = 0; return AddEntity(m_pTracked); }
//----------------------------------------------------------------------------- // Purpose: Adds any entities found in the given object tree to the list of // entities that are in this world. Called whenever an object is added // to this world. // Input : pObject - object (and children) to add to the entity list. //----------------------------------------------------------------------------- void CMapWorld::EntityList_Add(CMapClass *pObject) { CMapEntity *pEntity = dynamic_cast<CMapEntity *>(pObject); if (pEntity != NULL) { AddEntity(pEntity); } EnumChildrenPos_t pos; CMapClass *pChild = pObject->GetFirstDescendent(pos); while (pChild != NULL) { CMapEntity *pEntity = dynamic_cast<CMapEntity *>(pChild); if ((pEntity != NULL) && (m_EntityList.Find(pEntity) == -1)) { AddEntity(pEntity); } pChild = pObject->GetNextDescendent(pos); } }
void ForceRepopulateList() { Clear(); CBaseEntity *pEnt = gEntList.FirstEnt(); while( pEnt ) { if( ShouldAddEntity(pEnt) ) AddEntity(pEnt); pEnt = gEntList.NextEnt( pEnt ); } }
void GameView::SpawnPlayers() { for (int i = 0; i < 4; ++i) { if (g_activePlayer[i]) { Player* player = new Player(); // todo pass in what "skin" used player->Init(g_playerSpawn[i], this, i); m_players.push_back(player); AddEntity(player); } } }
bool CommunityHealthWorkerEventCoordinator::notifyOnEvent( IIndividualHumanEventContext *context, const EventTrigger& trigger) { if( IsRemoveIndividualEvent( trigger ) ) { RemoveEntity( context ); } else { float current_time = m_Parent->GetSimulationTime().time; if( m_pInterventionNode != nullptr ) { INodeEventContext* p_nec = context->GetNodeEventContext(); AddEntity( current_time, p_nec->GetId().data, p_nec, m_QueueNode ); } else { AddEntity( current_time, context->GetSuid().data, context, m_QueueIndividual ); } } return true; }
World::World(Switch *sw, unsigned int scrWidth, unsigned int scrHeight) : Scene(sw, scrWidth, scrHeight) { //Set scene dimentions screenHeight = scrHeight; screenWidth = screenWidth; //Initialize variables zone = 0; danger = 0; //Load Images that may be used on the map if (!LoadTileImages()) std::cout<<"ERROR: Could not load tile image!"<<std::endl; //Create speech dialog bubble. textBubble = new TextBubble(); textBubble->LoadAnimations(); textBubbleButton = new BubbleButton(450,420,(char*)"Continue"); textBubbleButton->LoadAnimations(); //Create party party = new Party( 73, 142, 25, 40, 0); //Create the savegame dialog. savegame = new SaveGameDialog(party); //Parse entities file. Parser *parser = new Parser(this, textBubble, savegame); parser->LoadXml((char*)"resources/map/secure_forest.xml"); parser->LoadXml((char*)"resources/map/city.xml"); parser->LoadXml((char*)"resources/map/forest.xml"); parser->LoadXml((char*)"resources/map/plains.xml"); parser->LoadXml((char*)"resources/map/cave.xml"); delete parser; //Add party and characters AddEntity(party); AddPhysicObject(party); party->LoadAnimations(); //Load map. if (!LoadMap((char*)"resources/map/world.map")) std::cout<<"ERROR: Could not load map!"<<std::endl; //load resources. if (!LoadResources()) std::cout<<"ERROR: Could not load resources!"<<std::endl; }
void AddProjectileDown(char x, char y) { Entity* projectile = AddEntity(); if(projectile == NULL) return; projectile->x = x; projectile->y = y; projectile->type = PROJECTILE_CHAR; projectile->flags |= PROJECTILE_F; projectile->flags |= COLLIDER_F; projectile->next_update = 1; projectile->update_delay = 1; projectile->Update = &ProjectileDownUpdate; projectile->Collision = &ProjectileDownCollision; game->nb_projectiles++; }
void AddTestPlayer(char x, char y) { Entity* player = AddEntity(); if(player == NULL) return; player->x = x; player->y = y; player->type = PLAYER_CHAR; player->next_update = 1; player->update_delay = 5; player->flags |= COLLIDER_F; player->extra[NEXT_SHOT] = 1; player->extra[SHOT_DELAY] = 2; player->extra[DIRECTION] = 1; player->Update = &TestPlayerUpdate; player->Collision = &TestPlayerCollision; }
DEntity* DMap::GetEntityForID( int ID ){ DEntity* findEntity = NULL; for ( std::list<DEntity *>::const_iterator chkEntity = entityList.begin(); chkEntity != entityList.end(); chkEntity++ ) { if ( ( *chkEntity )->m_nID == ID ) { findEntity = ( *chkEntity ); break; } } if ( !findEntity ) { findEntity = AddEntity( "worldspawn", ID ); } return findEntity; }