Exemplo n.º 1
0
 /// <summary>
 /// Creates a new ChuteTemplate from the given ProceduralChute
 /// </summary>
 /// <param name="pChute">Module to create the object from</param>
 /// <param name="node">ConfigNode to load the data from</param>
 /// <param name="id">Index of the ChuteTemplate</param>
 public ChuteTemplate(ProceduralChute pChute, ConfigNode node, int id)
 {
     this.pChute = pChute;
     this.id = id;
     this.templateGUI = new TemplateGUI(this);
     if (node != null) { Load(node); }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a ChuteTemplate from the given ProceduralChute
        /// </summary>
        /// <param name="pChute">Procedural chute to make the template from</param>
        /// <param name="secondary">If this is the secondary chute</param>
        public ChuteTemplate(ProceduralChute pChute, bool secondary)
        {
            this.pChute    = pChute;
            this.secondary = secondary;
            this.pChute.materials.TryGetMaterial(chute.material, ref material);
            materialsID = this.pChute.materials.GetMaterialIndex(chute.material);
            if (this.pChute.textureLibrary != "none")
            {
                this.textures.TryGetCanopy(chuteID, ref canopy);
                this.textures.TryGetModel(modelID, ref model);
            }

            if (HighLogic.LoadedSceneIsEditor)
            {
                if (!this.pChute.initiated)
                {
                    if (this.textures.TryGetCanopy(currentCanopy, ref canopy))
                    {
                        chuteID = this.textures.GetCanopyIndex(canopy);
                    }
                    if (this.textures.TryGetModel(chute.parachuteName, ref model, true))
                    {
                        modelID = this.textures.GetModelIndex(model);
                    }
                    if (RCUtils.types.Contains(currentType))
                    {
                        typeID = RCUtils.types.ToList().IndexOf(currentType);
                    }
                }

                preDepDiam = chute.preDeployedDiameter.ToString();
                depDiam    = chute.deployedDiameter.ToString();
                isPressure = chute.minIsPressure;
                if (isPressure)
                {
                    predepClause = chute.minPressure.ToString();
                }
                else
                {
                    predepClause = chute.minDeployment.ToString();
                }
                deploymentAlt = chute.deploymentAlt.ToString();
                cutAlt        = chute.cutAlt.ToString();
                if (cutAlt == "-1")
                {
                    cutAlt = string.Empty;
                }
                preDepSpeed = chute.preDeploymentSpeed.ToString();
                depSpeed    = chute.deploymentSpeed.ToString();
            }
            position = this.part.FindModelTransform(chute.parachuteName).position;

            if (HighLogic.LoadedSceneIsFlight)
            {
                UpdateCanopy();
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Creates a new ChuteTemplate from the given ProceduralChute
 /// </summary>
 /// <param name="pChute">Module to create the object from</param>
 /// <param name="node">ConfigNode to load the data from</param>
 /// <param name="id">Index of the ChuteTemplate</param>
 public ChuteTemplate(ProceduralChute pChute, ConfigNode node, int id)
 {
     this.pChute      = pChute;
     this.id          = id;
     this.templateGUI = new TemplateGUI(this);
     if (node != null)
     {
         Load(node);
     }
 }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        //Applies the parameters to the parachute
        private void Apply(bool toSymmetryCounterparts)
        {
            if ((GetErrors("general").Count != 0 || GetErrors("main").Count != 0 || (secondaryChute && GetErrors("secondary").Count != 0)))
            {
                this.failedVisible = true; return;
            }

            rcModule.mustGoDown     = mustGoDown;
            rcModule.deployOnGround = deployOnGround;
            rcModule.timer          = RCUtils.ParseTime(timer);
            rcModule.cutSpeed       = float.Parse(cutSpeed);
            rcModule.spareChutes    = RCUtils.ParseWithEmpty(spares);

            main.ApplyChanges(toSymmetryCounterparts);
            if (secondaryChute)
            {
                secondary.ApplyChanges(toSymmetryCounterparts);
            }

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

                    module.mustGoDown  = mustGoDown;
                    module.timer       = RCUtils.ParseTime(timer);
                    module.cutSpeed    = float.Parse(cutSpeed);
                    module.spareChutes = RCUtils.ParseWithEmpty(spares);

                    ProceduralChute pChute = part.Modules["ProceduralChute"] as 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;
                }
            }

            this.successfulVisible = true;
            if (!warning)
            {
                successfulWindow.height = 50;
            }
        }
Exemplo n.º 6
0
        //Applies the parameters to the parachute
        internal void Apply(bool toSymmetryCounterparts)
        {
            if ((GetErrors("general").Count != 0 || GetErrors("main").Count != 0 || (secondaryChute && GetErrors("secondary").Count != 0)))
            {
                this.editorGUI.failedVisible = true; return;
            }
            rcModule.mustGoDown     = mustGoDown;
            rcModule.deployOnGround = deployOnGround;
            rcModule.timer          = RCUtils.ParseTime(timer);
            rcModule.cutSpeed       = float.Parse(cutSpeed);
            rcModule.spareChutes    = RCUtils.ParseWithEmpty(spares);
            rcModule.chuteCount     = (int)rcModule.spareChutes;

            chutes.ForEach(c => c.ApplyChanges(toSymmetryCounterparts));
            if (toSymmetryCounterparts)
            {
                foreach (Part part in this.part.symmetryCounterparts)
                {
                    RealChuteModule module = part.Modules["RealChuteModule"] as RealChuteModule;
                    UpdateCaseTexture(part, module);
                    UpdateScale(part, module);

                    module.mustGoDown  = mustGoDown;
                    module.timer       = RCUtils.ParseTime(timer);
                    module.cutSpeed    = float.Parse(cutSpeed);
                    module.spareChutes = RCUtils.ParseWithEmpty(spares);

                    ProceduralChute pChute = part.Modules["ProceduralChute"] as 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;
                }
            }
            this.part.mass = rcModule.caseMass + rcModule.parachutes.Sum(p => p.chuteMass);
            this.editorGUI.successfulVisible = true;
            if (!editorGUI.warning)
            {
                editorGUI.successfulWindow.height = 50;
            }
            GameEvents.onEditorShipModified.Fire(EditorLogic.fetch.ship);
        }
Exemplo n.º 7
0
        //Copies all fields to the symmetry counterpart
        public void CopyFromOriginal(RealChuteModule module, ProceduralChute pChute)
        {
            Parachute     sym      = module.parachutes[id];
            ChuteTemplate template = pChute.chutes[id];

            parachute = pChute.rcModule.parachutes[id];

            material = sym.mat;
            parachute.deployedDiameter    = sym.deployedDiameter;
            parachute.preDeployedDiameter = sym.preDeployedDiameter;
            isPressure = sym.minIsPressure;
            if (isPressure)
            {
                parachute.minPressure = sym.minPressure;
            }
            else
            {
                parachute.minDeployment = sym.minDeployment;
            }
            parachute.deploymentAlt      = sym.deploymentAlt;
            parachute.cutAlt             = sym.cutAlt;
            parachute.preDeploymentSpeed = sym.preDeploymentSpeed;
            parachute.deploymentSpeed    = sym.deploymentSpeed;
            this.chuteID       = template.chuteID;
            this.typeID        = template.typeID;
            this.modelID       = template.modelID;
            this.materialsID   = template.materialsID;
            this.isPressure    = template.isPressure;
            this.calcSelect    = template.calcSelect;
            this.getMass       = template.getMass;
            this.useDry        = template.useDry;
            this.preDepDiam    = template.preDepDiam;
            this.depDiam       = template.depDiam;
            this.predepClause  = template.predepClause;
            this.mass          = template.mass;
            this.landingSpeed  = template.landingSpeed;
            this.deceleration  = template.deceleration;
            this.refDepAlt     = template.refDepAlt;
            this.chuteCount    = template.chuteCount;
            this.deploymentAlt = template.deploymentAlt;
            this.cutAlt        = template.cutAlt;
            this.preDepSpeed   = template.preDepSpeed;
            this.depSpeed      = template.depSpeed;
        }
Exemplo n.º 8
0
        //Copies values from the original symmetry part
        private void CopyFromOriginal(Part p)
        {
            RealChuteModule module = p.Modules["RealChuteModule"] as RealChuteModule;
            ProceduralChute pChute = p.Modules["ProceduralChute"] as ProceduralChute;

            this.mustGoDown     = module.mustGoDown;
            this.timer          = module.timer.ToString();
            this.cutSpeed       = module.cutSpeed.ToString();
            this.spares         = module.spareChutes.ToString();
            this.presetID       = pChute.presetID;
            this.planets        = pChute.planets;
            this.size           = pChute.size;
            this.caseID         = pChute.caseID;
            this.mustGoDown     = pChute.mustGoDown;
            this.deployOnGround = pChute.deployOnGround;
            this.timer          = pChute.timer;
            this.cutSpeed       = pChute.cutSpeed;
            this.spares         = pChute.spares;

            this.chutes.ForEach(c => c.CopyFromOriginal(module, pChute));
        }
Exemplo n.º 9
0
        /// <summary>
        /// Creates a ChuteTemplate from the given ProceduralChute
        /// </summary>
        /// <param name="pChute">Procedural chute to make the template from</param>
        /// <param name="secondary">If this is the secondary chute</param>
        public ChuteTemplate(ProceduralChute pChute, bool secondary)
        {
            this.pChute = pChute;
            this.secondary = secondary;
            this.pChute.materials.TryGetMaterial(chute.material, ref material);
            materialsID = this.pChute.materials.GetMaterialIndex(chute.material);
            if (this.pChute.textureLibrary != "none")
            {
                this.textures.TryGetCanopy(chuteID, ref canopy);
                this.textures.TryGetModel(modelID, ref model);
            }

            if (HighLogic.LoadedSceneIsEditor)
            {
                if (!this.pChute.initiated)
                {
                    if (this.textures.TryGetCanopy(currentCanopy, ref canopy)) { chuteID = this.textures.GetCanopyIndex(canopy); }
                    if (this.textures.TryGetModel(chute.parachuteName, ref model, true)) { modelID = this.textures.GetModelIndex(model); }
                    if (RCUtils.types.Contains(currentType)) { typeID = RCUtils.types.ToList().IndexOf(currentType); }
                }

                preDepDiam = chute.preDeployedDiameter.ToString();
                depDiam = chute.deployedDiameter.ToString();
                isPressure = chute.minIsPressure;
                if (isPressure) { predepClause = chute.minPressure.ToString(); }
                else { predepClause = chute.minDeployment.ToString(); }
                deploymentAlt = chute.deploymentAlt.ToString();
                cutAlt = chute.cutAlt.ToString();
                if (cutAlt == "-1") { cutAlt = string.Empty; }
                preDepSpeed = chute.preDeploymentSpeed.ToString();
                depSpeed = chute.deploymentSpeed.ToString();
            }
            position = this.part.FindModelTransform(chute.parachuteName).position;

            if (HighLogic.LoadedSceneIsFlight) { UpdateCanopy(); }
        }
Exemplo n.º 10
0
 /// <summary>
 /// Creates a new RCEditorGUI
 /// </summary>
 /// <param name="pChute">ProceduralChute module to create the object from</param>
 public RCEditorGUI(ProceduralChute pChute)
 {
     this.pChute = pChute;
 }
Exemplo n.º 11
0
 /// <summary>
 /// Creates a new ChuteTemplate from the given ProceduralChute
 /// </summary>
 /// <param name="pChute">Module to create the object from</param>
 /// <param name="node">ConfigNode to load the data from</param>
 /// <param name="id">Index of the ChuteTemplate</param>
 public ChuteTemplate(ProceduralChute pChute, ConfigNode node, int id)
 {
     this.pChute = pChute;
     this.id = id;
     Load(node);
 }
Exemplo n.º 12
0
        //Copies all fields to the symmetry counterpart
        public void CopyFromOriginal(RealChuteModule module, ProceduralChute pChute)
        {
            Parachute sym = module.parachutes[id];
            ChuteTemplate template = pChute.chutes[id];
            parachute = pChute.rcModule.parachutes[id];

            material = sym.mat;
            parachute.deployedDiameter = sym.deployedDiameter;
            parachute.preDeployedDiameter = sym.preDeployedDiameter;
            isPressure = sym.minIsPressure;
            if (isPressure) { parachute.minPressure = sym.minPressure; }
            else { parachute.minDeployment = sym.minDeployment; }
            parachute.deploymentAlt = sym.deploymentAlt;
            parachute.cutAlt = sym.cutAlt;
            parachute.preDeploymentSpeed = sym.preDeploymentSpeed;
            parachute.deploymentSpeed = sym.deploymentSpeed;
            this.chuteID = template.chuteID;
            this.typeID = template.typeID;
            this.modelID = template.modelID;
            this.materialsID = template.materialsID;
            this.isPressure = template.isPressure;
            this.calcSelect = template.calcSelect;
            this.getMass = template.getMass;
            this.useDry = template.useDry;
            this.preDepDiam = template.preDepDiam;
            this.depDiam = template.depDiam;
            this.predepClause = template.predepClause;
            this.mass = template.mass;
            this.landingSpeed = template.landingSpeed;
            this.deceleration = template.deceleration;
            this.refDepAlt = template.refDepAlt;
            this.chuteCount = template.chuteCount;
            this.deploymentAlt = template.deploymentAlt;
            this.cutAlt = template.cutAlt;
            this.preDepSpeed = template.preDepSpeed;
            this.depSpeed = template.depSpeed;
        }
Exemplo n.º 13
0
 /// <summary>
 /// Creates a new ChuteTemplate from the given ProceduralChute
 /// </summary>
 /// <param name="pChute">Module to create the object from</param>
 /// <param name="node">ConfigNode to load the data from</param>
 /// <param name="id">Index of the ChuteTemplate</param>
 public ChuteTemplate(ProceduralChute pChute, ConfigNode node, int id)
 {
     this.pChute = pChute;
     this.id     = id;
     Load(node);
 }