Table of Contents

Class ClientAnimator

Namespace
Vintagestory.API.Common
Assembly
VintagestoryAPI.dll

Syncs every frame with entity.ActiveAnimationsByAnimCode, starts and stops animations when necessary and does recursive interpolation on the rotation, position and scale value for each frame, for each element and for each active element this produces always correctly blended animations but is significantly more costly for the cpu when compared to the technique used by the AnimatorBase.

public class ClientAnimator : AnimatorBase, IAnimator
Inheritance
ClientAnimator
Implements
Derived
Inherited Members
Extension Methods

Constructors

ClientAnimator(WalkSpeedSupplierDelegate, List<ElementPose>, Animation[], ShapeElement[], Dictionary<int, AnimationJoint>, Action<string>, Action<AnimationSound>)

public ClientAnimator(WalkSpeedSupplierDelegate walkSpeedSupplier, List<ElementPose> rootPoses, Animation[] animations, ShapeElement[] rootElements, Dictionary<int, AnimationJoint> jointsById, Action<string> onAnimationStoppedListener = null, Action<AnimationSound> onShouldPlaySoundListener = null)

Parameters

walkSpeedSupplier WalkSpeedSupplierDelegate
rootPoses List<ElementPose>
animations Animation[]
rootElements ShapeElement[]
jointsById Dictionary<int, AnimationJoint>
onAnimationStoppedListener Action<string>
onShouldPlaySoundListener Action<AnimationSound>

ClientAnimator(WalkSpeedSupplierDelegate, Animation[], Action<string>, Action<AnimationSound>)

public ClientAnimator(WalkSpeedSupplierDelegate walkSpeedSupplier, Animation[] animations, Action<string> onAnimationStoppedListener = null, Action<AnimationSound> onShouldPlaySoundListener = null)

Parameters

walkSpeedSupplier WalkSpeedSupplierDelegate
animations Animation[]
onAnimationStoppedListener Action<string>
onShouldPlaySoundListener Action<AnimationSound>

ClientAnimator(WalkSpeedSupplierDelegate, Animation[], ShapeElement[], Dictionary<int, AnimationJoint>, Action<string>, Action<AnimationSound>)

public ClientAnimator(WalkSpeedSupplierDelegate walkSpeedSupplier, Animation[] animations, ShapeElement[] rootElements, Dictionary<int, AnimationJoint> jointsById, Action<string> onAnimationStoppedListener = null, Action<AnimationSound> onShouldPlaySoundListener = null)

Parameters

walkSpeedSupplier WalkSpeedSupplierDelegate
animations Animation[]
rootElements ShapeElement[]
jointsById Dictionary<int, AnimationJoint>
onAnimationStoppedListener Action<string>
onShouldPlaySoundListener Action<AnimationSound>

Fields

MaxConcurrentAnimations

public static int MaxConcurrentAnimations

Field Value

int

jointsById

public Dictionary<int, AnimationJoint> jointsById

Field Value

Dictionary<int, AnimationJoint>

jointsDone

protected HashSet<int> jointsDone

Field Value

HashSet<int>

Properties

MaxJointId

public override int MaxJointId { get; }

Property Value

int

Methods

AnimNowActive(RunningAnimation, AnimationMetaData)

protected override void AnimNowActive(RunningAnimation anim, AnimationMetaData animData)

Parameters

anim RunningAnimation
animData AnimationMetaData

CreateForEntity(Entity, List<ElementPose>, Animation[], ShapeElement[], Dictionary<int, AnimationJoint>)

public static ClientAnimator CreateForEntity(Entity entity, List<ElementPose> rootPoses, Animation[] animations, ShapeElement[] rootElements, Dictionary<int, AnimationJoint> jointsById)

Parameters

entity Entity
rootPoses List<ElementPose>
animations Animation[]
rootElements ShapeElement[]
jointsById Dictionary<int, AnimationJoint>

Returns

ClientAnimator

CreateForEntity(Entity, Animation[], ShapeElement[], Dictionary<int, AnimationJoint>)

public static ClientAnimator CreateForEntity(Entity entity, Animation[] animations, ShapeElement[] rootElements, Dictionary<int, AnimationJoint> jointsById)

Parameters

entity Entity
animations Animation[]
rootElements ShapeElement[]
jointsById Dictionary<int, AnimationJoint>

Returns

ClientAnimator

DumpCurrentState()

public override string DumpCurrentState()

Returns

string

GetPosebyName(string, StringComparison)

public override ElementPose GetPosebyName(string name, StringComparison stringComparison = StringComparison.InvariantCultureIgnoreCase)

Parameters

name string
stringComparison StringComparison

Returns

ElementPose

LoadAttachmentPoints(List<ElementPose>)

protected virtual void LoadAttachmentPoints(List<ElementPose> cachedPoses)

Parameters

cachedPoses List<ElementPose>

LoadPosesAndAttachmentPoints(ShapeElement[], List<ElementPose>)

protected virtual void LoadPosesAndAttachmentPoints(ShapeElement[] elements, List<ElementPose> intoPoses)

Parameters

elements ShapeElement[]
intoPoses List<ElementPose>

OnFrame(Dictionary<string, AnimationMetaData>, float)

The event fired on each frame.

public override void OnFrame(Dictionary<string, AnimationMetaData> activeAnimationsByAnimCode, float dt)

Parameters

activeAnimationsByAnimCode Dictionary<string, AnimationMetaData>
dt float

ReloadAttachmentPoints()

public override void ReloadAttachmentPoints()

calculateMatrices(float)

protected override void calculateMatrices(float dt)

Parameters

dt float

initFields()

protected virtual void initFields()