Refactor Barotrauma to be ECS. (#4674)
- Refactor IPressureProtection to be two different ECS events.
This commit is contained in:
committed by
GitHub
parent
6891c32eb5
commit
246fda53c5
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user