Exemplo n.º 1
0
        internal void HandleZoom(ThirdPersonState third, bool zoomIn)
        {
            if (third == null)
            {
                return;
            }

            this._init_z();

            if (this._min_zoom == null || this._inc_zoom == null)
            {
                return;
            }

            float min  = this._min_zoom.GetFloat();
            float inc  = this._inc_zoom.GetFloat();
            float cur  = third.TargetZoomLevel;
            float next = cur + (zoomIn ? -1.0f : 1.0f) * inc;

            if (cur <= min && zoomIn)
            {
                third.TargetZoomLevel = min;
                this.SetWantState(WantStates.EnabledFromZoom);
                return;
            }

            if (next < min)
            {
                next = min;
            }
            else if (next > 1.0f)
            {
                next = 1.0f;
            }

            third.TargetZoomLevel = next;

            if (!zoomIn && this.AlreadyHasWantState())
            {
                this.SetWantState(WantStates.DisabledFromZoom);
            }
        }
Exemplo n.º 2
0
        internal void HandleActorTurnToCamera(Actor actor, ThirdPersonState third, bool fromFreeLookChanged)
        {
            if (third == null || actor == null)
            {
                return;
            }

            double x    = third.XRotationFromLastResetPoint;
            double y    = third.YRotationFromLastResetPoint;
            double didx = 0.0;
            double didy = 0.0;

            if (x == 0.0 && y == 0.0)
            {
                return;
            }

            double max  = 0.0;
            double diff = this.Plugin._lastDiff2;
            double time = this.Values.ActorTurnTime.CurrentValue;

            if (time <= 0.0)
            {
                max = Math.PI * 2.0;
            }
            else if (diff >= 1.0)
            {
                max = (diff * 0.001) / time * Math.PI * 2.0;
            }

            // Turn left or right.
            if (x != 0.0)
            {
                double actual = x;
                if (Math.Abs(actual) > max)
                {
                    if (actual < 0.0)
                    {
                        actual = -max;
                    }
                    else
                    {
                        actual = max;
                    }
                }

                Memory.InvokeCdecl(this.Plugin.ActorTurnZ, actor.Address, (float)actual);
                if (actual == x)
                {
                    third.XRotationFromLastResetPoint = 0.0f;
                }
                else
                {
                    third.XRotationFromLastResetPoint -= (float)actual;
                }

                didx = actual;
            }

            // Turn up or down.
            if (y != 0.0)
            {
                double actual = y;
                Memory.InvokeCdecl(this.Plugin.ActorTurnX, actor.Address, -(float)actual);
                third.YRotationFromLastResetPoint = 0.0f;

                didy = actual;
            }

            // Fix visual error with turning.
            if (fromFreeLookChanged)
            {
                int duration = 1;
                if (this.IsEnabled && this.LastActorTurnFrames < duration)
                {
                    this.LastActorTurnX      = (float)didx;
                    this.LastActorTurnY      = (float)didy;
                    this.LastActorTurnFrames = duration;
                }
            }
        }