internal void OnCompilationSucceeded(Oxide.Plugins.CompiledAssembly compiledAssembly) { if (this.timeoutTimer == null) { Interface.Oxide.LogWarning(string.Concat("Ignored unexpected plugin compilation: ", this.Name), Array.Empty <object>()); return; } Oxide.Core.Libraries.Timer.TimerInstance timerInstance = this.timeoutTimer; if (timerInstance != null) { timerInstance.Destroy(); } else { } this.timeoutTimer = null; this.IsCompilationNeeded = false; this.CompilationQueuedAt = 0f; this.CompiledAssembly = compiledAssembly; Action <bool> compileCallback = this.CompileCallback; if (compileCallback == null) { return; } compileCallback(true); }
internal void LoadPlugin(Action <CSharpPlugin> callback = null) { if (this.CompiledAssembly == null) { Interface.Oxide.LogError("Load called before a compiled assembly exists: {0}", new object[] { this.Name }); return; } this.LoadCallback = callback; this.CompiledAssembly.LoadAssembly((bool loaded) => { CSharpPlugin watcher; if (!loaded) { Action <CSharpPlugin> action = callback; if (action == null) { return; } action(null); return; } if (this.CompilerErrors != null) { this.InitFailed(string.Concat("Unable to load ", this.ScriptName, ". ", this.CompilerErrors)); return; } Type type = this.CompiledAssembly.LoadedAssembly.GetType(string.Concat("Oxide.Plugins.", this.Name)); if (type == null) { this.InitFailed(string.Concat("Unable to find main plugin class: ", this.Name)); return; } try { watcher = Activator.CreateInstance(type) as CSharpPlugin; goto Label0; } catch (MissingMethodException missingMethodException) { this.InitFailed(string.Concat("Main plugin class should not have a constructor defined: ", this.Name)); } catch (TargetInvocationException targetInvocationException) { Exception innerException = targetInvocationException.InnerException; this.InitFailed(string.Concat("Unable to load ", this.ScriptName, ". ", innerException.ToString())); } catch (Exception exception) { this.InitFailed(string.Concat("Unable to load ", this.ScriptName, ". ", exception.ToString())); } return; Label0: if (watcher == null) { this.InitFailed(string.Concat("Plugin assembly failed to load: ", this.ScriptName)); return; } if (!watcher.SetPluginInfo(this.ScriptName, this.ScriptPath)) { this.InitFailed(null); return; } watcher.Watcher = this.Extension.Watcher; watcher.Loader = this.Loader; if (!Interface.Oxide.PluginLoaded(watcher)) { this.InitFailed(null); return; } if (!this.CompiledAssembly.IsBatch) { this.LastGoodAssembly = this.CompiledAssembly; } Action <CSharpPlugin> action1 = callback; if (action1 == null) { return; } action1(watcher); }); }