Class StepAnimator<TObject>
- Namespace
- MLEM.Animations
- Assembly
- MLEM.dll
A step animator is a simple class to facilitate multi-step, timed, and optionally looping "animations" in the form of event callbacks. A step animator supports multiple Steps which are executed in order in Update(TObject, TimeSpan).
public class StepAnimator<TObject> : GenericDataHolder, IGenericDataHolder
Type Parameters
TObjectThe object to animate, which is passed to all relevant events.
- Inheritance
-
StepAnimator<TObject>
- Implements
- Derived
- Inherited Members
Constructors
StepAnimator(params Step[])
Creates a new step animator with the given settings.
public StepAnimator(params StepAnimator<TObject>.Step[] steps)
Parameters
stepsStep[]The steps to play.
StepAnimator(IList<Step>, bool)
Creates a new step animator with the given settings.
public StepAnimator(IList<StepAnimator<TObject>.Step> steps, bool loop = false)
Parameters
stepsIList<StepAnimator<TObject>.Step>The steps to play.
loopboolWhether the
stepsshould loop.
StepAnimator(Random, IList<Step>, bool)
Creates a new step animator with the given settings.
public StepAnimator(Random random, IList<StepAnimator<TObject>.Step> steps, bool loop = false)
Parameters
randomRandomThe random instance to use for determining the time for each StepAnimator<TObject>.Step with differing MinTime and MaxTime to play for.
stepsIList<StepAnimator<TObject>.Step>The steps to play.
loopboolWhether the
stepsshould loop.
Fields
Loop
Whether this step animator is looping.
public readonly bool Loop
Field Value
Steps
This step animator's steps.
public readonly ReadOnlyCollection<StepAnimator<TObject>.Step> Steps
Field Value
- ReadOnlyCollection<StepAnimator<TObject>.Step>
Properties
CurrentStep
The currently executed step, or null if the animator has not started yet or is finished.
public StepAnimator<TObject>.Step CurrentStep { get; }
Property Value
- StepAnimator<TObject>.Step
CurrentStepIndex
The index of the CurrentStep in the Steps collection. This is -1 if the animator has not started yet or is finished.
public int CurrentStepIndex { get; }
Property Value
CurrentStepTime
The time into the CurrentStep.
public TimeSpan CurrentStepTime { get; }
Property Value
CurrentStepTotalTime
The total time that the CurrentStep should play for.
public TimeSpan CurrentStepTotalTime { get; }
Property Value
Methods
Reset(TObject)
Resets this step animator, returning back to the first StepAnimator<TObject>.Step in its Steps collection.
public void Reset(TObject obj)
Parameters
objTObjectThe object to animate, which is passed to all relevant events.
Update(TObject, TimeSpan)
Updates this step animator, starting, updating and finishing its Steps. If this method returns true, this step animator has finished playing (which will never occur if there are any steps and Loop is true).
public bool Update(TObject obj, TimeSpan passed)
Parameters
objTObjectThe object to animate, which is passed to all relevant events.
passedTimeSpanThe amount of time that has passed since the last time this method was called.
Returns
- bool
Whether this step animator has finished playing.