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

@@ -7,7 +7,6 @@ using Content.Server.Clothing.Components;
using Content.Server.Hands.Components;
using Content.Server.Interaction;
using Content.Server.Items;
using Content.Server.Pressure;
using Content.Server.Storage.Components;
using Content.Shared.ActionBlocker;
using Content.Shared.Acts;
@@ -38,7 +37,7 @@ namespace Content.Server.Inventory.Components
{
[RegisterComponent]
[ComponentReference(typeof(SharedInventoryComponent))]
public class InventoryComponent : SharedInventoryComponent, IExAct, IPressureProtection, IEffectBlocker
public class InventoryComponent : SharedInventoryComponent, IExAct, IEffectBlocker
{
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
@@ -63,52 +62,6 @@ namespace Content.Server.Inventory.Components
}
}
// Optimization: Cache this
[ViewVariables]
public float HighPressureMultiplier
{
get
{
var multiplier = 1f;
foreach (var (slot, containerSlot) in _slotContainers)
{
foreach (var entity in containerSlot.ContainedEntities)
{
foreach (var protection in entity.GetAllComponents<IPressureProtection>())
{
multiplier *= protection.HighPressureMultiplier;
}
}
}
return multiplier;
}
}
// Optimization: Cache this
[ViewVariables]
public float LowPressureMultiplier
{
get
{
var multiplier = 1f;
foreach (var (slot, containerSlot) in _slotContainers)
{
foreach (var entity in containerSlot.ContainedEntities)
{
foreach (var protection in entity.GetAllComponents<IPressureProtection>())
{
multiplier *= protection.LowPressureMultiplier;
}
}
}
return multiplier;
}
}
public override float WalkSpeedModifier
{
get