public void AddTechEvent(string nodeName) { if (CareerEventScope.ShouldIgnore || !IsEnabled) { return; } _techEvents.Add(new TechResearchEvent(KSPUtils.GetUT()) { NodeName = nodeName }); }
private void ContractAccepted(Contract c) { if (CareerEventScope.ShouldIgnore || c.AutoAccept) { return; // Do not record the Accept event for record contracts } _contractDict.Add(new ContractEvent(KSPUtils.GetUT()) { Type = ContractEventType.Accept, FundsChange = c.FundsAdvance, RepChange = 0, DisplayName = c.Title, InternalName = GetContractInternalName(c) }); }
public void AddFailureEvent(Vessel v, string part, string type) { if (!IsEnabled) { return; } _failures.Add(new FailureEvent(KSPUtils.GetUT()) { VesselUID = v.GetKCTVesselId(), LaunchID = v.GetVesselLaunchId(), Part = part, Type = type }); }
public void AddFacilityConstructionEvent(SpaceCenterFacility facility, int newLevel, double cost, ConstructionState state) { if (CareerEventScope.ShouldIgnore || !IsEnabled) { return; } _facilityConstructions.Add(new FacilityConstructionEvent(KSPUtils.GetUT()) { Facility = facility, NewLevel = newLevel, Cost = cost, State = state }); }
private void ContractCompleted(Contract c) { if (CareerEventScope.ShouldIgnore) { return; } _contractDict.Add(new ContractEvent(KSPUtils.GetUT()) { Type = ContractEventType.Complete, FundsChange = c.FundsCompletion, RepChange = c.ReputationCompletion, DisplayName = c.Title, InternalName = GetContractInternalName(c) }); }
private void VesselSituationChange(GameEvents.HostedFromToAction <Vessel, Vessel.Situations> ev) { if (CareerEventScope.ShouldIgnore) { return; } // KJR can clobber the vessel back to prelaunch state in case of clamp wobble. Need to exclude such events. if (!_launched && ev.from == Vessel.Situations.PRELAUNCH && ev.host == FlightGlobals.ActiveVessel) { Debug.Log($"[LRTR] Launching {FlightGlobals.ActiveVessel?.vesselName}"); _launched = true; _launchedVessels.Add(new LaunchEvent(KSPUtils.GetUT()) { VesselName = FlightGlobals.ActiveVessel?.vesselName, VesselUID = ev.host.GetKCTVesselId(), LaunchID = ev.host.GetVesselLaunchId(), BuiltAt = ev.host.GetVesselBuiltAt() ?? EditorFacility.None // KSP can't serialize nullables }); } }
protected void FixedUpdate() { int pC; if (HighLogic.LoadedSceneIsFlight && part.CrewCapacity > 0 && (pC = part.protoModuleCrew.Count) > 0) { double UT = KSPUtils.GetUT(); if (nextCheck < 0d) { nextCheck = UT + checkInterval; } else if (UT > nextCheck) { if (!_origDoStockGCalcs.HasValue) { _origDoStockGCalcs = ProtoCrewMember.doStockGCalcs; } double deltaTime = UT - nextCheck; nextCheck = UT + checkInterval; double curAltitute = part.vessel.altitude; if (curAltitute > crewDeathAltitude) { // Assume the standard atmosphere if (referenceDensity < 0d) { referenceDensity = Planetarium.fetch.Home.GetDensity(Planetarium.fetch.Home.GetPressure(crewDeathAltitude), Planetarium.fetch.Home.GetTemperature(crewDeathAltitude)); referenceDensityMin = referenceDensity * 0.02d; } timeSinceHypoxiaStarted += deltaTime; ScreenMessages.PostScreenMessage($"Cockpit is above the safe altitude which will lead to crew incapacitation and eventually to death", 1f, ScreenMessageStyle.UPPER_CENTER, XKCDColors.Red); if (!_origDoStockGCalcs.HasValue) { _origDoStockGCalcs = ProtoCrewMember.doStockGCalcs; } ProtoCrewMember.doStockGCalcs = false; bool killed = false; for (int i = pC; i-- > 0;) { ProtoCrewMember pcm = part.protoModuleCrew[i]; double highGPenalty = vessel.geeForce > 3d ? System.Math.Pow(vessel.geeForce - 2d, 2d) : 1; double curDensity = part.atmDensity; if (curDensity < referenceDensityMin) { curDensity = referenceDensityMin; } double altitudeMult = (curAltitute - crewDeathAltitude) / crewDeathAltitude * 10d + referenceDensity / curDensity - 1d; double timeMult = System.Math.Pow(timeSinceHypoxiaStarted, 1.5d) * 0.01d; pcm.gExperienced += (0.5d + rnd.NextDouble()) * gDamageAdder * highGPenalty * altitudeMult * timeMult; double gMult = ProtoCrewMember.GToleranceMult(pcm) * HighLogic.CurrentGame.Parameters.CustomParams <GameParameters.AdvancedParams>().KerbalGToleranceMult; _anyCrewAboveWarnThreshold = pcm.gExperienced > PhysicsGlobals.KerbalGThresholdWarn * gMult; double locThreshold = PhysicsGlobals.KerbalGThresholdLOC * gMult; if (!pcm.outDueToG && pcm.gExperienced > locThreshold) { // Just passed out ScreenMessages.PostScreenMessage($"<color=red>{pcm.name} has lost consciousness due to hypoxia!</color>", 5.5f, ScreenMessageStyle.UPPER_CENTER); } // There's at least one cycle of delay after passing out before the death chance rolls start if (pcm.outDueToG && rnd.NextDouble() < crewDeathChance * altitudeMult * timeMult) { killed = true; ScreenMessages.PostScreenMessage($"{vessel.vesselName}: Crewmember {pcm.name} has died from exposure to near-vacuum.", 30.0f, ScreenMessageStyle.UPPER_CENTER, XKCDColors.Red); FlightLogger.fetch.LogEvent($"[{KSPUtil.PrintTime(vessel.missionTime, 3, false)}] {pcm.name} died from exposure to near-vacuum."); part.RemoveCrewmember(pcm); pcm.Die(); } } if (killed && CameraManager.Instance.currentCameraMode == CameraManager.CameraMode.IVA) { CameraManager.Instance.SetCameraFlight(); } } else { timeSinceHypoxiaStarted = 0d; if (_origDoStockGCalcs.HasValue) { ProtoCrewMember.doStockGCalcs = _origDoStockGCalcs.Value; _origDoStockGCalcs = null; } } } } }