private void refreshVesselRooms() { Vessel vessel = FlightGlobals.ActiveVessel; List <Part> rooms = new List <Part> (); List <Part> stockIVAs = new List <Part> (); if (vessel != null) { ProbeControlRoomUtils.Logger.message("[ProbeControlRoom] refreshVesselRooms() - scanning vessel: " + vessel.ToString()); foreach (Part p in vessel.parts) { ProbeControlRoomPart room = p.GetComponent <ProbeControlRoomPart> (); if (room != null) { ProbeControlRoomUtils.Logger.debug("[ProbeControlRoom] refreshVesselRooms() - found ProbeControlRoomPart in: " + p.ToString()); if (p.internalModel == null) { p.CreateInternalModel(); if (p.internalModel != null) { p.internalModel.Initialize(p); p.internalModel.SetVisible(false); } ProbeControlRoomUtils.Logger.debug("[ProbeControlRoom] refreshVesselRooms() created ProbeControlRoomPart in: " + p.ToString()); } InternalModel model = p.internalModel; model.enabled = true; if (model != null) { ProbeControlRoomUtils.Logger.debug("[ProbeControlRoom] refreshVesselRooms() - found internalModel in: " + p.ToString()); rooms.Add(p); } } InternalModel imodel = p.internalModel; if (imodel != null) { ProbeControlRoomUtils.Logger.debug("[ProbeControlRoom] refreshVesselRooms() - found internalModel in: " + p.ToString()); if (p.protoModuleCrew.Count >= 1) { ProbeControlRoomUtils.Logger.debug("[ProbeControlRoom] refreshVesselRooms() - found internalModel in: " + p.ToString() + " - and it has crew!"); stockIVAs.Add(p); } } } ProbeControlRoomUtils.Logger.message("[ProbeControlRoom] refreshVesselRooms() - scanned vessel: " + vessel.ToString() + " - rooms: " + rooms.Count.ToString() + " - stockIVAs: " + stockIVAs.Count.ToString()); Instance.vesselRooms = rooms; vesselStockIVAs = stockIVAs; } else { ProbeControlRoomUtils.Logger.debug("[ProbeControlRoom] refreshVesselRooms() - no valid vessel"); vesselRooms = new List <Part> (); vesselStockIVAs = new List <Part> (); } }
void ResetCameraToIVA() { aModule = aPart.FindModulesImplementing <ProbeControlRoomPart>()[0]; Transform actualTransform = aPart.internalModel.FindModelTransform(aModule.seatTransformName); if (Transform.Equals(actualTransform, null)) { ProbeControlRoomUtils.Logger.error("ResetCameraToIVA(Part) - NULL on actualTransform-seatTransformName, using fallback..."); actualTransform = aPart.internalModel.FindModelTransform("Seat"); } else { ProbeControlRoomUtils.Logger.message("ResetCameraToIVA(Part) - Seat: " + aModule.seatTransformName.ToString()); } CameraManager.Instance.SetCameraInternal(aPart.internalModel, actualTransform); //Restore PCRIVA camera if (hassavedlookangles && field_set_internalcamera_currentPitch != null && field_set_internalcamera_currentRot != null && field_set_internalcamera_currentZoom != null) { field_set_internalcamera_currentPitch(InternalCamera.Instance, savedpitch); field_set_internalcamera_currentRot(InternalCamera.Instance, savedrot); field_set_internalcamera_currentZoom(InternalCamera.Instance, savedzoom); InternalCamera.Instance.Update(); } //Disable sun effects inside of IVA SetSun(false); ProbeControlRoomUtils.Logger.debug("ResetCameraToIVA - DONE"); }
public void stopIVA() { GameSettings.CAMERA_FX_INTERNAL = OldCameraFx; ProbeControlRoomUtils.Logger.debug("[ProbeControlRoom] stopIVA()"); isActive = false; aModule = null; aPart = null; CameraManager.ICameras_DeactivateAll(); CameraManager.Instance.SetCameraFlight(); if (UIPartActionController.Instance != null) { UIPartActionController.Instance.Activate(); } ProbeControlRoomUtils.Logger.debug("[ProbeControlRoom] stopIVA() - CHECKMARK"); if (aPartRestartTo != null) { ProbeControlRoomUtils.Logger.message("[ProbeControlRoom] stopIVA() - RestartHook found, fire!"); Part aPartRestartToCache = aPartRestartTo; aPartRestartTo = null; startIVA(aPartRestartToCache); } }
public void stopIVA() { ProbeControlRoomUtils.Logger.debug("[ProbeControlRoom] stopIVA()"); isActive = false; aModule = null; aPart = null; if (ProbeControlRoomSettings.Instance.DisableSounds) { ProbeControlRoomUtils.Logger.message("[ProbeControlRoom] stopIVA() - DisableSounds - RESTORE"); //re-enable sound GameSettings.SHIP_VOLUME = shipVolumeBackup; GameSettings.AMBIENCE_VOLUME = ambianceVolumeBackup; //GameSettings.MUSIC_VOLUME = musicVolumeBackup; //GameSettings.UI_VOLUME = uiVolumeBackup; //GameSettings.VOICE_VOLUME = voiceVolumeBackup; } if (ProbeControlRoomSettings.Instance.DisableWobble) { ProbeControlRoomUtils.Logger.message("[ProbeControlRoom] stopIVA() - DisableWobble - RESTORE"); //re-enable camera wobble GameSettings.FLT_CAMERA_WOBBLE = cameraWobbleBackup; GameSettings.CAMERA_FX_INTERNAL = cameraFXInternalBackup; GameSettings.CAMERA_FX_EXTERNAL = cameraFXExternalBackup; } CameraManager.ICameras_DeactivateAll(); CameraManager.Instance.SetCameraFlight(); if (UIPartActionController.Instance != null) { UIPartActionController.Instance.Activate(); } ProbeControlRoomUtils.Logger.debug("[ProbeControlRoom] stopIVA() - CHECKMARK"); appLauncherButton.SetTexture(IconActivate); if (aPartRestartTo != null) { ProbeControlRoomUtils.Logger.message("[ProbeControlRoom] stopIVA() - RestartHook found, fire!"); Part aPartRestartToCache = aPartRestartTo; aPartRestartTo = null; startIVA(aPartRestartToCache); } }
public bool startIVA(Part p) { ProbeControlRoomUtils.Logger.debug("[ProbeControlRoom] startIVA(Part)"); Transform actualTransform; refreshVesselRooms(); if (vesselRooms.Contains(p)) { aModule = p.FindModulesImplementing <ProbeControlRoomPart> ().First(); aPart = p; // TODO when currentReference its a dockingport, store and restore that instead? p.MakeReferencePart(); actualTransform = p.internalModel.FindModelTransform(aModule.seatTransformName); if (Transform.Equals(actualTransform, null)) { ProbeControlRoomUtils.Logger.error("[ProbeControlRoom] startIVA(Part) - NULL on actualTransform-seatTransformName, using fallback..."); actualTransform = p.internalModel.FindModelTransform("Seat"); } else { ProbeControlRoomUtils.Logger.message("[ProbeControlRoom] startIVA(Part) - Seat: " + aModule.seatTransformName.ToString()); } ProbeControlRoomUtils.Logger.debug("[ProbeControlRoom] startIVA(Part) - fire up IVA"); //disable sound shipVolumeBackup = GameSettings.SHIP_VOLUME; ambianceVolumeBackup = GameSettings.AMBIENCE_VOLUME; //musicVolumeBackup = GameSettings.MUSIC_VOLUME; //uiVolumeBackup = GameSettings.UI_VOLUME; //voiceVolumeBackup = GameSettings.VOICE_VOLUME; GameSettings.SHIP_VOLUME = 0; GameSettings.AMBIENCE_VOLUME = 0; //GameSettings.MUSIC_VOLUME = 0; //GameSettings.UI_VOLUME = 0; //GameSettings.VOICE_VOLUME = 0; //disable camera wobble cameraWobbleBackup = GameSettings.FLT_CAMERA_WOBBLE; cameraFXInternalBackup = GameSettings.CAMERA_FX_INTERNAL; cameraFXExternalBackup = GameSettings.CAMERA_FX_EXTERNAL; GameSettings.FLT_CAMERA_WOBBLE = 0; GameSettings.CAMERA_FX_INTERNAL = 0; GameSettings.CAMERA_FX_EXTERNAL = 0; CameraManager.ICameras_DeactivateAll(); FlightCamera.fetch.EnableCamera(); FlightCamera.fetch.DeactivateUpdate(); FlightCamera.fetch.gameObject.SetActive(true); FlightEVA.fetch.DisableInterface(); InternalCamera.Instance.SetTransform(actualTransform, true); InternalCamera.Instance.EnableCamera(); FlightGlobals.ActiveVessel.SetActiveInternalPart(p.internalModel.part); IVASun sunBehaviour; sunBehaviour = (IVASun)FindObjectOfType(typeof(IVASun)); sunBehaviour.enabled = false; isActive = true; if (UIPartActionController.Instance != null) { UIPartActionController.Instance.Deactivate(); } CameraManager.Instance.currentCameraMode = CameraManager.CameraMode.Internal; ProbeControlRoomUtils.Logger.debug("[ProbeControlRoom] startIVA(Part) - DONE"); return(true); } else { ProbeControlRoomUtils.Logger.error("[ProbeControlRoom] startIVA(Part) - Cannot instantiate ProbeControlRoom in this location - Part/ModuleNotFound"); throw new ArgumentException("[ProbeControlRoom] startIVA(Part) - Cannot instantiate ProbeControlRoom in this location - Part/ModuleNotFound"); //return false; } }
public void stopIVA() { ProbeControlRoomUtils.Logger.debug ("[ProbeControlRoom] stopIVA()"); isActive = false; aModule = null; aPart = null; if (ProbeControlRoomSettings.Instance.DisableSounds) { ProbeControlRoomUtils.Logger.message ("[ProbeControlRoom] stopIVA() - DisableSounds - RESTORE"); //re-enable sound GameSettings.SHIP_VOLUME = shipVolumeBackup; GameSettings.AMBIENCE_VOLUME = ambianceVolumeBackup; //GameSettings.MUSIC_VOLUME = musicVolumeBackup; //GameSettings.UI_VOLUME = uiVolumeBackup; //GameSettings.VOICE_VOLUME = voiceVolumeBackup; } if (ProbeControlRoomSettings.Instance.DisableWobble) { ProbeControlRoomUtils.Logger.message ("[ProbeControlRoom] stopIVA() - DisableWobble - RESTORE"); //re-enable camera wobble GameSettings.FLT_CAMERA_WOBBLE = cameraWobbleBackup; GameSettings.CAMERA_FX_INTERNAL = cameraFXInternalBackup; GameSettings.CAMERA_FX_EXTERNAL = cameraFXExternalBackup; } CameraManager.ICameras_DeactivateAll (); CameraManager.Instance.SetCameraFlight(); if(UIPartActionController.Instance != null) UIPartActionController.Instance.Activate (); ProbeControlRoomUtils.Logger.debug ("[ProbeControlRoom] stopIVA() - CHECKMARK"); if (aPartRestartTo != null) { ProbeControlRoomUtils.Logger.message ("[ProbeControlRoom] stopIVA() - RestartHook found, fire!"); Part aPartRestartToCache = aPartRestartTo; aPartRestartTo = null; startIVA (aPartRestartToCache); } }
public bool startIVA(Part p) { ProbeControlRoomUtils.Logger.debug ("[ProbeControlRoom] startIVA(Part)"); Transform actualTransform; refreshVesselRooms (); if(vesselRooms.Contains(p)) { aModule = p.FindModulesImplementing<ProbeControlRoomPart> ().First (); aPart = p; // TODO when currentReference its a dockingport, store and restore that instead? p.MakeReferencePart (); actualTransform = p.internalModel.FindModelTransform (aModule.seatTransformName); if (Transform.Equals (actualTransform, null)) { ProbeControlRoomUtils.Logger.error ("[ProbeControlRoom] startIVA(Part) - NULL on actualTransform-seatTransformName, using fallback..."); actualTransform = p.internalModel.FindModelTransform ("Seat"); } else { ProbeControlRoomUtils.Logger.message ("[ProbeControlRoom] startIVA(Part) - Seat: "+aModule.seatTransformName.ToString()); } ProbeControlRoomUtils.Logger.debug ("[ProbeControlRoom] startIVA(Part) - fire up IVA"); //disable sound shipVolumeBackup = GameSettings.SHIP_VOLUME; ambianceVolumeBackup = GameSettings.AMBIENCE_VOLUME; //musicVolumeBackup = GameSettings.MUSIC_VOLUME; //uiVolumeBackup = GameSettings.UI_VOLUME; //voiceVolumeBackup = GameSettings.VOICE_VOLUME; if (ProbeControlRoomSettings.Instance.DisableSounds) { ProbeControlRoomUtils.Logger.message ("[ProbeControlRoom] startIVA(Part) - DisableSounds"); GameSettings.SHIP_VOLUME = 0f; GameSettings.AMBIENCE_VOLUME = 0; GameSettings.MUSIC_VOLUME = 0; GameSettings.UI_VOLUME = 0; GameSettings.VOICE_VOLUME = 0; } //disable camera wobble cameraWobbleBackup = GameSettings.FLT_CAMERA_WOBBLE; cameraFXInternalBackup = GameSettings.CAMERA_FX_INTERNAL; cameraFXExternalBackup = GameSettings.CAMERA_FX_EXTERNAL; if (ProbeControlRoomSettings.Instance.DisableWobble) { ProbeControlRoomUtils.Logger.message ("[ProbeControlRoom] startIVA(Part) - DisableWobble"); GameSettings.FLT_CAMERA_WOBBLE = 0; GameSettings.CAMERA_FX_INTERNAL = 0; GameSettings.CAMERA_FX_EXTERNAL = 0; } // TODO: create cfg file with cached vars, on crash to be restored CameraManager.ICameras_DeactivateAll (); FlightCamera.fetch.EnableCamera (); FlightCamera.fetch.DeactivateUpdate (); FlightCamera.fetch.gameObject.SetActive (true); FlightEVA.fetch.DisableInterface (); InternalCamera.Instance.SetTransform(actualTransform, true); InternalCamera.Instance.EnableCamera (); FlightGlobals.ActiveVessel.SetActiveInternalPart (p.internalModel.part); IVASun sunBehaviour; sunBehaviour = (IVASun)FindObjectOfType(typeof(IVASun)); sunBehaviour.enabled = false; isActive = true; if(UIPartActionController.Instance != null) UIPartActionController.Instance.Deactivate (); CameraManager.Instance.currentCameraMode = CameraManager.CameraMode.Internal; ProbeControlRoomUtils.Logger.debug ("[ProbeControlRoom] startIVA(Part) - DONE"); return true; } else { ProbeControlRoomUtils.Logger.error ("[ProbeControlRoom] startIVA(Part) - Cannot instantiate ProbeControlRoom in this location - Part/ModuleNotFound"); throw new ArgumentException("[ProbeControlRoom] startIVA(Part) - Cannot instantiate ProbeControlRoom in this location - Part/ModuleNotFound"); //return false; } }
/// <summary> /// Scans vessel for usable IVA rooms and PCR rooms and initializes them as neccessary /// </summary> private void refreshVesselRooms() { ProbeControlRoomUtils.Logger.debug("refreshVesselRooms()"); Vessel vessel = FlightGlobals.ActiveVessel; //If the vessel is null, there is something wrong and no reason to continue scan if (vessel == null) { canStockIVA = false; maybecanstockiva = false; aPart = null; cachedrenderers = null; aModule = null; ProbeControlRoomUtils.Logger.error("refreshVesselRooms() - ERROR: FlightGlobals.activeVessel is NULL"); return; } canStockIVA = false; maybecanstockiva = false; for (int i = 0; i < vessel.parts.Count; i++) { Part p = vessel.parts[i]; ProbeControlRoomPart room = p.GetComponent <ProbeControlRoomPart>(); //Are we not loaded yet? if ((!HighLogic.CurrentGame.Parameters.Flight.CanIVA || vessel.packed) && p.protoModuleCrew.Count > 0) { ProbeControlRoomUtils.Logger.message("refreshVesselRooms() - Maybe we can IVA!"); maybecanstockiva = true; canStockIVA = true; } else if (HighLogic.CurrentGame.Parameters.Flight.CanIVA && p.protoModuleCrew.Count > 0 && p.internalModel != null) { ProbeControlRoomUtils.Logger.message("refreshVesselRooms() - Stock IVA possible. Part: " + p.ToString()); canStockIVA = true; } } // If our current vessel still has the old PCR part, keep it active if (aPart != null && vessel.parts.Contains(aPart)) { // If stock IVA is available then we can't have our model around, it might // interfere with stock IVA clicks. if (canStockIVA) { ProbeControlRoomUtils.Logger.debug("refreshVesselRooms() - Destroying existing PCR part due to stock IVA."); canPCRIVA = false; if (aPart.internalModel != null) { aPart.internalModel.gameObject.DestroyGameObject(); aPart.internalModel = null; } aPart = null; } else { canPCRIVA = true; ProbeControlRoomUtils.Logger.debug("refreshVesselRooms() - Old part still there, cleaning up extra rooms and returning"); //Our old part is still there and active. Clean up extras as needed and return for (int i = 0; i < vessel.parts.Count; i++) { Part p = vessel.parts[i]; if (p.GetComponent <ProbeControlRoomPart>() != null && aPart != p && p.protoModuleCrew.Count == 0 && p.internalModel != null) { ProbeControlRoomUtils.Logger.debug("refreshRooms() Found and destroying old PCR in " + p.ToString()); p.internalModel.gameObject.DestroyGameObject(); p.internalModel = null; } } } return; } else { aPart = null; ProbeControlRoomUtils.Logger.debug("refreshVesselRooms() - Old part no longer in vessel."); } //Do not create PCR when stock IVA available. if (canStockIVA) { ProbeControlRoomUtils.Logger.debug("refreshVesselRooms() - stock IVA available in vessel."); canPCRIVA = false; return; } //No current active PCR found, time to create a new one canPCRIVA = false; List <Part> rooms = new List <Part>(); List <Part> pcrNoModel = new List <Part>(); ProbeControlRoomUtils.Logger.message("refreshVesselRooms() - scanning vessel: " + vessel.ToString()); //Look throught the list of parts and save those that have probe control room modules on them based on available internal models for (int i = 0; i < vessel.parts.Count; i++) { Part p = vessel.parts[i]; ProbeControlRoomPart room = p.GetComponent <ProbeControlRoomPart>(); if (room != null) { if (p.internalModel != null) { //Check for stock IVA if (p.protoModuleCrew.Count > 0) { ProbeControlRoomUtils.Logger.message("refreshVesselRooms() - Found Stock IVA with crew: " + p.ToString()); canStockIVA = true; } else { //No stock IVA possible, PCR model found ProbeControlRoomUtils.Logger.message("refreshVesselRooms() - Found part with PCR IVA model: " + p.ToString()); rooms.Add(p); } } else { //PCR Module noted but no active internal model found ProbeControlRoomUtils.Logger.message("refreshVesselrooms() - Found PCR part but it has no model: " + p.ToString()); pcrNoModel.Add(p); } } } //Clean up and specifiy active rooms if (rooms.Count > 0) { ProbeControlRoomUtils.Logger.message("refreshVesselRooms() - Cleaning up pcrNoModel List"); pcrNoModel.Clear(); pcrNoModel = null; //Select primary part for use and verify it's initialized ProbeControlRoomUtils.Logger.message("refreshVesselRooms() - Initializing room in " + rooms[0].ToString()); aPart = rooms[0]; cachedrenderers = null; aPart.internalModel.Initialize(aPart); aPart.internalModel.SetVisible(false); ProbeControlRoomUtils.Logger.message("refreshVesselRooms() - C"); //Remove Excess internal models if (rooms.Count > 1) { ProbeControlRoomUtils.Logger.debug("refreshVesselRooms() - Removing " + (rooms.Count - 1) + " Rooms"); for (int i = 1; i < rooms.Count; i++) { rooms[i].internalModel.gameObject.DestroyGameObject(); rooms[i].internalModel = null; } } canPCRIVA = true; rooms.Clear(); rooms = null; } else if (pcrNoModel.Count > 0) { // No parts with an available internal model were found, attempting to create one aPart = pcrNoModel[0]; cachedrenderers = null; aPart.CreateInternalModel(); ProbeControlRoomUtils.Logger.debug("refreshVesselRooms() - No active room with a model found, creating now in " + aPart.ToString()); if (aPart.internalModel == null) { //Something went wrong creating the model ProbeControlRoomUtils.Logger.message("refreshVesselRooms() - ERROR creating internal model"); return; } aPart.internalModel.Initialize(aPart); aPart.internalModel.SetVisible(false); canPCRIVA = true; } if (pcrNoModel != null) { pcrNoModel.Clear(); } pcrNoModel = null; // Set app launcher availability based on current layout. if (AppLauncher) { if (canPCRIVA) { toolbarControl.Enabled = true; } else { toolbarControl.Enabled = false; } } return; }
/// <summary> /// Sets up IVA and activates it /// </summary> /// <returns>True if successful, False on error</returns> public bool startIVA() { if (FlightGlobals.ActiveVessel == null) { ProbeControlRoomUtils.Logger.debug("startIVA() - return ACTIVE VESSEL NULL"); return(false); } ProbeControlRoomUtils.Logger.debug("startIVA()"); Transform actualTransform; if (FlightGlobals.ActiveVessel.packed) { ProbeControlRoomUtils.Logger.debug("startIVA() - return vessel still packed!"); return(false); } if (canStockIVA || FlightGlobals.ActiveVessel.evaController != null) { ProbeControlRoomUtils.Logger.debug("startIVA() - return EVA or IVA"); return(false); } //Verify active room available if (!canPCRIVA) { ProbeControlRoomUtils.Logger.message("startIVA() - Refresh rooms said there were no IVAs available! Can't start."); return(false); } //Ensure part still exists if (aPart == null) { ProbeControlRoomUtils.Logger.message("startIVA() Lost our part, refreshing"); refreshVesselRooms(); } if (aPart == null) { ProbeControlRoomUtils.Logger.message("startIVA() Can't find a part. DIE."); return(false); } //Setup module for transforms if (aPart.FindModulesImplementing <ProbeControlRoomPart>().Count == 0) { ProbeControlRoomUtils.Logger.error("startIVA() a module was not found on the part now, exiting"); return(false); } aModule = aPart.FindModulesImplementing <ProbeControlRoomPart>()[0]; //Make the PCR part the focused part aPart.MakeReferencePart(); //Setup camera transform for internal seat actualTransform = aPart.internalModel.FindModelTransform(aModule.seatTransformName); if (Transform.Equals(actualTransform, null)) { ProbeControlRoomUtils.Logger.error("startIVA(Part) - NULL on actualTransform-seatTransformName, using fallback..."); actualTransform = aPart.internalModel.FindModelTransform("Seat"); } else { ProbeControlRoomUtils.Logger.message("startIVA(Part) - Seat: " + aModule.seatTransformName.ToString()); } ProbeControlRoomUtils.Logger.debug("startIVA() - fire up IVA"); //disable sound shipVolumeBackup = GameSettings.SHIP_VOLUME; ambianceVolumeBackup = GameSettings.AMBIENCE_VOLUME; if (ProbeControlRoomSettings.Instance.DisableSounds) { ProbeControlRoomUtils.Logger.message("startIVA() - DisableSounds"); GameSettings.SHIP_VOLUME = 0f; GameSettings.AMBIENCE_VOLUME = 0; GameSettings.MUSIC_VOLUME = 0; GameSettings.UI_VOLUME = 0; GameSettings.VOICE_VOLUME = 0; } //disable camera wobble cameraWobbleBackup = GameSettings.FLT_CAMERA_WOBBLE; cameraFXInternalBackup = GameSettings.CAMERA_FX_INTERNAL; cameraFXExternalBackup = GameSettings.CAMERA_FX_EXTERNAL; if (ProbeControlRoomSettings.Instance.DisableWobble) { ProbeControlRoomUtils.Logger.message("startIVA() - DisableWobble"); GameSettings.FLT_CAMERA_WOBBLE = 0; GameSettings.CAMERA_FX_INTERNAL = 0; GameSettings.CAMERA_FX_EXTERNAL = 0; } // TODO: create cfg file with cached vars, on crash to be restored //Prevent user from turning on vessel labels if (!HasCachedVesselLabelsSetting) { HasCachedVesselLabelsSetting = true; CachedVesselLabelsSetting = GameSettings.FLT_VESSEL_LABELS; } if (!VesselLabelKeyDisabled) { VesselLabelKeyDisabled = true; CachedLabelPrimaryKey = GameSettings.TOGGLE_LABELS.primary; CachedLabelSecondaryKey = GameSettings.TOGGLE_LABELS.secondary; GameSettings.TOGGLE_LABELS.primary = new KeyCodeExtended(KeyCode.None); GameSettings.TOGGLE_LABELS.secondary = new KeyCodeExtended(KeyCode.None); } SetVesselLabelsValue(false); //Highlighters if (!HasCachedHighlightInFlightSetting) { HasCachedHighlightInFlightSetting = true; CachedHighlightInFlightSetting = GameSettings.INFLIGHT_HIGHLIGHT; } GameSettings.INFLIGHT_HIGHLIGHT = false; //Unsure of this purpose at the moment FlightCamera.fetch.EnableCamera(); FlightCamera.fetch.DeactivateUpdate(); FlightCamera.fetch.gameObject.SetActive(true); //Move internal camera to the correct position and enable InternalCamera.Instance.SetTransform(actualTransform, true); InternalCamera.Instance.EnableCamera(); if (UIPartActionController.Instance != null) { UIPartActionController.Instance.Deactivate(); } //Activate internal camera CameraManager.Instance.SetCameraInternal(aPart.internalModel, actualTransform); ProbeControlRoomUtils.Logger.debug("startIVA() - DONE"); //GUI may not be started yet. if (toolbarControl != null) { //Change app launcher button icon toolbarControl.SetTexture(IconActivate, enabledTexture); } if (hassavedlookangles && field_set_internalcamera_currentPitch != null && field_set_internalcamera_currentRot != null && field_set_internalcamera_currentZoom != null) { ProbeControlRoomUtils.Logger.debug(string.Format("startIVA() - Restoring pitch and rot. {0}, {1}", savedpitch, savedrot)); field_set_internalcamera_currentPitch(InternalCamera.Instance, savedpitch); field_set_internalcamera_currentRot(InternalCamera.Instance, savedrot); field_set_internalcamera_currentZoom(InternalCamera.Instance, savedzoom); InternalCamera.Instance.Update(); } //Disable sun effects inside of IVA SetSun(false); ProbeControlRoomUtils.Logger.debug("startIVA() - REALLY DONE"); isActive = true; return(true); }
public bool startIVA(Part p) { ProbeControlRoomUtils.Logger.debug("[ProbeControlRoom] startIVA(Part)"); Transform actualTransform; refreshVesselRooms(); if (vesselRooms.Contains(p)) { aModule = p.FindModulesImplementing <ProbeControlRoomPart> ().First(); aPart = p; // TODO when currentReference its a dockingport, store and restore that instead? p.MakeReferencePart(); actualTransform = p.internalModel.FindModelTransform(aModule.seatTransformName); if (Transform.Equals(actualTransform, null)) { ProbeControlRoomUtils.Logger.error("[ProbeControlRoom] startIVA(Part) - NULL on actualTransform-seatTransformName, using fallback..."); actualTransform = p.internalModel.FindModelTransform("Seat"); } else { ProbeControlRoomUtils.Logger.message("[ProbeControlRoom] startIVA(Part) - Seat: " + aModule.seatTransformName.ToString()); } ProbeControlRoomUtils.Logger.debug("[ProbeControlRoom] startIVA(Part) - fire up IVA"); //disable sound shipVolumeBackup = GameSettings.SHIP_VOLUME; ambianceVolumeBackup = GameSettings.AMBIENCE_VOLUME; //musicVolumeBackup = GameSettings.MUSIC_VOLUME; //uiVolumeBackup = GameSettings.UI_VOLUME; //voiceVolumeBackup = GameSettings.VOICE_VOLUME; if (ProbeControlRoomSettings.Instance.DisableSounds) { ProbeControlRoomUtils.Logger.message("[ProbeControlRoom] startIVA(Part) - DisableSounds"); GameSettings.SHIP_VOLUME = 0f; GameSettings.AMBIENCE_VOLUME = 0; GameSettings.MUSIC_VOLUME = 0; GameSettings.UI_VOLUME = 0; GameSettings.VOICE_VOLUME = 0; } //disable camera wobble cameraWobbleBackup = GameSettings.FLT_CAMERA_WOBBLE; cameraFXInternalBackup = GameSettings.CAMERA_FX_INTERNAL; cameraFXExternalBackup = GameSettings.CAMERA_FX_EXTERNAL; if (ProbeControlRoomSettings.Instance.DisableWobble) { ProbeControlRoomUtils.Logger.message("[ProbeControlRoom] startIVA(Part) - DisableWobble"); GameSettings.FLT_CAMERA_WOBBLE = 0; GameSettings.CAMERA_FX_INTERNAL = 0; GameSettings.CAMERA_FX_EXTERNAL = 0; } // TODO: create cfg file with cached vars, on crash to be restored FlightCamera.fetch.EnableCamera(); FlightCamera.fetch.DeactivateUpdate(); FlightCamera.fetch.gameObject.SetActive(true); /* InternalSeat CapComSeat = new InternalSeat(); * CapComSeat.seatTransform = actualTransform; * foreach(InternalSeat i in p.internalModel.seats) * { * Debug.Log("PCR InternalSeat: " + i.seatTransformName); * } * p.internalModel.seats.Add(CapComSeat); * CapComSeat.allowCrewHelmet = false; * ProtoCrewMember CapCom = new ProtoCrewMember(ProtoCrewMember.KerbalType.Crew); * p.internalModel.SitKerbalAt(CapCom, CapComSeat); * p.internalModel.SpawnCrew(); * * CapCom.ChangeName("CapCom"); * CapCom.isBadass = true; * CapCom.veteran = true; */ InternalCamera.Instance.SetTransform(actualTransform, true); InternalCamera.Instance.EnableCamera(); IVASun sunBehaviour; sunBehaviour = (IVASun)FindObjectOfType(typeof(IVASun)); sunBehaviour.enabled = false; isActive = true; if (UIPartActionController.Instance != null) { UIPartActionController.Instance.Deactivate(); } p.internalModel.SpawnCrew(); // CameraManager.Instance.currentCameraMode = CameraManager.CameraMode.Internal; CameraManager.Instance.SetCameraInternal(p.internalModel, actualTransform); CameraManager.Instance.SetCameraMode(CameraManager.CameraMode.Internal); ProbeControlRoomUtils.Logger.debug("[ProbeControlRoom] startIVA(Part) - DONE"); appLauncherButton.SetTexture(IconDeactivate); return(true); } else { ProbeControlRoomUtils.Logger.error("[ProbeControlRoom] startIVA(Part) - Cannot instantiate ProbeControlRoom in this location - Part/ModuleNotFound"); throw new ArgumentException("[ProbeControlRoom] startIVA(Part) - Cannot instantiate ProbeControlRoom in this location - Part/ModuleNotFound"); //return false; } }
/// <summary> /// Sets up IVA and activtes it /// </summary> /// <returns>True if successful, False on error</returns> public bool startIVA() { ProbeControlRoomUtils.Logger.debug("startIVA()"); Transform actualTransform; //Verify active room available if (!canPCRIVA) { ProbeControlRoomUtils.Logger.message("startIVA() - Refresh rooms said there were no IVAs available! Can't start."); return(false); } //Ensure part still exists if (aPart == null) { ProbeControlRoomUtils.Logger.message("startIVA() Lost our part, refreshing"); refreshVesselRooms(); } //Setup module for transforms if (aPart.FindModulesImplementing <ProbeControlRoomPart>().Count == 0) { ProbeControlRoomUtils.Logger.error("startIVA() a module was not found on the part now, exiting"); return(false); } aModule = aPart.FindModulesImplementing <ProbeControlRoomPart>()[0]; //Make the PCR part the focused part aPart.MakeReferencePart(); //Setup camera transform for internal seat actualTransform = aPart.internalModel.FindModelTransform(aModule.seatTransformName); if (Transform.Equals(actualTransform, null)) { ProbeControlRoomUtils.Logger.error("startIVA(Part) - NULL on actualTransform-seatTransformName, using fallback..."); actualTransform = aPart.internalModel.FindModelTransform("Seat"); } else { ProbeControlRoomUtils.Logger.message("startIVA(Part) - Seat: " + aModule.seatTransformName.ToString()); } ProbeControlRoomUtils.Logger.debug("startIVA() - fire up IVA"); //disable sound shipVolumeBackup = GameSettings.SHIP_VOLUME; ambianceVolumeBackup = GameSettings.AMBIENCE_VOLUME; if (ProbeControlRoomSettings.Instance.DisableSounds) { ProbeControlRoomUtils.Logger.message("startIVA() - DisableSounds"); GameSettings.SHIP_VOLUME = 0f; GameSettings.AMBIENCE_VOLUME = 0; GameSettings.MUSIC_VOLUME = 0; GameSettings.UI_VOLUME = 0; GameSettings.VOICE_VOLUME = 0; } //disable camera wobble cameraWobbleBackup = GameSettings.FLT_CAMERA_WOBBLE; cameraFXInternalBackup = GameSettings.CAMERA_FX_INTERNAL; cameraFXExternalBackup = GameSettings.CAMERA_FX_EXTERNAL; if (ProbeControlRoomSettings.Instance.DisableWobble) { ProbeControlRoomUtils.Logger.message("startIVA() - DisableWobble"); GameSettings.FLT_CAMERA_WOBBLE = 0; GameSettings.CAMERA_FX_INTERNAL = 0; GameSettings.CAMERA_FX_EXTERNAL = 0; } // TODO: create cfg file with cached vars, on crash to be restored //Unsure of this purpose at the moment FlightCamera.fetch.EnableCamera(); FlightCamera.fetch.DeactivateUpdate(); FlightCamera.fetch.gameObject.SetActive(true); //Move internal camera to the correct position and enable InternalCamera.Instance.SetTransform(actualTransform, true); InternalCamera.Instance.EnableCamera(); //Disable sun effects inside of IVA IVASun sunBehaviour; sunBehaviour = (IVASun)FindObjectOfType(typeof(IVASun)); sunBehaviour.enabled = false; if (UIPartActionController.Instance != null) { UIPartActionController.Instance.Deactivate(); } //Activate internal camera CameraManager.Instance.SetCameraInternal(aPart.internalModel, actualTransform); ProbeControlRoomUtils.Logger.debug("startIVA() - DONE"); //Change app launcher button icon appLauncherButton.SetTexture(IconDeactivate); isActive = true; return(true); }