예제 #1
0
        private void FixedUpdate()
        {
            if (Time.timeSinceLevelLoad < 2.0f || !setGameSettings) // Check not loading level
            {
                return;
            }

            if (IsFreezeActive) // Process active freezing process
            {
                ProcessFreezeKerbal();
            }

            if (IsThawActive) // Process active thawing process
            {
                ProcessThawKerbal();
            }

            //If an emergency thaw has been called, thaw the first kerbal in the stored frozen kerbal list until none remain.
            if (!IsFreezeActive && !IsThawActive && emergencyThawInProgress && vessel.isActiveVessel)
            {
                if (_StoredCrewList.Count > 0)
                {
                    skipThawStep1 = true;  // we don't use any EC for emergency thaw
                    beginThawKerbal(_StoredCrewList[0].CrewName);
                }
                else
                {
                    Utilities.Log_Debug("Emergency Thaw completed");
                }
            }

            // The following section is the on-going EC check and temperature checks and update the seat counts for the freezer, only in flight and activevessel
            if (HighLogic.LoadedSceneIsFlight && FlightGlobals.ready && vessel.isActiveVessel && setGameSettings)
            {
                if (DeepFreeze.Instance.DFsettings.ECreqdForFreezer)
                {
                    Fields["FrznChargeRequired"].guiActive = true;
                    Fields["FrznChargeUsage"].guiActive = true;
                    Fields["_FreezerOutofEC"].guiActive = true;
                    if (Utilities.timewarpIsValid(5))  // EC usage and generation still seems to work up to warpfactor of 4.
                    {
                        PartInfo partInfo;
                        if (!DeepFreeze.Instance.DFgameSettings.knownFreezerParts.TryGetValue(part.flightID, out partInfo))
                        {
                            Utilities.Log("Freezer Part NOT found: " + part.name + "(" + part.flightID + ")" + " (" + vessel.id + ")");
                            partInfo = new PartInfo(vessel.id, part.name, Planetarium.GetUniversalTime());
                            partInfo.ECWarning = false;
                        }
                        ChkOngoingEC(partInfo); // Check the on-going EC usage
                    }
                    else
                    {
                        timeSinceLastECtaken = (float)Planetarium.GetUniversalTime();
                    }
                }
                else
                {
                    Fields["FrznChargeRequired"].guiActive = false;
                    Fields["FrznChargeUsage"].guiActive = false;
                    Fields["_FreezerOutofEC"].guiActive = false;
                    timeSinceLastECtaken = (float)Planetarium.GetUniversalTime();
                }

                if (DeepFreeze.Instance.DFsettings.RegTempReqd)
                {
                    Fields["_FrzrTmp"].guiActive = true;
                    if (Utilities.timewarpIsValid(2)) // Temperature is buggy in timewarp so it is disabled whenever timewarp is on.
                    {
                        PartInfo partInfo;
                        if (!DeepFreeze.Instance.DFgameSettings.knownFreezerParts.TryGetValue(part.flightID, out partInfo))
                        {
                            Utilities.Log("Freezer Part NOT found: " + part.name + "(" + part.flightID + ")" + " (" + vessel.id + ")");
                            partInfo = new PartInfo(vessel.id, part.name, Planetarium.GetUniversalTime());
                            partInfo.TempWarning = false;
                        }
                        ChkOngoingTemp(partInfo); // Check the on-going Temperature
                    }
                    else
                    {
                        timeSinceLastTmpChk = (float)Planetarium.GetUniversalTime();
                    }
                }
                else
                {
                    Fields["_FrzrTmp"].guiActive = false;
                }

                UpdateCounts(); // Update the Kerbal counters and stored crew lists for the part
            }
        }
예제 #2
0
        internal static PartInfo Load(ConfigNode node)
        {
            string PartName = "Unknown";

            node.TryGetValue("PartName", ref PartName);
            double lastUpdate = 0.0;

            node.TryGetValue("lastUpdate", ref lastUpdate);
            string tmpvesselID = "";

            node.TryGetValue("vesselID", ref tmpvesselID);
            Guid vesselID = Guid.Empty;

            try
            {
                vesselID = new Guid(tmpvesselID);
            }
            catch (Exception ex)
            {
                vesselID = Guid.Empty;
                Debug.Log("DFInterface - Load of GUID VesselID for known part failed Err: " + ex);
            }
            PartInfo info = new PartInfo(vesselID, PartName, lastUpdate);

            node.TryGetValue("numSeats", ref info.numSeats);
            node.TryGetValue("numCrew", ref info.numCrew);

            string CrewString = "";

            node.TryGetValue("crewMembers", ref CrewString);

            string[] CrewStrings = CrewString.Split(',');
            if (CrewStrings.Length > 0)
            {
                for (int i = 0; i < CrewStrings.Length; i++)
                {
                    info.crewMembers.Add(CrewStrings[i]);
                }
            }
            string CrewTraitString = "";

            node.TryGetValue("crewMemberTraits", ref CrewTraitString);
            string[] CrewTStrings = CrewTraitString.Split(',');
            if (CrewTStrings.Length > 0)
            {
                for (int i = 0; i < CrewTStrings.Length; i++)
                {
                    info.crewMemberTraits.Add(CrewTStrings[i]);
                }
            }
            node.TryGetValue("numFrznCrew", ref info.numFrznCrew);
            node.TryGetValue("hibernating", ref info.hibernating);
            node.TryGetValue("hasextDoor", ref info.hasextDoor);
            node.TryGetValue("hasextPod", ref info.hasextPod);
            node.TryGetValue("timeLastElectricity", ref info.timeLastElectricity);
            node.TryGetValue("frznChargeRequired", ref info.frznChargeRequired);
            node.TryGetValue("timeLastTempCheck", ref info.timeLastTempCheck);
            node.TryGetValue("deathCounter", ref info.deathCounter);
            node.TryGetValue("tmpdeathCounter", ref info.tmpdeathCounter);
            node.TryGetValue("outofEC", ref info.outofEC);
            info.TmpStatus = Utilities.GetNodeValue(node, "TmpStatus", FrzrTmpStatus.OK);
            node.TryGetValue("cabinTemp", ref info.cabinTemp);
            node.TryGetValue("ECWarning", ref info.ECWarning);
            node.TryGetValue("TempWarning", ref info.TempWarning);

            return(info);
        }
예제 #3
0
        private void ChkOngoingEC(PartInfo partInfo)
        {
            // The following section of code consumes EC when we have ECreqdForFreezer set to true in the part config.
            // This consumes electric charge when we have frozen kerbals on board.
            // But due to bugs in KSP ith EC and SolarPanels at high timewarp if timewarp is > 4x we turn it off.
            // If we run out of EC and Lethal setting is on, we roll the dice. There is a 1 in 3 chance a Kerbal will DIE!!!!
            // If lethal setting is off an emergency thaw of all frozen crew occurs.

            //Utilities.Log_Debug("ChkOngoingEC start");
            double currenttime = Planetarium.GetUniversalTime();
            double timeperiod = currenttime - timeSinceLastECtaken;
            // Utilities.Log_Debug("currenttime = " + currenttime + " timeperiod = " + timeperiod + " updateECTempInterval= " + updateECTempInterval);
            if (timeperiod > updateECTempInterval) //only update every udpateECTempInterval to avoid request resource bug when amounts are too small
            {
                if (TotalFrozen > 0) //We have frozen Kerbals, consume EC
                {
                    double ECreqd = FrznChargeRequired / 60.0f * timeperiod * TotalFrozen;
                    Utilities.Log_Debug("DeepFreezer Running the freezer parms currenttime = {0} timeperiod = {1} ecreqd = {2}" , currenttime.ToString(), timeperiod.ToString(), ECreqd.ToString());
                    if (requireResource(vessel, EC, ECreqd, false, out ResAvail))
                    {
                        if (OnGoingECMsg != null) ScreenMessages.RemoveMessage(OnGoingECMsg);
                        //Have resource
                        requireResource(vessel, EC, ECreqd, true, out ResAvail);
                        FrznChargeUsage = (float)ResAvail;
                        Utilities.Log_Debug("DeepFreezer Consumed Freezer EC " + ECreqd + " units");
                        timeSinceLastECtaken = (float)currenttime;
                        deathCounter = currenttime;
                        _FreezerOutofEC = false;
                        partInfo.ECWarning = false;
                    }
                    else
                    {
                        if (Time.timeSinceLevelLoad < 5.0f) // this is true if vessel just loaded or we just switched to this vessel
                                              // we need to check if we aren't going to exhaust all EC in one call.. and???
                        {
                            ECreqd = ResAvail * 95 / 100;
                            if (requireResource(vessel, EC, ECreqd, false, out ResAvail))
                            {
                                requireResource(vessel, EC, ECreqd, true, out ResAvail);
                                FrznChargeUsage = (float)ResAvail;
                            }
                        }
                        //Debug.Log("DeepFreezer Ran out of EC to run the freezer");
                        if (!partInfo.ECWarning)
                        {
                            if (TimeWarp.CurrentRateIndex > 1) Utilities.stopWarp();
                            ScreenMessages.PostScreenMessage("Insufficient electric charge to monitor frozen kerbals.", 10.0f, ScreenMessageStyle.UPPER_CENTER);
                            partInfo.ECWarning = true;
                            deathCounter = currenttime;
                        }
                        if (OnGoingECMsg != null) ScreenMessages.RemoveMessage(OnGoingECMsg);
                        OnGoingECMsg = ScreenMessages.PostScreenMessage(" Freezer Out of EC : Systems critical in " + (deathRoll - (currenttime - deathCounter)).ToString("######0") + " secs");
                        _FreezerOutofEC = true;
                        FrznChargeUsage = 0f;
                        Utilities.Log_Debug("DeepFreezer deathCounter = " + deathCounter);
                        if (currenttime - deathCounter > deathRoll)
                        {
                            if (DeepFreeze.Instance.DFsettings.fatalOption)
                            {
                                Utilities.Log_Debug("DeepFreezer deathRoll reached, Kerbals all die...");
                                deathCounter = currenttime;
                                //all kerbals die
                                var kerbalsToDelete = new List<FrznCrewMbr>();
                                foreach (FrznCrewMbr deathKerbal in _StoredCrewList)
                                {
                                    DeepFreeze.Instance.KillFrozenCrew(deathKerbal.CrewName);
                                    ScreenMessages.PostScreenMessage(deathKerbal.CrewName + " died due to lack of Electrical Charge to run cryogenics", 10.0f, ScreenMessageStyle.UPPER_CENTER);
                                    Utilities.Log("DeepFreezer - kerbal " + deathKerbal.CrewName + " died due to lack of Electrical charge to run cryogenics");
                                    kerbalsToDelete.Add(deathKerbal);
                                    if (!flatline.isPlaying)
                                    {
                                        flatline.Play();
                                    }
                                }
                                kerbalsToDelete.ForEach(id => _StoredCrewList.Remove(id));
                            }
                            else  //NON-Fatal option set. Thaw them all.
                            {
                                Utilities.Log_Debug("DeepFreezer deathRoll reached, Kerbals all don't die... They just Thaw out...");
                                deathCounter = currenttime;
                                //all kerbals thaw out
                                emergencyThawInProgress = true;  //This will trigger FixedUpdate to thaw all frozen kerbals in the part, one by one.
                            }
                        }
                    }
                }
                else  // no frozen kerbals, so just update last time EC checked
                {
                    Utilities.Log_Debug("No frozen kerbals for EC consumption in part " + part.name);
                    timeSinceLastECtaken = (float)currenttime;
                    deathCounter = currenttime;
                    FrznChargeUsage = 0f;
                }
            }
            //Utilities.Log_Debug("ChkOngoingEC end");
        }
예제 #4
0
        private void ChkOngoingTemp(PartInfo partInfo)
        {
            // The follow section of code checks Temperatures when we have RegTempReqd set to true in the master config file.
            // This check is done when we have frozen kerbals on board.
            // But due to bugs in KSP with EC and SolarPanels at high timewarp if timewarp is > 4x we turn it off.
            // If the temperature is too high and fatal option is on, we roll the dice. There is a 1 in 3 chance a Kerbal will DIE!!!!
            // If fatal option is off all frozen kerbals are thawed
            double currenttime = Planetarium.GetUniversalTime();
            double timeperiod = currenttime - timeSinceLastTmpChk;
            //Utilities.Log_Debug("ChkOngoingTemp start time=" + Time.time.ToString() + ",timeSinceLastTmpChk=" + timeSinceLastTmpChk.ToString() + ",Planetarium.UniversalTime=" + Planetarium.GetUniversalTime().ToString() + " timeperiod=" + timeperiod.ToString());
            if (timeperiod > updateECTempInterval) //only update every udpateECTempInterval to avoid request resource bug when amounts are too small
            {
                if (TotalFrozen > 0) //We have frozen Kerbals, generate and check heat
                {
                    //Add Heat for equipment monitoring frozen kerbals
                    double heatamt = heatamtMonitoringFrznKerbals / 60.0f * timeperiod * TotalFrozen;
                    if (heatamt > 0) part.AddThermalFlux(heatamt);
                    Utilities.Log_Debug("Added " + heatamt + " kW of heat for monitoring " + TotalFrozen + " frozen kerbals");
                    if (part.temperature < DeepFreeze.Instance.DFsettings.RegTempMonitor)
                    {
                        Utilities.Log_Debug("DeepFreezer Temperature check is good parttemp=" + part.temperature + ",MaxTemp=" + DeepFreeze.Instance.DFsettings.RegTempMonitor);
                        if (TempChkMsg != null) ScreenMessages.RemoveMessage(TempChkMsg);
                        _FrzrTmp = FrzrTmpStatus.OK;
                        tmpdeathCounter = currenttime;
                        // do warning if within 40 and 20 kelvin
                        double tempdiff = DeepFreeze.Instance.DFsettings.RegTempMonitor - part.temperature;
                        if (tempdiff <= 40)
                        {
                            _FrzrTmp = FrzrTmpStatus.WARN;
                            ScreenMessages.PostScreenMessage("Check Temperatures, Freezer getting hot", 5.0f, ScreenMessageStyle.UPPER_CENTER);
                        }
                        else
                        {
                            if (tempdiff < 20)
                            {
                                _FrzrTmp = FrzrTmpStatus.RED;
                                ScreenMessages.PostScreenMessage("Warning!! Check Temperatures NOW, Freezer getting very hot", 5.0f, ScreenMessageStyle.UPPER_CENTER);
                            }
                        }
                        timeSinceLastTmpChk = (float)currenttime;
                        partInfo.TempWarning = false;
                    }
                    else
                    {
                        // OVER TEMP I'm Melting!!!!
                        Debug.Log("DeepFreezer Part Temp TOO HOT, Kerbals are going to melt parttemp=" + part.temperature);
                        if (!partInfo.TempWarning)
                        {
                            if (TimeWarp.CurrentRateIndex > 1) Utilities.stopWarp();
                            ScreenMessages.PostScreenMessage("Temperature getting too hot for kerbals to remain frozen.", 10.0f, ScreenMessageStyle.UPPER_CENTER);
                            partInfo.TempWarning = true;
                        }
                        _FrzrTmp = FrzrTmpStatus.RED;
                        Utilities.Log_Debug("DeepFreezer tmpdeathCounter = {0}" , tmpdeathCounter.ToString());
                        if (TempChkMsg != null) ScreenMessages.RemoveMessage(TempChkMsg);
                        TempChkMsg = ScreenMessages.PostScreenMessage(" Freezer Over Temp : Systems critical in " + (tmpdeathRoll - (currenttime - tmpdeathCounter)).ToString("######0") + " secs");
                        if (currenttime - tmpdeathCounter > tmpdeathRoll)
                        {
                            Utilities.Log_Debug("DeepFreezer tmpdeathRoll reached, roll the dice...");
                            tmpdeathCounter = currenttime;
                            partInfo.TempWarning = false;
                            //a kerbal dies
                            if (DeepFreeze.Instance.DFsettings.fatalOption)
                            {
                                int dice = rnd.Next(1, _StoredCrewList.Count); // Randomly select a Kerbal to kill.
                                Utilities.Log_Debug("DeepFreezer A Kerbal dies dice=" + dice);
                                FrznCrewMbr deathKerbal = _StoredCrewList[dice - 1];
                                DeepFreeze.Instance.KillFrozenCrew(deathKerbal.CrewName);
                                ScreenMessages.PostScreenMessage(deathKerbal.CrewName + " died due to overheating, cannot keep frozen", 10.0f, ScreenMessageStyle.UPPER_CENTER);
                                Debug.Log("DeepFreezer - kerbal " + deathKerbal.CrewName + " died due to overheating, cannot keep frozen");
                                _StoredCrewList.Remove(deathKerbal);

                                if (!flatline.isPlaying)
                                {
                                    flatline.Play();
                                }
                            }
                            else  //NON-fatal option set. Thaw them all.
                            {
                                ScreenMessages.PostScreenMessage("Over Temperature - Emergency Thaw in Progress.", 10.0f, ScreenMessageStyle.UPPER_CENTER);
                                Utilities.Log_Debug("DeepFreezer deathRoll reached, Kerbals all don't die... They just Thaw out...");
                                //all kerbals thaw out
                                emergencyThawInProgress = true;  //This will trigger FixedUpdate to thaw all frozen kerbals in the part, one by one.
                            }
                        }
                    }
                }
                else  // no frozen kerbals, so just update last time tmp checked
                {
                    timeSinceLastTmpChk = (float)currenttime;
                }
            }
            //Utilities.Log_Debug("ChkOngoingTemp end");
        }
예제 #5
0
        internal void Load(ConfigNode node)
        {
            KnownFrozenKerbals.Clear();
            knownVessels.Clear();
            knownFreezerParts.Clear();
            knownKACAlarms.Clear();

            if (node.HasNode(configNodeName))
            {
                ConfigNode DFsettingsNode = node.GetNode(configNodeName);
                DFsettingsNode.TryGetValue("Enabled", ref Enabled);

                KnownFrozenKerbals.Clear();
                var kerbalNodes = DFsettingsNode.GetNodes(KerbalInfo.ConfigNodeName);
                foreach (ConfigNode kerbalNode in kerbalNodes)
                {
                    if (kerbalNode.HasValue("kerbalName"))
                    {
                        string id = kerbalNode.GetValue("kerbalName");
                        Utilities.Log_Debug("DFGameSettings Loading kerbal = " + id);
                        KerbalInfo kerbalInfo = KerbalInfo.Load(kerbalNode);
                        KnownFrozenKerbals.Add(id, kerbalInfo);
                    }
                }
                Utilities.Log_Debug("DFGameSettings finished loading FrozenKerbals");
                knownVessels.Clear();
                var vesselNodes = DFsettingsNode.GetNodes(VesselInfo.ConfigNodeName);
                foreach (ConfigNode vesselNode in vesselNodes)
                {
                    if (vesselNode.HasValue("Guid"))
                    {
                        Guid id = new Guid(vesselNode.GetValue("Guid"));
                        Utilities.Log_Debug("DFGameSettings Loading Guid = " + id);
                        VesselInfo vesselInfo = VesselInfo.Load(vesselNode);
                        knownVessels[id] = vesselInfo;
                    }
                }
                Utilities.Log_Debug("DFGameSettings finished loading KnownVessels");
                knownFreezerParts.Clear();
                var partNodes = DFsettingsNode.GetNodes(PartInfo.ConfigNodeName);
                foreach (ConfigNode partNode in partNodes)
                {
                    if (partNode.HasValue("flightID"))
                    {
                        uint id = uint.Parse(partNode.GetValue("flightID"));
                        Utilities.Log_Debug("DFGameSettings Loading flightID = " + id);
                        PartInfo partInfo = PartInfo.Load(partNode);
                        knownFreezerParts[id] = partInfo;
                    }
                }
                Utilities.Log_Debug("DFGameSettings finished loading KnownParts");
                knownKACAlarms.Clear();
                var KACAlarmNodes = DFsettingsNode.GetNodes(AlarmInfo.ConfigNodeName);
                foreach (ConfigNode alarmNode in KACAlarmNodes)
                {
                    if (alarmNode.HasValue("alarmID"))
                    {
                        string alarmID = alarmNode.GetValue("alarmID");
                        Utilities.Log_Debug("DFGameSettings Loading alarmID = " + alarmID);
                        AlarmInfo alarmInfo = AlarmInfo.Load(alarmNode);
                        knownKACAlarms[alarmID] = alarmInfo;
                    }
                }
                SyncDictionaries();
            }
            Utilities.Log_Debug("DFGameSettings Loading Complete");
        }
예제 #6
0
        internal static PartInfo Load(ConfigNode node)
        {
            string PartName = Utilities.GetNodeValue(node, "PartName", "Unknown");
            double lastUpdate = Utilities.GetNodeValue(node, "lastUpdate", 0.0);
            string tmpvesselID = Utilities.GetNodeValue(node, "vesselID", "");
            Guid vesselID = Guid.Empty;
            try
            {
                vesselID = new Guid(tmpvesselID);
            }
            catch (Exception ex)
            {
                vesselID = Guid.Empty;
                Debug.Log("DFInterface - Load of GUID VesselID for known part failed Err: " + ex);
            }
            PartInfo info = new PartInfo(vesselID, PartName, lastUpdate);
            info.numSeats = Utilities.GetNodeValue(node, "numSeats", 0);
            info.numCrew = Utilities.GetNodeValue(node, "numCrew", 0);
            string CrewString = Utilities.GetNodeValue(node, "crewMembers", string.Empty);
            string[] CrewStrings = CrewString.Split(',');
            if (CrewStrings.Length > 0)
            {
                for (int i = 0; i < CrewStrings.Length; i++)
                {
                    info.crewMembers.Add(CrewStrings[i]);
                }
            }
            string CrewTraitString = Utilities.GetNodeValue(node, "crewMemberTraits", string.Empty);
            string[] CrewTStrings = CrewTraitString.Split(',');
            if (CrewTStrings.Length > 0)
            {
                for (int i = 0; i < CrewTStrings.Length; i++)
                {
                    info.crewMemberTraits.Add(CrewTStrings[i]);
                }
            }
            info.numFrznCrew = Utilities.GetNodeValue(node, "numFrznCrew", 0);
            info.hibernating = Utilities.GetNodeValue(node, "hibernating", false);
            info.hasextDoor = Utilities.GetNodeValue(node, "hasextDoor", false);
            info.timeLastElectricity = Utilities.GetNodeValue(node, "timeLastElectricity", lastUpdate);
            info.frznChargeRequired = Utilities.GetNodeValue(node, "frznChargeRequired", 0d);
            info.timeLastTempCheck = Utilities.GetNodeValue(node, "timeLastTempCheck", lastUpdate);
            info.deathCounter = Utilities.GetNodeValue(node, "deathCounter", 0d);
            info.tmpdeathCounter = Utilities.GetNodeValue(node, "tmpdeathCounter", 0d);
            info.outofEC = Utilities.GetNodeValue(node, "outofEC", false);
            info.TmpStatus = Utilities.GetNodeValue(node, "TmpStatus", FrzrTmpStatus.OK);
            info.cabinTemp = Utilities.GetNodeValue(node, "cabinTemp", 0f);
            info.ECWarning = Utilities.GetNodeValue(node, "ECWarning", false);
            info.TempWarning = Utilities.GetNodeValue(node, "TempWarning", false);

            return info;
        }
예제 #7
0
        private void FixedUpdate()
        {
            if (Time.timeSinceLevelLoad < 2.0f) // Check not loading level
            {
                return;
            }

            if (IsFreezeActive) // Process active freezing process
            {
                ProcessFreezeKerbal();
            }

            if (IsThawActive) // Process active thawing process
            {
                ProcessThawKerbal();
            }

            //If an emergency thaw has been called, thaw the first kerbal in the stored frozen kerbal list until none remain.
            if (!IsFreezeActive && !IsThawActive && emergencyThawInProgress && vessel.isActiveVessel)
            {
                if (_StoredCrewList.Count > 0)
                {
                    skipThawStep1 = true;  // we don't use any EC for emergency thaw
                    beginThawKerbal(_StoredCrewList[0].CrewName);
                }
                else
                {
                    this.Log_Debug("Emergency Thaw completed");
                }
            }

            // The following section is the on-going EC check and temperature checks and update the seat counts for the freezer, only in flight and activevessel
            if (HighLogic.LoadedSceneIsFlight && FlightGlobals.ready && vessel.isActiveVessel && setGameSettings)
            {
                if (DeepFreeze.Instance.DFsettings.ECreqdForFreezer)
                {
                    this.Fields["FrznChargeRequired"].guiActive = true;
                    this.Fields["FrznChargeUsage"].guiActive = true;
                    this.Fields["_FreezerOutofEC"].guiActive = true;
                    if (Utilities.timewarpIsValid(5))  // EC usage and generation still seems to work up to warpfactor of 4.
                    {
                        PartInfo partInfo;
                        if (!DeepFreeze.Instance.DFgameSettings.knownFreezerParts.TryGetValue(this.part.flightID, out partInfo))
                        {
                            this.Log("Freezer Part NOT found: " + this.part.name + "(" + this.part.flightID + ")" + " (" + vessel.id + ")");
                            partInfo = new PartInfo(vessel.id, this.part.name, Planetarium.GetUniversalTime());
                            partInfo.ECWarning = false;
                        }
                        ChkOngoingEC(partInfo); // Check the on-going EC usage
                    }
                    else
                    {
                        timeSinceLastECtaken = (float)Planetarium.GetUniversalTime();
                    }
                }
                else
                {
                    this.Fields["FrznChargeRequired"].guiActive = false;
                    this.Fields["FrznChargeUsage"].guiActive = false;
                    this.Fields["_FreezerOutofEC"].guiActive = false;
                    timeSinceLastECtaken = (float)Planetarium.GetUniversalTime();
                }

                if (DeepFreeze.Instance.DFsettings.RegTempReqd)
                {
                    this.Fields["_FrzrTmp"].guiActive = true;
                    if (Utilities.timewarpIsValid(2)) // Temperature is buggy in timewarp so it is disabled whenever timewarp is on.
                    {
                        PartInfo partInfo;
                        if (!DeepFreeze.Instance.DFgameSettings.knownFreezerParts.TryGetValue(this.part.flightID, out partInfo))
                        {
                            this.Log("Freezer Part NOT found: " + this.part.name + "(" + this.part.flightID + ")" + " (" + vessel.id + ")");
                            partInfo = new PartInfo(vessel.id, this.part.name, Planetarium.GetUniversalTime());
                            partInfo.TempWarning = false;
                        }
                        ChkOngoingTemp(partInfo); // Check the on-going Temperature
                    }
                    else
                    {
                        timeSinceLastTmpChk = (float)Planetarium.GetUniversalTime();
                    }
                }
                else
                {
                    this.Fields["_FrzrTmp"].guiActive = false;
                }

                if (onvslchgExternal)
                {
                    timeSinceLastECtaken = (float)Planetarium.GetUniversalTime();
                    timeSinceLastTmpChk = (float)Planetarium.GetUniversalTime();
                    onvslchgNotActive = true;
                    onvslchgNotActiveDelay = 0f;
                    onvslchgExternal = false;
                }

                if (onvslchgNotActive) // this only runs if a VesselChange game event has triggered externally (not triggered by this module)
                {
                    if (onvslchgNotActiveDelay > 3f)
                    {
                        this.Log_Debug("Onupdate reset cryopod doors after vessel change");
                        onvslchgNotActive = false;
                        if (partHasInternals)
                        {
                            resetCryopods(true);
                        }
                        if (hasExternalDoor)
                        {
                            setHelmetstoDoorState();
                            setDoorHandletoDoorState();
                        }
                    }
                    else
                    {
                        if (_crewXferTOActive)
                        {
                            //Crew Xfer is the cause of the vessel change, let the crewXfer code reset the pods. so reset this counter and turn off this event.
                            onvslchgNotActive = false;
                        }
                        onvslchgNotActiveDelay += Time.fixedDeltaTime;
                    }
                }
                UpdateCounts(); // Update the Kerbal counters and stored crew lists for the part
            }
        }
예제 #8
0
 private void Start()
 {
     Utilities.Log_Debug("DFIntMemory startup");
     ChkUnknownFrozenKerbals();
     ChkActiveFrozenKerbals();
     DeepFreeze.Instance.DFgameSettings.DmpKnownFznKerbals();
     resetFreezerCams();
     if (Utilities.GameModeisFlight)
     {
         if (DFInstalledMods.IsTexReplacerInstalled)
         {
             TRWrapper.InitTRWrapper();
         }
         if (DFInstalledMods.IsUSILSInstalled)
         {
             USIWrapper.InitUSIWrapper();
         }
         if (DFInstalledMods.IsSMInstalled)
         {
             SMWrapper.InitSMWrapper();
         }
     }
     if (DFInstalledMods.IsRTInstalled)
     {
         RTWrapper.InitTRWrapper();
     }
     currentTime = Planetarium.GetUniversalTime();
     lastFixedUpdateTime = currentTime;
     vesselInfo = new VesselInfo("testVessel", currentTime);
     partInfo = new PartInfo(Guid.Empty, "testPart", currentTime);
 }
예제 #9
0
        private void UpdateVesselInfo(VesselInfo vesselInfo, Vessel vessel, double currentTime)
        {
            // Utilities.Log_Debug("UpdateVesselInfo " + vesselInfo.vesselName);
            vesselInfo.vesselType = vessel.vesselType;
            vesselInfo.lastUpdate = Planetarium.GetUniversalTime();
            vesselInfo.hibernating = false;
            vesselInfo.hasextDoor = false;
            vesselInfo.hasextPod = false;
            DpFrzrLoadedVsl.Clear();
            DpFrzrLoadedVsl = vessel.FindPartModulesImplementing<DeepFreezer>();
            foreach (DeepFreezer frzr in DpFrzrLoadedVsl)
            {
                // do we have a known part? If not add it
                if (!DeepFreeze.Instance.DFgameSettings.knownFreezerParts.TryGetValue(frzr.part.flightID, out partInfo))
                {
                    Utilities.Log("New Freezer Part: " + frzr.name + "(" + frzr.part.flightID + ")" + " (" + vessel.id + ")");
                    partInfo = new PartInfo(vessel.id, frzr.name, currentTime);
                    //partInfo.vesselID = vessel.id;
                    //partInfo.PartName = frzr.name;
                    partInfo.hibernating = false;
                    partInfo.ECWarning = false;
                    partInfo.TempWarning = false;
                    partInfo.lastUpdate = currentTime;
                    partInfo.crewMembers.Clear();
                    partInfo.crewMemberTraits.Clear();

                    partInfo.hasextDoor = frzr.ExternalDoorActive;
                    partInfo.hasextPod = frzr.isPodExternal;
                    partInfo.numSeats = frzr.FreezerSize;
                    partInfo.timeLastElectricity = frzr.timeSinceLastECtaken;
                    partInfo.frznChargeRequired = frzr.FrznChargeRequired;
                    partInfo.timeLastTempCheck = frzr.timeSinceLastTmpChk;
                    partInfo.deathCounter = frzr.deathCounter;
                    partInfo.tmpdeathCounter = frzr.tmpdeathCounter;
                    partInfo.outofEC = frzr.DFFreezerOutofEC;
                    partInfo.TmpStatus = frzr.DFFrzrTmp;
                    partInfo.cabinTemp = frzr.CabinTemp;
                    foreach (ProtoCrewMember crew in frzr.part.protoModuleCrew)
                    {
                        partInfo.crewMembers.Add(crew.name);
                        partInfo.crewMemberTraits.Add(crew.experienceTrait.Title);
                    }

                    DeepFreeze.Instance.DFgameSettings.knownFreezerParts[frzr.part.flightID] = partInfo;
                }
                else   // Update existing entry
                {
                    partInfo.hasextDoor = frzr.ExternalDoorActive;
                    partInfo.hasextPod = frzr.isPodExternal;
                    partInfo.numSeats = frzr.FreezerSize;
                    partInfo.timeLastElectricity = frzr.timeSinceLastECtaken;
                    partInfo.frznChargeRequired = frzr.FrznChargeRequired;
                    partInfo.timeLastTempCheck = frzr.timeSinceLastTmpChk;
                    partInfo.deathCounter = frzr.deathCounter;
                    partInfo.tmpdeathCounter = frzr.tmpdeathCounter;
                    partInfo.outofEC = frzr.DFFreezerOutofEC;
                    partInfo.TmpStatus = frzr.DFFrzrTmp;
                    partInfo.cabinTemp = frzr.CabinTemp;
                    partInfo.crewMembers.Clear();
                    partInfo.crewMemberTraits.Clear();
                    foreach (ProtoCrewMember crew in frzr.part.protoModuleCrew)
                    {
                        partInfo.crewMembers.Add(crew.name);
                        partInfo.crewMemberTraits.Add(crew.experienceTrait.Title);
                    }
                }
                //now update the knownfreezerpart and any related vesselinfo field
                if (frzr.ExternalDoorActive)
                    vesselInfo.hasextDoor = true;
                if (frzr.isPodExternal)
                    vesselInfo.hasextPod = true;
            }
        }