package gameEngine.entites; import gameEngine.entites.gameComponents.GameComponent; import gameEngine.entites.gameComponents.Mesh; import java.util.ArrayList; import java.util.List; public class GameObject extends Entity { public final List<GameComponent> gameComponents = new ArrayList<>(); public GameObject(String id) { super(id); } public void addComponent(GameComponent component) { for (GameComponent existingComponent : gameComponents) { if (existingComponent.getClass().equals(component.getClass())) { System.out.println("Component already exists: " + component.getClass().getSimpleName()); return; } } this.gameComponents.add(component); System.out.println("Component added: " + component.getClass().getSimpleName()); } public void removeComponent(GameComponent component) { boolean removed = this.gameComponents.remove(component); if (removed) { System.out.println("Component removed: " + component.getClass().getSimpleName()); } else { System.out.println("Component not found: " + component.getClass().getSimpleName()); } } public void initComponents() { for (GameComponent component : gameComponents) { component.init(); } } public void updateComponents(boolean isEditorScene) { for (GameComponent component : gameComponents) { if (isEditorScene) { if (component instanceof Mesh) { component.update(); } } else { component.update(); } } } }