Interface ComponentAccessor<ECS_TYPE>

Type Parameters:
ECS_TYPE - The store type associated with this component accessor.
All Known Implementing Classes:
CommandBuffer, Store

public interface ComponentAccessor<ECS_TYPE>
Allows access to components in logic that might only have access to the CommandBuffer but not the Store and vice versa depending on from where it's called.
  • Method Details

    • getComponent

      @Nullable <T extends Component<ECS_TYPE>> T getComponent(@Nonnull Ref<ECS_TYPE> ref, @Nonnull ComponentType<ECS_TYPE,T> componentType)
      Fetches the component instance of the given type for the given entity reference.
      Type Parameters:
      T - The component class type.
      Parameters:
      ref - The entity reference that we are fetching the component for.
      componentType - The component type of the component.
      Returns:
      the component of the reference, or null if one doesn't exist.
    • ensureAndGetComponent

      @Nonnull <T extends Component<ECS_TYPE>> T ensureAndGetComponent(@Nonnull Ref<ECS_TYPE> ref, @Nonnull ComponentType<ECS_TYPE,T> componentType)
      Ensures and fetches the component instance of the given type for the given entity reference.
      Type Parameters:
      T - The component class type.
      Parameters:
      ref - The entity reference that we are fetching the component for.
      componentType - The component type of the component.
      Returns:
      the component of the reference.
    • getArchetype

      @Nonnull Archetype<ECS_TYPE> getArchetype(@Nonnull Ref<ECS_TYPE> ref)
      Fetches the archetype for the given entity reference.
      Parameters:
      ref - The entity Ref to fetch the archetype for.
      Returns:
      the Archetype of the given reference.
    • getResource

      @Nonnull <T extends Resource<ECS_TYPE>> T getResource(@Nonnull ResourceType<ECS_TYPE,T> resourceType)
      Fetches a resource from the given resource type.
      Type Parameters:
      T - The resource type.
      Parameters:
      resourceType - The resource type to fetch.
      Returns:
      the Resource of the given class type.
    • getExternalData

      @Nonnull ECS_TYPE getExternalData()
      Returns:
      the external data of this component accessor.
    • putComponent

      <T extends Component<ECS_TYPE>> void putComponent(@Nonnull Ref<ECS_TYPE> ref, @Nonnull ComponentType<ECS_TYPE,T> componentType, @Nonnull T component)
      Called to put the given component onto the given entity.
      Type Parameters:
      T - The component class type.
      Parameters:
      ref - The entity reference of the entity.
      componentType - The component type of the component being put.
      component - The component instance that is being put.
    • addComponent

      <T extends Component<ECS_TYPE>> void addComponent(@Nonnull Ref<ECS_TYPE> ref, @Nonnull ComponentType<ECS_TYPE,T> componentType, @Nonnull T component)
      Adds the given component to the given entity reference.
      Type Parameters:
      T - The component class type.
      Parameters:
      ref - The entity Ref that we are adding this component to.
      componentType - The type of the component.
      component - The component instance to be added.
    • addComponent

      <T extends Component<ECS_TYPE>> T addComponent(@Nonnull Ref<ECS_TYPE> ref, @Nonnull ComponentType<ECS_TYPE,T> componentType)
      Adds and returns the given component to the given entity reference.
      Type Parameters:
      T - The component class type.
      Parameters:
      ref - The entity Ref that we are adding this component to.
      componentType - The type of the component.
      Returns:
      the newly instantiated instance of the component.
    • addEntities

      Ref<ECS_TYPE>[] addEntities(@Nonnull Holder<ECS_TYPE>[] holders, @Nonnull AddReason reason)
      Adds the given entities to the store of this component accessor.
      Parameters:
      holders - The holders of the entities to add.
      reason - The reason that we are adding these entities.
      Returns:
      an array of entity Ref instances, representing the added entities.
    • addEntity

      @Nullable Ref<ECS_TYPE> addEntity(@Nonnull Holder<ECS_TYPE> holder, @Nonnull AddReason reason)
      Adds the given entity to the store of this component accessor.
      Parameters:
      holder - The holder of the entity to add.
      reason - The reason that we are adding this entity.
      Returns:
      the entity Ref of the added entity.
    • removeEntity

      @Nonnull Holder<ECS_TYPE> removeEntity(@Nonnull Ref<ECS_TYPE> ref, @Nonnull Holder<ECS_TYPE> holder, @Nonnull RemoveReason reason)
      Called to remove the given entity from the store of this component accessor.
      Parameters:
      ref - The entity reference of the entity being removed.
      holder - The holder of the entity being removed.
      reason - The reason that we are removing this entity.
      Returns:
      the holder of the removed entity.
    • removeComponent

      <T extends Component<ECS_TYPE>> void removeComponent(@Nonnull Ref<ECS_TYPE> ref, @Nonnull ComponentType<ECS_TYPE,T> componentType)
      Called to remove the component of the given type from the given entity.
      Type Parameters:
      T - The component type based on the store type.
      Parameters:
      ref - The entity reference of the entity that we are removing the component from.
      componentType - The component type of the component that we are removing.
    • tryRemoveComponent

      <T extends Component<ECS_TYPE>> void tryRemoveComponent(@Nonnull Ref<ECS_TYPE> ref, @Nonnull ComponentType<ECS_TYPE,T> componentType)
      Called to try to remove the component og the given type from the given entity.
      Type Parameters:
      T - The component type based on the store type.
      Parameters:
      ref - The entity reference of the entity that we are removing the component from.
      componentType - The component type of the component that we are removing.
    • invoke

      <Event extends EcsEvent> void invoke(@Nonnull Ref<ECS_TYPE> ref, @Nonnull Event param)
    • invoke

      <Event extends EcsEvent> void invoke(@Nonnull EntityEventType<ECS_TYPE,Event> systemType, @Nonnull Ref<ECS_TYPE> ref, @Nonnull Event param)
    • invoke

      <Event extends EcsEvent> void invoke(@Nonnull Holder<ECS_TYPE> holder, @Nonnull Event param)
    • invoke

      <Event extends EcsEvent> void invoke(@Nonnull EntityHolderEventType<ECS_TYPE,Event> systemType, @Nonnull Holder<ECS_TYPE> holder, @Nonnull Event param)
    • invoke

      <Event extends EcsEvent> void invoke(@Nonnull Event param)
    • invoke

      <Event extends EcsEvent> void invoke(@Nonnull WorldEventType<ECS_TYPE,Event> systemType, @Nonnull Event param)