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
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
VariablePropertyis provided, the property updates dynamically. - If an
AnimatedPropertyis 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 Summary
FieldsModifier and TypeFieldDescriptionprotected final AnimatedProperty<T> protected final VariableProperty<T> Fields inherited from class dev.prozilla.pine.common.property.VariableProperty
random -
Constructor Summary
ConstructorsConstructorDescriptionAdaptivePropertyBase(VariableProperty<T> variableProperty) Creates a new property with a dynamic value ifvariablePropertyis notnull, or a fixed value. -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks whether this property has an animated value.booleanChecks whether this property has a dynamic value.voidRestarts the animation of this property, if it is animated.voidupdateAnimation(float deltaTime) Updates the animation of this property, if it is animated.
-
Field Details
-
variableProperty
-
animatedProperty
-
-
Constructor Details
-
AdaptivePropertyBase
Creates a new property with a dynamic value ifvariablePropertyis notnull, 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:
restartAnimationin interfaceAnimatable
-
updateAnimation
public void updateAnimation(float deltaTime) Updates the animation of this property, if it is animated.- Specified by:
updateAnimationin interfaceAnimatable- 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.
-