From c3ef23cb74f395884857f39a314583e41e4fa192 Mon Sep 17 00:00:00 2001 From: R00V Date: Sun, 29 Dec 2024 17:35:16 +0200 Subject: [PATCH] even more issues fixed --- .../src/main/java/com/iluwatar/Entity.java | 19 ------------------- .../main/java/com/iluwatar/GameSystem.java | 2 -- .../src/test/java/com/iluwatar/AppTest.java | 4 ++-- .../test/java/com/iluwatar/EntityTest.java | 10 ---------- 4 files changed, 2 insertions(+), 33 deletions(-) diff --git a/entity-component-system/src/main/java/com/iluwatar/Entity.java b/entity-component-system/src/main/java/com/iluwatar/Entity.java index c1427c86b350..fa1e2e60fba4 100644 --- a/entity-component-system/src/main/java/com/iluwatar/Entity.java +++ b/entity-component-system/src/main/java/com/iluwatar/Entity.java @@ -40,7 +40,6 @@ public class Entity { private boolean isEnabled; private TransformComponent transform; private Entity parent; - private GameSystem gameSystem; private List components; private List children; @@ -262,24 +261,6 @@ public void setIsEnabled(boolean isEnabled) { } } - /** - * Gets the game system this entity belongs to. - * - * @return the game system the entity is part of - */ - public GameSystem getGameSystem() { - return gameSystem; - } - - /** - * Sets the game system this entity belongs to. - * - * @param gameSystem the game system to set - */ - public void setGameSystem(GameSystem gameSystem) { - this.gameSystem = gameSystem; - } - /** * Gets the parent entity of this entity. * diff --git a/entity-component-system/src/main/java/com/iluwatar/GameSystem.java b/entity-component-system/src/main/java/com/iluwatar/GameSystem.java index c28a1aa395fa..2511b5ae4706 100644 --- a/entity-component-system/src/main/java/com/iluwatar/GameSystem.java +++ b/entity-component-system/src/main/java/com/iluwatar/GameSystem.java @@ -51,8 +51,6 @@ public GameSystem() { public void addEntity(Entity entity) { if (entity != null) { entities.add(entity); - entity.setGameSystem(this); - // Recursively add children entities for (Entity child : entity.getChildren()) { addEntity(child); diff --git a/entity-component-system/src/test/java/com/iluwatar/AppTest.java b/entity-component-system/src/test/java/com/iluwatar/AppTest.java index 3fd0adbed4e1..2f427bdf7783 100644 --- a/entity-component-system/src/test/java/com/iluwatar/AppTest.java +++ b/entity-component-system/src/test/java/com/iluwatar/AppTest.java @@ -106,9 +106,9 @@ void testFinalEntityStateAfterSimulation() { GameSystem gameSystem = new GameSystem(); gameSystem.addEntity(entity1); gameSystem.addEntity(entity2); - TransformComponent TestTransform = new TransformComponent(new float[]{5.0f, 0.0f, 0.0f}, + TransformComponent testTransform = new TransformComponent(new float[]{5.0f, 0.0f, 0.0f}, new float[]{0.0f, 45.0f, 0.0f}, new float[]{1.0f, 1.0f, 1.0f}); - entity1.setTransformComponent(TestTransform); + entity1.setTransformComponent(testTransform); for (int i = 0; i < 10; i++) { gameSystem.update(1.0f / 60.0f); diff --git a/entity-component-system/src/test/java/com/iluwatar/EntityTest.java b/entity-component-system/src/test/java/com/iluwatar/EntityTest.java index 9da954c11925..a8a0cc0ec546 100644 --- a/entity-component-system/src/test/java/com/iluwatar/EntityTest.java +++ b/entity-component-system/src/test/java/com/iluwatar/EntityTest.java @@ -154,16 +154,6 @@ void testSetIsEnabled() { assertTrue(entityChild.isEnabled(), "The entity child should be enabled after calling setIsEnabled(true)."); } - @Test - void testGetAndSetGameSystem() { - - GameSystem gameSystem = new GameSystem(); - Entity entity = new Entity("MyEntity"); - entity.setGameSystem(gameSystem); - - assertEquals(gameSystem, entity.getGameSystem(), "The game system should match the one set."); - } - @Test void testUpdate_whenEntityDisabled_shouldReturnImmediately() {