HouseType.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 System;
  15. using System.Collections.Generic;
  16. using System.Linq;
  17. using System.Text;
  18. using System.Threading.Tasks;
  19. namespace MobiusEditor.Model
  20. {
  21. public class HouseType
  22. {
  23. public sbyte ID { get; private set; }
  24. public string Name { get; private set; }
  25. public string UnitTeamColor { get; private set; }
  26. public string BuildingTeamColor { get; private set; }
  27. public IDictionary<string, string> OverrideTeamColors { get; private set; }
  28. public HouseType(sbyte id, string name, string unitTeamColor, string buildingTeamColor, params (string type, string teamColor)[] overrideTeamColors)
  29. {
  30. ID = id;
  31. Name = name;
  32. UnitTeamColor = unitTeamColor;
  33. BuildingTeamColor = buildingTeamColor;
  34. OverrideTeamColors = overrideTeamColors.ToDictionary(x => x.type, x => x.teamColor);
  35. }
  36. public HouseType(sbyte id, string name, string teamColor)
  37. : this(id, name, teamColor, teamColor)
  38. {
  39. }
  40. public HouseType(sbyte id, string name)
  41. : this(id, name, null)
  42. {
  43. }
  44. public override bool Equals(object obj)
  45. {
  46. if (obj is HouseType)
  47. {
  48. return this == obj;
  49. }
  50. else if (obj is sbyte)
  51. {
  52. return ID == (sbyte)obj;
  53. }
  54. else if (obj is string)
  55. {
  56. return string.Equals(Name, obj as string, StringComparison.OrdinalIgnoreCase);
  57. }
  58. return base.Equals(obj);
  59. }
  60. public override int GetHashCode()
  61. {
  62. return ID.GetHashCode();
  63. }
  64. public override string ToString()
  65. {
  66. return Name;
  67. }
  68. }
  69. }