De-duplicate loadout gear (#30341)
* De-duplicate loadout gear Needs supporting code, probably with an interface with StartingGearPrototype which would also use it, but I regexed the yaml. * Code updates * Remaining yaml * Fix automatic naming * raiseEvent * Don't code when tired kids
This commit is contained in:
@@ -49,25 +49,32 @@ public abstract class SharedStationSpawningSystem : EntitySystem
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!PrototypeManager.TryIndex(loadoutProto.Equipment, out var startingGear))
|
||||
{
|
||||
Log.Error($"Unable to find starting gear {loadoutProto.Equipment} for loadout {loadoutProto}");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Handle any extra data here.
|
||||
EquipStartingGear(entity, startingGear, raiseEvent: false);
|
||||
EquipStartingGear(entity, loadoutProto, raiseEvent: false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void EquipStartingGear(EntityUid entity, LoadoutPrototype loadout, bool raiseEvent = true)
|
||||
{
|
||||
EquipStartingGear(entity, loadout.StartingGear, raiseEvent);
|
||||
EquipStartingGear(entity, (IEquipmentLoadout) loadout, raiseEvent);
|
||||
}
|
||||
|
||||
/// <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);
|
||||
EquipStartingGear(entity, gearProto, raiseEvent);
|
||||
}
|
||||
|
||||
/// <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, StartingGearPrototype? startingGear, bool raiseEvent = true)
|
||||
{
|
||||
EquipStartingGear(entity, (IEquipmentLoadout?) startingGear, raiseEvent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -76,7 +83,7 @@ public abstract class SharedStationSpawningSystem : EntitySystem
|
||||
/// <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)
|
||||
public void EquipStartingGear(EntityUid entity, IEquipmentLoadout? startingGear, bool raiseEvent = true)
|
||||
{
|
||||
if (startingGear == null)
|
||||
return;
|
||||
@@ -145,4 +152,4 @@ public abstract class SharedStationSpawningSystem : EntitySystem
|
||||
RaiseLocalEvent(entity, ref ev);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user