Class ViewImpl<E extends ViewEntry>

java.lang.Object
technology.sola.ecs.cache.ViewImpl<E>
Type Parameters:
E - the ViewEntry implementation
All Implemented Interfaces:
View<E>
Direct Known Subclasses:
View1, View2, View3, View4, ViewN

@NullMarked public abstract class ViewImpl<E extends ViewEntry> extends Object implements View<E>
The View class is a container of ViewEntry that are updated whenever a World updates an Entity's components that now satisfies or no longer satisfies the List of watched Components.
  • Field Details

    • componentClasses

      protected final List<Class<? extends Component>> componentClasses
      The component classes for the view.
  • Constructor Details

    • ViewImpl

      public ViewImpl(List<Class<? extends Component>> componentClasses)
      Creates a new view watching desired components.
      Parameters:
      componentClasses - the Component classes to watch
  • Method Details

    • getEntries

      public Collection<E> getEntries()
      Specified by:
      getEntries in interface View<E extends ViewEntry>
      Returns:
      the List of ViewEntry in this View
    • isWatchingComponent

      public boolean isWatchingComponent(Class<? extends Component> componentClassToCheck)
      Checks if this view responds to an Entity adding or removing the component type or if an entity is deleted while having the component type.
      Specified by:
      isWatchingComponent in interface View<E extends ViewEntry>
      Parameters:
      componentClassToCheck - the Component class to check
      Returns:
      true if view will update
    • createEntryFromEntity

      protected abstract @Nullable E createEntryFromEntity(Entity entity)
      Creates an ViewEntry from a Entity.
      Parameters:
      entity - the Entity to create a ViewEntry from
      Returns:
      the ViewEntry