Exemple #1
0
        /*public override void OnSave(ConfigNode node)
        {
            Debug.Log("# OnSave " + node);
            return;
            base.OnSave(node);
            Debug.Log("# Saving hatches");
            ConfigNode hatchNode = new ConfigNode("Hatch");
            foreach (Hatch h in Hatches)
            {
                hatchNode.AddValue("attachNodeId", h.AttachNodeId);
                hatchNode.AddValue("position", h.Position.x + ", " +  h.Position.y + ", " + h.Position.z);
                hatchNode.AddValue("scale", h.Scale.x + ", " + h.Scale.y + ", " + h.Scale.z);
            }
            Debug.Log("# Adding hatch node " + hatchNode);
            node.AddNode(hatchNode);
        }*/
        public override void OnLoad(ConfigNode node)
        {
            if (node.HasValue("CanIva"))
                CanIva = bool.Parse(node.GetValue("CanIva"));

            if (node.HasNode("Hatch"))
            {
                ConfigNode[] hatchNodes = node.GetNodes("Hatch");
                foreach (var hn in hatchNodes)
                {
                    Hatch h = ParseHatch(hn);
                    if (h != null)
                    {
                        Hatches.Add(h);
                        if (h.Collider != null)
                            InternalColliders.Add(h.Collider);
                    }
                }
                PersistenceManager.instance.AddHatches(part.name, Hatches);
            }
            Debug.Log("# Hatches loaded from config for part " + part.name + ": " + Hatches.Count);

            if (node.HasNode("InternalCollider"))
            {
                ConfigNode[] colliderNodes = node.GetNodes("InternalCollider");
                foreach (var cn in colliderNodes)
                {
                    InternalCollider ic = ParseInternalCollider(cn);
                    if (ic != null)
                        InternalColliders.Add(ic);
                }
                PersistenceManager.instance.AddInternalColliders(part.name, InternalColliders);
                Debug.Log("# Internal colliders loaded from config for part " + part.name + ": " + InternalColliders.Count);
            }
        }
        public void Load(ConfigNode node)
        {
            unlocked = false;

            node.TryGetValue("name", ref name);

            double cost = 0d;
            node.TryGetValue("cost", ref cost);

            node.TryGetValue("entryCost", ref entryCost);
            if(double.IsNaN(entryCost))
                entryCost = Math.Max(0d, cost * RFSettings.Instance.configEntryCostMultiplier);

            node.TryGetValue("sciEntryCost", ref sciEntryCost);
            if(double.IsNaN(sciEntryCost))
                sciEntryCost = Math.Max(0d, cost * RFSettings.Instance.configScienceCostMultiplier);

            node.TryGetValue("unlocked", ref unlocked);

            node.TryGetValue("techRequired", ref techRequired);

            if (node.HasNode("entryCostMultipliers"))
                LoadMultipliers(node.GetNode("entryCostMultipliers"));

            if (node.HasNode("entryCostSubtractors"))
                LoadSubtractors(node.GetNode("entryCostSubtractors"));

            node.TryGetValue("maxSubtraction", ref maxSubtraction);
        }
 public override void OnLoad(ConfigNode node)
 {
     try
     {
         if (!vessel.isEVA)
         {
             foreach (ProtoCrewMember crewmember in part.protoModuleCrew)
             {
                 if (!VanAllen.crew_rad_exposure.ContainsKey(crewmember.name))
                 {
                     if (node.HasNode("KERBAL_RADIATION_" + crewmember.name))
                     {
                         ConfigNode rad_node = node.GetNode("KERBAL_RADIATION_" + crewmember.name);
                         if (rad_node.HasValue("lifetimeDose"))
                             VanAllen.crew_rad_exposure.Add(crewmember.name, double.Parse(rad_node.GetValue("lifetimeDose")));
                     }
                 }
             }
         }
         else
         {
             if (!VanAllen.crew_rad_exposure.ContainsKey(vessel.vesselName))
             {
                 if (node.HasNode("KERBAL_RADIATION_" + vessel.vesselName))
                 {
                     ConfigNode rad_node = node.GetNode("KERBAL_RADIATION_" + vessel.vesselName);
                     if (rad_node.HasValue("lifetimeDose"))
                         VanAllen.crew_rad_exposure.Add(vessel.vesselName, double.Parse(rad_node.GetValue("lifetimeDose")));
                 }
             }
         }
     }
     catch (Exception ex) { }
 }
        public override void OnLoad(ConfigNode gameNode)
        {
            //reset the list here
            //KerbalAlarmClock.alarms = new KACAlarmList();
            KerbalAlarmClock.alarms.RemoveRange(0,KerbalAlarmClock.alarms.Count);

            base.OnLoad(gameNode);
            MonoBehaviourExtended.LogFormatted("BaseLoadDone. Alarms Count (Should be 0):{0}", KerbalAlarmClock.alarms.Count);

            MonoBehaviourExtended.LogFormatted_DebugOnly("OnLoad: ");
            MonoBehaviourExtended.LogFormatted_DebugOnly("{0}",gameNode);

            if (gameNode.HasNode("KerbalAlarmClockScenario")) MonoBehaviourExtended.LogFormatted_DebugOnly("Found {0}","KerbalAlarmClockScenario");
            if (gameNode.HasNode("KACAlarmListStorage")) MonoBehaviourExtended.LogFormatted_DebugOnly("Found {0}", "KACAlarmListStorage");
            if(gameNode.HasNode("KACAlarmListStorage"))
            {
                KerbalAlarmClock.alarms.DecodeFromCN(gameNode.GetNode("KACAlarmListStorage"));

                foreach (KACAlarm a in KerbalAlarmClock.alarms)
                {
                    if (!a.AlarmActionConverted) {
                        a.AlarmActionConvert = a.AlarmAction;
                        a.AlarmAction = KACAlarm.AlarmActionEnum.Converted;
                        a.AlarmActionConverted = true;
                    }
                }
            }

            MonoBehaviourExtended.LogFormatted("ScenarioLoadDone. Alarms Count:{0}", KerbalAlarmClock.alarms.Count);
            //{MonoBehaviourExtended.LogFormatted_DebugOnly("A");} else {MonoBehaviourExtended.LogFormatted_DebugOnly("B");}
            //KerbalAlarmClock.alarms.DecodeFromCN(gameNode.GetNode(this.GetType().Name));
        }
Exemple #5
0
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     if (node.HasNode("RENAME") || node.HasNode("DISABLE"))
     {
         configNodeData = node.ToString();
     }
 }
Exemple #6
0
 public override void OnLoad(ConfigNode node)
 {
     if (node.HasNode("library"))
     {
         library.Load(node.GetNode("library"));
     }
 }
        public void Load(ConfigNode node)
        {
            if (node.HasNode(configNodeName))
            {
                ConfigNode settingsNode = node.GetNode(configNodeName);

                settingsNode.TryGetValue("IsNewSave", ref IsNewSave);

                knownCrew.Clear();
                var crewNodes = settingsNode.GetNodes(CrewMemberInfo.ConfigNodeName);
                foreach (ConfigNode crewNode in crewNodes)
                {
                    CrewMemberInfo crewMemberInfo = CrewMemberInfo.Load(crewNode);
                    knownCrew[crewMemberInfo.name] = crewMemberInfo;
                }

                knownVessels.Clear();
                var vesselNodes = settingsNode.GetNodes(VesselInfo.ConfigNodeName);
                foreach (ConfigNode vesselNode in vesselNodes)
                {
                    if (vesselNode.HasValue("Guid"))
                    {
                        Guid id = new Guid(vesselNode.GetValue("Guid"));
                        VesselInfo vesselInfo = VesselInfo.Load(vesselNode);
                        knownVessels[id] = vesselInfo;
                    }
                }
            }
        }
        public void Awake()
        {
            //            Debug.Log("********************************************************************" + HighLogic.LoadedScene + "*********************************************************************");
            settings = ConfigNode.Load("GameData/CustomerSatisfactionProgram/Config.cfg");

            if (settings.HasNode("SETTINGS")) {
                Debug.Log("Loading Settings");
                settings = settings.GetNode("SETTINGS");

                if (settings.HasValue("VERSION")) {
                    version = (settings.GetValue("VERSION"));
                }
                if (settings.HasValue("CAP")) {
                    cap = (int.Parse(settings.GetValue("CAP")));
                }
                if (settings.HasValue("CLEANUP")) {
                    cleanup = (int.Parse(settings.GetValue("CLEANUP")));
                    if (cleanup == 2) {
                        settings.AddValue("CLEANUP", 0);
                    }
                }
            }

            GameEvents.onKerbalRemoved.Add(OnKerbalRemoved);
            GameEvents.onKerbalAdded.Add(OnKerbalAdded);
            GameEvents.onKerbalTypeChange.Add(OnKerbalTypeChange);
            GameEvents.onGameSceneLoadRequested.Add(OnGameSceneLoadRequested);
        }
        //load scenario
        public override void OnLoad(ConfigNode node)
        {
            try {
            if (node.HasNode(CONFIG_NODENAME)) {
              //load
              Debug.Log("StateFundingScenario loading from persistence");
              ConfigNode loadNode = node.GetNode(CONFIG_NODENAME);
              ConfigNode.LoadObjectFromConfig(data, loadNode);
              isInit = true;
            }
            else {
              Debug.Log("StateFundingScenario default init");
              //default init
              var NewView = new NewInstanceConfigView ();
              NewView.OnCreate ((InstanceData Inst) => {
            data = Inst;
            ReviewMgr.CompleteReview ();
              });
              isInit = true;
            }

            for (int i = 0; i < StateFundingGlobal.fetch.Governments.ToArray ().Length; i++) {
              Government Gov = StateFundingGlobal.fetch.Governments.ToArray () [i];
              if (Gov.name == data.govName) {
            data.Gov = Gov;
              }
            }

              }
              catch {

              }
        }
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     if (node.HasNode("LOOK_CONST") || node.HasNode("POS_CONST"))
     {
         configNodeData = node.ToString();
     }
     if (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor)
     {
         initialize();
     }
     else
     {
         initializePrefab();
     }
 }
Exemple #11
0
        private bool CheckForDataNodes(ConfigNode node)
        {
            foreach (string type in KRESUtils.types.Values)
            {
                if (!node.HasNode(type)) { goto Incomplete; }
                ConfigNode t = node.GetNode(type);
                foreach (CelestialBody body in KRESUtils.GetRelevantBodies(type))
                {
                    if (!t.HasNode(body.bodyName)) { goto Incomplete; }
                }
            }
            return true;

            Incomplete:
            {
                print("no nodes");
                node.ClearNodes();
                foreach(string type in KRESUtils.types.Values)
                {
                    ConfigNode t = node.AddNode(type);
                    foreach(CelestialBody body in KRESUtils.GetRelevantBodies(type))
                    {
                        ConfigNode b = t.AddNode(body.bodyName);
                        b.AddValue("currentError", 1d);
                    }
                }
                return false;
            }
        }
Exemple #12
0
 //called on GameSave event, refresh all data from loaded vessels and save to .sfs
 private void GameSaveTrigger(ConfigNode node)
 {
     //need to call save routines here
     if (node.HasNode("VMSNode")) //note that we do not load data at this point, our data storage is static so we know what's in the save file is old, invalid data
     {
         node.RemoveNodes("VMSNode"); //should only ever be on VMSnode in a file, remove all nodes to error trap it
     }
     node.AddNode(VesselModuleStaticData.SaveRoutine());
 }
 public override void OnLoad(ConfigNode node)
 {
     if (node.HasNode("ScienceData"))
     {
         ConfigNode storedDataNode = node.GetNode("ScienceData");
         ImpactScienceData data = new ImpactScienceData(storedDataNode);
         result=data;
     }
 }
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     if (node.HasNode("TEXTURESET"))
     {
         configNodeData = node.ToString();
     }
     initialize();
 }
 public void Load(ConfigNode node)
 {
     if (!HighLogic.LoadedSceneIsEditor && node.HasNode("UllageSim"))
     {
     #if DEBUG
         MonoBehaviour.print("*U* Ullage load called on " + engine.part.name);
     #endif
         ullageSim.Load(node.GetNode("UllageSim"));
     }
 }
 public void Load(ConfigNode node)
 {
     if (node.HasValue("scope"))
         scope = node.GetValue("scope").ToLower();
     if (node.HasNode("reliabilityCurve"))
     {
         reliabilityCurve = new FloatCurve();
         reliabilityCurve.Load(node.GetNode("reliabilityCurve"));
     }
 }
Exemple #17
0
 //load data from .sfs file and then refresh any already loaded vessels, may be no vessels loaded depending on race conditions
 private void GameLoadTrigger(ConfigNode node)
 {
     VesselModuleStaticData.ClearData();
     ConfigNode vmNode = new ConfigNode("VMSNode");
     if (node.HasNode("VMSNode"))
     {
         vmNode = node.GetNode("VMSNode");
     }
     VesselModuleStaticData.LoadRoutine(vmNode); //load data into static data module, okay to pass empty node
     VesselModuleStaticData.RefreshVesselData(); //refresh data in any VesselModuleSave that have already loaded somehow
 }
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     if (node.HasNode("cycle"))
     {
         cycle = new FloatCurve();
         cycle.Load(node.GetNode("cycle"));
     }
     else
         cycle = null;
 }
		public PartRecipe (ConfigNode recipe)
		{
			part_recipe = new Recipe (recipe);
			if (!part_recipe.HasIngredient ("structure")) {
				part_recipe.AddIngredient (new Ingredient ("structure", 5));
			}
			if (recipe.HasNode ("Resources")) {
				structure_recipe = new Recipe (recipe.GetNode ("Resources"));
			} else {
				structure_recipe = ExRecipeDatabase.default_structure_recipe;
			}
		}
 public void Load(ConfigNode node)
 {
     if (node.HasNode ("next")) {
         next = new AudioSequence ();
         next.Load(node.GetNode ("next"));
     }
     if (node.HasValue ("clip")) {
         clip = node.GetValue ("clip");
         Debug.Log ("AudioSequence"+clip);
         sound = GameDatabase.Instance.GetAudioClip (clip);
     }
 }
        public void Load(ConfigNode node)
        {
            double dtmp;

            if (node.HasValue("name"))
                name = node.GetValue("name");

            if (node.HasValue("entryCost"))
            {
                if (double.TryParse(node.GetValue("entryCost"), out dtmp))
                    entryCost = dtmp;
            }

            if (node.HasValue("maxSubtraction"))
                if (double.TryParse(node.GetValue("maxSubtraction"), out dtmp))
                    maxSubtraction = dtmp;

            if (node.HasNode("entryCostMultipliers"))
                LoadMultipliers(node.GetNode("entryCostMultipliers"));

            if (node.HasNode("entryCostSubtractors"))
                LoadSubtractors(node.GetNode("entryCostSubtractors"));
        }
Exemple #22
0
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     if ((object)ProgressTracking.Instance != null)
     {
         MethodInfo generate = ProgressTracking.Instance.GetType().GetMethod("generateAchievementsTree", BindingFlags.NonPublic | BindingFlags.Instance);
         ProgressTracking.Instance.achievementTree = (ProgressTree)(generate.Invoke(ProgressTracking.Instance, null));
         OnAwake();
         if (node.HasNode("Progress"))
         {
             ProgressTracking.Instance.achievementTree.Load(node.GetNode("Progress"));
         }
     }
 }
 public override void OnLoad(ConfigNode node)
 {
     try
     {
         if (!vessel.isEVA)
         {
             foreach (ProtoCrewMember crewmember in part.protoModuleCrew)
             {
                 if (!VanAllen.crew_rad_exposure.ContainsKey(crewmember.name))
                 {
                     if (node.HasNode("KERBAL_RADIATION_" + crewmember.name))
                     {
                         ConfigNode rad_node = node.GetNode("KERBAL_RADIATION_" + crewmember.name);
                         if (rad_node.HasValue("lifetimeDose"))
                             VanAllen.crew_rad_exposure.Add(crewmember.name, double.Parse(rad_node.GetValue("lifetimeDose")));
                     }
                 }
             }
         }
         else
         {
             if (!VanAllen.crew_rad_exposure.ContainsKey(vessel.vesselName))
             {
                 if (node.HasNode("KERBAL_RADIATION_" + vessel.vesselName))
                 {
                     ConfigNode rad_node = node.GetNode("KERBAL_RADIATION_" + vessel.vesselName);
                     if (rad_node.HasValue("lifetimeDose"))
                         VanAllen.crew_rad_exposure.Add(vessel.vesselName, double.Parse(rad_node.GetValue("lifetimeDose")));
                 }
             }
         }
     }
     catch (Exception ex)
     {
         UnityEngine.Debug.LogError("[KSPI] - InterstellarReactor.FNModuleRadiation exception: " + ex.Message);
     }
 }
        public static void SaveSettings(ConfigNode fileNode)
        {
            if(!fileNode.HasNode("BDAInputSettings"))
            {
                fileNode.AddNode("BDAInputSettings");
            }

            ConfigNode cfg = fileNode.GetNode("BDAInputSettings");

            FieldInfo[] fields = typeof(BDInputSettingsFields).GetFields();
            for(int i = 0; i < fields.Length; i++)
            {
                string fieldName = fields[i].Name;
                string valueString = ((BDInputInfo)fields[i].GetValue(null)).inputString;
                cfg.SetValue(fieldName, valueString, true);
            }
        }
Exemple #25
0
        public void Save(ConfigNode node)
        {
            ConfigNode settingsNode;
            if (node.HasNode(configNodeName))
            {
                settingsNode = node.GetNode(configNodeName);
            }
            else
            {
                settingsNode = node.AddNode(configNodeName);
            }

            foreach (var bioVessel in BioVessels)
            {
                ConfigNode vesselNode = bioVessel.Value.Save(settingsNode);
                vesselNode.AddValue("Guid", bioVessel.Key);
            }
        }
 public void Load(ConfigNode node)
 {
     if (node.HasNode("LIFE_SUPPORT_SETTINGS"))
     {
         SettingsNode = node.GetNode("LIFE_SUPPORT_SETTINGS");
         _StatusInfo = SetupStatusInfo();
         _VesselInfo = SetupVesselInfo();
         _Settings = SetupSettings();
         //Reset cache
         LifeSupportManager.Instance.ResetCache();
     }
     else
     {
         _StatusInfo = new List<LifeSupportStatus>();
         _VesselInfo = new List<VesselSupplyStatus>();
         _Settings = null;
     }
 }
Exemple #27
0
        public void Load(ConfigNode node)
        {
            if (node.HasNode(configNodeName))
            {
                ConfigNode settingsNode = node.GetNode(configNodeName);

                BioVessels.Clear();
                var vesselNodes = settingsNode.GetNodes(BioVessel.ConfigNodeName);
                foreach (ConfigNode vesselNode in vesselNodes)
                {
                    if (vesselNode.HasValue("Guid"))
                    {
                        Guid id = new Guid(vesselNode.GetValue("Guid"));
                        BioVessel bioVessel = BioVessel.Load(vesselNode);
                        BioVessels[id] = bioVessel;
                    }
                }
            }
        }
 public void Save(ConfigNode node)
 {
     ConfigNode TSTStockPlanetOrderNode;
     if (node.HasNode(configNodeName))
     {
         TSTStockPlanetOrderNode = node.GetNode(configNodeName);
         TSTStockPlanetOrderNode.ClearData();
     }
     else
     {
         TSTStockPlanetOrderNode = node.AddNode(configNodeName);
     }
     if (NHPlanetOrder.Length > 0)
     {
         string tmpPlanetOrder = string.Join(",", NHPlanetOrder);
         TSTStockPlanetOrderNode.AddValue("planets", tmpPlanetOrder);
     }
     Utilities.Log_Debug("TSTNHPlanetOrder save complete");
 }
 public void Load(ConfigNode node)
 {
     if (node.HasNode(configNodeName))
     {
         ConfigNode TSTStockPlanetOrderNode = new ConfigNode();
         node.TryGetNode(configNodeName, ref TSTStockPlanetOrderNode);
         string tmpPlanetOrderString = "";
         TSTStockPlanetOrderNode.TryGetValue("planets", ref tmpPlanetOrderString);
         string[] tmpPlanetOrder = tmpPlanetOrderString.Split(',');
         NHPlanetOrder = new string[tmpPlanetOrder.Length];
         if (tmpPlanetOrder.Length > 0)
         {
             for (int i = 0; i < tmpPlanetOrder.Length; i++)
             {
                 NHPlanetOrder[i] = tmpPlanetOrder[i];
             }
         }
     }
     Utilities.Log_Debug("TSTNHPlanetOrder load complete");
 }
        public static void LoadSettings(ConfigNode fileNode)
        {
            if(!fileNode.HasNode("BDAInputSettings"))
            {
                fileNode.AddNode("BDAInputSettings");
            }

            ConfigNode cfg = fileNode.GetNode("BDAInputSettings");

            FieldInfo[] fields = typeof(BDInputSettingsFields).GetFields();
            for(int i = 0; i < fields.Length; i++)
            {
                string fieldName = fields[i].Name;
                if(cfg.HasValue(fieldName))
                {
                    BDInputInfo orig = (BDInputInfo)fields[i].GetValue(null);
                    BDInputInfo loaded = new BDInputInfo(cfg.GetValue(fieldName), orig.description);
                    fields[i].SetValue(null, loaded);
                }
            }
        }