MarkingPoints.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using Robust.Shared.Prototypes;
  2. using Robust.Shared.Serialization;
  3. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
  4. namespace Content.Shared.Humanoid.Markings;
  5. [DataDefinition]
  6. [Serializable, NetSerializable]
  7. public sealed partial class MarkingPoints
  8. {
  9. [DataField("points", required: true)]
  10. public int Points = 0;
  11. [DataField("required", required: true)]
  12. public bool Required = false;
  13. // Default markings for this layer.
  14. [DataField("defaultMarkings", customTypeSerializer:typeof(PrototypeIdListSerializer<MarkingPrototype>))]
  15. public List<string> DefaultMarkings = new();
  16. public static Dictionary<MarkingCategories, MarkingPoints> CloneMarkingPointDictionary(Dictionary<MarkingCategories, MarkingPoints> self)
  17. {
  18. var clone = new Dictionary<MarkingCategories, MarkingPoints>();
  19. foreach (var (category, points) in self)
  20. {
  21. clone[category] = new MarkingPoints()
  22. {
  23. Points = points.Points,
  24. Required = points.Required,
  25. DefaultMarkings = points.DefaultMarkings
  26. };
  27. }
  28. return clone;
  29. }
  30. }
  31. [Prototype]
  32. public sealed partial class MarkingPointsPrototype : IPrototype
  33. {
  34. [IdDataField] public string ID { get; private set; } = default!;
  35. /// <summary>
  36. /// If the user of this marking point set is only allowed to
  37. /// use whitelisted markings, and not globally usable markings.
  38. /// Only used for validation and profile construction. Ignored anywhere else.
  39. /// </summary>
  40. [DataField("onlyWhitelisted")] public bool OnlyWhitelisted;
  41. [DataField("points", required: true)]
  42. public Dictionary<MarkingCategories, MarkingPoints> Points { get; private set; } = default!;
  43. }