DirectionType.cs (2147B)
1 // 2 // Copyright 2020 Electronic Arts Inc. 3 // 4 // The Command & Conquer Map Editor and corresponding source code is free 5 // software: you can redistribute it and/or modify it under the terms of 6 // the GNU General Public License as published by the Free Software Foundation, 7 // either version 3 of the License, or (at your option) any later version. 8 9 // The Command & Conquer Map Editor and corresponding source code is distributed 10 // in the hope that it will be useful, but with permitted additional restrictions 11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 12 // distributed with this program. You should have received a copy of the 13 // GNU General Public License along with permitted additional restrictions 14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection 15 using System; 16 17 namespace MobiusEditor.Model 18 { 19 public class DirectionType 20 { 21 public byte ID { get; private set; } 22 23 public string Name { get; private set; } 24 25 public FacingType Facing { get; private set; } 26 27 public DirectionType(byte id, string name, FacingType facing) 28 { 29 ID = id; 30 Name = name; 31 Facing = facing; 32 } 33 34 public DirectionType(byte id, string name) 35 : this(id, name, FacingType.None) 36 { 37 } 38 39 public override bool Equals(object obj) 40 { 41 if (obj is DirectionType) 42 { 43 return this == obj; 44 } 45 else if (obj is byte) 46 { 47 return ID == (byte)obj; 48 } 49 else if (obj is string) 50 { 51 return string.Equals(Name, obj as string, StringComparison.OrdinalIgnoreCase); 52 } 53 else if (obj is FacingType) 54 { 55 return Facing == (FacingType)obj; 56 } 57 58 return base.Equals(obj); 59 } 60 61 public override int GetHashCode() 62 { 63 return ID.GetHashCode(); 64 } 65 66 public override string ToString() 67 { 68 return Name; 69 } 70 } 71 }