Skip to content

Commit

Permalink
fix: vel becomes 0 when game is paused
Browse files Browse the repository at this point in the history
  • Loading branch information
DemoJameson committed Apr 24, 2023
1 parent c9e84e6 commit 05bd9a2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
17 changes: 10 additions & 7 deletions CelesteTAS-EverestInterop/Source/TAS/GameInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public static class GameInfo {
public static Vector2Double LastPlayerSeekerPos;
public static float DashTime;
public static bool Frozen;

private static int transitionFrames;
public static int TransitionFrames;

public static string HudInfo {
get {
Expand Down Expand Up @@ -153,18 +152,22 @@ private static void SceneOnAfterUpdate(On.Monocle.Scene.orig_AfterUpdate orig, S
return;
}

Update(true);
if (self is Level level) {
Update(!level.wasPaused);
} else {
Update();
}
}

private static void LevelOnOnTransitionTo(Level level, LevelData next, Vector2 direction) {
transitionFrames = GetTransitionFrames(level, next);
TransitionFrames = GetTransitionFrames(level, next);
}

private static void LevelOnUpdate(On.Celeste.Level.orig_Update orig, Level self) {
orig(self);

if (transitionFrames > 0) {
transitionFrames--;
if (TransitionFrames > 0) {
TransitionFrames--;
}
}

Expand Down Expand Up @@ -360,7 +363,7 @@ public static void Update(bool updateVel = false) {
public static string GetStatuses(Level level, Player player) {
List<string> statuses = new();

string noControlFrames = transitionFrames > 0 ? $"({transitionFrames})" : string.Empty;
string noControlFrames = TransitionFrames > 0 ? $"({TransitionFrames})" : string.Empty;
float unpauseTimer = LevelUnpauseTimer?.Invoke(level) ?? 0f;
if (unpauseTimer > 0f) {
noControlFrames = $"({(int) Math.Ceiling(unpauseTimer / Engine.RawDeltaTime)})";
Expand Down
3 changes: 2 additions & 1 deletion CelesteTAS-EverestInterop/Source/TAS/Savestates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public static class Savestates {
{typeof(GameInfo).GetFieldInfo(nameof(GameInfo.LastPlayerSeekerPos)), null},
{typeof(GameInfo).GetFieldInfo(nameof(GameInfo.LastPlayerSeekerDiff)), null},
{typeof(GameInfo).GetFieldInfo(nameof(GameInfo.DashTime)), null},
{typeof(GameInfo).GetFieldInfo(nameof(GameInfo.Frozen)), null}
{typeof(GameInfo).GetFieldInfo(nameof(GameInfo.Frozen)), null},
{typeof(GameInfo).GetFieldInfo(nameof(GameInfo.TransitionFrames)), null},
};

private static bool savedByBreakpoint;
Expand Down

0 comments on commit 05bd9a2

Please sign in to comment.