Class ItemProperty<T extends ItemPropertyValue>

java.lang.Object
group24.escaperoom.entities.properties.ItemProperty<T>
All Implemented Interfaces:
com.badlogic.gdx.utils.Json.Serializable
Direct Known Subclasses:
BooleanProperty, ConditionalProperty, ContainsItemProperty, LockedProperty, PhantomProperty, ReadableProperty, Stylable, ViewableProperty

public abstract class ItemProperty<T extends ItemPropertyValue> extends Object implements com.badlogic.gdx.utils.Json.Serializable
  • Field Details

    • owner

      protected Item owner
  • Constructor Details

    • ItemProperty

      public ItemProperty()
  • Method Details

    • setOwner

      public void setOwner(Item i)
    • getOwner

      public Item getOwner()
    • getValueClass

      public abstract Class<T> getValueClass()
      Returns:
      the class of the ItemPropertyValue for this property
    • getPotentialValues

      public abstract com.badlogic.gdx.utils.Array<T> getPotentialValues()
      Returns:
      all possible values for this property
    • getDisplayName

      public abstract String getDisplayName()
      Returns:
      name of this property, used as a display string in menus
    • defaultConfiguration

      public void defaultConfiguration(Item owner)
      Parameters:
      owner - create a default configuration of this property for the given owner
    • apply

      public void apply(Item owner)
      Parameters:
      owner - apply this property to this item
    • getDescription

      public abstract PropertyDescription getDescription()
      Returns:
      the PropertyDescription of this Property
    • getType

      public abstract PropertyType getType()
      Returns:
      PropertyType of this property. This allows us to get the property of an item from it's property map
      See Also:
    • set

      public void set(com.badlogic.gdx.utils.Array<T> values)
      Set the value of this property to value It is the responsibility of the caller to only pass values that are recieved from getPotentialValues()
      Parameters:
      values - to set
    • set

      public void set(T value)
      Set the value of this property to value It is the responsibility of the caller to only pass values that are recieved from getPotentialValues()
      Parameters:
      value - to set
    • unsafeSet

      public void unsafeSet(com.badlogic.gdx.utils.Array<ItemPropertyValue> value)
      Unsafely set this item. This should only be used when the compile time class of the expected property type cannot be determined. The caller must ensure that the value class is the same as getValueClass()
      Parameters:
      value - to set
    • unsafeSet

      public void unsafeSet(ItemPropertyValue value)
      Unsafely set this item This should only be used when the compile time class of the expected property class cannot be determined. The caller must ensure that the value class is the same as getValueClass()
      Parameters:
      value - to set
    • getInputType

      public abstract ItemProperty.MenuType getInputType()
      Returns:
      the ItemProperty.MenuType that should be used to recieve and display the ItemPropertyValue associated with this property - adding a new input type requires updating ItemMenu to support it
    • getPopOut

      public <CC extends com.badlogic.gdx.scenes.scene2d.Actor & ConfigurationMenu.HandlesMenuClose> ConfigurationMenu<CC> getPopOut(Menu.MenuEntry parent)
      If this property specifies ItemProperty.MenuType.PopOut This function will be called to get the Menu which should be displayed when this property is selected.
      Type Parameters:
      CC - the ConfigurationMenu requires an actor type implementing ConfigurationMenu.HandlesMenuClose
      Parameters:
      parent - Menu.MenuEntry spawning this menu
      Returns:
      the menu to display
    • getCustomItemConfigurationMenu

      public Optional<PropertyConfiguration> getCustomItemConfigurationMenu()
      Get a PropertyConfiguration that contains all fields necessary to configure this property in the ItemEditor
      Returns:
      Some(PropertyConfiguration) should this property need configuration
    • getCurrentValues

      public com.badlogic.gdx.utils.Array<T> getCurrentValues()
      Returns:
      an array containing the current values of this property
    • getCurrentValue

      public T getCurrentValue()
      Returns:
      the current value of this property
    • getAvailableActions

      protected abstract com.badlogic.gdx.utils.Array<PlayerAction> getAvailableActions()
      Returns:
      all available PlayerAction
    • getActions

      public com.badlogic.gdx.utils.Array<PlayerAction> getActions(GameContext ctx)
    • cloneProperty

      public ItemProperty<? extends ItemPropertyValue> cloneProperty(Item newOwner)
      Parameters:
      newOwner - the new owner of this property
      Returns:
      a clone of this item property (along with state and values) for a new item
    • updateTexture

      public void updateTexture()
      Updates the owner's texture based on the property. Properties which do not change the texture should not override this function. Typically used when reloading textures on already placed items.