LabAPI
LabAPI copied to clipboard
[IDEA] Improve Pickup.IsDestroyed null-check reliability
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
IsDestroyedproperty to first check ifBaseisnullbefore accessing its properties.
Suggested code fix:
public bool IsDestroyed => Base == null || GameObject == null;