ItemStorageLocation.cs 992 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using Robust.Shared.Serialization;
  2. namespace Content.Shared.Storage;
  3. [DataDefinition, Serializable, NetSerializable]
  4. public partial record struct ItemStorageLocation
  5. {
  6. /// <summary>
  7. /// The rotation, stored a cardinal direction in order to reduce rounding errors.
  8. /// </summary>
  9. [DataField("_rotation")]
  10. public Direction Direction;
  11. /// <summary>
  12. /// The rotation of the piece in storage.
  13. /// </summary>
  14. public Angle Rotation
  15. {
  16. get => Direction.ToAngle();
  17. set => Direction = value.GetCardinalDir();
  18. }
  19. /// <summary>
  20. /// Where the item is located in storage.
  21. /// </summary>
  22. [DataField]
  23. public Vector2i Position;
  24. public ItemStorageLocation(Angle rotation, Vector2i position)
  25. {
  26. Rotation = rotation;
  27. Position = position;
  28. }
  29. public bool Equals(ItemStorageLocation? other)
  30. {
  31. return Rotation == other?.Rotation &&
  32. Position == other.Value.Position;
  33. }
  34. };