From a649be79f90e4c9dee4cf961d3f26395901b9dcb Mon Sep 17 00:00:00 2001 From: MSWS Date: Fri, 1 Nov 2024 15:09:59 -0700 Subject: [PATCH] Fix circular dependency --- mod/Jailbreak.LastRequest/LastRequestManager.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mod/Jailbreak.LastRequest/LastRequestManager.cs b/mod/Jailbreak.LastRequest/LastRequestManager.cs index 58219c7..5049579 100644 --- a/mod/Jailbreak.LastRequest/LastRequestManager.cs +++ b/mod/Jailbreak.LastRequest/LastRequestManager.cs @@ -24,8 +24,7 @@ namespace Jailbreak.LastRequest; -public class LastRequestManager(ILRLocale messages, IServiceProvider provider, - ILastGuardService lastGuard, IRebelService rebel) +public class LastRequestManager(ILRLocale messages, IServiceProvider provider) : ILastRequestManager, IDamageBlocker { public static readonly FakeConVar CV_LR_BASE_TIME = new("css_jb_lr_time_base", @@ -123,7 +122,9 @@ public void EnableLR(CCSPlayerController? died = null) { RoundUtil.AddTimeRemaining(CV_LR_GUARD_TIME.Value * cts); - var players = Utilities.GetPlayers(); + var players = Utilities.GetPlayers(); + var lastGuard = provider.GetService(); + var rebel = provider.GetService(); foreach (var player in players) { player.ExecuteClientCommand("play sounds/lr"); var wrapper = new PlayerWrapper(player); @@ -150,7 +151,7 @@ public void EnableLR(CCSPlayerController? died = null) { if (player.Team != CsTeam.Terrorist) continue; if (died != null && player.SteamID == died.SteamID) continue; - if (lastGuard.IsLastGuardActive) rebel.UnmarkRebel(player); + if (lastGuard is { IsLastGuardActive: true }) rebel?.UnmarkRebel(player); player.ExecuteClientCommandFromServer("css_lr"); }