public final void removeComponent(final Component _component) { _component.setParent(null); // Required by j2Objc conversion, causes memory-leak otherwise components.remove(_component); final EventController controller = _component.getComponentEventController(); eventSystem.removeEventHandler(controller); }
/** * Once clear() is called, the Entity it is pretty much dead, it's lost all of its components and * the ComponentEventSystem is nulled out. */ public void clear() { final ArrayList<Component> comps = new ArrayList<Component>(components); removeComponents(comps); comps.clear(); eventSystem.clearHandlers(); }
/** Update the message system of the Entity and update the Components */ public final void update(final float _dt) { eventSystem.update(); // Update Components final int size = components.size(); for (int i = 0; i < size; ++i) { components.get(i).update(_dt); } }
/** * Add a component to the Entity and set its parent to the Entity The Component should not be * owned by another Component, it could get messy! */ public final void addComponent(final Component _component) { _component.setParent(this); components.add(_component); final EventController controller = _component.getComponentEventController(); controller.setAddEventInterface(eventSystem); eventSystem.addEventHandler(controller); }