Interface Attribute<T extends Number>
- 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 Summary
Modifier and TypeMethodDescriptionvoidaddModifier(AttributeModifier<T> modifier) Adds a modifier to this attribute.Returns the unmodified, base value of this attribute.Returns the final, modified value of this attribute after applying all activeAttributeModifiers.getModifiersByType(Class<? extends AttributeModifier<T>> modifierClass) Returns all modifiers of the specified type that are currently applied to this attribute.voidmoveModifier(AttributeModifier<T> modifier, int index) Moves an existing modifier to a new position in the modifier list.voidremoveModifier(AttributeModifier<T> modifier) Removes a modifier from this attribute.
-
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 activeAttributeModifiers.- Returns:
- the computed final numeric value
-
addModifier
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
Removes a modifier from this attribute.- Parameters:
modifier- the modifier to remove
-
moveModifier
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 moveindex- the new index position for the modifier
-
getModifiersByType
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
-