Refactor Barotrauma to be ECS. (#4674)

- Refactor IPressureProtection to be two different ECS events.
This commit is contained in:
Vera Aguilera Puerto
2021-09-22 13:02:25 +02:00
committed by GitHub
parent 6891c32eb5
commit 246fda53c5
8 changed files with 217 additions and 144 deletions

View File

@@ -1,3 +1,4 @@
using Content.Server.Atmos;
using Content.Server.Inventory.Components;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
@@ -12,6 +13,8 @@ namespace Content.Server.Inventory
SubscribeLocalEvent<HumanInventoryControllerComponent, EntRemovedFromContainerMessage>(HandleRemovedFromContainer);
SubscribeLocalEvent<InventoryComponent, EntRemovedFromContainerMessage>(HandleInvRemovedFromContainer);
SubscribeLocalEvent<InventoryComponent, HighPressureEvent>(OnHighPressureEvent);
SubscribeLocalEvent<InventoryComponent, LowPressureEvent>(OnLowPressureEvent);
}
private static void HandleInvRemovedFromContainer(EntityUid uid, InventoryComponent component, EntRemovedFromContainerMessage args)
@@ -23,5 +26,23 @@ namespace Content.Server.Inventory
{
component.CheckUniformExists();
}
private void OnHighPressureEvent(EntityUid uid, InventoryComponent component, HighPressureEvent args)
{
RelayPressureEvent(component, args);
}
private void OnLowPressureEvent(EntityUid uid, InventoryComponent component, LowPressureEvent args)
{
RelayPressureEvent(component, args);
}
private void RelayPressureEvent<T>(InventoryComponent component, T args) where T : PressureEvent
{
foreach (var equipped in component.GetAllHeldItems())
{
RaiseLocalEvent(equipped.Uid, args, false);
}
}
}
}