internal void CrewTransferAbort() { if (SMSettings.RealXfers) { SMSound.SourceCrewRun.Stop(); SMSound.SourceCrewStop.Play(); if (FromCrewMember != null) { AddCrewMember(FromCrewMember, FromPart, FromSeat); } if (ToCrewMember != null) { AddCrewMember(ToCrewMember, ToPart, ToSeat); } } SMAddon.Elapsed = 0; SMAddon.SmVessel.TransferCrewObj.IvaDelayActive = false; SMAddon.SmVessel.TransferCrewObj.IvaPortraitDelay = 0; SMAddon.SmVessel.TransferCrewObj.FromCrewMember = SMAddon.SmVessel.TransferCrewObj.ToCrewMember = null; CrewXferState = XferState.Off; _crewXferActive = IsSeat2SeatXfer = false; CrewHatchController.fetch.EnableInterface(); CameraManager.ICameras_ResetAll(); IsStockXfer = false; }
private void ResetXferProcess() { IvaDelayActive = false; IvaPortraitDelay = 0; FromCrewMember = ToCrewMember = null; FromSeat = ToSeat = null; SMAddon.SmVessel.RespawnCrew(); CrewHatchController.fetch.EnableInterface(); CameraManager.ICameras_ResetAll(); CrewXferState = XferState.Off; _crewXferActive = IsSeat2SeatXfer = IsStockXfer = false; }
void ToggleXferState(int ind, XferState state, string label) { bool on = false; if (xferState != null) { on = xferState[ind] == state; } if (GUILayout.Toggle(on, label, toggleWidth)) { if (xferState != null) { xferState[ind] = state; } } }
void TransferState(int ind, RMResourceSet set, string res) { XferState old = XferState.Hold; if (xferState != null) { old = xferState[ind]; } ToggleXferState(ind, XferState.Hold, "Hold"); ToggleXferState(ind, XferState.In, "In"); ToggleXferState(ind, XferState.Out, "Out"); GUILayout.Space(40); if (xferState != null && xferState[ind] != old) { if (old == XferState.In) { RemoveSet(dstSets, set, res); } else if (old == XferState.Out) { RemoveSet(srcSets, set, res); } if (xferState[ind] == XferState.In) { AddSet(dstSets, set, res); } else if (xferState[ind] == XferState.Out) { AddSet(srcSets, set, res); } canTransfer = false; foreach (string r in dstSets.Keys) { if (srcSets.ContainsKey(r)) { canTransfer = true; break; } } } }
private void ResetXferProcess() { IvaDelayActive = false; IvaPortraitDelay = 0; FromPart = ToPart = null; FromSeat = ToSeat = null; FromCrewMember = ToCrewMember = null; //FromParts = ToParts = null; //FromCrewMembers = ToCrewMembers = null; CrewMembersToTransfer = null; ToParts = null; SMAddon.SmVessel.SourceMembersSelected.Clear(); SMAddon.SmVessel.TargetMembersSelected.Clear(); SMAddon.SmVessel.RespawnCrew(); CrewHatchController.fetch.EnableInterface(); CameraManager.ICameras_ResetAll(); CrewXferState = XferState.Off; _crewXferActive = IsSeat2SeatXfer = IsStockXfer = false; }
public void MoveSet(XferState from, XferState to, RMResourceSet set, string resourceName) { if (from == XferState.In) { xferControl.RemoveDestination(set, resourceName); } else if (from == XferState.Out) { xferControl.RemoveSource(set, resourceName); } if (to == XferState.In) { xferControl.AddDestination(set, resourceName); } else if (to == XferState.Out) { xferControl.AddSource(set, resourceName); } xferControl.CheckTransfer(); }
internal void CrewTransferProcesses() { try { if (!CrewXferActive) { return; } if (CameraManager.Instance.currentCameraMode == CameraManager.CameraMode.IVA) { ScreenMessages.PostScreenMessage("<color=orange>Cannot go IVA. An SM Crew Xfer is in progress</color>", 4f); CameraManager.Instance.SetCameraMode(CameraManager.CameraMode.Flight); } switch (CrewXferState) { case XferState.Off: // We're just starting loop, so set some evnironment stuff. // We want to run the start sound no matter what the realism settings are // to give an audio indication to the player that the process is active Timestamp = DateTime.Now; SMSound.SourceCrewStart.Play(); CrewXferState = XferState.Start; break; case XferState.Start: SMAddon.Elapsed += (DateTime.Now - Timestamp).TotalSeconds; if (SMSettings.RealXfers) { // Play run sound when start sound is nearly done. (repeats) if (SMAddon.Elapsed >= SMSound.ClipPumpStart.length - 0.25) { SMSound.SourceCrewStart.Stop(); SMSound.SourceCrewRun.Play(); SMAddon.Elapsed = 0; CrewXferState = XferState.Transfer; } } else { CrewXferState = XferState.Transfer; } break; case XferState.Transfer: SMAddon.Elapsed += (DateTime.Now - Timestamp).TotalSeconds; if (SMSettings.RealXfers) { // wait for movement to end... if (SMAddon.Elapsed >= CrewXferDelaySec || (IsSeat2SeatXfer && SMAddon.Elapsed > Seat2SeatXferDelaySec)) { CrewXferState = XferState.Stop; CrewTransferStartAction(); } } else { if (SMAddon.Elapsed > 1) { CrewXferState = XferState.Stop; } } break; case XferState.Stop: // Spawn crew in parts and in vessel. if (SMSettings.RealXfers) { // play crew sit. SMSound.SourceCrewRun.Stop(); SMSound.SourceCrewStop.Play(); } CrewTransferStartAction(); CrewTransferStopAction(); Vessel.CrewWasModified(SMAddon.SmVessel.Vessel); SMAddon.SmVessel.Vessel.DespawnCrew(); SMAddon.Elapsed = 0; CrewXferState = XferState.Portraits; IvaDelayActive = true; break; case XferState.Portraits: // Account for crew move callbacks by adding a frame delay for portrait updates after crew move... SMAddon.SmVessel.Vessel.SpawnCrew(); if (IvaDelayActive && IvaPortraitDelay < SMSettings.IvaUpdateFrameDelay) { IvaPortraitDelay += 1; } else if ((IvaDelayActive && IvaPortraitDelay >= SMSettings.IvaUpdateFrameDelay) || !IvaDelayActive) { if (IsStockXfer) { ScreenMessages.PostScreenMessage( $"<color=yellow>{FromCrewMember.name} moved (by SM) to {ToPart.partInfo.title}.</color>", 5f); } ResetXferProcess(); } break; } if (CrewXferState != XferState.Off) { Timestamp = DateTime.Now; } } catch (Exception ex) { if (!SMAddon.FrameErrTripped) { SmUtils.LogMessage($"Transfer State: {CrewXferState}...", SmUtils.LogType.Error, true); SmUtils.LogMessage( $" in CrewTransferProcess (repeating error). Error: {ex.Message} \r\n\r\n{ex.StackTrace}", SmUtils.LogType.Error, true); SMAddon.FrameErrTripped = true; ResetXferProcess(); } } }
private void ResetXferProcess() { IvaDelayActive = false; IvaPortraitDelay = 0; FromCrewMember = ToCrewMember = null; SMAddon.SmVessel.RespawnCrew(); CrewHatchController.fetch.EnableInterface(); CameraManager.ICameras_ResetAll(); CrewXferState = XferState.Off; _crewXferActive = IsSeat2SeatXfer = IsStockXfer = false; }
internal void CrewTransferProcess() { try { if (!CrewXferActive) return; if (CameraManager.Instance.currentCameraMode == CameraManager.CameraMode.IVA) { ScreenMessages.PostScreenMessage("<color=orange>Cannot go IVA. An SM Crew Xfer is in progress</color>", 4f); CameraManager.Instance.SetCameraMode(CameraManager.CameraMode.Flight); } switch (CrewXferState) { case XferState.Off: // We're just starting loop, so set some evnironment stuff. Timestamp = DateTime.Now; SMSound.SourceCrewStart.Play(); CrewXferState = XferState.Start; break; case XferState.Start: SMAddon.Elapsed += (DateTime.Now - Timestamp).TotalSeconds; if (SMSettings.RealismMode) { // Play run sound when start sound is nearly done. (repeats) if (SMAddon.Elapsed >= SMSound.ClipPumpStart.length - 0.25) { SMSound.SourceCrewStart.Stop(); SMSound.SourceCrewRun.Play(); SMAddon.Elapsed = 0; CrewXferState = XferState.Transfer; } } else { CrewXferState = XferState.Transfer; } break; case XferState.Transfer: SMAddon.Elapsed += (DateTime.Now - Timestamp).TotalSeconds; if (SMSettings.RealismMode) { // wait for movement to end... if (SMAddon.Elapsed >= CrewXferDelaySec || (IsSeat2SeatXfer && SMAddon.Elapsed > Seat2SeatXferDelaySec)) CrewXferState = XferState.Stop; } else { if (SMAddon.Elapsed > 1) CrewXferState = XferState.Stop; } break; case XferState.Stop: // Spawn crew in parts and in vessel. if (SMSettings.RealismMode) { // play crew sit. SMSound.SourceCrewRun.Stop(); SMSound.SourceCrewStop.Play(); } SMAddon.Elapsed = 0; CrewTransferAction(); CrewXferState = XferState.Portraits; IvaDelayActive = true; break; case XferState.Portraits: // Account for crew move callbacks by adding a frame delay for portrait updates after crew move... if (IvaDelayActive && IvaPortraitDelay < SMSettings.IvaUpdateFrameDelay) { IvaPortraitDelay += 1; } else if ((IvaDelayActive && IvaPortraitDelay >= SMSettings.IvaUpdateFrameDelay) || !IvaDelayActive) { if (IsStockXfer) ScreenMessages.PostScreenMessage( string.Format("<color=yellow>{0} moved (by SM) to {1}.</color>", FromCrewMember.name, ToPart.partInfo.title), 5f); ResetXferProcess(); } break; } if (CrewXferState != XferState.Off) Timestamp = DateTime.Now; } catch (Exception ex) { if (!SMAddon.FrameErrTripped) { Utilities.LogMessage("Transfer State: " + CrewXferState + "...", Utilities.LogType.Error, true); Utilities.LogMessage( string.Format(" in CrewTransferProcess (repeating error). Error: {0} \r\n\r\n{1}", ex.Message, ex.StackTrace), Utilities.LogType.Error, true); SMAddon.FrameErrTripped = true; ResetXferProcess(); } } }
internal void CrewTransferAbort() { if (SMSettings.RealismMode) { SMSound.SourceCrewRun.Stop(); SMSound.SourceCrewStop.Play(); } SMAddon.Elapsed = 0; SMAddon.SmVessel.TransferCrewObj.IvaDelayActive = false; SMAddon.SmVessel.TransferCrewObj.IvaPortraitDelay = 0; SMAddon.SmVessel.TransferCrewObj.FromCrewMember = SMAddon.SmVessel.TransferCrewObj.ToCrewMember = null; CrewXferState = XferState.Off; _crewXferActive = IsSeat2SeatXfer = false; //FlightEVA.fetch.EnableInterface(); CrewHatchController.fetch.EnableInterface(); CameraManager.ICameras_ResetAll(); IsStockXfer = false; }