From 89939016411732091b7597fbe343163fdc8c339f Mon Sep 17 00:00:00 2001 From: atlimit8 Date: Thu, 8 Feb 2024 23:29:01 -0600 Subject: [PATCH] Add null check to Actor.Crushables --- OpenRA.Game/Actor.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OpenRA.Game/Actor.cs b/OpenRA.Game/Actor.cs index 9da4620d35..1e6b245ace 100644 --- a/OpenRA.Game/Actor.cs +++ b/OpenRA.Game/Actor.cs @@ -72,7 +72,11 @@ namespace OpenRA public IOccupySpace OccupiesSpace { get; } public ITargetable[] Targetables { get; } public IEnumerable EnabledTargetablePositions { get; } - public ICrushable[] Crushables { get; } + readonly ICrushable[] crushables; + public ICrushable[] Crushables + { + get => crushables ?? throw new InvalidOperationException($"Crushables for {Info.Name} are not initialized."); + } public bool IsIdle => CurrentActivity == null; public bool IsDead => Disposed || (health != null && health.IsDead); @@ -198,7 +202,7 @@ namespace OpenRA EnabledTargetablePositions = targetablePositions.Where(Exts.IsTraitEnabled); enabledTargetableWorldPositions = EnabledTargetablePositions.SelectMany(tp => tp.TargetablePositions(this)); SyncHashes = syncHashesList.ToArray(); - Crushables = crushablesList.ToArray(); + crushables = crushablesList.ToArray(); } }