/*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 SSTUEngineLayout(ConfigNode node) { name = node.GetStringValue("name"); mountSizeMult = node.GetFloatValue("mountSizeMult", mountSizeMult); defaultUpperStageMount = node.GetStringValue("defaultUpperStageMount", defaultUpperStageMount); defaultLowerStageMount = node.GetStringValue("defaultLowerStageMount", defaultLowerStageMount); ConfigNode[] posNodes = node.GetNodes("POSITION"); int len = posNodes.Length; for (int i = 0; i < len; i++) { positions.Add(new SSTUEnginePosition(posNodes[i])); } ConfigNode[] mountNodes = node.GetNodes("MOUNT"); len = mountNodes.Length; List<SSTUEngineLayoutMountOption> mountOptionsList = new List<SSTUEngineLayoutMountOption>(); string mountName; ModelDefinition md; for (int i = 0; i < len; i++) { mountName = mountNodes[i].GetStringValue("name"); md = SSTUModelData.getModelDefinition(mountName); if (md != null) { mountOptionsList.Add(new SSTUEngineLayoutMountOption(mountNodes[i])); } else { MonoBehaviour.print("ERROR: Could not locate mount model data for name: " + mountName + " -- please check your configs for errors."); } } mountOptions = mountOptionsList.ToArray(); }
public override void OnLoad(ConfigNode node) { base.OnLoad(node); ConfigNode[] efficiencyNodes = node.GetNodes(kEfficiencyData); ConfigNode[] toolTipsShown = node.GetNodes(kToolTip); string value = node.GetValue("reputationIndex"); if (string.IsNullOrEmpty(value) == false) reputationIndex = int.Parse(value); foreach (ConfigNode efficiencyNode in efficiencyNodes) { EfficiencyData efficiencyData = new EfficiencyData(); efficiencyData.Load(efficiencyNode); efficiencyDataMap.Add(efficiencyData.Key, efficiencyData); } foreach (ConfigNode toolTipNode in toolTipsShown) { if (toolTipNode.HasValue("name") == false) continue; value = toolTipNode.GetValue("name"); if (toolTips.ContainsKey(value)) toolTips[value] = toolTipNode; else toolTips.Add(value, toolTipNode); } }
public override void OnLoad(ConfigNode node) { try { foreach (ConfigNode child in node.GetNodes("CONTRACT")) { ConfiguredContract contract = null; try { contract = new ConfiguredContract(); Contract.Load(contract, child); } catch (Exception e) { LoggingUtil.LogWarning(this, "Ignored an exception while trying to load a pre-loaded contract:"); LoggingUtil.LogException(e); } if (contract != null && contract.contractType != null) { contract.preLoaded = true; contracts.Add(contract); } } } catch (Exception e) { LoggingUtil.LogError(this, "Error loading ContractPreLoader from persistance file!"); LoggingUtil.LogException(e); ExceptionLogWindow.DisplayFatalException(ExceptionLogWindow.ExceptionSituation.SCENARIO_MODULE_LOAD, e, "ContractPreLoader"); } }
private void AddGrabModule(ConfigNode node) { foreach (ConfigNode grabNode in node.GetNodes("GRAB")) { // Check if the node has value if (!grabNode.HasValue("stockPartName")) { KAS_Shared.DebugWarning("AddGrabModule(AddModule) Missing stockPartName node !"); continue; } // Add and Retrieve the module string partName = grabNode.GetValue("stockPartName").Replace('_', '.'); AvailablePart aPart = PartLoader.getPartInfoByName(partName); if (aPart == null) { KAS_Shared.DebugError("AddModule(AddModule) - " + partName + " not found in partloader"); continue; } // get or add grab module KASModuleGrab grabModule = aPart.partPrefab.GetComponent<KASModuleGrab>(); if (grabModule) { KAS_Shared.DebugWarning("AddModule(AddModule) - KASModuleGrab already added to " + partName); } else { grabModule = aPart.partPrefab.AddModule("KASModuleGrab") as KASModuleGrab; if (!grabModule) { KAS_Shared.DebugError("AddGrabModule(AddModule) Error when adding module !"); continue; } } // Configure the module if (grabNode.HasValue("evaPartPos")) grabModule.evaPartPos = KAS_Shared.ParseCfgVector3(grabNode.GetValue("evaPartPos")); if (grabNode.HasValue("evaPartDir")) grabModule.evaPartDir = KAS_Shared.ParseCfgVector3(grabNode.GetValue("evaPartDir")); if (grabNode.HasValue("customGroundPos")) grabModule.customGroundPos = bool.Parse(grabNode.GetValue("customGroundPos")); if (grabNode.HasValue("dropPartPos")) grabModule.dropPartPos = KAS_Shared.ParseCfgVector3(grabNode.GetValue("dropPartPos")); if (grabNode.HasValue("dropPartRot")) grabModule.dropPartRot = KAS_Shared.ParseCfgVector3(grabNode.GetValue("dropPartRot")); if (grabNode.HasValue("physicJoint")) grabModule.physicJoint = bool.Parse(grabNode.GetValue("physicJoint")); if (grabNode.HasValue("addPartMass")) grabModule.addPartMass = bool.Parse(grabNode.GetValue("addPartMass")); if (grabNode.HasValue("storable")) grabModule.storable = bool.Parse(grabNode.GetValue("storable")); if (grabNode.HasValue("storedSize")) grabModule.storedSize = int.Parse(grabNode.GetValue("storedSize")); if (grabNode.HasValue("bayType")) grabModule.bayType = grabNode.GetValue("bayType").ToString(); if (grabNode.HasValue("bayNode")) grabModule.bayNode = grabNode.GetValue("bayNode").ToString(); if (grabNode.HasValue("bayRot")) grabModule.bayRot = KAS_Shared.ParseCfgVector3(grabNode.GetValue("bayRot")); if (grabNode.HasValue("grabSndPath")) grabModule.grabSndPath = grabNode.GetValue("grabSndPath").ToString(); if (grabNode.HasValue("attachMaxDist")) grabModule.attachMaxDist = float.Parse(grabNode.GetValue("attachMaxDist")); if (grabNode.HasValue("attachOnPart")) grabModule.attachOnPart = bool.Parse(grabNode.GetValue("attachOnPart")); if (grabNode.HasValue("attachOnEva")) grabModule.attachOnEva = bool.Parse(grabNode.GetValue("attachOnEva")); if (grabNode.HasValue("attachOnStatic")) grabModule.attachOnStatic = bool.Parse(grabNode.GetValue("attachOnStatic")); if (grabNode.HasValue("attachSendMsgOnly")) grabModule.attachSendMsgOnly = bool.Parse(grabNode.GetValue("attachSendMsgOnly")); if (grabNode.HasValue("attachPartSndPath")) grabModule.attachPartSndPath = grabNode.GetValue("attachPartSndPath").ToString(); if (grabNode.HasValue("attachStaticSndPath")) grabModule.attachStaticSndPath = grabNode.GetValue("attachStaticSndPath").ToString(); if (grabNode.HasValue("detachSndPath")) grabModule.detachSndPath = grabNode.GetValue("detachSndPath").ToString(); KAS_Shared.DebugLog("AddGrabModule(AddModule) Module successfully configured on " + partName); } }
public ConverterRecipe loadFromNode(ConfigNode node) { ConfigNode[] inputNodes = node.GetNodes("RECIPEINPUT"); ConfigNode[] outputNodes = node.GetNodes("RECIPEOUTPUT"); int len = inputNodes.Length; for (int i = 0; i < len; i++) { inputs.Add(new ConverterResourceEntry().loadFromNode(inputNodes[i])); } len = outputNodes.Length; for (int i = 0; i < len; i++) { outputs.Add(new ConverterResourceEntry().loadFromNode(outputNodes[i])); } return this; }
internal SelectVariable(ConfigNode node, RasterPropMonitorComputer rpmComp) { name = node.GetValue("name"); foreach (ConfigNode sourceVarNode in node.GetNodes("VARIABLE_DEFINITION")) { bool reverseVal; VariableOrNumberRange vonr = ProcessSourceNode(sourceVarNode, rpmComp, out reverseVal); sourceVariables.Add(vonr); reverse.Add(reverseVal); VariableOrNumber val = rpmComp.InstantiateVariableOrNumber(sourceVarNode.GetValue("value")); result.Add(val); } if (node.HasValue("defaultValue")) { VariableOrNumber val = rpmComp.InstantiateVariableOrNumber(node.GetValue("defaultValue")); result.Add(val); } else { throw new Exception(string.Format("Select variable {0} is missing its defaultValue", name)); } if (sourceVariables.Count == 0) { throw new ArgumentException("Did not find any VARIABLE_DEFINITION nodes in RPM_SELECT_VARIABLE", name); } }
public void OnLoad(ConfigNode configNode) { name = ConfigNodeUtil.ParseValue<string>(configNode, "name"); aspectRatio = ConfigNodeUtil.ParseValue<float>(configNode, "aspectRatio"); foreach (ConfigNode child in configNode.GetNodes()) { Type nodeType = ConfigNodeUtil.ParseTypeValue(child.name); if (nodeType.IsSubclassOf(typeof(CutSceneCamera))) { CutSceneCamera cameraDefinition = Activator.CreateInstance(nodeType) as CutSceneCamera; cameraDefinition.OnLoad(child); cameras.Add(cameraDefinition); } else if (nodeType.IsSubclassOf(typeof(Actor))) { Actor actor = Activator.CreateInstance(nodeType) as Actor; actor.OnLoad(child); actors.Add(actor); } else if (nodeType.IsSubclassOf(typeof(CutSceneAction))) { CutSceneAction action = Activator.CreateInstance(nodeType) as CutSceneAction; action.cutSceneDefinition = this; action.OnLoad(child); actions.Add(action); } else { LoggingUtil.LogError(this, "Couldn't load CutSceneDefinition - unknown type '" + child.name + "'."); } } }
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(); }
public FloatCurve ProcessNodeAsFloatCurve(ConfigNode node) { FloatCurve resultCurve = new FloatCurve(); ConfigNode[] moduleNodeArray = node.GetNodes(nodeName); debugMessage("ProcessNodeAsFloatCurve: moduleNodeArray.length " + moduleNodeArray.Length); for (int k = 0; k < moduleNodeArray.Length; k++) { debugMessage("found node"); string[] valueArray = moduleNodeArray[k].GetValues(valueName); debugMessage("found " + valueArray.Length + " values"); for (int l = 0; l < valueArray.Length; l++) { string[] splitString = valueArray[l].Split(' '); try { Vector2 v2 = new Vector2(float.Parse(splitString[0]), float.Parse(splitString[1])); resultCurve.Add(v2.x, v2.y, 0, 0); } catch { Debug.Log("Error parsing vector2"); } } } return resultCurve; }
public CustomVariable(ConfigNode node) { name = node.GetValue("name"); foreach (ConfigNode sourceVarNode in node.GetNodes("SOURCE_VARIABLE")) { SourceVariable sourceVar = new SourceVariable(sourceVarNode); sourceVariables.Add(sourceVar); } if(sourceVariables.Count == 0) { throw new ArgumentException("Did not find any SOURCE_VARIABLE nodes in RPM_CUSTOM_VARIABLE", name); } string oper = node.GetValue("operator"); if (oper == Operator.NONE.ToString()) { op = Operator.NONE; } else if (oper == Operator.AND.ToString()) { op = Operator.AND; } else if (oper == Operator.OR.ToString()) { op = Operator.OR; } else if (oper == Operator.XOR.ToString()) { op = Operator.XOR; } else { throw new ArgumentException("Found an invalid operator type in RPM_CUSTOM_VARIABLE", oper); } }
public BitmapFont(ConfigNode node, string nodeUrl) { id = node.GetValue("id"); name = node.GetValue("name"); displayName = node.GetValue("displayName"); size = int.Parse(node.GetValue("size")); UnityEngine.Texture2D texture = Utils.LoadTexture("GameData/" + nodeUrl + ".pngmap", false); characterMap = new Dictionary<char, BitmapChar>(); float h = 0; foreach(ConfigNode n in node.GetNodes("ASP_BITMAP_CHAR")) { BitmapChar cMap = new BitmapChar(n, texture); characterMap[cMap.character] = cMap; // vh is -ve if (cMap.vh < height) h = cMap.vh; } height = (int) Math.Abs(h); UnityEngine.Object.Destroy(texture); }
public void Load(ConfigNode node) { ConfigNode[] converterNodes = node.GetNodes("KolonyConverter"); KolonyConverter converter; if (converterNodes == null) { Log("converter nodes are null"); return; } //Clear the list of converters (if any) Clear(); //Go through all the nodes, create a new converter, and tell it to load its data. foreach (ConfigNode converterNode in converterNodes) { //Create the converter converter = (KolonyConverter)this.part.AddModule("KolonyConverter"); //Load its data from the node LoadFromNode(converter, converterNode); //Remove its gui elements? converter.ShowGUI(_showGUI); //Add to the list converters.Add(converter); } }
public DefaultBody(ConfigNode configNode, Random random) { configNode.TryGetValue("name", ref this.name); foreach (ConfigNode resourceNode in configNode.GetNodes("KRES_RESOURCE")) { this.resources.Add(new DefaultResource(resourceNode, random)); } }
public void Load(ConfigNode node) { foreach (ConfigNode pn in node.GetNodes("PROGRAM")) { Program prog = new Program(); prog.Load(pn); putProgram(prog); } }
protected override void OnLoad(ConfigNode node) { base.OnLoad(node); foreach (ConfigNode kerbalNode in node.GetNodes("KERBAL")) { kerbals.Add(Kerbal.Load(kerbalNode)); } }
public void Load(ConfigNode node) { ConfigNode[] nodes = node.GetNodes("Resource"); for (int i = 0; i < nodes.Length; ++i) { WingTankResource res = new WingTankResource(nodes[i]); resources.Add(res.resource.name, res); } }
public GeneratorConfiguration(ConfigNode node) { load(node); foreach (var bodyNode in node.GetNodes("Body")) { var body = (GeneratorConfiguration)this.MemberwiseClone(); body.load(bodyNode); bodies[bodyNode.GetValue("name")] = body; } }
// Compatible with ModuleDataTransmitter public override void OnLoad(ConfigNode node) { foreach (ConfigNode data in node.GetNodes("CommsData")) { scienceDataQueue.Add(new ScienceData(data)); } var antennas = part.FindModulesImplementing<ModuleRTAntenna>(); GUIStatus = "Idle"; }
public override void OnLoad(ConfigNode node) { base.OnLoad(node); foreach(ConfigNode dataNode in node.GetNodes("ScienceData")) { storedData.Add(new ScienceData(dataNode)); } updateMenu(); }
void CreateSwitchInfos(ConfigNode node) { var si_list = node.GetNodes ("SwitchInfo"); switch_infos = new List<SwitchInfo> (); foreach (var si_node in si_list) { var si = new SwitchInfo (part); si.Load (si_node); switch_infos.Add (si); } }
public override void OnLoad(ConfigNode node) { foreach (ConfigNode hdNode in node.GetNodes("harddisk")) { Harddisk newDisk = new Harddisk(hdNode); this.hardDisk = newDisk; } base.OnLoad(node); }
public override void OnLoad(ConfigNode node) { base.OnLoad(node); ConfigNode[] moduleNodes = node.GetNodes("WBIMODULE"); if (moduleNodes == null) return; //Save the module settings, we'll need these for later. foreach (ConfigNode moduleNode in moduleNodes) moduleSettings.Add(moduleNode); }
public ReactorFuelMode(ConfigNode node) { _reactor_type = Convert.ToInt32(node.GetValue("ReactorType")); _mode_gui_name = node.GetValue("GUIName"); _aneutronic = Boolean.Parse(node.GetValue("Aneutronic")); _normreactionrate = Double.Parse(node.GetValue("NormalisedReactionRate")); _normpowerrequirements = Double.Parse(node.GetValue("NormalisedPowerConsumption")); _charged_power_ratio = Double.Parse(node.GetValue("ChargedParticleRatio")); _mev_per_charged_product = node.HasValue("MeVPerChargedProduct") ? Double.Parse(node.GetValue("MeVPerChargedProduct")) : 0; ConfigNode[] fuel_nodes = node.GetNodes("FUEL"); _fuels = fuel_nodes.Select(nd => new ReactorFuel(nd)).ToList(); }
// Compatible with ModuleDataTransmitter public override void OnLoad(ConfigNode node) { foreach (ConfigNode data in node.GetNodes("CommsData")) { mQueue.Add(new ScienceData(data)); } var antennas = part.FindModulesImplementing<ModuleRTAntenna>(); mParent = antennas.Count > 0 ? antennas[0] : null; GUI_Status = "Idle"; }
public Harddisk(ConfigNode node) { Capacity = 10000; if (node.HasValue("capacity")) Capacity = int.Parse(node.GetValue("capacity")); if (node.HasValue("volumeName")) Name = node.GetValue("volumeName"); foreach (ConfigNode fileNode in node.GetNodes("file")) { Add(new ProgramFile(fileNode)); } }
public Filter(ConfigNode node) { checks = new List<Check>(); foreach (ConfigNode subNode in node.GetNodes("CHECK")) { checks.Add(new Check(subNode)); } bool tmp; bool.TryParse(node.GetValue("invert"), out tmp); invert = tmp; }
public static ShaderProperty[] parse(ConfigNode node) { ShaderProperty[] props; ConfigNode[] propNodes = node.GetNodes("PROPERTY"); int len = propNodes.Length; props = new ShaderProperty[len]; for (int i = 0; i < len; i++) { props[i] = new ShaderProperty(propNodes[i]); } return props; }
protected override void OnLoad(ConfigNode configNode) { foreach (ConfigNode child in configNode.GetNodes("CONDITION")) { ConditionDetail cd = new ConditionDetail(); cd.condition = ConfigNodeUtil.ParseValue<ConditionDetail.Condition>(child, "condition"); cd.parameter = ConfigNodeUtil.ParseValue<string>(child, "parameter", (string)null); cd.disabled = ConfigNodeUtil.ParseValue<bool>(child, "disabled"); conditions.Add(cd); } basename = ConfigNodeUtil.ParseValue<string>(configNode, "basename"); }
public MeshConfig(ConfigNode node, Part part) { variantName = node.GetValue("variantName"); if (variantName == null || variantName.Length == 0) { MonoBehaviour.print("ILLEGAL VARIANT NAME: " + variantName); } tankName = node.GetStringValue("tankName"); variantMass = (float)node.GetDoubleValue("variantMass"); variantCost = (float)node.GetDoubleValue("variantCost"); tankOption = node.GetStringValue("tankOption"); String meshNames = node.GetStringValue("meshNames"); if (String.IsNullOrEmpty(meshNames)) { meshData = new MeshData[0]; } else { String[] splitNames = meshNames.Split(','); meshData = new MeshData[splitNames.Length]; int len = splitNames.Length; for (int i = 0; i < len; i++) { meshData[i] = new MeshData(splitNames[i].Trim(), part); } } String configControlIDs = node.GetStringValue("controlIDs"); if (String.IsNullOrEmpty(configControlIDs)) { controlledModules = new int[0]; } else { String[] splitIDs = configControlIDs.Split(','); controlledModules = new int[splitIDs.Length]; for (int i = 0; i < splitIDs.Length; i++) { controlledModules[i] = SSTUUtils.safeParseInt(splitIDs[i].Trim()); } } ConfigNode[] nodeNodes = node.GetNodes("MESHNODE"); if (nodeNodes != null && nodeNodes.Length > 0) { nodeData = new MeshNodeData[nodeNodes.Length]; int len = nodeNodes.Length; for (int i = 0; i < len; i++) { nodeData[i] = new MeshNodeData(nodeNodes[i], part); } } else { nodeData = new MeshNodeData[0]; } }