Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void WorldManager::shutdown()
- {
- //destroy worlds
- /*int size = mWorlds.size();
- for (int i=0; i<size; i++)
- {
- destroyWorld(mWorlds.at(i)->getName());
- }*/
- foreach(worldsmap::value_type i, mWorlds)
- {
- //destroyWorld(i.first);
- World* r_world = i.second;
- if (r_world)
- {
- if (mCurrentWorld != r_world)
- {
- //save current world
- String temp_name = mCurrentWorld->getName();
- //switch to world for destroying
- switchWorld(name);
- //world
- delete r_world;
- //mWorlds.erase(name);
- //sceneholders
- destroyScenes(name);
- //switch back
- switchWorld(temp_name);
- }
- else
- {
- //world
- delete r_world;
- //mWorlds.erase(name);
- //sceneholders
- destroyScenes(name);
- //switch to other world because current already destroyed
- if (mWorlds.size() > 1)
- {
- switchWorld(mWorlds.begin()->first);
- }
- else
- {
- mCurrentWorld = 0;
- }
- }
- to_log("WorldManager:: world "+ name + " destroyed suxxess");
- }
- }
- mWorlds.clear();
- mCurrentWorld = 0;
- to_log("WorldManager :: shutdown suxxess..");
- };
- void WorldManager::test()
- {
- //make tests here
- //---
- to_log("WorldManager :: Test is ok");
- };
- void WorldManager::update(float time)
- {
- if (mCurrentWorld)
- {
- mCurrentWorld->update(time);
- }
- };
- void WorldManager::createWorld(const String& params)
- {
- //create params
- WorldParams* temp_params = new WorldParams(params);
- if (getWorld(temp_params->name))
- {
- to_log("WorldManager:: World " + temp_params->name + " already exist, please choose other name..");
- }
- else
- {
- to_log("WorldManager:: World " + temp_params->name + " starts creating..");
- //sceneholders
- createScenes(params);
- //switch scenes
- switchScenes(temp_params->name);
- //create world
- World* temp_w = new World(temp_params);
- //set as current
- mWorlds[temp_params->name] = temp_w;
- mCurrentWorld = temp_w;
- };
- };
- void WorldManager::destroyWorld(const String& name)
- {
- //get
- World* r_world = getWorld(name);
- //try to destroy
- if (r_world)
- {
- if (mCurrentWorld != r_world)
- {
- //save current world
- String temp_name = mCurrentWorld->getName();
- //switch to world for destroying
- switchWorld(name);
- //world
- delete r_world;
- mWorlds.erase(name);
- //sceneholders
- destroyScenes(name);
- //switch back
- switchWorld(temp_name);
- }
- else
- {
- //world
- delete r_world;
- mWorlds.erase(name);
- //sceneholders
- destroyScenes(name);
- //switch to other world because current already destroyed
- if (mWorlds.size() > 1)
- {
- switchWorld(mWorlds.begin()->first);
- }
- else
- {
- mCurrentWorld = 0;
- }
- }
- to_log("WorldManager:: world "+ name + " destroyed suxxess");
- }
- else
- {
- to_log("WorldManager :: World :" + name + " not exist");
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement