public ModpackWorker(DMPGame dmpGame, Settings dmpSettings, ModWorker modWorker, NetworkWorker networkWorker, ChatWorker chatWorker, AdminSystem adminSystem) { gameDataPath = Path.Combine(KSPUtil.ApplicationRootPath, "GameData"); cacheDataPath = Path.Combine(KSPUtil.ApplicationRootPath, "DarkMultiPlayer-ModCache"); Directory.CreateDirectory(cacheDataPath); ckanDataPath = Path.Combine(KSPUtil.ApplicationRootPath, "DarkMultiPlayer.ckan"); gameDataServerCachePath = Path.Combine(KSPUtil.ApplicationRootPath, "DarkMultiPlayer-Server-GameData.txt"); gameDataClientCachePath = Path.Combine(KSPUtil.ApplicationRootPath, "DarkMultiPlayer-Client-GameData.txt"); this.dmpGame = dmpGame; this.dmpSettings = dmpSettings; this.modWorker = modWorker; this.networkWorker = networkWorker; this.chatWorker = chatWorker; this.adminSystem = adminSystem; dmpGame.updateEvent.Add(Update); GameEvents.onGameSceneLoadRequested.Add(OnGameSceneLoadRequested); try { numHashingThreads = Environment.ProcessorCount; } catch { Console.WriteLine("Environment.ProcessorCount does not work"); } }
public Groups(DMPGame dmpGame, NetworkWorker networkWorker, Settings dmpSettings) { this.dmpGame = dmpGame; this.networkWorker = networkWorker; this.dmpSettings = dmpSettings; dmpGame.updateEvent.Add(ProcessMessages); }
public DynamicTickWorker(DMPGame dmpGame, NetworkWorker networkWorker) { this.dmpGame = dmpGame; this.networkWorker = networkWorker; maxSecondryVesselsPerTick = MASTER_MAX_SECONDARY_VESSELS; dmpGame.updateEvent.Add(Update); }
public HackyInAtmoLoader(DMPGame dmpGame, LockSystem lockSystem, VesselWorker vesselWorker) { this.dmpGame = dmpGame; this.lockSystem = lockSystem; this.vesselWorker = vesselWorker; dmpGame.fixedUpdateEvent.Add(FixedUpdate); }
public VesselRecorder(DMPGame dmpGame, WarpWorker warpWorker, VesselWorker vesselWorker) { this.warpWorker = warpWorker; this.vesselWorker = vesselWorker; this.dmpGame = dmpGame; this.dmpGame.updateEvent.Add(Update); }
public GroupsWindow(DMPGame dmpGame, Settings dmpSettings, Groups groups) { this.dmpGame = dmpGame; this.dmpSettings = dmpSettings; this.groups = groups; dmpGame.drawEvent.Add(Draw); }
public FlagSyncer(DMPGame dmpGame, Settings dmpSettings, NetworkWorker networkWorker) { this.dmpGame = dmpGame; this.dmpSettings = dmpSettings; this.networkWorker = networkWorker; flagPath = Path.Combine(Path.Combine(Path.Combine(KSPUtil.ApplicationRootPath, "GameData"), "DarkMultiPlayer"), "Flags"); dmpGame.updateEvent.Add(Update); }
public GroupsWindow(DMPGame dmpGame, Settings dmpSettings, Groups groups) { this.dmpGame = dmpGame; this.dmpSettings = dmpSettings; this.groups = groups; drawAction = new NamedAction(Draw); dmpGame.drawEvent.Add(drawAction); }
public FlagSyncer(DMPGame dmpGame, Settings dmpSettings, NetworkWorker networkWorker) { this.dmpGame = dmpGame; this.dmpSettings = dmpSettings; this.networkWorker = networkWorker; flagPath = Path.Combine(Path.Combine(Client.dmpClient.gameDataDir, "DarkMultiPlayer"), "Flags"); dmpGame.updateEvent.Add(Update); }
public ScenarioWorker(DMPGame dmpGame, VesselWorker vesselWorker, ConfigNodeSerializer configNodeSerializer, NetworkWorker networkWorker) { this.dmpGame = dmpGame; this.vesselWorker = vesselWorker; this.configNodeSerializer = configNodeSerializer; this.networkWorker = networkWorker; dmpGame.updateEvent.Add(Update); }
public Permissions(DMPGame dmpGame, NetworkWorker networkWorker, Settings dmpSettings, Groups groups) { this.dmpGame = dmpGame; this.networkWorker = networkWorker; this.dmpSettings = dmpSettings; this.groups = groups; dmpGame.updateEvent.Add(ProcessMessages); }
public PermissionsWindow(DMPGame dmpGame, Settings dmpSettings, Groups groups, Permissions permissions, LockSystem lockSystem) { this.dmpGame = dmpGame; this.dmpSettings = dmpSettings; this.groups = groups; this.permissions = permissions; this.lockSystem = lockSystem; dmpGame.drawEvent.Add(Draw); }
public TimeSyncer(DMPGame dmpGame, NetworkWorker networkWorker, VesselWorker vesselWorker) { this.dmpGame = dmpGame; this.networkWorker = networkWorker; this.vesselWorker = vesselWorker; dmpGame.fixedUpdateEvent.Add(FixedUpdate); currentSubspace = -1; requestedRate = 1f; }
public PlayerColorWorker(DMPGame dmpGame, Settings dmpSettings, LockSystem lockSystem, NetworkWorker networkWorker) { this.dmpGame = dmpGame; this.dmpSettings = dmpSettings; this.lockSystem = lockSystem; this.networkWorker = networkWorker; updateEvent = new NamedAction(Update); dmpGame.updateEvent.Add(updateEvent); }
public AsteroidWorker(DMPGame dmpGame, LockSystem lockSystem, NetworkWorker networkWorker, VesselWorker vesselWorker) { this.dmpGame = dmpGame; this.lockSystem = lockSystem; this.networkWorker = networkWorker; this.vesselWorker = vesselWorker; this.dmpGame.updateEvent.Add(Update); GameEvents.onVesselCreate.Add(OnVesselCreate); }
public WarpWorker(DMPGame dmpGame, Settings dmpSettings, TimeSyncer timeSyncer, NetworkWorker networkWorker, PlayerStatusWorker playerStatusWorker) { this.dmpGame = dmpGame; this.dmpSettings = dmpSettings; this.timeSyncer = timeSyncer; this.networkWorker = networkWorker; this.playerStatusWorker = playerStatusWorker; dmpGame.updateEvent.Add(Update); }
public VesselRecorder(DMPGame dmpGame, WarpWorker warpWorker, VesselWorker vesselWorker, NetworkWorker networkWorker, Settings dmpSettings) { this.warpWorker = warpWorker; this.vesselWorker = vesselWorker; this.networkWorker = networkWorker; this.dmpSettings = dmpSettings; this.dmpGame = dmpGame; this.dmpGame.updateEvent.Add(Update); }
public ScreenshotWorker(DMPGame dmpGame, Settings dmpSettings, ChatWorker chatWorker, NetworkWorker networkWorker, PlayerStatusWorker playerStatusWorker) { this.dmpGame = dmpGame; this.dmpSettings = dmpSettings; this.chatWorker = chatWorker; this.networkWorker = networkWorker; this.playerStatusWorker = playerStatusWorker; dmpGame.updateEvent.Add(Update); dmpGame.drawEvent.Add(Draw); }
public PlayerStatusWorker(DMPGame dmpGame, Settings dmpSettings, VesselWorker vesselWorker, LockSystem lockSystem, NetworkWorker networkWorker) { this.dmpGame = dmpGame; this.vesselWorker = vesselWorker; this.lockSystem = lockSystem; this.networkWorker = networkWorker; myPlayerStatus = new PlayerStatus(); myPlayerStatus.playerName = dmpSettings.playerName; myPlayerStatus.statusText = "Syncing"; dmpGame.updateEvent.Add(Update); }
public DebugWindow(DMPGame dmpGame, Settings dmpSettings, TimeSyncer timeSyncer, NetworkWorker networkWorker, VesselWorker vesselWorker, DynamicTickWorker dynamicTickWorker, WarpWorker warpWorker) { this.dmpGame = dmpGame; this.dmpSettings = dmpSettings; this.timeSyncer = timeSyncer; this.networkWorker = networkWorker; this.vesselWorker = vesselWorker; this.dynamicTickWorker = dynamicTickWorker; this.warpWorker = warpWorker; dmpGame.updateEvent.Add(Update); dmpGame.drawEvent.Add(Draw); }
public PlayerStatusWorker(DMPGame dmpGame, Settings dmpSettings, VesselWorker vesselWorker, LockSystem lockSystem, NetworkWorker networkWorker, Permissions permissions) { this.dmpGame = dmpGame; this.vesselWorker = vesselWorker; this.lockSystem = lockSystem; this.networkWorker = networkWorker; this.permissions = permissions; myPlayerStatus = new PlayerStatus(); myPlayerStatus.playerName = dmpSettings.playerName; myPlayerStatus.statusText = "Syncing"; updateAction = new NamedAction(Update); dmpGame.updateEvent.Add(updateAction); }
public CraftLibraryWorker(DMPGame dmpGame, Settings dmpSettings, NetworkWorker networkWorker) { this.dmpGame = dmpGame; this.dmpSettings = dmpSettings; this.networkWorker = networkWorker; savePath = Path.Combine(Path.Combine(Client.dmpClient.kspRootPath, "saves"), "DarkMultiPlayer"); vabPath = Path.Combine(Path.Combine(savePath, "Ships"), "VAB"); sphPath = Path.Combine(Path.Combine(savePath, "Ships"), "SPH"); subassemblyPath = Path.Combine(savePath, "Subassemblies"); BuildUploadList(); dmpGame.updateEvent.Add(Update); dmpGame.drawEvent.Add(Draw); }
public DebugWindow(DMPGame dmpGame, Settings dmpSettings, TimeSyncer timeSyncer, NetworkWorker networkWorker, VesselWorker vesselWorker, DynamicTickWorker dynamicTickWorker, WarpWorker warpWorker, VesselRecorder vesselRecorder, PosistionStatistics posistionStatistics, OptionsWindow optionsWindow) { this.dmpGame = dmpGame; this.dmpSettings = dmpSettings; this.timeSyncer = timeSyncer; this.networkWorker = networkWorker; this.vesselWorker = vesselWorker; this.dynamicTickWorker = dynamicTickWorker; this.warpWorker = warpWorker; this.vesselRecorder = vesselRecorder; this.posistionStatistics = posistionStatistics; this.optionsWindow = optionsWindow; dmpGame.updateEvent.Add(Update); dmpGame.drawEvent.Add(Draw); }
public PlayerStatusWindow(DMPGame dmpGame, Settings dmpSettings, WarpWorker warpWorker, ChatWorker chatWorker, CraftLibraryWorker craftLibraryWorker, DebugWindow debugWindow, ScreenshotWorker screenshotWorker, TimeSyncer timeSyncer, PlayerStatusWorker playerStatusWorker, OptionsWindow optionsWindow, PlayerColorWorker playerColorWorker) { this.dmpGame = dmpGame; this.dmpSettings = dmpSettings; this.warpWorker = warpWorker; this.chatWorker = chatWorker; this.craftLibraryWorker = craftLibraryWorker; this.debugWindow = debugWindow; this.screenshotWorker = screenshotWorker; this.timeSyncer = timeSyncer; this.playerStatusWorker = playerStatusWorker; this.optionsWindow = optionsWindow; this.playerColorWorker = playerColorWorker; dmpGame.updateEvent.Add(Update); dmpGame.drawEvent.Add(Draw); }
public PlayerStatusWindow(DMPGame dmpGame, Settings dmpSettings, WarpWorker warpWorker, ChatWorker chatWorker, CraftLibraryWorker craftLibraryWorker, ScreenshotWorker screenshotWorker, TimeSyncer timeSyncer, PlayerStatusWorker playerStatusWorker, OptionsWindow optionsWindow, PlayerColorWorker playerColorWorker, GroupsWindow groupsWindow, PermissionsWindow permissionsWindow) { this.dmpGame = dmpGame; this.dmpSettings = dmpSettings; this.warpWorker = warpWorker; this.chatWorker = chatWorker; this.craftLibraryWorker = craftLibraryWorker; this.screenshotWorker = screenshotWorker; this.timeSyncer = timeSyncer; this.playerStatusWorker = playerStatusWorker; this.optionsWindow = optionsWindow; this.playerColorWorker = playerColorWorker; this.groupsWindow = groupsWindow; this.permissionsWindow = permissionsWindow; updateAction = new NamedAction(Update); drawAction = new NamedAction(Draw); this.dmpGame.updateEvent.Add(updateAction); this.dmpGame.drawEvent.Add(drawAction); }
public ChatWorker(DMPGame dmpGame, Settings dmpSettings, NetworkWorker networkWorker, AdminSystem adminSystem, PlayerStatusWorker playerStatusWorker) { this.dmpGame = dmpGame; this.dmpSettings = dmpSettings; this.networkWorker = networkWorker; this.adminSystem = adminSystem; this.playerStatusWorker = playerStatusWorker; RegisterChatCommand("help", DisplayHelp, "Displays this help"); RegisterChatCommand("join", JoinChannel, "Joins a new chat channel"); RegisterChatCommand("query", StartQuery, "Starts a query"); RegisterChatCommand("leave", LeaveChannel, "Leaves the current channel"); RegisterChatCommand("part", LeaveChannel, "Leaves the current channel"); RegisterChatCommand("ping", ServerPing, "Pings the server"); RegisterChatCommand("motd", ServerMOTD, "Gets the current Message of the Day"); RegisterChatCommand("resize", ResizeChat, "Resized the chat window"); RegisterChatCommand("version", DisplayVersion, "Displays the current version of DMP"); dmpGame.updateEvent.Add(Update); dmpGame.drawEvent.Add(Draw); }
public void Update() { long startClock = Profiler.DMPReferenceTime.ElapsedTicks; lastClockTicks = DateTime.UtcNow.Ticks; lastRealTimeSinceStartup = Time.realtimeSinceStartup; DarkLog.Update(); if (modDisabled) { return; } try { if (HighLogic.LoadedScene == GameScenes.MAINMENU) { if (!modWorker.dllListBuilt) { modWorker.dllListBuilt = true; modWorker.BuildDllFileList(); } if (!dmpSaveChecked) { dmpSaveChecked = true; SetupBlankGameIfNeeded(); } } //Handle GUI events if (!connectionWindow.renameEventHandled) { dmpSettings.SaveSettings(); connectionWindow.renameEventHandled = true; } if (!connectionWindow.addEventHandled) { dmpSettings.servers.Add(connectionWindow.addEntry); connectionWindow.addEntry = null; dmpSettings.SaveSettings(); connectionWindow.addingServer = false; connectionWindow.addEventHandled = true; } if (!connectionWindow.editEventHandled) { dmpSettings.servers[connectionWindow.selected].name = connectionWindow.editEntry.name; dmpSettings.servers[connectionWindow.selected].address = connectionWindow.editEntry.address; dmpSettings.servers[connectionWindow.selected].port = connectionWindow.editEntry.port; connectionWindow.editEntry = null; dmpSettings.SaveSettings(); connectionWindow.addingServer = false; connectionWindow.editEventHandled = true; } if (!connectionWindow.removeEventHandled) { dmpSettings.servers.RemoveAt(connectionWindow.selected); connectionWindow.selected = -1; dmpSettings.SaveSettings(); connectionWindow.removeEventHandled = true; } if (!connectionWindow.connectEventHandled) { connectionWindow.connectEventHandled = true; dmpGame = new DMPGame(dmpSettings, universeSyncCache, modWorker, connectionWindow, dmpModInterface, toolbarSupport, optionsWindow); dmpGame.networkWorker.ConnectToServer(dmpSettings.servers[connectionWindow.selected].address, dmpSettings.servers[connectionWindow.selected].port); } if (commandLineConnect != null && HighLogic.LoadedScene == GameScenes.MAINMENU && Time.timeSinceLevelLoad > 1f) { dmpGame = new DMPGame(dmpSettings, universeSyncCache, modWorker, connectionWindow, dmpModInterface, toolbarSupport, optionsWindow); dmpGame.networkWorker.ConnectToServer(commandLineConnect.address, commandLineConnect.port); commandLineConnect = null; } if (!connectionWindow.disconnectEventHandled) { connectionWindow.disconnectEventHandled = true; if (dmpGame != null) { if (dmpGame.networkWorker.state == ClientState.CONNECTING) { dmpGame.networkWorker.Disconnect("Cancelled connection to server"); } else { dmpGame.networkWorker.SendDisconnect("Quit during initial sync"); } dmpGame.Stop(); dmpGame = null; } } connectionWindow.Update(); modWindow.Update(); optionsWindow.Update(); universeConverterWindow.Update(); dmpModInterface.Update(); if (dmpGame != null) { foreach (Action updateAction in dmpGame.updateEvent) { try { updateAction(); } catch (Exception e) { DarkLog.Debug("Threw in UpdateEvent, exception: " + e); if (dmpGame.networkWorker.state != ClientState.RUNNING) { if (dmpGame.networkWorker.state != ClientState.DISCONNECTED) { dmpGame.networkWorker.SendDisconnect("Unhandled error while syncing!"); } else { dmpGame.networkWorker.Disconnect("Unhandled error while syncing!"); } } } } } //Force quit if (dmpGame != null && dmpGame.forceQuit) { dmpGame.forceQuit = false; dmpGame.Stop(); dmpGame = null; StopGame(); } if (displayDisconnectMessage) { if (HighLogic.LoadedScene != GameScenes.MAINMENU) { if ((Client.realtimeSinceStartup - lastDisconnectMessageCheck) > 1f) { lastDisconnectMessageCheck = Client.realtimeSinceStartup; if (disconnectMessage != null) { disconnectMessage.duration = 0; } disconnectMessage = ScreenMessages.PostScreenMessage("You have been disconnected!", 2f, ScreenMessageStyle.UPPER_CENTER); } } else { displayDisconnectMessage = false; } } //Normal quit if (dmpGame != null && dmpGame.running) { if (!dmpGame.playerStatusWindow.disconnectEventHandled) { dmpGame.playerStatusWindow.disconnectEventHandled = true; dmpGame.forceQuit = true; dmpGame.scenarioWorker.SendScenarioModules(true); // Send scenario modules before disconnecting dmpGame.networkWorker.SendDisconnect("Quit"); } if (dmpGame.screenshotWorker.uploadScreenshot) { dmpGame.screenshotWorker.uploadScreenshot = false; StartCoroutine(UploadScreenshot()); } if (HighLogic.CurrentGame.flagURL != dmpSettings.selectedFlag) { DarkLog.Debug("Saving selected flag"); dmpSettings.selectedFlag = HighLogic.CurrentGame.flagURL; dmpSettings.SaveSettings(); dmpGame.flagSyncer.flagChangeEvent = true; } // save every GeeASL from each body in FlightGlobals if (HighLogic.LoadedScene == GameScenes.FLIGHT && bodiesGees.Count == 0) { foreach (CelestialBody body in FlightGlobals.fetch.bodies) { bodiesGees.Add(body, body.GeeASL); } } //handle use of cheats if (!dmpGame.serverAllowCheats) { CheatOptions.InfinitePropellant = false; CheatOptions.NoCrashDamage = false; CheatOptions.IgnoreAgencyMindsetOnContracts = false; CheatOptions.IgnoreMaxTemperature = false; CheatOptions.InfiniteElectricity = false; CheatOptions.NoCrashDamage = false; CheatOptions.UnbreakableJoints = false; foreach (KeyValuePair <CelestialBody, double> gravityEntry in bodiesGees) { gravityEntry.Key.GeeASL = gravityEntry.Value; } } if (HighLogic.LoadedScene == GameScenes.FLIGHT && FlightGlobals.ready) { HighLogic.CurrentGame.Parameters.Flight.CanLeaveToSpaceCenter = !dmpGame.vesselWorker.isSpectating && dmpSettings.revertEnabled || (PauseMenu.canSaveAndExit == ClearToSaveStatus.CLEAR); } else { HighLogic.CurrentGame.Parameters.Flight.CanLeaveToSpaceCenter = true; } if (HighLogic.LoadedScene == GameScenes.MAINMENU) { dmpGame.networkWorker.SendDisconnect("Quit to main menu"); dmpGame.Stop(); dmpGame = null; } } if (dmpGame != null && dmpGame.startGame) { dmpGame.startGame = false; StartGame(); } } catch (Exception e) { if (dmpGame != null) { DarkLog.Debug("Threw in Update, state " + dmpGame.networkWorker.state.ToString() + ", exception: " + e); if (dmpGame.networkWorker.state != ClientState.RUNNING) { if (dmpGame.networkWorker.state != ClientState.DISCONNECTED) { dmpGame.networkWorker.SendDisconnect("Unhandled error while syncing!"); } else { dmpGame.networkWorker.Disconnect("Unhandled error while syncing!"); } } } else { DarkLog.Debug("Threw in Update, state NO_NETWORKWORKER, exception: " + e); } } Profiler.updateData.ReportTime(startClock); }
public void SetDependencies(DMPGame dmpGame, NetworkWorker networkWorker, PlayerColorWorker playerColorWorker) { this.networkWorker = networkWorker; this.playerColorWorker = playerColorWorker; this.dmpGame = dmpGame; }
public void Stop() { networkWorker = null; playerColorWorker = null; dmpGame = null; }
public void ConnectToServer(string address, int port) { dmpGame = new DMPGame(dmpSettings, universeSyncCache, modWorker, connectionWindow, dmpModInterface, toolbarSupport, optionsWindow, profiler); dmpGame.networkWorker.ConnectToServer(address, port); }