Пример #1
0
        public void Update(GameTime time)
        {
            MouseState state = Mouse.GetState();

            this.wheelTurns      = state.ScrollWheelValue - this.lastState.ScrollWheelValue;
            this.wheelTurnedUp   = FezButtonStateExtensions.NextState(this.wheelTurnedUp, this.wheelTurns > 0);
            this.wheelTurnedDown = FezButtonStateExtensions.NextState(this.wheelTurnedDown, this.wheelTurns < 0);
            if (this.renderPanelHandle != this.parentFormHandle)
            {
                state = Mouse.GetState();
            }
            this.movement = new Point(state.X - this.position.X, state.Y - this.position.Y);
            this.position = new Point(state.X, state.Y);
            if (state != this.lastState)
            {
                bool hasMoved = this.movement.X != 0 || this.movement.Y != 0;
                this.leftButton   = this.DeduceMouseButtonState(this.leftButton, this.lastState.LeftButton, state.LeftButton, hasMoved);
                this.middleButton = this.DeduceMouseButtonState(this.middleButton, this.lastState.MiddleButton, state.MiddleButton, hasMoved);
                this.rightButton  = this.DeduceMouseButtonState(this.rightButton, this.lastState.RightButton, state.RightButton, hasMoved);
                this.lastState    = state;
            }
            else
            {
                this.ResetButton(ref this.leftButton);
                this.ResetButton(ref this.middleButton);
                this.ResetButton(ref this.rightButton);
            }
        }
Пример #2
0
 public static bool IsDown(this FezButtonState state)
 {
     if (state != FezButtonState.Pressed)
     {
         return(state == FezButtonState.Down);
     }
     else
     {
         return(true);
     }
 }
Пример #3
0
        // we transition gamepad buttons here because it involves a lot more injection to do it in GamepadsManager
        private FezButtonState Transition(FezButtonState state)
        {
            if (UseGamepadState == FezButtonState.Down)
            {
                return(state);
            }
            if (state == FezButtonState.Down || state == UseGamepadState)
            {
                return(UseGamepadState);
            }

            return(FezButtonState.Up);
        }
Пример #4
0
 // symetric coalescing that prefers the pressed state, unlike the original coalescing
 private static FezButtonState Coalesce(FezButtonState first, FezButtonState second)
 {
     if (first == FezButtonState.Up)
     {
         return(second);
     }
     if (second == FezButtonState.Up)
     {
         return(first);
     }
     if (first == second)
     {
         return(first);
     }
     return(FezButtonState.Down);
 }
Пример #5
0
        public static FezButtonState NextState(this FezButtonState state, bool pressed)
        {
            switch (state)
            {
            case FezButtonState.Up:
                return(!pressed ? FezButtonState.Up : FezButtonState.Pressed);

            case FezButtonState.Pressed:
                return(!pressed ? FezButtonState.Released : FezButtonState.Down);

            case FezButtonState.Released:
                return(!pressed ? FezButtonState.Up : FezButtonState.Pressed);

            default:
                return(!pressed ? FezButtonState.Released : FezButtonState.Down);
            }
        }
Пример #6
0
        protected override bool Act(TimeSpan elapsed)
        {
            NearestTriles nearestTriles = this.LevelManager.NearestTrile(this.PlayerManager.HeldInstance.Center);
            CollisionType collisionType = CollisionType.None;
            bool          flag          = false;

            if (nearestTriles.Deep != null)
            {
                collisionType = nearestTriles.Deep.GetRotatedFace(FezMath.VisibleOrientation(this.CameraManager.Viewpoint));
                flag          = flag | collisionType == CollisionType.AllSides;
            }
            if (flag && (this.InputManager.RotateLeft == FezButtonState.Pressed || this.InputManager.RotateRight == FezButtonState.Pressed))
            {
                this.InputManager.PressedToDown();
            }
            if (nearestTriles.Deep == null)
            {
                flag = true;
            }
            if (nearestTriles.Deep != null)
            {
                flag = flag | collisionType == CollisionType.TopNoStraightLedge;
            }
            FezButtonState fezButtonState = this.PlayerManager.Animation.Timing.Ended ? FezButtonState.Down : FezButtonState.Pressed;

            if (this.CameraManager.ActionRunning && !flag && (this.PlayerManager.LookingDirection == HorizontalDirection.Right && this.InputManager.Right == fezButtonState || this.PlayerManager.LookingDirection == HorizontalDirection.Left && this.InputManager.Left == fezButtonState))
            {
                bool    background1 = this.PlayerManager.Background;
                Vector3 position    = this.PlayerManager.Position;
                this.PlayerManager.Position += FezMath.RightVector(this.CameraManager.Viewpoint) * (float)-FezMath.Sign(this.PlayerManager.LookingDirection) * 0.5f;
                this.PhysicsManager.DetermineInBackground((IPhysicsEntity)this.PlayerManager, true, false, false);
                bool background2 = this.PlayerManager.Background;
                this.PlayerManager.Background = background1;
                this.PlayerManager.Position   = position;
                if (!background2)
                {
                    this.PlayerManager.Action = ActionType.FromCornerBack;
                    return(false);
                }
            }
            this.huggedCorner           = (-(!this.rotatedFrom.HasValue ? FezMath.RightVector(this.CameraManager.Viewpoint) * (float)FezMath.Sign(this.PlayerManager.LookingDirection) : FezMath.RightVector(this.rotatedFrom.Value) * (float)FezMath.Sign(this.PlayerManager.LookingDirection)) + Vector3.UnitY * (float)Math.Sign(this.CollisionManager.GravityFactor)) * this.PlayerManager.HeldInstance.TransformedSize / 2f;
            this.PlayerManager.Position = this.PlayerManager.HeldInstance.Center + this.huggedCorner;
            return(true);
        }
Пример #7
0
 public extern void orig_set_Up(FezButtonState value);
Пример #8
0
 public extern void orig_set_RotateRight(FezButtonState value);
Пример #9
0
 public extern void orig_set_OpenInventory(FezButtonState value);
Пример #10
0
 public extern void orig_set_MapZoomOut(FezButtonState value);
Пример #11
0
 private TimedAnalogButtonState(float value, FezButtonState state, TimeSpan timePressed)
 {
   this.Value = value;
   this.State = state;
   this.TimePressed = timePressed;
 }
Пример #12
0
 public extern void orig_set_CancelTalk(FezButtonState value);
Пример #13
0
 private TimedAnalogButtonState(float value, FezButtonState state, TimeSpan timePressed)
 {
     this.Value       = value;
     this.State       = state;
     this.TimePressed = timePressed;
 }
Пример #14
0
        // replace to make the transitions between playback and record much smoother
        // [MonoModReplace]
        public void Update(GameTime gameTime)
        {
            // Logger.Log("TAS", "IM Update");

            // keyboard
            KeyboardState.Update(Keyboard.GetState(), gameTime);
            Back          = KeyboardState.OpenMap;
            Start         = KeyboardState.Pause;
            Jump          = KeyboardState.Jump;
            GrabThrow     = KeyboardState.GrabThrow;
            CancelTalk    = KeyboardState.CancelTalk;
            Down          = KeyboardState.Down;
            Up            = KeyboardState.Up;
            Left          = KeyboardState.Left;
            Right         = KeyboardState.Right;
            OpenInventory = KeyboardState.OpenInventory;
            RotateLeft    = KeyboardState.RotateLeft;
            RotateRight   = KeyboardState.RotateRight;
            MapZoomIn     = KeyboardState.MapZoomIn;
            MapZoomOut    = KeyboardState.MapZoomOut;
            FpsToggle     = KeyboardState.FpViewToggle;
            ClampLook     = KeyboardState.ClampLook;

            FreeLook = new Vector2(KeyboardState.LookRight.IsDown() ? 1f : (KeyboardState.LookLeft.IsDown() ? -1f : 0.0f), KeyboardState.LookUp.IsDown() ? 1f : (KeyboardState.LookDown.IsDown() ? -1f : 0.0f));

            if (gamepad && UseGamepadState != FezButtonState.Up)
            {
                PlayerIndex[] players = ControllerIndex.Any.GetPlayers();
                for (int index = 0; index < players.Length; ++index)
                {
                    GamepadState gamepadState = GamepadsManager[players[index]];
                    if (!gamepadState.Connected)
                    {
                        if (gamepadState.NewlyDisconnected && ActiveControllerDisconnected != null)
                        {
                            ActiveControllerDisconnected(players[index]);
                        }
                    }
                    else
                    {
                        ClampLook     = Coalesce(ClampLook, Transition(gamepadState.RightStick.Clicked.State));
                        FpsToggle     = Coalesce(FpsToggle, Transition(gamepadState.LeftStick.Clicked.State));
                        Back          = Coalesce(Back, Transition(gamepadState.Back));
                        Start         = Coalesce(Start, Transition(gamepadState.Start));
                        Jump          = Coalesce(Jump, Transition(gamepadState.A.State));
                        GrabThrow     = Coalesce(GrabThrow, Transition(gamepadState.X.State));
                        CancelTalk    = Coalesce(CancelTalk, Transition(gamepadState.B.State));
                        OpenInventory = Coalesce(OpenInventory, Transition(gamepadState.Y.State));
                        Up            = Coalesce(Up, Coalesce(Transition(gamepadState.DPad.Up.State), Transition(gamepadState.LeftStick.Up.State)));
                        Down          = Coalesce(Down, Coalesce(Transition(gamepadState.DPad.Down.State), Transition(gamepadState.LeftStick.Down.State)));
                        Left          = Coalesce(Left, Coalesce(Transition(gamepadState.DPad.Left.State), Transition(gamepadState.LeftStick.Left.State)));
                        Right         = Coalesce(Right, Coalesce(Transition(gamepadState.DPad.Right.State), Transition(gamepadState.LeftStick.Right.State)));
                        MapZoomIn     = Coalesce(MapZoomIn, Transition(gamepadState.RightShoulder.State));
                        MapZoomOut    = Coalesce(MapZoomOut, Transition(gamepadState.LeftShoulder.State));

                        // for input recording consistency, we always assume StrictRotation
                        RotateLeft  = Coalesce(RotateLeft, Transition(gamepadState.LeftTrigger.State));
                        RotateRight = Coalesce(RotateRight, Transition(gamepadState.RightTrigger.State));

                        // special handling of FreeLook since buttons are not defined on gamepad
                        // but we must emulate keyboard buttons
                        bool right = FreeLook.X > 0 || gamepadState.RightStick.Right.State.IsDown();
                        bool left  = FreeLook.X < 0 || gamepadState.RightStick.Left.State.IsDown();
                        bool up    = FreeLook.Y > 0 || gamepadState.RightStick.Up.State.IsDown();
                        bool down  = FreeLook.Y < 0 || gamepadState.RightStick.Down.State.IsDown();
                        FreeLook = new Vector2(right ? 1f : (left ? -1f : 0.0f), up ? 1f : (down ? -1f : 0.0f));
                    }
                }
            }

            // keyboard and gamepadhave different ways to calculate exact up, so force keyboard calculation
            ExactUp = Up;
            // calculate movement after gamepad so corrected coalesce applies to movement as well
            Movement = new Vector2(Right.IsDown() ? 1f : (Left.IsDown() ? -1f : 0.0f), Up.IsDown() ? 1f : (Down.IsDown() ? -1f : 0.0f));

            // no need to pull mouse since it is disabled anyway

            //finish enabling/disabling gamepad
            UseGamepadState = UseGamepadState.IsDown() ? FezButtonState.Down : FezButtonState.Up;
        }
Пример #15
0
        public void Update(GameTime gameTime)
        {
            FakeInputHelper.Updating = true;

            orig_Update(gameTime);

            FakeInputHelper.PreUpdate(gameTime);

            foreach (KeyValuePair<CodeInputAll, FezButtonState> pair in FakeInputHelper.Overrides) {
                switch (pair.Key) {
                    case CodeInputAll.Back:
                        Back = pair.Value;
                        break;
                    case CodeInputAll.Start:
                        Start = pair.Value;
                        break;
                    case CodeInputAll.Jump:
                        Jump = pair.Value;
                        break;
                    case CodeInputAll.GrabThrow:
                        GrabThrow = pair.Value;
                        break;
                    case CodeInputAll.CancelTalk:
                        CancelTalk = pair.Value;
                        break;
                    case CodeInputAll.Down:
                        Down = pair.Value;
                        if (pair.Value.IsDown()) {
                            Movement = new Vector2(Movement.X, -1f);
                        }
                        break;
                    case CodeInputAll.Up:
                        ExactUp = Up = pair.Value;
                        if (pair.Value.IsDown()) {
                            Movement = new Vector2(Movement.X, 1f);
                        }
                        break;
                    case CodeInputAll.Left:
                        Left = pair.Value;
                        if (pair.Value.IsDown()) {
                            Movement = new Vector2(-1f, Movement.Y);
                        }
                        break;
                    case CodeInputAll.Right:
                        Right = pair.Value;
                        if (pair.Value.IsDown()) {
                            Movement = new Vector2(1f, Movement.Y);
                        }
                        break;
                    case CodeInputAll.OpenInventory:
                        OpenInventory = pair.Value;
                        break;
                    case CodeInputAll.RotateLeft:
                        RotateLeft = pair.Value;
                        break;
                    case CodeInputAll.RotateRight:
                        RotateRight = pair.Value;
                        break;
                    case CodeInputAll.MapZoomIn:
                        MapZoomIn = pair.Value;
                        break;
                    case CodeInputAll.MapZoomOut:
                        MapZoomOut = pair.Value;
                        break;
                    case CodeInputAll.FpsToggle:
                        FpsToggle = pair.Value;
                        break;
                    case CodeInputAll.ClampLook:
                        ClampLook = pair.Value;
                        break;
                    default:
                        //TODO get int value and do something special
                        throw new ArgumentOutOfRangeException();
                }
            }

            FakeInputHelper.PostUpdate(gameTime);

            /*
            Movement = new Vector2(FezButtonStateExtensions.IsDown(KeyboardState.Right) ? 1f : (FezButtonStateExtensions.IsDown(KeyboardState.Left) ? -1f : 0.0f), FezButtonStateExtensions.IsDown(KeyboardState.Up) ? 1f : (FezButtonStateExtensions.IsDown(KeyboardState.Down) ? -1f : 0.0f));
            FreeLook = new Vector2(FezButtonStateExtensions.IsDown(KeyboardState.LookRight) ? 1f : (FezButtonStateExtensions.IsDown(KeyboardState.LookLeft) ? -1f : 0.0f), FezButtonStateExtensions.IsDown(KeyboardState.LookUp) ? 1f : (FezButtonStateExtensions.IsDown(KeyboardState.LookDown) ? -1f : 0.0f));
            Back = KeyboardState.OpenMap;
            Start = KeyboardState.Pause;
            Jump = KeyboardState.Jump;
            GrabThrow = KeyboardState.GrabThrow;
            CancelTalk = KeyboardState.CancelTalk;
            Down = KeyboardState.Down;
            ExactUp = Up = KeyboardState.Up;
            Left = KeyboardState.Left;
            Right = KeyboardState.Right;
            OpenInventory = KeyboardState.OpenInventory;
            RotateLeft = KeyboardState.RotateLeft;
            RotateRight = KeyboardState.RotateRight;
            MapZoomIn = KeyboardState.MapZoomIn;
            MapZoomOut = KeyboardState.MapZoomOut;
            FpsToggle = KeyboardState.FpViewToggle;
            ClampLook = KeyboardState.ClampLook;
            */

            FakeInputHelper.Updating = false;
        }
Пример #16
0
 private TimedButtonState(FezButtonState state, TimeSpan timePressed)
 {
     this.State       = state;
     this.TimePressed = timePressed;
 }
Пример #17
0
 public extern void orig_set_ClampLook(FezButtonState value);
Пример #18
0
 public extern void orig_set_FpsToggle(FezButtonState value);
Пример #19
0
 public extern void orig_set_GrabThrow(FezButtonState value);
Пример #20
0
 public void Update(GameTime time)
 {
   MouseState state = Mouse.GetState();
   this.wheelTurns = state.ScrollWheelValue - this.lastState.ScrollWheelValue;
   this.wheelTurnedUp = FezButtonStateExtensions.NextState(this.wheelTurnedUp, this.wheelTurns > 0);
   this.wheelTurnedDown = FezButtonStateExtensions.NextState(this.wheelTurnedDown, this.wheelTurns < 0);
   if (this.renderPanelHandle != this.parentFormHandle)
     state = Mouse.GetState();
   this.movement = new Point(state.X - this.position.X, state.Y - this.position.Y);
   this.position = new Point(state.X, state.Y);
   if (state != this.lastState)
   {
     bool hasMoved = this.movement.X != 0 || this.movement.Y != 0;
     this.leftButton = this.DeduceMouseButtonState(this.leftButton, this.lastState.LeftButton, state.LeftButton, hasMoved);
     this.middleButton = this.DeduceMouseButtonState(this.middleButton, this.lastState.MiddleButton, state.MiddleButton, hasMoved);
     this.rightButton = this.DeduceMouseButtonState(this.rightButton, this.lastState.RightButton, state.RightButton, hasMoved);
     this.lastState = state;
   }
   else
   {
     this.ResetButton(ref this.leftButton);
     this.ResetButton(ref this.middleButton);
     this.ResetButton(ref this.rightButton);
   }
 }
Пример #21
0
        protected override void TestConditions()
        {
            switch (this.PlayerManager.Action)
            {
            case ActionType.Teetering:
            case ActionType.IdlePlay:
            case ActionType.IdleSleep:
            case ActionType.IdleLookAround:
            case ActionType.IdleYawn:
            case ActionType.Idle:
            case ActionType.LookingLeft:
            case ActionType.LookingRight:
            case ActionType.LookingUp:
            case ActionType.LookingDown:
            case ActionType.Walking:
            case ActionType.Running:
            case ActionType.Jumping:
            case ActionType.Lifting:
            case ActionType.Falling:
            case ActionType.Bouncing:
            case ActionType.Flying:
            case ActionType.Dropping:
            case ActionType.Sliding:
            case ActionType.Landing:
                TrileInstance trileInstance1 = this.IsOnLadder(out this.currentApproach);
                if (this.currentApproach == ClimbingApproach.None)
                {
                    break;
                }
                bool flag = false;
                if (FezButtonStateExtensions.IsDown(this.InputManager.Down) && this.PlayerManager.Grounded)
                {
                    TrileInstance trileInstance2 = this.LevelManager.NearestTrile(trileInstance1.Center - Vector3.UnitY).Surface;
                    flag = trileInstance2 != null && trileInstance2.Trile.ActorSettings.Type == ActorType.Ladder;
                }
                FezButtonState fezButtonState = this.PlayerManager.Grounded ? FezButtonState.Pressed : FezButtonState.Down;
                if (!flag && this.InputManager.Up != fezButtonState && (this.PlayerManager.Grounded || this.currentApproach != ClimbingApproach.Left && this.currentApproach != ClimbingApproach.Right || Math.Sign(this.InputManager.Movement.X) != FezMath.Sign(ClimbingApproachExtensions.AsDirection(this.currentApproach))) || this.lastGrabbed != null && (trileInstance1 == this.lastGrabbed || trileInstance1.Position == this.lastGrabbed.Position + Vector3.UnitY || trileInstance1.Position == this.lastGrabbed.Position - Vector3.UnitY))
                {
                    break;
                }
                this.PlayerManager.HeldInstance = trileInstance1;
                switch (this.currentApproach)
                {
                case ClimbingApproach.Right:
                case ClimbingApproach.Left:
                    this.PlayerManager.NextAction = ActionType.SideClimbingLadder;
                    break;

                case ClimbingApproach.Back:
                    this.PlayerManager.NextAction = ActionType.BackClimbingLadder;
                    break;

                case ClimbingApproach.Front:
                    this.PlayerManager.NextAction = ActionType.FrontClimbingLadder;
                    break;
                }
                if (this.PlayerManager.Grounded)
                {
                    ActionType actionType = this.currentApproach == ClimbingApproach.Back ? ActionType.IdleToClimb : (this.currentApproach == ClimbingApproach.Front ? ActionType.IdleToFrontClimb : (this.currentApproach == ClimbingApproach.Back ? ActionType.IdleToClimb : ActionType.IdleToSideClimb));
                    if (this.CollisionManager.CollidePoint(this.GetDestination(), Vector3.Down, QueryOptions.None, 0.0f, this.CameraManager.Viewpoint).Collided)
                    {
                        this.WalkTo.Destination   = new Func <Vector3>(this.GetDestination);
                        this.WalkTo.NextAction    = actionType;
                        this.PlayerManager.Action = ActionType.WalkingTo;
                    }
                    else
                    {
                        this.PlayerManager.Action    = actionType;
                        this.PlayerManager.Position -= 0.15f * Vector3.UnitY;
                    }
                }
                else
                {
                    this.PlayerManager.Action = this.currentApproach == ClimbingApproach.Back ? ActionType.JumpToClimb : ActionType.JumpToSideClimb;
                }
                if (this.currentApproach != ClimbingApproach.Left && this.currentApproach != ClimbingApproach.Right)
                {
                    break;
                }
                this.PlayerManager.LookingDirection = ClimbingApproachExtensions.AsDirection(this.currentApproach);
                break;
            }
        }