Fix material storage going BRRT (#29167)
If the volume hits 0 we just remove it.
This commit is contained in:
@@ -78,9 +78,6 @@ public sealed partial class LatheMenu : DefaultWindow
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void PopulateRecipes()
|
public void PopulateRecipes()
|
||||||
{
|
{
|
||||||
if (!_entityManager.TryGetComponent<LatheComponent>(_owner, out var component))
|
|
||||||
return;
|
|
||||||
|
|
||||||
var recipesToShow = new List<LatheRecipePrototype>();
|
var recipesToShow = new List<LatheRecipePrototype>();
|
||||||
foreach (var recipe in Recipes)
|
foreach (var recipe in Recipes)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Interaction.Components;
|
using Content.Shared.Interaction.Components;
|
||||||
|
using Content.Shared.Mobs;
|
||||||
using Content.Shared.Stacks;
|
using Content.Shared.Stacks;
|
||||||
using Content.Shared.Whitelist;
|
using Content.Shared.Whitelist;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
namespace Content.Shared.Materials;
|
namespace Content.Shared.Materials;
|
||||||
|
|
||||||
@@ -166,8 +168,14 @@ public abstract class SharedMaterialStorageSystem : EntitySystem
|
|||||||
return false;
|
return false;
|
||||||
if (!CanChangeMaterialAmount(uid, materialId, volume, component))
|
if (!CanChangeMaterialAmount(uid, materialId, volume, component))
|
||||||
return false;
|
return false;
|
||||||
component.Storage.TryAdd(materialId, 0);
|
|
||||||
component.Storage[materialId] += volume;
|
var existing = component.Storage.GetOrNew(materialId);
|
||||||
|
existing += volume;
|
||||||
|
|
||||||
|
if (existing == 0)
|
||||||
|
component.Storage.Remove(materialId);
|
||||||
|
else
|
||||||
|
component.Storage[materialId] = existing;
|
||||||
|
|
||||||
var ev = new MaterialAmountChangedEvent();
|
var ev = new MaterialAmountChangedEvent();
|
||||||
RaiseLocalEvent(uid, ref ev);
|
RaiseLocalEvent(uid, ref ev);
|
||||||
|
|||||||
Reference in New Issue
Block a user