Table of Contents

Class Motion<TArgs>

Namespace
TrinketTinker.Companions.Motions
Assembly
TrinketTinker.dll

Abstract class, controls drawing and movement of companion

public abstract class Motion<TArgs> : IMotion where TArgs : IArgs

Type Parameters

TArgs
Inheritance
Motion<TArgs>
Implements
Derived
Inherited Members

Constructors

Motion(TrinketTinkerCompanion, MotionData, VariantData)

Basic constructor, tries to parse arguments as the generic IArgs type.

public Motion(TrinketTinkerCompanion companion, MotionData mdata, VariantData vdata)

Parameters

companion TrinketTinkerCompanion
mdata MotionData
vdata VariantData

Fields

PauseMovementByAnimClip

An anim clip that pauses movement is currently playing.

public bool PauseMovementByAnimClip

Field Value

bool

c

Companion that owns this motion.

protected readonly TrinketTinkerCompanion c

Field Value

TrinketTinkerCompanion

cs

Companion animation controller

protected TinkerAnimSprite cs

Field Value

TinkerAnimSprite

currAnchorTarget

The current anchor target, is sync'd by CurrAnchorTarget

protected AnchorTarget currAnchorTarget

Field Value

AnchorTarget

framesetLength

Number of frames in 1 set, used for Repeat and SerpentMotion

protected int framesetLength

Field Value

int

lightId

Light source ID, generated if LightRadius is set in MotionData.

protected string lightId

Field Value

string

md

Data for this motion.

protected MotionData md

Field Value

MotionData

prevAnchorTarget

The previous anchor target

protected AnchorTarget prevAnchorTarget

Field Value

AnchorTarget

vd

Data for this motion.

protected VariantData vd

Field Value

VariantData

Properties

AnchorChanged

Anchor changed during this tick

protected bool AnchorChanged { get; }

Property Value

bool

BoundingBox

Bounding box of trinket

public Rectangle BoundingBox { get; }

Property Value

Rectangle

CompanionAnimSprite

Current variant data

public TinkerAnimSprite CompanionAnimSprite { get; }

Property Value

TinkerAnimSprite

MotionClass

Type name of the motion, can use short form like "Hover" for hover motion.

public string MotionClass { get; }

Property Value

string

NetRand

Clip random

public Random NetRand { get; set; }

Property Value

Random

Speaker

Current variant data

public ChatterSpeaker Speaker { get; }

Property Value

ChatterSpeaker

TotalFrames

Actual total frame used for Repeat, equal to frame length

protected virtual int TotalFrames { get; }

Property Value

int

Methods

Cleanup()

Cleanup motion, remove light source.

public virtual void Cleanup()

DirectionFrameStart()

First frame of animation, depending on direction.

protected virtual int DirectionFrameStart()

Returns

int

Frame number

Draw(SpriteBatch)

Draws the companion, for all game instances in multiplayer.

public void Draw(SpriteBatch b)

Parameters

b SpriteBatch

DrawCompanion(SpriteBatch, DrawSnapshot)

Draw companion from snapshot, enqueue repeat as required

protected virtual void DrawCompanion(SpriteBatch b, DrawSnapshot snapshot)

Parameters

b SpriteBatch
snapshot DrawSnapshot

DrawCompanionBreathing(SpriteBatch, DrawSnapshot)

Draw companion breathing from snapshot, enqueue repeat as required

protected virtual void DrawCompanionBreathing(SpriteBatch b, DrawSnapshot snapshot)

Parameters

b SpriteBatch
snapshot DrawSnapshot

DrawShadow(SpriteBatch, DrawSnapshot)

Draw shadow from snapshot, enqueue repeat as required

protected virtual void DrawShadow(SpriteBatch b, DrawSnapshot snapshot)

Parameters

b SpriteBatch
snapshot DrawSnapshot

EnqueueRepeatDraws(DrawSnapshot, bool)

Queue up repeats of the current draw.

protected void EnqueueRepeatDraws(DrawSnapshot snapshot, bool isShadow)

Parameters

snapshot DrawSnapshot
isShadow bool

GetDrawLayer()

Get draw layer of motion

public virtual float GetDrawLayer()

Returns

float

offset

GetOffset()

Get offset

public virtual Vector2 GetOffset()

Returns

Vector2

GetPositionalLayerDepth(Vector2)

Get layer depth based on position

protected virtual float GetPositionalLayerDepth(Vector2 offset)

Parameters

offset Vector2

Returns

float

GetRotation()

Get sprite rotation

protected virtual float GetRotation()

Returns

float

Rotation in radians

GetShadowOffset(Vector2)

Get shadow offset, default same as offset but with no Y

public virtual Vector2 GetShadowOffset(Vector2 offset)

Parameters

offset Vector2

Returns

Vector2

GetShadowScale()

Get shadow draw scale.

protected virtual Vector2 GetShadowScale()

Returns

Vector2

GetTextureScale()

Get texture draw scale.

protected virtual Vector2 GetTextureScale()

Returns

Vector2

Initialize(Farmer)

Initialize motion, setup light source if needed.

public virtual void Initialize(Farmer farmer)

Parameters

farmer Farmer

IsFacing(Vector2)

Check is facing

public virtual bool IsFacing(Vector2 target)

Parameters

target Vector2

Returns

bool

IsMoving()

Moving flag used for basis of anim

protected abstract bool IsMoving()

Returns

bool

OnOwnerWarp()

Update light source when owner changes location

public virtual void OnOwnerWarp()

SetActiveAnchors(IEnumerable<string>)

Rebuild the list of active anchors.

public void SetActiveAnchors(IEnumerable<string> abilityTypes)

Parameters

abilityTypes IEnumerable<string>

SetAltVariant(string?, Trinket?)

Set an alt variant.

public void SetAltVariant(string? altVariantKey, Trinket? trinketItem)

Parameters

altVariantKey string
trinketItem Trinket

SetCurrAnchorTarget(int)

Sync curr anchor target value

public void SetCurrAnchorTarget(int val)

Parameters

val int

SetMotionVariantData(MotionData, VariantData)

Update motion and variant data, when invalidate

public virtual void SetMotionVariantData(MotionData mdata, VariantData vdata)

Parameters

mdata MotionData
vdata VariantData

SetOneshotClip(string?)

Set an oneshot clip, to play once until end

public void SetOneshotClip(string? clipKey)

Parameters

clipKey string

SetOverrideClip(string?)

Set an override clip, to play instead of normal directional animation

public void SetOverrideClip(string? clipKey)

Parameters

clipKey string

SetSpeechBubble(string?)

Set a speech bubble to call, usually on ability proc.

public void SetSpeechBubble(string? speechBubbleKey)

Parameters

speechBubbleKey string

ShouldMove()

Whether the companion should attempt to move this frame

protected virtual bool ShouldMove()

Returns

bool

UpdateAnchor(GameTime, GameLocation)

Changes the position of the anchor that the companion moves relative to, based on Anchors.

public virtual AnchorTarget UpdateAnchor(GameTime time, GameLocation location)

Parameters

time GameTime
location GameLocation

Returns

AnchorTarget

UpdateAnchor(GameLocation)

Changes the position of the anchor that the companion moves relative to, based on Anchors.

protected virtual AnchorTarget UpdateAnchor(GameLocation location)

Parameters

location GameLocation

Returns

AnchorTarget

UpdateDirection()

Update companion facing direction using a direction.

protected virtual void UpdateDirection()

UpdateGlobal(GameTime, GameLocation)

Update info that should change every tick, for all game instances in multiplayer.

public virtual void UpdateGlobal(GameTime time, GameLocation location)

Parameters

time GameTime
location GameLocation

UpdateLightSource(GameTime, GameLocation)

Reposition the lightsource.

public virtual void UpdateLightSource(GameTime time, GameLocation location)

Parameters

time GameTime
location GameLocation

UpdateLocal(GameTime, GameLocation)

Update info that should change every tick, for owner only. Netfield changes should happen here.

public abstract void UpdateLocal(GameTime time, GameLocation location)

Parameters

time GameTime
location GameLocation