Example #1
0
 //to be called on initial prefab part load; populate the instance with the default values from the input node
 public virtual void load(ConfigNode node, GameObject root)
 {
     fairingBase = new FairingContainer(root, cylinderSides, numOfSections, wallThickness);
     uvMapName = node.GetStringValue("uvMap", uvMapName);
     UVMap uvMap = UVMap.GetUVMapGlobal(uvMapName);
     fairingBase.outsideUV = uvMap.getArea("outside");
     fairingBase.insideUV = uvMap.getArea("inside");
     fairingBase.edgesUV = uvMap.getArea("edges");
     rotationOffset = node.GetVector3("rotationOffset", Vector3.zero);
     topY = node.GetFloatValue("topY", topY);
     bottomY = node.GetFloatValue("bottomY", bottomY);
     capSize = node.GetFloatValue("capSize", capSize);
     wallThickness = node.GetFloatValue("wallThickness", wallThickness);
     maxPanelHeight = node.GetFloatValue("maxPanelHeight", maxPanelHeight);
     cylinderSides = node.GetIntValue("cylinderSides", cylinderSides);
     numOfSections = node.GetIntValue("numOfSections", numOfSections);
     topRadius = node.GetFloatValue("topRadius", topRadius);
     bottomRadius = node.GetFloatValue("bottomRadius", bottomRadius);
     canAdjustTop = node.GetBoolValue("canAdjustTop", canAdjustTop);
     canAdjustBottom = node.GetBoolValue("canAdjustBottom", canAdjustBottom);
     removeMass = node.GetBoolValue("removeMass", removeMass);
     fairingJettisonMass = node.GetFloatValue("fairingJettisonMass", fairingJettisonMass);
     jettisonForce = node.GetFloatValue("jettisonForce", jettisonForce);
     jettisonDirection = node.GetVector3("jettisonDirection", jettisonDirection);
     fairingName = node.GetStringValue("name", fairingName);
 }
 public SRBModelData(ConfigNode node)
     : base(node)
 {
     minThrust = node.GetFloatValue("minThrust");
     maxThrust = node.GetFloatValue("maxThrust");
     engineConfig = node.GetStringValue("engineConfig");
 }
Example #3
0
 public SRBNozzleData(ConfigNode node)
     : base(node)
 {
     thrustTransformName = node.GetStringValue("thrustTransformName");
     gimbalTransformName = node.GetStringValue("gimbalTransformName");
     gimbalAdjustmentRange = node.GetFloatValue("gimbalAdjustRange", 0);
     gimbalFlightRange = node.GetFloatValue("gimbalFlightRange", 0);
 }
 public HeatShieldType(ConfigNode node)
 {
     name = node.GetStringValue("name");
     heatCurve = node.GetFloatCurve("heatCurve");
     resourceMult = node.GetFloatValue("resourceMult", resourceMult);
     ablationMult = node.GetFloatValue("ablationMult", ablationMult);
     massMult = node.GetFloatValue("massMult", massMult);
 }
Example #5
0
 public FuelTypeData(ConfigNode node)
 {
     name = node.GetStringValue("name");
     fuelType = FuelTypes.INSTANCE.getFuelType(name);
     if (fuelType == null) { throw new NullReferenceException("Fuel type was null for fuel name: " + name); }
     tankageVolumeLoss = node.GetFloatValue("tankageVolumeLoss", fuelType.tankageVolumeLoss);
     tankageMassFraction = node.GetFloatValue("tankageMassFraction", fuelType.tankageMassFactor);
     costPerDryTon = node.GetFloatValue("costPerDryTon", fuelType.costPerDryTon);
 }
Example #6
0
 public ModelData(ConfigNode node)
 {
     name = node.GetStringValue("name");
     modelDefinition = SSTUModelData.getModelDefinition(name);
     if (modelDefinition==null)
     {
         MonoBehaviour.print("ERROR: Could not locate model data for name: " + name);
     }
     minVerticalScale = node.GetFloatValue("minVerticalScale", 1f);
     maxVerticalScale = node.GetFloatValue("maxVerticalScale", 1f);
 }
Example #7
0
 public EngineMount(ConfigNode node)
 {
     name = node.GetStringValue("name");
     layoutNames = node.GetValues("layoutName");
     defaultDiameter = node.GetFloatValue("size", defaultDiameter);
     minDiameter = node.GetFloatValue("minSize", minDiameter);
     maxDiameter = node.GetFloatValue("maxSize", maxDiameter);
     engineSpacing = node.GetFloatValue("engineSpacing", engineSpacing);
     canAdjustSize = node.GetBoolValue("canAdjustSize", canAdjustSize);
     rotateEngineModels = node.GetBoolValues("rotateEngines");
     mountDefinition = SSTUEngineMountDefinition.getMountDefinition(name);
 }
        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();
        }
Example #9
0
 public SSTUFuelType(ConfigNode node)
 {
     name = node.GetStringValue("name");
     tankageVolumeLoss = node.GetFloatValue("tankageVolumeLoss");
     tankageMassFactor = node.GetFloatValue("tankageMassFactor", 1);
     costPerDryTon = node.GetFloatValue("costPerDryTon");
     ConfigNode[] fuelConfigs = node.GetNodes("RESOURCE");
     SSTUFuelEntry e = null;
     foreach(ConfigNode n in fuelConfigs)
     {
         e = new SSTUFuelEntry(n);
         fuelEntries.Add(e);
         litersPerUnit += SSTUFuelTypes.INSTANCE.getResourceVolume(e.resourceName) * e.ratio;
         costPerUnit += PartResourceLibrary.Instance.GetDefinition(e.resourceName).unitCost * e.ratio;
     }
     unitsPerCubicMeter = 1000f / litersPerUnit;
     MonoBehaviour.print("Loaded SSTU_FUEL TYPE: "+name+"  units/m3: "+unitsPerCubicMeter+"  costPerUnit: "+costPerUnit +"  costPerM3: "+(unitsPerCubicMeter*costPerUnit));
 }
Example #10
0
        public LightType type; //read

        #endregion Fields

        #region Constructors

        public LightData(ConfigNode node, Part part)
        {
            name = node.GetStringValue("name");
            intensity = node.GetFloatValue("intensity");
            range = node.GetFloatValue("range");
            angle = node.GetFloatValue("angle");
            type = (LightType)Enum.Parse(typeof(LightType), node.GetStringValue("type", LightType.Point.ToString()));

            transform = part.transform.FindRecursive(name);
            light = transform.GetComponent<Light>();
            if (light == null)
            {
                light = transform.gameObject.AddComponent<Light>();//add it if it does not exist
            }

            light.intensity = intensity;
            light.range = range;
            light.spotAngle = angle;
            light.type = type;
        }
Example #11
0
 public FuelType(ConfigNode node)
 {
     name = node.GetStringValue("name");
     tankageVolumeLoss = node.GetFloatValue("tankageVolumeLoss", 0.15f);
     tankageMassFactor = node.GetFloatValue("tankageMassFactor", 0.15f);
     costPerDryTon = node.GetFloatValue("costPerDryTon");
     ConfigNode[] fuelConfigs = node.GetNodes("RESOURCE");
     SSTUFuelEntry e = null;
     PartResourceDefinition def;
     float massPerUnit = 0;
     foreach (ConfigNode n in fuelConfigs)
     {
         e = new SSTUFuelEntry(n);
         fuelEntries.Add(e);
         litersPerUnit += FuelTypes.INSTANCE.getResourceVolume(e.resourceName) * e.ratio;
         def = PartResourceLibrary.Instance.GetDefinition(e.resourceName);
         costPerUnit += def.unitCost * e.ratio;
         massPerUnit += def.density * e.ratio;
     }
     unitsPerCubicMeter = 1000f / litersPerUnit;
     tonsPerCubicMeter = massPerUnit * unitsPerCubicMeter;
 }
 public ShaderProperty(ConfigNode node)
 {
     name = node.GetStringValue("name");
     if (node.HasValue("float"))
     {
         fVal = true;
         floatVal = node.GetFloatValue("float");
     }
     else
     {
         fVal = false;
         colorVal = node.getColor("color");
     }
 }
Example #13
0
 public ModelData(ConfigNode node)
 {
     name = node.GetStringValue("name", String.Empty);
     modelName = node.GetStringValue("modelName", String.Empty);
     techLimit = node.GetStringValue("techLimit", techLimit);
     height = node.GetFloatValue("height", height);
     volume = node.GetFloatValue("volume", volume);
     mass = node.GetFloatValue("mass", mass);
     cost = node.GetFloatValue("cost", cost);
     diameter = node.GetFloatValue("diameter", diameter);
     verticalOffset = node.GetFloatValue("verticalOffset", verticalOffset);
     invertModel = node.GetBoolValue("invertModel", invertModel);
 }
 public SolarData(ConfigNode node)
 {
     name = node.GetStringValue("name");
     modelName = node.GetStringValue("modelName", name);
     upgradeName = node.GetStringValue("upgrade");
     def = SSTUModelData.getModelDefinition(modelName);
     ConfigNode solarNode = def.configNode.GetNode("SOLARDATA");
     animationName = solarNode.GetStringValue("animationName");
     pivotNames = solarNode.GetStringValue("pivotNames");
     secPivotNames = solarNode.GetStringValue("secPivotNames");
     sunNames = solarNode.GetStringValue("sunNames");
     energy = solarNode.GetFloatValue("energy");
     panelsEnabled = solarNode.GetBoolValue("enabled");
     sunAxis = solarNode.GetStringValue("sunAxis", SSTUSolarPanelDeployable.Axis.ZPlus.ToString());
     energy = node.GetFloatValue("energy", energy);//allow local override of energy
     ConfigNode[] posNodes = node.GetNodes("POSITION");
     int len = posNodes.Length;
     positions = new SolarPosition[len];
     for (int i = 0; i < len; i++)
     {
         positions[i] = new SolarPosition(posNodes[i]);
     }
 }
 public SSTUCustomUpperStageIntertank(ConfigNode node) : base(node)
 {
     ratio = node.GetFloatValue("ratio", ratio);
     fairingOffset = node.GetFloatValue("fairingOffset", fairingOffset);
 }
 public SSTUCustomUpperStageTopCap(ConfigNode node) : base(node)
 {
     fairingOffset = node.GetFloatValue("fairingOffset", fairingOffset);
 }
Example #17
0
 public TechLimitHeightDiameter(ConfigNode node) : base(node)
 {
     maxDiameter = node.GetFloatValue("maxDiameter");
     maxHeight = node.GetFloatValue("maxHeight");
 }
Example #18
0
        public SSTUEngineMountDefinition(ConfigNode node)
        {
            mountName = node.GetStringValue("name");
            modelName = node.GetStringValue("modelName");
            invertModel = node.GetBoolValue("invertModel", invertModel);
            singleModel = node.GetBoolValue("singleModel", singleModel);
            verticalOffset = node.GetFloatValue("verticalOffset");
            height = node.GetFloatValue("height", height);
            fairingDisabled = node.GetBoolValue("fairingDisabled", fairingDisabled);
            fairingTopOffset = node.GetFloatValue("fairingTopOffset");
            mountMass = node.GetFloatValue("mass", mountMass);
            defaultDiameter = node.GetFloatValue("defaultDiameter", defaultDiameter);
            volume = node.GetFloatValue("volume", volume);
            rcsVerticalPosition = node.GetFloatValue("rcsVerticalPosition", rcsVerticalPosition);
            rcsHorizontalPosition = node.GetFloatValue("rcsHorizontalPosition", rcsHorizontalPosition);
            rcsVerticalRotation = node.GetFloatValue("rcsVerticalRotation");
            rcsHorizontalRotation = node.GetFloatValue("rcsHorizontalRotation");

            if (node.HasValue("node"))
            {
                String[] vals = node.GetStringValues("node");
                foreach (String val in vals) { nodePositions.Add(new AttachNodeData(val)); }
                if (invertModel) { foreach (AttachNodeData data in nodePositions) { data.invert(); } }
            }
        }
Example #19
0
        public ModelDefinition(ConfigNode node)
        {
            name = node.GetStringValue("name", String.Empty);
            modelName = node.GetStringValue("modelName", String.Empty);
            techLimit = node.GetStringValue("techLimit", techLimit);
            height = node.GetFloatValue("height", height);
            volume = node.GetFloatValue("volume", volume);
            mass = node.GetFloatValue("mass", mass);
            cost = node.GetFloatValue("cost", cost);
            diameter = node.GetFloatValue("diameter", diameter);
            verticalOffset = node.GetFloatValue("verticalOffset", verticalOffset);
            invertForTop = node.GetBoolValue("invertForTop", invertForTop);
            invertForBottom = node.GetBoolValue("invertForBottom", invertForBottom);

            fairingDisabled = node.GetBoolValue("fairingDisabled", fairingDisabled);
            fairingTopOffset = node.GetFloatValue("fairingTopOffset");
            rcsVerticalPosition = node.GetFloatValue("rcsVerticalPosition", rcsVerticalPosition);
            rcsHorizontalPosition = node.GetFloatValue("rcsHorizontalPosition", rcsHorizontalPosition);
            rcsVerticalRotation = node.GetFloatValue("rcsVerticalRotation", rcsVerticalRotation);
            rcsHorizontalRotation = node.GetFloatValue("rcsHorizontalRotation", rcsHorizontalRotation);

            defaultTextureSet = node.GetStringValue("defaultTextureSet");

            String[] attachNodeStrings = node.GetValues("node");
            int len = attachNodeStrings.Length;
            attachNodeData = new AttachNodeBaseData[len];
            for (int i = 0; i < len; i++)
            {
                attachNodeData[i] = new AttachNodeBaseData(attachNodeStrings[i]);
            }

            ConfigNode[] textureSetNodes = node.GetNodes("TEXTURESET");
            len = textureSetNodes.Length;
            textureSets = new ModelTextureSet[len];
            for (int i = 0; i < len; i++)
            {
                textureSets[i] = new ModelTextureSet(textureSetNodes[i]);
            }
            if (node.HasValue("surface"))
            {
                surfaceNode = new AttachNodeBaseData(node.GetStringValue("surface"));
            }
            else
            {
                String val = (diameter*0.5f) + ",0,0,1,0,0,2";
                surfaceNode = new AttachNodeBaseData(val);
            }
        }
Example #20
0
 public SingleModelData(ConfigNode node) : base(node)
 {
     name = node.GetStringValue("name", String.Empty);
     modelName = node.GetStringValue("modelName", String.Empty);
     height = node.GetFloatValue("height", height);
     volume = node.GetFloatValue("volume", volume);
     diameter = node.GetFloatValue("diameter", diameter);
     verticalOffset = node.GetFloatValue("verticalOffset", verticalOffset);
     invertModel = node.GetBoolValue("invertModel", invertModel);
 }
        public EngineClusterLayoutData(SSTUEngineLayout layoutData, ConfigNode node, float engineScale, float moduleEngineSpacing, float moduleMountSize, float increment, bool upperMounts, bool lowerMounts)
        {
            this.engineScale = engineScale;
            this.layoutData = layoutData;
            layoutName = layoutData.name;

            defaultMount = lowerMounts? layoutData.defaultLowerStageMount : layoutData.defaultUpperStageMount;
            engineSpacing = moduleEngineSpacing;

            Dictionary<String, ConfigNode> localMountNodes = new Dictionary<String, ConfigNode>();
            Dictionary<String, SSTUEngineLayoutMountOption> globalMountOptions = new Dictionary<String, SSTUEngineLayoutMountOption>();
            List<ConfigNode> customMounts = new List<ConfigNode>();

            String name;
            ConfigNode mountNode;

            SSTUEngineLayoutMountOption mountOption;
            int len = layoutData.mountOptions.Length;
            for (int i = 0; i < len; i++)
            {
                mountOption = layoutData.mountOptions[i];
                if ((mountOption.upperStage && upperMounts) || (mountOption.lowerStage && lowerMounts))
                {
                    globalMountOptions.Add(mountOption.mountName, mountOption);
                }
            }

            if (node != null)
            {
                //override data from the config node
                defaultMount = node.GetStringValue("defaultMount", defaultMount);
                engineSpacing = node.GetFloatValue("engineSpacing", engineSpacing);
                engineRotationOverride = node.GetFloatValuesCSV("rotateEngines", engineRotationOverride);
                ConfigNode[] mountNodes = node.GetNodes("MOUNT");
                len = mountNodes.Length;
                for (int i = 0; i < len; i++)
                {
                    mountNode = mountNodes[i];
                    name = mountNode.GetStringValue("name");
                    if (mountNode.GetBoolValue("remove", false))
                    {
                        globalMountOptions.Remove(name);
                    }
                    else
                    {
                        if (!globalMountOptions.ContainsKey(name))
                        {
                            customMounts.Add(mountNode);
                        }
                        localMountNodes.Add(name, mountNode);
                    }
                }
            }

            engineSpacing = engineSpacing * engineScale;//pre-scale the engine spacing by the engine scale value; needed for engine positioning and mount-size calculation
            moduleMountSize = moduleMountSize * engineScale;//pre-scale the mount size by the engine scale value; needed for mount-size calculation
            List<EngineClusterLayoutMountData> mountDataTemp = new List<EngineClusterLayoutMountData>();
            foreach(String key in globalMountOptions.Keys)
            {
                if (localMountNodes.ContainsKey(key))//was specified in the config and was not a simple removal; merge values into global node...
                {
                    mountNode = mergeNodes(getAutoSizeNode(globalMountOptions[key], engineSpacing, moduleMountSize, increment), localMountNodes[key]);
                }
                else
                {
                    mountNode = getAutoSizeNode(globalMountOptions[key], engineSpacing, moduleMountSize, increment);
                }
                mountDataTemp.Add(new EngineClusterLayoutMountData(mountNode));
            }
            foreach (ConfigNode cm in customMounts)
            {
                mountDataTemp.Add(new EngineClusterLayoutMountData(cm));
            }
            mountData = mountDataTemp.ToArray();
        }
        /// <summary>
        /// Merges global and local config nodes for an engine layout<para/>
        /// Local node values have priority if they are present; any non-specified local values are defaulted
        /// to the global value
        /// </summary>
        /// <param name="global"></param>
        /// <param name="local"></param>
        /// <returns></returns>
        private ConfigNode mergeNodes(ConfigNode global, ConfigNode local)
        {
            ConfigNode output = new ConfigNode("MOUNT");
            global.CopyTo(output);
            if (local.HasValue("canAdjustSize"))
            {
                output.RemoveValues("canAdjustSize");
                output.AddValue("canAdjustSize", local.GetBoolValue("canAdjustSize"));
            }
            if (local.HasValue("size"))
            {
                output.RemoveValues("size");
                output.AddValue("size", local.GetFloatValue("size"));
            }
            if (local.HasValue("minSize"))
            {
                output.RemoveValues("minSize");
                output.AddValue("minSize", local.GetFloatValue("minSize"));
            }
            if (local.HasValue("maxSize"))
            {
                output.RemoveValues("maxSize");
                output.AddValue("maxSize", local.GetFloatValue("maxSize"));
            }
            if (local.HasValue("engineSpacing"))
            {
                output.RemoveValues("engineSpacing");
                output.AddValue("engineSpacing", local.GetFloatValue("engineSpacing"));
            }
            if (local.HasValue("rotateEngines"))
            {
                output.RemoveValues("rotateEngines");
                output.AddValue("rotateEngines", local.GetStringValue("rotateEngines"));
            }

            return output;
        }
Example #23
0
 public UVArea(ConfigNode node)
 {
     name = node.GetStringValue("name");
     this.u1 = node.GetFloatValue("u1");
     this.u2 = node.GetFloatValue("u2");
     this.v1 = node.GetFloatValue("v1");
     this.v2 = node.GetFloatValue("v2");
 }
Example #24
0
 public MountModelData(ConfigNode node)
     : base(node)
 {
     layoutNames = node.GetValues("layoutName");
     defaultDiameter = node.GetFloatValue("size", defaultDiameter);
     minDiameter = node.GetFloatValue("minSize", minDiameter);
     maxDiameter = node.GetFloatValue("maxSize", maxDiameter);
     engineSpacing = node.GetFloatValue("engineSpacing", engineSpacing);
     canAdjustSize = node.GetBoolValue("canAdjustSize", canAdjustSize);
     rotateEngineModels = node.GetBoolValues("rotateEngines");
     singleModel = node.GetBoolValue("singleModel", singleModel);
 }
Example #25
0
 public SSTUEnginePosition(ConfigNode node)
 {
     x = node.GetFloatValue("x");
     z = node.GetFloatValue("z");
     rotation = node.GetFloatValue("rotation");
 }
 public SSTUParachuteDefinition(ConfigNode node)
 {
     name = node.GetStringValue("name");
     modelName = node.GetStringValue("modelName");
     capName = node.GetStringValue("capName");
     lineName = node.GetStringValue("lineName");
     capHeight = node.GetFloatValue("capHeight");
     capDiameter = node.GetFloatValue("capDiameter");
     lineHeight = node.GetFloatValue("lineHeight");
 }
 public EngineClusterLayoutMountData(ConfigNode node)
     : base(node)
 {
     canAdjustSize = node.GetBoolValue("canAdjustSize", canAdjustSize);
     initialDiameter = node.GetFloatValue("size", initialDiameter);
     minDiameter = node.GetFloatValue("minSize", initialDiameter);
     maxDiameter = node.GetFloatValue("maxSize", initialDiameter);
     rotateEngines = node.GetFloatValuesCSV("rotateEngines", new float[] {});
     engineSpacing = node.GetFloatValue("engineSpacing", engineSpacing);
     if (String.IsNullOrEmpty(modelDefinition.modelName)) { canAdjustSize = false; }
 }
 public SSTUAnimData(ConfigNode node, Transform transform)
 {
     animationName = node.GetStringValue("name");
     animationSpeed = node.GetFloatValue("speed", animationSpeed);
     animationLayer = node.GetIntValue("layer", animationLayer);
     maxDeployTime = node.GetFloatValue("max", maxDeployTime);
     setupController(animationName, animationSpeed, animationLayer, transform);
 }
Example #29
0
 public SSTUCustomUpperStageRCS(ConfigNode node)
     : base(node)
 {
     modelRotation = node.GetFloatValue("modelRotation");
     modelHorizontalZOffset = node.GetFloatValue("modelHorizontalZOffset");
     modelHorizontalXOffset = node.GetFloatValue("modelHorizontalXOffset");
     modelVerticalOffset = node.GetFloatValue("modelVerticalOffset");
 }
Example #30
0
 public ConverterResourceEntry loadFromNode(ConfigNode node)
 {
     resourceName = node.GetStringValue("resourceName");
     resourceAmount = node.GetFloatValue("resourceAmount");
     stopIfFull = node.GetBoolValue("stopIfFull");
     if (PartResourceLibrary.Instance.resourceDefinitions.Contains(resourceName))
     {
         resourceDefID = PartResourceLibrary.Instance.resourceDefinitions[resourceName].id;
     }
     else
     {
         MonoBehaviour.print("ERROR, could not locate resource definition for name: " + resourceName);
     }
     return this;
 }