public static string MakeDecisions(string[] dependCS) { List <string> SourceCodes = new List <string>(dependCS); CSharpCompiler.ScriptBundleLoader.IScriptBundle bd = csharpLoader.LoadAndWatchSourceBundle(SourceCodes); Type[] types = bd.assembly.GetTypes(); Type[] FlagTypes = types.Where(x => x.BaseType.Name == "DefDecision").ToArray(); var fields = new List <Tuple <string, Type, Type, List <object>, CodeAttributeDeclaration> >(); foreach (var type in FlagTypes) { fields.Add(new Tuple <string, Type, Type, List <object>, CodeAttributeDeclaration>(type.Name, type, type, null, null)); } CodeDomGen sourceCodeCreater = new CodeDomGen("Decisions", fields); string source = sourceCodeCreater.Create(); Debug.Log(source); Debug.Log("Load decision count:" + FlagTypes.Count()); return(source); }
private void LoadMod(string path) { Debug.Log(string.Format("*****************Start Load mod {0}********************", path)); CSVManager.Load(path); CSGenerator.csharpLoader = csharpLoader; CSGenerator.path = path; List <string> sourceCodes = new List <string>(); sourceCodes.Add(CSGenerator.MakeOffices()); sourceCodes.Add(CSGenerator.MakeFactions()); sourceCodes.AddRange(ReadAllCSInPath(path + "/name")); sourceCodes.AddRange(ReadAllCSInPath(path + "/flag")); sourceCodes.AddRange(ReadAllCSInPath(path + "/decision")); sourceCodes.Add(CSGenerator.MakeFlags()); sourceCodes.Add(CSGenerator.MakeDecisions(sourceCodes.ToArray())); sourceCodes.AddRange(ReadAllCSInPath(path + "/event")); CSharpCompiler.ScriptBundleLoader.IScriptBundle bd = csharpLoader.LoadAndWatchSourceBundle(sourceCodes.ToArray()); Type[] Types = bd.assembly.GetTypes(); DynastyName.Load(Types); YearName.Load(Types); PersonName.Load(Types); EventManager.Load(Types); var qurey = (from x in Types where x.Name == "CountryFlags" select x).Single(); System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(qurey.TypeHandle); qurey = (from x in Types where x.Name == "Decisions" select x).Single(); System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(qurey.TypeHandle); qurey = (from x in Types where x.Name == "Offices" select x).Single(); System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(qurey.TypeHandle); qurey = (from x in Types where x.Name == "Factions" select x).Single(); System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(qurey.TypeHandle); Debug.Log(string.Format("******************End Load mod {0}********************", path)); }
public static string MakeFlags() { string[] fileNames = Directory.GetFiles(path + "/flag", "*.cs", SearchOption.AllDirectories); CSharpCompiler.ScriptBundleLoader.IScriptBundle bd = csharpLoader.LoadAndWatchScriptsBundle(fileNames); Type[] types = bd.assembly.GetTypes(); Type[] FlagTypes = types.Where(x => x.BaseType.Name == "DefCountryFlag").ToArray(); var fields = new List <Tuple <string, Type, Type, List <object>, CodeAttributeDeclaration> >(); foreach (var type in FlagTypes) { fields.Add(new Tuple <string, Type, Type, List <object>, CodeAttributeDeclaration>(type.Name, type, type, null, null)); } CodeDomGen sourceCodeCreater = new CodeDomGen("CountryFlags", fields); string source = sourceCodeCreater.Create(); Debug.Log(source); Debug.Log("Load country flag count:" + FlagTypes.Count()); return(source); }