Beispiel #1
0
        private void SetEngineInfo()
        {
            var protoModuleEngine = PartExtensions.GetProtoModuleEngine(selectedPart);

            if (protoModuleEngine != null)
            {
                infoItems.Add(PartInfoItem.Create("Thrust", Units.ToForce(protoModuleEngine.MinimumThrust, protoModuleEngine.MaximumThrust)));
                infoItems.Add(PartInfoItem.Create("Isp", Units.ConcatF(protoModuleEngine.GetSpecificImpulse(1.0f), protoModuleEngine.GetSpecificImpulse(0.0f)) + "s"));
                if (protoModuleEngine.Propellants.Count > 0)
                {
                    infoItems.Add(PartInfoItem.Create("Propellants"));

                    float totalRatio = 0.0f;
                    for (int i = 0; i < protoModuleEngine.Propellants.Count; ++i)
                    {
                        totalRatio = totalRatio + protoModuleEngine.Propellants[i].ratio;
                    }

                    for (int i = 0; i < protoModuleEngine.Propellants.Count; ++i)
                    {
                        var propellant = protoModuleEngine.Propellants[i];
                        infoItems.Add(PartInfoItem.Create("\t" + propellant.name, (propellant.ratio / totalRatio).ToPercent()));
                    }
                }
            }
        }
Beispiel #2
0
 private void SetMassItems()
 {
     if (selectedPart.physicalSignificance == Part.PhysicalSignificance.FULL)
     {
         infoItems.Add(PartInfoItem.Create("Mass", Units.ToMass(PartExtensions.GetDryMass(selectedPart), PartExtensions.GetWetMass(selectedPart))));
     }
 }
Beispiel #3
0
        private void SetGeneratorInfo()
        {
            var moduleGenerator = PartExtensions.GetModule <ModuleGenerator>(selectedPart);

            if (moduleGenerator != null)
            {
                if (moduleGenerator.resHandler.inputResources.Count > 0)
                {
                    infoItems.Add(PartInfoItem.Create("Generator Input"));
                    for (int i = 0; i < moduleGenerator.resHandler.inputResources.Count; ++i)
                    {
                        var generatorResource = moduleGenerator.resHandler.inputResources[i];
                        infoItems.Add(PartInfoItem.Create("\t" + generatorResource.name, generatorResource.rate.ToRate()));
                    }
                }

                if (moduleGenerator.resHandler.outputResources.Count > 0)
                {
                    infoItems.Add(PartInfoItem.Create("Generator Output"));
                    for (int i = 0; i < moduleGenerator.resHandler.outputResources.Count; ++i)
                    {
                        var generatorResource = moduleGenerator.resHandler.outputResources[i];
                        infoItems.Add(PartInfoItem.Create("\t" + generatorResource.name, generatorResource.rate.ToRate()));
                    }
                }

                if (moduleGenerator.isAlwaysActive)
                {
                    infoItems.Add(PartInfoItem.Create("Generator is Always Active"));
                }
            }
        }
 private void SetGeneratorInfo()
 {
     moduleGenerator = selectedPart.GetModule <ModuleGenerator>();
     if (moduleGenerator != null)
     {
         if (moduleGenerator.inputList.Count > 0)
         {
             infoItems.Add(PartInfoItem.Create("Generator Input"));
             for (int i = 0; i < moduleGenerator.inputList.Count; ++i)
             {
                 generatorResource = moduleGenerator.inputList[i];
                 infoItems.Add(PartInfoItem.Create("\t" + generatorResource.name, generatorResource.rate.ToRate()));
             }
         }
         if (moduleGenerator.outputList.Count > 0)
         {
             infoItems.Add(PartInfoItem.Create("Generator Output"));
             for (int i = 0; i < moduleGenerator.outputList.Count; ++i)
             {
                 generatorResource = moduleGenerator.outputList[i];
                 infoItems.Add(PartInfoItem.Create("\t" + generatorResource.name, generatorResource.rate.ToRate()));
             }
         }
         if (moduleGenerator.isAlwaysActive)
         {
             infoItems.Add(PartInfoItem.Create("Generator is Always Active"));
         }
     }
 }
Beispiel #5
0
 private void SetSasInfo()
 {
     if (PartExtensions.HasModule <ModuleSAS>(selectedPart))
     {
         infoItems.Add(PartInfoItem.Create("SAS Equiped"));
     }
 }
Beispiel #6
0
        private void SetResourceItems()
        {
            bool visibleResources = false;

            for (int i = 0; i < selectedPart.Resources.dict.Count; ++i)
            {
                if (selectedPart.Resources.dict.At(i).hideFlow == false)
                {
                    visibleResources = true;
                    break;
                }
            }

            if (visibleResources)
            {
                infoItems.Add(PartInfoItem.Create("Resources"));
                for (int i = 0; i < selectedPart.Resources.dict.Count; ++i)
                {
                    var partResource = selectedPart.Resources.dict.At(i);

                    if (partResource.hideFlow == false)
                    {
                        infoItems.Add(PartResourceExtensions.GetDensity(partResource) > 0
                                          ? PartInfoItem.Create("\t" + partResource.info.name, "(" + PartResourceExtensions.GetMass(partResource).ToMass() + ") " + partResource.amount.ToString("F1"))
                                          : PartInfoItem.Create("\t" + partResource.info.name, partResource.amount.ToString("F1")));
                    }
                }
            }
        }
Beispiel #7
0
 private void SetScienceContainerInfo()
 {
     if (PartExtensions.HasModule <ModuleScienceContainer>(selectedPart))
     {
         infoItems.Add(PartInfoItem.Create("Science Container"));
     }
 }
        private void SetVesselInfo()
        {
            SimManager.Gravity = CelestialBodies.SelectedBody.Gravity;

            if (BuildAdvanced.Instance.ShowAtmosphericDetails)
            {
                SimManager.Atmosphere = CelestialBodies.SelectedBody.GetAtmospheres(BuildAdvanced.Altitude);
            }
            else
            {
                SimManager.Atmosphere = 0.0;
            }

            SimManager.RequestSimulation();
            SimManager.TryStartSimulation();

            if (lastStage != null)
            {
                PartInfoItem.Release(infoItems);
                infoItems.Clear();
                infoItems.Add(PartInfoItem.Create("Delta-V", lastStage.deltaV.ToString("N0") + " / " + lastStage.totalDeltaV.ToString("N0") + "m/s"));
                infoItems.Add(PartInfoItem.Create("Mass", Units.ToMass(lastStage.mass, lastStage.totalMass)));
                infoItems.Add(PartInfoItem.Create("TWR", lastStage.thrustToWeight.ToString("F2") + " (" + lastStage.maxThrustToWeight.ToString("F2") + ")"));
                infoItems.Add(PartInfoItem.Create("Parts", lastStage.partCount + " / " + lastStage.totalPartCount));
            }
        }
Beispiel #9
0
 private void SetSingleActivationInfo()
 {
     if (PartExtensions.HasModule <ModuleAnimateGeneric>(selectedPart, m => m.isOneShot))
     {
         infoItems.Add(PartInfoItem.Create("Single Activation"));
     }
 }
 private void SetGimbalInfo()
 {
     moduleGimbal = selectedPart.GetModule <ModuleGimbal>();
     if (moduleGimbal != null)
     {
         infoItems.Add(PartInfoItem.Create("Thrust Vectoring", moduleGimbal.gimbalRange.ToString("F2")));
     }
 }
 private void SetRcsInfo()
 {
     moduleRcs = selectedPart.GetModule <ModuleRCS>();
     if (moduleRcs != null)
     {
         infoItems.Add(PartInfoItem.Create("Thruster Power", moduleRcs.thrusterPower.ToForce()));
         infoItems.Add(PartInfoItem.Create("Specific Impulse", Units.ConcatF(moduleRcs.atmosphereCurve.Evaluate(1.0f), moduleRcs.atmosphereCurve.Evaluate(0.0f)) + "s"));
     }
 }
Beispiel #12
0
        public static PartInfoItem New(string name, string value)
        {
            PartInfoItem obj = pool.Borrow();

            obj.Name  = name;
            obj.Value = value;

            return(obj);
        }
Beispiel #13
0
        public static PartInfoItem New(string name)
        {
            PartInfoItem obj = pool.Borrow();

            obj.Name  = name;
            obj.Value = string.Empty;

            return(obj);
        }
 private void SetParachuteInfo()
 {
     moduleParachute = selectedPart.GetModule <ModuleParachute>();
     if (moduleParachute != null)
     {
         infoItems.Add(PartInfoItem.Create("Deployed Drag", Units.ConcatF(moduleParachute.semiDeployedDrag, moduleParachute.fullyDeployedDrag)));
         infoItems.Add(PartInfoItem.Create("Deployment Altitude", moduleParachute.deployAltitude.ToDistance()));
         infoItems.Add(PartInfoItem.Create("Deployment Pressure", moduleParachute.minAirPressureToOpen.ToString("F2")));
     }
 }
 private void SetTransmitterInfo()
 {
     moduleDataTransmitter = selectedPart.GetModule <ModuleDataTransmitter>();
     if (moduleDataTransmitter != null)
     {
         infoItems.Add(PartInfoItem.Create("Packet Size", moduleDataTransmitter.packetSize.ToString("F2") + " Mits"));
         infoItems.Add(PartInfoItem.Create("Bandwidth", (moduleDataTransmitter.packetInterval * moduleDataTransmitter.packetSize).ToString("F2") + "Mits/sec"));
         infoItems.Add(PartInfoItem.Create(moduleDataTransmitter.requiredResource, moduleDataTransmitter.packetResourceCost.ToString("F2") + "/Packet"));
     }
 }
Beispiel #16
0
        private void SetTransmitterInfo()
        {
            moduleDataTransmitter = selectedPart.GetModule <ModuleDataTransmitter>();
            if (moduleDataTransmitter != null)
            {
                infoItems.Add(PartInfoItem.Create("Packet Size", moduleDataTransmitter.packetSize.ToString("F2") + " Mits"));
                infoItems.Add(PartInfoItem.Create("Bandwidth", (moduleDataTransmitter.packetInterval * moduleDataTransmitter.packetSize).ToString("F2") + "Mits/sec"));

                // TODO: allow for multiple consumed resources
                infoItems.Add(PartInfoItem.Create(moduleDataTransmitter.GetConsumedResources()[0].name, moduleDataTransmitter.packetResourceCost.ToString("F2") + "/Packet"));
            }
        }
 private void SetDecouplerInfo()
 {
     protoModuleDecoupler = selectedPart.GetProtoModuleDecoupler();
     if (protoModuleDecoupler != null)
     {
         infoItems.Add(PartInfoItem.Create("Ejection Force", protoModuleDecoupler.EjectionForce.ToForce()));
         if (protoModuleDecoupler.IsOmniDecoupler)
         {
             infoItems.Add(PartInfoItem.Create("Omni-directional"));
         }
     }
 }
 private void SetAlternatorInfo()
 {
     moduleAlternator = selectedPart.GetModule <ModuleAlternator>();
     if (moduleAlternator != null)
     {
         infoItems.Add(PartInfoItem.Create("Alternator"));
         for (int i = 0; i < moduleAlternator.outputResources.Count; ++i)
         {
             moduleResource = moduleAlternator.outputResources[i];
             infoItems.Add(PartInfoItem.Create("\t" + moduleResource.name, moduleResource.rate.ToRate()));
         }
     }
 }
 private void SetScienceExperimentInfo()
 {
     moduleScienceExperiment = selectedPart.GetModule <ModuleScienceExperiment>();
     if (moduleScienceExperiment != null)
     {
         infoItems.Add(PartInfoItem.Create("Science Experiment", moduleScienceExperiment.experimentActionName));
         infoItems.Add(PartInfoItem.Create("\tTransmit Efficiency", moduleScienceExperiment.xmitDataScalar.ToPercent()));
         if (moduleScienceExperiment.rerunnable == false)
         {
             infoItems.Add(PartInfoItem.Create("\tSingle Usage"));
         }
     }
 }
 private void SetSolarPanelInfo()
 {
     moduleDeployableSolarPanel = selectedPart.GetModule <ModuleDeployableSolarPanel>();
     if (moduleDeployableSolarPanel != null)
     {
         infoItems.Add(PartInfoItem.Create("Charge Rate", moduleDeployableSolarPanel.chargeRate.ToRate()));
         if (moduleDeployableSolarPanel.isBreakable)
         {
             infoItems.Add(PartInfoItem.Create("Breakable"));
         }
         if (moduleDeployableSolarPanel.sunTracking)
         {
             infoItems.Add(PartInfoItem.Create("Sun Tracking"));
         }
     }
 }
 private void SetReactionWheelInfo()
 {
     moduleReactionWheel = selectedPart.GetModule <ModuleReactionWheel>();
     if (moduleReactionWheel != null)
     {
         infoItems.Add(PartInfoItem.Create("Reaction Wheel Torque"));
         infoItems.Add(PartInfoItem.Create("\tPitch", moduleReactionWheel.PitchTorque.ToTorque()));
         infoItems.Add(PartInfoItem.Create("\tRoll", moduleReactionWheel.RollTorque.ToTorque()));
         infoItems.Add(PartInfoItem.Create("\tYaw", moduleReactionWheel.YawTorque.ToTorque()));
         for (int i = 0; i < moduleReactionWheel.inputResources.Count; ++i)
         {
             moduleResource = moduleReactionWheel.inputResources[i];
             infoItems.Add(PartInfoItem.Create("\t" + moduleResource.name, moduleResource.rate.ToRate()));
         }
     }
 }
Beispiel #22
0
        private void SetSolarPanelInfo()
        {
            var moduleDeployableSolarPanel = PartExtensions.GetModule <ModuleDeployableSolarPanel>(selectedPart);

            if (moduleDeployableSolarPanel != null)
            {
                infoItems.Add(PartInfoItem.Create("Charge Rate", moduleDeployableSolarPanel.chargeRate.ToRate()));
                if (moduleDeployableSolarPanel.isBreakable)
                {
                    infoItems.Add(PartInfoItem.Create("Breakable"));
                }

                if (moduleDeployableSolarPanel.trackingBody == Sun.Instance)
                {
                    infoItems.Add(PartInfoItem.Create("Sun Tracking"));
                }
            }
        }
 private void Window(int windowId)
 {
     try
     {
         GUILayout.Label(selectedPart.partInfo.title, BuildOverlay.TitleStyle);
         if (showInfo)
         {
             for (int i = 0; i < infoItems.Count; ++i)
             {
                 partInfoItem = infoItems[i];
                 GUILayout.Space(2.0f);
                 GUILayout.BeginHorizontal();
                 if (partInfoItem.Value != null)
                 {
                     GUILayout.Label(partInfoItem.Name + ":", BuildOverlay.NameStyle);
                     GUILayout.Space(25.0f);
                     GUILayout.Label(partInfoItem.Value, BuildOverlay.ValueStyle);
                 }
                 else
                 {
                     GUILayout.Label(partInfoItem.Name, BuildOverlay.NameStyle);
                 }
                 GUILayout.EndHorizontal();
             }
         }
         else if (clickToOpen && namesOnly == false)
         {
             GUILayout.Space(2.0f);
             GUILayout.Label("Click middle mouse to show more info...", BuildOverlay.NameStyle);
         }
     }
     catch (Exception ex)
     {
         Logger.Exception(ex);
     }
 }
        protected void Update()
        {
            try
            {
                if (!Visible || Hidden || EditorLogic.RootPart == null || EditorLogic.fetch.editorScreen != EditorScreen.Parts)
                {
                    return;
                }

                position.x = Mathf.Clamp(Input.mousePosition.x + 16.0f, 0.0f, Screen.width - position.width);
                position.y = Mathf.Clamp(Screen.height - Input.mousePosition.y, 0.0f, Screen.height - position.height);
                if (position.x < Input.mousePosition.x + 20.0f)
                {
                    position.y = Mathf.Clamp(position.y + 20.0f, 0.0f, Screen.height - position.height);
                }
                if (position.x < Input.mousePosition.x + 16.0f && position.y < Screen.height - Input.mousePosition.y)
                {
                    position.x = Input.mousePosition.x - 3 - position.width;
                }

                part = EditorLogic.fetch.ship.parts.Find(p => p.stackIcon.highlightIcon) ?? EditorLogic.SelectedPart;
                if (part != null)
                {
                    if (!part.Equals(selectedPart))
                    {
                        selectedPart = part;
                        ResetInfo();
                    }
                    if (NamesOnly || skipFrame)
                    {
                        skipFrame = false;
                        return;
                    }

                    if (!showInfo && Input.GetMouseButtonDown(2))
                    {
                        showInfo = true;
                    }
                    else if (ClickToOpen && showInfo && Input.GetMouseButtonDown(2))
                    {
                        ResetInfo();
                    }

                    if (showInfo)
                    {
                        PartInfoItem.Release(infoItems);
                        infoItems.Clear();
                        SetCostInfo();
                        SetMassItems();
                        SetResourceItems();
                        SetEngineInfo();
                        SetAlternatorInfo();
                        SetGimbalInfo();
                        SetRcsInfo();
                        SetParachuteInfo();
                        SetSasInfo();
                        SetReactionWheelInfo();
                        SetSolarPanelInfo();
                        SetGeneratorInfo();
                        SetDecouplerInfo();
                        SetTransmitterInfo();
                        SetScienceExperimentInfo();
                        SetScienceContainerInfo();
                        SetSingleActivationInfo();
                    }
                }
                else
                {
                    selectedPart = null;
                }
            }
            catch (Exception ex)
            {
                Logger.Exception(ex);
            }
        }
Beispiel #25
0
 private void SetCostInfo()
 {
     infoItems.Add(PartInfoItem.Create("Cost", Units.ConcatF(PartExtensions.GetCostDry(selectedPart), PartExtensions.GetCostWet(selectedPart))));
 }
Beispiel #26
0
        protected void Update()
        {
            try
            {
                if (!Visible || Hidden || EditorLogic.RootPart == null || (EditorPanels.Instance.IsMouseOver() && IsPointerOverStaging() == false))
                {
                    return;
                }

                position.x = Mathf.Clamp(Input.mousePosition.x + 16.0f, 0.0f, Screen.width - position.width);
                position.y = Mathf.Clamp(Screen.height - Input.mousePosition.y, 0.0f, Screen.height - position.height);
                if (position.x < Input.mousePosition.x + 20.0f)
                {
                    position.y = Mathf.Clamp(position.y + 20.0f, 0.0f, Screen.height - position.height);
                }

                if (position.x < Input.mousePosition.x + 16.0f && position.y < Screen.height - Input.mousePosition.y)
                {
                    position.x = Input.mousePosition.x - 3 - position.width;
                }

                RaycastHit rayHit;
                Part       part = null;
                if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out rayHit))
                {
                    // MyLogger.Log("Raycast returned true");
                    part = rayHit.transform.GetComponent <Part>();
                }
                else
                {
                    // MyLogger.Log("Raycast returned false");
                    part = EditorLogic.fetch.ship.parts.Find(p => p.HighlightActive) ?? EditorLogic.SelectedPart;
                }

                if (part != null)
                {
                    if (!part.Equals(selectedPart))
                    {
                        selectedPart = part;
                        ResetInfo();
                    }

                    if (NamesOnly || skipFrame)
                    {
                        skipFrame = false;
                        return;
                    }

                    if (!showInfo && Input.GetKeyDown(KeyBinder.PartInfoShowHide))
                    {
                        showInfo = true;
                    }
                    else if (ClickToOpen && showInfo && Input.GetKeyDown(KeyBinder.PartInfoShowHide))
                    {
                        ResetInfo();
                    }

                    if (showInfo)
                    {
                        PartInfoItem.Release(infoItems);
                        infoItems.Clear();
                        SetCostInfo();
                        SetMassItems();
                        SetResourceItems();
                        SetEngineInfo();
                        SetAlternatorInfo();
                        SetGimbalInfo();
                        SetRcsInfo();
                        SetParachuteInfo();
                        SetSasInfo();
                        SetReactionWheelInfo();
                        SetSolarPanelInfo();
                        SetGeneratorInfo();
                        SetDecouplerInfo();
                        SetTransmitterInfo();
                        SetScienceExperimentInfo();
                        SetScienceContainerInfo();
                        SetSingleActivationInfo();
                    }
                }
                else
                {
                    selectedPart = null;
                }
            }
            catch (Exception ex)
            {
                MyLogger.Exception(ex);
            }
        }
Beispiel #27
0
 private void SetCostInfo()
 {
     infoItems.Add(PartInfoItem.Create("Cost", Units.ConcatF(selectedPart.GetCostDry(), selectedPart.GetCostWet())));
 }
Beispiel #28
0
 private static void Reset(PartInfoItem obj)
 {
     obj.Name  = string.Empty;
     obj.Value = string.Empty;
 }
 private void Window(int windowId)
 {
     try
     {
         GUILayout.Label(selectedPart.partInfo.title, BuildOverlay.TitleStyle);
         if (showInfo)
         {
             for (int i = 0; i < infoItems.Count; ++i)
             {
                 partInfoItem = infoItems[i];
                 GUILayout.Space(2.0f);
                 GUILayout.BeginHorizontal();
                 if (partInfoItem.Value != null)
                 {
                     GUILayout.Label(partInfoItem.Name + ":", BuildOverlay.NameStyle);
                     GUILayout.Space(25.0f);
                     GUILayout.Label(partInfoItem.Value, BuildOverlay.ValueStyle);
                 }
                 else
                 {
                     GUILayout.Label(partInfoItem.Name, BuildOverlay.NameStyle);
                 }
                 GUILayout.EndHorizontal();
             }
         }
         else if (clickToOpen && namesOnly == false)
         {
             GUILayout.Space(2.0f);
             GUILayout.Label("Click middle mouse to show more info...", BuildOverlay.NameStyle);
         }
     }
     catch (Exception ex)
     {
         MyLogger.Exception(ex);
     }
 }
 private static void Reset(PartInfoItem obj)
 {
     obj.Name = string.Empty;
     obj.Value = string.Empty;
 }