Interface Attribute<T extends Number>

Type Parameters:
T - the numeric type of this attribute (e.g. Integer, Float, Double)
All Known Implementing Classes:
Acceleration, ActionPoints, Armor, Friction, Health, Mana, MaxActionSlots, MaxArmorSlots, MaxItemSlots, MaxSpeed, SimpleAttribute

public interface Attribute<T extends Number>
Represents a numeric attribute belonging to an entity or system component.

Attributes define a base numeric value and can be modified by one or more AttributeModifiers that alter the effective (final) value. Typical examples include attributes such as health, strength, speed, or defense.

Implementations of this interface are responsible for managing their modifier list, applying modifiers in order, and producing a computed getFinalValue().

  • Method Details

    • getBaseValue

      T getBaseValue()
      Returns the unmodified, base value of this attribute.
      Returns:
      the base numeric value
    • getFinalValue

      T getFinalValue()
      Returns the final, modified value of this attribute after applying all active AttributeModifiers.
      Returns:
      the computed final numeric value
    • addModifier

      void addModifier(AttributeModifier<T> modifier)
      Adds a modifier to this attribute.

      Modifiers are typically applied in insertion order unless otherwise handled by the implementation.

      Parameters:
      modifier - the modifier to add
    • removeModifier

      void removeModifier(AttributeModifier<T> modifier)
      Removes a modifier from this attribute.
      Parameters:
      modifier - the modifier to remove
    • moveModifier

      void moveModifier(AttributeModifier<T> modifier, int index)
      Moves an existing modifier to a new position in the modifier list.

      This can be used to control the order of modifier application.

      Parameters:
      modifier - the modifier to move
      index - the new index position for the modifier
    • getModifiersByType

      List<AttributeModifier<T>> getModifiersByType(Class<? extends AttributeModifier<T>> modifierClass)
      Returns all modifiers of the specified type that are currently applied to this attribute.
      Parameters:
      modifierClass - the modifier type to filter by
      Returns:
      a list of modifiers matching the given class