TeamType.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. // The Command & Conquer Map Editor and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. using MobiusEditor.Interface;
  15. using System;
  16. using System.Collections.Generic;
  17. using System.Linq;
  18. namespace MobiusEditor.Model
  19. {
  20. public class TeamTypeClass : ICloneable
  21. {
  22. public ITechnoType Type { get; set; }
  23. public byte Count { get; set; }
  24. public TeamTypeClass Clone()
  25. {
  26. return new TeamTypeClass()
  27. {
  28. Type = Type,
  29. Count = Count
  30. };
  31. }
  32. object ICloneable.Clone()
  33. {
  34. return Clone();
  35. }
  36. }
  37. public class TeamTypeMission : ICloneable
  38. {
  39. public string Mission { get; set; }
  40. public int Argument { get; set; }
  41. public TeamTypeMission Clone()
  42. {
  43. return new TeamTypeMission()
  44. {
  45. Mission = Mission,
  46. Argument = Argument
  47. };
  48. }
  49. object ICloneable.Clone()
  50. {
  51. return Clone();
  52. }
  53. }
  54. public class TeamType : INamedType, ICloneable
  55. {
  56. public static readonly string None = "None";
  57. public string Name { get; set; }
  58. public HouseType House { get; set; }
  59. public bool IsRoundAbout { get; set; }
  60. public bool IsLearning { get; set; }
  61. public bool IsSuicide { get; set; }
  62. public bool IsAutocreate { get; set; }
  63. public bool IsMercenary { get; set; }
  64. public int RecruitPriority { get; set; }
  65. public byte MaxAllowed { get; set; }
  66. public byte InitNum { get; set; }
  67. public byte Fear { get; set; }
  68. public bool IsReinforcable { get; set; }
  69. public bool IsPrebuilt { get; set; }
  70. public int Origin { get; set; }
  71. public string Trigger { get; set; } = Model.Trigger.None;
  72. public List<TeamTypeClass> Classes { get; } = new List<TeamTypeClass>();
  73. public List<TeamTypeMission> Missions { get; } = new List<TeamTypeMission>();
  74. public TeamType Clone()
  75. {
  76. var teamType = new TeamType()
  77. {
  78. Name = Name,
  79. House = House,
  80. IsRoundAbout = IsRoundAbout,
  81. IsLearning = IsLearning,
  82. IsSuicide = IsSuicide,
  83. IsAutocreate = IsAutocreate,
  84. IsMercenary = IsMercenary,
  85. RecruitPriority = RecruitPriority,
  86. MaxAllowed = MaxAllowed,
  87. InitNum = InitNum,
  88. Fear = Fear,
  89. IsReinforcable = IsReinforcable,
  90. IsPrebuilt = IsPrebuilt,
  91. Origin = Origin,
  92. Trigger = Trigger
  93. };
  94. teamType.Classes.AddRange(Classes.Select(c => c.Clone()));
  95. teamType.Missions.AddRange(Missions.Select(m => m.Clone()));
  96. return teamType;
  97. }
  98. public override bool Equals(object obj)
  99. {
  100. if (obj is TeamType)
  101. {
  102. return this == obj;
  103. }
  104. else if (obj is string)
  105. {
  106. return string.Equals(Name, obj as string, StringComparison.OrdinalIgnoreCase);
  107. }
  108. return base.Equals(obj);
  109. }
  110. public override int GetHashCode()
  111. {
  112. return Name.GetHashCode();
  113. }
  114. public override string ToString()
  115. {
  116. return Name;
  117. }
  118. object ICloneable.Clone()
  119. {
  120. return Clone();
  121. }
  122. }
  123. }