Class AttributeModifier<T extends Number>

java.lang.Object
de.gurkenlabs.litiengine.attributes.AttributeModifier<T>
Type Parameters:
T - the generic type
All Implemented Interfaces:
Comparable<AttributeModifier<T>>

public class AttributeModifier<T extends Number> extends Object implements Comparable<AttributeModifier<T>>
An attribute modifier allows to modify attributes by the specified Modification and modify value.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    AttributeModifier(Modification mod, double modifyValue)
    Initializes a new instance of the AttributeModifier class.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    compareTo(AttributeModifier<T> otherModifier)
    Compares this attribute modifier to another based on the apply order of their modifications.
    boolean
    Checks if this attribute modifier is equal to another object.
    Gets the modification type applied by this modifier.
    double
    Gets the value that is used to modify an attribute.
    int
    Generates a hash code for this attribute modifier.
    boolean
    Checks if this attribute modifier is active.
    modify(T modvalue)
    Modifies the provided value based on the modification type and modify value of this attribute modifier.
    void
    setActive(boolean active)
    Sets the active status of this attribute modifier.
    void
    setModifyValue(double value)
    Sets the modify value for this attribute modifier.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AttributeModifier

      public AttributeModifier(Modification mod, double modifyValue)
      Initializes a new instance of the AttributeModifier class.
      Parameters:
      mod - The modification type.
      modifyValue - The modification value to be applied by this instance.
  • Method Details

    • compareTo

      public int compareTo(AttributeModifier<T> otherModifier)
      Compares this attribute modifier to another based on the apply order of their modifications.
      Specified by:
      compareTo in interface Comparable<T extends Number>
      Parameters:
      otherModifier - The other attribute modifier to compare.
      Returns:
      An integer representing the comparison result.
    • equals

      public boolean equals(Object obj)
      Checks if this attribute modifier is equal to another object.
      Overrides:
      equals in class Object
      Parameters:
      obj - The object to compare with.
      Returns:
      True if the objects are equal, false otherwise.
    • hashCode

      public int hashCode()
      Generates a hash code for this attribute modifier.
      Overrides:
      hashCode in class Object
      Returns:
      The hash code.
    • getModification

      public Modification getModification()
      Gets the modification type applied by this modifier.
      Returns:
      The modification type applied by this modifier.
    • getModifyValue

      public double getModifyValue()
      Gets the value that is used to modify an attribute.
      Returns:
      The value that is used to modify an attribute.
    • isActive

      public boolean isActive()
      Checks if this attribute modifier is active.
      Returns:
      True if active, false otherwise.
    • modify

      public T modify(T modvalue)
      Modifies the provided value based on the modification type and modify value of this attribute modifier.
      Parameters:
      modvalue - The original value to be modified.
      Returns:
      The modified value.
    • setModifyValue

      public void setModifyValue(double value)
      Sets the modify value for this attribute modifier.
      Parameters:
      value - The new modify value.
    • setActive

      public void setActive(boolean active)
      Sets the active status of this attribute modifier.
      Parameters:
      active - True to activate, false to deactivate.