- add: improve system

This commit is contained in:
2024-02-14 23:27:46 +03:00
parent 40d813de44
commit c9396e7b5a
13 changed files with 322 additions and 74 deletions

View File

@@ -1,24 +0,0 @@
using Content.Shared._Amour.Hole;
using Robust.Server.Containers;
using Robust.Shared.Containers;
namespace Content.Server._Amour.Hole;
public sealed partial class HoleSystem
{
[Dependency] private readonly ContainerSystem _containerSystem = default!;
private void InitializeContainer()
{
SubscribeLocalEvent<HoleContainerComponent,ComponentInit>(OnContainerInit);
}
private void OnContainerInit(EntityUid uid, HoleContainerComponent component, ComponentInit args)
{
component.Slot = _containerSystem.EnsureContainer<Container>(uid, HoleContainerComponent.SlotName);
foreach (var holePrototype in component.HolePrototypes)
{
Log.Debug("ADDED " + holePrototype);
_containerSystem.Insert(Spawn(holePrototype), component.Slot);
}
}
}

View File

@@ -7,7 +7,8 @@ namespace Content.Server._Amour.Hole;
public sealed partial class HoleSystem
{
[Dependency] private readonly ContainerSystem _container = default!;
public void InitializeInventory()
private void InitializeInventory()
{
SubscribeLocalEvent<HoleInventoryComponent,ComponentInit>(OnInventoryInit);
}

View File

@@ -12,14 +12,8 @@ public sealed partial class HoleSystem : SharedHoleSystem
public override void Initialize()
{
InitializeContainer();
base.Initialize();
InitializeInventory();
SubscribeLocalEvent<HoleComponent,EntGotInsertedIntoContainerMessage>(OnInsert);
}
private void OnInsert(EntityUid uid, HoleComponent component, EntGotInsertedIntoContainerMessage args)
{
component.Parent = GetNetEntity(args.Container.Owner);
}
public override void Update(float frameTime)