/** * Add a singleton component to the manager and the world. * * @param component Component to add. * @return Entity the component is attached to. */ public Entity addSingletonComponent(Component component) { // ensure that we have a proper mapper for the component so that we can // retrieve it later. Class<? extends Component> componentClass = component.getClass(); if (!mappers.containsKey(componentClass)) { mappers.put(componentClass, world.getMapper(componentClass)); } singletonEntity.addComponent(component); return singletonEntity; }