public static void Run(string script) { if (!script.StartsWith("Item.")) { script = "Item." + script; } using (new Profiler(nameof(ScriptEvent) + "." + script)) { string rootNamespace = Assembly.GetExecutingAssembly().GetName().Name; string scriptNamespace = rootNamespace + ".Scripts." + script; // Check the script cache first. If it exists, we run it. if (ScriptService.IsScriptRegisteredByNamespace(scriptNamespace)) { ScriptService.RunScriptByNamespace(scriptNamespace); return; } // Otherwise look for a script contained by the app. scriptNamespace = rootNamespace + "." + script; Type type = Type.GetType(scriptNamespace); if (type == null) { Console.WriteLine("Unable to locate type for ScriptItemEvent: " + script); return; } IRegisteredEvent @event = Activator.CreateInstance(type) as IRegisteredEvent; @event?.Run(); } }
public static void Run(string variableName) { NWObject self = (NWGameObject.OBJECT_SELF); string script = self.GetLocalString(variableName); using (new Profiler("ScriptEvent." + script)) { string rootNamespace = Assembly.GetExecutingAssembly().GetName().Name; string scriptNamespace = rootNamespace + ".Scripts." + script; // Check the script cache first. If it exists, we run it. if (ScriptService.IsScriptRegisteredByNamespace(scriptNamespace)) { ScriptService.RunScriptByNamespace(scriptNamespace); return; } // Otherwise look for a script contained by the app. scriptNamespace = rootNamespace + "." + script; Type type = Type.GetType(scriptNamespace); if (type == null) { Console.WriteLine("Unable to locate type for ScriptEvent: " + script); return; } IRegisteredEvent @event = Activator.CreateInstance(type) as IRegisteredEvent; @event?.Run(); } }
public static void Run(string variableName) { NWObject self = (_.OBJECT_SELF); string script = self.GetLocalString(variableName); using (new Profiler("ScriptEvent." + script)) { string rootNamespace = Assembly.GetExecutingAssembly().GetName().Name; string scriptNamespace = rootNamespace + ".Scripts." + script; // Check the script cache first. If it exists, we run it. if (ScriptService.IsScriptRegisteredByNamespace(scriptNamespace)) { ScriptService.RunScriptByNamespace(scriptNamespace); } else { Console.WriteLine("Unable to locate script: " + scriptNamespace); } } }
public static void Run(string script) { if (!script.StartsWith("Item.")) { script = "Item." + script; } using (new Profiler(nameof(ScriptEvent) + "." + script)) { string rootNamespace = Assembly.GetExecutingAssembly().GetName().Name; string scriptNamespace = rootNamespace + ".Scripts." + script; // Check the script cache first. If it exists, we run it. if (ScriptService.IsScriptRegisteredByNamespace(scriptNamespace)) { ScriptService.RunScriptByNamespace(scriptNamespace); } else { Console.WriteLine("Unable to locate item script: " + script); } } }