StationRecordKey.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. namespace Content.Shared.StationRecords;
  2. /// <summary>
  3. /// Station record keys. These should be stored somewhere,
  4. /// preferably within an ID card.
  5. /// This refers to both the id and station. This is suitable for an access reader field etc,
  6. /// but when you already know the station just store the id itself.
  7. /// </summary>
  8. public readonly struct StationRecordKey : IEquatable<StationRecordKey>
  9. {
  10. [DataField]
  11. public readonly uint Id;
  12. [DataField("station")]
  13. public readonly EntityUid OriginStation;
  14. public static StationRecordKey Invalid = default;
  15. public StationRecordKey(uint id, EntityUid originStation)
  16. {
  17. Id = id;
  18. OriginStation = originStation;
  19. }
  20. public bool Equals(StationRecordKey other)
  21. {
  22. return Id == other.Id && OriginStation.Id == other.OriginStation.Id;
  23. }
  24. public override bool Equals(object? obj)
  25. {
  26. return obj is StationRecordKey other && Equals(other);
  27. }
  28. public override int GetHashCode()
  29. {
  30. return HashCode.Combine(Id, OriginStation);
  31. }
  32. public bool IsValid() => OriginStation.IsValid();
  33. }