Class ViewCache

java.lang.Object
technology.sola.ecs.cache.ViewCache

@NullMarked public class ViewCache extends Object
The ViewCache classes handles caching and updating ViewImpl instances when Entity modifications are made in a World.
  • Constructor Details

    • ViewCache

      public ViewCache(World world)
      Creates a ViewCache instance for a World
      Parameters:
      world - the World instance
  • Method Details

    • createView

      public <C1 extends Component> View1<C1> createView(Class<C1> c1Class)
      Gets a View1 for the desired component class from the cache or creates it if it does not exist.
      Type Parameters:
      C1 - the component type
      Parameters:
      c1Class - the Component class
      Returns:
      the View1
    • createView

      public <C1 extends Component, C2 extends Component> View2<C1,C2> createView(Class<C1> c1Class, Class<C2> c2Class)
      Gets a View2 for the desired component classes from the cache or creates it if it does not exist.
      Type Parameters:
      C1 - the first component type
      C2 - the second component type
      Parameters:
      c1Class - the first Component class
      c2Class - the second Component class
      Returns:
      the View2
    • createView

      public <C1 extends Component, C2 extends Component, C3 extends Component> View3<C1,C2,C3> createView(Class<C1> c1Class, Class<C2> c2Class, Class<C3> c3Class)
      Gets a View3 for the desired component classes from the cache or creates it if it does not exist.
      Type Parameters:
      C1 - the first component type
      C2 - the second component type
      C3 - the third component type
      Parameters:
      c1Class - the first Component class
      c2Class - the second Component class
      c3Class - the third Component class
      Returns:
      the View3
    • createView

      public <C1 extends Component, C2 extends Component, C3 extends Component, C4 extends Component> View4<C1,C2,C3,C4> createView(Class<C1> c1Class, Class<C2> c2Class, Class<C3> c3Class, Class<C4> c4Class)
      Gets a View4 for the desired component classes from the cache or creates it if it does not exist.
      Type Parameters:
      C1 - the first component type
      C2 - the second component type
      C3 - the third component type
      C4 - the fourth component type
      Parameters:
      c1Class - the first Component class
      c2Class - the second Component class
      c3Class - the third Component class
      c4Class - the fourth Component class
      Returns:
      the View4
    • createView

      @SafeVarargs public final ViewN createView(Class<? extends Component>... componentClasses)
      Gets a ViewN for the desired component classes from the cache or creates it if it does not exist.
      Parameters:
      componentClasses - the component classes for the view
      Returns:
      the ViewN
    • destroyView

      public void destroyView(Class<? extends Component>[] componentClasses)
      Destroys a view from the cache so that it no longer will receive any updates.
      Parameters:
      componentClasses - the component classes for the view
    • updateForAddComponent

      public void updateForAddComponent(Entity entity, Class<? extends Component> componentClass)
      Updates cached ViewImpls for an Entity's added Component.
      Parameters:
      entity - the Entity updated
      componentClass - the class of the Component added to the entity
    • updateForRemoveComponent

      public void updateForRemoveComponent(Entity entity, Class<? extends Component> componentClass)
      Updates cached ViewImpls for an Entity's removed Component.
      Parameters:
      entity - the Entity updated
      componentClass - the class of the Component removed from the entity
    • updateForDisabledStateChange

      public void updateForDisabledStateChange(Entity entity)
      Updates cached ViewImpls for an Entity that was disabled or enabled.
      Parameters:
      entity - the Entity update
    • updateForDeletedEntity

      public void updateForDeletedEntity(Entity entity)
      Updates cached ViewImpls for a deleted Entity.
      Parameters:
      entity - the Entity deleted