public void Start() { if (autostart) { HighLogic.SaveFolder = save_name; DebugToolbar.toolbarShown = true; if (mode == "editor") { var editor = EditorFacility.VAB; GamePersistence.LoadGame("persistent", HighLogic.SaveFolder, true, false); if (craft_name != null || craft_name != "") { string path = Paths.joined(KSPUtil.ApplicationRootPath, "saves", save_name, "Ships", "VAB", craft_name + ".craft"); EditorDriver.StartAndLoadVessel(path, editor); } else { EditorDriver.StartEditor(editor); } } else if (mode == "spacecenter") { HighLogic.LoadScene(GameScenes.SPACECENTER); } else if (mode == "flight") { FlightDriver.StartAndFocusVessel("quicksave", 1); } } }
private static void SwitchVesselIfSpectating(Vessel killVessel) { if (FlightGlobals.ActiveVessel?.id == killVessel.id) { //Try to switch to a nearby loaded vessel... var otherVessel = FlightGlobals.VesselsLoaded.FirstOrDefault(v => v.id != killVessel.id); //No nearby vessel detected... Get a random vessel and switch to it if exists, otherwise go to spacecenter if (otherVessel == null) { otherVessel = FlightGlobals.Vessels.FirstOrDefault(v => v.id != killVessel.id); } if (otherVessel != null) { FlightGlobals.ForceSetActiveVessel(otherVessel); } else { HighLogic.LoadScene(GameScenes.SPACECENTER); } LunaScreenMsg.PostScreenMessage(LocalizationContainer.ScreenText.SpectatingRemoved, 10f, ScreenMessageStyle.UPPER_CENTER); } }
internal void SpaceCenterAction() { switch (facType) { case KKFacilityType.Barracks: var acPrefab = FindObjectOfType <ACSceneSpawner>(); UIMasterController.Instance.AddCanvas(acPrefab.ACScreenPrefab, true); break; case KKFacilityType.Business: if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER) { var adminPrefab = FindObjectOfType <AdministrationSceneSpawner>(); UIMasterController.Instance.AddCanvas(adminPrefab.AdministrationScreenPrefab, true); } break; case KKFacilityType.Research: if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER || HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX) { var researchPrefab = FindObjectOfType <RDSceneSpawner>(); UIMasterController.Instance.AddCanvas(researchPrefab.RDScreenPrefab, true); } break; case KKFacilityType.GroundStation: HighLogic.LoadScene(GameScenes.TRACKSTATION); break; } }
// IEnumerator loadScene(GameScenes scenes, EditorFacility facility = EditorFacility.None) void loadScene(GameScenes scenes, EditorFacility facility = EditorFacility.None) { //yield return new WaitForEndOfFrame (); if (scenes != GameScenes.EDITOR) { HighLogic.LoadScene(scenes); } else if (facility != EditorFacility.None) { EditorFacility editorFacility = EditorFacility.None; if (ShipConstruction.ShipConfig != null) { editorFacility = ShipConstruction.ShipType; } if (HighLogic.LoadedSceneIsFlight && FlightGlobals.fetch) { FlightGlobals.PersistentVesselIds.Clear(); FlightGlobals.PersistentLoadedPartIds.Clear(); FlightGlobals.PersistentUnloadedPartIds.Clear(); } EditorDriver.StartupBehaviour = (editorFacility == facility ? EditorDriver.StartupBehaviours.LOAD_FROM_CACHE : EditorDriver.StartupBehaviours.START_CLEAN); EditorDriver.StartEditor(facility); } InputLockManager.ClearControlLocks(); }
public void Start() { if (HighLogic.LoadedScene == GameScenes.MAINMENU) { //only do it on the first entry to the menu if (first) { first = false; var windowPtr = FindWindow(null, "Kerbal Space Program"); if (windowPtr != null) { // this is handy to have AutoSizer or similar program correctly set the window position when launching SetWindowText(windowPtr, "KSP - Trajectories Debug"); } HighLogic.SaveFolder = "default"; HighLogic.LoadScene(GameScenes.SPACECENTER); // When debugging, we are dirty cheating alpacas. CheatOptions.InfiniteElectricity = true; CheatOptions.InfinitePropellant = true; CheatOptions.IgnoreMaxTemperature = true; } } }
private void PerformPostPlacementAction() { if (HighLogic.CurrentGame.Parameters.CustomParams <WA>().noreload) { "Suppressed reload of SPACECENTER".Log(); } if (HighLogic.CurrentGame.Parameters.CustomParams <WA>().jumpto) { var vessel = FindVesselByName(_mainGui.RequestedPlacement.Kerbal.name); if (vessel == null) { $"Unable to jump to vessel - no vessel found".Log(); } else { $"Loading Flight scene for {vessel.name}".Log(); FlightDriver.StartAndFocusVessel("persistent", FlightGlobals.Vessels.IndexOf(vessel)); } } if (HighLogic.CurrentGame.Parameters.CustomParams <WA>().reload || (!HighLogic.CurrentGame.Parameters.CustomParams <WA>().jumpto&& !HighLogic.CurrentGame.Parameters.CustomParams <WA>().noreload)) { "Reloading SPACECENTER".Log(); HighLogic.LoadScene(GameScenes.SPACECENTER); } }
private static bool PrefixSetStartupNewVessel() { if (MainSystem.NetworkState < ClientState.Connected || string.IsNullOrEmpty(FlightDriver.newShipToLoadPath)) { return(true); } var configNode = ConfigNode.Load(FlightDriver.newShipToLoadPath); var shipName = configNode.GetValue("ship"); var partNames = configNode.GetNodes("PART").Select(n => n.GetValue("part").Substring(0, n.GetValue("part").IndexOf('_'))).ToList(); var partCount = configNode.GetNodes("PART").Count(); if (ModSystem.Singleton.ModControl) { var bannedParts = ModSystem.Singleton.GetBannedPartsFromPartNames(partNames.Distinct()).ToArray(); if (bannedParts.Any()) { LunaLog.LogError($"Vessel {shipName} Contains the following banned parts: {string.Join(", ", bannedParts)}"); BannedPartsWindow.Singleton.DisplayBannedPartsDialog(shipName, bannedParts); HighLogic.LoadScene(GameScenes.SPACECENTER); return(false); } } if (partCount > SettingsSystem.ServerSettings.MaxVesselParts) { LunaLog.LogError($"Vessel {shipName} has {partCount} parts and the max allowed in the server is: {SettingsSystem.ServerSettings.MaxVesselParts}"); BannedPartsWindow.Singleton.DisplayBannedPartsDialog(shipName, partCount); HighLogic.LoadScene(GameScenes.SPACECENTER); return(false); } return(true); }
public void Start() { //only do it on the first entry to the menu if (first) { first = false; HighLogic.SaveFolder = "default"; Game game = GamePersistence.LoadGame("persistent", HighLogic.SaveFolder, true, false); if (game != null && game.flightState != null && game.compatible) { HighLogic.CurrentGame = game; HighLogic.LoadScene(GameScenes.SPACECENTER); //Int32 FirstVessel; //Boolean blnFoundVessel = false; //for (FirstVessel = 0; FirstVessel < game.flightState.protoVessels.Count; FirstVessel++) //{ // if (game.flightState.protoVessels[FirstVessel].vesselType != VesselType.SpaceObject && // game.flightState.protoVessels[FirstVessel].vesselType != VesselType.Unknown) // { // blnFoundVessel = true; // break; // } //} //if (!blnFoundVessel) // FirstVessel = 0; //FlightDriver.StartAndFocusVessel(game, FirstVessel); } //CheatOptions.InfiniteFuel = true; } }
public void RemoveVessel(Guid vesselId, bool isDockingUpdate, string dockingPlayer) { var vessel = FlightGlobals.Vessels.FirstOrDefault(v => v.id == vesselId); if (vessel == null) { return; } if (isDockingUpdate) { if (FlightGlobals.ActiveVessel?.id == vessel.id) { var dockingPlayerVessel = FlightGlobals.Vessels .FirstOrDefault(v => LockSystem.Singleton.LockOwner("control-" + v.id) == dockingPlayer); if (dockingPlayerVessel != null) { FlightGlobals.ForceSetActiveVessel(dockingPlayerVessel); } else { HighLogic.LoadScene(GameScenes.TRACKSTATION); ScreenMessages.PostScreenMessage("Kicked to tracking station, a player docked with you but they were not loaded into the game."); } } Debug.Log($"[LMP]: Removing docked vessel: {vesselId}"); System.KillVessel(vessel, true); } else { Debug.Log($"[LMP]: Removing vessel: {vesselId}"); System.KillVessel(vessel, true); } }
void GUIActive(int windowID) { if (HighLogic.LoadedScene == GameScenes.SETTINGS) { GUI.BringWindowToFront(09271); } GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Label("Width: "); xString = GUILayout.TextField(xString); xString = Regex.Replace(xString, @"[^0-9]", ""); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Height: "); yString = GUILayout.TextField(yString); yString = Regex.Replace(yString, @"[^0-9]", ""); GUILayout.EndHorizontal(); fullScreen = GUILayout.Toggle(fullScreen, "Fullscreen"); reloadScene = GUILayout.Toggle(reloadScene, "Reload scene"); if (GUILayout.Button("Set Screen Resolution")) { if (xString != null && yString != null) { x = Convert.ToInt32(xString); y = Convert.ToInt32(yString); if (x > 0 && y > 0) { GameSettings.SCREEN_RESOLUTION_HEIGHT = y; GameSettings.SCREEN_RESOLUTION_WIDTH = x; GameSettings.FULLSCREEN = fullScreen; GameSettings.SaveSettings(); Screen.SetResolution(x, y, fullScreen); if (reloadScene) { if (HighLogic.LoadedScene != GameScenes.LOADING) { HighLogic.LoadScene(HighLogic.LoadedScene); } else { ScreenMessages.PostScreenMessage("You cannot reload the scene while loading the game!", 1); } } } else { ScreenMessages.PostScreenMessage("One or both of your values is too small. Please enter a valid value.", 1, ScreenMessageStyle.UPPER_CENTER); } } else { ScreenMessages.PostScreenMessage("The values you have set are invalid. Please set a valid value.", 1, ScreenMessageStyle.UPPER_CENTER); } } GUILayout.EndVertical(); GUI.DragWindow(); }
private void OnApplicationQuit() { if (gameRunning && NetworkWorker.fetch.state == ClientState.RUNNING) { Application.CancelQuit(); ScenarioWorker.fetch.SendScenarioModules(true); HighLogic.LoadScene(GameScenes.MAINMENU); } }
private void StopGame() { HighLogic.SaveFolder = "DarkMultiPlayer"; if (HighLogic.LoadedScene != GameScenes.MAINMENU) { HighLogic.LoadScene(GameScenes.MAINMENU); } HighLogic.CurrentGame = null; }
private void StopGame() { HighLogic.SaveFolder = "DarkMultiPlayer"; GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE); if (HighLogic.LoadedScene != GameScenes.MAINMENU) { HighLogic.LoadScene(GameScenes.MAINMENU); } }
void mainMenuWindow(int windowID) { GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); if (GUILayout.Button(TradingButton, HighLogic.Skin.button)) { trading.checkPrice(vessel.orbit.referenceBody.name, vessel.orbit.semiMajorAxis); menuWindow = false; trading.DrawGUIWindow = true; } if (GUILayout.Button(CrewHireButton, HighLogic.Skin.button)) { menuWindow = false; crewHire.GenerateCrew(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button(AsteroidButton, HighLogic.Skin.button)) { menuWindow = false; asteroid.asteroidGUI = true; } if (GUILayout.Button(ShipShopButton, HighLogic.Skin.button)) { menuWindow = false; shipShop.MenuWindow = true; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button(ExplorationButton, HighLogic.Skin.button)) { menuWindow = false; exploration.infoWindow = true; } if (GUILayout.Button(Contract, HighLogic.Skin.button)) { GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.BACKUP); HighLogic.LoadScene(GameScenes.SPACECENTER); menuWindow = false; } if (part.partInfo.name == "pirateStationScreen") { if (GUILayout.Button(SlaveTrafficButton, HighLogic.Skin.button)) { slavesTraffic.CheckPrice(vessel.mainBody.name); menuWindow = false; slavesTraffic.slaveWindow = true; } } GUILayout.EndHorizontal(); if (GUILayout.Button("close", HighLogic.Skin.button)) { menuWindow = false; } GUILayout.EndVertical(); }
private void OnApplicationQuit() { if (dmpGame != null && dmpGame.networkWorker.state == ClientState.RUNNING) { Application.CancelQuit(); dmpGame.scenarioWorker.SendScenarioModules(true); HighLogic.LoadScene(GameScenes.MAINMENU); } }
// static functions, that make live a lot easier /// <summary> /// Stores a Vessel into the specified Hangar /// </summary> internal static void StoreVessel(Vessel vessel, Hangar hangar) { StoredVessel storedVessel = new StoredVessel { uuid = vessel.protoVessel.vesselID, vesselName = vessel.GetDisplayName() }; //get the experience and assign the crew to the rooster foreach (Part part in vessel.parts) { int count = part.protoModuleCrew.Count; if (count != 0) { ProtoCrewMember[] crewList = part.protoModuleCrew.ToArray(); for (int i = 0; i < count; i++) { crewList[i].flightLog.AddEntryUnique(FlightLog.EntryType.Recover); crewList[i].flightLog.AddEntryUnique(FlightLog.EntryType.Land, FlightGlobals.currentMainBody.name); crewList[i].ArchiveFlightLog(); // remove the crew from the ship part.RemoveCrewmember(crewList[i]); } } } // save the ship storedVessel.vesselNode = new ConfigNode("VESSEL"); //create a backup of the current state, then save that state ProtoVessel backup = vessel.BackupVessel(); backup.Save(storedVessel.vesselNode); // save the stored information in the hangar hangar.storedVessels.Add(storedVessel); // remove the stored vessel from the game vessel.MakeInactive(); vessel.Unload(); //vessel.Die(); FlightGlobals.RemoveVessel(vessel); if (vessel != null) { vessel.protoVessel.Clean(); } //UnityEngine.Object.Destroy(vessel.gameObject); GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE); HighLogic.LoadScene(GameScenes.SPACECENTER); }
private void StopGame() { HighLogic.SaveFolder = "LunaMultiPlayer"; if (HighLogic.LoadedScene != GameScenes.MAINMENU) { HighLogic.LoadScene(GameScenes.MAINMENU); } //HighLogic.CurrentGame = null; This is no bueno BodiesGees.Clear(); }
private bool WantsToQuit() { if (dmpGame != null && dmpGame.networkWorker.state == ClientState.RUNNING) { dmpGame.scenarioWorker.SendScenarioModules(true); HighLogic.LoadScene(GameScenes.MAINMENU); return(false); } return(true); }
public void FixedUpdate() { if (first) { first = false; HighLogic.SaveFolder = "default"; var game = GamePersistence.LoadGame("persistent", HighLogic.SaveFolder, true, false); if (game != null && game.flightState != null && game.compatible) { HighLogic.LoadScene(GameScenes.TRACKSTATION); } } }
private void LoadGame(string name) { if (name.EndsWith(".sfs")) { name = name.Substring(0, name.Length - 4); } if (HighLogic.CurrentGame.Parameters.Flight.CanQuickLoad) { string filename = name + ".sfs"; string path = KSPUtil.GetOrCreatePath("saves/" + HighLogic.SaveFolder); if (!File.Exists(Path.Combine(path, filename))) { throw new KOSException("Error loading the quicksave file, the save file does not exist."); } shared.Cpu.GetCurrentOpcode().AbortProgram = true; try { SaveGame("kos-backup-quicksave"); var game = GamePersistence.LoadGame(name, HighLogic.SaveFolder, true, false); if (game.flightState != null) { if (game.compatible) { GamePersistence.UpdateScenarioModules(game); if (game.startScene != GameScenes.FLIGHT) { if (KSPUtil.CheckVersion(game.file_version_major, game.file_version_minor, game.file_version_revision, 0, 24, 0) != VersionCompareResult.INCOMPATIBLE_TOO_EARLY) { GamePersistence.SaveGame(game, name, HighLogic.SaveFolder, SaveMode.OVERWRITE); HighLogic.LoadScene(GameScenes.SPACECENTER); return; } } FlightDriver.StartAndFocusVessel(game, game.flightState.activeVesselIdx); } } } catch (Exception ex) { SafeHouse.Logger.Log(ex.Message); throw new KOSException("Error loading the quicksave file"); } } else { throw new KOSException("KSP prevents using quickload currently."); } }
private static void SwitchVesselIfSpectating(Vessel killVessel) { if (VesselCommon.IsSpectating && FlightGlobals.ActiveVessel.id == killVessel.id) { var otherVessels = FlightGlobals.Vessels.Where(v => v.id != killVessel.id).ToArray(); if (otherVessels.Any()) { FlightGlobals.ForceSetActiveVessel(otherVessels.First()); } else { HighLogic.LoadScene(GameScenes.SPACECENTER); } ScreenMessages.PostScreenMessage("The player you were spectating removed his vessel"); } }
private static void SwitchVesselIfSpectating(Vessel killVessel) { if (FlightGlobals.ActiveVessel?.id == killVessel.id) { //Get a random vessel and switch to it if exists, otherwise go to spacecenter var otherVessel = FlightGlobals.Vessels.FirstOrDefault(v => v.id != killVessel.id); if (otherVessel != null) { FlightGlobals.ForceSetActiveVessel(otherVessel); } else { HighLogic.LoadScene(GameScenes.SPACECENTER); } ScreenMessages.PostScreenMessage("The vessel you were spectating was removed", 10f); } }
IEnumerator loadScene(GameScenes scenes, EditorFacility facility = EditorFacility.None) { yield return(new WaitForEndOfFrame()); if (scenes != GameScenes.EDITOR) { HighLogic.LoadScene(scenes); } else if (facility != EditorFacility.None) { EditorFacility editorFacility = EditorFacility.None; if (ShipConstruction.ShipConfig != null) { editorFacility = ShipConstruction.ShipType; } EditorDriver.StartupBehaviour = (editorFacility == facility ? EditorDriver.StartupBehaviours.LOAD_FROM_CACHE : EditorDriver.StartupBehaviours.START_CLEAN); EditorDriver.StartEditor(facility); } InputLockManager.ClearControlLocks(); }
private static void SwitchVesselIfKillingActiveVessel(Vessel killVessel) { if (FlightGlobals.ActiveVessel && FlightGlobals.ActiveVessel.id == killVessel.id) { FlightGlobals.fetch.SetVesselTarget(null); //Try to switch to a nearby loaded vessel... var otherVessel = FlightGlobals.FindNearestControllableVessel(killVessel); if (otherVessel != null) { FlightGlobals.ForceSetActiveVessel(otherVessel); } else { HighLogic.LoadScene(GameScenes.SPACECENTER); } LunaScreenMsg.PostScreenMessage(LocalizationContainer.ScreenText.SpectatingRemoved, 10f, ScreenMessageStyle.UPPER_CENTER); } }
static void onPipelineFinished(ConfigNode node, string saveName, Version originalVersion) { var game = GamePersistence.LoadGameCfg(node, saveName, true, false); if (game != null && game.flightState != null) { if (game.compatible) { GamePersistence.UpdateScenarioModules(game); if (node != null) { GameEvents.onGameStatePostLoad.Fire(node); } if (game.startScene != GameScenes.FLIGHT && originalVersion >= new Version(0, 24, 0)) { GamePersistence.SaveGame(game, "persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE); HighLogic.LoadScene(GameScenes.SPACECENTER); return; } } FlightDriver.StartAndFocusVessel(game, game.flightState.activeVesselIdx); } }
void GUIActive(int windowID) { #if false if (HighLogic.LoadedScene == GameScenes.SETTINGS) { GUI.BringWindowToFront(09271); } #endif GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Label("Name: "); nameString = GUILayout.TextField(nameString); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Width: "); xString = GUILayout.TextField(xString); xString = Regex.Replace(xString, @"[^0-9]", ""); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Height: "); yString = GUILayout.TextField(yString); yString = Regex.Replace(yString, @"[^0-9]", ""); GUILayout.EndHorizontal(); fullScreen = GUILayout.Toggle(fullScreen, "Fullscreen"); reloadScene = GUILayout.Toggle(reloadScene, "Reload scene"); if (GUILayout.Button("Set Screen Resolution")) { if (xString != null && yString != null) { x = Convert.ToInt32(xString); y = Convert.ToInt32(yString); if (x > 0 && y > 0) { GameSettings.SCREEN_RESOLUTION_HEIGHT = y; GameSettings.SCREEN_RESOLUTION_WIDTH = x; GameSettings.FULLSCREEN = fullScreen; GameSettings.SaveSettings(); Screen.SetResolution(x, y, fullScreen); Log.detail("Set screen resolution"); if (reloadScene) { if (HighLogic.LoadedScene != GameScenes.LOADING) { HighLogic.LoadScene(HighLogic.LoadedScene); } else { ScreenMessages.PostScreenMessage("You cannot reload the scene while loading the game!", 1); } } } else { ScreenMessages.PostScreenMessage("One or both of your values is too small. Please enter a valid value.", 1, ScreenMessageStyle.UPPER_CENTER); } } else { ScreenMessages.PostScreenMessage("The values you have set are invalid. Please set a valid value.", 1, ScreenMessageStyle.UPPER_CENTER); } } if (nameString == "") { GUI.enabled = false; } if (GUILayout.Button("Save")) { string newName = nameString; string newX = xString; string newY = yString; bool newFullscreen = fullScreen; ConfigNode config = new ConfigNode(newName); config.AddValue("name", newName); config.AddValue("x", newX); config.AddValue("y", newY); config.AddValue("fullscreen", newFullscreen.ToString()); this.presets.Create(config); ScreenMessages.PostScreenMessage("Preset saved. You can change the preset later by using the same name in this editor.", 5, ScreenMessageStyle.UPPER_CENTER); this.presets.ReloadFiles(); } GUI.enabled = 0 != this.presets.files.Count; if (deleteEnabled) { if (GUILayout.Button("Disable Delete")) { deleteEnabled = false; } } else { if (GUILayout.Button("Enable Delete")) { deleteEnabled = true; } } if (GUILayout.Button("Close")) { toolbarButton.Active = false; } GUILayout.EndVertical(); GUILayout.BeginVertical(); scrollViewPos = GUILayout.BeginScrollView(scrollViewPos); foreach (Data.ConfigNode configNode in this.presets.files) { ConfigNode config = configNode.Node; if (deleteEnabled) { if (GUILayout.Button("Delete " + config.GetValue("name"))) { confirmDeleteEnabled = true; this.presets.MarkForDeletion(configNode); } } else { if (GUILayout.Button(config.GetValue("name"))) { int xVal; int.TryParse(config.GetValue("x"), out xVal); int yVal; int.TryParse(config.GetValue("y"), out yVal); bool fullscreen; bool.TryParse(config.GetValue("fullscreen"), out fullscreen); GameSettings.SCREEN_RESOLUTION_HEIGHT = yVal; GameSettings.SCREEN_RESOLUTION_WIDTH = xVal; GameSettings.FULLSCREEN = fullscreen; GameSettings.SaveSettings(); Screen.SetResolution(xVal, yVal, fullscreen); Log.detail("Set screen resolution from preset"); } } } GUILayout.EndScrollView(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); if (GUI.Button(new Rect(anyresWinRect.width - 18, 3f, 15f, 15f), new GUIContent("X"))) { toolbarButton.Active = false; } GUI.DragWindow(); }
public void UnityWorker() { try { var message = this.socketWorker.logMessages.TryPop(null); if (message != null) { this.Log(message); } UpdateTime(this.socketWorker.TimeUpdate); var vesselUpdate = this.socketWorker.VesselUpdate; var vessel = FlightGlobals.ActiveVessel; if (vessel == null || vessel.state == Vessel.State.DEAD || vesselUpdate == null) { // Main process has probably gone back to space center, // so let's go back to the tracking station. HighLogic.LoadScene(GameScenes.TRACKSTATION); return; } if (vesselUpdate.Id != vessel.id) { // This might look odd, but it aint my fault. // If you try and switch loaded scenes too quickly, // data structures in squad's code don't get populated // and it's exception city. if (vessel.patchedConicRenderer == null || vessel.patchedConicRenderer.solver == null || vessel.patchedConicRenderer.solver.maneuverNodes == null) { return; } // Vessel switched, tracking station code handles that TrackingStation.UpdateVessel(this, vesselUpdate); return; } this.UpdateManeuverNodes(); this.UpdateTarget(); IList <ManeuverNode> maneuvers; if (vessel.patchedConicSolver == null) { maneuvers = null; } else { maneuvers = vessel.patchedConicSolver.maneuverNodes; } this.socketWorker.Send(maneuvers, vessel.targetObject); this.UpdateVessel(vessel, vesselUpdate); } catch (Exception e) { LogException(e); throw; } }
void GUIActive(int windowID) { if (GUI.Button(new Rect(0, 0, 50, 25), "Presets")) { presets.windowEnabled = !presets.windowEnabled; if (!presets.windowEnabled) { presets.loadEnabled = false; } else { //presets.windowRect = new Rect(anyresWinRect.xMin + anyresWinRect.width, anyresWinRect.yMin, 200, 100); presets.windowRect.x = anyresWinRect.xMin + anyresWinRect.width; presets.windowRect.y = anyresWinRect.yMin; //presets.loadRect = new Rect(presets.windowRect.xMin + presets.windowRect.width, anyresWinRect.yMin, 200, 400); presets.loadRect.x = presets.windowRect.xMin + presets.windowRect.width; presets.loadRect.y = presets.windowRect.yMin; //presets.newRect = new Rect(presets.windowRect.xMin + presets.windowRect.width, anyresWinRect.yMin, 200, 230); presets.newRect.x = presets.windowRect.xMin + presets.windowRect.width; presets.newRect.y = anyresWinRect.yMin; } } if (HighLogic.LoadedScene == GameScenes.SETTINGS) { GUI.BringWindowToFront(09271); } GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Label("Width: "); xString = GUILayout.TextField(xString); xString = Regex.Replace(xString, @"[^0-9]", ""); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Height: "); yString = GUILayout.TextField(yString); yString = Regex.Replace(yString, @"[^0-9]", ""); GUILayout.EndHorizontal(); fullScreen = GUILayout.Toggle(fullScreen, "Fullscreen"); reloadScene = GUILayout.Toggle(reloadScene, "Reload scene"); if (GUILayout.Button("Set Screen Resolution")) { if (xString != null && yString != null) { x = Convert.ToInt32(xString); y = Convert.ToInt32(yString); if (x > 0 && y > 0) { GameSettings.SCREEN_RESOLUTION_HEIGHT = y; GameSettings.SCREEN_RESOLUTION_WIDTH = x; GameSettings.FULLSCREEN = fullScreen; GameSettings.SaveSettings(); Screen.SetResolution(x, y, fullScreen); Debug.Log("[AnyRes] Set screen resolution"); if (reloadScene) { if (HighLogic.LoadedScene != GameScenes.LOADING) { HighLogic.LoadScene(HighLogic.LoadedScene); } else { ScreenMessages.PostScreenMessage("You cannot reload the scene while loading the game!", 1); } } } else { ScreenMessages.PostScreenMessage("One or both of your values is too small. Please enter a valid value.", 1, ScreenMessageStyle.UPPER_CENTER); } } else { ScreenMessages.PostScreenMessage("The values you have set are invalid. Please set a valid value.", 1, ScreenMessageStyle.UPPER_CENTER); } } GUILayout.EndVertical(); GUI.DragWindow(); }
public void GoToMainMenu() { HighLogic.LoadScene(GameScenes.MAINMENU); }
private static void RenderEditMode() { BuildListVessel ship = KCTGameStates.EditedVessel; if (_finishedShipBP < 0 && ship.IsFinished) { // If ship is finished, then both build and integration times can be refreshed with newly calculated values _finishedShipBP = Utilities.GetBuildTime(ship.ExtractedPartNodes); ship.BuildPoints = _finishedShipBP; ship.IntegrationPoints = MathParser.ParseIntegrationTimeFormula(ship); } Utilities.GetShipEditProgress(ship, out double newProgressBP, out double originalCompletionPercent, out double newCompletionPercent); GUILayout.Label($"Original: {Math.Max(0, Math.Round(100 * originalCompletionPercent, 2))}%"); GUILayout.Label($"Edited: {Math.Round(100 * newCompletionPercent, 2)}%"); BuildListVessel.ListType type = EditorLogic.fetch.launchSiteName == "LaunchPad" ? BuildListVessel.ListType.VAB : BuildListVessel.ListType.SPH; GUILayout.BeginHorizontal(); GUILayout.Label("Build Time at "); if (BuildRateForDisplay == null) { BuildRateForDisplay = Utilities.GetBuildRate(0, type, null).ToString(); } BuildRateForDisplay = GUILayout.TextField(BuildRateForDisplay, GUILayout.Width(75)); GUILayout.Label(" BP/s:"); List <double> rates = new List <double>(); if (ship.Type == BuildListVessel.ListType.VAB) { rates = Utilities.GetVABBuildRates(null); } else { rates = Utilities.GetSPHBuildRates(null); } if (double.TryParse(BuildRateForDisplay, out double bR)) { if (GUILayout.Button(new GUIContent("*", "Switch build line that is used for build time calculations"), GUILayout.ExpandWidth(false))) { _rateIndexHolder = (_rateIndexHolder + 1) % rates.Count; bR = rates[_rateIndexHolder]; BuildRateForDisplay = bR.ToString(); } GUILayout.EndHorizontal(); GUILayout.Label(MagiCore.Utilities.GetFormattedTime(Math.Abs(KCTGameStates.EditorBuildTime + KCTGameStates.EditorIntegrationTime - newProgressBP) / bR)); } else { GUILayout.EndHorizontal(); GUILayout.Label("Invalid Build Rate"); } GUILayout.BeginHorizontal(); if (GUILayout.Button("Save Edits")) { _finishedShipBP = -1; Utilities.SaveShipEdits(ship); } if (GUILayout.Button("Cancel Edits")) { KCTDebug.Log("Edits cancelled."); _finishedShipBP = -1; ScrapYardWrapper.ProcessVessel(KCTGameStates.EditedVessel.ExtractedPartNodes); KCTGameStates.ClearVesselEditMode(); HighLogic.LoadScene(GameScenes.SPACECENTER); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Simulate")) { _finishedShipBP = -1; _simulationConfigPosition.height = 1; EditorLogic.fetch.Lock(true, true, true, "KCTGUILock"); GUIStates.ShowSimConfig = true; double effCost = Utilities.GetEffectiveCost(EditorLogic.fetch.ship.Parts); double bp = Utilities.GetBuildTime(effCost); KCTGameStates.LaunchedVessel = new BuildListVessel(EditorLogic.fetch.ship, EditorLogic.fetch.launchSiteName, effCost, bp, EditorLogic.FlagURL); } GUILayout.EndHorizontal(); if (KCTGameStates.LaunchedVessel != null && !KCTGameStates.LaunchedVessel.AreTanksFull() && GUILayout.Button("Fill Tanks")) { foreach (Part p in EditorLogic.fetch.ship.parts) { //fill as part prefab would be filled? if (Utilities.PartIsProcedural(p)) { foreach (PartResource rsc in p.Resources) { if (GuiDataAndWhitelistItemsDatabase.ValidFuelRes.Contains(rsc.resourceName) && rsc.flowState) { rsc.amount = rsc.maxAmount; } } } else { foreach (PartResource rsc in p.Resources) { if (GuiDataAndWhitelistItemsDatabase.ValidFuelRes.Contains(rsc.resourceName) && rsc.flowState) { PartResource templateRsc = p.partInfo.partPrefab.Resources.FirstOrDefault(r => r.resourceName == rsc.resourceName); if (templateRsc != null) { rsc.amount = templateRsc.amount; } } } } } } RenderMergeSection(ship); }