private void setseatstaticoverlay(InternalSeat seat) { try { if (seat.kerbalRef != null) { seat.kerbalRef.staticOverlayDuration = 0f; seat.kerbalRef.state = Kerbal.States.ALIVE; } } catch (Exception ex) { Utilities.Log("DeepFreezer Error attempting to change staticoverlayduration"); Utilities.Log(ex.Message); } }
public void Update() { if (CameraManager.Instance.currentCameraMode != CameraManager.CameraMode.IVA) { if (_lastCameraMode == CameraManager.CameraMode.IVA) { // Switching away from IVA. //InputLockManager.RemoveControlLock("FreeIVA"); // Return the kerbal to its original seat. TargetedSeat = ActiveKerbal.seat; Buckle(); } } else { // In IVA. if (_lastCameraMode != CameraManager.CameraMode.IVA) { // Switching to IVA. FreeIva.EnableInternals(); SetCameraToSeat(); InternalCollider.HideAllColliders(); } GetInput(); } _lastCameraMode = CameraManager.Instance.currentCameraMode; }
public void TargetSeats() { float closestDistance = MaxInteractDistance; TargetedSeat = null; TargetedSeatIndex = -1; if (FreeIva.CurrentPart.internalModel == null) return; for (int i = 0; i < FreeIva.CurrentPart.internalModel.seats.Count; i++) { if (FreeIva.CurrentPart.internalModel.seats[i].taken && !FreeIva.CurrentPart.internalModel.seats[i].crew.Equals(ActiveKerbal)) continue; if (IsTargeted(FreeIva.CurrentPart.internalModel.seats[i].seatTransform.position)) { float distance = Vector3.Distance(FreeIva.CurrentPart.internalModel.seats[i].seatTransform.position, InternalCamera.Instance.transform.position); if (distance < closestDistance) { TargetedSeat = FreeIva.CurrentPart.internalModel.seats[i]; TargetedSeatIndex = i; closestDistance = distance; } } } if (TargetedSeat != null) ScreenMessages.PostScreenMessage("Enter seat [" + Settings.UnbuckleKey + "] (Not working yet)", 0.1f, ScreenMessageStyle.LOWER_CENTER); }
public void Unbuckle() { _previousPos = Vector3.zero; FreeIva.EnableInternals(); UpdateActiveKerbal(); FreeIva.InitialPart = FreeIva.CurrentPart; OriginalSeat = ActiveKerbal.seat; HideCurrentKerbal(true); // InternalSpace.Instance is the InternalCamera's parent normally. InternalCamera.Instance.transform.parent = KerbalCollider.transform; InputLockManager.SetControlLock(ControlTypes.ALL_SHIP_CONTROLS, "FreeIVA"); //ActiveKerbal.flightLog.AddEntry("Unbuckled"); ScreenMessages.PostScreenMessage("Unbuckled", 1f, ScreenMessageStyle.LOWER_CENTER); KerbalCollider.collider.enabled = true; buckled = false; }
// this is called when a crew transfer has completed. For catching stock Xfers. Because Ship Manifest Xfers will avoid these scenarios. private void OnCrewTransferred(GameEvents.HostedFromToAction<ProtoCrewMember, Part> fromToAction) { Utilities.Log_Debug("DeepFreezer", "OnCrewTransferred Fired From: " + fromToAction.from.name + " To: " + fromToAction.to.name + " Host: " + fromToAction.host.name); //Ship Manifest Transfers checked crewXferSMActive = false; crewXferSMStock = false; if (DFInstalledMods.SMInstalled) { Utilities.Log_Debug("DeepFreezer", "Check SMxfer running what kind and store it"); ShipManifest.ICrewTransfer SMObject = null; SMObject = GetSMXfer(); //If IsStockXfer = true than a StockXfer is running under SM control //When it finishes, SM will revert the Xfer and then run a normal SM CrewXfer. //So While the Stock Xfer is running we ignore this OnCrewTransferred event. //If SM does not have OverrideStockCrewXfer = true than it will ignore the event, so we bypass this // IF and the next IF and do a stock Xfer processing further down. this.Log_Debug("SMStockXfer?=" + SMObject.IsStockXfer); this.Log_Debug("SMXfer?=" + SMObject.CrewXferActive); this.Log_Debug("SMseat2seat?=" + SMObject.IsSeat2SeatXfer); this.Log_Debug("OverrideStock?=" + SMObject.OverrideStockCrewXfer); crewXferSMTimeDelay = SMObject.CrewXferDelaySec; if (SMObject.IsStockXfer || (!SMObject.CrewXferActive && SMObject.OverrideStockCrewXfer)) { //we need to just check one thing, that if this a xfer to the part that isn't FULL of frozen kerbals. //If it is we must take over and revert. this.Log_Debug("Partfull=" + PartFull); this.Log_Debug("to part is this part=" + fromToAction.to + " - " + this.part); if (FreezerSpace == 0 && fromToAction.to == this.part) // If there is no available seats for this Kerbal we kick them back out. { _crewXferTOActive = true; // Set a flag to know a Xfer has started and we check when it is finished in savecryopodstatepersistent(); saveexternaldoorstatepersistent(); Utilities.Log_Debug("DeepFreezer", "CrewXfer PartFull transfer them back, part is full - attempt to cancel stock xfer"); ScreenMessages.PostScreenMessage("Cannot enter this freezer, part is full", 5.0f, ScreenMessageStyle.UPPER_CENTER); // Remove the transfer message that stock displayed. var message = new ScreenMessage(string.Empty, 15f, ScreenMessageStyle.LOWER_CENTER); var messages = FindObjectOfType<ScreenMessages>(); if (messages != null) { var messagesToRemove = messages.activeMessages.Where(x => x.startTime == message.startTime && x.style == ScreenMessageStyle.LOWER_CENTER).ToList(); foreach (var m in messagesToRemove) ScreenMessages.RemoveMessage(m); } xferisfromEVA = false; xferfromPart = fromToAction.from; xferfromSeat = fromToAction.host.seat; xfertoPart = fromToAction.to; xfercrew = fromToAction.host; setseatstaticoverlay(xfercrew.seat); xferbackwhenFull = true; return; } Utilities.Log_Debug("Stock Xfer is running with Ship Manifest Override, so we ignore the Stock Xfer"); return; } //This is a normal Ship Manifest Crew Xfer or an over-riden Stock Crew Xfer from SM if (SMObject.CrewXferActive) { Utilities.Log_Debug("SMXfer is running"); FlightEVA.fetch.DisableInterface(); savecryopodstatepersistent(); saveexternaldoorstatepersistent(); crewXferSMActive = SMObject.CrewXferActive; //crewXferSMStock = SMObject.IsStockXfer; if (SMObject.FromPart == this.part) { removeFreezeEvent(fromToAction.host.name); _crewXferFROMActive = true; // Set a flag to know a Xfer has started and we check when it is finished in xferfromPart = SMObject.FromPart; xfertoPart = SMObject.ToPart; xfercrew = fromToAction.host; if (xfercrew.KerbalRef != null) { Utilities.reinvigerateIVAKerbalAnimations(xfercrew.KerbalRef); } timecrewXferFROMfired = Time.time; } if (SMObject.ToPart == this.part) { _crewXferTOActive = true; // Set a flag to know a Xfer has started and we check when it is finished in xferfromPart = SMObject.FromPart; xfertoPart = SMObject.ToPart; xfercrew = fromToAction.host; xfertoSeat = SMObject.ToSeat; setseatstaticoverlay(SMObject.ToSeat); timecrewXferTOfired = Time.time; } return; } else { Utilities.Log_Debug("No SMXfer running"); } } //Stock Transfers only past here, or no Stock Xfer override is active within SM. So it must be stock savecryopodstatepersistent(); saveexternaldoorstatepersistent(); if (fromToAction.from == this.part) // if the Xfer is FROM this part { Utilities.Log_Debug("DeepFreezer", "crewXferFROMActive"); FlightEVA.fetch.DisableInterface(); removeFreezeEvent(fromToAction.host.name); // Remove the Freeze Event for the crewMember leaving the part if (fromToAction.to.Modules.Cast<PartModule>().Any(x => x is KerbalEVA)) // Kerbal is going EVA { return; } _crewXferFROMActive = true; // Set a flag to know a Xfer has started and we check when it is finished in xferfromPart = fromToAction.from; xfertoPart = fromToAction.to; xfercrew = fromToAction.host; if (xfercrew.KerbalRef != null) { Utilities.reinvigerateIVAKerbalAnimations(xfercrew.KerbalRef); } timecrewXferFROMfired = Time.time; return; } if (fromToAction.to == this.part) // if the Xfer is TO this part { Utilities.Log_Debug("DeepFreezer", "crewXferTOActive"); FlightEVA.fetch.DisableInterface(); _crewXferTOActive = true; // Set a flag to know a Xfer has started and we check when it is finished in if (fromToAction.from.Modules.Cast<PartModule>().Any(x => x is KerbalEVA)) // Kerbal is entering from EVA { Utilities.Log_Debug("DeepFreezer", "CrewXfer xferisfromEVA = true"); xferisfromEVA = true; xferfromPart = null; xferfromSeat = null; xfertoPart = fromToAction.to; xfercrew = fromToAction.host; Utilities.Log_Debug("CrewXFER host seatidx=" + xfercrew.seatIdx); foreach (FrznCrewMbr lst in _StoredCrewList) { Utilities.Log_Debug("CrewXFER Frozen Crew SeatIdx= " + lst.SeatIdx + ",Seattaken=" + this.part.internalModel.seats[lst.SeatIdx].taken); } } else { Utilities.Log_Debug("DeepFreezer", "CrewXfer xferisfromEVA = false"); xferisfromEVA = false; xferfromPart = fromToAction.from; xferfromSeat = fromToAction.host.seat; xfertoPart = fromToAction.to; xfercrew = fromToAction.host; setseatstaticoverlay(xfercrew.seat); } if (PartFull) // If there is no free seats for this Kerbal we kick them back out. { Utilities.Log_Debug("DeepFreezer", "CrewXfer PartFull transfer them back, part is full - attempt to cancel stock xfer"); ScreenMessages.PostScreenMessage("Cannot enter this freezer, part is full", 5.0f, ScreenMessageStyle.UPPER_CENTER); // Remove the transfer message that stock displayed. var message = new ScreenMessage(string.Empty, 15f, ScreenMessageStyle.LOWER_CENTER); var messages = FindObjectOfType<ScreenMessages>(); if (messages != null) { var messagesToRemove = messages.activeMessages.Where(x => x.startTime == message.startTime && x.style == ScreenMessageStyle.LOWER_CENTER).ToList(); foreach (var m in messagesToRemove) ScreenMessages.RemoveMessage(m); } xferbackwhenFull = true; } timecrewXferTOfired = Time.time; Utilities.Log_Debug("DeepFreezer", "crewXferTOActive end"); } }