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 : IArgsType 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
- companionTrinketTinkerCompanion
- mdataMotionData
- vdataVariantData
Fields
PauseMovementByAnimClip
An anim clip that pauses movement is currently playing.
public bool PauseMovementByAnimClipField Value
c
Companion that owns this motion.
protected readonly TrinketTinkerCompanion cField Value
cs
Companion animation controller
protected TinkerAnimSprite csField Value
currAnchorTarget
The current anchor target, is sync'd by CurrAnchorTarget
protected AnchorTarget currAnchorTargetField Value
framesetLength
Number of frames in 1 set, used for Repeat and SerpentMotion
protected int framesetLengthField Value
lightId
Light source ID, generated if LightRadius is set in MotionData.
protected string lightIdField Value
md
Data for this motion.
protected MotionData mdField Value
prevAnchorTarget
The previous anchor target
protected AnchorTarget prevAnchorTargetField Value
vd
Data for this motion.
protected VariantData vdField 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
- bSpriteBatch
DrawCompanion(SpriteBatch, DrawSnapshot)
Draw companion from snapshot, enqueue repeat as required
protected virtual void DrawCompanion(SpriteBatch b, DrawSnapshot snapshot)Parameters
- bSpriteBatch
- snapshotDrawSnapshot
DrawCompanionBreathing(SpriteBatch, DrawSnapshot)
Draw companion breathing from snapshot, enqueue repeat as required
protected virtual void DrawCompanionBreathing(SpriteBatch b, DrawSnapshot snapshot)Parameters
- bSpriteBatch
- snapshotDrawSnapshot
DrawShadow(SpriteBatch, DrawSnapshot)
Draw shadow from snapshot, enqueue repeat as required
protected virtual void DrawShadow(SpriteBatch b, DrawSnapshot snapshot)Parameters
- bSpriteBatch
- snapshotDrawSnapshot
EnqueueRepeatDraws(DrawSnapshot, bool)
Queue up repeats of the current draw.
protected void EnqueueRepeatDraws(DrawSnapshot snapshot, bool isShadow)Parameters
- snapshotDrawSnapshot
- isShadowbool
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
- offsetVector2
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
- offsetVector2
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
- farmerFarmer
IsFacing(Vector2)
Check is facing
public virtual bool IsFacing(Vector2 target)Parameters
- targetVector2
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
- abilityTypesIEnumerable<string>
SetAltVariant(string?, Trinket?)
Set an alt variant.
public void SetAltVariant(string? altVariantKey, Trinket? trinketItem)Parameters
- altVariantKeystring
- trinketItemTrinket
SetCurrAnchorTarget(int)
Sync curr anchor target value
public void SetCurrAnchorTarget(int val)Parameters
- valint
SetMotionVariantData(MotionData, VariantData)
Update motion and variant data, when invalidate
public virtual void SetMotionVariantData(MotionData mdata, VariantData vdata)Parameters
- mdataMotionData
- vdataVariantData
SetOneshotClip(string?)
Set an oneshot clip, to play once until end
public void SetOneshotClip(string? clipKey)Parameters
- clipKeystring
SetOverrideClip(string?)
Set an override clip, to play instead of normal directional animation
public void SetOverrideClip(string? clipKey)Parameters
- clipKeystring
SetSpeechBubble(string?)
Set a speech bubble to call, usually on ability proc.
public void SetSpeechBubble(string? speechBubbleKey)Parameters
- speechBubbleKeystring
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
- timeGameTime
- locationGameLocation
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
- locationGameLocation
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
- timeGameTime
- locationGameLocation
UpdateLightSource(GameTime, GameLocation)
Reposition the lightsource.
public virtual void UpdateLightSource(GameTime time, GameLocation location)Parameters
- timeGameTime
- locationGameLocation
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
- timeGameTime
- locationGameLocation