public static KerbalInfo Load(ConfigNode node) { double lastUpdate = GetNodeValue(node, "lastUpdate", 0.0); KerbalInfo info = new KerbalInfo(lastUpdate); info.status = GetNodeValue(node, "status", ProtoCrewMember.RosterStatus.Dead); info.type = GetNodeValue(node, "type", ProtoCrewMember.KerbalType.Unowned); string tmpvesselID = GetNodeValue(node, "vesselID", ""); try { info.vesselID = new Guid(tmpvesselID); } catch (Exception ex) { info.vesselID = Guid.Empty; Debug.Log("DFInterface - Load of GUID VesselID for frozen kerbal failed Err: " + ex); } info.partID = GetNodeValue(node, "partID", (uint)0); info.vesselName = GetNodeValue(node, "VesselName", " "); info.seatIdx = GetNodeValue(node, "seatIdx", 0); info.seatName = GetNodeValue(node, "seatName", ""); info.experienceTraitName = GetNodeValue(node, "experienceTraitName", " "); return(info); }
protected void onVesselRecovered(ProtoVessel vessel, bool notSureWhatFor) { Utilities.Log("DeepFreezeEvents onVesselRecovered " + vessel.vesselID); List <string> frznKerbalkeys = new List <string>(DFgameSettings.KnownFrozenKerbals.Keys); foreach (string key in frznKerbalkeys) { KerbalInfo kerbalinfo = DFgameSettings.KnownFrozenKerbals[key]; if (kerbalinfo.vesselID == vessel.vesselID) { if (kerbalinfo.type == ProtoCrewMember.KerbalType.Unowned) //Frozen crew { if (Instance.DFsettings.AutoRecoverFznKerbals) { Utilities.Log_Debug("AutoRecover is ON"); Utilities.Log("Calling ThawFrozen Crew to thaw FrozenCrew " + key); ThawFrozenCrew(key, vessel.vesselID); } else { Utilities.Log("DeepFreeze AutoRecovery of frozen kerbals is set to off. Must be thawed manually."); Utilities.Log("DeepFreezeEvents frozenkerbal remains frozen =" + key); ProtoCrewMember realkerbal = HighLogic.CurrentGame.CrewRoster.Unowned.FirstOrDefault(b => b.name == key); if (realkerbal != null) { realkerbal.type = ProtoCrewMember.KerbalType.Unowned; realkerbal.rosterStatus = ProtoCrewMember.RosterStatus.Dead; Utilities.Log_Debug("Kerbal " + realkerbal.name + " " + realkerbal.type + " " + realkerbal.rosterStatus); ScreenMessages.PostScreenMessage(key + " was stored frozen at KSC", 5.0f, ScreenMessageStyle.UPPER_LEFT); } } } else // Tourist/Comatose crew { Utilities.Log_Debug("Comatose crew - reset to crew " + key); ProtoCrewMember crew = HighLogic.CurrentGame.CrewRoster.Tourist.FirstOrDefault(c => c.name == key); if (crew != null) { crew.type = ProtoCrewMember.KerbalType.Crew; crew.rosterStatus = ProtoCrewMember.RosterStatus.Assigned; Utilities.Log_Debug("Kerbal " + crew.name + " " + crew.type + " " + crew.rosterStatus); crew.ArchiveFlightLog(); crew.rosterStatus = ProtoCrewMember.RosterStatus.Available; DFgameSettings.KnownFrozenKerbals.Remove(crew.name); } } } } var alarmsToDelete = new List <string>(); alarmsToDelete.AddRange(Instance.DFgameSettings.knownKACAlarms.Where(e => e.Value.VesselID == vessel.vesselID).Select(e => e.Key).ToList()); alarmsToDelete.ForEach(id => Instance.DFgameSettings.knownKACAlarms.Remove(id)); var partsToDelete = new List <uint>(); partsToDelete.AddRange(Instance.DFgameSettings.knownFreezerParts.Where(e => e.Value.vesselID == vessel.vesselID).Select(e => e.Key).ToList()); partsToDelete.ForEach(id => Instance.DFgameSettings.knownFreezerParts.Remove(id)); if (DFgameSettings.knownVessels.ContainsKey(vessel.vesselID)) { DFgameSettings.knownVessels.Remove(vessel.vesselID); } }
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"); }