Пример #1
0
        public void UpdateProp()
        {
            ProceduralPart ppart = PPart;

            UpdateFairing();

            if (ppart != null)
            {
                ProceduralShapeBezierCone shape = ppart.CurrentShape as ProceduralShapeBezierCone;

                if (null != shape)
                {
                    float diameter = shape.topDiameter;
                    float length   = shape.length;

                    if (HighLogic.LoadedSceneIsEditor)
                    {
                        float surfaceArea = Mathf.PI * (diameter / 2) * (diameter / 2);

                        PartResource pr = part.Resources[ablativeResource];

                        if (null != pr)
                        {
                            double ratio = pr.maxAmount != 0 ? pr.amount / pr.maxAmount : 1.0;
                            //Debug.LogWarning("ratio: " + ratio);
                            //Debug.LogWarning("amount: " + pr.amount);
                            //Debug.LogWarning("max amount: " + pr.maxAmount);
                            pr.maxAmount = (double)(ablatorPerArea * surfaceArea);
                            pr.amount    = Math.Min(ratio * pr.maxAmount, pr.maxAmount);
                            //ResourceListChanged();
                            MaxAmountChanged(part, pr, pr.maxAmount);
                            InitialAmountChanged(part, pr, pr.maxAmount);
                        }
                    }

                    //Debug.Log(massPerDiameter + " * " + diameter);
                    mass = massPerDiameter * diameter + massFromDiameterCurve.Evaluate(diameter);
                    //Debug.LogWarning("changed mass: " + mass);
                    MassChanged(mass);

                    //Debug.Log("CoL offset " + -length);

                    part.CoLOffset.y = -length;

                    part.CoPOffset.y = CoPoffset.Evaluate(diameter);
                    //Debug.Log("CoP offset: "+ part.CoPOffset.y);


                    if (HighLogic.LoadedSceneIsEditor)
                    {
                        GameEvents.onEditorShipModified.Fire(EditorLogic.fetch.ship);
                    }
                }
            }

            // We don't need to tell FAR, because the shape will do it for us anyway.
        }
Пример #2
0
        // Thats for DRE, which is not updated yet
        //private void UpdateDissipationAndLoss(double ablativeResource)
        //{
        //    // The heat model is going to change considerably.
        //    // Will just do an unconfigurable quick and dirty way for now.
        //    FloatCurve loss = new FloatCurve();
        //    loss.Add(650, 0, 0, 0);
        //    loss.Add(1000, (float)(0.2 * lossTweak * ablativeResource));
        //    loss.Add(3000, (float)(0.3 * lossTweak * ablativeResource), 0, 0);

        //    FloatCurve dissipation = new FloatCurve();
        //    dissipation.Add(300, 0, 0, 0);
        //    dissipation.Add(500, (float)(80000 * dissipationTweak / ablativeResource), 0, 0);

        //    // Save it.
        //    PartModule modHeatShield = part.Modules["ModuleHeatShield"];

        //    Type type = modHeatShield.GetType();

        //    type.GetField("loss").SetValue(modHeatShield, loss);
        //    type.GetField("dissipation").SetValue(modHeatShield, dissipation);
        //}


        public float GetCurrentCostMult()
        {
            if (multiplyCostByDiameter != 0)
            {
                ProceduralPart ppart = PPart;

                if (ppart != null)
                {
                    ProceduralShapeBezierCone shape = ppart.CurrentShape as ProceduralShapeBezierCone;

                    if (null != shape)
                    {
                        float diameter = shape.topDiameter;
                        return(diameter * multiplyCostByDiameter);
                    }
                }
            }


            return(1);
        }