Ejemplo n.º 1
0
 /// <summary>
 /// Update the current fairing modules (top, centra, and bottom) for the current model-module configuration (diameters, positions).
 /// </summary>
 /// <param name="userInput"></param>
 private void updateFairing(bool userInput)
 {
     ModuleROTNodeFairing[] modules = part.GetComponents <ModuleROTNodeFairing>();
     if (centralFairingIndex >= 0 && centralFairingIndex < modules.Length)
     {
         bool enabled = coreModule.fairingEnabled;
         ModuleROTNodeFairing coreFairing = modules[centralFairingIndex];
         float top = coreModule.fairingTop;
         float bot = coreModule.fairingBottom;
         ROTFairingUpdateData data = new ROTFairingUpdateData();
         data.setTopY(top);
         data.setTopRadius(currentDiameter * 0.5f);
         data.setBottomY(bot);
         data.setBottomRadius(currentDiameter * 0.5f);
         data.setEnable(enabled);
         coreFairing.updateExternal(data);
     }
     if (topFairingIndex >= 0 && topFairingIndex < modules.Length)
     {
         ROTModelModule <ModuleROTank> moduleForUpperFiaring = getUpperFairingModelModule();
         bool enabled = moduleForUpperFiaring.fairingEnabled;
         ModuleROTNodeFairing topFairing = modules[topFairingIndex];
         float topFairingBottomY         = moduleForUpperFiaring.fairingBottom;
         ROTFairingUpdateData data       = new ROTFairingUpdateData();
         data.setTopY(getPartTopY());
         data.setBottomY(topFairingBottomY);
         data.setBottomRadius(currentDiameter * 0.5f);
         data.setEnable(enabled);
         if (userInput)
         {
             data.setTopRadius(currentDiameter * 0.5f);
         }
         topFairing.updateExternal(data);
     }
     if (bottomFairingIndex >= 0 && bottomFairingIndex < modules.Length)
     {
         ROTModelModule <ModuleROTank> moduleForLowerFairing = getLowerFairingModelModule();
         bool enabled = moduleForLowerFairing.fairingEnabled;
         ModuleROTNodeFairing bottomFairing = modules[bottomFairingIndex];
         float bottomFairingTopY            = moduleForLowerFairing.fairingTop;
         ROTFairingUpdateData data          = new ROTFairingUpdateData();
         data.setTopRadius(currentDiameter * 0.5f);
         data.setTopY(bottomFairingTopY);
         data.setEnable(enabled);
         if (userInput)
         {
             data.setBottomRadius(currentDiameter * 0.5f);
         }
         bottomFairing.updateExternal(data);
     }
 }
Ejemplo n.º 2
0
 private void updateFromExternalData(ROTFairingUpdateData eData)
 {
     //MonoBehaviour.print("Updating fairing from external interaction ");
     if (fairingParts == null)
     {
         MonoBehaviour.print("ERROR: Fairing parts are null for external update");
     }
     foreach (ROTNodeFairingData data in fairingParts)
     {
         if (eData.hasTopY && data.canAdjustTop)
         {
             if (eData.topY != data.topY)
             {
                 needsRebuilt = fairingCreated;
             }
             data.topY = eData.topY;
             //MonoBehaviour.print("Set top pos: " + eData.topY);
         }
         if (eData.hasBottomY && data.canAdjustBottom)
         {
             if (eData.bottomY != data.bottomY)
             {
                 needsRebuilt = fairingCreated;
             }
             data.bottomY = eData.bottomY;
             //MonoBehaviour.print("Set bot pos: " + eData.bottomY);
         }
         if (eData.hasTopRad && data.canAdjustTop)
         {
             if (eData.topRadius != data.topRadius)
             {
                 needsRebuilt = fairingCreated;
             }
             data.topRadius = eData.topRadius;
             guiTopDiameter = data.topRadius * 2f;
             //MonoBehaviour.print("Set top rad: " + eData.topRadius);
         }
         if (eData.hasBottomRad && data.canAdjustBottom)
         {
             if (eData.bottomRadius != data.bottomRadius)
             {
                 needsRebuilt = fairingCreated;
             }
             data.bottomRadius = eData.bottomRadius;
             guiBottomDiameter = data.bottomRadius * 2f;
             //MonoBehaviour.print("Set bot rad: " + eData.bottomRadius);
         }
     }
     if (eData.hasEnable)
     {
         fairingForceDisabled = !eData.enable;
         //MonoBehaviour.print("Set enable: " + eData.enable);
     }
     else
     {
         fairingForceDisabled = false;//default to NOT force disabled
     }
     if (fairingCreated && fairingForceDisabled)
     {
         needsRebuilt = false;
         destroyFairing();
     }
     else
     {
         needsStatusUpdate = true;
     }
     needsGuiUpdate     = true;
     externalUpdateData = null;
 }
Ejemplo n.º 3
0
 public void updateExternal(ROTFairingUpdateData data)
 {
     externalUpdateData = data;
 }