Exemplo n.º 1
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);
            mpf = part.GetComponent <ModuleProceduralFairing>();
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            textureSets = TextureSet.loadTextureSets(node.GetNodes("TEXTURESET"));
            int len = textureSets.Length;

            string[] textureSetNames = new string[len];
            for (int i = 0; i < len; i++)
            {
                textureSetNames[i] = textureSets[i].setName;
            }
            this.updateUIChooseOptionControl("currentTextureSet", textureSetNames, textureSetNames, true, currentTextureSet);

            updateModelScale();
            updateTexture(currentTextureSet);
            updateNodePositions(false);
            this.updateUIFloatEditControl("currentDiameter", minDiameter, maxDiameter, diameterIncrement * 2f, diameterIncrement, diameterIncrement * 0.05f, true, currentDiameter);
            Fields["currentDiameter"].uiControlEditor.onFieldChanged   = onDiameterUpdated;
            Fields["currentTextureSet"].uiControlEditor.onFieldChanged = onTextureUpdated;
            Fields["currentTextureSet"].guiActiveEditor = textureSets.Length > 1;
            updateEditorFields();
        }
Exemplo n.º 2
0
        private void loadConfigData()
        {
            recolorHandler = new RecoloringHandler(Fields[nameof(customColorData)]);
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

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

            if (currentTextureSetData == null)
            {
                currentTextureSet     = textureSetNames[0];
                currentTextureSetData = KSPShaderLoader.getTextureSet(currentTextureSet);
                initializedColors     = false;
            }
            if (!initializedColors)
            {
                initializedColors = true;
                recolorHandler.setColorData(currentTextureSetData.maskColors);
            }
            fairingMaterial = currentTextureSetData.textureData[0].createMaterial("SSTUFairingMaterial");
            Fields["currentTextureSet"].guiActiveEditor = textureNodes.Length > 1;
            this.updateUIChooseOptionControl("currentTextureSet", textureSetNames, titles, true, currentTextureSet);
        }
Exemplo n.º 3
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.");
            }
        }
Exemplo n.º 4
0
 private void initialize()
 {
     if (rendersToRemove != null && rendersToRemove.Length > 0)
     {
         SSTUUtils.removeTransforms(part, SSTUUtils.parseCSV(rendersToRemove));
     }
     loadFairingData(SSTUConfigNodeUtils.parseConfigNode(configNodeData));
     if (externalUpdateData != null)
     {
         updateFromExternalData(externalUpdateData);
     }
     updateEditorFields(false); //update cached editor gui field values for diameter, sections, etc.
     buildFairing();            //construct fairing from cached/persistent/default data
     needsStatusUpdate = true;
     if (textureSets != null)
     {
         if (textureSets.Length <= 1)//only a single, (or no) texture set selected/avaialable
         {
             Events["nextTextureEvent"].active = false;
         }
         if (textureSets.Length > 0 && String.IsNullOrEmpty(currentTextureSet))
         {
             TextureSet s = textureSets[0];
             currentTextureSet = textureSets[0].setName;
         }
     }
 }
Exemplo n.º 5
0
        private void loadConfigData()
        {
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            ConfigNode[] textureNodes = node.GetNodes("TEXTURESET");
            int          len          = textureNodes.Length;

            textureSetData = new TextureSet[len];
            for (int i = 0; i < len; i++)
            {
                textureSetData[i] = new TextureSet(textureNodes[i]);
            }
            currentTextureSetData = Array.Find(textureSetData, m => m.setName == currentTextureSet);
            if (currentTextureSetData == null)
            {
                currentTextureSetData = textureSetData[0];
                currentTextureSet     = currentTextureSetData.setName;
            }
            string[] textureSetNames = new string[len];
            for (int i = 0; i < len; i++)
            {
                textureSetNames[i] = textureSetData[i].setName;
            }
            this.updateUIChooseOptionControl("currentTextureSet", textureSetNames, textureSetNames, true, currentTextureSet);
        }
Exemplo n.º 6
0
        private void init()
        {
            if (initialized)
            {
                return;
            }
            initialized   = true;
            rcsIndices    = SSTUUtils.parseIntArray(rcsModuleIndex);
            engineIndices = SSTUUtils.parseIntArray(engineModuleIndex);
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

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

            fuelTypes = FuelTypeISP.parse(fuelTypeNodes);
            fuelType  = Array.Find(fuelTypes, m => m.fuelPreset.name == currentFuelType);
            if (fuelType == null && (fuelTypes != null && fuelTypes.Length > 0))
            {
                SSTULog.error("ERROR: SSTUModularRCS - currentFuelType was null for value: " + currentFuelType);
                fuelType        = fuelTypes[0];
                currentFuelType = fuelType.fuelPreset.name;
                SSTULog.error("Assigned default fuel type of: " + currentFuelType + ".  This is likely a config error that needs to be corrected.");
            }
            else if (fuelTypes == null || fuelTypes.Length < 1)
            {
                SSTULog.error("ERROR: SSTURCSFuelSelection - No fuel type definitions found.");
            }
        }
Exemplo n.º 7
0
        private void loadConfigData()
        {
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            ConfigNode[] containerNodes = node.GetNodes("CONTAINER");
            int          len            = containerNodes.Length;

            containers = new ContainerDefinition[len];
            for (int i = 0; i < len; i++)
            {
                containers[i] = new ContainerDefinition(this, containerNodes[i]);
            }
            if (!string.IsNullOrEmpty(persistentData))
            {
                string[] splits = persistentData.Split(':');
                len = containers.Length;
                for (int i = 0; i < len && i < splits.Length; i++)
                {
                    containers[i].loadPersistenData(splits[i]);
                }
            }
            prevFuelType = getBaseContainer().fuelPreset;
            ConfigNode[] blacklistNodes = node.GetNodes("BLACKLIST");
            len = blacklistNodes.Length;
            blacklistedResources = new string[len];
            for (int i = 0; i < len; i++)
            {
                blacklistedResources[i] = blacklistNodes[i].GetStringValue("name");
            }
        }
Exemplo n.º 8
0
 private void initialize()
 {
     //MonoBehaviour.print("NodeFairingInit: "+fairingCreated+ " :: " +fairingForceDisabled+ " :: "+fairingJettisoned + " :: " +fairingEnabled);
     if (rendersToRemove != null && rendersToRemove.Length > 0)
     {
         SSTUUtils.removeTransforms(part, SSTUUtils.parseCSV(rendersToRemove));
     }
     loadFairingData(SSTUConfigNodeUtils.parseConfigNode(configNodeData));
     if (externalUpdateData != null)
     {
         updateFromExternalData(externalUpdateData);
     }
     if (fairingCreated || (fairingEnabled && !fairingJettisoned && !fairingForceDisabled && string.IsNullOrEmpty(nodeName)))//previously existed, recreate it, or should exist by default values in the config
     {
         buildFairing();
         if (!string.IsNullOrEmpty(nodeName))
         {
             AttachNode n = part.FindAttachNode(nodeName);
             if (n != null && n.attachedPart != null)
             {
                 prevAttachedPart = n.attachedPart;
                 //MonoBehaviour.print("Setting initial attached part to: " + prevAttachedPart);
             }
         }
     }
     else if (!fairingJettisoned && !fairingForceDisabled && !string.IsNullOrEmpty(nodeName))//else could potentially be activated by a node...check for activation
     {
         needsStatusUpdate = true;
     }
     updateTextureSet(false);
     needsGuiUpdate = true;
     //MonoBehaviour.print("NodeFairingInit End: " + fairingCreated + " :: " + fairingForceDisabled + " :: " + fairingJettisoned + " :: " + fairingEnabled);
 }
Exemplo n.º 9
0
        private void init()
        {
            if (initialized)
            {
                return;
            }
            initialized = true;
            if (HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight)
            {
                updateCrewCapacity(inflated ? inflatedCrew : deflatedCrew);
            }

            ConfigNode    node     = SSTUConfigNodeUtils.parseConfigNode(configNodeData);
            AnimationData animData = new AnimationData(node.GetNode("ANIMATIONDATA"));

            animationModule = new AnimationModule(part, this, nameof(persistentState), null, nameof(inflateEvent), nameof(deflateEvent));
            animationModule.getSymmetryModule = m => ((SSTUInflatable)m).animationModule;
            animationModule.setupAnimations(animData, part.transform.FindRecursive("model"), 0);
            animationModule.onAnimStateChangeCallback = onAnimationStateChange;

            resourceDef = PartResourceLibrary.Instance.GetDefinition(resourceName);
            if (resourceDef == null)
            {
                MonoBehaviour.print("ERROR: Could not locate resource for name: " + resourceName + " for " + this.name);
            }
            updateRequiredMass();
        }
Exemplo n.º 10
0
        private void initialize()
        {
            if (initialized)
            {
                return;
            }
            initialized = true;

            recolorHandler = new RecoloringHandler(Fields[nameof(customColorData)]);

            mpf = part.GetComponent <ModuleProceduralFairing>();
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

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

            if (t == null)
            {
                currentTextureSet = names[0];
                t = TexturesUnlimitedLoader.getTextureSet(currentTextureSet);
                initializedColors = false;
            }
            if (!initializedColors)
            {
                initializedColors = true;
                recolorHandler.setColorData(t.maskColors);
            }
            this.updateUIChooseOptionControl(nameof(currentTextureSet), names, titles, true, currentTextureSet);
            Fields[nameof(currentTextureSet)].guiActiveEditor = names.Length > 1;
        }
Exemplo n.º 11
0
        private void initialize()
        {
            meshes = part.transform.FindChildren(decalMeshName);
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            ConfigNode[] decalNodes = node.GetNodes("DECAL");
            int          len        = decalNodes.Length;

            possibleDecals = new SSTUDecal[len];
            for (int i = 0; i < len; i++)
            {
                possibleDecals[i] = new SSTUDecal(decalNodes[i]);
            }
            SSTUDecal currentDecalObj = Array.Find(possibleDecals, m => m.name == currentDecal);

            if (currentDecalObj == null && len > 0)
            {
                currentDecalObj = possibleDecals[0];
                currentDecal    = currentDecalObj.name;
            }
            else if (currentDecalObj == null)
            {
                MonoBehaviour.print("ERROR: NO decals found to load for part: " + part.name);
            }
            foreach (Transform mesh in meshes)
            {
                currentDecalObj.enable(mesh);
            }
        }
Exemplo n.º 12
0
        private void initialize()
        {
            if (initialized)
            {
                return;
            }
            initialized = true;
            if (currentDiameter > maxDiameter)
            {
                currentDiameter = maxDiameter;
            }
            if (currentDiameter < minDiameter)
            {
                currentDiameter = minDiameter;
            }

            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            AnimationData animData = new AnimationData(node.GetNode("ANIMATIONDATA"));

            animationModule = new AnimationModule(part, this, nameof(persistentState), null, nameof(enableAnimationEvent), nameof(disableAnimationEvent));
            animationModule.getSymmetryModule = m => ((SSTUWeldingDockingPort)m).animationModule;
            animationModule.setupAnimations(animData, part.transform.FindRecursive("model"), animationLayer);
            animationModule.onAnimStateChangeCallback = onAnimStateChange;

            updateModelScale();
            updateDragCubes();
            updatePartCost();
            updatePartMass();
        }
Exemplo n.º 13
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();
        }
Exemplo n.º 14
0
 private void initialize()
 {
     if (initialized)
     {
         return;
     }
     initialized = true;
     loadConfigData(SSTUConfigNodeUtils.parseConfigNode(configNodeData));
 }
Exemplo n.º 15
0
        private void initialize()
        {
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            AnimationData animData = new AnimationData(node.GetNode("ANIMATIONDATA"));

            animationModule = new AnimationModule(part, this, nameof(persistentState), nameof(animationMaxDeploy), nameof(enableAnimationEvent), nameof(disableAnimationEvent));
            animationModule.getSymmetryModule = m => ((SSTUAnimateControlled)m).animationModule;
            animationModule.setupAnimations(animData, part.transform.FindRecursive("model"), animationLayer);
            animationModule.onAnimStateChangeCallback = onAnimStateChange;
        }
Exemplo n.º 16
0
 private void initialize()
 {
     if (initialized)
     {
         return;
     }
     initialized = true;
     loadConfigData(SSTUConfigNodeUtils.parseConfigNode(configNodeData));
     initializeModels();
     setChuteState(chuteState);
 }
Exemplo n.º 17
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();
        }
Exemplo n.º 18
0
        private void initialize()
        {
            if (initialized)
            {
                return;
            }
            initialized = true;
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            ConfigNode[] textureNodes = node.GetNodes("TEXTURESET");
            textureSetData        = TextureSet.loadTextureSets(textureNodes);
            currentTextureSetData = Array.Find(textureSetData, m => m.setName == currentTextureSet);
            if (currentTextureSetData == null)
            {
                currentTextureSetData = textureSetData[0];
                currentTextureSet     = currentTextureSetData.setName;
            }

            int len = textureSetData.Length;

            string[] textureSetNames = new string[len];
            for (int i = 0; i < len; i++)
            {
                textureSetNames[i] = textureSetData[i].setName;
            }
            this.updateUIChooseOptionControl("currentTextureSet", textureSetNames, textureSetNames, true, currentTextureSet);

            TextureData data = currentTextureSetData.textureDatas[0];

            fairingMaterial = SSTUUtils.loadMaterial(data.diffuseTextureName, null, "KSP/Specular");

            loadMaterial();

            Transform tr = part.transform.FindRecursive("model").FindOrCreate("PetalAdapterRoot");

            fairingBase = new InterstageFairingContainer(tr.gameObject, cylinderSides, numberOfPanels, wallThickness);
            UVMap uvs = UVMap.GetUVMapGlobal(uvMap);

            fairingBase.outsideUV = uvs.getArea("outside");
            fairingBase.insideUV  = uvs.getArea("inside");
            fairingBase.edgesUV   = uvs.getArea("edges");

            rebuildFairing(false);//will create fairing using default / previously saved fairing configuration
            restoreEditorFields();
            setPanelRotations(currentRotation);
            if (panelsJettisoned)
            {
                fairingBase.destroyExistingPanels();
            }
            updateGuiState();
        }
Exemplo n.º 19
0
        private void initialize()
        {
            if (initialized)
            {
                return;
            }
            initialized = true;
            double hsp  = 1;
            double dens = 1;

            PartResourceDefinition resource = PartResourceLibrary.Instance.GetDefinition(resourceName);

            hsp  = resource.specificHeatCapacity;
            dens = resource.density;

            fluxPerResourceUnit = hsp * ablationEfficiency * dens;
            baseSkinIntMult     = part.skinInternalConductionMult;
            baseCondMult        = part.heatConductivity;

            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            Transform mhsRoot = part.transform.FindRecursive("model").FindOrCreate("SSTU-MHS-Root");

            ConfigNode[] modelNodes = node.GetNodes("MODELS");
            ModelDefinitionLayoutOptions[] models = SSTUModelData.getModelDefinitions(modelNodes);
            model = new ModelModule <SSTUModularHeatShield>(part, this, mhsRoot, ModelOrientation.CENTRAL, nameof(currentShieldModel), null, nameof(currentShieldTexture), nameof(modelPersistentData), null, null, null, null);
            model.getSymmetryModule = (m) => m.model;
            model.setupModelList(models);
            model.setupModel();
            model.setScaleForDiameter(currentDiameter);
            model.setPosition(0);
            model.updateModelMeshes();
            model.updateSelections();
            model.volumeScalar = resourceScalePower;
            model.massScalar   = resourceScalePower;
            if (standAlonePart)
            {
                updateDragCube();
                updateAttachNodes(false);
            }
            SSTUModInterop.updateResourceVolume(part);
            ConfigNode[] typeNodes = node.GetNodes("SHIELDTYPE");
            shieldTypeData        = HeatShieldTypeData.load(typeNodes);
            currentShieldTypeData = Array.Find(shieldTypeData, m => m.baseType.name == currentShieldType);
            updateModuleStats();
            updatePartCost();
            SSTUModInterop.onPartGeometryUpdate(part, false);
            SSTUModInterop.updateResourceVolume(part);
            SSTUStockInterop.fireEditorUpdate();//update for mass/cost/etc.
        }
Exemplo n.º 20
0
        private void init()
        {
            if (initialized)
            {
                return;
            }
            initialized         = true;
            standoffRotatedRoot = part.transform.FindRecursive("SSTUModularRCSStructureRoot");
            if (standoffRotatedRoot == null)
            {
                standoffRotatedRoot = new GameObject("SSTUModularRCSStructureRoot").transform;
                standoffRotatedRoot.NestToParent(part.transform.FindRecursive("model"));
                standoffRotatedRoot.Rotate(90, -90, 0);
            }
            modelRotatedRoot = part.transform.FindRecursive("SSTUModularRCSBlockRoot");
            if (modelRotatedRoot == null)
            {
                modelRotatedRoot = new GameObject("SSTUModularRCSBlockRoot").transform;
                modelRotatedRoot.NestToParent(part.transform.FindRecursive("model"));
                modelRotatedRoot.Rotate(0, 0, 0);
            }
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            ModelDefinitionLayoutOptions[] blocks  = SSTUModelData.getModelDefinitions(node.GetNodes("MODEL"));
            ModelDefinitionLayoutOptions[] structs = SSTUModelData.getModelDefinitions(node.GetNodes("STRUCTURE"));

            modelTransform      = modelRotatedRoot.FindOrCreate("ModularRCSModel");
            rcsBlockModule      = new ModelModule <SSTUModularRCS>(part, this, modelTransform, ModelOrientation.CENTRAL, nameof(currentModel), nameof(currentLayout), nameof(currentTexture), nameof(modelPersistentData), null, null, null, null);
            rcsBlockModule.name = "RCSBlock";
            rcsBlockModule.getSymmetryModule = m => m.rcsBlockModule;
            rcsBlockModule.setupModelList(blocks);
            rcsBlockModule.getValidOptions = () => blocks;
            rcsBlockModule.setupModel();
            rcsBlockModule.updateSelections();

            standoffTransform   = standoffRotatedRoot.FindOrCreate("ModularRCSStandoff");
            standoffModule      = new ModelModule <SSTUModularRCS>(part, this, standoffTransform, ModelOrientation.TOP, nameof(currentStructure), nameof(currentLayout), nameof(currentStructureTexture), nameof(structurePersistentData), null, null, null, null);
            standoffModule.name = "Standoff";
            standoffModule.getSymmetryModule = m => m.standoffModule;
            standoffModule.setupModelList(structs);
            standoffModule.getValidOptions = () => structs;
            standoffModule.setupModel();
            standoffModule.updateSelections();

            updateModelScale();
            updateMassAndCost();
            rcsBlockModule.renameRCSThrustTransforms(rcsThrustTransformName);

            updateAttachNodes(false);
        }
Exemplo n.º 21
0
        private void initialize()
        {
            if (initialized)
            {
                return;
            }
            initialized = true;
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            ConfigNode[] nodes = node.GetNodes("MODEL");
            modelData = ModelData.parseModels <PositionedModelData>(nodes, m => new PositionedModelData(m));
            setActiveModel(currentModel);
            updateMassAndCost();
        }
Exemplo n.º 22
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.");
            }
        }
Exemplo n.º 23
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   t            = KSPShaderLoader.getTextureSet(currentTextureSet);

            if (t == null)
            {
                currentTextureSet = names[0];
                t = KSPShaderLoader.getTextureSet(currentTextureSet);
                initializedColors = false;
            }
            if (!initializedColors)
            {
                initializedColors = true;
                recolorHandler.setColorData(t.maskColors);
            }
            this.updateUIChooseOptionControl(nameof(currentTextureSet), names, titles, true, currentTextureSet);
            fairingMaterial = t.textureData[0].createMaterial("SSTUFairingMaterial");

            Transform tr = part.transform.FindRecursive("model").FindOrCreate("PetalAdapterRoot");

            fairingBase = new InterstageFairingContainer(tr.gameObject, cylinderSides, numberOfPanels, wallThickness);
            UVMap uvs = UVMap.GetUVMapGlobal(uvMap);

            fairingBase.outsideUV = uvs.getArea("outside");
            fairingBase.insideUV  = uvs.getArea("inside");
            fairingBase.edgesUV   = uvs.getArea("edges");

            validateStraightHeight();
            rebuildFairing(false);//will create fairing using default / previously saved fairing configuration
            setPanelRotations(currentRotation);
            if (panelsJettisoned)
            {
                fairingBase.destroyFairing();
            }
            updateGuiState();
        }
Exemplo n.º 24
0
        private void initialize()
        {
            if (initialized)
            {
                return;
            }
            initialized = true;
            ConfigNode    node     = SSTUConfigNodeUtils.parseConfigNode(configNodeData);
            AnimationData animData = new AnimationData(node.GetNode("ANIMATIONDATA"));

            animationModule = new AnimationModule(part, this, nameof(persistentState), null, nameof(deployEngineEvent), nameof(retractEngineEvent));
            animationModule.getSymmetryModule = m => ((SSTUDeployableEngine)m).animationModule;
            animationModule.setupAnimations(animData, part.transform.FindRecursive("model"), 0);
            animationModule.onAnimStateChangeCallback = onAnimationStateChange;
        }
Exemplo n.º 25
0
        private void initialize()
        {
            if (!moduleIsEnabled)
            {
                //TODO -- UI disabling
                return;
            }
            if (initialized)
            {
                return;
            }
            initialized = true;
            AnimationData  animData = null;
            ModelSolarData msd      = null;
            ConfigNode     node     = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            if (node.HasValue("modelDefinition"))
            {
                ModelDefinition def = SSTUModelData.getModelDefinition(node.GetStringValue("modelDefinition"));
                if (def == null)
                {
                    MonoBehaviour.print("Could not locate model definition: " + node.GetStringValue("modelDefinition") + " for solar data");
                }
                else
                {
                    animData = def.animationData;
                    msd      = def.solarModuleData;
                }
            }
            //allow local override of animation data
            if (node.HasNode("ANIMATIONDATA"))
            {
                animData = new AnimationData(node.GetNode("ANIMATIONDATA"));
            }
            if (node.HasNode("SOLARDATA"))
            {
                msd = new ModelSolarData(node.GetNode("SOLARDATA"));
            }

            animationModule = new AnimationModule(part, this, nameof(persistentState), null, nameof(extendEvent), nameof(retractEvent));
            animationModule.getSymmetryModule = m => ((SSTUSolarPanelDeployable)m).animationModule;
            animationModule.setupAnimations(animData, part.transform.FindRecursive("model"), animationLayer);

            solarModule = new SolarModule(part, this, animationModule, Fields[nameof(solarPersistentData)], Fields[nameof(guiStatus)]);
            solarModule.getSymmetryModule = m => ((SSTUSolarPanelDeployable)m).solarModule;
            solarModule.setupSolarPanelData(new ModelSolarData[] { msd }, new Transform[] { part.transform.FindRecursive("model") });
            nominalSolarOutput = solarModule.standardPotentialOutput;
        }
Exemplo n.º 26
0
        private void initialize()
        {
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            ConfigNode[] animNodes = node.GetNodes("ANIMATION");
            int          len       = animNodes.Length;

            ConfigNode[] allNodes = null;
            if (!String.IsNullOrEmpty(animationName))
            {
                allNodes = new ConfigNode[len + 1];
                for (int i = 0; i < len; i++)
                {
                    allNodes[i] = animNodes[i];
                }
                ConfigNode legacyNode = new ConfigNode("ANIMATION");
                legacyNode.AddValue("name", animationName);
                legacyNode.AddValue("speed", animationSpeed);
                legacyNode.AddValue("layer", animationLayer);
                allNodes[len] = legacyNode;
            }
            else
            {
                allNodes = animNodes;
            }
            if (allNodes == null)
            {
                allNodes = new ConfigNode[0];
            }                                                      //should be impossible, but ensures clean init with no animations defined, without throwing un-necessary errors

            AnimState prevState = (AnimState)Enum.Parse(typeof(AnimState), persistentState);
            float     time      = prevState == AnimState.STOPPED_START || prevState == AnimState.PLAYING_BACKWARD ? 0 : 1;

            controller = new AnimationController(time, animationMaxDeploy);
            SSTUAnimData animationData;

            len = allNodes.Length;
            for (int i = 0; i < len; i++)
            {
                animationData = new SSTUAnimData(allNodes[i], part.gameObject.transform.FindRecursive("model"));
                controller.addAnimationData(animationData);
            }
            controller.restorePreviousAnimationState(prevState, 1f);
            controller.setStateChangeCallback(onAnimationStateChange);
        }
Exemplo n.º 27
0
        private void initialize()
        {
            constraints.Clear();
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            ConfigNode[] lookConstraintNodes = node.GetNodes("LOOK_CONST");
            foreach (ConfigNode lcn in lookConstraintNodes)
            {
                loadLookConstraint(lcn);
            }

            ConfigNode[] lockedConstraintNodes = node.GetNodes("LOCKED_CONST");
            foreach (ConfigNode lcn in lockedConstraintNodes)
            {
                loadLockedConstraint(lcn);
            }
            updateConstraints();
        }
Exemplo n.º 28
0
        private void initialize()
        {
            if (initialized)
            {
                return;
            }
            initialized = true;
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);
            Transform  root = part.transform.FindRecursive("model").FindOrCreate(rootTransformName);

            models = new ModelModule <PositionedModelData, SSTUModelSwitch2>(part, this, root, ModelOrientation.TOP, nameof(modelPersistentData), nameof(currentModel), nameof(currentTexture));
            models.getSymmetryModule = m => m.models;
            models.setupModelList(ModelData.parseModels <PositionedModelData>(node.GetNodes("MODEL"), m => new PositionedModelData(m)));
            models.setupModel();
            models.model.updateScale(currentScale);
            models.updateModel();
            updateMassAndCost();
            updateAttachNodes(false);
        }
Exemplo n.º 29
0
        /// <summary>
        /// Loads all of the part definitions and values from the stashed config node data
        /// </summary>
        private void loadConfigData()
        {
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            noseModule = new ModelModule <SingleModelData, SSTUModularUpperStage>(part, this, getRootTransform("MUSNose"), ModelOrientation.TOP, nameof(nosePersistentData), nameof(currentNose), nameof(currentNoseTexture));
            noseModule.getSymmetryModule = m => m.noseModule;
            noseModule.setupModelList(SingleModelData.parseModels(node.GetNodes("NOSE")));
            noseModule.setupModel();

            upperModule = new ModelModule <SingleModelData, SSTUModularUpperStage>(part, this, getRootTransform("MUSUpper"), ModelOrientation.TOP, nameof(upperPersistentData), nameof(currentUpper), nameof(currentUpperTexture));
            upperModule.getSymmetryModule = m => m.upperModule;
            upperModule.setupModelList(SingleModelData.parseModels(node.GetNodes("UPPER")));
            upperModule.setupModel();

            intertankModule = new ModelModule <SingleModelData, SSTUModularUpperStage>(part, this, getRootTransform("MUSIntertank"), ModelOrientation.TOP, nameof(intertankPersistentData), nameof(currentIntertank), nameof(currentIntertankTexture));
            intertankModule.getSymmetryModule = m => m.intertankModule;
            intertankModule.setupModelList(SingleModelData.parseModels(node.GetNodes("INTERTANK")));
            intertankModule.setupModel();

            lowerModule = new ModelModule <SingleModelData, SSTUModularUpperStage>(part, this, getRootTransform("MUSLower"), ModelOrientation.TOP, nameof(lowerPersistentData), nameof(currentLower), nameof(currentLowerTexture));
            lowerModule.getSymmetryModule = m => m.lowerModule;
            lowerModule.setupModelList(SingleModelData.parseModels(node.GetNodes("LOWER")));
            lowerModule.setupModel();

            mountModule = new ModelModule <SingleModelData, SSTUModularUpperStage>(part, this, getRootTransform("MUSMount"), ModelOrientation.BOTTOM, nameof(mountPersistentData), nameof(currentMount), nameof(currentMountTexture));
            mountModule.getSymmetryModule = m => m.mountModule;
            mountModule.setupModelList(SingleModelData.parseModels(node.GetNodes("MOUNT")));
            mountModule.setupModel();

            rcsModule = new ModelModule <SSTUModularUpperStageRCS, SSTUModularUpperStage>(part, this, getRootTransform("MUSRCS"), ModelOrientation.CENTRAL, nameof(rcsPersistentData), nameof(currentRCS), nameof(currentRCSTexture));
            rcsModule.getSymmetryModule = m => m.rcsModule;
            rcsModule.setupModelList(SingleModelData.parseModels(node.GetNodes("RCS"), m => new SSTUModularUpperStageRCS(m)));
            rcsModule.setupModel();
            updateRCSModule();

            if (!splitTank)
            {
                intertankModule.model.destroyCurrentModel();
                lowerModule.model.destroyCurrentModel();
            }
        }
Exemplo n.º 30
0
        private void initialize()
        {
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);// SSTUStockInterop.getPartModuleConfig(part, this);

            ConfigNode[] animNodes = node.GetNodes("ANIMATION");
            int          len       = animNodes.Length;

            ConfigNode[] allNodes = null;
            if (!String.IsNullOrEmpty(animationName))
            {
                allNodes = new ConfigNode[len + 1];
                for (int i = 0; i < len; i++)
                {
                    allNodes[i] = animNodes[i];
                }
                ConfigNode legacyNode = new ConfigNode("ANIMATION");
                legacyNode.AddValue("name", animationName);
                legacyNode.AddValue("speed", animationSpeed);
                legacyNode.AddValue("layer", animationLayer);
                allNodes[len] = legacyNode;
            }
            else
            {
                allNodes = animNodes;
            }

            controller = new AnimationController();
            SSTUAnimData animationData;

            len = allNodes.Length;
            for (int i = 0; i < len; i++)
            {
                animationData = new SSTUAnimData(allNodes[i], part.gameObject.transform.FindRecursive("model"));
                controller.addAnimationData(animationData);
            }
            AnimState prevState = (AnimState)Enum.Parse(typeof(AnimState), persistentState);

            controller.restorePreviousAnimationState(prevState);
            controller.setStateChangeCallback(onAnimationStateChange);
        }