From 343c99da7daf34e6ed8dbc3e15bdab6928920f56 Mon Sep 17 00:00:00 2001 From: Rampastring Date: Sat, 19 Oct 2024 21:36:51 +0300 Subject: [PATCH] Move turret animation frame selection logic to Animation.GetFrameIndex instead of AnimRenderer --- src/TSMapEditor/Models/Animation.cs | 8 ++++++++ src/TSMapEditor/Rendering/ObjectRenderers/AnimRenderer.cs | 7 ------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/TSMapEditor/Models/Animation.cs b/src/TSMapEditor/Models/Animation.cs index 3436c72c..cd79924d 100644 --- a/src/TSMapEditor/Models/Animation.cs +++ b/src/TSMapEditor/Models/Animation.cs @@ -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) diff --git a/src/TSMapEditor/Rendering/ObjectRenderers/AnimRenderer.cs b/src/TSMapEditor/Rendering/ObjectRenderers/AnimRenderer.cs index ec2d80e2..ef54de99 100644 --- a/src/TSMapEditor/Rendering/ObjectRenderers/AnimRenderer.cs +++ b/src/TSMapEditor/Rendering/ObjectRenderers/AnimRenderer.cs @@ -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;