Skip to content

Commit

Permalink
Dont attempt auto-open on warmup, properly handle early round ends
Browse files Browse the repository at this point in the history
  • Loading branch information
MSWS committed Aug 24, 2024
1 parent ba5f0da commit 7f4b1f6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions mod/Jailbreak.Warden/Global/WardenBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class WardenBehavior(ILogger<WardenBehavior> logger,

private BasePlugin parent = null!;
private PreWardenStats? preWardenStats;
private Timer? unblueTimer;
private Timer? unblueTimer, openCellsTimer;

public void Start(BasePlugin basePlugin) { parent = basePlugin; }

Expand Down Expand Up @@ -394,6 +394,7 @@ private bool playerHasHealthshot(CCSPlayerController player,
public HookResult OnRoundEnd(EventRoundEnd ev, GameEventInfo info) {
TryRemoveWarden();
mute.UnPeaceMute();
openCellsTimer?.Kill();
return HookResult.Continue;
}

Expand All @@ -402,12 +403,13 @@ public HookResult OnRoundStart(EventRoundStart ev, GameEventInfo info) {
firstWarden = true;
preWardenStats = null;

if (CvWardenAutoOpenCells.Value < 0) return HookResult.Continue;
if (CvWardenAutoOpenCells.Value < 0 || RoundUtil.IsWarmup())
return HookResult.Continue;
var openCmd = provider.GetService<IWardenOpenCommand>();
if (openCmd == null) return HookResult.Continue;
var cmdLocale = provider.GetRequiredService<IWardenCmdOpenLocale>();

parent.AddTimer(CvWardenAutoOpenCells.Value, () => {
openCellsTimer = parent.AddTimer(CvWardenAutoOpenCells.Value, () => {
if (openCmd.OpenedCells) return;
var zone = provider.GetService<IZoneManager>();
if (zone != null)
Expand Down

0 comments on commit 7f4b1f6

Please sign in to comment.