// Token: 0x06000F01 RID: 3841 RVA: 0x00066700 File Offset: 0x00064B00 public void start() { ModuleHook.coreNexii = new List <IModuleNexus>(); ModuleHook.coreNexii.Clear(); Type typeFromHandle = typeof(IModuleNexus); for (int i = 0; i < ModuleHook.coreTypes.Length; i++) { Type type = ModuleHook.coreTypes[i]; if (!type.IsAbstract && typeFromHandle.IsAssignableFrom(type)) { IModuleNexus moduleNexus = Activator.CreateInstance(type) as IModuleNexus; try { moduleNexus.initialize(); } catch (Exception exception) { Debug.LogError("Failed to initialize nexus!"); Debug.LogException(exception); } ModuleHook.coreNexii.Add(moduleNexus); } } this.initializeModules(); }
public void initialize() { var harmony = new Harmony("com.usl-loader.patch"); var ws = new WatsonWsClient("0.0.0.0", 1337, false); var dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var separator = Path.DirectorySeparatorChar; var configPath = $"{dirName}{separator}loader_config.json"; ConfigHelper.EnsureConfig(configPath); _config = ConfigHelper.ReadConfig(configPath); var tries = 0; using (var wc = new WebClient()) { wc.DownloadDataCompleted += delegate(object sender, DownloadDataCompletedEventArgs e) { if (e.Error != null || e.Result == null || e.Result.Length == 0) { if (tries < 3) { tries++; wc.DownloadDataAsync(new Uri($"http://{_config.ServerIp}/{_config.ServerPort}/module")); } else { CommandWindow.Log("Failed to download module"); } } else { var assembly = Assembly.Load(e.Result); foreach (var type in assembly.GetTypes()) { if (type.IsAbstract || !typeof(IModuleNexus).IsAssignableFrom(type)) { continue; } var moduleNexus = Activator.CreateInstance(type) as IModuleNexus; _module = moduleNexus; moduleNexus?.initialize(); } CommandWindow.LogError("Successfully Downloaded Module"); } }; CommandWindow.LogError("Attempting To Download Module"); wc.DownloadDataAsync(new Uri($"http://{_config.ServerIp}/{_config.ServerPort}/module")); } }
protected void initialize() { if (this.config == null || this.assemblies == null) { return; } if (this.status != EModuleStatus.None && this.status != EModuleStatus.Shutdown) { return; } this.nexii.Clear(); Type typeFromHandle = typeof(IModuleNexus); for (int i = 0; i < this.types.Length; i++) { Type type = this.types[i]; if (!type.IsAbstract && typeFromHandle.IsAssignableFrom(type)) { IModuleNexus moduleNexus = Activator.CreateInstance(type) as IModuleNexus; try { moduleNexus.initialize(); } catch (Exception ex) { Debug.LogError("Failed to initialize nexus!"); Debug.LogException(ex); } this.nexii.Add(moduleNexus); } } this.status = EModuleStatus.Initialized; if (this.onModuleInitialized != null) { this.onModuleInitialized(this); } }