Example #1
0
        private void buildFairing()
        {
            //MonoBehaviour.print("Building Fairing "+guiTopDiameter+" : "+guiBottomDiameter);
            needsRebuilt   = false;
            fairingCreated = true;
            int len = fairingParts.Length;

            if (HighLogic.LoadedSceneIsEditor)//only enforce editor sizing while in the editor;
            {
                for (int i = 0; i < len; i++)
                {
                    //MonoBehaviour.print("pt t/b " + fairingParts[i].topRadius + " : " + fairingParts[i].bottomRadius);
                    if (fairingParts[i].canAdjustTop && canAdjustTop)
                    {
                        fairingParts[i].topRadius = guiTopDiameter * 0.5f;
                    }
                    if (fairingParts[i].canAdjustBottom && canAdjustBottom)
                    {
                        fairingParts[i].bottomRadius = guiBottomDiameter * 0.5f;
                    }
                    //MonoBehaviour.print("pt t/b 2" + fairingParts[i].topRadius + " : " + fairingParts[i].bottomRadius);
                }
            }
            for (int i = 0; i < len; i++)
            {
                fairingParts[i].generateColliders = this.generateColliders;
                fairingParts[i].facesPerCollider  = 1;
                fairingParts[i].numOfSections     = (int)Math.Round(numOfSections);
                fairingParts[i].createFairing(editorTransparency ? 0.25f : 1f);
            }
            ROTModInterop.onPartGeometryUpdate(part, true);
        }
Example #2
0
        public void destroyFairing()
        {
            //MonoBehaviour.print("Destroying Fairing");
            int len = fairingParts.Length;

            for (int i = 0; i < len; i++)
            {
                fairingParts[i].destroyFairing();
            }
            if (fairingCreated)
            {
                ROTModInterop.onPartGeometryUpdate(part, true);
            }
            fairingCreated = false;
        }
Example #3
0
        private void updateTextureSet(bool useDefaults)
        {
            TextureSet s = TexturesUnlimitedLoader.getTextureSet(currentTextureSet);

            RecoloringData[] colors = useDefaults ? s.maskColors : getSectionColors(string.Empty);
            int len = fairingParts.Length;

            for (int i = 0; i < len; i++)
            {
                fairingParts[i].fairingBase.enableTextureSet(currentTextureSet, colors);
            }
            if (useDefaults)
            {
                recolorHandler.setColorData(colors);
            }
            updateOpacity();
            ROTModInterop.onPartTextureUpdated(part);
        }
Example #4
0
 private void jettisonFairing()
 {
     //MonoBehaviour.print("Jettisoning fairing - prev: "+prevAttachedPart);
     if (numOfSections == 1 && prevAttachedPart != null)
     {
         //MonoBehaviour.print("Reparenting fairing to: " + prevAttachedPart);
         reparentFairing(prevAttachedPart);
         ROTModInterop.onPartGeometryUpdate(prevAttachedPart, true);//update other parts highlight renderers, to add the new fairing bits to it.
     }
     else
     {
         //MonoBehaviour.print("Jettisoning Panels: " + fairingParts.Length);
         foreach (ROTNodeFairingData data in fairingParts)
         {
             data.jettisonPanels(part);
         }
     }
     prevAttachedPart  = null;
     fairingJettisoned = true;
     fairingEnabled    = false;
     destroyFairing();//cleanup any leftover bits in fairing containers
 }
Example #5
0
 /// <summary>
 /// Calls the generic ROT procedural drag-cube updating routines.  Will update the drag cubes for whatever the current model state is.
 /// </summary>
 private void updateDragCubes()
 {
     ROTModInterop.onPartGeometryUpdate(part, true);
 }
Example #6
0
        /// <summary>
        /// Initialize the UI controls, including default values, and specifying delegates for their 'onClick' methods.<para/>
        /// All UI based interaction code will be defined/run through these delegates.
        /// </summary>
        private void initializeUI()
        {
            Action <ModuleROTank> modelChangedAction = (m) =>
            {
                m.updateModulePositions();
                m.updateDimensions();
                m.updateAttachNodes(true);
                m.updateFairing(true);
                m.updateAvailableVariants();
                m.updateDragCubes();
                ROTModInterop.updateResourceVolume(m.part);
            };

            //set up the core variant UI control
            string[] variantNames = ROTUtils.getNames(variantSets.Values, m => m.variantName);
            this.updateUIChooseOptionControl(nameof(currentVariant), variantNames, variantNames, true, currentVariant);
            Fields[nameof(currentVariant)].guiActiveEditor = variantSets.Count > 1;

            Fields[nameof(currentVariant)].uiControlEditor.onFieldChanged = (a, b) =>
            {
                //TODO find variant set for the currently enabled core model
                //query the index from that variant set
                ModelDefinitionVariantSet prevMdvs = getVariantSet(coreModule.definition.name);
                //this is the index of the currently selected model within its variant set
                int previousIndex = prevMdvs.indexOf(coreModule.layoutOptions);
                //grab ref to the current/new variant set
                ModelDefinitionVariantSet mdvs = getVariantSet(currentVariant);
                //and a reference to the model from same index out of the new set ([] call does validation internally for IAOOBE)
                ModelDefinitionLayoutOptions newCoreDef = mdvs[previousIndex];
                //now, call model-selected on the core model to update for the changes, including symmetry counterpart updating.
                this.actionWithSymmetry(m =>
                {
                    m.currentVariant = currentVariant;
                    m.coreModule.modelSelected(newCoreDef.definition.name);
                    modelChangedAction(m);
                });
            };

            Fields[nameof(currentDiameter)].uiControlEditor.onFieldChanged = (a, b) =>
            {
                this.actionWithSymmetry(m =>
                {
                    if (m != this)
                    {
                        m.currentDiameter = this.currentDiameter;
                    }
                    modelChangedAction(m);
                    m.prevDiameter = m.currentDiameter;
                });
                ROTStockInterop.fireEditorUpdate();
            };

            Fields[nameof(currentVScale)].uiControlEditor.onFieldChanged = (a, b) =>
            {
                this.actionWithSymmetry(m =>
                {
                    if (m != this)
                    {
                        m.currentVScale = this.currentVScale;
                    }
                    modelChangedAction(m);
                });
                ROTStockInterop.fireEditorUpdate();
            };

            Fields[nameof(currentNose)].uiControlEditor.onFieldChanged = (a, b) =>
            {
                noseModule.modelSelected(a, b);
                this.actionWithSymmetry(modelChangedAction);
                ROTStockInterop.fireEditorUpdate();
            };

            Fields[nameof(currentCore)].uiControlEditor.onFieldChanged = (a, b) =>
            {
                coreModule.modelSelected(a, b);
                this.actionWithSymmetry(modelChangedAction);
                ROTStockInterop.fireEditorUpdate();
            };

            Fields[nameof(currentMount)].uiControlEditor.onFieldChanged = (a, b) =>
            {
                mountModule.modelSelected(a, b);
                this.actionWithSymmetry(modelChangedAction);
                ROTStockInterop.fireEditorUpdate();
            };

            //------------------MODEL DIAMETER SWITCH UI INIT---------------------//
            if (maxDiameter == minDiameter)
            {
                Fields[nameof(currentDiameter)].guiActiveEditor = false;
            }
            else
            {
                this.updateUIFloatEditControl(nameof(currentDiameter), minDiameter, maxDiameter, diameterLargeStep, diameterSmallStep, diameterSlideStep, true, currentDiameter);
            }
            Fields[nameof(currentVScale)].guiActiveEditor = enableVScale;

            //------------------MODULE TEXTURE SWITCH UI INIT---------------------//
            Fields[nameof(currentNoseTexture)].uiControlEditor.onFieldChanged  = noseModule.textureSetSelected;
            Fields[nameof(currentCoreTexture)].uiControlEditor.onFieldChanged  = coreModule.textureSetSelected;
            Fields[nameof(currentMountTexture)].uiControlEditor.onFieldChanged = mountModule.textureSetSelected;

            if (HighLogic.LoadedSceneIsEditor)
            {
                GameEvents.onEditorShipModified.Add(new EventData <ShipConstruct> .OnEvent(onEditorVesselModified));
            }
        }