diff --git a/src/AntiRush.cs b/src/AntiRush.cs index ebf7bd5..b025afd 100644 --- a/src/AntiRush.cs +++ b/src/AntiRush.cs @@ -31,6 +31,8 @@ public override void Load(bool isReload) Server.NextFrame(() => { + _gameRules = Utilities.FindAllEntitiesByDesignerName("cs_gamerules").First().GameRules!; + foreach (var controller in Utilities.GetPlayers()) _playerData[controller] = new PlayerData(); diff --git a/src/Events.cs b/src/Events.cs index 0929e70..53a93fe 100644 --- a/src/Events.cs +++ b/src/Events.cs @@ -11,14 +11,17 @@ private HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info) _roundStart = Server.CurrentTime; _bombPlanted = false; - var gameRules = Utilities.FindAllEntitiesByDesignerName("cs_gamerules").First().GameRules!; - _warmup = gameRules.WarmupPeriod; + _gameRules ??= Utilities.FindAllEntitiesByDesignerName("cs_gamerules").First().GameRules!; + _warmup = _gameRules.WarmupPeriod; if (!Config.DrawZones) return HookResult.Continue; foreach (var zone in _zones) + { + zone.Data = []; zone.Draw(); + } return HookResult.Continue; } diff --git a/src/Globals.cs b/src/Globals.cs index 1af3e14..20e92ec 100644 --- a/src/Globals.cs +++ b/src/Globals.cs @@ -8,7 +8,7 @@ namespace AntiRush; public partial class AntiRush { public override string ModuleName => "AntiRush"; - public override string ModuleVersion => "1.0.5"; + public override string ModuleVersion => "1.0.6"; public override string ModuleAuthor => "https://github.com/oscar-wos/AntiRush"; public AntiRushConfig Config { get; set; } = new(); public Menu.Menu Menu { get; } = new(); @@ -20,4 +20,5 @@ public partial class AntiRush private bool _bombPlanted; private bool _warmup; private float[] _countdown = []; + private CCSGameRules? _gameRules; } \ No newline at end of file diff --git a/src/Zone.cs b/src/Zone.cs index 64f8fbd..d7a3e11 100644 --- a/src/Zone.cs +++ b/src/Zone.cs @@ -16,7 +16,7 @@ public class Zone(string name, ZoneType type, float delay, int damage, CsTeam[] public CsTeam[] Teams { get; init; } = teams; public Vector MinPoint { get; init; } = minPoint; public Vector MaxPoint { get; init; } = maxPoint; - public Dictionary Data { get; } = []; + public Dictionary Data { get; set; } = []; public CBeam[] Beams { get; } = []; public bool IsInZone(Vector point)