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:
metalgearsloth
2024-08-05 14:42:25 +10:00
committed by GitHub
parent 6264a557a6
commit 9a8620d9d8
47 changed files with 173 additions and 1641 deletions

View File

@@ -4,7 +4,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
namespace Content.Shared.Roles;
[Prototype]
public sealed partial class StartingGearPrototype : IPrototype, IInheritingPrototype
public sealed partial class StartingGearPrototype : IPrototype, IInheritingPrototype, IEquipmentLoadout
{
/// <inheritdoc/>
[ViewVariables]
@@ -19,26 +19,41 @@ public sealed partial class StartingGearPrototype : IPrototype, IInheritingProto
[AbstractDataField]
public bool Abstract { get; }
/// <inheritdoc />
[DataField]
[AlwaysPushInheritance]
public Dictionary<string, EntProtoId> Equipment { get; set; } = new();
/// <inheritdoc />
[DataField]
[AlwaysPushInheritance]
public List<EntProtoId> Inhand { get; set; } = new();
/// <inheritdoc />
[DataField]
[AlwaysPushInheritance]
public Dictionary<string, List<EntProtoId>> Storage { get; set; } = new();
}
/// <summary>
/// Specifies the starting entity prototypes and where to equip them for the specified class.
/// </summary>
public interface IEquipmentLoadout
{
/// <summary>
/// The slot and entity prototype ID of the equipment that is to be spawned and equipped onto the entity.
/// </summary>
[DataField]
[AlwaysPushInheritance]
public Dictionary<string, EntProtoId> Equipment = new();
public Dictionary<string, EntProtoId> Equipment { get; set; }
/// <summary>
/// The inhand items that are equipped when this starting gear is equipped onto an entity.
/// </summary>
[DataField]
[AlwaysPushInheritance]
public List<EntProtoId> Inhand = new(0);
public List<EntProtoId> Inhand { get; set; }
/// <summary>
/// Inserts entities into the specified slot's storage (if it does have storage).
/// </summary>
[DataField]
[AlwaysPushInheritance]
public Dictionary<string, List<EntProtoId>> Storage = new();
public Dictionary<string, List<EntProtoId>> Storage { get; set; }
/// <summary>
/// Gets the entity prototype ID of a slot in this starting gear.