Generalized material spawning (#12489)
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user