TeamType.cs (4329B)
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 MobiusEditor.Interface; 16 using System; 17 using System.Collections.Generic; 18 using System.Linq; 19 20 namespace MobiusEditor.Model 21 { 22 public class TeamTypeClass : ICloneable 23 { 24 public ITechnoType Type { get; set; } 25 26 public byte Count { get; set; } 27 28 public TeamTypeClass Clone() 29 { 30 return new TeamTypeClass() 31 { 32 Type = Type, 33 Count = Count 34 }; 35 } 36 37 object ICloneable.Clone() 38 { 39 return Clone(); 40 } 41 } 42 43 public class TeamTypeMission : ICloneable 44 { 45 public string Mission { get; set; } 46 47 public int Argument { get; set; } 48 49 public TeamTypeMission Clone() 50 { 51 return new TeamTypeMission() 52 { 53 Mission = Mission, 54 Argument = Argument 55 }; 56 } 57 58 object ICloneable.Clone() 59 { 60 return Clone(); 61 } 62 } 63 64 public class TeamType : INamedType, ICloneable 65 { 66 public static readonly string None = "None"; 67 68 public string Name { get; set; } 69 70 public HouseType House { get; set; } 71 72 public bool IsRoundAbout { get; set; } 73 74 public bool IsLearning { get; set; } 75 76 public bool IsSuicide { get; set; } 77 78 public bool IsAutocreate { get; set; } 79 80 public bool IsMercenary { get; set; } 81 82 public int RecruitPriority { get; set; } 83 84 public byte MaxAllowed { get; set; } 85 86 public byte InitNum { get; set; } 87 88 public byte Fear { get; set; } 89 90 public bool IsReinforcable { get; set; } 91 92 public bool IsPrebuilt { get; set; } 93 94 public int Origin { get; set; } 95 96 public string Trigger { get; set; } = Model.Trigger.None; 97 98 public List<TeamTypeClass> Classes { get; } = new List<TeamTypeClass>(); 99 100 public List<TeamTypeMission> Missions { get; } = new List<TeamTypeMission>(); 101 102 public TeamType Clone() 103 { 104 var teamType = new TeamType() 105 { 106 Name = Name, 107 House = House, 108 IsRoundAbout = IsRoundAbout, 109 IsLearning = IsLearning, 110 IsSuicide = IsSuicide, 111 IsAutocreate = IsAutocreate, 112 IsMercenary = IsMercenary, 113 RecruitPriority = RecruitPriority, 114 MaxAllowed = MaxAllowed, 115 InitNum = InitNum, 116 Fear = Fear, 117 IsReinforcable = IsReinforcable, 118 IsPrebuilt = IsPrebuilt, 119 Origin = Origin, 120 Trigger = Trigger 121 }; 122 123 teamType.Classes.AddRange(Classes.Select(c => c.Clone())); 124 teamType.Missions.AddRange(Missions.Select(m => m.Clone())); 125 126 return teamType; 127 } 128 129 public override bool Equals(object obj) 130 { 131 if (obj is TeamType) 132 { 133 return this == obj; 134 } 135 else if (obj is string) 136 { 137 return string.Equals(Name, obj as string, StringComparison.OrdinalIgnoreCase); 138 } 139 140 return base.Equals(obj); 141 } 142 143 public override int GetHashCode() 144 { 145 return Name.GetHashCode(); 146 } 147 148 public override string ToString() 149 { 150 return Name; 151 } 152 153 object ICloneable.Clone() 154 { 155 return Clone(); 156 } 157 } 158 }