예제 #1
0
 public void DoCommand(String s, bool output = true)
 {
     try
     {
         vm.Execute(s);
     }
     catch (Exception e)
     {
         OutputEngine.WriteLine(e.Message);
     }
 }
예제 #2
0
        internal static void Initialize()
        {
            OutputEngine.WriteLine("Total mods registered: " + registeredMods.Count);
            IO.Log.Write("  Total mods registered: " + registeredMods.Count);

            for (int i = 0; i < registeredMods.Count; i++)
            {
                Graphics.GUI.Scene.Console.vm.RegisterAssembly(registeredMods[i].GetType().Assembly);
                registeredMods[i].Initialize();
            }
        }
예제 #3
0
 public void DoFileAsync(String fn)
 {
     if (AsyncThread != null)
     {
         AsyncThread.Abort();
     }
     AsyncThread = new System.Threading.Thread(delegate()
     {
         String s = "";
         System.IO.StreamReader tsr = new System.IO.StreamReader(fn);
         if (tsr.Peek() == 8)
         {
             tsr.Read();
             tsr.Close();
             IO.SaveReader sr = new IO.SaveReader(fn);
             s = sr.ReadToEnd();
             sr.Close();
         }
         else
         {
             //tsr.Read();
             s = tsr.ReadToEnd();
             tsr.Close();
         }
         //pLuaVM.DoFile(fn);
         try
         {
             pLuaVM.DoString(s);
         }
         catch (Exception e)
         {
             IO.Log.Write("Exception in LUA engine at DoFileAsync");
             IO.Log.Write(e.Message);
             IO.Log.Write(e.Source);
             OutputEngine.WriteLine("LUA error: " + e.Message);
         }
     });
     AsyncThread.Start();
 }
예제 #4
0
        public static void LoadDLLs()
        {
            IO.Log.Write("    Loading Component DLLs");
            if (!System.IO.Directory.Exists("Components"))
            {
                IO.Log.Write("        Components direction not found");
                System.IO.Directory.CreateDirectory("Components");
                return;
            }
            String[] files = System.IO.Directory.GetFiles("Components/", "*.dll", System.IO.SearchOption.AllDirectories);
            OutputEngine.WriteLine("Attempting to load components. " + files.Length.ToString() + " located");
            IO.Log.Write("        " + files.Length.ToString() + " file(s) found");
            if (files.Length != 0)
            {
                for (int i = 0; i < files.Length; i++)
                {
                    OutputEngine.WriteLine("Attemting to load from /" + files[i]);
                    IO.Log.Write("        Attempting to load " + files[i]);
                    try
                    {
                        System.Reflection.Assembly a = System.Reflection.Assembly.LoadFrom(files[i]);
                        Type[] types         = a.GetTypes();
                        bool   hasComponents = false;
                        for (int j = 0; j < types.Length; j++)
                        {
                            if (types[j].ToString().StartsWith("MicroWorld.Components.") &&
                                !types[j].ToString().StartsWith("MicroWorld.Components.GUI") &&
                                !types[j].ToString().StartsWith("MicroWorld.Components.Graphics") &&
                                !types[j].ToString().StartsWith("MicroWorld.Components.Logics"))
                            {
                                String name = types[j].ToString().Substring(22);
                                if (name != "Component" && name != "ComponentsManager" && name.IndexOf(".") == -1 && //name check
                                    Activator.CreateInstance(types[j]) is Components.Component)                      //actual type check
                                {
                                    hasComponents = true;
                                    OutputEngine.WriteLine("Found component: " + name);
                                    IO.Log.Write("            Component found: " + name);
                                    Main.LoadingDetails = "Found component: " + name;
                                    RegisteredComponents.Add(types[j]);
                                }
                            }
                            //TODO MOVE!!!
                            if (types[j].IsSubclassOf(typeof(Modding.BaseMod)))
                            {
                                OutputEngine.WriteLine("Found mod: " + types[j].ToString());
                                IO.Log.Write("            Mod found: " + types[j].ToString());
                                Modding.ModdingLogics.registeredMods.Add(Activator.CreateInstance(types[j]) as Modding.BaseMod);
                                OutputEngine.WriteLine("Mod registered successfully!");
                                IO.Log.Write("            Mod registered successfully!");
                            }
                        }

                        if (!hasComponents)
                        {
                            OutputEngine.WriteLine("File /" + files[i] + " contains no components");
                            IO.Log.Write("        No components found");
                        }
                        else
                        {
                            Utilities.Reflection.RegisterAssembly(a);
                            OutputEngine.WriteLine("Successfully loaded /" + files[i]);
                            IO.Log.Write("        Succressfully loaded from " + files[i]);
                        }
                    }
                    catch (Exception e)
                    {
                        OutputEngine.WriteLine("Error while loading /" + files[i]);
                        IO.Log.Write("        Error while loading " + files[i]);
                        IO.Log.Write(IO.Log.State.ERROR, "       \r\n" + e.Message);
                        IO.Log.Write(IO.Log.State.ERROR, "       \r\n" + e.StackTrace);
                        Console.WriteLine(e.Message);
                    }
                    OutputEngine.WriteLine("");
                }
            }
        }
예제 #5
0
 public void writeln(String strCmd)
 {
     OutputEngine.WriteLine("[LUA]: " + strCmd);
 }
예제 #6
0
 public static void writeln(object o)
 {
     OutputEngine.WriteLine(">> " + o == null ? "null" : o.ToString());
 }
예제 #7
0
 public void writeln(String strCmd)
 {
     OutputEngine.WriteLine(strCmd);
     OutputEngine.WriteLine();
 }