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
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 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 ifvariableProperty
is notnull
, or a fixed value. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks whether this property has an animated value.boolean
Checks whether this property has a dynamic value.void
Restarts the animation of this property, if it is animated.void
updateAnimation
(float deltaTime) Updates the animation of this property, if it is animated.Methods inherited from class dev.prozilla.pine.common.property.VariableProperty
getValue
-
Field Details
-
variableProperty
-
animatedProperty
-
-
Constructor Details
-
AdaptivePropertyBase
Creates a new property with a dynamic value ifvariableProperty
is 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:
restartAnimation
in interfaceAnimatable
-
updateAnimation
public void updateAnimation(float deltaTime) Updates the animation of this property, if it is animated.- Specified by:
updateAnimation
in 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.
-