BlockState.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace MineCase.Block
  5. {
  6. public struct BlockState : IEquatable<BlockState>
  7. {
  8. public uint Id { get; set; }
  9. public uint MetaValue { get; set; }
  10. public bool IsId(BlockId id)
  11. {
  12. return Id == (uint)id;
  13. }
  14. public bool IsSameId(BlockState other)
  15. {
  16. return Id == other.Id;
  17. }
  18. public override bool Equals(object obj)
  19. {
  20. return obj is BlockState && Equals((BlockState)obj);
  21. }
  22. public bool Equals(BlockState other)
  23. {
  24. return Id == other.Id &&
  25. MetaValue == other.MetaValue;
  26. }
  27. public override int GetHashCode()
  28. {
  29. var hashCode = -81208087;
  30. hashCode = hashCode * -1521134295 + base.GetHashCode();
  31. hashCode = hashCode * -1521134295 + Id.GetHashCode();
  32. hashCode = hashCode * -1521134295 + MetaValue.GetHashCode();
  33. return hashCode;
  34. }
  35. public static bool operator ==(BlockState state1, BlockState state2)
  36. {
  37. return state1.Equals(state2);
  38. }
  39. public static bool operator !=(BlockState state1, BlockState state2)
  40. {
  41. return !(state1 == state2);
  42. }
  43. }
  44. }