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
TrinketTinkerCompanionmdata
MotionDatavdata
VariantData
Fields
PauseMovementByAnimClip
An anim clip that pauses movement is currently playing.
public bool PauseMovementByAnimClip
Field Value
c
Companion that owns this motion.
protected readonly TrinketTinkerCompanion c
Field Value
cs
Companion animation controller
protected TinkerAnimSprite cs
Field Value
currAnchorTarget
The current anchor target, is sync'd by CurrAnchorTarget
protected AnchorTarget currAnchorTarget
Field Value
framesetLength
Number of frames in 1 set, used for Repeat and SerpentMotion
protected int framesetLength
Field Value
lightId
Light source ID, generated if LightRadius is set in MotionData.
protected string lightId
Field Value
md
Data for this motion.
protected MotionData md
Field Value
prevAnchorTarget
The previous anchor target
protected AnchorTarget prevAnchorTarget
Field Value
vd
Data for this motion.
protected VariantData vd
Field Value
Properties
AnchorChanged
Anchor changed during this tick
protected bool AnchorChanged { get; }
Property Value
BoundingBox
Bounding box of trinket
public Rectangle BoundingBox { get; }
Property Value
- Rectangle
CompanionAnimSprite
Current variant data
public TinkerAnimSprite CompanionAnimSprite { get; }
Property Value
MotionClass
Type name of the motion, can use short form like "Hover" for hover motion.
public string MotionClass { get; }
Property Value
NetRand
Clip random
public Random NetRand { get; set; }
Property Value
Speaker
Current variant data
public ChatterSpeaker Speaker { get; }
Property Value
TotalFrames
Actual total frame used for Repeat, equal to frame length
protected virtual int TotalFrames { get; }
Property Value
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
SpriteBatchsnapshot
DrawSnapshot
DrawCompanionBreathing(SpriteBatch, DrawSnapshot)
Draw companion breathing from snapshot, enqueue repeat as required
protected virtual void DrawCompanionBreathing(SpriteBatch b, DrawSnapshot snapshot)
Parameters
b
SpriteBatchsnapshot
DrawSnapshot
DrawShadow(SpriteBatch, DrawSnapshot)
Draw shadow from snapshot, enqueue repeat as required
protected virtual void DrawShadow(SpriteBatch b, DrawSnapshot snapshot)
Parameters
b
SpriteBatchsnapshot
DrawSnapshot
EnqueueRepeatDraws(DrawSnapshot, bool)
Queue up repeats of the current draw.
protected void EnqueueRepeatDraws(DrawSnapshot snapshot, bool isShadow)
Parameters
snapshot
DrawSnapshotisShadow
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
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
IsMoving()
Moving flag used for basis of anim
protected abstract bool IsMoving()
Returns
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
stringtrinketItem
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
MotionDatavdata
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
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
GameTimelocation
GameLocation
Returns
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
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
GameTimelocation
GameLocation
UpdateLightSource(GameTime, GameLocation)
Reposition the lightsource.
public virtual void UpdateLightSource(GameTime time, GameLocation location)
Parameters
time
GameTimelocation
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
GameTimelocation
GameLocation