CurrencyComponent.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233
  1. using Content.Shared.FixedPoint;
  2. using Content.Shared.Store;
  3. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary;
  4. namespace Content.Server.Store.Components;
  5. /// <summary>
  6. /// Identifies a component that can be inserted into a store
  7. /// to increase its balance.
  8. /// </summary>
  9. /// <remarks>
  10. /// Note that if this entity is a stack of items, then this is meant to represent the value per stack item, not
  11. /// the whole stack. This also means that in general, the actual value should not be modified from the initial
  12. /// prototype value because otherwise stack merging/splitting may modify the total value.
  13. /// </remarks>
  14. [RegisterComponent]
  15. public sealed partial class CurrencyComponent : Component
  16. {
  17. /// <summary>
  18. /// The value of the currency.
  19. /// The string is the currency type that will be added.
  20. /// The FixedPoint2 is the value of each individual currency entity.
  21. /// </summary>
  22. /// <remarks>
  23. /// Note that if this entity is a stack of items, then this is meant to represent the value per stack item, not
  24. /// the whole stack. This also means that in general, the actual value should not be modified from the initial
  25. /// prototype value
  26. /// because otherwise stack merging/splitting may modify the total value.
  27. /// </remarks>
  28. [ViewVariables(VVAccess.ReadWrite)]
  29. [DataField("price", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<FixedPoint2, CurrencyPrototype>))]
  30. public Dictionary<string, FixedPoint2> Price = new();
  31. }