public static void Serialize(BinaryWriter s, RTSTeam team) { s.Write(team.Type); RTSRace.Serialize(s, team.Race); if (team.Input != null) { s.Write(true); s.Write(ReflectedScript.GetKey(team.Input)); team.Input.Serialize(s); } else { s.Write(false); } s.Write(team.ColorScheme.Name); s.Write(team.ColorScheme.Primary); s.Write(team.ColorScheme.Secondary); s.Write(team.ColorScheme.Tertiary); s.Write(team.Buildings.Count); foreach (var building in team.Buildings) { RTSBuilding.Serialize(s, building); } s.Write(team.Units.Count); foreach (var unit in team.Units) { RTSUnit.Serialize(s, unit); } s.Write(team.Squads.Count); foreach (var squad in team.Squads) { RTSSquad.Serialize(s, squad); } }
public static Dictionary<string, ReflectedScript> Compile(string[] files, string[] references, out string error) { // No Error Default error = null; // Compile CompilerParameters compParams = new CompilerParameters(references, null, false); compParams.CompilerOptions = "/optimize"; compParams.GenerateExecutable = false; compParams.GenerateInMemory = true; compParams.TreatWarningsAsErrors = false; #if DEBUG compParams.IncludeDebugInformation = true; #endif CompilerResults cr = compiler.CompileAssemblyFromFile(compParams, files); // Check For Errors if(cr.Errors.Count > 0) { error = ""; foreach(var e in cr.Errors) error += e + "\n"; return null; } // Dictionaries var res = new Dictionary<string, ReflectedScript>(); // Loop Through All Visible Types Assembly a = cr.CompiledAssembly; Type[] types = a.GetExportedTypes(); foreach(Type t in types) { ZXPProxy.Add(t); ZXParser.AddDynamicType(t.FullName, t); // We Don't Want Abstract Classes Or Interfaces if(t.IsAbstract || t.IsInterface) continue; // Check For The Superclass if(t.IsSubclassOf(typeof(ACScript))) { var rs = new ReflectedScript(t); res.Add(rs.TypeName, rs); } } return res; }
public static Dictionary<string, ReflectedScript> Compile(string[] files, string[] references, out string error) { // No Error Default error = null; // Compile CompilerParameters compParams = new CompilerParameters(references, null, false); compParams.CompilerOptions = "/optimize"; compParams.GenerateExecutable = false; compParams.GenerateInMemory = true; compParams.TreatWarningsAsErrors = false; #if DEBUG compParams.IncludeDebugInformation = true; #endif CompilerResults cr = compiler.CompileAssemblyFromFile(compParams, files); // Check For Errors if(cr.Errors.Count > 0) { error = ""; foreach(var e in cr.Errors) error += e + "\n"; return null; } // Dictionaries var res = new Dictionary<string, ReflectedScript>(); // Loop Through All Visible Types Assembly a = cr.CompiledAssembly; Type[] types = a.GetExportedTypes(); foreach(Type t in types) { ZXPProxy.Add(t); ZXParser.AddDynamicType(t.FullName, t); // We Don't Want Abstract Classes Or Interfaces if(t.IsAbstract || t.IsInterface) continue; // Check For The Superclass if(t.IsSubclassOf(typeof(ACScript))) { var rs = new ReflectedScript(t); res.Add(rs.TypeName, rs); } } return res; }
public override void OnEntry(GameTime gameTime) { camera = new FreeCamera(Vector3.UnitY * Region.HEIGHT * 0.6f, 0, 0, G.Viewport.AspectRatio); gtcList = new List <ACGameTypeController>(); icList = new List <ACInputController>(); foreach (var kvp in GameEngine.Scripts) { ReflectedScript rs = kvp.Value; if (rs.ScriptType == ScriptType.GameType) { gtcList.Add(rs.CreateInstance <ACGameTypeController>()); } else if (rs.ScriptType == ScriptType.Input) { icList.Add(rs.CreateInstance <ACInputController>()); } } CreateVoxWorld(); CreateWidgets(); CreateTools(); MouseEventDispatcher.OnMousePress += OnMP; KeyboardEventDispatcher.OnKeyPressed += OnKP; }