Value() public method

public Value ( float inputs ) : float
inputs float
return float
Beispiel #1
0
    public void UpdateEmitters(float power)
    {
        UpdateInputs(power);

        for (int i = 0; i < persistentEmitters.Count; i++)
        {
            PersistentKSPParticleEmitter pkpe = persistentEmitters[i];

            if (pkpe.go == null)
            {
                continue;
            }

            //pkpe.pe.useWorldSpace
            float finalScale = fixedScale * specialScale;

            float finalSizeClamp = sizeClamp + sizeClampCurve.Value(inputs);

            float sizePower = size.Value(inputs) * finalScale;
            pkpe.pe.minSize = Mathf.Min(pkpe.minSizeBase * sizePower, finalSizeClamp);
            pkpe.pe.maxSize = Mathf.Min(pkpe.maxSizeBase * sizePower, finalSizeClamp);

            float emissionPower = emission.Value(inputs) * emissionMult;
            pkpe.pe.minEmission = Mathf.FloorToInt(pkpe.minEmissionBase * emissionPower);
            pkpe.pe.maxEmission = Mathf.FloorToInt(pkpe.maxEmissionBase * emissionPower);

            float energyPower = energy.Value(inputs);
            pkpe.pe.minEnergy = pkpe.minEnergyBase * energyPower;
            pkpe.pe.maxEnergy = pkpe.maxEnergyBase * energyPower;

            float velocityPower = speed.Value(inputs) * finalScale;
            pkpe.pe.localVelocity = pkpe.localVelocityBase * velocityPower;
            pkpe.pe.worldVelocity = pkpe.worldVelocityBase * velocityPower;

            float forcePower = force.Value(inputs);
            pkpe.pe.force = pkpe.forceBase * forcePower;

            pkpe.pe.sizeGrow = grow.Value(inputs);

            float currentScale = scale.Value(inputs) * finalScale;
            pkpe.pe.shape1D = pkpe.scale1DBase * currentScale;
            pkpe.pe.shape2D = pkpe.scale2DBase * currentScale;
            pkpe.pe.shape3D = pkpe.scale3DBase * currentScale;

            pkpe.sizeClamp = finalSizeClamp;
            pkpe.randomInitalVelocityOffsetMaxRadius = randomInitalVelocityOffsetMaxRadius + initalVelocityOffsetMaxRadius.Value(inputs);

            pkpe.randConeEmit = randConeEmit.Value(inputs);
            pkpe.xyForce      = xyForce.Value(inputs);
            pkpe.zForce       = zForce.Value(inputs);

            pkpe.vRandPosOffset = vRandPosOffset.Value(inputs);
            pkpe.vPosOffset     = vPosOffset.Value(inputs);

            pkpe.physical        = physical && !SmokeScreenConfig.Instance.globalPhysicalDisable;
            pkpe.initialDensity  = initialDensity;
            pkpe.dragCoefficient = dragCoefficient;

            pkpe.collide      = collide && !SmokeScreenConfig.Instance.globalCollideDisable;
            pkpe.stickiness   = stickiness;
            pkpe.collideRatio = collideRatio;

            pkpe.logarithmicGrow      = logGrow.Value(inputs);
            pkpe.logarithmicGrowScale = logGrowScale.Value(inputs);

            pkpe.linearGrow = linGrow.Value(inputs);

            if (alpha.Value(inputs) != 1 || linAlphaDecay.Value(inputs) != 0 || logAlphaDecay.Value(inputs) != 0)
            {
                Color[] cols = new Color[5];

                for (int t = 0; t < 5; t++)
                {
                    float a =
                        Mathf.Clamp01(alpha.Value(inputs) *
                                      (1 - linAlphaDecay.Value(inputs) * (t / 4) -
                                       Mathf.Log(logAlphaDecay.Value(inputs) * (t / 4) + 1)));
                    cols[t] = new Color(a, a, a, a);
                }

                pkpe.pe.colorAnimation   = cols;
                pkpe.pe.doesAnimateColor = true;
            }

            pkpe.go.transform.localPosition = localPosition
                                              + offsetDirection.normalized * offset.Value(inputs) * finalScale;

            pkpe.go.transform.localRotation = Quaternion.Euler(localRotation);


            if (renderMode != lastRenderMode)
            {
                // Bad code is bad
                try
                {
                    pkpe.pe.particleRenderMode = (ParticleRenderMode)Enum.Parse(typeof(ParticleRenderMode), renderMode);
                }
                catch (ArgumentException) { }
                lastRenderMode = renderMode;
            }
        }
    }
    public void UpdateEmitters(float power)
    {
        UpdateInputs(power);

        for (int i = 0; i < persistentEmitters.Count; i++)
        {
            PersistentKSPShurikenEmitter pkpe = persistentEmitters[i];

            if (pkpe.go == null)
            {
                continue;
            }

            float finalScale = fixedScale * specialScale;

            float finalSizeClamp = sizeClamp + sizeClampCurve.Value(inputs);

            float sizePower = size.Value(inputs) * finalScale;
            pkpe.minSize = Mathf.Min(pkpe.minSizeBase * sizePower, finalSizeClamp);
            pkpe.maxSize = Mathf.Min(pkpe.maxSizeBase * sizePower, finalSizeClamp);

            float emissionPower = emission.Value(inputs) * emissionMult;
            pkpe.minEmission = Mathf.FloorToInt(pkpe.minEmissionBase * emissionPower);
            pkpe.maxEmission = Mathf.FloorToInt(pkpe.maxEmissionBase * emissionPower);

            float energyPower = energy.Value(inputs);
            pkpe.minEnergy = pkpe.minEnergyBase * energyPower;
            pkpe.maxEnergy = pkpe.maxEnergyBase * energyPower;

            float velocityPower = speed.Value(inputs) * finalScale;
            pkpe.localVelocity = pkpe.localVelocityBase * velocityPower;
            pkpe.worldVelocity = pkpe.worldVelocityBase * velocityPower;

            float forcePower = force.Value(inputs);
            pkpe.force = pkpe.forceBase * forcePower;

            ParticleSystem.ForceOverLifetimeModule fol = pkpe.pe.forceOverLifetime;
            fol.enabled = pkpe.force.sqrMagnitude > 0 || pkpe.rndForce.sqrMagnitude > 0;
            fol.x       = new ParticleSystem.MinMaxCurve(pkpe.forceBase.x, pkpe.force.x + pkpe.rndForce.x);
            fol.y       = new ParticleSystem.MinMaxCurve(pkpe.forceBase.y, pkpe.force.y + pkpe.rndForce.y);
            fol.z       = new ParticleSystem.MinMaxCurve(pkpe.forceBase.z, pkpe.force.z + pkpe.rndForce.z);

            pkpe.sizeGrow = grow.Value(inputs);

            float currentScale = scale.Value(inputs) * finalScale;
            pkpe.shape1D = pkpe.scale1DBase * currentScale;
            pkpe.shape2D = pkpe.scale2DBase * currentScale;
            pkpe.shape3D = pkpe.scale3DBase * currentScale;

            pkpe.sizeClamp = finalSizeClamp;
            pkpe.randomInitalVelocityOffsetMaxRadius = randomInitalVelocityOffsetMaxRadius + initalVelocityOffsetMaxRadius.Value(inputs);

            pkpe.randConeEmit = randConeEmit.Value(inputs);
            pkpe.xyForce      = xyForce.Value(inputs);
            pkpe.zForce       = zForce.Value(inputs);

            pkpe.vRandPosOffset = vRandPosOffset.Value(inputs);
            pkpe.vPosOffset     = vPosOffset.Value(inputs);

            pkpe.physical        = physical && !SmokeScreenConfig.Instance.globalPhysicalDisable;
            pkpe.initialDensity  = initialDensity;
            pkpe.dragCoefficient = dragCoefficient;

            pkpe.collide      = collide && !SmokeScreenConfig.Instance.globalCollideDisable;
            pkpe.stickiness   = stickiness;
            pkpe.collideRatio = collideRatio;

            pkpe.logarithmicGrow      = logGrow.Value(inputs);
            pkpe.logarithmicGrowScale = logGrowScale.Value(inputs);

            pkpe.decluster = decluster;

            pkpe.emitOnUpdate = EmitOnUpdate;

            pkpe.linearGrow = linGrow.Value(inputs);

            if (alpha.Value(inputs) != 1 || linAlphaDecay.Value(inputs) != 0 || logAlphaDecay.Value(inputs) != 0)
            {
                //Color[] cols = new Color[5];

                GradientColorKey[] colorKeys = new GradientColorKey[5];
                GradientAlphaKey[] alphaKeys = new GradientAlphaKey[5];

                for (int t = 0; t < 5; t++)
                {
                    float a =
                        Mathf.Clamp01(alpha.Value(inputs) *
                                      (1 - linAlphaDecay.Value(inputs) * (t / 4f) -
                                       Mathf.Log(logAlphaDecay.Value(inputs) * (t / 4f) + 1)));
                    colorKeys[t] = new GradientColorKey(Color.red, t * 0.25f);
                    alphaKeys[t] = new GradientAlphaKey(a, t * 0.25f);
                }

                ParticleSystem.ColorOverLifetimeModule col = pkpe.pe.colorOverLifetime;
                col.enabled = true;

                Gradient gradient = new Gradient();
                gradient.SetKeys(colorKeys, alphaKeys);

                col.color = new ParticleSystem.MinMaxGradient(gradient);
            }

            pkpe.saturationMult = saturationMult.Value(inputs);
            pkpe.brightnessMult = brightnessMult.Value(inputs);
            pkpe.alphaMult      = alphaMult.Value(inputs);

            pkpe.go.transform.localPosition = localPosition
                                              + offset.Value(inputs) * finalScale * offsetDirection.normalized;

            pkpe.go.transform.localRotation = Quaternion.Euler(localRotation);
        }
    }