This commit is contained in:
2025-01-02 13:56:33 -05:00
parent 30bdd66086
commit 18072f3b66
20 changed files with 109 additions and 75 deletions

View File

@@ -1,33 +1,33 @@
#include <Engine/Level/Scene.h>
bool Scene::EntityListContains(const Entity* entity) const {
bool Engine::Scene::EntityListContains(const Entity* entity) const {
for (auto* e : EntityList)
if (e == entity)
return true;
return false;
}
bool Scene::FixedListContains(const Fixed* fixed) const {
bool Engine::Scene::FixedListContains(const Fixed* fixed) const {
for (auto* f : FixedList)
if (f == fixed)
return true;
return false;
}
size_t Scene::FixedCount() const {
size_t Engine::Scene::FixedCount() const {
return FixedList.size();
}
size_t Scene::EntityCount() const {
size_t Engine::Scene::EntityCount() const {
return EntityList.size();
}
void Scene::Update() {
void Engine::Scene::Update() {
for (auto& e : EntityList)
e->Update();
}
void Scene::Render() {
void Engine::Scene::Render() {
for (auto& f : FixedList)
if (f->Enabled())
f->Render();
@@ -41,7 +41,7 @@ void Scene::Render() {
HeadsUpDisplay->Render();
}
Scene::~Scene() {
Engine::Scene::~Scene() {
for (auto* f : FixedList)
delete f;
@@ -51,7 +51,7 @@ Scene::~Scene() {
delete HeadsUpDisplay;
}
void Scene::Unload() {
void Engine::Scene::Unload() {
for (auto* f : FixedList)
delete f;
@@ -61,42 +61,42 @@ void Scene::Unload() {
delete HeadsUpDisplay;
}
void Scene::AppendEntity(Entity* entity) {
void Engine::Scene::AppendEntity(Entity* entity) {
if (!EntityListContains(entity))
EntityList.push_back(entity);
}
void Scene::AppendFixed(Fixed* fixed) {
void Engine::Scene::AppendFixed(Fixed* fixed) {
if (!FixedListContains(fixed))
FixedList.push_back(fixed);
}
void Scene::DestroyEntity(Entity *entity) {
void Engine::Scene::DestroyEntity(Entity *entity) {
auto it = std::find(EntityList.begin(), EntityList.end(), entity);
if (it != EntityList.end())
delete *it, EntityList.erase(it);
}
void Scene::DestroyFixed(Fixed* fixed) {
void Engine::Scene::DestroyFixed(Fixed* fixed) {
auto it = std::find(FixedList.begin(), FixedList.end(), fixed);
if (it != FixedList.end())
delete *it, FixedList.erase(it);
}
void Scene::RemoveEntity(Entity* entity) {
void Engine::Scene::RemoveEntity(Entity* entity) {
auto it = std::find(EntityList.begin(), EntityList.end(), entity);
if (it != EntityList.end())
EntityList.erase(it);
}
void Scene::RemoveFixed(Fixed* fixed) {
void Engine::Scene::RemoveFixed(Fixed* fixed) {
auto it = std::find(FixedList.begin(), FixedList.end(), fixed);
if (it != FixedList.end())
FixedList.erase(it);
}
std::string Scene::GetName() const {
std::string Engine::Scene::GetName() const {
return name;
}