Skip to content

Commit

Permalink
Fixing bug with some entity systems not cleaning up after themselves.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chukobyte committed Jan 9, 2022
1 parent 1f341b8 commit 71e1901
Show file tree
Hide file tree
Showing 13 changed files with 7 additions and 54 deletions.
2 changes: 1 addition & 1 deletion _version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "0.47.0"
"version": "0.47.1"
}
2 changes: 1 addition & 1 deletion src/core/ecs/system/entity_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class EntitySystem {
return enabled;
}

virtual void Initialize() = 0;
virtual void Initialize() {}

virtual void Enable() {
enabled = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ class AnimatedSpriteRenderingEntitySystem : public EntitySystem {
sceneManager = GD::GetContainer()->sceneManager;
enabled = true;
}
void Initialize() override {}
void Enable() override {}
void Disable() override {}

void OnEntityDestroyed(Entity entity) override {}

void Render() override {
if (IsEnabled()) {
Expand Down
7 changes: 1 addition & 6 deletions src/core/ecs/system/systems/collision_entity_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,10 @@ class CollisionEntitySystem : public EntitySystem {
}

void Initialize() override {
EntitySystem::Initialize();
colliderTexture = GD::GetContainer()->assetManager->GetTexture(BLANK_WHITE_TEXTURE_ASSET_ID);
}

void Enable() override {}

void Disable() override {}

void OnEntityDestroyed(Entity entity) override {}

void ProcessEntityCollisions(Entity sourceEntity, Vector2 offset = Vector2(0.0f, 0.0f)) {
collisionContext->ClearCollisionData();
std::vector<Entity> collidedEntities;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ class DirectionalLightRenderingEntitySystem : public EntitySystem {
componentManager = GD::GetContainer()->componentManager;
enabled = true;
}
void Initialize() override {}
void Enable() override {}
void Disable() override {}

void OnEntityDestroyed(Entity entity) override {}

void Render() override {
if (IsEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ class PointLightRenderingEntitySystem : public EntitySystem {
componentManager = GD::GetContainer()->componentManager;
enabled = true;
}
void Initialize() override {}
void Enable() override {}
void Disable() override {}

void OnEntityDestroyed(Entity entity) override {}

void Render() override {
if (IsEnabled()) {
Expand Down
5 changes: 1 addition & 4 deletions src/core/ecs/system/systems/script_entity_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,13 @@ class ScriptEntitySystem : public EntitySystem {
}

void Initialize() override {
EntitySystem::Initialize();
for (auto const &pair : scriptContexts) {
auto const &scriptContext = pair.second;
scriptContext->Initialize();
}
}

void Enable() override {}

void Disable() override {}

void OnEntityDestroyed(Entity entity) override {
EntitySystem::OnEntityDestroyed(entity);
assert(activeScriptContext != nullptr && "No active script context!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ class SpotLightRenderingEntitySystem : public EntitySystem {
componentManager = GD::GetContainer()->componentManager;
enabled = true;
}
void Initialize() override {}
void Enable() override {}
void Disable() override {}

void OnEntityDestroyed(Entity entity) override {}

void Render() override {
if (IsEnabled()) {
Expand Down
5 changes: 0 additions & 5 deletions src/core/ecs/system/systems/sprite_rendering_entity_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ class SpriteRenderingEntitySystem : public EntitySystem {
enabled = true;
}

void Initialize() override {}
void Enable() override {}
void Disable() override {}
void OnEntityDestroyed(Entity entity) override {}

void Render() override {
if (IsEnabled()) {
for (Entity entity : entities) {
Expand Down
8 changes: 1 addition & 7 deletions src/core/ecs/system/systems/text_rendering_entity_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,13 @@ class TextRenderingEntitySystem : public EntitySystem {
enabled = true;
}

void Initialize() override {}
void Enable() override {}
void Disable() override {}

void OnRegisterEntity(Entity entity) override {
EntitySystem::OnRegisterEntity(entity);
UpdateEntityText(entity, componentManager->GetComponent<TextLabelComponent>(entity));
}
void OnUnRegisterEntity(Entity entity) override {
EntitySystem::OnUnRegisterEntity(entity);
}

void OnEntityDestroyed(Entity entity) override {
EntitySystem::OnEntityDestroyed(entity);
textLines.erase(entity);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ class TextureCubeRenderingEntitySystem : public EntitySystem {
componentManager = GD::GetContainer()->componentManager;
enabled = true;
}
void Initialize() override {}
void Enable() override {}
void Disable() override {}

void OnEntityDestroyed(Entity entity) override {}

void Render() override {
if (IsEnabled()) {
Expand Down
6 changes: 2 additions & 4 deletions src/core/ecs/system/systems/timer_entity_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ class TimerEntitySystem : public EntitySystem {
}

void Initialize() override {
EntitySystem::Initialize();
timerManager->Initialize();
}

void Enable() override {}

void Disable() override {}

void OnEntityDestroyed(Entity entity) override {
EntitySystem::OnEntityDestroyed(entity);
timerManager->RemoveTimer(entity);
}

Expand Down
1 change: 0 additions & 1 deletion src/core/scripting/python/python_modules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,6 @@ PyObject* PythonModules::sprite_set_draw_source(PyObject *self, PyObject *args,
SpriteComponent spriteComponent = entityComponentOrchestrator->GetComponent<SpriteComponent>(entity);
spriteComponent.drawSource = Rect2(x, y, w, h);
entityComponentOrchestrator->UpdateComponent<SpriteComponent>(entity, spriteComponent);
Logger::GetInstance()->Debug("sprite draw source");
Py_RETURN_NONE;
}
return nullptr;
Expand Down

0 comments on commit 71e1901

Please sign in to comment.