// Method to optionally abort an attempt to use the stock crew transfer mechanism private void OnCrewTransferSelected(CrewTransfer.CrewTransferData crewTransferData) { // If transfers are not restricted then we have got nothing to do here. if (_allowUnrestrictedTransfers) { return; } ICLSPart clsFrom = Instance.Vessel.Parts.Find(x => x.Part == crewTransferData.sourcePart); ICLSPart clsTo = Instance.Vessel.Parts.Find(x => x.Part == crewTransferData.destPart); // If in same space, ignore if (clsFrom != null && clsTo != null && clsFrom.Space == clsTo.Space) { return; } // Okay, houston, we have a problem. Prevent transfer. crewTransferData.canTransfer = false; ScreenMessages.PostScreenMessage( $"<color=orange>{_clsLocWarnXfer}: {crewTransferData.crewMember.name}. {crewTransferData.sourcePart.partInfo.title} {_clsLocAnd} {crewTransferData.destPart.partInfo.title} {_clsLocNotSameLs}.</color>", 10f); }
private void OnCrewTransferSelected(CrewTransfer.CrewTransferData data) { Util.Log($"OnAttemptTransfer: {data.destPart.partInfo.title}"); if (AllowUnsafeActivity || !data.canTransfer) { return; } // Calculate whether total part+suit LS is less than 30 seconds double destLS = data.destPart.Resources[C.NAME_LIFESUPPORT].amount; double partFactor = destLS / C.LS_30_SECONDS / (data.destPart.protoModuleCrew.Count + 1); double evaFactor = evals_info[data.crewMember.name].ls_current / C.EVA_LS_30_SECONDS; Util.Log($"eva factor = {evaFactor}"); Util.Log($"part factor = {partFactor}"); Util.Log($"crew count = {data.destPart.protoModuleCrew.Count}"); if (partFactor + evaFactor < 1.0 && destLS < data.sourcePart.Resources[C.NAME_LIFESUPPORT].amount) { data.canTransfer = false; Util.PostUpperMessage($"Moving to part is unsafe!"); } }