GodotIdeMetadata.cs 1.3 KB

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