Class AdaptivePropertyBase<T>

java.lang.Object
dev.prozilla.pine.common.property.VariableProperty<T>
dev.prozilla.pine.common.property.adaptive.AdaptivePropertyBase<T>
All Implemented Interfaces:
Animatable
Direct Known Subclasses:
AdaptiveFloatProperty, AdaptiveIntProperty, AdaptiveProperty

public abstract class AdaptivePropertyBase<T> extends VariableProperty<T> implements Animatable
Base class for an optimized property that can either have a fixed value or be dynamically changed by a VariableProperty.

This class provides a more efficient alternative to using VariableProperty exclusively, allowing for fixed values when dynamic behavior is unnecessary.

  • If a VariableProperty is provided, the property updates dynamically.
  • If an AnimatedProperty is provided, the property will be updated each frame by the animation.
  • If neither is provided, the property remains fixed.

Certain implementations store fixed values as primitives to optimize performance and avoid unnecessary (un)boxing.

  • Field Details

  • Constructor Details

    • AdaptivePropertyBase

      public AdaptivePropertyBase(VariableProperty<T> variableProperty)
      Creates a new property with a dynamic value if variableProperty is not null, or a fixed value.
      Parameters:
      variableProperty - Variable property that determines the value of this property
  • Method Details

    • restartAnimation

      public void restartAnimation()
      Restarts the animation of this property, if it is animated.
      Specified by:
      restartAnimation in interface Animatable
    • updateAnimation

      public void updateAnimation(float deltaTime)
      Updates the animation of this property, if it is animated.
      Specified by:
      updateAnimation in interface Animatable
      Parameters:
      deltaTime - Time between this frame and the last one, in seconds.
    • isDynamic

      public boolean isDynamic()
      Checks whether this property has a dynamic value.
    • isAnimated

      public boolean isAnimated()
      Checks whether this property has an animated value.