public override ThenResponse Perform(EventInfo eventInfo) { ThenResponse response = ThenResponse.Continue; try { IScriptHandler scriptHandler = Container.GetExportedValue<IScriptHandler>(); if (scriptHandler != null) { if (UseNamedScript) { if (!Enum.TryParse(scriptHandler.RunNamedScript(eventInfo, ScriptName), out response)) { response = ThenResponse.Continue; } } else { if (!Enum.TryParse(scriptHandler.RunScript(eventInfo, ScriptText), out response)) { response = ThenResponse.Continue; } } } } catch (Exception e) { Log.LogError(e, "Unknown Script Error: " + e.Message); } return response; }
static void Main(string[] args) { Console.Title = "Coob"; Console.TreatControlCAsInput = true; Log.Info("Starting Coob."); DefaultCoobOptions defopt = new DefaultCoobOptions(); iniFile config = new iniFile(AppDomain.CurrentDomain.BaseDirectory + "config.ini"); if (File.Exists("config.ini")) { Log.Info("Read file config.ini ..."); defopt.Port = Convert.ToInt32(config.IniReadValue("Settings", "Port")); defopt.WorldSeed = Convert.ToInt32(config.IniReadValue("Settings", "WorldSeed")); } else { Log.Warning("File config.ini doesn't exist"); Log.Info("Creating file config.ini ..."); File.Create("config.ini").Close(); config.IniWriteValue("Settings", "Port", defopt.Port.ToString()); config.IniWriteValue("Settings", "WorldSeed", defopt.WorldSeed.ToString()); } Log.Info("Port set to " + defopt.Port); Log.Info("WorldSeed set to " + defopt.WorldSeed); Coob = new Coob(defopt); Scripting = new JavascriptEngine(); ScriptManager = new ScriptManager(); ScriptManager.ScriptHandlers.Add(Scripting); ScriptManager.Initialize(); Scripting.SetParameter("coob", Root.Coob); Scripting.Run(); var initializeEventArgs = new InitializeEventArgs(0); if (ScriptManager.CallEvent("OnInitialize", initializeEventArgs).Canceled) return; Coob.Options.WorldSeed = initializeEventArgs.WorldSeed; Coob.StartServer(); while (Coob.Running) { var input = Console.ReadLine().ToLower(); if (input == "exit") // Temporary way to quit server properly. Seems to f**k up because the console hates life. Coob.StopServer(); } Log.Info("Stopping server..."); //Scripting.CallFunction("onQuit"); ScriptManager.CallEvent("OnQuit", new QuitEventArgs()); Log.Display(); // "Needs" to be called here since it normally gets called in the message handler (which isn't called anymore since server stopped). }
public void Initialize() { #if UNITY_EDITOR || UNITY_ANDROID script = new ReflectionHandler(); #else script = new ILRuntimeHandler(); #endif if (script != null) { script.Initialize(); Client.Instance.StartCoroutine(LoadDll()); } }
private void LoadPlugin(string directory, IScriptHandler scriptHandler, string pluginDirectory) { string pluginName = directory.Substring(directory.LastIndexOf('/') + 1); if (!VerifyPlugin(pluginName)) { return; } string entryPath = Path.Combine(directory, scriptHandler.GetEntryFileName() + scriptHandler.GetScriptExtension()); if (File.Exists(entryPath)) { var lines = GetDependencies(directory); foreach (var line in lines) { if (!loadedPlugins.Contains(line)) { var dependencies = GetDependencies("Plugins/" + scriptHandler.GetScriptDirectoryName() + "/" + line); if (dependencies.Contains(pluginName)) { Log.Error("Plugin \"" + pluginName + "\" has a dependency to itself!"); return; } if (dependencies.Contains(pluginName)) { Log.Error("Circular dependency detected between \"" + pluginName + "\" and \"" + line + "\"!"); return; } Log.Info(pluginName + " requires " + line + ". Loading " + line + "."); LoadPlugin(pluginDirectory + "/" + line, scriptHandler, pluginDirectory); } } scriptHandler.LoadPlugin(pluginName, entryPath); loadedPlugins.Add(pluginName); } else { Log.Error("Plugin \"" + pluginName + "\" could not be loaded because it does not exist!"); return; } }
static void Main(string[] args) { Console.Title = "Coob"; //Console.TreatControlCAsInput = true; Log.Info("Starting Coob."); Scripting = new JavascriptEngine(); ScriptManager = new ScriptManager(); ScriptManager.ScriptHandlers.Add(Scripting); ScriptManager.Initialize(); Scripting.Run(); Coob = new Coob(new CoobOptions { Port = 12345, WorldSeed = 1234, }); Scripting.SetParameter("coob", Coob); Scripting.SetParameter("world", Coob.World); var initializeEventArgs = new InitializeEventArgs(0); if (ScriptManager.CallEvent("OnInitialize", initializeEventArgs).Canceled) return; Log.Info("World seed: " + Coob.World.Seed); Coob.StartServer(); while(Coob.Running) { var input = Console.ReadLine().ToLower(); if (input == "exit") // Temporary way to quit server properly. Seems to f**k up because the console hates life. Coob.StopServer(); } Log.Info("Stopping server..."); //Scripting.CallFunction("onQuit"); ScriptManager.CallEvent("OnQuit", new QuitEventArgs()); Log.Display(); // "Needs" to be called here since it normally gets called in the message handler (which isn't called anymore since server stopped). }
static void Main(string[] args) { Console.Title = "Coob"; //Console.TreatControlCAsInput = true; Log.Info("Starting Coob."); Scripting = new JavascriptEngine(); ScriptManager = new ScriptManager(); ScriptManager.ScriptHandlers.Add(Scripting); ScriptManager.Initialize(); Scripting.Run(); var initArgs = ScriptManager.CallEvent <InitializeEventArgs>("OnInitialize", new InitializeEventArgs()); Coob = new Coob(new CoobOptions { Port = initArgs.Port, WorldSeed = initArgs.WorldSeed, }); Scripting.SetParameter("coob", Coob); Scripting.SetParameter("world", Coob.World); Log.Info("World seed: " + Coob.World.Seed); Coob.StartServer(); while (Coob.Running) { var input = Console.ReadLine() ?? ""; // FixMe: This will cause the console to spam HandleConsoleCommand(line) with an empty string if there's no input. HandleConsoleCommand(input); } Log.Info("Stopping server..."); //Scripting.CallFunction("onQuit"); ScriptManager.CallEvent("OnQuit", new QuitEventArgs()); Log.Display(); // "Needs" to be called here since it normally gets called in the message handler (which isn't called anymore since server stopped). }
public void Deregister(IScriptHandler <DialogueData> handler) { handler.DialogueStartEventHandler -= OnScriptStarted; handler.DialogueUpdateEventHandler -= OnScriptUpdated; handler.DialogueEndEventHandler -= OnScriptEnded; }