Changeset 6386 in orxonox.OLD for branches/network/src/story_entities
- Timestamp:
- Jan 2, 2006, 1:30:23 AM (19 years ago)
- Location:
- branches/network/src/story_entities
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/story_entities/campaign.cc
r6376 r6386 34 34 { 35 35 this->setClassID(CL_CAMPAIGN, "Campaign"); 36 this->isInit = false;37 36 38 37 PRINTF(4)("Loading Campaign...\n"); 39 38 assert( root != NULL); 40 39 40 this->campaignData = new CampaignData(); 41 41 this->loadParams(root); 42 42 } … … 51 51 52 52 /** 53 * initializes the class54 */55 ErrorMessage Campaign::init()56 {57 this->isInit = true;58 }59 60 61 /**62 53 * loads the Parameters of a Campaign 63 54 * @param root: The XML-element to load from … … 87 78 StoryEntity* created = (StoryEntity*) Factory::fabricate(element); 88 79 if( created != NULL) 89 this->addEntity( created); 90 PRINTF(3)("Campaign: Constructor: adding a world with name \"%s\" and id %i\n", 91 created->getName(), created->getStoryID()); 80 this->campaignData->addStoryEntity(created); 92 81 } 93 82 LOAD_PARAM_END_CYCLE(element); … … 97 86 98 87 /** 99 * starts the campaing100 */ 101 ErrorMessage Campaign:: start()102 { 103 this-> start(0);88 * initializes the class 89 */ 90 ErrorMessage Campaign::init() 91 { 92 this->isInit = true; 104 93 } 105 94 … … 109 98 * @param storyID the id of the StoryEntity 110 99 */ 111 ErrorMessage Campaign::start(int storyID = 0) 112 { 113 ErrorMessage errorCode; 114 if( !this->isInit) return errorCode; 115 if( storyID == WORLD_ID_GAMEEND) return errorCode; 116 this->running = true; 117 StoryEntity* se = this->getStoryEntity(storyID); 118 this->currentEntity = se; 119 while( se != NULL && this->running) 120 { 121 PRINTF(0)("Campaign is starting StoryEntity nr:%i\n", se->getStoryID()); 122 123 se->init(); 124 se->loadData(); 125 126 se->preStart(); 127 se->start(); 128 129 130 int nextWorldID = se->getNextStoryID(); 131 132 this->entities.remove(se); 133 delete se; 134 135 se = this->getStoryEntity(nextWorldID); 136 this->currentEntity = se; 137 if( ( nextWorldID == WORLD_ID_GAMEEND) || ( se == NULL) ) 138 { 139 PRINTF(4)("Quitting campaing story loop\n"); 140 if(se != NULL) 141 delete se; 142 return errorCode; 143 } 144 } 145 146 /* clean up all world that have not been loaded and therefore are still in the world list - 147 this probably does not belong into the start function. remove this later 148 */ 149 list<StoryEntity*>::iterator it; 150 for(it = this->entities.begin(); it != entities.end(); it++) 151 { 152 delete (*it); 100 ErrorMessage Campaign::start() 101 { 102 PRINTF(2)("Starting Campaign nr. %i\n", this->getStoryID()); 103 104 ErrorMessage errorCode; 105 int storyID = WORLD_ID_0; 106 107 for( this->currentEntity = this->campaignData->getFirstLevel(), this->isRunning = true; 108 this->currentEntity != NULL && this->isRunning; 109 this->currentEntity = this->campaignData->getNextLevel()) 110 { 111 PRINTF(0)("Campaign is starting StoryEntity nr:%i\n", this->currentEntity->getStoryID()); 112 113 this->currentEntity->init(); 114 this->currentEntity->loadData(); 115 this->currentEntity->start(); 116 this->currentEntity->unloadData(); 153 117 } 154 118 … … 158 122 159 123 /** 160 * pauses the campai ng124 * pauses the campaign 161 125 */ 162 126 ErrorMessage Campaign::pause() 163 127 { 164 if( this->currentEntity != NULL)128 if( this->currentEntity != NULL) 165 129 this->isPaused = true; 166 130 } 167 131 168 132 133 /** 134 * resumes the campaign after a pause 135 */ 169 136 ErrorMessage Campaign::resume() 170 137 { 171 if( this->currentEntity != NULL)138 if( this->currentEntity != NULL) 172 139 this->isPaused = false; 173 140 } 174 141 175 142 143 /** 144 * stops the campaign 145 */ 176 146 ErrorMessage Campaign::stop() 177 147 { 178 this-> running = false;179 if( this->currentEntity != NULL)148 this->isRunning = false; 149 if( this->currentEntity != NULL) 180 150 { 181 151 this->currentEntity->stop(); … … 183 153 } 184 154 185 /* 186 ErrorMessage Campaign::destroy() 187 { 188 if(this->currentEntity != NULL) 189 { 190 this->currentEntity->destroy(); 191 delete this->currentEntity; 192 this->currentEntity = NULL; 193 } 194 }*/ 195 196 197 /** 198 * adds an game stroy entity to the campaign 199 200 * @param se: The entity 201 * @param storyID: The number that identifies the entity in the campaign. Each ID only used once in a Campaign 202 203 An entity can be a world (playable), a cinematic, a shop, sounds, whatever you 204 want to queue up in the campaign. 205 */ 206 void Campaign::addEntity(StoryEntity* se, int storyID) 207 { 208 se->setStoryID(storyID); 209 this->addEntity(se); 210 } 211 212 void Campaign::addEntity(StoryEntity* se) 213 { 214 this->entities.push_back(se); 215 } 216 217 218 void Campaign::removeEntity(int storyID) 219 { 220 this->removeEntity(this->getStoryEntity(storyID)); 221 222 } 223 224 225 void Campaign::removeEntity(StoryEntity* se) 226 { 227 this->entities.remove(se); 228 } 229 230 231 /* 232 \brief this changes to the next level 233 */ 234 void Campaign::nextLevel() 155 156 /** 157 * this changes to the next level 158 */ 159 void Campaign::switchToNextLevel() 235 160 { 236 161 PRINTF(4)("Campaign:nextLevel()\n"); … … 238 163 } 239 164 240 /* 241 \brief change to the previous level - not implemented 242 243 this propably useless 244 */ 245 void Campaign::previousLevel() 165 166 167 /* CampaignData */ 168 169 /** 170 * constructor for CampaignData 171 */ 172 CampaignData::CampaignData() 173 { 174 this->setClassID(CL_CAMPAIGN_DATA, "CampaignData"); 175 this->currentEntity = NULL; 176 } 177 178 179 /** 180 * destructor for CampaignData 181 */ 182 CampaignData::~ CampaignData() 246 183 {} 247 184 248 185 249 /* 250 \brief lookup a entity with a given id 251 * @param story id to be lookuped 252 @returns the entity found or NULL if search ended without match 253 */ 254 StoryEntity* Campaign::getStoryEntity(int storyID) 255 { 256 if( storyID == WORLD_ID_GAMEEND) 257 return NULL; 258 259 int id; 260 list<StoryEntity*>::iterator it; 261 for( it = this->entities.begin(); it != this->entities.end(); it++) 262 { 263 id = (*it)->getStoryID(); 264 if( id == storyID) 265 return (*it); 266 } 267 268 return NULL; 269 } 186 /** 187 * add the StoryEntity to the campaign data tank 188 * @param se the StoryEntity to add 189 */ 190 void CampaignData::addStoryEntity(StoryEntity* se) 191 { 192 this->storyEntities.push_back(se); 193 } 194 195 196 /** 197 * switch to the next level in the list and return it 198 */ 199 StoryEntity* CampaignData::getFirstLevel() 200 { 201 int nextStoryID; 202 int storyID; 203 list<StoryEntity*>::iterator it; 204 205 nextStoryID = 0; 206 this->currentEntity = NULL; 207 for( it = this->storyEntities.begin(); it != this->storyEntities.end(); it++) 208 { 209 storyID = (*it)->getStoryID(); 210 if( storyID == nextStoryID) 211 this->currentEntity = (*it); 212 } 213 return this->currentEntity; 214 } 215 216 217 /** 218 * switch to the next level in the list and return it 219 */ 220 StoryEntity* CampaignData::getNextLevel() 221 { 222 int nextStoryID; 223 int storyID; 224 list<StoryEntity*>::iterator it; 225 226 nextStoryID = this->currentEntity->getNextStoryID(); 227 this->currentEntity = NULL; 228 for( it = this->storyEntities.begin(); it != this->storyEntities.end(); it++) 229 { 230 storyID = (*it)->getStoryID(); 231 if( storyID == nextStoryID) 232 this->currentEntity = (*it); 233 } 234 return this->currentEntity; 235 } 236 237 238 239 240 -
branches/network/src/story_entities/campaign.h
r6374 r6386 1 /*! 2 * @file campaign.h 3 * definition of the campaign 4 */ 1 5 2 6 #ifndef _CAMPAIGN_H 3 7 #define _CAMPAIGN_H 4 8 9 5 10 #include "story_entity.h" 6 7 11 #include <list> 8 12 9 class World; 13 10 14 class TiXmlElement; 15 class CampaignData; 11 16 17 18 //! A class that represents a game Campaign that contains other StoryEntities like GameWorlds, movies, etc. 12 19 class Campaign : public StoryEntity 13 20 { … … 22 29 virtual ErrorMessage init(); 23 30 virtual ErrorMessage start(); 24 virtual ErrorMessage start(int storyID);25 31 virtual ErrorMessage pause(); 26 32 virtual ErrorMessage resume(); 27 33 virtual ErrorMessage stop(); 28 34 29 void addEntity(StoryEntity* se, int storyID); 30 void addEntity(StoryEntity* se); 31 void removeEntity(int storyID); 32 void removeEntity(StoryEntity* se); 33 34 void nextLevel(); 35 void previousLevel(); 35 void switchToNextLevel(); 36 36 37 37 38 38 private: 39 StoryEntity* getStoryEntity(int storyID); 40 41 42 private: 43 StoryEntity* currentEntity; 44 std::list<StoryEntity*> entities; 45 bool running; 46 39 StoryEntity* currentEntity; //!< reference to the current StoryEntity 40 CampaignData* campaignData; //!< reference to the CampaignData 47 41 }; 48 42 49 43 50 44 45 //! A class that contains the data of the Campaign object 51 46 class CampaignData : virtual public BaseObject 52 47 { … … 56 51 virtual ~CampaignData(); 57 52 58 void addStoryEntity(StoryEntity* se , int storyID = -1);53 void addStoryEntity(StoryEntity* se); 59 54 60 void getNextLevel(); 55 StoryEntity* getFirstLevel(); 56 StoryEntity* getNextLevel(); 57 58 59 private: 60 StoryEntity* currentEntity; //!< reference to the currently used StoryEntity 61 std::list<StoryEntity*> storyEntities; //!< list of story entities 61 62 }; 62 63 -
branches/network/src/story_entities/debug_world.cc
r6222 r6386 1 /*2 orxonox - the future of 3D-vertical-scrollers3 4 Copyright (C) 2004 orx5 6 This program is free software; you can redistribute it and/or modify7 it under the terms of the GNU General Public License as published by8 the Free Software Foundation; either version 2, or (at your option)9 any later version.10 11 ### File Specific:12 main-programmer: Patrick Boenzli13 co-programmer: Christian Meyer14 co-programmer: Benjamin Grauer15 */16 17 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD18 19 #include "world.h"20 21 #include "shell_command.h"22 23 #include "state.h"24 25 #include "p_node.h"26 #include "pilot_node.h"27 #include "world_entity.h"28 #include "player.h"29 #include "camera.h"30 #include "environment.h"31 #include "skysphere.h"32 #include "skybox.h"33 #include "satellite.h"34 #include "test_entity.h"35 #include "terrain.h"36 #include "light.h"37 #include "load_param.h"38 #include "shell.h"39 40 #include "fast_factory.h"41 #include "animation_player.h"42 #include "particle_engine.h"43 #include "graphics_engine.h"44 #include "physics_engine.h"45 #include "fields.h"46 47 #include "md2Model.h"48 49 #include "glmenu_imagescreen.h"50 #include "game_loader.h"51 52 #include "animation3d.h"53 54 #include "substring.h"55 56 #include "factory.h"57 58 #include "weapons/projectile.h"59 #include "event_handler.h"60 #include "sound_engine.h"61 #include "ogg_player.h"62 63 #include "class_list.h"64 65 #include "cd_engine.h"66 #include "npcs/npc_test1.h"67 #include "shader.h"68 69 #include "playable.h"70 #include "network_manager.h"71 #include "playable.h"72 73 74 SHELL_COMMAND(speed, World, setSpeed);75 SHELL_COMMAND(togglePNodeVisibility, World, togglePNodeVisibility);76 SHELL_COMMAND(toggleBVVisibility, World, toggleBVVisibility);77 78 using namespace std;79 80 //! This creates a Factory to fabricate a World81 CREATE_FACTORY(World, CL_WORLD);82 83 World::World(const TiXmlElement* root)84 {85 this->constuctorInit("", -1);86 this->path = NULL;87 88 this->loadParams(root);89 }90 91 /**92 * create a new World93 94 This creates a new empty world!95 */96 World::World (const char* name)97 {98 this->path = NULL;99 this->constuctorInit(name, -1);100 }101 102 /**103 * creates a new World...104 * @param worldID with this ID105 */106 World::World (int worldID)107 {108 this->path = NULL;109 this->constuctorInit(NULL, worldID);110 }111 112 /**113 * remove the World from memory114 115 delete everything explicitly, that isn't contained in the parenting tree!116 things contained in the tree are deleted automaticaly117 */118 World::~World ()119 {120 delete this->shell;121 PRINTF(3)("World::~World() - deleting current world\n");122 123 delete this->localPlayer;124 125 // delete all the initialized Engines.126 FastFactory::flushAll(true);127 delete LightManager::getInstance();128 delete ParticleEngine::getInstance();129 delete AnimationPlayer::getInstance();130 delete PhysicsEngine::getInstance();131 132 // external engines initialized by the orxonox-class get deleted133 SoundEngine::getInstance()->flushAllBuffers();134 SoundEngine::getInstance()->flushAllSources();135 136 if (State::getObjectManager() == &this->objectManager)137 State::setObjectManager(NULL);138 // erease everything that is left.139 delete PNode::getNullParent();140 141 //secondary cleanup of PNodes;142 const std::list<BaseObject*>* nodeList = ClassList::getList(CL_PARENT_NODE);143 if (nodeList != NULL)144 while (!nodeList->empty())145 delete nodeList->front();146 147 Shader::suspendShader();148 149 // unload the resources !!150 ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL);151 152 delete[] this->path;153 }154 155 /**156 * initializes the world.157 * @param name the name of the world158 * @param worldID the ID of this world159 *160 * set all stuff here that is world generic and does not use to much memory161 * because the real init() function StoryEntity::init() will be called162 * shortly before start of the game.163 * since all worlds are initiated/referenced before they will be started.164 * NO LEVEL LOADING HERE - NEVER!165 */166 void World::constuctorInit(const char* name, int worldID)167 {168 this->setClassID(CL_WORLD, "World");169 170 this->setName(name);171 this->debugWorldNr = worldID;172 this->gameTime = 0.0f;173 this->setSpeed(1.0);174 this->music = NULL;175 this->shell = NULL;176 this->localPlayer = NULL;177 this->localCamera = NULL;178 179 this->showPNodes = false;180 this->showBV = false;181 }182 183 /**184 * loads the parameters of a World from an XML-element185 * @param root the XML-element to load from186 */187 void World::loadParams(const TiXmlElement* root)188 {189 PRINTF(4)("Creating a World\n");190 191 LoadParam(root, "identifier", this, World, setStoryID)192 .describe("Sets the StoryID of this world");193 194 LoadParam(root, "nextid", this, World, setNextStoryID)195 .describe("Sets the ID of the next world");196 197 LoadParam(root, "path", this, World, setPath)198 .describe("The Filename of this World (relative from the data-dir)");199 }200 201 /**202 * this is executed just before load203 *204 * since the load function sometimes needs data, that has been initialized205 * before the load and after the proceeding storyentity has finished206 */207 ErrorMessage World::preLoad()208 {209 State::setObjectManager(&this->objectManager);210 this->cycle = 0;211 212 /* init the world interface */213 this->shell = new Shell();214 215 LightManager::getInstance();216 PNode::getNullParent();217 218 AnimationPlayer::getInstance(); // initializes the animationPlayer219 ParticleEngine::getInstance();220 PhysicsEngine::getInstance();221 222 this->localCamera = new Camera();223 this->localCamera->setName ("World-Camera");224 225 State::setCamera(this->localCamera, this->localCamera->getTarget());226 227 GraphicsEngine::getInstance()->displayFPS(true);228 }229 230 231 /**232 * loads the World by initializing all resources, and set their default values.233 */234 ErrorMessage World::load()235 {236 PRINTF(3)("> Loading world: '%s'\n", getPath());237 TiXmlElement* element;238 GameLoader* loader = GameLoader::getInstance();239 240 if( getPath() == NULL)241 {242 PRINTF(1)("World has no path specified for loading");243 this->loadDebugWorld(this->getStoryID());244 return (ErrorMessage){213,"Path not specified","World::load()"};245 }246 247 TiXmlDocument* XMLDoc = new TiXmlDocument( getPath());248 // load the campaign document249 if( !XMLDoc->LoadFile())250 {251 // report an error252 PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc->ErrorDesc(), this->getPath(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());253 delete XMLDoc;254 return (ErrorMessage){213,"XML File parsing error","World::load()"};255 }256 257 // check basic validity258 TiXmlElement* root = XMLDoc->RootElement();259 assert( root != NULL);260 261 if( root == NULL || root->Value() == NULL || strcmp( root->Value(), "WorldDataFile"))262 {263 // report an error264 PRINTF(1)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n");265 delete XMLDoc;266 return (ErrorMessage){213,"Path not a WorldDataFile","World::load()"};267 }268 269 // load the parameters270 // name271 const char* string = grabParameter( root, "name");272 if( string == NULL)273 {274 PRINTF(2)("World is missing a proper 'name'\n");275 this->setName("Unknown");276 }277 else278 {279 this->setName(string);280 }281 282 ////////////////283 // LOADSCREEN //284 ////////////////285 element = root->FirstChildElement("LoadScreen");286 if (element == NULL)287 {288 PRINTF(2)("no LoadScreen specified, loading default\n");289 290 glmis->setBackgroundImage("pictures/load_screen.jpg");291 this->glmis->setMaximum(8);292 this->glmis->draw();293 }294 else295 {296 this->glmis->loadParams(element);297 this->glmis->draw();298 }299 this->glmis->draw();300 301 ////////////////////////302 // find WorldEntities //303 ////////////////////////304 305 element = root->FirstChildElement("WorldEntities");306 307 if( element == NULL)308 {309 PRINTF(1)("World is missing 'WorldEntities'\n");310 }311 else312 {313 element = element->FirstChildElement();314 // load Players/Objects/Whatever315 PRINTF(4)("Loading WorldEntities\n");316 while( element != NULL)317 {318 BaseObject* created = Factory::fabricate(element);319 if( created != NULL )320 {321 if(created->isA(CL_WORLD_ENTITY))322 this->spawn(dynamic_cast<WorldEntity*>(created));323 printf("Created a %s: %s\n", created->getClassName(), created->getName());324 }325 326 // if we load a 'Player' we use it as localPlayer327 328 329 //todo do this more elegant330 if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox"))331 sky = dynamic_cast<SkyBox*>(created);332 if( element->Value() != NULL && !strcmp( element->Value(), "Terrain"))333 {334 terrain = dynamic_cast<Terrain*>(created);335 CDEngine::getInstance()->setTerrain(terrain);336 }337 element = element->NextSiblingElement();338 glmis->step(); //! @todo temporary339 }340 PRINTF(4)("Done loading WorldEntities\n");341 }342 343 //////////////////////////////344 // LOADING ADDITIONAL STUFF //345 //////////////////////////////346 347 LoadParamXML(root, "LightManager", LightManager::getInstance(), LightManager, loadParams);348 349 LoadParamXML(root, "ParticleEngine", ParticleEngine::getInstance(), ParticleEngine, loadParams);350 // LoadParamXML(root, "PhysicsEngine", PhysicsEngine::getInstance(), PhysicsEngine, loadParams);351 352 // free the XML data353 354 delete XMLDoc;355 /* GENERIC LOADING PROCESS FINISHED */356 357 358 // Create a Player359 this->localPlayer = new Player();360 361 Playable* playable;362 const list<BaseObject*>* playableList = ClassList::getList(CL_PLAYABLE);363 if (playableList != NULL)364 {365 playable = dynamic_cast<Playable*>(playableList->front());366 this->localPlayer->setControllable(playable);367 }368 369 // bind camera370 playable->addChild (this->localCamera);371 372 // //localCamera->setParent(TrackNode::getInstance());373 // tn->addChild(this->localCamera);374 localCamera->setClipRegion(1, 10000.0);375 localCamera->lookAt(playable);376 // this->localPlayer->setParentMode(PNODE_ALL);377 if (sky != NULL)378 {379 this->sky->setParent(this->localCamera);380 this->sky->setParentMode(PNODE_MOVEMENT);381 }382 383 // initialize debug coord system384 objectList = glGenLists(1);385 glNewList (objectList, GL_COMPILE);386 387 glEndList();388 389 SoundEngine::getInstance()->setListener(this->localCamera);390 391 392 393 ////////////394 // STATIC //395 ////////////396 397 398 // TestEntity* testEntity = new TestEntity();399 // testEntity->setRelCoor(Vector(570, 10, -15));400 // testEntity->setRelDir(Quaternion(M_PI, Vector(0, 1, 0)));401 // this->spawn(testEntity);402 403 for(int i = 0; i < 100; i++)404 {405 WorldEntity* tmp = new NPCTest1();406 char npcChar[10];407 sprintf (npcChar, "NPC_%d", i);408 tmp->setName(npcChar);409 tmp->setAbsCoor(((float)rand()/RAND_MAX) * 5000, 50/*+ (float)rand()/RAND_MAX*20*/, ((float)rand()/RAND_MAX -.5) *30);410 this->spawn(tmp);411 }412 413 this->music = NULL;414 //(OggPlayer*)ResourceManager::getInstance()->load("sound/00-luke_grey_-_hypermode.ogg", OGG, RP_LEVEL);415 //music->playback();416 }417 418 419 420 /**421 * creates a debug world: only for experimental stuff422 */423 void World::loadDebugWorld(int worldID)424 {425 /*monitor progress*/426 this->glmis->step();427 // stuff beyond this point remains to be loaded properly428 429 // LIGHT initialisation430 LightManager::getInstance()->setAmbientColor(.1,.1,.1);431 // LightManager::getInstance()->addLight();432 LightManager::getInstance()->debug();433 434 switch(this->debugWorldNr)435 {436 /*437 this loads the hard-coded debug world. this only for simplicity and will be438 removed by a reald world-loader, which interprets a world-file.439 if you want to add an own debug world, just add a case DEBUG_WORLD_[nr] and440 make whatever you want...441 */442 case DEBUG_WORLD_0:443 {444 LightManager::getInstance()->getLight()->setAbsCoor(-5.0, 10.0, -40.0);445 /*monitor progress*/446 this->glmis->step();447 448 // bind camera449 this->localCamera = new Camera();450 this->localCamera->setName ("camera");451 /*monitor progress*/452 this->glmis->step();453 454 455 // Create SkySphere456 this->sky = new Skysphere("pictures/sky-replace.jpg");457 this->sky->setName("SkySphere");458 this->spawn(this->sky);459 this->localCamera->addChild(this->sky);460 this->sky->setParentMode(PNODE_MOVEMENT);461 /*monitor progress*/462 this->glmis->step();463 464 465 terrain = new Terrain("worlds/newGround.obj");466 terrain->setRelCoor(Vector(0,-10,0));467 this->spawn(terrain);468 /*monitor progress*/469 this->glmis->step();470 471 this->glmis->step();472 break;473 }474 case DEBUG_WORLD_1:475 {476 477 break;478 }479 case DEBUG_WORLD_2:480 {481 482 break;483 }484 default:485 break;486 }487 }488 489 /**490 * initializes a new World shortly before start491 *492 * this is the function, that will be loaded shortly before the world is493 * started494 */495 ErrorMessage World::init()496 {497 this->bPause = false;498 499 /* update the object position before game start - so there are no wrong coordinates used in the first processing */500 PNode::getNullParent()->updateNode (0.001f);501 PNode::getNullParent()->updateNode (0.001f);502 503 }504 505 506 /**507 * starts the World508 */509 ErrorMessage World::start()510 {511 PRINTF(3)("World::start() - starting current World: nr %i\n", this->debugWorldNr);512 this->bQuitOrxonox = false;513 this->bQuitCurrentGame = false;514 this->mainLoop();515 }516 517 /**518 * stops the world.519 520 This happens, when the player decides to end the Level.521 */522 ErrorMessage World::stop()523 {524 PRINTF(3)("World::stop() - got stop signal\n");525 this->bQuitCurrentGame = true;526 }527 528 /**529 * pauses the Game530 */531 ErrorMessage World::pause()532 {533 this->isPaused = true;534 }535 536 /**537 * ends the pause Phase538 */539 ErrorMessage World::resume()540 {541 this->isPaused = false;542 }543 544 /**545 * destroys the World546 */547 ErrorMessage World::destroy()548 {549 550 }551 552 /**553 * shows the loading screen554 */555 void World::displayLoadScreen ()556 {557 PRINTF(3)("World::displayLoadScreen - start\n");558 559 //GLMenuImageScreen*560 this->glmis = new GLMenuImageScreen();561 this->glmis->setMaximum(8);562 563 PRINTF(3)("World::displayLoadScreen - end\n");564 }565 566 /**567 * removes the loadscreen, and changes over to the game568 569 @todo take out the delay570 */571 void World::releaseLoadScreen ()572 {573 PRINTF(3)("World::releaseLoadScreen - start\n");574 this->glmis->setValue(this->glmis->getMaximum());575 PRINTF(3)("World::releaseLoadScreen - end\n");576 delete this->glmis;577 }578 579 580 /**581 * this returns the current game time582 * @returns elapsed game time583 */584 double World::getGameTime()585 {586 return this->gameTime;587 }588 589 /**590 \brief main loop of the world: executing all world relevant function591 592 in this loop we synchronize (if networked), handle input events, give the heart-beat to593 all other member-entities of the world (tick to player, enemies etc.), checking for594 collisions drawing everything to the screen.595 */596 void World::mainLoop()597 {598 this->lastFrame = SDL_GetTicks ();599 PRINTF(3)("World::mainLoop() - Entering main loop\n");600 601 while( !this->bQuitOrxonox && !this->bQuitCurrentGame) /* @todo implement pause */602 {603 ++this->cycle;604 // Network605 this->synchronize ();606 // Process input607 this->handleInput ();608 if( this->bQuitCurrentGame || this->bQuitOrxonox)609 break;610 // Process time611 this->tick ();612 // Process collision613 this->collide ();614 // Update the state615 this->update ();616 // Draw617 this->display ();618 }619 620 PRINTF(3)("World::mainLoop() - Exiting the main loop\n");621 }622 623 624 /**625 * synchronize local data with remote data626 */627 void World::synchronize ()628 {629 // Get remote input630 // Update synchronizables631 /* NetworkManager::getInstance()->synchronize();*/632 }633 634 635 /**636 * run all input processing637 638 the command node is the central input event dispatcher. the node uses the even-queue from639 sdl and has its own event-passing-queue.640 */641 void World::handleInput ()642 {643 EventHandler::getInstance()->process();644 645 // remoteinput646 }647 648 void World::tick(std::list<WorldEntity*> entityList, float dt)649 {650 std::list<WorldEntity*>::iterator entity;651 for (entity = entityList.begin(); entity != entityList.end(); entity++)652 (*entity)->tick(dt);653 654 }655 656 /**657 * advance the timeline658 659 this calculates the time used to process one frame (with all input handling, drawing, etc)660 the time is mesured in ms and passed to all world-entities and other classes that need661 a heart-beat.662 */663 void World::tick ()664 {665 Uint32 currentFrame = SDL_GetTicks();666 if(!this->bPause)667 {668 this->dt = currentFrame - this->lastFrame;669 670 if( this->dt > 10)671 {672 float fps = 1000/dt;673 674 // temporary, only for showing how fast the text-engine is675 char tmpChar[20];676 sprintf(tmpChar, "fps: %4.0f", fps);677 }678 else679 {680 /* the frame-rate is limited to 100 frames per second, all other things are for681 nothing.682 */683 PRINTF(3)("fps = 1000 - frame rate is adjusted\n");684 SDL_Delay(10-dt);685 this->dt = 10;686 }687 688 this->dtS = (float)this->dt / 1000.0 * this->speed;689 this->gameTime += this->dtS;690 691 /* this->tick(this->objectManager.getObjectList(OM_DEAD_TICK), this->dtS);692 this->tick(this->objectManager.getObjectList(OM_COMMON), this->dtS);693 this->tick(this->objectManager.getObjectList(OM_GROUP_00), this->dtS);*/694 this->tick(this->objectManager.getObjectList(OM_GROUP_01), this->dtS);695 this->tick(this->objectManager.getObjectList(OM_GROUP_01_PROJ), this->dtS);696 697 /* update tick the rest */698 this->localCamera->tick(this->dtS);699 // tick the engines700 AnimationPlayer::getInstance()->tick(this->dtS);701 // if (this->cycle > 5)702 PhysicsEngine::getInstance()->tick(this->dtS);703 704 ParticleEngine::getInstance()->tick(this->dtS);705 706 707 /** actualy the Graphics Engine should tick the world not the other way around...708 but since we like the things not too complicated we got it this way around709 until there is need or time to do it the other way around.710 @todo: GraphicsEngine ticks world: separation of processes and data...711 712 bensch: in my opinion the GraphicsEngine could draw the world, but not tick it,713 beceause graphics have nothing(or at least not much) to do with Motion.714 */715 GraphicsEngine::getInstance()->tick(this->dtS);716 }717 this->lastFrame = currentFrame;718 }719 720 721 /**722 * this function gives the world a consistant state723 724 after ticking (updating the world state) this will give a constistant725 state to the whole system.726 */727 void World::update()728 {729 GraphicsEngine::getInstance()->update(this->dtS);730 PNode::getNullParent()->updateNode (this->dtS);731 732 SoundEngine::getInstance()->update();733 //music->update();734 }735 736 737 void World::collide()738 {739 CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_00),740 this->objectManager.getObjectList(OM_GROUP_01_PROJ));741 CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_01),742 this->objectManager.getObjectList(OM_COMMON));743 }744 745 /**746 * render the current frame747 748 clear all buffers and draw the world749 */750 void World::display ()751 {752 // clear buffer753 glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);754 // set camera755 this->localCamera->apply ();756 // draw world757 this->draw();758 // draw HUD759 /** @todo draw HUD */760 // flip buffers761 GraphicsEngine::swapBuffers();762 //SDL_Surface* screen = Orxonox::getInstance()->getScreen ();763 //SDL_Flip (screen);764 }765 766 767 /**768 * runs through all entities calling their draw() methods769 */770 void World::draw ()771 {772 GraphicsEngine* engine = GraphicsEngine::getInstance();773 engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON_NOTICK));774 engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON));775 engine->draw(State::getObjectManager()->getObjectList(OM_COMMON));776 engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_00));777 engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01));778 engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01_PROJ));779 780 // {781 // if( entity->isVisible() ) entity->draw();782 //FIXME783 // if( unlikely( this->showBV)) entity->drawBVTree(3, 226); // to draw the bounding boxes of the objects at level 2 for debug purp784 // entity = iterator->nextElement();785 // }786 787 glCallList (objectList);788 789 ParticleEngine::getInstance()->draw();790 791 if (unlikely(this->showPNodes))792 PNode::getNullParent()->debugDraw(0);793 794 engine->draw();795 //TextEngine::getInstance()->draw();796 }797 798 /**799 * add and spawn a new entity to this world800 * @param entity to be added801 */802 void World::spawn(WorldEntity* entity)803 {804 // this->entities->add (entity);805 entity->postSpawn ();806 }807 808 809 /**810 * add and spawn a new entity to this world811 * @param entity to be added812 * @param absCoor At what coordinates to add this entity.813 * @param absDir In which direction should it look.814 */815 void World::spawn(WorldEntity* entity, Vector* absCoor, Quaternion* absDir)816 {817 // this->entities->add (entity);818 819 entity->setAbsCoor (*absCoor);820 entity->setAbsDir (*absDir);821 822 entity->postSpawn ();823 }824 825 826 /**827 * add and spawn a new entity to this world828 * @param entity to be added829 * @param entity to be added to (PNode)830 * @param At what relative coordinates to add this entity.831 * @param In which relative direction should it look.832 */833 void World::spawn(WorldEntity* entity, PNode* parentNode,834 Vector* relCoor, Quaternion* relDir)835 {836 if( parentNode != NULL)837 {838 parentNode->addChild (entity);839 840 entity->setRelCoor (*relCoor);841 entity->setRelDir (*relDir);842 843 // this->entities->add (entity);844 845 entity->postSpawn ();846 }847 }848 849 void World::setPath( const char* name)850 {851 if (this->path)852 delete this->path;853 if (ResourceManager::isFile(name))854 {855 this->path = new char[strlen(name)+1];856 strcpy(this->path, name);857 }858 else859 {860 this->path = new char[strlen(ResourceManager::getInstance()->getDataDir()) + strlen(name) +1];861 sprintf(this->path, "%s%s", ResourceManager::getInstance()->getDataDir(), name);862 }863 }864 865 const char* World::getPath( void)866 {867 return path;868 } -
branches/network/src/story_entities/debug_world.h
r6150 r6386 1 /*!2 * @file world.h3 * Holds and manages all game data4 */5 6 #ifndef _WORLD_H7 #define _WORLD_H8 9 #include "stdincl.h"10 #include "comincl.h"11 #include "story_entity.h"12 #include "p_node.h"13 #include "object_manager.h"14 15 16 class WorldEntity;17 class Camera;18 class Player;19 class GLMenuImageScreen;20 class Terrain;21 class TiXmlElement;22 23 class Shell;24 class OggPlayer;25 26 //! The game world27 /**28 this class initializes everything that should be displayed inside of the current level.29 it is the main driving factor during gameplay.30 */31 class World : public StoryEntity {32 33 public:34 World (const char* name);35 World (int worldID);36 World (const TiXmlElement* root = NULL);37 virtual ~World ();38 39 void loadParams(const TiXmlElement* root);40 41 double getGameTime();42 43 /* classes from story-entity */44 virtual ErrorMessage preLoad();45 virtual ErrorMessage load ();46 virtual ErrorMessage init ();47 virtual ErrorMessage start ();48 virtual ErrorMessage stop ();49 virtual ErrorMessage pause ();50 virtual ErrorMessage resume ();51 virtual ErrorMessage destroy ();52 53 void loadDebugWorld(int worldID);54 55 virtual void displayLoadScreen();56 virtual void releaseLoadScreen();57 58 /* command node functions */59 bool command (Command* cmd);60 61 /* interface to world */62 void spawn (WorldEntity* entity);63 void spawn (WorldEntity* entity, Vector* absCoor, Quaternion* absDir);64 void spawn(WorldEntity* entity, PNode* parentNode, Vector* relCoor, Quaternion* relDir);65 66 /** @param speed sets the speed of the Game */67 inline void setSpeed(float speed) { this->speed = speed; };68 const char* getPath();69 void setPath( const char* name);70 71 inline Camera* getLocalCamera() { return this->localCamera; };72 73 void togglePNodeVisibility() { this->showPNodes = !this->showPNodes; };74 void toggleBVVisibility() { this->showBV = !this->showBV; };75 76 private:77 void constuctorInit(const char* name, int worldID);78 /* function for main-loop */79 void mainLoop ();80 void synchronize ();81 void handleInput ();82 void tick (std::list<WorldEntity*> worldEntity, float dt);83 void tick ();84 void update ();85 void collide ();86 void draw ();87 void display ();88 void debug ();89 90 private:91 bool showPNodes; //!< if the PNodes should be visible.92 bool showBV; //!< if the Bounding Volumes should be visible.93 Uint32 lastFrame; //!< last time of frame94 Uint32 cycle; //!< The cycle we are in (starts with 0 and rises with every frame)95 Uint32 dt; //!< time needed to calculate this frame (in milliSeconds)96 float dtS; //!< The time needed for caluculations in seconds97 float speed; //!< how fast the game flows98 double gameTime; //!< this is where the game time is saved99 bool bQuitOrxonox; //!< quit this application100 bool bQuitCurrentGame; //!< quit only the current game and return to menu101 bool bPause; //!< pause mode102 103 ObjectManager objectManager; //!< The ObjectManager of this World.104 105 GLMenuImageScreen* glmis; //!< The Level-Loader Display106 107 int debugWorldNr; //!< The Debug Nr. needed, if something goes wrong108 char* path; //!< The file from which this world is loaded109 110 Shell* shell;111 OggPlayer* music;112 113 // IMPORTANT WORLD-ENTITIES114 Camera* localCamera; //!< The current Camera115 WorldEntity* sky; //!< The Environmental Heaven of orxonox @todo insert this to environment insted116 Terrain* terrain; //!< The Terrain of the World.117 118 GLuint objectList; //!< temporary: @todo this will be ereased soon119 120 Player* localPlayer; //!< The Player, you fly through the level.121 };122 123 #endif /* _WORLD_H */ -
branches/network/src/story_entities/dedicated_server_world.cc
r6355 r6386 9 9 any later version. 10 10 11 11 ### File Specific: 12 12 main-programmer: Patrick Boenzli 13 co-programmer: Christian Meyer14 co-programmer: Benjamin Grauer15 13 */ 16 14 17 15 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD 18 16 19 #include " network_world.h"17 #include "dedicated_server_world.h" 20 18 21 #include "shell_command.h"22 #include "resource_manager.h"23 19 #include "state.h" 20 #include "class_list.h" 24 21 25 #include "p_node.h"26 #include "world_entity.h"27 #include "player.h"28 #include "camera.h"29 #include "environment.h"30 #include "terrain.h"31 32 #include "test_entity.h"33 #include "terrain.h"34 #include "light.h"35 22 #include "load_param.h" 36 #include "shell.h"37 38 23 #include "fast_factory.h" 39 #include "animation_player.h"40 #include "particle_engine.h"41 #include "graphics_engine.h"42 #include "physics_engine.h"43 #include "fields.h"44 45 #include "md2Model.h"46 47 #include "glmenu_imagescreen.h"48 #include "game_loader.h"49 50 #include "animation3d.h"51 52 #include "substring.h"53 54 24 #include "factory.h" 55 25 56 #include "weapons/projectile.h" 57 #include "event_handler.h" 58 #include "sound_engine.h" 59 #include "ogg_player.h" 26 #include "world_entity.h" 27 #include "npcs/npc_test1.h" 60 28 61 #include "class_list.h"62 63 #include "cd_engine.h"64 #include "npcs/npc_test1.h"65 #include "shader.h"66 67 #include "playable.h"68 #include "network_manager.h"69 #include "network_game_manager.h"70 #include "playable.h"71 72 73 SHELL_COMMAND(speed, NetworkWorld, setSpeed);74 SHELL_COMMAND(togglePNodeVisibility, NetworkWorld, togglePNodeVisibility);75 SHELL_COMMAND(toggleBVVisibility, NetworkWorld, toggleBVVisibility);76 29 77 30 using namespace std; 78 31 79 //! This creates a Factory to fabricate a NetworkWorld80 CREATE_FACTORY( NetworkWorld, CL_WORLD);32 //! This creates a Factory to fabricate a DedicatedServerWorld 33 CREATE_FACTORY(DedicatedServerWorld, CL_DEDICATED_SERVER_WORLD); 81 34 82 NetworkWorld::NetworkWorld(const TiXmlElement* root) 35 36 37 DedicatedServerWorld::DedicatedServerWorld(const TiXmlElement* root) 38 : GameWorld(root) 83 39 { 84 this-> constuctorInit("", -1);85 this-> path = NULL;40 this->setClassID(CL_DEDICATED_SERVER_WORLD, "DedicatedServerWorld"); 41 this->setName("DedicatedServerWorld uninitialized"); 86 42 87 43 this->loadParams(root); 88 44 } 89 45 46 90 47 /** 91 * remove the NetworkWorld from memory48 * remove the DedicatedServerWorld from memory 92 49 * 93 50 * delete everything explicitly, that isn't contained in the parenting tree! 94 51 * things contained in the tree are deleted automaticaly 95 52 */ 96 NetworkWorld::~NetworkWorld ()53 DedicatedServerWorld::~DedicatedServerWorld () 97 54 { 98 delete this->shell; 99 PRINTF(3)("NetworkWorld::~NetworkWorld() - deleting current world\n"); 100 101 delete this->localPlayer; 102 103 // delete all the initialized Engines. 104 FastFactory::flushAll(true); 105 delete LightManager::getInstance(); 106 delete ParticleEngine::getInstance(); 107 delete AnimationPlayer::getInstance(); 108 delete PhysicsEngine::getInstance(); 109 110 // external engines initialized by the orxonox-class get deleted 111 SoundEngine::getInstance()->flushAllBuffers(); 112 SoundEngine::getInstance()->flushAllSources(); 113 114 if (State::getObjectManager() == &this->objectManager) 115 State::setObjectManager(NULL); 116 // erease everything that is left. 117 delete PNode::getNullParent(); 118 119 //secondary cleanup of PNodes; 120 const std::list<BaseObject*>* nodeList = ClassList::getList(CL_PARENT_NODE); 121 if (nodeList != NULL) 122 while (!nodeList->empty()) 123 delete nodeList->front(); 124 125 Shader::suspendShader(); 126 127 // unload the resources !! 128 ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL); 129 } 130 131 /** 132 * initializes the world. 133 * @param name the name of the world 134 * @param worldID the ID of this world 135 * 136 * set all stuff here that is world generic and does not use to much memory 137 * because the real init() function StoryEntity::init() will be called 138 * shortly before start of the game. 139 * since all worlds are initiated/referenced before they will be started. 140 * NO LEVEL LOADING HERE - NEVER! 141 */ 142 void NetworkWorld::constuctorInit(const char* name, int worldID) 143 { 144 this->setClassID(CL_WORLD, "NetworkWorld"); 145 PRINTF(0)("START\n"); 146 147 this->setName(name); 148 this->gameTime = 0.0f; 149 this->setSpeed(1.0); 150 this->music = NULL; 151 this->shell = NULL; 152 this->localPlayer = NULL; 153 this->localCamera = NULL; 154 155 this->showPNodes = false; 156 this->showBV = false; 157 } 158 159 /** 160 * loads the parameters of a NetworkWorld from an XML-element 161 * @param root the XML-element to load from 162 */ 163 void NetworkWorld::loadParams(const TiXmlElement* root) 164 { 165 PRINTF(4)("Creating a NetworkWorld\n"); 166 167 LoadParam(root, "identifier", this, NetworkWorld, setStoryID) 168 .describe("Sets the StoryID of this world"); 169 170 LoadParam(root, "nextid", this, NetworkWorld, setNextStoryID) 171 .describe("Sets the ID of the next world"); 172 173 LoadParam(root, "path", this, NetworkWorld, setPath) 174 .describe("The Filename of this NetworkWorld (relative from the data-dir)"); 175 } 176 177 /** 178 * this is executed just before load 179 * 180 * since the load function sometimes needs data, that has been initialized 181 * before the load and after the proceeding storyentity has finished 182 */ 183 ErrorMessage NetworkWorld::preLoad() 184 { 185 State::setObjectManager(&this->objectManager); 186 this->cycle = 0; 187 188 /* init the world interface */ 189 this->shell = new Shell(); 190 191 LightManager::getInstance(); 192 PNode::getNullParent(); 193 194 AnimationPlayer::getInstance(); // initializes the animationPlayer 195 ParticleEngine::getInstance(); 196 PhysicsEngine::getInstance(); 197 198 this->localCamera = new Camera(); 199 this->localCamera->setName ("NetworkWorld-Camera"); 200 201 State::setCamera(this->localCamera, this->localCamera->getTarget()); 202 203 GraphicsEngine::getInstance()->displayFPS(true); 204 this->displayLoadScreen(); 55 PRINTF(3)("DedicatedServerWorld::~DedicatedServerWorld() - deleting current world\n"); 205 56 } 206 57 207 58 208 59 /** 209 * loads the NetworkWorld by initializing all resources, and set their default values. 60 * loads the parameters of a DedicatedServerWorld from an XML-element 61 * @param root the XML-element to load from 210 62 */ 211 ErrorMessage NetworkWorld::load()63 void DedicatedServerWorld::loadParams(const TiXmlElement* root) 212 64 { 213 PRINTF(3)("> Loading world: '%s'\n", getPath()); 214 TiXmlElement* element; 215 GameLoader* loader = GameLoader::getInstance(); 65 static_cast<GameWorld*>(this)->loadParams(root); 216 66 217 if( getPath() == NULL) 218 { 219 PRINTF(1)("World has no path specified for loading"); 220 return (ErrorMessage){213,"Path not specified","World::load()"}; 221 } 222 223 TiXmlDocument* XMLDoc = new TiXmlDocument( getPath()); 224 // load the campaign document 225 if( !XMLDoc->LoadFile()) 226 { 227 // report an error 228 PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc->ErrorDesc(), this->getPath(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); 229 delete XMLDoc; 230 return (ErrorMessage){213,"XML File parsing error","NetworkWorld::load()"}; 231 } 232 233 // check basic validity 234 TiXmlElement* root = XMLDoc->RootElement(); 235 assert( root != NULL); 236 237 if( root == NULL || root->Value() == NULL || strcmp( root->Value(), "WorldDataFile")) 238 { 239 // report an error 240 PRINTF(1)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n"); 241 delete XMLDoc; 242 return (ErrorMessage){213,"Path not a WorldDataFile","NetworkWorld::load()"}; 243 } 244 245 246 // load the parameters 247 // name 248 const char* string = grabParameter( root, "name"); 249 if( string == NULL) 250 { 251 PRINTF(2)("World is missing a proper 'name'\n"); 252 this->setName("Unknown"); 253 } 254 else 255 { 256 this->setName(string); 257 } 258 259 260 //////////////// 261 // LOADSCREEN // 262 //////////////// 263 element = root->FirstChildElement("LoadScreen"); 264 if (element == NULL) 265 { 266 PRINTF(2)("no LoadScreen specified, loading default\n"); 267 268 glmis->setBackgroundImage("pictures/load_screen.jpg"); 269 this->glmis->setMaximum(8); 270 this->glmis->draw(); 271 } 272 else 273 { 274 this->glmis->loadParams(element); 275 this->glmis->draw(); 276 } 277 this->glmis->draw(); 278 279 280 281 //////////////////////////// 282 // Loading Spawning Point // 283 //////////////////////////// 284 element = root->FirstChildElement("SpawningPoints"); 285 if( element == NULL) 286 { 287 PRINTF(1)("NetworkWorld is missing 'SpawningPoints'\n"); 288 } 289 else 290 { 291 element = element->FirstChildElement(); 292 // load Players/Objects/Whatever 293 PRINTF(4)("Loading Spawning Points\n"); 294 while( element != NULL) 295 { 296 BaseObject* created = Factory::fabricate(element); 297 if( created != NULL ) 298 { 299 // if(created->isA(CL_SPAWNING_POINT)) 300 // this->spawn(dynamic_cast<WorldEntity*>(created)); 301 printf("Created a Spawning Point %s: %s\n", created->getClassName(), created->getName()); 302 } 303 304 305 element = element->NextSiblingElement(); 306 glmis->step(); //! @todo temporary 307 } 308 PRINTF(4)("Done loading NetworkWorldEntities\n"); 309 } 310 311 312 //////////////////////// 313 // find WorldEntities // 314 //////////////////////// 315 element = root->FirstChildElement("WorldEntities"); 316 if( element == NULL) 317 { 318 PRINTF(1)("NetworkWorld is missing 'WorldEntities'\n"); 319 } 320 else 321 { 322 element = element->FirstChildElement(); 323 // load Players/Objects/Whatever 324 PRINTF(4)("Loading NetworkWorldEntities\n"); 325 while( element != NULL) 326 { 327 if( NetworkManager::getInstance()->isGameServer()) 328 { 329 330 BaseObject* created = NetworkGameManager::getInstance()->createEntity(element); 331 if( created != NULL ) 332 { 333 // if(created->isA(CL_WORLD_ENTITY)) 334 // this->spawn(dynamic_cast<WorldEntity*>(created)); 335 printf("Created a %s: %s\n", created->getClassName(), created->getName()); 336 } 337 else 338 PRINTF(1)("NetworkWorld: could not create this entity\n"); 339 340 // if we load a 'Player' we use it as localPlayer 341 342 343 //todo do this more elegant 344 if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) 345 sky = dynamic_cast<WorldEntity*>(created); 346 if( element->Value() != NULL && !strcmp( element->Value(), "Terrain")) 347 { 348 terrain = dynamic_cast<Terrain*>(created); 349 CDEngine::getInstance()->setTerrain(terrain); 350 351 } 352 353 } 354 else if( /* !strcmp( element->Value(), "SkyBox") || */ /* !strcmp( element->Value(), "Terrain") || */ !strcmp( element->Value(), "SpaceShip")) 355 { 356 BaseObject* created = Factory::fabricate(element); 357 if( created != NULL ) 358 { 359 // if(created->isA(CL_WORLD_ENTITY)) 360 // this->spawn(dynamic_cast<WorldEntity*>(created)); 361 printf("Created a %s: %s\n", created->getClassName(), created->getName()); 362 } 363 else 364 PRINTF(1)("NetworkWorld: could not create this entity\n"); 365 366 // if we load a 'Player' we use it as localPlayer 367 368 369 //todo do this more elegant 370 if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) 371 sky = dynamic_cast<WorldEntity*>(created); 372 if( element->Value() != NULL && !strcmp( element->Value(), "Terrain")) 373 { 374 terrain = dynamic_cast<Terrain*>(created); 375 CDEngine::getInstance()->setTerrain(terrain); 376 } 377 } 378 element = element->NextSiblingElement(); 379 glmis->step(); //! @todo temporary 380 PRINTF(4)("Done loading NetworkWorldEntities\n"); 381 } 382 } 383 384 385 ////////////////////////////// 386 // LOADING ADDITIONAL STUFF // 387 ////////////////////////////// 388 389 LoadParamXML(root, "LightManager", LightManager::getInstance(), LightManager, loadParams); 390 391 LoadParamXML(root, "ParticleEngine", ParticleEngine::getInstance(), ParticleEngine, loadParams); 392 // LoadParamXML(root, "PhysicsEngine", PhysicsEngine::getInstance(), PhysicsEngine, loadParams); 393 394 // free the XML data 395 396 delete XMLDoc; 397 /* GENERIC LOADING PROCESS FINISHED */ 398 399 400 // Create a Player 401 this->localPlayer = new Player(); 402 403 Playable* playable; 404 const list<BaseObject*>* playableList = ClassList::getList(CL_PLAYABLE); 405 if (playableList != NULL) 406 { 407 playable = dynamic_cast<Playable*>(playableList->front()); 408 this->localPlayer->setControllable(playable); 409 } 410 411 412 // //localCamera->setParent(TrackNode::getInstance()); 413 // tn->addChild(this->localCamera); 414 localCamera->setClipRegion(1, 10000.0); 415 // localCamera->lookAt(playable); 416 // this->localPlayer->setParentMode(PNODE_ALL); 417 if (this->sky != NULL) 418 { 419 this->localCamera->addChild(sky); 420 } 421 SoundEngine::getInstance()->setListener(this->localCamera); 422 423 424 425 //////////// 426 // STATIC // 427 //////////// 428 429 430 // TestEntity* testEntity = new TestEntity(); 431 // testEntity->setRelCoor(Vector(570, 10, -15)); 432 // testEntity->setRelDir(Quaternion(M_PI, Vector(0, 1, 0))); 433 // this->spawn(testEntity); 434 435 // for(int i = 0; i < 100; i++) 436 // { 437 // WorldEntity* tmp = NetworkGameManager::; 438 // char npcChar[10]; 439 // sprintf (npcChar, "NPC_%d", i); 440 // tmp->setName(npcChar); 441 // tmp->setAbsCoor(((float)rand()/RAND_MAX) * 5000, 50/*+ (float)rand()/RAND_MAX*20*/, ((float)rand()/RAND_MAX -.5) *30); 442 // this->spawn(tmp); 443 // } 444 445 this->music = NULL; 446 //(OggPlayer*)ResourceManager::getInstance()->load("sound/00-luke_grey_-_hypermode.ogg", OGG, RP_LEVEL); 447 //music->playback(); 67 PRINTF(4)("Loaded DedicatedServerWorld specific stuff\n"); 448 68 } 449 69 450 ErrorMessage NetworkWorld::postLoad()451 {452 /*monitor progress*/453 this->glmis->step();454 // stuff beyond this point remains to be loaded properly455 456 // LIGHT initialisation457 LightManager::getInstance()->setAmbientColor(.1,.1,.1);458 // LightManager::getInstance()->addLight();459 LightManager::getInstance()->debug();460 461 this->releaseLoadScreen();462 }463 464 465 /**466 * initializes a new NetworkWorld shortly before start467 *468 * this is the function, that will be loaded shortly before the world is469 * started470 */471 ErrorMessage NetworkWorld::preStart()472 {473 this->bPause = false;474 475 /* update the object position before game start - so there are no wrong coordinates used in the first processing */476 PNode::getNullParent()->updateNode (0.001f);477 PNode::getNullParent()->updateNode (0.001f);478 }479 480 481 /**482 * starts the NetworkWorld483 */484 ErrorMessage NetworkWorld::start()485 {486 this->bQuitWorld = false;487 this->mainLoop();488 }489 490 /**491 * stops the world.492 493 This happens, when the player decides to end the Level.494 */495 ErrorMessage NetworkWorld::stop()496 {497 PRINTF(3)("NetworkWorld::stop() - got stop signal\n");498 this->bQuitWorld= true;499 }500 501 /**502 * pauses the Game503 */504 ErrorMessage NetworkWorld::pause()505 {506 this->isPaused = true;507 }508 509 /**510 * ends the pause Phase511 */512 ErrorMessage NetworkWorld::resume()513 {514 this->isPaused = false;515 }516 517 /**518 * destroys the NetworkWorld519 */520 ErrorMessage NetworkWorld::destroy()521 {522 523 }524 525 /**526 * shows the loading screen527 */528 void NetworkWorld::displayLoadScreen ()529 {530 PRINTF(3)("NetworkWorld::displayLoadScreen - start\n");531 532 //GLMenuImageScreen*533 this->glmis = new GLMenuImageScreen();534 this->glmis->setMaximum(8);535 536 PRINTF(3)("NetworkWorld::displayLoadScreen - end\n");537 }538 539 /**540 * @brief removes the loadscreen, and changes over to the game541 *542 * @todo take out the delay543 */544 void NetworkWorld::releaseLoadScreen ()545 {546 PRINTF(3)("NetworkWorld::releaseLoadScreen - start\n");547 this->glmis->setValue(this->glmis->getMaximum());548 PRINTF(3)("NetworkWorld::releaseLoadScreen - end\n");549 delete this->glmis;550 }551 552 553 /**554 * this returns the current game time555 * @returns elapsed game time556 */557 double NetworkWorld::getGameTime()558 {559 return this->gameTime;560 }561 562 /**563 \brief main loop of the world: executing all world relevant function564 in this loop we synchronize (if networked), handle input events, give the heart-beat to565 all other member-entities of the world (tick to player, enemies etc.), checking for566 collisions drawing everything to the screen.567 */568 void NetworkWorld::mainLoop()569 {570 this->lastFrame = SDL_GetTicks ();571 PRINTF(3)("World::mainLoop() - Entering main loop\n");572 573 while(!this->bQuitWorld) /* @todo implement pause */574 {575 ++this->cycle;576 // Network577 this->synchronize ();578 // Process input579 this->handleInput ();580 if( this->bQuitWorld)581 break;582 // Process time583 this->tick ();584 // Process collision585 this->collide ();586 // Update the state587 this->update ();588 // Draw589 this->display ();590 }591 592 PRINTF(3)("NetworkWorld::mainLoop() - Exiting the main loop\n");593 }594 595 596 /**597 * synchronize local data with remote data598 */599 void NetworkWorld::synchronize ()600 {601 // Get remote input602 // Update synchronizables603 NetworkManager::getInstance()->synchronize();604 }605 606 607 /**608 * run all input processing609 610 the command node is the central input event dispatcher. the node uses the even-queue from611 sdl and has its own event-passing-queue.612 */613 void NetworkWorld::handleInput ()614 {615 EventHandler::getInstance()->process();616 617 // remoteinput618 }619 620 void NetworkWorld::tick(std::list<WorldEntity*> entityList, float dt)621 {622 std::list<WorldEntity*>::iterator entity;623 for (entity = entityList.begin(); entity != entityList.end(); entity++)624 (*entity)->tick(dt);625 626 }627 628 /**629 * advance the timeline630 631 this calculates the time used to process one frame (with all input handling, drawing, etc)632 the time is mesured in ms and passed to all world-entities and other classes that need633 a heart-beat.634 */635 void NetworkWorld::tick ()636 {637 Uint32 currentFrame = SDL_GetTicks();638 if(!this->bPause)639 {640 this->dt = currentFrame - this->lastFrame;641 642 if( this->dt > 10)643 {644 float fps = 1000/dt;645 646 // temporary, only for showing how fast the text-engine is647 char tmpChar[20];648 sprintf(tmpChar, "fps: %4.0f", fps);649 }650 else651 {652 /* the frame-rate is limited to 100 frames per second, all other things are for653 nothing.654 */655 PRINTF(3)("fps = 1000 - frame rate is adjusted\n");656 SDL_Delay(10-dt);657 this->dt = 10;658 }659 660 this->dtS = (float)this->dt / 1000.0 * this->speed;661 this->gameTime += this->dtS;662 663 this->tick(this->objectManager.getObjectList(OM_DEAD_TICK), this->dtS);664 this->tick(this->objectManager.getObjectList(OM_COMMON), this->dtS);665 this->tick(this->objectManager.getObjectList(OM_GROUP_00), this->dtS);666 this->tick(this->objectManager.getObjectList(OM_GROUP_01), this->dtS);667 this->tick(this->objectManager.getObjectList(OM_GROUP_01_PROJ), this->dtS);668 669 /* update tick the rest */670 this->localCamera->tick(this->dtS);671 // tick the engines672 AnimationPlayer::getInstance()->tick(this->dtS);673 // if (this->cycle > 5)674 PhysicsEngine::getInstance()->tick(this->dtS);675 676 ParticleEngine::getInstance()->tick(this->dtS);677 678 679 /** actualy the Graphics Engine should tick the world not the other way around...680 but since we like the things not too complicated we got it this way around681 until there is need or time to do it the other way around.682 @todo: GraphicsEngine ticks world: separation of processes and data...683 684 bensch: in my opinion the GraphicsEngine could draw the world, but not tick it,685 beceause graphics have nothing(or at least not much) to do with Motion.686 */687 GraphicsEngine::getInstance()->tick(this->dtS);688 }689 this->lastFrame = currentFrame;690 }691 692 693 /**694 * this function gives the world a consistant state695 696 after ticking (updating the world state) this will give a constistant697 state to the whole system.698 */699 void NetworkWorld::update()700 {701 GraphicsEngine::getInstance()->update(this->dtS);702 PNode::getNullParent()->updateNode (this->dtS);703 SoundEngine::getInstance()->update();704 //music->update();705 }706 707 708 void NetworkWorld::collide()709 {710 CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_00),711 this->objectManager.getObjectList(OM_GROUP_01_PROJ));712 CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_01),713 this->objectManager.getObjectList(OM_COMMON));714 }715 716 /**717 * render the current frame718 719 clear all buffers and draw the world720 */721 void NetworkWorld::display ()722 {723 // clear buffer724 glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);725 // set camera726 this->localCamera->apply ();727 // draw world728 this->draw();729 // draw HUD730 /** @todo draw HUD */731 // flip buffers732 GraphicsEngine::swapBuffers();733 //SDL_Surface* screen = Orxonox::getInstance()->getScreen ();734 //SDL_Flip (screen);735 }736 737 738 /**739 * runs through all entities calling their draw() methods740 */741 void NetworkWorld::draw ()742 {743 GraphicsEngine* engine = GraphicsEngine::getInstance();744 engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON_NOTICK));745 engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON));746 engine->draw(State::getObjectManager()->getObjectList(OM_COMMON));747 engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_00));748 engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01));749 engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01_PROJ));750 751 if( unlikely( this->showBV)) // to draw the bounding boxes of the objects at level 2 for debug purp752 {753 CDEngine* engine = CDEngine::getInstance();754 engine->drawBV(State::getObjectManager()->getObjectList(OM_ENVIRON_NOTICK));755 engine->drawBV(State::getObjectManager()->getObjectList(OM_ENVIRON));756 engine->drawBV(State::getObjectManager()->getObjectList(OM_COMMON));757 engine->drawBV(State::getObjectManager()->getObjectList(OM_GROUP_00));758 engine->drawBV(State::getObjectManager()->getObjectList(OM_GROUP_01));759 engine->drawBV(State::getObjectManager()->getObjectList(OM_GROUP_01_PROJ));760 }761 762 // {763 // if( entity->isVisible() ) entity->draw();764 //FIXME765 // entity = iterator->nextElement();766 // }767 768 ParticleEngine::getInstance()->draw();769 770 if (unlikely(this->showPNodes))771 PNode::getNullParent()->debugDraw(0);772 773 engine->draw();774 //TextEngine::getInstance()->draw();775 }776 777 void NetworkWorld::setPath( const char* name)778 {779 if (this->path)780 delete this->path;781 if (ResourceManager::isFile(name))782 {783 this->path = new char[strlen(name)+1];784 strcpy(this->path, name);785 }786 else787 {788 this->path = new char[strlen(ResourceManager::getInstance()->getDataDir()) + strlen(name) +1];789 sprintf(this->path, "%s%s", ResourceManager::getInstance()->getDataDir(), name);790 }791 }792 793 const char* NetworkWorld::getPath( void)794 {795 return path;796 } -
branches/network/src/story_entities/dedicated_server_world.h
r6355 r6386 1 1 /*! 2 * @file world.h3 * Holds and manages all gamedata4 */2 * @file dedicated_server_world.h 3 * Holds and manages all dedicated server data 4 */ 5 5 6 #ifndef _ WORLD_H7 #define _ WORLD_H6 #ifndef _DEDICATED_SERVER_WORLD_H 7 #define _DEDICATED_SERVER_WORLD_H 8 8 9 #include "sdlincl.h" 10 #include "story_entity.h" 11 #include "object_manager.h" 9 #include "game_world.h" 12 10 13 class NetworkWorld;14 11 15 class WorldEntity;16 class Camera;17 class Player;18 class GLMenuImageScreen;19 class Terrain;20 12 class TiXmlElement; 21 13 22 class Shell;23 class OggPlayer;24 14 25 15 //! The game world 26 16 /** 27 this class initializes everything that should be displayed inside of the current level. 28 it is the main driving factor during gameplay. 29 */ 30 class NetworkWorld : public StoryEntity { 17 * this class initializes everything that should be displayed inside of the current level. 18 * it is the main driving factor during gameplay. 19 */ 20 class DedicatedServerWorld : public GameWorld 21 { 31 22 32 public:33 NetworkWorld (const TiXmlElement* root = NULL);34 virtual ~NetworkWorld ();23 public: 24 DedicatedServerWorld (const TiXmlElement* root = NULL); 25 virtual ~DedicatedServerWorld (); 35 26 36 void loadParams(const TiXmlElement* root); 37 38 double getGameTime(); 39 40 /* classes from story-entity */ 41 virtual ErrorMessage preLoad(); 42 virtual ErrorMessage load (); 43 virtual ErrorMessage postLoad(); 44 45 virtual ErrorMessage preStart(); 46 virtual ErrorMessage start (); 47 virtual ErrorMessage stop (); 48 virtual ErrorMessage pause (); 49 virtual ErrorMessage resume (); 50 virtual ErrorMessage destroy (); 51 52 void displayLoadScreen(); 53 void releaseLoadScreen(); 54 55 /* interface to world */ 56 // void spawn (WorldEntity* entity); 57 58 /** @param speed sets the speed of the Game */ 59 inline void setSpeed(float speed) { this->speed = speed; }; 60 const char* getPath(); 61 void setPath( const char* name); 62 63 void togglePNodeVisibility() { this->showPNodes = !this->showPNodes; }; 64 void toggleBVVisibility() { this->showBV = !this->showBV; }; 65 66 private: 67 void constuctorInit(const char* name, int worldID); 68 /* function for main-loop */ 69 void synchronize (); 70 void handleInput (); 71 void tick (std::list<WorldEntity*> worldEntity, float dt); 72 void tick (); 73 void update (); 74 void collide (); 75 void draw (); 76 void mainLoop (); 77 78 void display (); 79 void debug (); 27 void loadParams(const TiXmlElement* root); 80 28 81 29 private: 82 char* path; //!< The file from which this world is loaded83 30 84 // FLAGS //85 bool bQuitWorld; //!< quit only the current game and return to menu86 bool bPause; //!< pause mode87 88 bool showPNodes; //!< if the PNodes should be visible.89 bool showBV; //!< if the Bounding Volumes should be visible.90 91 // TIMING //92 Uint32 lastFrame; //!< last time of frame93 Uint32 cycle; //!< The cycle we are in (starts with 0 and rises with every frame)94 Uint32 dt; //!< time needed to calculate this frame (in milliSeconds)95 float dtS; //!< The time needed for caluculations in seconds96 float speed; //!< how fast the game flows97 double gameTime; //!< this is where the game time is saved98 99 // INTERNAL ENGINES100 ObjectManager objectManager; //!< The ObjectManager of this World.101 Shell* shell;102 OggPlayer* music;103 104 GLMenuImageScreen* glmis; //!< The Level-Loader Display105 106 107 // IMPORTANT ENTITIES108 Camera* localCamera; //!< The current Camera109 Player* localPlayer; //!< The Player, you fly through the level.110 111 WorldEntity* sky; //!< The Environmental Heaven of orxonox @todo insert this to environment insted112 Terrain* terrain; //!< The Terrain of the NetworkWorld.113 31 }; 114 32 115 #endif /* _ WORLD_H */33 #endif /* _DEDICATED_SERVER_WORLD_H */ -
branches/network/src/story_entities/game_world.cc
r6377 r6386 278 278 BaseObject* created = Factory::fabricate(element); 279 279 if( created != NULL ) 280 {281 if(created->isA(CL_WORLD_ENTITY))282 this->spawn(dynamic_cast<WorldEntity*>(created));283 280 printf("Created a %s: %s\n", created->getClassName(), created->getName()); 284 }285 286 // if we load a 'Player' we use it as localPlayer287 281 288 282 … … 345 339 //music->playback(); 346 340 347 this->releaseLoadScreen();348 }349 350 351 /**352 * initializes a new GameWorld shortly before start353 *354 * this is the function, that will be loaded shortly before the world is355 * started356 */357 ErrorMessage GameWorld::preStart()358 {359 this->bPause = false;360 361 341 /* update the object position before game start - so there are no wrong coordinates used in the first processing */ 362 342 PNode::getNullParent()->updateNode (0.001f); 363 343 PNode::getNullParent()->updateNode (0.001f); 344 345 this->releaseLoadScreen(); 364 346 } 365 347 … … 370 352 ErrorMessage GameWorld::start() 371 353 { 372 this->bQuitWorld = false; 354 this->isPaused = false; 355 this->isRunning = true; 373 356 this->mainLoop(); 374 357 } … … 382 365 { 383 366 PRINTF(3)("GameWorld::stop() - got stop signal\n"); 384 this-> bQuitWorld= true;367 this->isRunning = false; 385 368 } 386 369 … … 408 391 { 409 392 PRINTF(3)("GameWorld::displayLoadScreen - start\n"); 410 411 //GLMenuImageScreen*412 393 this->glmis = new GLMenuImageScreen(); 413 394 this->glmis->setMaximum(8); 414 415 395 PRINTF(3)("GameWorld::displayLoadScreen - end\n"); 416 396 } 397 417 398 418 399 /** … … 472 453 { 473 454 Uint32 currentFrame = SDL_GetTicks(); 474 if( !this->bPause)455 if( !this->isPaused) 475 456 { 476 457 this->dt = currentFrame - this->lastFrame; … … 624 605 PRINTF(3)("GameWorld::mainLoop() - Entering main loop\n"); 625 606 626 while( !this->bQuitWorld) /* @todo implement pause */607 while( this->isRunning) /* @todo implement pause */ 627 608 { 628 609 ++this->cycle; … … 631 612 // Process input 632 613 this->handleInput (); 633 if( this->bQuitWorld)614 if( !this->isRunning) 634 615 break; 635 616 // Process time … … 652 633 * @param entity to be added 653 634 */ 654 void GameWorld::spawn(WorldEntity* entity)655 {656 // this->entities->add (entity);657 entity->postSpawn ();658 }635 // void GameWorld::spawn(WorldEntity* entity) 636 // { 637 // // this->entities->add (entity); 638 // entity->postSpawn (); 639 // } 659 640 660 641 /** -
branches/network/src/story_entities/game_world.h
r6372 r6386 38 38 virtual ErrorMessage init(); 39 39 virtual ErrorMessage loadData(); 40 virtual ErrorMessage unloadData() {} 40 41 41 virtual ErrorMessage preStart();42 42 virtual ErrorMessage start(); 43 43 virtual ErrorMessage stop(); 44 44 virtual ErrorMessage pause(); 45 45 virtual ErrorMessage resume(); 46 47 virtual void displayLoadScreen();48 virtual void releaseLoadScreen();49 50 /* interface to the game world */51 virtual void spawn (WorldEntity* entity);52 46 53 47 … … 57 51 inline void setSpeed(float speed) { this->speed = speed; }; 58 52 /** returns the track path of this world @returns the track path */ 59 const char* getPath() { returnpath; }53 const char* getPath() { return this->path; } 60 54 void setPath( const char* name); 61 55 … … 67 61 68 62 protected: 63 /* world loading functions */ 64 virtual ErrorMessage loadGUI(TiXmlElement* root) {} 65 virtual ErrorMessage loadWorldEntities(TiXmlElement* root) {} 66 virtual ErrorMessage loadScene(TiXmlElement* root) {} 67 69 68 /* world - running functions */ 70 69 virtual void mainLoop (); 71 70 72 virtual void synchronize (); 73 virtual void handleInput (); 74 virtual void tick (std::list<WorldEntity*> worldEntity, float dt); 75 virtual void tick (); 76 virtual void update (); 77 virtual void collide (); 78 virtual void draw (); 79 virtual void display (); 71 virtual void synchronize(); 72 virtual void handleInput(); 73 virtual void tick(std::list<WorldEntity*> worldEntity, float dt); 74 virtual void tick(); 75 virtual void update(); 76 virtual void collide(); 77 virtual void draw(); 78 virtual void display(); 79 80 81 private: 82 void displayLoadScreen(); 83 void releaseLoadScreen(); 80 84 81 85 82 86 protected: 83 87 char* path; //!< The file from which this world is loaded 84 85 /* state flags */86 bool bQuitWorld; //!< quit only the current game and return to menu87 bool bPause; //!< pause mode88 88 89 89 bool showPNodes; //!< if the PNodes should be visible. -
branches/network/src/story_entities/story_entity.cc
r6376 r6386 32 32 33 33 this->isInit = false; 34 this->readyToRun = false;35 34 this->isPaused = false; 36 this->is Suspended= false;35 this->isRunning = false; 37 36 38 37 this->storyID = -1; -
branches/network/src/story_entities/story_entity.h
r6377 r6386 1 1 /*! 2 2 * @file story_entity.h 3 4 */3 * holds the base class of everything that is playable - that is part of the story 4 */ 5 5 6 6 … … 24 24 /** initializes a Story Entity to the needed values */ 25 25 virtual ErrorMessage init() {}; 26 /** called to load the data into the story entity*/26 /** called to load the data into the StoryEntity*/ 27 27 virtual ErrorMessage loadData() {}; 28 28 /** function that unloads the data from the StoryEntity */ 29 virtual ErrorMessage unloadData() {}; 29 30 /* running, stopping and pausing */ 30 /** called shortly before starting the Entity */31 virtual ErrorMessage preStart() {};32 31 /** starts the Entity. Starts the main cycle */ 33 32 virtual ErrorMessage start() = 0; … … 36 35 /** resumes the Entity after a stop/pause or suspend. */ 37 36 virtual ErrorMessage resume() = 0; 38 /** suspends the Entity detaches all mayor functions (optional) */39 virtual ErrorMessage suspend() {};40 /** rewinds to the beginning/last checkpoint */41 virtual ErrorMessage rewind() {};42 /** leaves the Entity. Ends it */43 virtual ErrorMessage preStop() {};44 37 /** Stops the entity. */ 45 38 virtual ErrorMessage stop() = 0; … … 62 55 protected: 63 56 bool isInit; //!< if the entity is initialized, this has to be true. 64 bool readyToRun; //!< If the entity is ready to run -> post-check.57 bool isRunning; //!< is true if the entity is running 65 58 bool isPaused; //!< is true if the entity is paused 66 bool isSuspended; //!< if the Entity is suspended.67 59 68 60
Note: See TracChangeset
for help on using the changeset viewer.