Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.7.6 fixes #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions source/PauseController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ void Update()

Plugin.Log.LogInfo($"MainTimerPanel found: {_mainTimerPanel != null}");
Plugin.Log.LogInfo($"GameTimerClass found: {_gameTimerClass != null}");
Plugin.Log.LogInfo($"Start Time: {_gameTimerClass.StartDateTime.Value.ToString()}");
Plugin.Log.LogInfo($"Escape Time: {_gameTimerClass.EscapeDateTime.Value.ToString()}");
Plugin.Log.LogInfo($"Past Time: {_gameTimerClass.PastTime}");

if (isPaused)
{
Expand All @@ -80,6 +83,8 @@ void Update()
}

Plugin.Log.LogInfo($"Game paused: [{isPaused}]");
Plugin.Log.LogInfo($"Start Time: {_gameTimerClass.StartDateTime.Value.ToString()}");
Plugin.Log.LogInfo($"Escape Time: {_gameTimerClass.EscapeDateTime.Value.ToString()}");
Plugin.Log.LogInfo($"Past Time: {_gameTimerClass.PastTime}");
}
}
Expand Down Expand Up @@ -255,7 +260,9 @@ private void UpdateTimers(TimeSpan timePaused)
// GameTimerClass controls the overall game state
// If PastTime > SessionTime game ends
// PastTime is calculated based on nullable_0
var fi1 = typeof(GameTimerClass).GetField("nullable_0", BindingFlags.Instance | BindingFlags.NonPublic);
var startTime = typeof(GameTimerClass).GetField("nullable_0", BindingFlags.Instance | BindingFlags.NonPublic);
var escapeTime = typeof(GameTimerClass).GetField("nullable_1", BindingFlags.Instance | BindingFlags.NonPublic);


// MainTimerPanel is the in-game ui clock, which operates separately
// from the timer in GameTimerClass
Expand All @@ -269,7 +276,7 @@ private void UpdateTimers(TimeSpan timePaused)
var fi3 = typeof(GameDateTime).GetField("_realtimeSinceStartup", BindingFlags.Instance | BindingFlags.NonPublic);

// get the underlying start date value from GameTimerClass nullable_0 private field
var startDate = fi1.GetValue(_gameTimerClass) as DateTime?;
var startDate = startTime.GetValue(_gameTimerClass) as DateTime?;

// get the underlying escape date value from TimerPanel dateTime_0 private field
var escapeDate = fi2.GetValue(_mainTimerPanel) as DateTime?;
Expand All @@ -278,7 +285,8 @@ private void UpdateTimers(TimeSpan timePaused)
var realTimeSinceStartup = (float)fi3.GetValue(_gameWorld.GameDateTime);

// add the time spent paused to the underlying start date
fi1.SetValue(_gameTimerClass, startDate.Value.Add(timePaused));
startTime.SetValue(_gameTimerClass, startDate.Value.Add(timePaused));
escapeTime.SetValue(_gameTimerClass, escapeDate.Value.Add(timePaused));

// add the time spent paused
fi2.SetValue(_mainTimerPanel, escapeDate.Value.Add(timePaused));
Expand Down