Skip to content

Commit 1478d77

Browse files
committed
Fix crash with StaticMoverWithLiftSpeed
Fixed by max480 in their own repository, max4805/MaxHelpingHand
1 parent c77f687 commit 1478d77

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

source/Misc/StaticMoverWithLiftSpeed.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
using Microsoft.Xna.Framework;
22
using Monocle;
33
using System;
4+
using System.Collections.Generic;
45

56
namespace Celeste.Mod.VortexHelper.Misc {
67
/// <summary>
78
/// A static mover that has an extra "event" OnSetLiftSpeed that is called with the exact value of the lift speed just before any move.
89
/// This allows to attach solids to solids with both solids having the same lift speed.
10+
/// <para/>
11+
/// <see href="https://github.com/max4805/MaxHelpingHand/blob/e76ac4ca2b06869f80f7dca82f231f4709a5aeb2/Entities/StaticMoverWithLiftSpeed.cs">Originally implemented by max480 in MaxHelpingHand.</see>
912
/// </summary>
1013
[TrackedAs(typeof(StaticMover))]
1114
public class StaticMoverWithLiftSpeed : StaticMover {
1215
public Action<Vector2> OnSetLiftSpeed;
1316

1417
public static class Hooks {
15-
private static Platform currentPlatform;
18+
private static LinkedList<Platform> currentPlatforms = new();
1619

1720
public static void Hook() {
1821
On.Celeste.Platform.MoveStaticMovers += Platform_MoveStaticMovers;
@@ -25,14 +28,14 @@ public static void Unhook() {
2528
}
2629

2730
private static void Platform_MoveStaticMovers(On.Celeste.Platform.orig_MoveStaticMovers orig, Platform self, Vector2 amount) {
28-
currentPlatform = self;
31+
currentPlatforms.AddLast(self);
2932
orig(self, amount);
30-
currentPlatform = null;
33+
currentPlatforms.RemoveLast();
3134
}
3235

3336
private static void StaticMover_Move(On.Celeste.StaticMover.orig_Move orig, StaticMover self, Vector2 amount) {
3437
if (self is StaticMoverWithLiftSpeed staticMover) {
35-
staticMover.OnSetLiftSpeed?.Invoke(currentPlatform.LiftSpeed);
38+
staticMover.OnSetLiftSpeed?.Invoke(currentPlatforms.Last.Value.LiftSpeed);
3639
}
3740

3841
orig(self, amount);

0 commit comments

Comments
 (0)