Inventory slot enumerator rejig (#21788)
This commit is contained in:
@@ -285,27 +285,7 @@ public sealed partial class AdminVerbSystem
|
||||
Text = "Refill Internals Oxygen",
|
||||
Category = VerbCategory.Tricks,
|
||||
Icon = new SpriteSpecifier.Rsi(new("/Textures/Objects/Tanks/oxygen.rsi"), "icon"),
|
||||
Act = () =>
|
||||
{
|
||||
foreach (var slot in _inventorySystem.GetSlots(args.Target))
|
||||
{
|
||||
if (!_inventorySystem.TryGetSlotEntity(args.Target, slot.Name, out var entity))
|
||||
continue;
|
||||
|
||||
if (!TryComp(entity, out tank))
|
||||
continue;
|
||||
|
||||
RefillGasTank(entity.Value, Gas.Oxygen, tank);
|
||||
}
|
||||
|
||||
foreach (var held in _handsSystem.EnumerateHeld(args.Target))
|
||||
{
|
||||
if (!TryComp(held, out tank))
|
||||
continue;
|
||||
|
||||
RefillGasTank(held, Gas.Oxygen, tank);
|
||||
}
|
||||
},
|
||||
Act = () => RefillEquippedTanks(args.User, Gas.Oxygen),
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = Loc.GetString("admin-trick-internals-refill-oxygen-description"),
|
||||
Priority = (int) TricksVerbPriorities.RefillOxygen,
|
||||
@@ -317,27 +297,7 @@ public sealed partial class AdminVerbSystem
|
||||
Text = "Refill Internals Nitrogen",
|
||||
Category = VerbCategory.Tricks,
|
||||
Icon = new SpriteSpecifier.Rsi(new("/Textures/Objects/Tanks/red.rsi"), "icon"),
|
||||
Act = () =>
|
||||
{
|
||||
foreach (var slot in _inventorySystem.GetSlots(args.Target))
|
||||
{
|
||||
if (!_inventorySystem.TryGetSlotEntity(args.Target, slot.Name, out var entity))
|
||||
continue;
|
||||
|
||||
if (!TryComp(entity, out tank))
|
||||
continue;
|
||||
|
||||
RefillGasTank(entity.Value, Gas.Nitrogen, tank);
|
||||
}
|
||||
|
||||
foreach (var held in _handsSystem.EnumerateHeld(args.Target))
|
||||
{
|
||||
if (!TryComp(held, out tank))
|
||||
continue;
|
||||
|
||||
RefillGasTank(held, Gas.Nitrogen, tank);
|
||||
}
|
||||
},
|
||||
Act = () =>RefillEquippedTanks(args.User, Gas.Nitrogen),
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = Loc.GetString("admin-trick-internals-refill-nitrogen-description"),
|
||||
Priority = (int) TricksVerbPriorities.RefillNitrogen,
|
||||
@@ -349,27 +309,7 @@ public sealed partial class AdminVerbSystem
|
||||
Text = "Refill Internals Plasma",
|
||||
Category = VerbCategory.Tricks,
|
||||
Icon = new SpriteSpecifier.Rsi(new("/Textures/Objects/Tanks/plasma.rsi"), "icon"),
|
||||
Act = () =>
|
||||
{
|
||||
foreach (var slot in _inventorySystem.GetSlots(args.Target))
|
||||
{
|
||||
if (!_inventorySystem.TryGetSlotEntity(args.Target, slot.Name, out var entity))
|
||||
continue;
|
||||
|
||||
if (!TryComp(entity, out tank))
|
||||
continue;
|
||||
|
||||
RefillGasTank(entity.Value, Gas.Plasma, tank);
|
||||
}
|
||||
|
||||
foreach (var held in _handsSystem.EnumerateHeld(args.Target))
|
||||
{
|
||||
if (!TryComp(held, out tank))
|
||||
continue;
|
||||
|
||||
RefillGasTank(held, Gas.Plasma, tank);
|
||||
}
|
||||
},
|
||||
Act = () => RefillEquippedTanks(args.User, Gas.Plasma),
|
||||
Impact = LogImpact.Extreme,
|
||||
Message = Loc.GetString("admin-trick-internals-refill-plasma-description"),
|
||||
Priority = (int) TricksVerbPriorities.RefillPlasma,
|
||||
@@ -792,9 +732,17 @@ public sealed partial class AdminVerbSystem
|
||||
}
|
||||
}
|
||||
|
||||
private void RefillGasTank(EntityUid tank, Gas gasType, GasTankComponent? tankComponent)
|
||||
private void RefillEquippedTanks(EntityUid target, Gas plasma)
|
||||
{
|
||||
if (!Resolve(tank, ref tankComponent))
|
||||
foreach (var held in _inventorySystem.GetHandOrInventoryEntities(target))
|
||||
{
|
||||
RefillGasTank(held, Gas.Plasma);
|
||||
}
|
||||
}
|
||||
|
||||
private void RefillGasTank(EntityUid tank, Gas gasType, GasTankComponent? tankComponent = null)
|
||||
{
|
||||
if (!Resolve(tank, ref tankComponent, false))
|
||||
return;
|
||||
|
||||
var mixSize = tankComponent.Air.Volume;
|
||||
|
||||
Reference in New Issue
Block a user