/** * Returns a component mapper for this type of components. * * @param <T> the class type of components * @param type the class of components this mapper uses * @param world the world that this component mapper should use * @return a new mapper */ @SuppressWarnings("unchecked") public static <T extends Component> BaseComponentMapper<T> getFor(Class<T> type, World world) { return world.getMapper(type); }
/** * Returns a component mapper for this type of components. * * @param <T> the class type of components * @param type the class of components this mapper uses * @param world the world that this component mapper should use * @return a new mapper */ @SuppressWarnings("unchecked") public static <T extends Component> BaseComponentMapper<T> getFor(Class<T> type, World world) { return world.getMapper(type); }
@SuppressWarnings("unchecked") private ComponentMapper<?> getComponentMapper(Field field) { Class<?> mapperType = cache.getGenericType(field); return world.getMapper((Class<? extends Component>) mapperType); }
@SuppressWarnings("unchecked") private ComponentMapper<?> getComponentMapper(Field field) { Class<?> mapperType = cache.getGenericType(field); return world.getMapper((Class<? extends Component>) mapperType); }
@SuppressWarnings("unchecked") public M( Class<? extends Component> type, World world) { this.mapper = (ComponentMapper<A>) world.getMapper(type); isMirrorable = ClassReflection.isAssignableFrom(net.mostlyoriginal.api.component.common.Mirrorable.class, type); }
@SuppressWarnings("unchecked") public M( Class<? extends Component> type, World world) { this.mapper = (ComponentMapper<A>) world.getMapper(type); isMirrorable = ClassReflection.isAssignableFrom(net.mostlyoriginal.api.component.common.Mirrorable.class, type); }
/** * 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; }
protected LinkSite(World world, ComponentType type, Field field, LinkPolicy.Policy defaultPolicy) { this.type = type; this.field = field; LinkPolicy.Policy policyOverride = LinkFactory.getPolicy(field); this.policy = (policyOverride != null) ? policyOverride : defaultPolicy; mapper = world.getMapper(type.getType()); activeEntityIds = world.getAspectSubscriptionManager().get(all()).getActiveEntityIds(); AspectSubscriptionManager subscriptions = world.getAspectSubscriptionManager(); subscription = subscriptions.get(all(type.getType())); subscription.addSubscriptionListener(this); }
protected LinkSite(World world, ComponentType type, Field field, LinkPolicy.Policy defaultPolicy) { this.type = type; this.field = field; LinkPolicy.Policy policyOverride = LinkFactory.getPolicy(field); this.policy = (policyOverride != null) ? policyOverride : defaultPolicy; mapper = world.getMapper(type.getType()); activeEntityIds = world.getAspectSubscriptionManager().get(all()).getActiveEntityIds(); AspectSubscriptionManager subscriptions = world.getAspectSubscriptionManager(); subscription = subscriptions.get(all(type.getType())); subscription.addSubscriptionListener(this); }