private void OnServerInitialized() { var timer = Interface.Oxide.GetLibrary <Timer>(); serverManagerLibrary = Interface.Oxide.GetLibrary <ServerManagerLibrary>("ServerManager"); timerInstance = timer.Repeat(UpdateInterval * 60, -1, () => serverManagerLibrary.CheckForUpdates()); }
private void watcher_Changed(object sender, FileSystemEventArgs e) { FSWatcher.QueuedChange queuedChange1; Action action2 = null; FileSystemWatcher fileSystemWatcher = (FileSystemWatcher)sender; int length = e.FullPath.Length - fileSystemWatcher.Path.Length - Path.GetExtension(e.Name).Length - 1; string str = e.FullPath.Substring(fileSystemWatcher.Path.Length + 1, length); if (!this.changeQueue.TryGetValue(str, out queuedChange1)) { queuedChange1 = new FSWatcher.QueuedChange(); this.changeQueue[str] = queuedChange1; } Timer.TimerInstance timerInstance1 = queuedChange1.timer; if (timerInstance1 != null) { timerInstance1.Destroy(); } else { } queuedChange1.timer = null; switch (e.ChangeType) { case WatcherChangeTypes.Created: { if (queuedChange1.type != WatcherChangeTypes.Deleted) { queuedChange1.type = WatcherChangeTypes.Created; goto case WatcherChangeTypes.Created | WatcherChangeTypes.Deleted; } else { queuedChange1.type = WatcherChangeTypes.Changed; goto case WatcherChangeTypes.Created | WatcherChangeTypes.Deleted; } } case WatcherChangeTypes.Deleted: { if (queuedChange1.type == WatcherChangeTypes.Created) { this.changeQueue.Remove(str); return; } queuedChange1.type = WatcherChangeTypes.Deleted; goto case WatcherChangeTypes.Created | WatcherChangeTypes.Deleted; } case WatcherChangeTypes.Created | WatcherChangeTypes.Deleted: { Interface.Oxide.NextTick(() => { Timer.TimerInstance timerInstance = queuedChange1.timer; if (timerInstance != null) { timerInstance.Destroy(); } else { } FSWatcher.QueuedChange queuedChange = queuedChange1; Timer u003cu003e4_this = this.timers; Action u003cu003e9_1 = action2; if (u003cu003e9_1 == null) { Action action = () => { queuedChange1.timer = null; this.changeQueue.Remove(str); if (Regex.Match(str, "include\\\\", RegexOptions.IgnoreCase).Success) { if (queuedChange1.type == WatcherChangeTypes.Created || queuedChange1.type == WatcherChangeTypes.Changed) { base.FirePluginSourceChanged(str); } return; } switch (queuedChange1.type) { case WatcherChangeTypes.Created: { base.FirePluginAdded(str); return; } case WatcherChangeTypes.Deleted: { if (!this.watchedPlugins.Contains(str)) { return; } base.FirePluginRemoved(str); return; } case WatcherChangeTypes.Created | WatcherChangeTypes.Deleted: { return; } case WatcherChangeTypes.Changed: { if (this.watchedPlugins.Contains(str)) { base.FirePluginSourceChanged(str); return; } base.FirePluginAdded(str); return; } default: { return; } } }; Action action1 = action; action2 = action; u003cu003e9_1 = action1; } queuedChange.timer = u003cu003e4_this.Once(0.2f, u003cu003e9_1, null); }); return; } case WatcherChangeTypes.Changed: { if (queuedChange1.type == WatcherChangeTypes.Created) { goto case WatcherChangeTypes.Created | WatcherChangeTypes.Deleted; } queuedChange1.type = WatcherChangeTypes.Changed; goto case WatcherChangeTypes.Created | WatcherChangeTypes.Deleted; } default: { goto case WatcherChangeTypes.Created | WatcherChangeTypes.Deleted; } } }
private void OnSceneChanged(SceneType sceneType, Scene scene) { Interface.Oxide.LogDebug($"Scene changed to {scene.name} ({scene.buildIndex})."); if (sceneType == SceneType.Game) { RemotePlayer.CreatePlayerPrefab(); localPlayer = GameObject.Find("Player") ?? throw new NotImplementedException("Could not find local player"); localPlayerControl = localPlayer.GetComponent <PlayerControl>() ?? throw new NotImplementedException("Could not find PlayerControl on local player"); localPoseControl = localPlayer.transform.Find("dude/mixamorig:Hips").GetComponent <PoseControl>() ?? throw new NotImplementedException("Could not find PoseControl on local player"); localPlayerBase = localPlayer.AddComponent <LocalPlayer>(); InitSpectator(); InitUI(); InitClient(); } else if (sceneType == SceneType.Menu) { InitMenuUI(); if (firstLaunch) { firstLaunch = false; // Don't connect to server automatically if an update is available or if this is the first ever launch. if (firstEverLaunch) { menuUi.ShowFirstLaunch(); return; } if (updateAvailable) { menuUi.ShowUpdateAvailable(); return; } } else { return; } var launchArguments = Environment.GetCommandLineArgs().Skip(1).ToArray(); for (int i = 0; i < launchArguments.Length; i += 2) { string argument = launchArguments[i].ToLower(); string value = i < launchArguments.Length - 1 ? launchArguments[i + 1].ToLower() : null; if (argument == "--goimp-connect") { string[] ipPort = value.Split(':'); string ipString = ipPort[0]; string portString = ipPort[1]; IPAddress ipAddress; short port; if (!IPAddress.TryParse(ipString, out ipAddress)) { Interface.Oxide.LogError($"Launch arguments contained invalid ip: {ipString}"); return; } if (!short.TryParse(portString, out port)) { Interface.Oxide.LogError($"Launch arguments contained invalid port: {portString}"); return; } launchEndPoint = new IPEndPoint(ipAddress, port); // Wait for game to finish loading then continue game. var loader = GameObject.FindObjectOfType <Loader>(); var loadingFinishedField = typeof(Loader).GetField("loadFinished", BindingFlags.Instance | BindingFlags.NonPublic); Timer.TimerInstance timerInstance = null; Action timerCallback = () => { bool loadingFinished = (bool)loadingFinishedField.GetValue(loader); if (loadingFinished) { loader.ContinueGame(); timerInstance.Destroy(); } }; timerInstance = Timer.Repeat(0, -1, timerCallback, this); } } } if (sceneType != SceneType.Game) { DestroyClient(); DestroyUI(); DestroySpectator(); if (ListenServer.Running) { ListenServer.Stop(); } } else if (sceneType != SceneType.Menu) { DestroyMenuUI(); } }