Skip to content

Commit

Permalink
Change max rotation speed to be read as degrees + cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
Wartori54 committed Jul 15, 2024
1 parent 94876ab commit a8589ff
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions Celeste.Mod.mm/Patches/BirdPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit a8589ff

Please sign in to comment.