예제 #1
0
        //Applies the parameters to the parachute
        internal void Apply(bool toSymmetryCounterparts, bool showMessage = true)
        {
            if (!showMessage && (GetErrors(true).Count > 0 || GetErrors(false).Count > 0))
            {
                this.editorGUI.failedVisible = true; return;
            }
            this.rcModule.mustGoDown     = this.mustGoDown;
            this.rcModule.deployOnGround = this.deployOnGround;
            this.rcModule.timer          = GuiUtils.ParseTime(this.timer);
            this.rcModule.cutSpeed       = float.Parse(this.cutSpeed);
            this.rcModule.spareChutes    = GuiUtils.ParseEmpty(this.spares);
            this.rcModule.chuteCount     = (int)this.rcModule.spareChutes;
            this.rcModule.delayBeforeCut = float.Parse(this.delayBeforeCut);
            this.chutes.ForEach(c => c.ApplyChanges(toSymmetryCounterparts));

            if (toSymmetryCounterparts)
            {
                foreach (Part p in this.part.symmetryCounterparts)
                {
                    RealChuteModule module = (RealChuteModule)p.Modules["RealChuteModule"];
                    UpdateCaseTexture(module);
                    UpdateScale(p, module);

                    module.mustGoDown     = this.mustGoDown;
                    module.timer          = GuiUtils.ParseTime(this.timer);
                    module.cutSpeed       = float.Parse(this.cutSpeed);
                    module.delayBeforeCut = float.Parse(this.delayBeforeCut);
                    module.spareChutes    = GuiUtils.ParseEmpty(this.spares);

                    ProceduralChute pChute = (ProceduralChute)p.Modules["ProceduralChute"];
                    pChute.presetId       = this.presetId;
                    pChute.planets        = this.planets;
                    pChute.size           = this.size;
                    pChute.caseId         = this.caseId;
                    pChute.mustGoDown     = this.mustGoDown;
                    pChute.deployOnGround = this.deployOnGround;
                    pChute.timer          = this.timer;
                    pChute.cutSpeed       = this.cutSpeed;
                    pChute.spares         = this.spares;
                    pChute.delayBeforeCut = this.delayBeforeCut;
                }
            }
            this.rcModule.UpdateMass();
            if (showMessage)
            {
                this.editorGUI.successfulVisible = true;
                if (!this.editorGUI.warning)
                {
                    this.editorGUI.successfulWindow.height = 50;
                }
            }
            GameEvents.onEditorShipModified.Fire(EditorLogic.fetch.ship);
        }
예제 #2
0
        //Applies changes to the parachute
        internal void ApplyChanges(bool toSymmetryCounterparts)
        {
            this.parachute.material = this.material.Name;
            this.parachute.mat      = this.material;

            if (this.templateGUI.calcSelect)
            {
                double m = this.templateGUI.getMass ? this.pChute.GetCraftMass(this.templateGUI.useDry) : double.Parse(this.templateGUI.mass);
                double alt = 0, acc = 0;
                switch (this.templateGUI.Type)
                {
                case ParachuteType.MAIN:
                {
                    alt = double.Parse(this.pChute.landingAlt);
                    acc = this.Body.GeeASL * RCUtils.geeToAcc;
                    break;
                }

                case ParachuteType.DROGUE:
                {
                    alt = double.Parse(this.templateGUI.refDepAlt);
                    acc = this.Body.GeeASL * RCUtils.geeToAcc;
                    break;
                }

                case ParachuteType.DRAG:
                {
                    alt = double.Parse(this.pChute.landingAlt);
                    acc = double.Parse(this.templateGUI.deceleration);
                    break;
                }
                }
                double density = this.Body.GetDensityAtAlt(alt, this.Body.GetMaxTemperatureAtAlt(alt));
                double speed   = double.Parse(this.templateGUI.landingSpeed);
                speed *= speed;

                Debug.Log(string.Format("[RealChute]: {0} {1} - m: {2}t, alt: {3}m, ρ: {4}kg/m³, v²: {5}m²/s², a: {6}m/s²", this.Part.partInfo.title, RCUtils.ParachuteNumber(this.id), m, alt, density, speed, acc));

                this.parachute.deployedDiameter = RCUtils.Round(Math.Sqrt((8000 * m * acc) / (Math.PI * speed * this.material.DragCoefficient * density * double.Parse(this.templateGUI.chuteCount))));
                float maxDiam = this.Textures != null || this.Textures.Models.Count > 0 ? this.model.MaxDiam : 70;
                if (this.parachute.deployedDiameter > this.model.MaxDiam)
                {
                    this.parachute.deployedDiameter = maxDiam;
                    this.EditorGUI.warning          = true;
                }
                else
                {
                    this.EditorGUI.warning = false;
                }
                this.parachute.preDeployedDiameter = RCUtils.Round(this.templateGUI.Type == ParachuteType.MAIN ? this.parachute.deployedDiameter / 20 : this.parachute.deployedDiameter / 2);
                Debug.Log(string.Format("[RealChute]: {0} {1} - depDiam: {2}m, preDepDiam: {3}m", this.Part.partInfo.title, RCUtils.ParachuteNumber(this.id), this.parachute.deployedDiameter, this.parachute.preDeployedDiameter));
            }

            else
            {
                this.parachute.preDeployedDiameter = RCUtils.Round(float.Parse(this.templateGUI.preDepDiam));
                this.parachute.deployedDiameter    = RCUtils.Round(float.Parse(this.templateGUI.depDiam));
                Debug.Log(string.Format("[RealChute]: {0} {1} - depDiam: {2}m, preDepDiam: {3}m", this.Part.partInfo.title, RCUtils.ParachuteNumber(this.id), this.parachute.deployedDiameter, this.parachute.preDeployedDiameter));
            }

            this.parachute.minIsPressure = this.templateGUI.isPressure;
            if (this.templateGUI.isPressure)
            {
                this.parachute.minPressure = float.Parse(this.templateGUI.predepClause);
            }
            else
            {
                this.parachute.minDeployment = float.Parse(this.templateGUI.predepClause);
            }
            this.parachute.deploymentAlt      = float.Parse(this.templateGUI.deploymentAlt);
            this.parachute.cutAlt             = GuiUtils.ParseEmpty(this.templateGUI.cutAlt);
            this.parachute.preDeploymentSpeed = float.Parse(this.templateGUI.preDepSpeed);
            this.parachute.deploymentSpeed    = float.Parse(this.templateGUI.depSpeed);

            if (toSymmetryCounterparts)
            {
                foreach (Part part in this.Part.symmetryCounterparts)
                {
                    Parachute sym = ((RealChuteModule)part.Modules["RealChuteModule"]).parachutes[this.id];
                    sym.material            = this.material.Name;
                    sym.mat                 = this.material;
                    sym.deployedDiameter    = this.parachute.deployedDiameter;
                    sym.preDeployedDiameter = this.parachute.preDeployedDiameter;
                    sym.minIsPressure       = this.templateGUI.isPressure;
                    sym.minPressure         = this.parachute.minPressure;
                    sym.minDeployment       = this.parachute.minDeployment;
                    sym.deploymentAlt       = this.parachute.deploymentAlt;
                    sym.cutAlt              = this.parachute.cutAlt;
                    sym.preDeploymentSpeed  = this.parachute.preDeploymentSpeed;
                    sym.deploymentSpeed     = this.parachute.deploymentSpeed;

                    TemplateGUI template = ((ProceduralChute)part.Modules["ProceduralChute"]).chutes[this.id].templateGUI;
                    template.chuteId       = this.templateGUI.chuteId;
                    template.TypeID        = this.templateGUI.TypeID;
                    template.modelId       = this.templateGUI.modelId;
                    template.materialsId   = this.templateGUI.materialsId;
                    template.isPressure    = this.templateGUI.isPressure;
                    template.calcSelect    = this.templateGUI.calcSelect;
                    template.getMass       = this.templateGUI.getMass;
                    template.useDry        = this.templateGUI.useDry;
                    template.preDepDiam    = this.templateGUI.preDepDiam;
                    template.depDiam       = this.templateGUI.depDiam;
                    template.predepClause  = this.templateGUI.predepClause;
                    template.mass          = this.templateGUI.mass;
                    template.landingSpeed  = this.templateGUI.landingSpeed;
                    template.deceleration  = this.templateGUI.deceleration;
                    template.refDepAlt     = this.templateGUI.refDepAlt;
                    template.chuteCount    = this.templateGUI.chuteCount;
                    template.deploymentAlt = this.templateGUI.deploymentAlt;
                    template.cutAlt        = this.templateGUI.cutAlt;
                    template.preDepSpeed   = this.templateGUI.preDepSpeed;
                    template.depSpeed      = this.templateGUI.depSpeed;
                }
            }
        }