Beispiel #1
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);
            ConfigNode node = SSTUStockInterop.getPartModuleConfig(part, this);

            techLimitMaxDiameter = SSTUStockInterop.getTechLimit(techLimitSet);
            if (diameter > techLimitMaxDiameter)
            {
                diameter = techLimitMaxDiameter;
            }
            fuelType = VolumeContainerLoader.getPreset(fuelPreset);
            float max = techLimitMaxDiameter < maxDiameter ? techLimitMaxDiameter : maxDiameter;

            this.updateUIFloatEditControl("height", minHeight, maxHeight, heightIncrement * 2, heightIncrement, heightIncrement * 0.05f, true, height);
            this.updateUIFloatEditControl("diameter", minDiameter, max, diameterIncrement * 2, diameterIncrement, diameterIncrement * 0.05f, true, diameter);
            locateTransforms();
            updateModelScales();
            updateModelPositions();
            updateAttachNodes(false);

            //can just check if part has -any- resources? if it does, then don't touch it... if it does not, then put some there (as long as it is not the prefab...)
            if (!initializedResources && (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor))
            {
                initializedResources = true;
                updatePartResources();
            }
            updateEditorFields();
            Fields["height"].uiControlEditor.onFieldChanged   = onHeightUpdated;
            Fields["diameter"].uiControlEditor.onFieldChanged = onDiameterUpdated;
        }
        private void initialize()
        {
            if (initialized)
            {
                return;
            }
            initialized = true;
            ConfigNode node = SSTUStockInterop.getPartModuleConfig(part, this);

            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");

            techLimitMaxDiameter = SSTUStockInterop.getTechLimit(techLimitSet);
            if (currentTopDiameter > techLimitMaxDiameter)
            {
                currentTopDiameter = techLimitMaxDiameter;
            }
            if (currentBottomDiameter > techLimitMaxDiameter)
            {
                currentBottomDiameter = techLimitMaxDiameter;
            }

            fuelType = VolumeContainerLoader.getPreset(fuelPreset);

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

            setupEngineModels(modelBase);
            minHeight = engineHeight * 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();
            updateNodePositions(false);
            if (!initializedResources && (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor))
            {
                initializedResources = true;
                updateResources();
            }
            updatePartMass();
            updateEngineThrust();
        }