MultiInputCurve.Value C# (CSharp) Method

Value() public method

public Value ( float inputs ) : float
inputs float
return float
    public float Value(float[] inputs)
    {
        float result = additive ? 0f : 1f;

        for (int i = 0; i < inputsCount; i++)
        {
            float input = inputs[i];

            result = additive ? result + curves[i].Value(input) : result * curves[i].Value(input);

            if (logCurves[i] != null)
            {
                result = additive
                    ? result + logCurves[i].Value(Mathf.Log10(input))
                    : result * logCurves[i].Value(Mathf.Log10(input));
            }
        }
        return result;
    }

Usage Example

Ejemplo n.º 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;
            }
        }
    }
All Usage Examples Of MultiInputCurve::Value