Skip to content

Commit

Permalink
Add null check to Actor.Crushables
Browse files Browse the repository at this point in the history
  • Loading branch information
atlimit8 authored and PunkPun committed Feb 9, 2024
1 parent 2fe13fe commit 8993901
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions OpenRA.Game/Actor.cs
Original file line number Diff line number Diff line change
@@ -72,7 +72,11 @@ public Activity CurrentActivity
public IOccupySpace OccupiesSpace { get; }
public ITargetable[] Targetables { get; }
public IEnumerable<ITargetablePositions> 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 @@ internal Actor(World world, string name, TypeDictionary initDict)
EnabledTargetablePositions = targetablePositions.Where(Exts.IsTraitEnabled);
enabledTargetableWorldPositions = EnabledTargetablePositions.SelectMany(tp => tp.TargetablePositions(this));
SyncHashes = syncHashesList.ToArray();
Crushables = crushablesList.ToArray();
crushables = crushablesList.ToArray();
}
}

0 comments on commit 8993901

Please sign in to comment.