* fix engine version * actually fix engine version * Automatically activated breathing masks * weh * who needed that component anyway * check if internals are already running * Update Content.Server/Atmos/Components/BreathToolComponent.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Update Content.Server/Body/Systems/InternalsSystem.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * prediction * record struct event * remove delayed activation, instead ensure that masks spawn last * leftover * engine version * re-implement --------- Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
119 lines
4.6 KiB
C#
119 lines
4.6 KiB
C#
using Content.Shared.Hands.Components;
|
|
using Content.Shared.Hands.EntitySystems;
|
|
using Content.Shared.Inventory;
|
|
using Content.Shared.Roles;
|
|
using Content.Shared.Storage;
|
|
using Content.Shared.Storage.EntitySystems;
|
|
using Robust.Shared.Collections;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Shared.Station;
|
|
|
|
public abstract class SharedStationSpawningSystem : EntitySystem
|
|
{
|
|
[Dependency] protected readonly IPrototypeManager PrototypeManager = default!;
|
|
[Dependency] protected readonly InventorySystem InventorySystem = default!;
|
|
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
|
[Dependency] private readonly SharedStorageSystem _storage = default!;
|
|
[Dependency] private readonly SharedTransformSystem _xformSystem = default!;
|
|
|
|
private EntityQuery<HandsComponent> _handsQuery;
|
|
private EntityQuery<InventoryComponent> _inventoryQuery;
|
|
private EntityQuery<StorageComponent> _storageQuery;
|
|
private EntityQuery<TransformComponent> _xformQuery;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
_handsQuery = GetEntityQuery<HandsComponent>();
|
|
_inventoryQuery = GetEntityQuery<InventoryComponent>();
|
|
_storageQuery = GetEntityQuery<StorageComponent>();
|
|
_xformQuery = GetEntityQuery<TransformComponent>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// <see cref="EquipStartingGear(Robust.Shared.GameObjects.EntityUid,System.Nullable{Robust.Shared.Prototypes.ProtoId{Content.Shared.Roles.StartingGearPrototype}},bool)"/>
|
|
/// </summary>
|
|
public void EquipStartingGear(EntityUid entity, ProtoId<StartingGearPrototype>? startingGear, bool raiseEvent = true)
|
|
{
|
|
PrototypeManager.TryIndex(startingGear, out var gearProto);
|
|
EquipStartingGear(entity, gearProto);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Equips starting gear onto the given entity.
|
|
/// </summary>
|
|
/// <param name="entity">Entity to load out.</param>
|
|
/// <param name="startingGear">Starting gear to use.</param>
|
|
/// <param name="raiseEvent">Should we raise the event for equipped. Set to false if you will call this manually</param>
|
|
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)
|
|
{
|
|
var equipmentStr = startingGear.GetGear(slot.Name);
|
|
if (!string.IsNullOrEmpty(equipmentStr))
|
|
{
|
|
var equipmentEntity = EntityManager.SpawnEntity(equipmentStr, xform.Coordinates);
|
|
InventorySystem.TryEquip(entity, equipmentEntity, slot.Name, silent: true, force:true);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (_handsQuery.TryComp(entity, out var handsComponent))
|
|
{
|
|
var inhand = startingGear.Inhand;
|
|
var coords = xform.Coordinates;
|
|
foreach (var prototype in inhand)
|
|
{
|
|
var inhandEntity = EntityManager.SpawnEntity(prototype, coords);
|
|
|
|
if (_handsSystem.TryGetEmptyHand(entity, out var emptyHand, handsComponent))
|
|
{
|
|
_handsSystem.TryPickup(entity, inhandEntity, emptyHand, checkActionBlocker: false, handsComp: handsComponent);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (startingGear.Storage.Count > 0)
|
|
{
|
|
var coords = _xformSystem.GetMapCoordinates(entity);
|
|
var ents = new ValueList<EntityUid>();
|
|
_inventoryQuery.TryComp(entity, out var inventoryComp);
|
|
|
|
foreach (var (slot, entProtos) in startingGear.Storage)
|
|
{
|
|
if (entProtos.Count == 0)
|
|
continue;
|
|
|
|
foreach (var ent in entProtos)
|
|
{
|
|
ents.Add(Spawn(ent, coords));
|
|
}
|
|
|
|
if (inventoryComp != null &&
|
|
InventorySystem.TryGetSlotEntity(entity, slot, out var slotEnt, inventoryComponent: inventoryComp) &&
|
|
_storageQuery.TryComp(slotEnt, out var storage))
|
|
{
|
|
foreach (var ent in ents)
|
|
{
|
|
_storage.Insert(slotEnt.Value, ent, out _, storageComp: storage, playSound: false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (raiseEvent)
|
|
{
|
|
var ev = new StartingGearEquippedEvent(entity);
|
|
RaiseLocalEvent(entity, ref ev, true);
|
|
}
|
|
}
|
|
}
|