LabAPI icon indicating copy to clipboard operation
LabAPI copied to clipboard

[IDEA] Improve Pickup.IsDestroyed null-check reliability

Open CCrous opened this issue 1 year ago • 0 comments

Goal Description

The IsDestroyed property in the Pickup class currently checks GameObject == null, but when a pickup is destroyed, the Base property (ItemPickupBase) becomes null. Accessing Base.Info during this check throws a NullReferenceException. This needs optimization to safely handle null references.

Proposed fix:

  • Update the IsDestroyed property to first check if Base is null before accessing its properties.

Suggested code fix:

public bool IsDestroyed => Base == null || GameObject == null;

CCrous avatar Feb 23 '25 12:02 CCrous