From a8589ffd2d601406056fb906f0830fbb6e50da18 Mon Sep 17 00:00:00 2001 From: Wartori54 Date: Mon, 15 Jul 2024 10:53:31 +0200 Subject: [PATCH] Change max rotation speed to be read as degrees + cleanups --- Celeste.Mod.mm/Patches/BirdPath.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Celeste.Mod.mm/Patches/BirdPath.cs b/Celeste.Mod.mm/Patches/BirdPath.cs index 22130efd8..612da20a5 100644 --- a/Celeste.Mod.mm/Patches/BirdPath.cs +++ b/Celeste.Mod.mm/Patches/BirdPath.cs @@ -23,7 +23,7 @@ public class patch_BirdPath : BirdPath { // Whether to apply the fix, see `PatchBirdPathUpdate` private bool angleFix = false; // Maximum rad/s turn speed, see `PatchBirdPathUpdate` - private float angleFixMaxRotation = 1; + private float angleFixMaxRotation = MathF.PI / 3; // Default to 60 deg second // If this entity is placed in a vanilla map we will forcibly disable all changes // Note that `angleFix` is false by default so that will also apply in vanilla private bool inVanilla = false; @@ -43,7 +43,7 @@ public patch_BirdPath(EntityID id, Vector2 position, Vector2[] nodes, bool onlyO public void ctor(EntityID id, EntityData data, Vector2 offset) { orig_ctor(id, data, offset); this.angleFix = data.Bool("angle_fix"); - this.angleFixMaxRotation = data.Float("angle_fix_max_rotation_speed"); + this.angleFixMaxRotation = MathF.Abs(data.Float("angle_fix_max_rotation_speed").ToRad()); } public extern void orig_Added(Scene scene); @@ -71,11 +71,7 @@ public float CalcAngle() { } else { float maxTurnSpeed = angleFixMaxRotation * Engine.DeltaTime; float newAngle = Calc.AngleLerp(this.speed.Angle(), oldAngle, 0.5F); - if (Calc.AbsAngleDiff(newAngle, oldAngle) > maxTurnSpeed) { - oldAngle += maxTurnSpeed * -Calc.SignAngleDiff(newAngle, oldAngle); - } else { - oldAngle = newAngle; - } + oldAngle = Calc.AngleApproach(oldAngle, newAngle, maxTurnSpeed); } return oldAngle + MathF.PI/2;