Removes all dependencies on engine component events. (#4199)

This commit is contained in:
Acruid
2021-06-18 01:49:18 -07:00
committed by GitHub
parent 9fea68707c
commit e1e54e9cb1
27 changed files with 235 additions and 184 deletions

View File

@@ -60,17 +60,7 @@ namespace Content.Server.Inventory.Components
return flagsCheck;
}
public override void HandleMessage(ComponentMessage message, IComponent? component)
{
base.HandleMessage(message, component);
switch (message)
{
case ContainerContentsModifiedMessage contentsModified:
Owner.SpawnTimer(0, DropIdAndPocketsIfWeNoLongerHaveAUniform);
break;
}
}
public void CheckUniformExists() { Owner.SpawnTimer(0, DropIdAndPocketsIfWeNoLongerHaveAUniform); }
// Hey, it's descriptive.
private void DropIdAndPocketsIfWeNoLongerHaveAUniform()

View File

@@ -489,7 +489,7 @@ namespace Content.Server.Inventory.Components
/// The underlying Container System just notified us that an entity was removed from it.
/// We need to make sure we process that removed entity as being unequipped from the slot.
/// </summary>
private void ForceUnequip(IContainer container, IEntity entity)
public void ForceUnequip(IContainer container, IEntity entity)
{
// make sure this is one of our containers.
// Technically the correct way would be to enumerate the possible slot names
@@ -572,23 +572,6 @@ namespace Content.Server.Inventory.Components
}
}
/// <inheritdoc />
public override void HandleMessage(ComponentMessage message, IComponent? component)
{
base.HandleMessage(message, component);
switch (message)
{
case ContainerContentsModifiedMessage msg:
if (msg.Removed)
ForceUnequip(msg.Container, msg.Entity);
break;
default:
break;
}
}
/// <inheritdoc />
public override void HandleNetworkMessage(ComponentMessage message, INetChannel netChannel,
ICommonSession? session = null)

View File

@@ -0,0 +1,27 @@
using Content.Server.Inventory.Components;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
namespace Content.Server.Inventory
{
class InventorySystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<HumanInventoryControllerComponent, EntRemovedFromContainerMessage>(HandleRemovedFromContainer);
SubscribeLocalEvent<InventoryComponent, EntRemovedFromContainerMessage>(HandleInvRemovedFromContainer);
}
private static void HandleInvRemovedFromContainer(EntityUid uid, InventoryComponent component, EntRemovedFromContainerMessage args)
{
component.ForceUnequip(args.Container, args.Entity);
}
private static void HandleRemovedFromContainer(EntityUid uid, HumanInventoryControllerComponent component, EntRemovedFromContainerMessage args)
{
component.CheckUniformExists();
}
}
}