Exemplo n.º 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);
            }
            ROLModInterop.OnPartGeometryUpdate(part, true);
        }
Exemplo n.º 2
0
        private void locateSolverEngines()
        {
            if (ROLModInterop.getSolverEngineModule(part, engineID) is ModuleEngines solverEnginesModule)
            {
                MethodInfo getter = ROLModInterop.getSolverEngineTempProperty().GetGetMethod();

                getSolverChamberTemp = (Func <double>)Delegate.CreateDelegate(typeof(Func <double>), solverEnginesModule, getter);
            }
        }
Exemplo n.º 3
0
 public override void OnStart(StartState state)
 {
     locateAnimatedTransforms();
     locateEngineModule();
     if (ROLModInterop.IsSolverEnginesInstalled() && !useThrottle)
     {
         locateSolverEngines();
     }
     else if (!ROLModInterop.IsSolverEnginesInstalled() && !useThrottle && HighLogic.LoadedSceneIsFlight)
     {
         StartCoroutine(updateHeatCalc());
     }
 }
Exemplo n.º 4
0
        public void DestroyFairing()
        {
            //MonoBehaviour.print("Destroying Fairing");
            int len = fairingParts.Length;

            for (int i = 0; i < len; i++)
            {
                fairingParts[i].DestroyFairing();
            }
            if (fairingCreated)
            {
                ROLModInterop.OnPartGeometryUpdate(part, true);
            }
            fairingCreated = false;
        }
Exemplo n.º 5
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();
            ROLModInterop.OnPartTextureUpdated(part);
        }
Exemplo n.º 6
0
 private void JettisonFairing()
 {
     //MonoBehaviour.print("Jettisoning fairing - prev: "+prevAttachedPart);
     if (numOfSections == 1 && prevAttachedPart != null)
     {
         //MonoBehaviour.print("Reparenting fairing to: " + prevAttachedPart);
         ReparentFairing(prevAttachedPart);
         ROLModInterop.OnPartGeometryUpdate(prevAttachedPart, true);//update other parts highlight renderers, to add the new fairing bits to it.
     }
     else
     {
         //MonoBehaviour.print("Jettisoning Panels: " + fairingParts.Length);
         foreach (ROLNodeFairingData data in fairingParts)
         {
             data.JettisonPanels(part);
         }
     }
     prevAttachedPart  = null;
     fairingJettisoned = true;
     fairingEnabled    = false;
     DestroyFairing();//cleanup any leftover bits in fairing containers
 }
Exemplo n.º 7
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()
 {
     ROLModInterop.onPartGeometryUpdate(part, true);
 }
Exemplo n.º 8
0
        private void UpdateTankVolume(bool lw)
        {
            if (!lw)
            {
                float totalVol = noseModule.moduleVolume + coreModule.moduleVolume + mountModule.moduleVolume;
                SendVolumeChangedEvent(totalVol);
                return;
            }

            Action <ModuleROTank> modelChangedAction = (m) =>
            {
                m.updateModulePositions();
                m.updateDimensions();
                m.updateAttachNodes(true);
                m.updateDragCubes();
                if (scaleMass)
                {
                    m.updateMass();
                }
                if (scaleCost)
                {
                    m.updateCost();
                }
                ROLModInterop.realFuelsVolumeUpdate(m.part, m.effectiveVolume);
            };

            float horScale   = currentDiameter / coreModule.definition.diameter;
            float domeLength = currentDiameter / 2;

            noseEffectiveLength  = horScale * noseModule.definition.effectiveLength;
            mountEffectiveLength = horScale * mountModule.definition.effectiveLength;
            coreEffectiveLength  = currentLength - domeLength;
            effectiveLength      = noseEffectiveLength + mountEffectiveLength + coreEffectiveLength;

            /*
             * debug("================================================");
             * debug("<color=green>EFFECTIVE LENGTH INFORMATION</color>");
             * debug($"horScale: {horScale}, domeLength: {domeLength}");
             * debug($"noseEffectiveLength: {noseEffectiveLength}, mountEffectiveLength: {mountEffectiveLength}, coreEffectiveLength: {coreEffectiveLength}");
             * debug($"effectiveLength: {effectiveLength}");
             * debug("================================================");
             */

            // Set the minimum length based on domeLength
            minLength = Math.Max(0.1f, domeLength - (noseEffectiveLength + mountEffectiveLength));

            // Update the float controller to reset the proper minimum length
            this.ROLupdateUIFloatEditControl(nameof(currentLength), minLength, maxLength, diameterLargeStep, diameterSmallStep, diameterSlideStep, true, currentLength);

            // Set the tank length to be the same size as the minLength if it is currently smaller
            if (currentLength < minLength)
            {
                currentLength = minLength;
            }

            // Calculate the new volume
            // First, get the additional volume from the nose and mounts
            float noseDiameter = noseModule.definition.shouldInvert(noseModule.definition.orientation) ? noseModule.definition.upperDiameter : noseModule.definition.lowerDiameter;
            float noseScale    = currentDiameter / noseDiameter;

            noseScale = Mathf.Pow(noseScale, 3);

            float mountDiameter = mountModule.definition.shouldInvert(mountModule.definition.orientation) ? mountModule.definition.lowerDiameter : mountModule.definition.upperDiameter;
            float mountScale    = currentDiameter / mountDiameter;

            mountScale = Mathf.Pow(mountScale, 3);

            noseAdditionalVol  = noseScale * noseModule.definition.additionalVolume * 1000f;
            mountAdditionalVol = mountScale * mountModule.definition.additionalVolume * 1000f;

            // Calculate the volume of the main tank
            float r = currentDiameter / 2;

            effectiveVolume  = (EllipsoidVolume(r, r, r / 2) + CylinderVolume(r, effectiveLength)) * 1000f;
            effectiveVolume += noseAdditionalVol + mountAdditionalVol;

            /*
             * debug("================================================");
             * debug("<color=blue>EFFECTIVE VOLUME INFORMATION</color>");
             * debug($"noseScale: {noseScale}, mountScale: {mountScale}");
             * debug($"noseAdditionalOrig: {noseModule.definition.additionalVolume}, noseAdditionalVol: {noseAdditionalVol}, coreAdditionalOrig: {mountModule.definition.additionalVolume}, mountAdditionalVol: {mountAdditionalVol}");
             * debug($"origEffectiveVolume: {effectiveVolume - noseAdditionalVol - mountAdditionalVol}");
             * debug($"effectiveVolume: {effectiveVolume}");
             * debug("================================================");
             */

            this.ROLactionWithSymmetry(modelChangedAction);
            ROLStockInterop.fireEditorUpdate();
        }