WheteThunger / MonumentAddons

Add entities, spawn points and more to monuments
https://umod.org/plugins/monument-addons
MIT License
7 stars 9 forks source link

Disable decay for hackable crates #36

Closed WheteThunger closed 2 years ago

WheteThunger commented 2 years ago

Hackable crates spawned by spawn groups should have decay disabled. Issue reported here: https://umod.org/community/monument-addons/42403-entity-disappearing-reappearing

Note: The codelockedhackablecrate has decay enabled, while codelockedhackablecrate_oilrig has decay disabled, so people can currently spawn the latter as a workaround. We should disable decay for both types to improve usability.

WheteThunger commented 2 years ago

Possible implementation in CustomSpawnPoint.ObjectSpawned:

var hackableCrate = entity as HackableLockedCrate;
if ((object)hackableCrate != null && hackableCrate.shouldDecay)
{
    hackableCrate.shouldDecay = false;
    hackableCrate.CancelInvoke(hackableCrate.DelayedDestroy);
}