-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#274 Add debug events synchronization
- Loading branch information
Showing
5 changed files
with
84 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using HarmonyLib; | ||
using JetBrains.Annotations; | ||
using MultiplayerMod.ModRuntime.Context; | ||
|
||
namespace MultiplayerMod.Game.Debug; | ||
|
||
[HarmonyPatch] | ||
public static class GameDebugEvents { | ||
|
||
public static event System.Action? GameFrameStepping; | ||
public static event System.Action? SimulationStepping; | ||
|
||
[HarmonyPrefix, UsedImplicitly] | ||
[HarmonyPatch(typeof(SpeedControlScreen), nameof(SpeedControlScreen.DebugStepFrame))] | ||
[RequireExecutionLevel(ExecutionLevel.Game)] | ||
private static void DebugStepFramePrefix() => GameFrameStepping?.Invoke(); | ||
|
||
[HarmonyPrefix, UsedImplicitly] | ||
[HarmonyPatch(typeof(global::Game), nameof(global::Game.ForceSimStep))] | ||
[RequireExecutionLevel(ExecutionLevel.Game)] | ||
private static void ForceSimStepPrefix() => SimulationStepping?.Invoke(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/MultiplayerMod/Multiplayer/Commands/Debug/DebugGameFrameStep.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System; | ||
|
||
namespace MultiplayerMod.Multiplayer.Commands.Debug; | ||
|
||
[Serializable] | ||
public class DebugGameFrameStep : MultiplayerCommand { | ||
|
||
public override void Execute(MultiplayerCommandContext context) => SpeedControlScreen.Instance.DebugStepFrame(); | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
src/MultiplayerMod/Multiplayer/Commands/Debug/DebugSimulationStep.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System; | ||
|
||
namespace MultiplayerMod.Multiplayer.Commands.Debug; | ||
|
||
[Serializable] | ||
public class DebugSimulationStep : MultiplayerCommand { | ||
|
||
public override void Execute(MultiplayerCommandContext context) => global::Game.Instance.ForceSimStep(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters