Removes all dependencies on engine component events. (#4199)
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
27
Content.Server/Inventory/InventorySystem.cs
Normal file
27
Content.Server/Inventory/InventorySystem.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user