public override string GetInfo()
        {
            if (!CompatibilityChecker.IsAllCompatible())
            {
                return(string.Empty);
            }
            //Info in the editor part window
            float tmpPartMass = TotalMass;

            massDelta = 0;
            if (!(part.partInfo?.partPrefab is null))
            {
                massDelta = tmpPartMass - part.partInfo.partPrefab.mass;
            }

            var b = new StringBuilder();

            b.Append(Localizer.Format("RCLModuleInfo0", caseMass));
            b.Append(Localizer.Format("RCLModuleInfo1", maxSpares));
            b.Append(Localizer.Format("RCLModuleInfo2", autoCutSpeed));
            b.AppendLine(Localizer.Format("RCLModuleInfo3", materialName));
            b.Append(Localizer.Format("RCLModuleInfo4", staticCd));
            b.Append(Localizer.Format("RCLModuleInfo5", maxTemp + absoluteZero));
            b.Append(Localizer.Format("RCLModuleInfo6", preDeployedDiameter));
            b.Append(Localizer.Format("RCLModuleInfo7", deployedDiameter));
            b.Append(Localizer.Format("RCLModuleInfo8", minAirPressureToOpen));
            b.Append(Localizer.Format("RCLModuleInfo9", deployAltitude));
            b.Append(Localizer.Format("RCLModuleInfo10",
                                      Math.Round(1 / semiDeploymentSpeed, 1, MidpointRounding.AwayFromZero)));
            b.Append(Localizer.Format("RCLModuleInfo11",
                                      Math.Round(1 / deploymentSpeed, 1, MidpointRounding.AwayFromZero)));

            return(b.ToString());
        }
示例#2
0
        public override string GetInfo()
        {
            if (!CompatibilityChecker.IsAllCompatible())
            {
                return(string.Empty);
            }
            //Info in the editor part window
            this.part.mass = this.totalMass;
            this.massDelta = 0f;
            if ((object)(this.part.partInfo) != null && (object)(this.part.partInfo.partPrefab) != null)
            {
                this.massDelta = this.part.mass - this.part.partInfo.partPrefab.mass;
            }

            StringBuilder b = new StringBuilder();

            b.AppendFormat("<b>Case mass</b>: {0}\n", this.caseMass);
            b.AppendFormat("<b>Spare chutes</b>: {0}\n", maxSpares);
            b.AppendFormat("<b>Autocut speed</b>: {0}m/s\n", this.autoCutSpeed);
            b.AppendLine("<b>Parachute material</b>: " + materialName);
            b.AppendFormat("<b>Drag coefficient</b>: {0:0.0}\n", staticCd);
            b.AppendFormat("<b>Chute max temperature</b>: {0}°C\n", maxTemp + absoluteZero);
            b.AppendFormat("<b>Predeployed diameter</b>: {0}m\n", this.preDeployedDiameter);
            b.AppendFormat("<b>Deployed diameter</b>: {0}m\n", this.deployedDiameter);
            b.AppendFormat("<b>Minimum deployment pressure</b>: {0}atm\n", this.minAirPressureToOpen);
            b.AppendFormat("<b>Deployment altitude</b>: {0}m\n", this.deployAltitude);
            b.AppendFormat("<b>Predeployment speed</b>: {0}s\n", Math.Round(1f / this.semiDeploymentSpeed, 1, MidpointRounding.AwayFromZero));
            b.AppendFormat("<b>Deployment speed</b>: {0}s\n", Math.Round(1f / this.deploymentSpeed, 1, MidpointRounding.AwayFromZero));
            return(b.ToString());
        }
示例#3
0
        void Start()
        {
            if (CompatibilityChecker.IsAllCompatible() && instance == null)
            {
                instance = this;
            }
            else
            {
                GameObject.Destroy(this);
                return;
            }

            showGUI = false;
            if (FARDebugAndSettings.FARDebugButtonStock)
            {
                FARDebugAndSettings.FARDebugButtonStock.SetFalse(false);
            }

            _vehicleAero = new VehicleAerodynamics();

            guiRect = new Rect(Screen.width / 4, Screen.height / 6, 10, 10);

            _instantSim = new InstantConditionSim();
            GUIDropDown <int>           flapSettingDropDown   = new GUIDropDown <int>(new string[] { Localizer.Format("FARFlapSetting0"), Localizer.Format("FARFlapSetting1"), Localizer.Format("FARFlapSetting2"), Localizer.Format("FARFlapSetting3") }, new int[] { 0, 1, 2, 3 }, 0);
            GUIDropDown <CelestialBody> celestialBodyDropdown = CreateBodyDropdown();

            modeDropdown = new GUIDropDown <FAREditorMode>(FAReditorMode_str, new FAREditorMode[] { FAREditorMode.STATIC, FAREditorMode.STABILITY, FAREditorMode.SIMULATION, FAREditorMode.AREA_RULING });

            _simManager = new EditorSimManager(_instantSim);

            _editorGraph     = new StaticAnalysisGraphGUI(_simManager, flapSettingDropDown, celestialBodyDropdown);
            _stabDeriv       = new StabilityDerivGUI(_simManager, flapSettingDropDown, celestialBodyDropdown);
            _stabDerivLinSim = new StabilityDerivSimulationGUI(_simManager);

            Color crossSection = GUIColors.GetColor(3);

            crossSection.a = 0.8f;

            Color crossSectionDeriv = GUIColors.GetColor(2);

            crossSectionDeriv.a = 0.8f;

            _areaRulingOverlay = EditorAreaRulingOverlay.CreateNewAreaRulingOverlay(new Color(0.05f, 0.05f, 0.05f, 0.7f), crossSection, crossSectionDeriv, 10, 5);
            guiRect.height     = 500;
            guiRect.width      = 650;


            //GameEvents.onEditorVariantApplied.Add(UpdateGeometryEvent); // Rodhern: Downgrade to KSP 1.3.1
            GameEvents.onEditorPartEvent.Add(UpdateGeometryEvent);
            GameEvents.onEditorUndo.Add(ResetEditorEvent);
            GameEvents.onEditorRedo.Add(ResetEditorEvent);
            GameEvents.onEditorShipModified.Add(ResetEditorEvent);
            GameEvents.onEditorLoad.Add(ResetEditorEvent);

            GameEvents.onGUIEngineersReportReady.Add(AddDesignConcerns);
            GameEvents.onGUIEngineersReportDestroy.Add(RemoveDesignConcerns);

            RequestUpdateVoxel();
        }
        private void Start()
        {
            if (!CompatibilityChecker.IsAllCompatible())
            {
                this.enabled = false;
                return;
            }

            _vessel      = gameObject.GetComponent <Vessel>();
            this.enabled = true;

            if (_vessel.rootPart.Modules.Contains("MissileLauncher") && _vessel.parts.Count == 1)
            {
                _vessel.rootPart.dragModel = Part.DragModel.CUBE;
                this.enabled = false;
                return;
            }

            _currentGeoModules = new List <GeometryPartModule>();
            for (int i = 0; i < _vessel.parts.Count; i++)
            {
                Part p = _vessel.parts[i];
                p.maximum_drag = 0;
                p.minimum_drag = 0;
                p.angularDrag  = 0;

                /*p.dragModel = Part.DragModel.NONE;
                 * p.dragReferenceVector = Vector3.zero;
                 * p.dragScalar = 0;
                 * p.dragVector = Vector3.zero;
                 * p.dragVectorDir = Vector3.zero;
                 * p.dragVectorDirLocal = Vector3.zero;
                 * p.dragVectorMag = 0;
                 * p.dragVectorSqrMag = 0;
                 *
                 * p.bodyLiftMultiplier = 0;
                 * p.bodyLiftScalar = 0;*/

                GeometryPartModule g = p.GetComponent <GeometryPartModule>();
                if ((object)g != null)
                {
                    _currentGeoModules.Add(g);
                }
                else if (p.Modules.Contains("KerbalEVA"))
                {
                    p.AddModule("GeometryPartModule");
                    g = p.GetComponent <GeometryPartModule>();
                    p.AddModule("FARAeroPartModule");
                    _currentGeoModules.Add(g);
                }
            }

            GameEvents.onVesselGoOffRails.Add(VesselUpdateEvent);
            GameEvents.onVesselChange.Add(VesselUpdateEvent);
            //GameEvents.onVesselLoaded.Add(VesselUpdate);
            GameEvents.onVesselCreate.Add(VesselUpdateEvent);
            GameEvents.onVesselWasModified.Add(VesselUpdateEvent);
            VesselUpdate(false);
        }
 private void OnGUI()
 {
     if (CompatibilityChecker.IsAllCompatible() && (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor) && this.visible && !this.hid)
     {
         GUI.skin    = HighLogic.Skin;
         this.window = GUILayout.Window(this.id, this.window, Window, "RealChute Info Window");
     }
 }
 private void OnGUI()
 {
     if (CompatibilityChecker.IsAllCompatible() && (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor) && this.visible && !this.hid)
     {
         GUI.skin    = HighLogic.Skin;
         this.window = GUILayout.Window(this.id, this.window, Window, Localizer.Format("RCLGUITitle"));
     }
 }
示例#7
0
        private void Update()
        {
            if (!CompatibilityChecker.IsAllCompatible() || !HighLogic.LoadedSceneIsFlight)
            {
                return;
            }

            //Makes the chute icon blink if failed
            if (this.failedTimer.isRunning)
            {
                double time = this.failedTimer.elapsed.TotalSeconds;
                if (time <= 2.5)
                {
                    if (!this.displayed)
                    {
                        ScreenMessages.PostScreenMessage("Parachute deployment failed.", 2.5f, ScreenMessageStyle.UPPER_CENTER);
                        if (this.part.ShieldedFromAirstream)
                        {
                            ScreenMessages.PostScreenMessage("Reason: parachute is shielded from airstream.", 2.5f, ScreenMessageStyle.UPPER_CENTER);
                        }
                        else if (this.groundStop)
                        {
                            ScreenMessages.PostScreenMessage("Reason: stopped on the ground.", 2.5f, ScreenMessageStyle.UPPER_CENTER);
                        }
                        else if (this.atmPressure == 0)
                        {
                            ScreenMessages.PostScreenMessage("Reason: in space.", 2.5f, ScreenMessageStyle.UPPER_CENTER);
                        }
                        else
                        {
                            ScreenMessages.PostScreenMessage("Reason: too high.", 2.5f, ScreenMessageStyle.UPPER_CENTER);
                        }
                        this.displayed = true;
                    }
                    if (time < 0.5 || (time >= 1 && time < 1.5) || time >= 2)
                    {
                        this.part.stackIcon.SetIconColor(XKCDColors.Red);
                    }
                    else
                    {
                        this.part.stackIcon.SetIconColor(XKCDColors.White);
                    }
                }
                else
                {
                    this.displayed = false;
                    this.part.stackIcon.SetIconColor(XKCDColors.White);
                    this.failedTimer.Reset();
                }
            }

            this.disarm.active             = (this.armed || this.showDisarm);
            this.deploy.active             = !this.staged && this.deploymentState != DeploymentStates.CUT;
            this.cutE.active               = this.isDeployed;
            this.repack.guiActiveUnfocused = this.canRepack;
        }
        private void Update()
        {
            if (!CompatibilityChecker.IsAllCompatible() || !HighLogic.LoadedSceneIsFlight)
            {
                return;
            }

            //Makes the chute icon blink if failed
            if (this.failedTimer.IsRunning)
            {
                double time = this.failedTimer.Elapsed.TotalSeconds;
                if (time <= 2.5)
                {
                    if (!this.displayed)
                    {
                        ScreenMessages.PostScreenMessage(Localizer.Format("RCLFailDeploy"), 2.5f, ScreenMessageStyle.UPPER_CENTER);
                        if (this.part.ShieldedFromAirstream)
                        {
                            ScreenMessages.PostScreenMessage(Localizer.Format("RCLFailShielded"), 2.5f, ScreenMessageStyle.UPPER_CENTER);
                        }
                        else if (this.GroundStop)
                        {
                            ScreenMessages.PostScreenMessage(Localizer.Format("RCLFailGround"), 2.5f, ScreenMessageStyle.UPPER_CENTER);
                        }
                        else if (this.atmPressure == 0)
                        {
                            ScreenMessages.PostScreenMessage(Localizer.Format("RCLFailPres"), 2.5f, ScreenMessageStyle.UPPER_CENTER);
                        }
                        else
                        {
                            ScreenMessages.PostScreenMessage(Localizer.Format("RCLFailOther"), 2.5f, ScreenMessageStyle.UPPER_CENTER);
                        }
                        this.displayed = true;
                    }
                    if (time < 0.5 || time >= 1 && time < 1.5 || time >= 2)
                    {
                        this.part.stackIcon.SetIconColor(XKCDColors.Red);
                    }
                    else
                    {
                        this.part.stackIcon.SetIconColor(XKCDColors.White);
                    }
                }
                else
                {
                    this.displayed = false;
                    this.part.stackIcon.SetIconColor(XKCDColors.White);
                    this.failedTimer.Reset();
                }
            }

            this.Disarm.active             = this.armed || this.showDisarm;
            this.DeployE.active            = !this.staged && this.DeploymentState != DeploymentStates.CUT;
            this.CutE.active               = this.IsDeployed;
            this.Repack.guiActiveUnfocused = this.CanRepack;
        }
示例#9
0
 private void OnDestroy()
 {
     if (!CompatibilityChecker.IsAllCompatible() || (!HighLogic.LoadedSceneIsFlight && !HighLogic.LoadedSceneIsEditor))
     {
         return;
     }
     //Hide/show UI event removal
     GameEvents.onHideUI.Remove(HideUI);
     GameEvents.onShowUI.Remove(ShowUI);
 }
 void Awake()
 {
     enabled = false;
     if (!CompatibilityChecker.IsAllCompatible())
     {
         return;
     }
     instance = this;
     StartCoroutine(CheckActionGroupEditor());
 }
 private void Start()
 {
     if (CompatibilityChecker.IsAllCompatible() && Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(this);
     }
 }
 private void OnGUI()
 {
     if (!CompatibilityChecker.IsAllCompatible() ||
         !HighLogic.LoadedSceneIsFlight && !HighLogic.LoadedSceneIsEditor ||
         !visible ||
         hid)
     {
         return;
     }
     GUI.skin = HighLogic.Skin;
     window   = GUILayout.Window(id, window, Window, Localizer.Format("RCLGUITitle"));
 }
 void Start()
 {
     if (CompatibilityChecker.IsAllCompatible() && instance == null)
     {
         instance = this;
     }
     else
     {
         GameObject.Destroy(this);
         return;
     }
 }
 void Start()
 {
     if (!CompatibilityChecker.IsAllCompatible())
     {
         this.enabled = false;
         return;
     }
     //RebuildAllMeshData();
     SetupIGeometryUpdaters();
     SetupICrossSectionAdjusters();
     GetAnimations();
 }
        void Start()
        {
            if (!CompatibilityChecker.IsAllCompatible())
            {
                this.enabled = false;
                return;
            }

            _vessel                = GetComponent <Vessel>();
            _vesselAero            = GetComponent <FARVesselAero>();
            _physicsCalcs          = new PhysicsCalcs(_vessel, _vesselAero);
            _flightStatusGUI       = new FlightStatusGUI();
            _stabilityAugmentation = new StabilityAugmentation(_vessel);
            _flightDataGUI         = new FlightDataGUI();
            _aeroVizGUI            = new AeroVisualizationGUI();

            settingsWindow = new GUIDropDown <int>(new string[4] {
                "Flt Data", "Stab Aug", "Air Spd", "Aero Viz"
            }, new int[4] {
                0, 1, 2, 3
            }, 0);
            //boxStyle.padding = new RectOffset(4, 4, 4, 4);

            if (vesselFlightGUI.ContainsKey(_vessel))
            {
                vesselFlightGUI[_vessel] = this;
            }
            else
            {
                vesselFlightGUI.Add(_vessel, this);
            }

            this.enabled = true;

            if (FARDebugValues.useBlizzyToolbar)
            {
                GenerateBlizzyToolbarButton();
            }
            else
            {
                OnGUIAppLauncherReady();
            }

            activeFlightGUICount++;

            if (_vessel == FlightGlobals.ActiveVessel || FlightGlobals.ActiveVessel == null)
            {
                LoadConfigs();
            }

            GameEvents.onShowUI.Add(ShowUI);
            GameEvents.onHideUI.Add(HideUI);
        }
示例#16
0
        void Start()
        {
            if (CompatibilityChecker.IsAllCompatible() && instance == null)
            {
                instance = this;
            }
            else
            {
                GameObject.Destroy(this);
                return;
            }

            _vehicleAero = new VehicleAerodynamics();

            guiRect = new Rect(Screen.width / 4, Screen.height / 6, 10, 10);

            _instantSim = new InstantConditionSim();
            GUIDropDown <int>           flapSettingDropDown   = new GUIDropDown <int>(new string[] { "0 (up)", "1 (init climb)", "2 (takeoff)", "3 (landing)" }, new int[] { 0, 1, 2, 3 }, 0);
            GUIDropDown <CelestialBody> celestialBodyDropdown = CreateBodyDropdown();

            modeDropdown = new GUIDropDown <FAREditorMode>(FAReditorMode_str, new FAREditorMode[] { FAREditorMode.STATIC, FAREditorMode.STABILITY, FAREditorMode.SIMULATION, FAREditorMode.AREA_RULING });

            _simManager = new EditorSimManager(_instantSim);

            _editorGraph     = new StaticAnalysisGraphGUI(_simManager, flapSettingDropDown, celestialBodyDropdown);
            _stabDeriv       = new StabilityDerivGUI(_simManager, flapSettingDropDown, celestialBodyDropdown);
            _stabDerivLinSim = new StabilityDerivSimulationGUI(_simManager);

            Color crossSection = GUIColors.GetColor(3);

            crossSection.a = 0.8f;

            Color crossSectionDeriv = GUIColors.GetColor(2);

            crossSectionDeriv.a = 0.8f;

            _areaRulingOverlay = EditorAreaRulingOverlay.CreateNewAreaRulingOverlay(new Color(0.05f, 0.05f, 0.05f, 0.7f), crossSection, crossSectionDeriv, 10, 5);
            guiRect.height     = 500;
            guiRect.width      = 650;


            GameEvents.onEditorPartEvent.Add(UpdateGeometryEvent);
            GameEvents.onEditorUndo.Add(ResetEditorEvent);
            GameEvents.onEditorRedo.Add(ResetEditorEvent);
            GameEvents.onEditorShipModified.Add(ResetEditorEvent);
            GameEvents.onEditorLoad.Add(ResetEditorEvent);

            GameEvents.onGUIEngineersReportReady.Add(AddDesignConcerns);
            GameEvents.onGUIEngineersReportDestroy.Add(RemoveDesignConcerns);

            RequestUpdateVoxel();
        }
示例#17
0
        private void OnGUI()
        {
            if (!CompatibilityChecker.IsAllCompatible() && (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor))
            {
                return;
            }

            //Info window visibility
            if (this.visible && !this.hid)
            {
                this.window = GUILayout.Window(this.ID, this.window, Window, "RealChute Info Window", this.skins.window);
            }
        }
 public override void OnAwake()
 {
     enabled = false;
     if (!CompatibilityChecker.IsAllCompatible())
     {
         compatible = false;
         Events["HideUI"].active = false;
         Events["ShowUI"].active = false;
         return;
     }
     PartMessageService.Register(this);
     // Initialize utilization from the settings file
     utilization = MFSSettings.partUtilizationDefault;
 }
        protected override void OnStart()
        {
            FARLogger.Info("FARVesselAero on " + vessel.name + " reporting startup");
            base.OnStart();

            if (!CompatibilityChecker.IsAllCompatible())
            {
                enabled = false;
                return;
            }

            if (!HighLogic.LoadedSceneIsFlight)
            {
                enabled = false;
                return;
            }

            _currentGeoModules = new List <GeometryPartModule>();

            foreach (Part p in vessel.parts)
            {
                p.maximum_drag = 0;
                p.minimum_drag = 0;
                p.angularDrag  = 0;

                var g = p.GetComponent <GeometryPartModule>();
                if (!(g is null))
                {
                    _currentGeoModules.Add(g);
                    if (g.Ready)
                    {
                        geoModulesReady++;
                    }
                }

                if (!p.Modules.Contains <KerbalEVA>() && !p.Modules.Contains <FlagSite>())
                {
                    continue;
                }
                FARLogger.Info("Handling Stuff for KerbalEVA / Flag");
                g = (GeometryPartModule)p.AddModule("GeometryPartModule");
                g.OnStart(StartState());
                p.AddModule("FARAeroPartModule").OnStart(StartState());
                _currentGeoModules.Add(g);
            }

            RequestUpdateVoxel(false);

            enabled = true;
        }
 public override void OnLoad(ConfigNode node)
 {
     if (!CompatibilityChecker.IsAllCompatible())
     {
         return;
     }
     this.part.mass = this.totalMass;
     if (HighLogic.LoadedScene == GameScenes.LOADING)
     {
         if (this.deployAltitude <= 500)
         {
             this.deployAltitude += 200;
         }
     }
 }
 public override void OnLoad(ConfigNode node)
 {
     if (!CompatibilityChecker.IsAllCompatible())
     {
         return;
     }
     if (HighLogic.LoadedScene == GameScenes.LOADING || !PartLoader.Instance.IsReady() || part.partInfo == null)
     {
         if (deployAltitude <= 500)
         {
             deployAltitude += 200;
         }
     }
     else
     {
         Part prefab = part.partInfo.partPrefab;
         massDelta = prefab == null ? 0 : TotalMass - prefab.mass;
     }
 }
 public override void OnLoad(ConfigNode node)
 {
     if (!CompatibilityChecker.IsAllCompatible())
     {
         return;
     }
     if (HighLogic.LoadedScene == GameScenes.LOADING)
     {
         if (this.deployAltitude <= 500)
         {
             this.deployAltitude += 200;
         }
     }
     else
     {
         Part prefab = this.part.partInfo.partPrefab;
         this.massDelta = prefab == null ? 0 : this.totalMass - prefab.mass;
     }
 }
 public override void OnLoad(ConfigNode node)
 {
     if (!CompatibilityChecker.IsAllCompatible())
     {
         return;
     }
     this.part.mass = this.totalMass;
     if (HighLogic.LoadedScene == GameScenes.LOADING)
     {
         PartModule parachute = this.part.Modules["ModuleParachute"];
         if (parachute != null)
         {
             this.part.RemoveModule(parachute);
         }
         if (this.deployAltitude <= 500)
         {
             this.deployAltitude += 200;
         }
     }
 }
示例#24
0
        public override void OnLoad(ConfigNode node)
        {
            if (!CompatibilityChecker.IsAllCompatible())
            {
                return;
            }
            this.part.mass = this.totalMass;
            this.massDelta = 0f;

            if ((object)(this.part.partInfo) != null && (object)(this.part.partInfo.partPrefab) != null)
            {
                this.massDelta = this.part.mass - this.part.partInfo.partPrefab.mass;
            }
            if (HighLogic.LoadedScene == GameScenes.LOADING)
            {
                if (this.deployAltitude <= 500)
                {
                    this.deployAltitude += 200;
                }
            }
        }
示例#25
0
        protected override void OnStart()
        {
            base.OnStart();

            if (!CompatibilityChecker.IsAllCompatible())
            {
                enabled = false;
                return;
            }

            showGUI = savedShowGUI;
            //since we're sharing the button, we need these shenanigans now
            if (FARDebugAndSettings.FARDebugButtonStock && HighLogic.LoadedSceneIsFlight)
            {
                if (showGUI)
                {
                    FARDebugAndSettings.FARDebugButtonStock.SetTrue(false);
                }
                else
                {
                    FARDebugAndSettings.FARDebugButtonStock.SetFalse(false);
                }
            }


            _vessel                = GetComponent <Vessel>();
            _vesselAero            = GetComponent <FARVesselAero>();
            _physicsCalcs          = new PhysicsCalcs(_vessel, _vesselAero);
            _flightStatusGUI       = new FlightStatusGUI();
            _stabilityAugmentation = new StabilityAugmentation(_vessel);
            _flightDataGUI         = new FlightDataGUI();
            AeroVizGUI             = new AeroVisualizationGUI();

            settingsWindow = new GUIDropDown <int>(new[]
            {
                Localizer.Format("FARFlightGUIWindowSelect0"),
                Localizer.Format("FARFlightGUIWindowSelect1"),
                Localizer.Format("FARFlightGUIWindowSelect2"),
                Localizer.Format("FARFlightGUIWindowSelect3")
            },
                                                   new[] { 0, 1, 2, 3 });

            if (vesselFlightGUI.ContainsKey(_vessel))
            {
                vesselFlightGUI[_vessel] = this;
            }
            else
            {
                vesselFlightGUI.Add(_vessel, this);
            }

            enabled = true;

            if (FARDebugValues.useBlizzyToolbar)
            {
                GenerateBlizzyToolbarButton();
            }

            activeFlightGUICount++;

            if (_vessel == FlightGlobals.ActiveVessel || FlightGlobals.ActiveVessel == null)
            {
                LoadConfigs();
            }

            GameEvents.onShowUI.Add(ShowUI);
            GameEvents.onHideUI.Add(HideUI);
        }
        public override void OnStart(StartState startState)
        {
            if (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight)
            {
                return;
            }
            if (!CompatibilityChecker.IsAllCompatible())
            {
                Actions.ForEach(a => a.active = false);
                Events.ForEach(e =>
                {
                    e.active          = false;
                    e.guiActive       = false;
                    e.guiActiveEditor = false;
                });
                Fields["chuteCount"].guiActive = false;
                return;
            }

            //Staging icon
            part.stagingIcon = "PARACHUTES";
            InitializeAnimationSystem();

            //First initiation of the part
            if (!initiated)
            {
                initiated  = true;
                armed      = false;
                chuteCount = maxSpares;
                cap.gameObject.SetActive(true);
            }

            float tmpPartMass = TotalMass;

            massDelta = 0;
            if (!(part.partInfo?.partPrefab is null))
            {
                massDelta = tmpPartMass - part.partInfo.partPrefab.mass;
            }

            //Flight loading
            if (HighLogic.LoadedSceneIsFlight)
            {
                var random = new Random();
                randomTime = (float)random.NextDouble();
                randomX    = (float)(random.NextDouble() * 100);
                randomY    = (float)(random.NextDouble() * 100);

                //Hide/show UI event addition
                GameEvents.onHideUI.Add(HideUI);
                GameEvents.onShowUI.Add(ShowUI);
                GameEvents.onStageActivate.Add(OnStageActivate);

                if (CanRepack)
                {
                    SetRepack();
                }

                if (!time.NearlyEqual(0))
                {
                    dragTimer = new PhysicsWatch(time);
                }
                if (DeploymentState != DeploymentStates.STOWED)
                {
                    part.stackIcon.SetIconColor(XKCDColors.Red);
                    cap.gameObject.SetActive(false);
                }

                if (staged && IsDeployed)
                {
                    parachute.gameObject.SetActive(true);
                    switch (DeploymentState)
                    {
                    case DeploymentStates.PREDEPLOYED:
                        part.SkipToAnimationTime(semiDeployedAnimation, semiDeploymentSpeed, Mathf.Clamp01(time));
                        break;

                    case DeploymentStates.DEPLOYED:
                        part.SkipToAnimationTime(fullyDeployedAnimation, deploymentSpeed, Mathf.Clamp01(time));
                        break;
                    }
                }

                DragCubeList cubes = part.DragCubes;
                //Set stock cubes to 0
                cubes.SetCubeWeight("PACKED", 0);
                cubes.SetCubeWeight("SEMIDEPLOYED", 0);
                cubes.SetCubeWeight("DEPLOYED", 0);

                //Sets RC cubes
                if (DeploymentState == DeploymentStates.STOWED)
                {
                    cubes.SetCubeWeight("PACKED", 1);
                    cubes.SetCubeWeight("RCDEPLOYED", 0);
                }
                else
                {
                    cubes.SetCubeWeight("PACKED", 0);
                    cubes.SetCubeWeight("RCDEPLOYED", 1);
                }
            }

            //GUI
            window = new Rect(200, 100, 350, 400);
            drag   = new Rect(0, 0, 350, 30);
        }
示例#27
0
        protected override void OnStart()
        {
            Debug.Log("FARVesselAero on " + vessel.name + " reporting startup");
            base.OnStart();

            if (!CompatibilityChecker.IsAllCompatible())
            {
                this.enabled = false;
                return;
            }
            if (!HighLogic.LoadedSceneIsFlight)
            {
                this.enabled = false;
                return;
            }

            _currentGeoModules = new List <GeometryPartModule>();

            /*if (!vessel.rootPart)
             * {
             *  this.enabled = false;
             *  return;
             * }*/

            for (int i = 0; i < vessel.parts.Count; i++)
            {
                Part p = vessel.parts[i];
                p.maximum_drag = 0;
                p.minimum_drag = 0;
                p.angularDrag  = 0;

                /*p.dragModel = Part.DragModel.NONE;
                 * p.dragReferenceVector = Vector3.zero;
                 * p.dragScalar = 0;
                 * p.dragVector = Vector3.zero;
                 * p.dragVectorDir = Vector3.zero;
                 * p.dragVectorDirLocal = Vector3.zero;
                 * p.dragVectorMag = 0;
                 * p.dragVectorSqrMag = 0;
                 *
                 * p.bodyLiftMultiplier = 0;
                 * p.bodyLiftScalar = 0;*/

                GeometryPartModule g = p.GetComponent <GeometryPartModule>();
                if ((object)g != null)
                {
                    _currentGeoModules.Add(g);
                    if (g.Ready)
                    {
                        geoModulesReady++;
                    }
                }
                if (p.Modules.Contains <KerbalEVA>() || p.Modules.Contains <FlagSite>())
                {
                    Debug.Log("Handling Stuff for KerbalEVA / Flag");
                    g = (GeometryPartModule)p.AddModule("GeometryPartModule");
                    g.OnStart(StartState());
                    p.AddModule("FARAeroPartModule").OnStart(StartState());
                    _currentGeoModules.Add(g);
                }
            }
            RequestUpdateVoxel(false);

            this.enabled = true;
            //GameEvents.onVesselLoaded.Add(VesselUpdateEvent);
            //GameEvents.onVesselChange.Add(VesselUpdateEvent);
            //GameEvents.onVesselLoaded.Add(VesselUpdate);
            //GameEvents.onVesselCreate.Add(VesselUpdateEvent);

            //Debug.Log("Starting " + _vessel.vesselName + " aero properties");
        }
示例#28
0
        private void Start()
        {
            if (!CompatibilityChecker.IsAllCompatible())
            {
                this.enabled = false;
                return;
            }

            _vessel      = gameObject.GetComponent <Vessel>();
            this.enabled = true;

            if (_vessel.rootPart.Modules.Contains("MissileLauncher") && _vessel.parts.Count == 1)
            {
                _vessel.rootPart.dragModel = Part.DragModel.CUBE;
                this.enabled = false;
                return;
            }

            _currentGeoModules = new List <GeometryPartModule>();
            for (int i = 0; i < _vessel.parts.Count; i++)
            {
                Part p = _vessel.parts[i];
                p.maximum_drag = 0;
                p.minimum_drag = 0;
                p.angularDrag  = 0;

                /*p.dragModel = Part.DragModel.NONE;
                 * p.dragReferenceVector = Vector3.zero;
                 * p.dragScalar = 0;
                 * p.dragVector = Vector3.zero;
                 * p.dragVectorDir = Vector3.zero;
                 * p.dragVectorDirLocal = Vector3.zero;
                 * p.dragVectorMag = 0;
                 * p.dragVectorSqrMag = 0;
                 *
                 * p.bodyLiftMultiplier = 0;
                 * p.bodyLiftScalar = 0;*/

                GeometryPartModule g = p.GetComponent <GeometryPartModule>();
                if ((object)g != null)
                {
                    _currentGeoModules.Add(g);
                    if (g.Ready)
                    {
                        geoModulesReady++;
                    }
                }
                if (p.Modules.Contains <KerbalEVA>() || p.Modules.Contains <FlagSite>())
                {
                    Debug.Log("Handling Stuff for KerbalEVA / Flag");
                    g = (GeometryPartModule)p.AddModule("GeometryPartModule");
                    g.OnStart(StartState());
                    p.AddModule("FARAeroPartModule").OnStart(StartState());
                    _currentGeoModules.Add(g);
                }
            }

            GameEvents.onVesselGoOffRails.Add(VesselUpdateEvent);
            //GameEvents.onVesselChange.Add(VesselUpdateEvent);
            //GameEvents.onVesselLoaded.Add(VesselUpdate);
            //GameEvents.onVesselCreate.Add(VesselUpdateEvent);
            GameEvents.onVesselWasModified.Add(VesselUpdateEvent);
            RequestUpdateVoxel(false);

            if (_vessel == null)
            {
                _vessel = gameObject.GetComponent <Vessel>();
                if (_vessel == null)
                {
                    return;
                }
            }

            if (_vehicleAero == null)
            {
                _vehicleAero         = new VehicleAerodynamics();
                _vesselIntakeRamDrag = new VesselIntakeRamDrag();
            }
            //Debug.Log("Starting " + _vessel.vesselName + " aero properties");
        }
示例#29
0
        public override void OnStart(PartModule.StartState state)
        {
            if (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight)
            {
                return;
            }
            if (!CompatibilityChecker.IsAllCompatible())
            {
                Actions.ForEach(a => a.active = false);
                Events.ForEach(e =>
                {
                    e.active          = false;
                    e.guiActive       = false;
                    e.guiActiveEditor = false;
                });
                Fields["chuteCount"].guiActive = false;
                return;
            }

            //Staging icon
            this.part.stagingIcon = "PARACHUTES";
            InitializeAnimationSystem();

            //First initiation of the part
            if (!this.initiated)
            {
                this.initiated  = true;
                this.armed      = false;
                this.chuteCount = maxSpares;
                this.cap.gameObject.SetActive(true);
            }
            this.part.mass = this.totalMass;
            this.massDelta = 0f;
            if ((object)(this.part.partInfo) != null && (object)(this.part.partInfo.partPrefab) != null)
            {
                this.massDelta = this.part.mass - this.part.partInfo.partPrefab.mass;
            }

            //Flight loading
            if (HighLogic.LoadedSceneIsFlight)
            {
                Random random = new Random();
                this.randomTime = (float)random.NextDouble();
                this.randomX    = (float)(random.NextDouble() * 100);
                this.randomY    = (float)(random.NextDouble() * 100);

                //Hide/show UI event addition
                GameEvents.onHideUI.Add(HideUI);
                GameEvents.onShowUI.Add(ShowUI);

                if (this.canRepack)
                {
                    SetRepack();
                }

                if (this.time != 0)
                {
                    this.dragTimer = new PhysicsWatch(this.time);
                }
                if (this.deploymentState != DeploymentStates.STOWED)
                {
                    this.part.stackIcon.SetIconColor(XKCDColors.Red);
                    this.cap.gameObject.SetActive(false);
                }

                if (this.staged && this.isDeployed)
                {
                    this.parachute.gameObject.SetActive(true);
                    switch (this.deploymentState)
                    {
                    case DeploymentStates.PREDEPLOYED:
                        this.part.SkipToAnimationTime(this.semiDeployedAnimation, this.semiDeploymentSpeed, Mathf.Clamp01(this.time)); break;

                    case DeploymentStates.DEPLOYED:
                        this.part.SkipToAnimationTime(this.fullyDeployedAnimation, this.deploymentSpeed, Mathf.Clamp01(this.time)); break;

                    default:
                        break;
                    }
                }

                DragCubeList cubes = this.part.DragCubes;
                //Set stock cubes to 0
                cubes.SetCubeWeight("PACKED", 0);
                cubes.SetCubeWeight("SEMIDEPLOYED", 0);
                cubes.SetCubeWeight("DEPLOYED", 0);

                //Sets RC cubes
                if (this.deploymentState == DeploymentStates.STOWED)
                {
                    cubes.SetCubeWeight("PACKED", 1);
                    cubes.SetCubeWeight("RCDEPLOYED", 0);
                }
                else
                {
                    cubes.SetCubeWeight("PACKED", 0);
                    cubes.SetCubeWeight("RCDEPLOYED", 1);
                }
            }

            //GUI
            this.window = new Rect(200, 100, 350, 400);
            this.drag   = new Rect(0, 0, 350, 30);
        }
示例#30
0
        private void FixedUpdate()
        {
            //Flight values
            if (!CompatibilityChecker.IsAllCompatible() || !HighLogic.LoadedSceneIsFlight || FlightGlobals.ActiveVessel == null || this.part.Rigidbody == null)
            {
                return;
            }
            this.pos     = this.part.partTransform.position;
            this.ASL     = FlightGlobals.getAltitudeAtPos(this.pos);
            this.trueAlt = this.ASL;
            if (this.vessel.mainBody.pqsController != null)
            {
                double terrainAlt = this.vessel.pqsAltitude;
                if (!this.vessel.mainBody.ocean || terrainAlt > 0)
                {
                    this.trueAlt -= terrainAlt;
                }
            }
            this.atmPressure = FlightGlobals.getStaticPressure(this.ASL, this.vessel.mainBody) * PhysicsGlobals.KpaToAtmospheres;
            this.atmDensity  = part.atmDensity;
            Vector3 velocity = this.part.Rigidbody.velocity + Krakensbane.GetFrameVelocityV3f();

            this.sqrSpeed   = velocity.sqrMagnitude;
            this.dragVector = -velocity.normalized;

            if (this.atmDensity > 0)
            {
                CalculateChuteFlux();
            }
            else
            {
                this.convFlux = 0;
            }

            CalculateSafeToDeployEstimate();

            if (!this.staged && GameSettings.LAUNCH_STAGES.GetKeyDown() && this.vessel.isActiveVessel && (this.part.inverseStage == Staging.CurrentStage - 1 || Staging.CurrentStage == 0))
            {
                ActivateRC();
            }

            if (this.staged)
            {
                //Checks if the parachute must disarm
                if (this.armed)
                {
                    this.part.stackIcon.SetIconColor(XKCDColors.LightCyan);
                    if (this.canDeploy)
                    {
                        this.armed = false;
                    }
                }
                //Parachute deployments
                else
                {
                    //Parachutes
                    if (this.canDeploy)
                    {
                        if (this.isDeployed)
                        {
                            if (!CalculateChuteTemp())
                            {
                                return;
                            }
                            FollowDragDirection();
                        }

                        switch (this.deploymentState)
                        {
                        case DeploymentStates.STOWED:
                        {
                            this.part.stackIcon.SetIconColor(XKCDColors.LightCyan);
                            if (this.pressureCheck && this.randomDeployment)
                            {
                                PreDeploy();
                            }
                            break;
                        }

                        case DeploymentStates.PREDEPLOYED:
                        {
                            this.part.Rigidbody.AddForceAtPosition(DragForce(0, this.preDeployedDiameter, 1f / this.semiDeploymentSpeed), this.forcePosition, ForceMode.Force);
                            if (this.trueAlt <= this.deployAltitude && this.dragTimer.elapsed.TotalSeconds >= 1f / this.semiDeploymentSpeed)
                            {
                                Deploy();
                            }
                            break;
                        }

                        case DeploymentStates.DEPLOYED:
                        {
                            this.part.rigidbody.AddForceAtPosition(DragForce(this.preDeployedDiameter, this.deployedDiameter, 1f / this.deploymentSpeed), this.forcePosition, ForceMode.Force);
                            break;
                        }

                        default:
                            break;
                        }
                    }
                    //Deactivation
                    else
                    {
                        if (this.isDeployed)
                        {
                            Cut();
                        }
                        else
                        {
                            this.failedTimer.Start();
                            StagingReset();
                        }
                    }
                }
            }
        }