diff --git a/Content.Server/Storage/Components/SpawnItemsOnUseComponent.cs b/Content.Server/Storage/Components/SpawnItemsOnUseComponent.cs index ef4b8197fc..6db9f091d3 100644 --- a/Content.Server/Storage/Components/SpawnItemsOnUseComponent.cs +++ b/Content.Server/Storage/Components/SpawnItemsOnUseComponent.cs @@ -24,6 +24,7 @@ namespace Content.Server.Storage.Components /// /// How many uses before the item should delete itself. /// + [ViewVariables(VVAccess.ReadWrite)] [DataField("uses")] public int Uses = 1; } diff --git a/Content.Server/Storage/EntitySystems/SpawnItemsOnUseSystem.cs b/Content.Server/Storage/EntitySystems/SpawnItemsOnUseSystem.cs index b24348507d..061ddee824 100644 --- a/Content.Server/Storage/EntitySystems/SpawnItemsOnUseSystem.cs +++ b/Content.Server/Storage/EntitySystems/SpawnItemsOnUseSystem.cs @@ -65,6 +65,10 @@ namespace Content.Server.Storage.EntitySystems if (args.Handled) return; + // If starting with zero or less uses, this component is a no-op + if (component.Uses <= 0) + return; + var coords = Transform(args.User).Coordinates; var spawnEntities = GetSpawns(component.Items, _random); EntityUid? entityToPlaceInHands = null; @@ -79,7 +83,9 @@ namespace Content.Server.Storage.EntitySystems SoundSystem.Play(component.Sound.GetSound(), Filter.Pvs(uid), uid); component.Uses--; - if (component.Uses == 0) + + // Delete entity only if component was successfully used + if (component.Uses <= 0) { args.Handled = true; EntityManager.DeleteEntity(uid);