diff --git a/Content.Client/Station/StationSpawningSystem.cs b/Content.Client/Station/StationSpawningSystem.cs
index 65da518d22..71dce5a78f 100644
--- a/Content.Client/Station/StationSpawningSystem.cs
+++ b/Content.Client/Station/StationSpawningSystem.cs
@@ -2,7 +2,4 @@ using Content.Shared.Station;
namespace Content.Client.Station;
-public sealed class StationSpawningSystem : SharedStationSpawningSystem
-{
-
-}
+public sealed class StationSpawningSystem : SharedStationSpawningSystem;
diff --git a/Content.Server/Atmos/Components/BreathToolComponent.cs b/Content.Server/Atmos/Components/BreathToolComponent.cs
index f3688ef7ff..ae17a5d872 100644
--- a/Content.Server/Atmos/Components/BreathToolComponent.cs
+++ b/Content.Server/Atmos/Components/BreathToolComponent.cs
@@ -12,9 +12,10 @@ namespace Content.Server.Atmos.Components
///
/// Tool is functional only in allowed slots
///
- [DataField("allowedSlots")]
+ [DataField]
public SlotFlags AllowedSlots = SlotFlags.MASK | SlotFlags.HEAD;
public bool IsFunctional;
+
public EntityUid? ConnectedInternalsEntity;
}
}
diff --git a/Content.Server/Body/Systems/InternalsSystem.cs b/Content.Server/Body/Systems/InternalsSystem.cs
index 972967fb15..8afd1c767f 100644
--- a/Content.Server/Body/Systems/InternalsSystem.cs
+++ b/Content.Server/Body/Systems/InternalsSystem.cs
@@ -8,6 +8,7 @@ using Content.Shared.DoAfter;
using Content.Shared.Hands.Components;
using Content.Shared.Internals;
using Content.Shared.Inventory;
+using Content.Shared.Roles;
using Content.Shared.Verbs;
using Robust.Shared.Containers;
using Robust.Shared.Utility;
@@ -23,17 +24,29 @@ public sealed class InternalsSystem : EntitySystem
[Dependency] private readonly InventorySystem _inventory = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
- public const SlotFlags InventorySlots = SlotFlags.POCKET | SlotFlags.BELT;
+ private EntityQuery _internalsQuery;
public override void Initialize()
{
base.Initialize();
+ _internalsQuery = GetEntityQuery();
+
SubscribeLocalEvent(OnInhaleLocation);
SubscribeLocalEvent(OnInternalsStartup);
SubscribeLocalEvent(OnInternalsShutdown);
SubscribeLocalEvent>(OnGetInteractionVerbs);
SubscribeLocalEvent(OnDoAfter);
+
+ SubscribeLocalEvent(OnStartingGear);
+ }
+
+ private void OnStartingGear(ref StartingGearEquippedEvent ev)
+ {
+ if (!_internalsQuery.TryComp(ev.Entity, out var internals) || internals.BreathToolEntity == null)
+ return;
+
+ ToggleInternals(ev.Entity, ev.Entity, force: false, internals);
}
private void OnGetInteractionVerbs(
@@ -217,7 +230,7 @@ public sealed class InternalsSystem : EntitySystem
if (component.BreathToolEntity is null || !AreInternalsWorking(component))
return 2;
- // If pressure in the tank is below low pressure threshhold, flash warning on internals UI
+ // If pressure in the tank is below low pressure threshold, flash warning on internals UI
if (TryComp(component.GasTankEntity, out var gasTank)
&& gasTank.IsLowPressure)
{
diff --git a/Content.Server/Station/Systems/StationSpawningSystem.cs b/Content.Server/Station/Systems/StationSpawningSystem.cs
index f8bd297905..6826dedf83 100644
--- a/Content.Server/Station/Systems/StationSpawningSystem.cs
+++ b/Content.Server/Station/Systems/StationSpawningSystem.cs
@@ -59,6 +59,7 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem
///
public override void Initialize()
{
+ base.Initialize();
Subs.CVar(_configurationManager, CCVars.ICRandomCharacters, e => _randomizeCharacters = e, true);
_spawnerCallbacks = new Dictionary>()
@@ -181,7 +182,7 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem
if (prototype?.StartingGear != null)
{
var startingGear = _prototypeManager.Index(prototype.StartingGear);
- EquipStartingGear(entity.Value, startingGear);
+ EquipStartingGear(entity.Value, startingGear, raiseEvent: false);
}
// Run loadouts after so stuff like storage loadouts can get
@@ -217,11 +218,14 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem
}
// Handle any extra data here.
- EquipStartingGear(entity.Value, startingGear);
+ EquipStartingGear(entity.Value, startingGear, raiseEvent: false);
}
}
}
+ var gearEquippedEv = new StartingGearEquippedEvent(entity.Value);
+ RaiseLocalEvent(entity.Value, ref gearEquippedEv, true);
+
if (profile != null)
{
if (prototype != null)
diff --git a/Content.Shared/Inventory/InventorySystem.Slots.cs b/Content.Shared/Inventory/InventorySystem.Slots.cs
index 1da44155b9..e0f2a69557 100644
--- a/Content.Shared/Inventory/InventorySystem.Slots.cs
+++ b/Content.Shared/Inventory/InventorySystem.Slots.cs
@@ -151,7 +151,6 @@ public partial class InventorySystem : EntitySystem
slotDefinitions = null;
return false;
}
-
slotDefinitions = inv.Slots;
return true;
}
diff --git a/Content.Shared/Roles/StartingGearEquippedEvent.cs b/Content.Shared/Roles/StartingGearEquippedEvent.cs
new file mode 100644
index 0000000000..41b6caccff
--- /dev/null
+++ b/Content.Shared/Roles/StartingGearEquippedEvent.cs
@@ -0,0 +1,10 @@
+namespace Content.Shared.Roles;
+
+///
+/// Raised directed on an entity when a new starting gear prototype has been equipped.
+///
+[ByRefEvent]
+public record struct StartingGearEquippedEvent(EntityUid Entity)
+{
+ public readonly EntityUid Entity = Entity;
+}
diff --git a/Content.Shared/Station/SharedStationSpawningSystem.cs b/Content.Shared/Station/SharedStationSpawningSystem.cs
index 363fb3f91e..8a063938ee 100644
--- a/Content.Shared/Station/SharedStationSpawningSystem.cs
+++ b/Content.Shared/Station/SharedStationSpawningSystem.cs
@@ -17,12 +17,24 @@ public abstract class SharedStationSpawningSystem : EntitySystem
[Dependency] private readonly SharedStorageSystem _storage = default!;
[Dependency] private readonly SharedTransformSystem _xformSystem = default!;
+ private EntityQuery _handsQuery;
+ private EntityQuery _inventoryQuery;
+ private EntityQuery _storageQuery;
+ private EntityQuery _xformQuery;
+
+ public override void Initialize()
+ {
+ base.Initialize();
+ _handsQuery = GetEntityQuery();
+ _inventoryQuery = GetEntityQuery();
+ _storageQuery = GetEntityQuery();
+ _xformQuery = GetEntityQuery();
+ }
+
///
- /// Equips starting gear onto the given entity.
+ ///
///
- /// Entity to load out.
- /// Starting gear to use.
- public void EquipStartingGear(EntityUid entity, ProtoId? startingGear)
+ public void EquipStartingGear(EntityUid entity, ProtoId? startingGear, bool raiseEvent = true)
{
PrototypeManager.TryIndex(startingGear, out var gearProto);
EquipStartingGear(entity, gearProto);
@@ -33,11 +45,14 @@ public abstract class SharedStationSpawningSystem : EntitySystem
///
/// Entity to load out.
/// Starting gear to use.
- public void EquipStartingGear(EntityUid entity, StartingGearPrototype? startingGear)
+ /// Should we raise the event for equipped. Set to false if you will call this manually
+ public void EquipStartingGear(EntityUid entity, StartingGearPrototype? startingGear, bool raiseEvent = true)
{
if (startingGear == null)
return;
+ var xform = _xformQuery.GetComponent(entity);
+
if (InventorySystem.TryGetSlots(entity, out var slotDefinitions))
{
foreach (var slot in slotDefinitions)
@@ -45,16 +60,16 @@ public abstract class SharedStationSpawningSystem : EntitySystem
var equipmentStr = startingGear.GetGear(slot.Name);
if (!string.IsNullOrEmpty(equipmentStr))
{
- var equipmentEntity = EntityManager.SpawnEntity(equipmentStr, EntityManager.GetComponent(entity).Coordinates);
+ var equipmentEntity = EntityManager.SpawnEntity(equipmentStr, xform.Coordinates);
InventorySystem.TryEquip(entity, equipmentEntity, slot.Name, silent: true, force:true);
}
}
}
- if (TryComp(entity, out HandsComponent? handsComponent))
+ if (_handsQuery.TryComp(entity, out var handsComponent))
{
var inhand = startingGear.Inhand;
- var coords = EntityManager.GetComponent(entity).Coordinates;
+ var coords = xform.Coordinates;
foreach (var prototype in inhand)
{
var inhandEntity = EntityManager.SpawnEntity(prototype, coords);
@@ -70,7 +85,7 @@ public abstract class SharedStationSpawningSystem : EntitySystem
{
var coords = _xformSystem.GetMapCoordinates(entity);
var ents = new ValueList();
- TryComp(entity, out InventoryComponent? inventoryComp);
+ _inventoryQuery.TryComp(entity, out var inventoryComp);
foreach (var (slot, entProtos) in startingGear.Storage)
{
@@ -84,7 +99,7 @@ public abstract class SharedStationSpawningSystem : EntitySystem
if (inventoryComp != null &&
InventorySystem.TryGetSlotEntity(entity, slot, out var slotEnt, inventoryComponent: inventoryComp) &&
- TryComp(slotEnt, out StorageComponent? storage))
+ _storageQuery.TryComp(slotEnt, out var storage))
{
foreach (var ent in ents)
{
@@ -93,5 +108,11 @@ public abstract class SharedStationSpawningSystem : EntitySystem
}
}
}
+
+ if (raiseEvent)
+ {
+ var ev = new StartingGearEquippedEvent(entity);
+ RaiseLocalEvent(entity, ref ev, true);
+ }
}
}