示例#1
0
        private void init()
        {
            if (initialized)
            {
                return;
            }
            initialized = true;
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            ConfigNode[] fuelTypeNodes = node.GetNodes("FUELTYPE");
            int          len           = fuelTypeNodes.Length;

            fuelTypes = new ContainerFuelPreset[len];
            for (int i = 0; i < len; i++)
            {
                fuelTypes[i] = VolumeContainerLoader.getPreset(fuelTypeNodes[i].GetValue("name"));
            }
            fuelType = Array.Find(fuelTypes, m => m.name == currentFuelType);
            if (fuelType == null && (fuelTypes != null && fuelTypes.Length > 0))
            {
                MonoBehaviour.print("ERROR: SSTUModularRCS - currentFuelType was null for value: " + currentFuelType);
                fuelType        = fuelTypes[0];
                currentFuelType = fuelType.name;
                MonoBehaviour.print("Assigned default fuel type of: " + currentFuelType + ".  This is likely a config error that needs to be corrected.");
            }
            else if (fuelTypes == null || fuelTypes.Length < 1)
            {
                //TODO -- handle cases of disabled fuel switching
                MonoBehaviour.print("ERROR: SSTUModularRCS - No fuel type definitions found.");
            }
        }
示例#2
0
 //called from the ModuleManagerPostLoad() callback for KSPShaderTools
 public void KSPShaderToolsPostLoad()
 {
     MonoBehaviour.print("Reloading config databases (fuel types, model data, etc...)");
     FuelTypes.INSTANCE.loadConfigData();
     VolumeContainerLoader.loadConfigData(); //needs to be loaded after fuel types
     SSTUDatabase.loadConfigData();          //loads heat-shield types
     SSTUModelData.loadConfigData();
 }
示例#3
0
 public void ModuleManagerPostLoad()
 {
     MonoBehaviour.print("Reloading config databases (fuel types, model data, etc...)");
     FuelTypes.INSTANCE.loadConfigData();
     VolumeContainerLoader.loadConfigData();//needs to be loaded after fuel types
     SSTUModelData.loadConfigData();
     SSTUDatabase.loadConfigData();
 }
示例#4
0
        private void initialize()
        {
            if (initialized)
            {
                return;
            }
            initialized    = true;
            recolorHandler = new RecoloringHandler(Fields[nameof(customColorData)]);
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            string[]   names  = node.GetStringValues("textureSet");
            string[]   titles = SSTUUtils.getNames(TexturesUnlimitedLoader.getTextureSets(names), m => m.title);
            TextureSet currentTextureSetData = TexturesUnlimitedLoader.getTextureSet(currentTextureSet);

            if (currentTextureSetData == null)
            {
                currentTextureSet     = names[0];
                currentTextureSetData = TexturesUnlimitedLoader.getTextureSet(currentTextureSet);
                initializedColors     = false;
            }
            if (!initializedColors)
            {
                initializedColors = true;
                recolorHandler.setColorData(currentTextureSetData.maskColors);
            }
            this.updateUIChooseOptionControl(nameof(currentTextureSet), names, titles, true, currentTextureSet);
            Fields[nameof(currentTextureSet)].guiActiveEditor = names.Length > 1;

            fuelType = VolumeContainerLoader.getPreset(fuelPreset);

            Transform modelBase = part.transform.FindRecursive("model");

            //Set up the engine models container
            ConfigNode[] modelNodes = node.GetNodes("MODEL");
            engineModelRoot = modelBase.FindOrCreate(engineModelRootName);
            ModelDefinitionLayoutOptions[] models = SSTUModelData.getModelDefinitions(modelNodes);
            engineModels = new ModelModule <SSTUInterstageDecoupler>(part, this, engineModelRoot, ModelOrientation.CENTRAL, nameof(currentEngineModel), nameof(currentEngineLayout), nameof(currentEngineTextureSet), nameof(customEngineColorData), null, null, null, null);
            engineModels.getSymmetryModule       = m => m.engineModels;
            engineModels.getValidOptions         = () => models;
            engineModels.getLayoutPositionScalar = () => currentBottomDiameter * 0.5f;
            //engineModels.getLayoutScaleScalar = () => currentEngineScale;
            engineModels.setupModelList(models);
            engineModels.setupModel();
            engineModels.updateSelections();
            updateEnginePositionAndScale();

            //set up the fairing container
            minHeight = engineModels.moduleHeight;
            Transform fairingContainerRoot = modelBase.FindOrCreate(baseTransformName);

            fairingBase = new FairingContainer(fairingContainerRoot.gameObject, cylinderSides, numberOfPanels, wallThickness);
            updateEditorFields();
            buildFairing();
            updateEnginePositionAndScale();
            updateFairingTextureSet(false);
            updateNodePositions(false);
            updatePartMass();
        }
示例#5
0
        public static void updateRCSFuelType(string fuelType, Part part)
        {
            ContainerFuelPreset fuelTypeData = VolumeContainerLoader.getPreset(fuelType);

            if (fuelTypeData != null)
            {
                updateRCSFuelType(fuelTypeData, part);
            }
        }
示例#6
0
        private void initialize()
        {
            if (initialized)
            {
                return;
            }
            initialized    = true;
            recolorHandler = new RecoloringHandler(Fields[nameof(customColorData)]);
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            ConfigNode[] textureNodes          = node.GetNodes("TEXTURESET");
            string[]     names                 = TextureSet.getTextureSetNames(textureNodes);
            string[]     titles                = TextureSet.getTextureSetTitles(textureNodes);
            TextureSet   currentTextureSetData = KSPShaderLoader.getTextureSet(currentTextureSet);

            if (currentTextureSetData == null)
            {
                currentTextureSet     = names[0];
                currentTextureSetData = KSPShaderLoader.getTextureSet(currentTextureSet);
                initializedColors     = false;
            }
            if (!initializedColors)
            {
                initializedColors = true;
                recolorHandler.setColorData(currentTextureSetData.maskColors);
            }
            this.updateUIChooseOptionControl("currentTextureSet", names, titles, true, currentTextureSet);
            Fields[nameof(currentTextureSet)].guiActiveEditor = textureNodes.Length > 1;

            fairingMaterial = currentTextureSetData.textureData[0].createMaterial("SSTUFairingMaterial");

            fuelType = VolumeContainerLoader.getPreset(fuelPreset);

            Transform modelBase = part.transform.FindRecursive("model");

            setupEngineModels(modelBase, node);
            minHeight = engineModels.model.modelDefinition.height * getEngineScale();
            Transform root     = modelBase.FindOrCreate(baseTransformName);
            Transform collider = modelBase.FindOrCreate("InterstageFairingBaseCollider");

            fairingBase = new InterstageDecouplerModel(root.gameObject, collider.gameObject, 0.25f, cylinderSides, numberOfPanels, wallThickness);
            updateEditorFields();
            buildFairing();
            updateTextureSet(false);
            updateNodePositions(false);
            if (!initializedResources && (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor))
            {
                initializedResources = true;
                updateResources();
            }
            updatePartMass();
            updateEngineThrust();
        }
示例#7
0
        private void init()
        {
            if (initialized)
            {
                return;
            }
            initialized = true;
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            standoffTransform = part.transform.FindRecursive("model").FindOrCreate("ModularRCSStandoff");
            standoffTransform.localRotation = Quaternion.Euler(0, 0, 90);//rotate 90' on z-axis, to face along x+/-; this should put the 'top' of the model at 0,0,0
            standoffModule = new ModelModule <SingleModelData, SSTUModularRCS>(part, this, standoffTransform, ModelOrientation.TOP, nameof(structurePersistentData), nameof(currentStructure), nameof(currentStructureTexture));
            standoffModule.getSymmetryModule = m => m.standoffModule;
            standoffModule.setupModelList(ModelData.parseModels <SingleModelData>(node.GetNodes("STRUCTURE"), m => new SingleModelData(m)));
            standoffModule.setupModel();

            if (string.IsNullOrEmpty(modelName))
            {
                MonoBehaviour.print("ERROR: SSTUModularRCS - null/empty modelName in module config.");
            }
            modelTransform = part.transform.FindModel(modelName);

            updateModelScale();
            updateMassAndCost();

            updateAttachNodes(false);

            ConfigNode[] fuelTypeNodes = node.GetNodes("FUELTYPE");
            int          len           = fuelTypeNodes.Length;

            fuelTypes = new ContainerFuelPreset[len];
            for (int i = 0; i < len; i++)
            {
                fuelTypes[i] = VolumeContainerLoader.getPreset(fuelTypeNodes[i].GetValue("name"));
            }
            fuelType = Array.Find(fuelTypes, m => m.name == currentFuelType);
            if (fuelType == null && (fuelTypes != null && fuelTypes.Length > 0))
            {
                MonoBehaviour.print("ERROR: SSTUModularRCS - currentFuelType was null for value: " + currentFuelType);
                fuelType        = fuelTypes[0];
                currentFuelType = fuelType.name;
                MonoBehaviour.print("Assigned default fuel type of: " + currentFuelType + ".  This is likely a config error that needs to be corrected.");
            }
            else if (fuelTypes == null || fuelTypes.Length < 1)
            {
                //TODO -- handle cases of disabled fuel switching
                MonoBehaviour.print("ERROR: SSTUModularRCS - No fuel type definitions found.");
            }
        }
示例#8
0
 public FuelTypeISP(ConfigNode node)
 {
     fuelPreset = VolumeContainerLoader.getPreset(node.GetStringValue("name"));
     if (fuelPreset == null)
     {
         SSTULog.error("Could not locate fuel preset for name: " + node.GetStringValue("name"));
     }
     if (node.HasNode("atmosphereCurve"))
     {
         atmosphereCurve = node.GetFloatCurve("atmosphereCurve");
     }
     else
     {
         atmosphereCurve = null;
     }
 }
示例#9
0
        public void ModuleManagerPostLoad()
        {
            MonoBehaviour.print("Creating Part Config cache.");
            partConfigNodes.Clear();
            ConfigNode[] partNodes = GameDatabase.Instance.GetConfigNodes("PART");
            String       name;

            foreach (ConfigNode node in partNodes)
            {
                name = node.GetStringValue("name");
                name = name.Replace('_', '.');
                if (partConfigNodes.ContainsKey(name))
                {
                    continue;
                }
                partConfigNodes.Add(name, node);
            }
            MonoBehaviour.print("Reloading config databases (fuel types, model data, etc...)");
            FuelTypes.INSTANCE.loadConfigData();
            VolumeContainerLoader.loadConfigData();//needs to be loaded after fuel types
            SSTUModelData.loadConfigData();
            SSTUDatabase.loadConfigData();
        }
示例#10
0
        public ContainerDefinition(SSTUVolumeContainer module, ConfigNode node)
        {
            this.module            = module;
            name                   = node.GetStringValue("name", name);
            availableResources     = node.GetStringValues("resource");
            resourceSets           = node.GetStringValues("resourceSet");
            tankModifierNames      = node.GetStringValues("modifier");
            configVolume           = volume = node.GetFloatValue("volume", 0);
            tankageVolume          = node.GetFloatValue("tankageVolume");
            tankageMass            = node.GetFloatValue("tankageMass");
            costPerDryTon          = node.GetFloatValue("dryCost", 700f);
            massPerEmptyCubicMeter = node.GetFloatValue("emptyMass", 0.05f);
            defaultFuelPreset      = node.GetStringValue("defaultFuelPreset");
            defaultResources       = node.GetStringValue("defaultResources");
            defaultModifier        = node.GetStringValue("defaultModifier", "standard");
            ecHasMass              = node.GetBoolValue("ecHasMass", ecHasMass);
            ecHasCost              = node.GetBoolValue("ecHasCost", ecHasCost);
            guiAvailable           = node.GetBoolValue("guiAvailable", guiAvailable);
            useStaticVolume        = node.GetBoolValue("useStaticVolume", useStaticVolume);

            if (availableResources.Length == 0 && resourceSets.Length == 0)
            {
                resourceSets = new string[] { "generic" };
            }                                                                                                             //validate that there is some sort of resource reference; generic is a special type for all pumpable resources
            if (tankModifierNames == null || tankModifierNames.Length == 0)
            {
                tankModifierNames = VolumeContainerLoader.getAllModifierNames();
            }                                                                                                                                   //validate that there is at least one modifier type

            //load available container modifiers
            modifiers = VolumeContainerLoader.getModifiersByName(tankModifierNames);

            //setup applicable resources
            List <string> resourceNames = new List <string>();
            int           len           = availableResources.Length;

            for (int i = 0; i < len; i++)
            {
                if (!resourceNames.Contains(availableResources[i]))
                {
                    resourceNames.Add(availableResources[i]);
                }
                else
                {
                    MonoBehaviour.print("ERROR:  Duplicate resource detected for name: " + availableResources[i] + " while loading data for part: " + module.part);
                }
            }
            len = resourceSets.Length;
            int resLen;
            ContainerResourceSet set;

            for (int i = 0; i < len; i++)
            {
                set = VolumeContainerLoader.getResourceSet(resourceSets[i]);
                if (set == null)
                {
                    continue;
                }
                resLen = set.availableResources.Length;
                for (int k = 0; k < resLen; k++)
                {
                    resourceNames.AddUnique(set.availableResources[k]);
                }
            }

            //validate vs part resource library, make sure they are all valid resource entries
            PartResourceLibrary    prl = PartResourceLibrary.Instance;
            PartResourceDefinition prd;

            len = resourceNames.Count;
            for (int i = len - 1; i >= 0; i--)//inverted loop to allow for removal by index while traversing
            {
                prd = prl.GetDefinition(resourceNames[i]);
                if (prd == null)
                {
                    MonoBehaviour.print("ERROR: Could not find resource definition for: " + resourceNames[i] + " while loading data for part: " + module.part + " -- resource removed from VolumeContainer");
                    resourceNames.RemoveAt(i);
                }
            }

            //sort and turn into an array
            resourceNames.Sort();//basic alpha sort...
            applicableResources = resourceNames.ToArray();

            if (string.IsNullOrEmpty(defaultFuelPreset) && string.IsNullOrEmpty(defaultResources) && applicableResources.Length > 0)
            {
                defaultResources = applicableResources[0] + ",1";
            }

            //setup volume data
            len = applicableResources.Length;
            subContainerData = new SubContainerDefinition[len];
            for (int i = 0; i < len; i++)
            {
                subContainerData[i] = new SubContainerDefinition(this, applicableResources[i]);
                if (subContainersByName.ContainsKey(subContainerData[i].name))
                {
                    MonoBehaviour.print("ERROR:  Duplicate resoruce detected for name: " + subContainerData[i].name + " while loading data for part: " + module.part);
                }
                else
                {
                    subContainersByName.Add(subContainerData[i].name, subContainerData[i]);
                }
            }

            //setup preset data
            List <ContainerFuelPreset> usablePresets = new List <ContainerFuelPreset>();

            ContainerFuelPreset[] presets = VolumeContainerLoader.getPresets();
            len = presets.Length;
            for (int i = 0; i < len; i++)
            {
                if (presets[i].applicable(applicableResources))
                {
                    usablePresets.Add(presets[i]);
                }
            }
            fuelPresets         = usablePresets.ToArray();
            currentModifierName = defaultModifier;
            internalInitializeDefaults();
        }
示例#11
0
        public ContainerDefinition(SSTUVolumeContainer module, ConfigNode node, float tankTotalVolume)
        {
            this.module        = module;
            name               = node.GetStringValue("name", name);
            availableResources = node.GetStringValues("resource");
            resourceSets       = node.GetStringValues("resourceSet");
            tankModifierNames  = node.GetStringValues("modifier");
            setContainerPercent(node.GetFloatValue("percent", 1));
            tankageVolume          = node.GetFloatValue("tankageVolume");
            tankageMass            = node.GetFloatValue("tankageMass");
            costPerDryTon          = node.GetFloatValue("dryCost", 700f);
            massPerEmptyCubicMeter = node.GetFloatValue("emptyMass", 0.05f);
            defaultFuelPreset      = node.GetStringValue("defaultFuelPreset");
            defaultResources       = node.GetStringValue("defaultResources");
            defaultModifier        = node.GetStringValue("defaultModifier", "standard");
            ecHasMass    = node.GetBoolValue("ecHasMass", ecHasMass);
            ecHasCost    = node.GetBoolValue("ecHasCost", ecHasCost);
            guiAvailable = node.GetBoolValue("guiAvailable", guiAvailable);

            if (availableResources.Length == 0 && resourceSets.Length == 0)
            {
                resourceSets = new string[] { "generic" };
            }                                                                                                             //validate that there is some sort of resource reference; generic is a special type for all pumpable resources
            if (tankModifierNames == null || tankModifierNames.Length == 0)
            {
                tankModifierNames = VolumeContainerLoader.getAllModifierNames();
            }                                                                                                                                   //validate that there is at least one modifier type

            //load available container modifiers
            modifiers = VolumeContainerLoader.getModifiersByName(tankModifierNames);

            //setup applicable resources
            List <string> resourceNames = new List <string>();

            resourceNames.AddRange(availableResources);
            int len = resourceSets.Length;
            int resLen;
            ContainerResourceSet set;

            for (int i = 0; i < len; i++)
            {
                set = VolumeContainerLoader.getResourceSet(resourceSets[i]);
                if (set == null)
                {
                    continue;
                }
                resLen = set.availableResources.Length;
                for (int k = 0; k < resLen; k++)
                {
                    resourceNames.AddUnique(set.availableResources[k]);
                }
            }
            resourceNames.Sort();//basic alpha sort...
            applicableResources = resourceNames.ToArray();

            if (string.IsNullOrEmpty(defaultFuelPreset) && string.IsNullOrEmpty(defaultResources) && applicableResources.Length > 0)
            {
                defaultResources = applicableResources[0] + ",1";
            }

            //setup volume data
            len = applicableResources.Length;
            subContainerData = new SubContainerDefinition[len];
            for (int i = 0; i < len; i++)
            {
                subContainerData[i] = new SubContainerDefinition(this, applicableResources[i]);
                subContainersByName.Add(subContainerData[i].name, subContainerData[i]);
            }

            //setup preset data
            List <ContainerFuelPreset> usablePresets = new List <ContainerFuelPreset>();

            ContainerFuelPreset[] presets = VolumeContainerLoader.getPresets();
            len = presets.Length;
            for (int i = 0; i < len; i++)
            {
                if (presets[i].applicable(applicableResources))
                {
                    usablePresets.Add(presets[i]);
                }
            }
            fuelPresets         = usablePresets.ToArray();
            currentModifierName = defaultModifier;
            currentRawVolume    = tankTotalVolume * percentOfTankVolume;
            internalInitializeDefaults();
        }