BDAnimationModules.MouseAimLight.OnFixedUpdate C# (CSharp) Method

OnFixedUpdate() public method

public OnFixedUpdate ( ) : void
return void
        public override void OnFixedUpdate()
        {
            if(!vessel.IsControllable)
            {
                turretEnabled = false;
            }

            bool hasPower;
            if(turretEnabled && part.RequestResource("ElectricCharge", resourceAmount * TimeWarp.fixedDeltaTime) >= resourceAmount * TimeWarp.fixedDeltaTime)
            {
                hasPower = true;
            }
            else
            {
                hasPower = false;
                //turretEnabled = false;
            }

            if(deployAnimName!="")
            {
                foreach(AnimationState anim in deployStates)
                {
                    //animation clamping
                    if(anim.normalizedTime>1)
                    {
                        anim.speed = 0;
                        anim.normalizedTime = 1;
                    }
                    if(anim.normalizedTime < 0)
                    {
                        anim.speed = 0;
                        anim.normalizedTime = 0;
                    }

                    //deploying
                    if(turretEnabled)
                    {
                        if(anim.normalizedTime<1 && anim.speed<1)
                        {
                            anim.speed = 1;
                            deployed = false;
                        }
                        if(anim.normalizedTime == 1)
                        {
                            deployed = true;
                            anim.enabled = false;
                        }
                    }

                    //retracting
                    if(!turretEnabled)
                    {
                        spotLight.intensity = Mathf.MoveTowards(spotLight.intensity, 0, 3*spotlightIntensity * TimeWarp.fixedDeltaTime);

                        deployed = false;
                        ReturnTurret();

                        if(turretZeroed)
                        {
                            spotLight.enabled = false;
                            anim.enabled = true;
                            if(anim.normalizedTime > 0 && anim.speed > -1)
                            {
                                anim.speed = -1;
                            }
                        }
                    }
                }
            }
            else
            {
                deployed = turretEnabled;
            }

            if(hasPower && deployed && (TimeWarp.WarpMode!=TimeWarp.Modes.HIGH || TimeWarp.CurrentRate == 1))
            {
                if(mouseTracking)
                {
                    Aim(GetTarget());
                }
                else
                {
                    Aim (transform.TransformPoint(localAimPoint));
                }
                spotLight.enabled = true;
                spotLight.intensity = Mathf.MoveTowards(spotLight.intensity, spotlightIntensity, spotlightIntensity * TimeWarp.fixedDeltaTime);
            }
            if(!hasPower)
            {
                spotLight.intensity = Mathf.MoveTowards(spotLight.intensity, 0, 3*spotlightIntensity * TimeWarp.fixedDeltaTime);
                if(spotLight.intensity == 0)
                {
                    spotLight.enabled = false;
                }
            }
            //emissive
            float colorSet = spotLight.intensity/spotlightIntensity;
            emissiveMatRef.SetColor("_EmissiveColor", new Color(colorSet,colorSet,colorSet,1));
        }