Generalized material spawning (#12489)

This commit is contained in:
Rane
2023-01-07 13:09:05 -05:00
committed by GitHub
parent f1cb0ca37a
commit fecd60e98a
13 changed files with 177 additions and 60 deletions

View File

@@ -1,9 +1,11 @@
using Content.Server.Administration.Logs;
using Content.Shared.Materials;
using Content.Shared.Popups;
using Content.Server.Power.Components;
using Content.Shared.Database;
using Content.Shared.Stacks;
using Content.Server.Power.Components;
using Content.Server.Construction.Components;
using Content.Server.Stack;
using Content.Shared.Database;
namespace Content.Server.Materials;
@@ -15,6 +17,21 @@ public sealed class MaterialStorageSystem : SharedMaterialStorageSystem
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly StackSystem _stackSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<MaterialStorageComponent, MachineDeconstructedEvent>(OnDeconstructed);
}
private void OnDeconstructed(EntityUid uid, MaterialStorageComponent component, MachineDeconstructedEvent args)
{
foreach (var (material, amount) in component.Storage)
{
_stackSystem.SpawnMultipleFromMaterial(amount, material, Transform(uid).Coordinates);
}
}
public override bool TryInsertMaterialEntity(EntityUid user, EntityUid toInsert, EntityUid receiver, MaterialStorageComponent? component = null)
{