java.lang.Object
group24.escaperoom.entities.properties.conditionals.Conditional
All Implemented Interfaces:
com.badlogic.gdx.utils.Json.Serializable, ItemPropertyValue
Direct Known Subclasses:
AlwaysActive, BinaryConditional, EmptyConditional, ItemContainsItem, ItemInArea, KaryConditional, PlayerHasItem, PlayerInTiles, RequiresItems, UnaryConditional

public abstract class Conditional extends Object implements com.badlogic.gdx.utils.Json.Serializable, ItemPropertyValue
  • Constructor Details

    • Conditional

      public Conditional()
  • Method Details

    • evaluate

      public abstract boolean evaluate(GameContext ctx)
      Parameters:
      ctx - the GameContext which should be used to evaluate this Conditional
      Returns:
      whether or not this Conditional is true
    • getType

      public abstract ConditionalType getType()
      Returns:
      the type of this conditional
    • getName

      public abstract String getName()
      Returns:
      the name of this Conditional
    • requiresPoll

      public boolean requiresPoll()
      Returns:
      whether or not this Conditional requires polling
    • poll

      public boolean poll(GameContext ctx)
      Given the game context, return whether or not this conditional needs to be polled. It must be valid to poll the conditional even after this function returns false
      Parameters:
      ctx - the game context
      Returns:
      whether or not this conditional still needs to be polled
    • childCount

      public Optional<Integer> childCount()
      Whether or not to limit the number of children below this conditional By default assumes the condition can have no children
      Returns:
      Some(count) if this conditional has a limit to the number of children
    • clone

      public Conditional clone()
      Overrides:
      clone in class Object
    • getChildren

      public com.badlogic.gdx.utils.Array<Conditional> getChildren()
      Returns an array of this conditional dependents, if they have any. The array will be the same length as childCount()
      Returns:
      an array of conditionals which this conditional depends on
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • setChildren

      public void setChildren(Conditional... conds)
      Parameters:
      conds - the Conditionals to set
    • getDisplay

      public Menu.MenuEntry getDisplay(Menu parent)
      Conditionals are not represented in Menus
      Specified by:
      getDisplay in interface ItemPropertyValue
      Parameters:
      parent - the menu spawning this entry
      Returns:
      the Menu.MenuEntry describing this ItemPropertyValue
    • getEditorConfiguration

      public abstract <CC extends com.badlogic.gdx.scenes.scene2d.Actor & ConfigurationMenu.HandlesMenuClose> Optional<CC> getEditorConfiguration(LevelEditorScreen editor)
      Primarily used in the ConditionalUI
      Type Parameters:
      CC - an actor type implenting ConfigurationMenu.HandlesMenuClose should this be uncessary, use SimpleUI
      Parameters:
      editor - the LevelEditorScreen on which this menu will be spawned
      Returns:
      Some(CC) should this Conditional require additional configuration.