コード例 #1
0
        public void MovePlayer(MotionCommand command, bool start, float speed, bool mouse, bool newHoldRun)
        {
            if (Player == null || Player.InqInterpretedMotionState() == null)
            {
                return;
            }

            // if vfptr[10] - PlayerIsDead
            if (PlayerIsDead())
            {
                // vfptr[9].OnAction - LoseKeyboardFocus
                LoseKeyboardFocus();
                // vfptr[17](0, 0) - SetAutoRun
                SetAutoRun(false, false);
                return;
            }

            // if !ICIDM::s_cidm->m_UseMouseTurning
            // - goto LABEL_55

            var mvp = new MovementParameters();

            if (mouse)
            {
                // someFlags &= 0xFFFFF7FF;
                // unset bit 11
                mvp.SetHoldKey = false;
                var holdRun = Convert.ToInt32(newHoldRun) + 1;
            }

            var turn     = (MotionCommand)MotionStance.Invalid;
            var sidestep = (MotionCommand)MotionStance.Invalid;

            if (TurnList.Count != 0)
            {
                turn = TurnList.FirstOrDefault().Command;
            }

            if (SidestepList.Count != 0)
            {
                sidestep = SidestepList.FirstOrDefault().Command;
            }

            // vfptr[17].OnLoseFocus - GetMouseLookActive
            var mouselook = GetMouseLookActive();

            bool start_turn_left      = false;
            bool start_turn_right     = false;
            bool start_sidestep_left  = false;
            bool start_sidestep_right = false;

            bool cancel_turn_left      = false;
            bool cancel_turn_right     = false;
            bool cancel_sidestep_left  = false;
            bool cancel_sidestep_right = false;

            MotionCommand cmd1;

            if (!mouse)
            {
                if (!mouselook)
                {
                    cmd1 = command;
                    // goto LABEL_59
                }
                if (command != MotionCommand.TurnRight)
                {
                    if (command != MotionCommand.TurnLeft)
                    {
                        if (start)
                        {
                            cancel_turn_left    = true;
                            start_sidestep_left = true;
                        }
                        else
                        {
                            cancel_sidestep_left = true;
                        }
                    }
                    else
                    {
                        cancel_turn_right = true;
                        cancel_turn_left  = true;
                    }
                    // goto LABEL_38
                }
                if (!start)
                {
                    cancel_sidestep_right = true;
                    // goto LABEL_38
                }
                // LABEL_31:
                cancel_turn_right    = true;
                start_sidestep_right = true;
                // goto LABEL_38
            }

            if (!mouselook)
            {
                if (turn == MotionCommand.TurnRight)
                {
                    cancel_sidestep_right = true;
                    start_turn_right      = true;
                }
                else if (turn == MotionCommand.TurnLeft)
                {
                    cancel_sidestep_left = true;
                    start_turn_left      = true;
                }
                // goto LABEL_38
            }

            if (command != MotionCommand.MouseLook)
            {
                // goto LABEL_38
            }

            if (turn == MotionCommand.TurnRight)
            {
                cancel_turn_right = true;

                if (sidestep == MotionCommand.SideStepLeft)
                {
                    start_sidestep_left = true;
                }
                else
                {
                    start_sidestep_right = true;
                }

                // goto LABEL_38
            }

            if (turn == MotionCommand.TurnLeft)
            {
                if (sidestep != MotionCommand.SideStepRight)
                {
                    cancel_turn_left    = true;
                    start_sidestep_left = true;

                    // goto LABEL_38
                }
                // goto LABEL_31
            }

            if (MouseLeftDown)
            {
                start   = true;
                command = MotionCommand.WalkForward;
            }

            // ============
            // LABEL 38:

            // vfptr[8].OnLoseFocus - TakeControlFromServer
            TakeControlFromServer();

            if (cancel_sidestep_right)
            {
                Player.StopMotion((uint)MotionCommand.SideStepRight, mvp, true);
            }

            if (cancel_sidestep_left)
            {
                Player.StopMotion((uint)MotionCommand.SideStepLeft, mvp, true);
            }

            if (cancel_turn_right)
            {
                Player.StopMotion((uint)MotionCommand.TurnRight, mvp, true);
            }

            if (cancel_turn_left)
            {
                Player.StopMotion((uint)MotionCommand.TurnLeft, mvp, true);
            }

            if (start_turn_right)
            {
                start = true;
                cmd1  = MotionCommand.TurnRight;
            }
            else
            {
                cmd1 = command;
            }

            if (start_turn_left)
            {
                start = true;
                cmd1  = MotionCommand.TurnLeft;
            }

            if (start_sidestep_right)
            {
                start = true;
                cmd1  = MotionCommand.SideStepRight;
                speed = 1.0f;
            }

            if (start_sidestep_left)
            {
                start   = true;
                command = MotionCommand.SideStepLeft;
                speed   = 1.0f;

                // LABEL_55:
                cmd1 = command;
            }

            var holdRunRel1 = 0;

            if (mouse)
            {
                holdRunRel1 = Convert.ToInt32(newHoldRun) + 1;
                // goto LABEL_60
            }

            // LABEL_59:
            holdRunRel1 = 0;

            // LABEL_60:
            if (AutonomyLevel != 0)
            {
                if (start)
                {
                    if (cmd1 != MotionCommand.Jump)
                    {
                        mvp = new MovementParameters();
                        // set 12th flag
                        mvp.Autonomous = true;
                        if (mouse)
                        {
                            mvp.SetHoldKey = false;     // unset 11th flag
                        }
                        if (((uint)cmd1 & (uint)CommandMask.Action) != 0)
                        {
                            // vfptr[15].OnLoseFocus(this)
                        }
                        var werror = Player.DoMotion((uint)cmd1, mvp);
                        switch (werror)
                        {
                        case WeenieError.None:
                            if (((uint)cmd1 & (uint)CommandMask.Action) != 0)
                            {
                                ActionStamp++;
                            }
                            return;

                        case WeenieError.CantCrouchInCombat:
                            break;      // 72

                        case WeenieError.CantSitInCombat:
                            break;      // 73

                        case WeenieError.CantLieDownInCombat:
                            break;      // 73

                        case WeenieError.YouAreTooTiredToDoThat:
                            break;      // 73

                        case WeenieError.CantChatEmoteInCombat:
                            break;      // 73

                        case WeenieError.CantChatEmoteNotStanding:
                            break;

                        default:
                            return;
                        }
                    }
                }
                else if (cmd1 != MotionCommand.Jump)
                {
                    mvp = new MovementParameters();
                    var holdRunRel = 0;
                    if (mouse)
                    {
                        mvp.SetHoldKey = false;
                        holdRunRel     = Convert.ToInt32(newHoldRun) + 1;
                    }
                    Player.StopMotion((uint)cmd1, mvp, true);
                }
            }
            else
            {
                // vfptr[4].OnLoseFocus - NonAutonomous?
                MovePlayer_NonAutonomous(cmd1, start, speed, (HoldKey)holdRunRel1);
            }
        }