WOWCube Docs logo
WOWCube Docs
Mission Control
Section Shortcuts
APIExamplesSourceWOWConnectChangelog
Filters
SDK and language defaults persist in cookies.
SDK version
Navigation Tree
Collapsed by default, focused on the active path.
Made byMcKay Seamons
GitHub
  1. Home
  2. Docs
  3. Source
  4. Scene.cpp
Mission NodeSDK 6.3C++scene.cpp

Scene.cpp

SDK Source File: Scene.cpp

Source / SDK 6.3 / C++ / Core

Scene.cpp

Scene.cpp
CPP
1/* Copyright Statement:
2 *
3 * (C) 2021-2025 Cubios Inc. All rights reserved.
4 */
5
6#include "Scene.h"
7
8namespace Cubios
9{
10
11Scene::Scene()
12{
13}
14
15Scene::~Scene()
16{
17 this->DisposeAllObjects();
18}
19
20SceneObject* Scene::operator[](uint32_t objectKey)
21 {
22 return this->root[objectKey];
23 }
24
25uint32_t Scene::CreateObject(SceneObject* obj)
26{
27 if(obj==nullptr) return false;
28
29 uint32_t s = (uint32_t)this->root.size();
30 obj->SetId(s);
31 this->root[s] = obj;
32
33 return s;
34}
35
36bool Scene::CreateObjectWithID(uint32_t id, SceneObject* obj)
37{
38 bool ret = true;
39 if(obj==nullptr) return false;
40
41 if(this->root.find(id)==this->root.end())
42 {
43 obj->SetId(id);
44 this->root[id] = obj;
45 }
46 else
47 {
48 LOG_e("CreateObjectWithID: Resource with id %d already exists\n",id);
49 ret = false;
50 }
51
52 return ret;
53}
54
55uint32_t Scene::CreateSound(Sound* obj)
56{
57 if(obj==nullptr) return false;
58
59 uint32_t s = (uint32_t)this->sounds.size();
60 obj->SetId(s);
61 this->sounds[s] = obj;
62
63 return s;
64}
65
66bool Scene::CreateSoundWithID(uint32_t id, Sound* obj)
67{
68 bool ret = true;
69 if(obj==nullptr) return false;
70
71 if(this->sounds.find(id)==this->sounds.end())
72 {
73 obj->SetId(id);
74 this->sounds[id] = obj;
75 }
76 else
77 {
78 LOG_e("CreateSoundWithID: Resource with id %d already exists\n",id);
79 ret = false;
80 }
81
82 return ret;
83}
84
85bool Scene::DisposeObjectWithID(uint32_t id)
86{
87 bool ret = true;
88 std::map<uint32_t, SceneObject*>::iterator it = this->root.find(id);
89
90 if(it!=this->root.end())
91 {
92 if(this->root[id]!=nullptr)
93 {
94 delete this->root[id];
95 }
96
97 this->root.erase(it);
98 }
99 else
100 {
101 ret = false;
102 }
103
104 return ret;
105}
106
107bool Scene::DisposeSoundWithID(uint32_t id)
108{
109 bool ret = true;
110 std::map<uint32_t, Sound*>::iterator it = this->sounds.find(id);
111
112 if(it!=this->sounds.end())
113 {
114 if(this->sounds[id]!=nullptr)
115 {
116 delete this->sounds[id];
117 }
118
119 this->sounds.erase(it);
120 }
121 else
122 {
123 ret = false;
124 }
125
126 return ret;
127}
128
129void Scene::DisposeAllObjects()
130{
131 for (auto it = this->root.begin(); it != this->root.end(); it++)
132 {
133 if((*it).second!=nullptr)
134 {
135 delete (*it).second;
136 }
137 }
138
139 for (auto it = this->sounds.begin(); it != this->sounds.end(); it++)
140 {
141 if((*it).second!=nullptr)
142 {
143 delete (*it).second;
144 }
145 }
146
147 this->root.clear();
148 this->sounds.clear();
149}
150
151void Scene::Play(uint32_t id,uint8_t volume)
152{
153 if(this->sounds.count(id)!=0)
154 {
155 this->sounds[id]->Play(volume);
156 }
157}
158
159}
160
Wrapped for easier reading. Turn wrap off to inspect exact line lengths.
Context Rail

Related nodes

AppManager.cpp
Source / SDK 6.3 / C++ / Core
AppManager.h
Source / SDK 6.3 / C++ / Core
Gfx.h
Source / SDK 6.3 / C++ / Core
native access.h
Source / SDK 6.3 / C++ / Core
Previous Node
SaveMessage.h
Source / SDK 6.3 / C++ / Core
Next Node
Scene.h
Source / SDK 6.3 / C++ / Core