StartingGearPrototype.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using Robust.Shared.Prototypes;
  2. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Array;
  3. namespace Content.Shared.Roles;
  4. [Prototype]
  5. public sealed partial class StartingGearPrototype : IPrototype, IInheritingPrototype, IEquipmentLoadout
  6. {
  7. /// <inheritdoc/>
  8. [ViewVariables]
  9. [IdDataField]
  10. public string ID { get; private set; } = string.Empty;
  11. /// <inheritdoc/>
  12. [ParentDataField(typeof(AbstractPrototypeIdArraySerializer<StartingGearPrototype>))]
  13. public string[]? Parents { get; private set; }
  14. /// <inheritdoc/>
  15. [AbstractDataField]
  16. public bool Abstract { get; private set; }
  17. /// <inheritdoc />
  18. [DataField]
  19. [AlwaysPushInheritance]
  20. public Dictionary<string, EntProtoId> Equipment { get; set; } = new();
  21. /// <inheritdoc />
  22. [DataField]
  23. [AlwaysPushInheritance]
  24. public List<EntProtoId> Inhand { get; set; } = new();
  25. /// <inheritdoc />
  26. [DataField]
  27. [AlwaysPushInheritance]
  28. public Dictionary<string, List<EntProtoId>> Storage { get; set; } = new();
  29. }
  30. /// <summary>
  31. /// Specifies the starting entity prototypes and where to equip them for the specified class.
  32. /// </summary>
  33. public interface IEquipmentLoadout
  34. {
  35. /// <summary>
  36. /// The slot and entity prototype ID of the equipment that is to be spawned and equipped onto the entity.
  37. /// </summary>
  38. public Dictionary<string, EntProtoId> Equipment { get; set; }
  39. /// <summary>
  40. /// The inhand items that are equipped when this starting gear is equipped onto an entity.
  41. /// </summary>
  42. public List<EntProtoId> Inhand { get; set; }
  43. /// <summary>
  44. /// Inserts entities into the specified slot's storage (if it does have storage).
  45. /// </summary>
  46. public Dictionary<string, List<EntProtoId>> Storage { get; set; }
  47. /// <summary>
  48. /// Gets the entity prototype ID of a slot in this starting gear.
  49. /// </summary>
  50. public string GetGear(string slot)
  51. {
  52. return Equipment.TryGetValue(slot, out var equipment) ? equipment : string.Empty;
  53. }
  54. }