From e72ba27a4bf8240620cbe28b18948cca994ecec7 Mon Sep 17 00:00:00 2001 From: MSWS Date: Tue, 20 Feb 2024 22:56:39 -0800 Subject: [PATCH] Add helper LR print function --- .../LastRequests/KnifeFight.cs | 13 +++++++++---- .../Mod/LastRequest/AbstractLastRequest.cs | 6 +++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/mod/Jailbreak.LastRequest/LastRequests/KnifeFight.cs b/mod/Jailbreak.LastRequest/LastRequests/KnifeFight.cs index 6722ab0e..6e099465 100644 --- a/mod/Jailbreak.LastRequest/LastRequests/KnifeFight.cs +++ b/mod/Jailbreak.LastRequest/LastRequests/KnifeFight.cs @@ -23,13 +23,18 @@ public override void Setup() guard.RemoveWeapons(); guard.Teleport(prisoner.Pawn.Value!.AbsOrigin!, prisoner.Pawn.Value.AbsRotation!, new Vector()); state = LRState.Pending; - plugin.AddTimer(3, Execute); + for (var i = 3; i >= 1; i--) + { + var copy = i; + plugin.AddTimer(3 - i, () => { PrintToParticipants($"{copy}..."); }); + } + + plugin.AddTimer(4, Execute); } public override void Execute() { - prisoner.PrintToChat("Begin!"); - guard.PrintToChat("Begin!"); + PrintToParticipants("Go!"); prisoner.GiveNamedItem("weapon_knife"); guard.GiveNamedItem("weapon_knife"); this.state = LRState.Active; @@ -37,6 +42,6 @@ public override void Execute() public override void End(LRResult result) { - this.state = LRState.Completed; + state = LRState.Completed; } } \ No newline at end of file diff --git a/public/Jailbreak.Public/Mod/LastRequest/AbstractLastRequest.cs b/public/Jailbreak.Public/Mod/LastRequest/AbstractLastRequest.cs index 3a8bfeca..63ff059d 100644 --- a/public/Jailbreak.Public/Mod/LastRequest/AbstractLastRequest.cs +++ b/public/Jailbreak.Public/Mod/LastRequest/AbstractLastRequest.cs @@ -11,7 +11,6 @@ public abstract class AbstractLastRequest public LRState state { get; protected set; } protected BasePlugin plugin; - protected DateTimeOffset startTime; protected AbstractLastRequest(BasePlugin plugin, CCSPlayerController prisoner, CCSPlayerController guard) { @@ -20,6 +19,11 @@ protected AbstractLastRequest(BasePlugin plugin, CCSPlayerController prisoner, C this.guard = guard; } + public void PrintToParticipants(string message) + { + prisoner.PrintToChat(message); + guard.PrintToChat(message); + } public abstract void Setup(); public abstract void Execute();