GodotIdeMetadata.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System.Diagnostics.CodeAnalysis;
  2. namespace GodotTools.IdeMessaging
  3. {
  4. public readonly struct GodotIdeMetadata
  5. {
  6. public int Port { get; }
  7. public string EditorExecutablePath { get; }
  8. public const string DefaultFileName = "ide_messaging_meta.txt";
  9. public GodotIdeMetadata(int port, string editorExecutablePath)
  10. {
  11. Port = port;
  12. EditorExecutablePath = editorExecutablePath;
  13. }
  14. public static bool operator ==(GodotIdeMetadata a, GodotIdeMetadata b)
  15. {
  16. return a.Port == b.Port && a.EditorExecutablePath == b.EditorExecutablePath;
  17. }
  18. public static bool operator !=(GodotIdeMetadata a, GodotIdeMetadata b)
  19. {
  20. return !(a == b);
  21. }
  22. public override bool Equals([NotNullWhen(true)] object? obj)
  23. {
  24. return obj is GodotIdeMetadata metadata && metadata == this;
  25. }
  26. public bool Equals(GodotIdeMetadata other)
  27. {
  28. return Port == other.Port && EditorExecutablePath == other.EditorExecutablePath;
  29. }
  30. public override int GetHashCode()
  31. {
  32. unchecked
  33. {
  34. return (Port * 397) ^ (EditorExecutablePath != null ? EditorExecutablePath.GetHashCode() : 0);
  35. }
  36. }
  37. }
  38. }