CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

HouseTypes.cs (2600B)


      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.Model;
     16 using System.Collections.Generic;
     17 using System.Linq;
     18 using System.Reflection;
     19 
     20 namespace MobiusEditor.TiberianDawn
     21 {
     22     public static class HouseTypes
     23     {
     24         public static readonly HouseType Good = new HouseType(0, "GoodGuy", "GOOD");
     25         public static readonly HouseType Bad = new HouseType(1, "BadGuy", "BAD_UNIT", "BAD_STRUCTURE", ("harv", "BAD_STRUCTURE"), ("mcv", "BAD_STRUCTURE"));
     26         public static readonly HouseType Neutral = new HouseType(2, "Neutral");
     27         public static readonly HouseType Special = new HouseType(3, "Special");
     28         public static readonly HouseType Multi1 = new HouseType(4, "Multi1", "MULTI1");
     29         public static readonly HouseType Multi2 = new HouseType(5, "Multi2", "MULTI2");
     30         public static readonly HouseType Multi3 = new HouseType(6, "Multi3", "MULTI3");
     31         public static readonly HouseType Multi4 = new HouseType(7, "Multi4", "MULTI4");
     32         public static readonly HouseType Multi5 = new HouseType(8, "Multi5", "MULTI5");
     33         public static readonly HouseType Multi6 = new HouseType(9, "Multi6", "MULTI6");
     34 
     35         private static readonly HouseType[] Types;
     36 
     37         static HouseTypes()
     38         {
     39             Types =
     40                 (from field in typeof(HouseTypes).GetFields(BindingFlags.Static | BindingFlags.Public)
     41                  where field.IsInitOnly && typeof(HouseType).IsAssignableFrom(field.FieldType)
     42                  select field.GetValue(null) as HouseType).ToArray();
     43         }
     44 
     45         public static IEnumerable<HouseType> GetTypes()
     46         {
     47             return Types;
     48         }
     49 
     50         public static string GetBasePlayer(string player)
     51         {
     52             return Bad.Equals(player) ? Good.Name : Bad.Name;
     53         }
     54     }
     55 }