| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- // Point3.cs
- //
- // Modified MIT License (MIT)
- //
- // Copyright (c) 2015 Completely Fair Games Ltd.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the "Software"), to deal
- // in the Software without restriction, including without limitation the rights
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- // copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // The following content pieces are considered PROPRIETARY and may not be used
- // in any derivative works, commercial or non commercial, without explicit
- // written permission from Completely Fair Games:
- //
- // * Images (sprites, textures, etc.)
- // * 3D Models
- // * Sound Effects
- // * Music
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- // THE SOFTWARE.
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Security.Cryptography.X509Certificates;
- using System.Text;
- using Microsoft.Xna.Framework;
- namespace DwarfCorp
- {
- public struct Point3 : IEquatable<Point3>
- {
- public int X;
- public int Y;
- public int Z;
- public static readonly Point3 Zero = new Point3(0, 0, 0);
- public Point3(int x, int y, int z)
- {
- X = x;
- Y = y;
- Z = z;
- }
- public override int GetHashCode()
- {
- const int p1 = 4273;
- const int p2 = 6247;
- return (X * p1 + Y) * p2 + Z;
- }
- public bool Equals(Point3 other)
- {
- return other.X == X && other.Y == Y && other.Z == Z;
- }
- public override bool Equals(object obj)
- {
- if(!(obj is Point3))
- {
- return false;
- }
- Point3 other = (Point3) obj;
- return other.X == X && other.Y == Y && other.Z == Z;
- }
- public static Point3 operator +(Point3 toAdd1, Point3 toAdd2)
- {
- return new Point3(toAdd1.X + toAdd2.X, toAdd1.Y + toAdd2.Y, toAdd1.Z + toAdd2.Z);
- }
- public Vector3 ToVector3()
- {
- return new Vector3(X, Y, Z);
- }
- public override string ToString()
- {
- return String.Format("{{{0}, {1}, {2}}}", X, Y, Z);
- }
- }
- }
|