Guest User

Untitled

a guest
May 28th, 2018
1,086
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5.  
  6. public struct Vector3Int : IEquatable<Vector3Int> {
  7.  
  8.     public int x, y, z;
  9.  
  10.     public Vector3Int(int x, int y, int z){
  11.         this.x = x;
  12.         this.y = y;
  13.         this.z = z;
  14.     }
  15.  
  16.     #region IEquatable implementation
  17.  
  18.     public bool Equals(Vector3Int other)
  19.     {
  20.         return other.x == this.x && other.y == this.y && other.z == this.z;
  21.     }
  22.  
  23.     #endregion
  24.  
  25.     public override bool Equals(object obj){
  26.         if (obj == null || !(obj is Vector3Int))
  27.         {
  28.             return false;
  29.         }
  30.  
  31.         return Equals((Vector3Int)obj);
  32.     }
  33.  
  34.     public override int GetHashCode(){
  35.         return x ^ (y << 10) ^ (z << 10);
  36.     }
  37.  
  38.     public override string ToString()
  39.     {
  40.         return string.Format("(" + x + ", " + y + "," + z + ")");
  41.     }
  42.  
  43.     public static bool operator ==(Vector3Int a, Vector3Int b){
  44.         return a.Equals(b);
  45.     }
  46.  
  47.     public static bool operator !=(Vector3Int a, Vector3Int b){
  48.         return !(a == b);
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment