Table of Contents

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

TObject

The 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

steps Step[]

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

steps IList<StepAnimator<TObject>.Step>

The steps to play.

loop bool

Whether the steps should 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

random Random

The random instance to use for determining the time for each StepAnimator<TObject>.Step with differing MinTime and MaxTime to play for.

steps IList<StepAnimator<TObject>.Step>

The steps to play.

loop bool

Whether the steps should loop.

Fields

Loop

Whether this step animator is looping.

public readonly bool Loop

Field Value

bool

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

int

CurrentStepTime

The time into the CurrentStep.

public TimeSpan CurrentStepTime { get; }

Property Value

TimeSpan

CurrentStepTotalTime

The total time that the CurrentStep should play for.

public TimeSpan CurrentStepTotalTime { get; }

Property Value

TimeSpan

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

obj TObject

The 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

obj TObject

The object to animate, which is passed to all relevant events.

passed TimeSpan

The amount of time that has passed since the last time this method was called.

Returns

bool

Whether this step animator has finished playing.