Skip to content

Commit

Permalink
Move turret animation frame selection logic to Animation.GetFrameInde…
Browse files Browse the repository at this point in the history
…x instead of AnimRenderer
  • Loading branch information
Rampastring committed Oct 19, 2024
1 parent 223ca63 commit 343c99d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 8 additions & 0 deletions src/TSMapEditor/Models/Animation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ public override int GetXDrawOffset()

public override int GetFrameIndex(int frameCount)
{
if (IsTurretAnim)
{
// Turret anims have their facing frames reversed
// Turret anims also only have 32 facings
byte facing = (byte)(255 - Facing - 31);
return facing / (256 / 32);
}

if (IsBuildingAnim && ParentBuilding != null)
{
if (frameCount > 1 && ParentBuilding.HP < Constants.ConditionYellowHP)
Expand Down
7 changes: 0 additions & 7 deletions src/TSMapEditor/Rendering/ObjectRenderers/AnimRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ protected override void Render(Animation gameObject, Point2D drawPoint, in Commo
return;

int frameIndex = gameObject.GetFrameIndex(drawParams.ShapeImage.GetFrameCount());
if (gameObject.IsTurretAnim)
{
// Turret anims have their facing frames reversed
// Turret anims also only have 32 facings
byte facing = (byte)(255 - gameObject.Facing - 31);
frameIndex = facing / (256 / 32);
}

float alpha = 1.0f;

Expand Down

0 comments on commit 343c99d

Please sign in to comment.