RectI.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.InteropServices;
  5. using System.Text;
  6. namespace BansheeEngine
  7. {
  8. [StructLayout(LayoutKind.Sequential)]
  9. public class RectI
  10. {
  11. public RectI(int x, int y, int width, int height)
  12. {
  13. this.x = x;
  14. this.y = y;
  15. this.width = width;
  16. this.height = height;
  17. }
  18. public static bool operator== (RectI lhs, RectI rhs)
  19. {
  20. return lhs.x == rhs.x && lhs.y == rhs.y && lhs.width == rhs.width && lhs.height == rhs.height;
  21. }
  22. public static bool operator!= (RectI lhs, RectI rhs)
  23. {
  24. return !(lhs == rhs);
  25. }
  26. public override int GetHashCode()
  27. {
  28. int hash = 23;
  29. hash = hash * 31 + x.GetHashCode();
  30. hash = hash * 31 + y.GetHashCode();
  31. hash = hash * 31 + width.GetHashCode();
  32. hash = hash * 31 + height.GetHashCode();
  33. return hash;
  34. }
  35. public override bool Equals(object other)
  36. {
  37. if (!(other is RectI))
  38. return false;
  39. RectI rect = (RectI)other;
  40. if (x.Equals(rect.x) && y.Equals(rect.y) && width.Equals(rect.width) && height.Equals(rect.height))
  41. return true;
  42. return false;
  43. }
  44. int x, y, width, height;
  45. }
  46. }