AnnLevel.cpp
Go to the documentation of this file.
1 // This is an open source non-commercial project. Dear PVS-Studio, please check it.
2 // PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
3 
4 #include "AnnLevel.hpp"
5 #include "AnnLogger.hpp"
6 #include "AnnGetter.hpp"
7 
8 using namespace Annwvyn;
9 
11 {
12  AnnDebug() << "Level object " << this << " has been created";
13 }
14 
16 {
17  AnnDebug() << "Running generic level unload procedure now.";
19 }
20 
22 {
23  AnnDebug() << "Unloading the level " << this << " From the scene";
24 
25  //Remove background music
26  AnnGetAudioEngine()->stopBGM();
27 
28  //Reset scene
29  AnnGetSceneryManager()->resetSceneParameters();
30 
31  //Restore the default gravity
32  AnnGetPhysicsEngine()->resetGravity();
33 
34  //Remove the level lights
35  for(auto obj : levelLighting)
36  AnnGetGameObjectManager()->removeLightObject(obj);
38 
39  //Remove the level objects
40  for(auto obj : levelContent)
41  AnnGetGameObjectManager()->removeGameObject(obj);
43 
44  //Remove volumetric event triggers
45  for(auto obj : levelTrigger)
46  AnnGetGameObjectManager()->removeTriggerObject(obj);
48 
49  levelMovable.clear();
50 
51  AnnGetPlayer()->_hintRoomscaleUpdateTranslationReference();
52 }
53 
55 {
56  return levelTrigger;
57 }
58 
60 {
61  auto light(AnnGetGameObjectManager()->createLightObject(id));
62  levelLighting.push_back(light);
63  return light;
64 }
65 
67 {
68  auto object(AnnGetGameObjectManager()->createGameObject(entityName.c_str(), objectName));
69  levelContent.push_back(object);
70  return object;
71 }
72 
74 {
75  levelMovable.push_back(movable);
76 }
77 
79 {
80  auto obj = AnnGetGameObjectManager()->createTriggerObject(id);
82  return obj;
83 }
84 
86 {
87  return levelContent;
88 }
89 
91 {
92  return levelLighting;
93 }
virtual void unload()
Unload the level by destroying every objects in "levelContent" and every lights in "levelLighting"...
Definition: AnnLevel.cpp:21
AnnLevel()
Construct the level.
Definition: AnnLevel.cpp:10
AnnGameObjectList & getContent()
Get the list of objects.
Definition: AnnLevel.cpp:85
AnnLightList & getLights()
Get the list of lights.
Definition: AnnLevel.cpp:90
std::vector< std::shared_ptr< AnnAbstractMovable > > levelMovable
List of movable on the level.
Definition: AnnLevel.hpp:66
Namespace containing the totality of Annwvyn components.
Definition: AnnGetter.cpp:8
std::shared_ptr< AnnLightObject > addLightObject(std::string id="")
Add a light object to the level.
Definition: AnnLevel.cpp:59
AnnGameObjectManagerPtr AnnGetGameObjectManager()
Get the game-object manager.
Definition: AnnGetter.cpp:22
T push_back(T... args)
virtual ~AnnLevel()
Destroy the level.
Definition: AnnLevel.cpp:15
AnnTriggerObjectList levelTrigger
Definition: AnnLevel.hpp:63
Pure virtual class that represent a level AnnLevelManager class only handle object that derive from t...
Create a ostream to the Ogre logger.
AnnAudioEnginePtr AnnGetAudioEngine()
Get the audio engine.
Definition: AnnGetter.cpp:12
Open an output stream to the engine log.
Definition: AnnLogger.hpp:24
T clear(T... args)
AnnSceneryManagerPtr AnnGetSceneryManager()
Get the scenery manager.
Definition: AnnGetter.cpp:19
AnnPhysicsEnginePtr AnnGetPhysicsEngine()
Get the physics engine.
Definition: AnnGetter.cpp:13
void addManualMovableObject(std::shared_ptr< AnnAbstractMovable > movable)
Add a manual movable object.
Definition: AnnLevel.cpp:73
AnnGameObjectList levelContent
Definition: AnnLevel.hpp:57
T c_str(T... args)
AnnLightList levelLighting
Definition: AnnLevel.hpp:60
AnnTriggerObjectList & getTriggers()
Get the list of triggers.
Definition: AnnLevel.cpp:54
AnnPlayerBodyPtr AnnGetPlayer()
Get the player object.
Definition: AnnGetter.cpp:17
std::shared_ptr< AnnTriggerObject > addTrggerObject(std::string id="")
Add a trigger object to the level.
Definition: AnnLevel.cpp:78
std::shared_ptr< AnnGameObject > addGameObject(std::string entityName, std::string name="")
Add a Game object to the level.
Definition: AnnLevel.cpp:66