コード例 #1
0
 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) { }
 }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: VesselWrappers.cs プロジェクト: pjslauta/hangar
 public override void Load(ConfigNode node)
 {
     ConfigNode metric_node = node.GetNode("METRIC");
     vessel_node = node.GetNode("VESSEL");
     metric = new Metric(metric_node);
     name   = node.GetValue("name");
     flag   = node.GetValue("flag");
     id     = new Guid(node.GetValue("id"));
 }
コード例 #4
0
		public void Load (ConfigNode node)
		{
			var req = node.GetNode ("Required");
			foreach (var r in req.GetNodes ("BuildResrouce")) {
				var res = new BuildResource ();
				res.Load (r);
				required.Add (res);
			}
			var opt = node.GetNode ("Optional");
			foreach (var r in opt.GetNodes ("BuildResrouce")) {
				var res = new BuildResource ();
				res.Load (r);
				optional.Add (res);
			}
		}
コード例 #5
0
        //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 {

              }
        }
コード例 #6
0
ファイル: KIS_Item.cs プロジェクト: Kerbas-ad-astra/KIS
 /// <summary>Creates a new part from save.</summary>
 public KIS_Item(AvailablePart availablePart, ConfigNode itemNode, ModuleKISInventory inventory,
           float quantity = 1)
 {
     // Get part node
     this.availablePart = availablePart;
     partNode = new ConfigNode();
     itemNode.GetNode("PART").CopyTo(partNode);
     // init config
     this.InitConfig(availablePart, inventory, quantity);
     // Get mass
     if (itemNode.HasValue("resourceMass")) {
       resourceMass = float.Parse(itemNode.GetValue("resourceMass"));
     } else {
       resourceMass = availablePart.partPrefab.GetResourceMass();
     }
     if (itemNode.HasValue("contentMass")) {
       contentMass = float.Parse(itemNode.GetValue("contentMass"));
     }
     if (itemNode.HasValue("contentCost")) {
       contentCost = float.Parse(itemNode.GetValue("contentCost"));
     }
     if (itemNode.HasValue("inventoryName")) {
       inventoryName = itemNode.GetValue("inventoryName");
     }
 }
コード例 #7
0
ファイル: GameSettings.cs プロジェクト: KSP-RO/TacLifeSupport
        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;
                    }
                }
            }
        }
コード例 #8
0
        protected override void OnLoad(ConfigNode configNode)
        {
            base.OnLoad(configNode);

            cutSceneDefinition = new CutSceneDefinition();
            cutSceneDefinition.OnLoad(configNode.GetNode("CUTSCENE_DEFINITION"));
        }
コード例 #9
0
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     //get settings node and kerbal node
     try
     {
         ConfigNode DataNode = node.GetNode("TerminusData");
         if (DataNode != null)
         {
             ConfigNode TLS_Kerbals = DataNode.GetNode("TLS_Kerbals");
             if (TLS_Kerbals != null)
             {
                 Terminus_Life_Support.TrackedKerbals.Clear();
                 foreach (ConfigNode kiNode in TLS_Kerbals.GetNodes("KerbalInfo"))
                 {
                     KerbalInfo ki = new KerbalInfo();
                     ki.FromConfigNode(kiNode);
                     if (ki.Name != "")
                         Terminus_Life_Support.TrackedKerbals.Add(ki);
                 }
                 Terminus_Life_Support.UpdateKerbalList(true);
             }
         }
     }
     catch (Exception e)
     {
         UnityEngine.Debug.LogException(e);
     }
 }
コード例 #10
0
ファイル: DataManager.cs プロジェクト: CYBUTEK/KRES
        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;
            }
        }
        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));
        }
コード例 #12
0
        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);
        }
コード例 #13
0
 internal static ConfigNode getFilePaths()
 {
     if (FilePaths==null)
     {
         if (RRSettings == null)
         {
             if (RRSettingsController.load())
             {
                 RRSettings = root.GetNode("RRSettings");
                 FilePaths = RRSettings.GetNode("FilePaths");
                 return FilePaths;
             }
             else
             {
                 return null;
             }
         }
         else
         {
             FilePaths = RRSettings.GetNode("FilePaths");
             return FilePaths;
         }
     }
     else
     {
         return FilePaths;
     }
 }
コード例 #14
0
ファイル: Chapter.cs プロジェクト: madguy/KerbalStory
        public Chapter(ConfigNode configNode)
        {
            this.Id = configNode.GetValue("id");

            var instructor = configNode.GetNode("INSTRACTOR");
            this.InstructorName = instructor.GetValue("name");
            this.InstractorType = instructor.GetValue("type");

            this.Title = configNode.GetValue("title");
            this.Story = configNode.GetValue("story").Replace("\\n", "\n");

            this.Difficulty = configNode.GetValue("difficulty").ToEnum<Contract.ContractPrestige>();
            this.Science = Int32.Parse(configNode.GetValue("science"));
            this.Reputation = Int32.Parse(configNode.GetValue("reputation"));
            var funds = configNode.GetValue("funds").Split(',');
            this.AdvanceFunds = Int32.Parse(funds[0]);
            this.CompletionFunds = Int32.Parse(funds[1]);
            this.FailureFunds = Int32.Parse(funds[2]);

            this.ContractParameters = configNode.GetNodes("PARAM").Select(node => {
                var paramName = node.GetValue("name");
                var parameterType = ContractSystem.GetParameterType(paramName);
                var contractParameter = (ContractParameter)Activator.CreateInstance(parameterType);
                contractParameter.Load(node);
                return contractParameter;
            }).ToList();
        }
コード例 #15
0
        protected override void OnLoad(ConfigNode node)
        {
            Debug.Log("CurrencyOperationRandomized.OnLoad");
            base.OnLoad(node);

            initialSetupDone = true;
            valueCache.Load(node.GetNode("VALUES"));
        }
コード例 #16
0
ファイル: KISAddonConfig.cs プロジェクト: Kerbas-ad-astra/KIS
 void SetInventoryConfig(Component moduleInventory, ConfigNode nodeSettings)
 {
     var nodeEvaInventory = nodeSettings.GetNode("EvaInventory");
     if (nodeEvaInventory != null) {
       var baseFields = new BaseFieldList(moduleInventory);
       baseFields.Load(nodeEvaInventory);
     }
 }
        public override void OnLoad(ConfigNode config)
        {
            var timer = System.Diagnostics.Stopwatch.StartNew();
            string persistentfile = KSPUtil.ApplicationRootPath + "saves/" + HighLogic.SaveFolder + "/persistent.sfs";
            ConfigNode oldConfig = ConfigNode.Load(persistentfile);
            ConfigNode gameconf = config.GetNode("GAME");
            ConfigNode Scenario = gameconf.GetNode("SCENARIO");

            UnityEngine.Debug.Log("RecourceRecoveryData OnLoad running 1 config=" + config);
            /*
            UnityEngine.Debug.Log("RecourceRecoveryData OnLoad running 2" );
            string currentPlanet = "Kerbin";
            UnityEngine.Debug.Log("RecourceRecoveryData OnLoad running 3" );
            if (!config.HasValue("Version") && (config.CountNodes < 1))
            {
                UnityEngine.Debug.Log("RecourceRecoveryData OnLoad running 4");
                //config.AddValue("Version", System.Diagnostics.FileVersionInfo.GetVersionInfo(Application.ResourceAssembly.Location).ProductVersion);

                //config.AddValue("Version", GetInformationalVersion(Windows.Application.ResourceAssembly));

                //config = new ConfigNode();

                planetNode = config.AddNode(currentPlanet);
                UnityEngine.Debug.Log("RecourceRecoveryData OnLoad running 5");
                planetNode = config.GetNode(currentPlanet);
                UnityEngine.Debug.Log("RecourceRecoveryData OnLoad running 6");
                planetNode.AddValue("name", currentPlanet);
                planetNode.AddValue("total_locations", "ToDo");
                planetNode.AddValue("total_number_recource_tanks", "ToDo");
                planetNode.AddValue("total_capacity", "ToDo");
                planetNode.AddValue("total_capacity_used","ToDo");
                UnityEngine.Debug.Log("RecourceRecoveryData OnLoad running 7");

                LocationsNode = planetNode.AddNode("LOCATIONS");
                UnityEngine.Debug.Log("RecourceRecoveryData OnLoad running 8");
                LocationsNode = config.GetNode("LOCATIONS");
                UnityEngine.Debug.Log("RecourceRecoveryData OnLoad running 9");

                ConfigNode storageNode = planetNode.AddNode("STORAGE");
                UnityEngine.Debug.Log("RecourceRecoveryData OnLoad running 10");
                storageNode = planetNode.GetNode("STORAGE");
                UnityEngine.Debug.Log("RecourceRecoveryData OnLoad running 11");
                storageNode.AddValue("capacity", "ToDo");
                UnityEngine.Debug.Log("RecourceRecoveryData OnLoad running 12");
                storageNode.AddValue("modulecount", "ToDo");
                UnityEngine.Debug.Log("RecourceRecoveryData OnLoad running 13");

            }

            //planetNode = config.GetNode(currentPlanet);

            UnityEngine.Debug.Log("RecourceRecoveryData OnLoad running 14");
            */
            timer.Stop();
            UnityEngine.Debug.Log("RecourceRecoveryData OnLoad running 15");
            UnityEngine.Debug.Log(String.Format("RecourceRecoveryData loaded ({0}ms)", timer.ElapsedMilliseconds));
            UnityEngine.Debug.Log("RecourceRecoveryData OnLoad running 16 config=" + config);
        }
コード例 #18
0
 public override void OnLoad(ConfigNode node)
 {
     if (node.HasNode("ScienceData"))
     {
         ConfigNode storedDataNode = node.GetNode("ScienceData");
         ImpactScienceData data = new ImpactScienceData(storedDataNode);
         result=data;
     }
 }
コード例 #19
0
 ConfigNode GetResources(ConfigNode node, string recipe_name)
 {
     var resources = node.GetNode ("Resources");
     if (resources == null) {
         //print ("[EL Recipes] skipping " + recipe_name + " "
         //	   + name + " with no Resources");
     }
     return resources;
 }
コード例 #20
0
		public override void OnLoad(ConfigNode node)
		{
			BeanCounter.LogFormatted_DebugOnly("Loading scenario node from persistence file");
			
			base.OnLoad(node);

            ConfigNode CN = node.GetNode(data.GetType().Name);
            if (CN != null)
                ConfigNode.LoadObjectFromConfig(data, CN);
		}
 protected override void OnLoad(ConfigNode node)
 {
     int bodyID = int.Parse(node.GetValue(KEESExperimentContract.TARGET_BODY));
     foreach (var body in FlightGlobals.Bodies)
     {
         if (body.flightGlobalsIndex == bodyID)
             targetBody = body;
     }
     experiment = ExperimentData.getExperimentDataFromNode(node.GetNode(ExperimentData.CONFIG_NODE_NAME));
 }
コード例 #22
0
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     var dataContainerNode = node.GetNode("CONTAINER");
     if (dataContainerNode != null)
     {
         AddDefaultSectionData(); // This adds support for adding more recently installed mod data into a section
         dataContainer.OnLoad(dataContainerNode);
     }
 }
コード例 #23
0
 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"));
     }
 }
コード例 #24
0
        public ResourceDefinition(ConfigNode node)
        {
            Resource = node.GetValue("Resource");
            var colorFull = node.GetValue("ColorFull");
            ColorFull = colorFull != null ? ConfigNode.ParseColor(colorFull) : Color.white;
            var colorEmpty = node.GetValue("ColorEmpty");
            ColorEmpty = colorEmpty != null ? ConfigNode.ParseColor(colorEmpty) : Color.white;

            Generator = node.GetNode("Generator") ?? new ConfigNode();
        }
コード例 #25
0
        public override void OnLoad(ConfigNode node)
        {
            Debug.Log("[KCT] Reading from persistence.");
            base.OnLoad(node);
            KCT_DataStorage kctVS = new KCT_DataStorage();
            KCT_BuildListStorage bls = new KCT_BuildListStorage();
            KCT_TechStorage tS = new KCT_TechStorage();
            ConfigNode CN = node.GetNode(kctVS.GetType().Name);
            if (CN != null)
                ConfigNode.LoadObjectFromConfig(kctVS, CN);

            CN = node.GetNode(bls.GetType().Name);
            if (CN != null)
                ConfigNode.LoadObjectFromConfig(bls, CN);

            CN = node.GetNode(tS.GetType().Name);
            if (CN != null)
                ConfigNode.LoadObjectFromConfig(tS, CN);

            for (int i = 0; i < KCT_GameStates.VABList.Count; i++)
            {
                KCT_GameStates.VABList[i].shipNode = node.GetNode("VAB" + i);
            }
            for (int i = 0; i < KCT_GameStates.SPHList.Count; i++)
            {
                KCT_GameStates.SPHList[i].shipNode = node.GetNode("SPH" + i);
            }
            for (int i = 0; i < KCT_GameStates.VABWarehouse.Count; i++)
            {
                KCT_GameStates.VABWarehouse[i].shipNode = node.GetNode("VABWH" + i);
            }
            for (int i = 0; i < KCT_GameStates.SPHWarehouse.Count; i++)
            {
                KCT_GameStates.SPHWarehouse[i].shipNode = node.GetNode("SPHWH" + i);
            }
            for (int i = 0; i < KCT_GameStates.TechList.Count; i++)
            {
                KCT_GameStates.TechList[i].protoNode = new ProtoTechNode(node.GetNode("Tech" + i));
            }

            KCT_GameStates.delayStart = true;
        }
コード例 #26
0
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     if (node.HasNode("cycle"))
     {
         cycle = new FloatCurve();
         cycle.Load(node.GetNode("cycle"));
     }
     else
         cycle = null;
 }
コード例 #27
0
 public ElectricEnginePropellant(ConfigNode node) {
     propellantname = node.GetValue("name");
     propellantguiname = node.GetValue("guiName");
     ispMultiplier = Convert.ToDouble(node.GetValue("ispMultiplier"));
     efficiency = Convert.ToDouble(node.GetValue("efficiency"));
     prop_type = Convert.ToInt32(node.GetValue("type"));
     effectname = node.GetValue("effectName");
     ConfigNode propellantnode = node.GetNode("PROPELLANT");
     propellant = new Propellant();
     propellant.Load(propellantnode);
 }
コード例 #28
0
ファイル: Manager.cs プロジェクト: SirDiazo/VesselModuleSave
 //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
 }
コード例 #29
0
		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;
			}
		}
コード例 #30
0
		public override void OnLoad (ConfigNode config)
		{
			var settings = config.GetNode ("Settings");
			if (settings == null) {
				settings = new ConfigNode ("Settings");
				if (HighLogic.LoadedScene == GameScenes.SPACECENTER) {
					enabled = true;
				}
			}
			//XXX fill in with config node stuff to load settings using the
			// settings config node
		}