예제 #1
0
        public void SetMotion(MotionCommand motion, bool start)
        {
            if (Player == null)
            {
                return;
            }

            var cmdStruct = new CmdStruct();

            cmdStruct.Args[0] = 0;
            cmdStruct.Args[1] = (uint)motion;
            cmdStruct.Args[2] = Convert.ToUInt32(start);
            cmdStruct.Args[3] = 4;

            // vfptr[12].OnLoseFocus - HandleKeyboardCommand
            HandleKeyboardCommand(cmdStruct, motion);
        }
예제 #2
0
 public void HandleMouseMovementCommand(CmdStruct cmdStruct)
 {
 }
예제 #3
0
        public void HandleKeyboardCommand(CmdStruct cmdStruct, MotionCommand command)
        {
            // vfptr[12] - IsActive
            if (!IsActive())
            {
                return;
            }

            bool start;

            if (cmdStruct.Command == MotionCommand.AutoRun)
            {
                start = Convert.ToBoolean(cmdStruct.Args[cmdStruct.Curr]);
                cmdStruct.Curr++;
                if (cmdStruct.Curr >= cmdStruct.Size)
                {
                    AutoRunSpeed = 1.0f;
                }
                else
                {
                    AutoRunSpeed = BitConverter.ToSingle(BitConverter.GetBytes(cmdStruct.Args[cmdStruct.Curr]));
                    cmdStruct.Curr++;
                }
                // vfptr[16].OnLoseFocus - ToggleAutoRun
                ToggleAutoRun();
                // vfptr[6].OnAction - SendMovementEvent
                SendMovementEvent();
                return;
            }

            if (((uint)cmdStruct.Command & (uint)CommandMask.UI) != 0)
            {
                return;
            }

            start = Convert.ToBoolean(cmdStruct.Args[cmdStruct.Curr]);
            cmdStruct.Curr++;

            var speed = 1.0f;

            if (cmdStruct.Curr < cmdStruct.Size)
            {
                speed = BitConverter.ToSingle(BitConverter.GetBytes(cmdStruct.Args[cmdStruct.Curr]));
                cmdStruct.Curr++;
            }

            if (ControlledByServer && !start)
            {
                // vfptr[1].OnLoseFocus - MovePlayer?
                MovePlayer((MotionCommand)cmdStruct.Command, start, speed, false, false);
                return;
            }

            // vfptr[8].OnLoseFocus(a2) - ACCmdInterp::TakeControlFromServer?
            TakeControlFromServer();

            if (cmdStruct.Command == MotionCommand.HoldRun‬)
            {
                // vfptr[2].OnLoseFocus

                if (!IsStandingStill())
                {
                    SendMovementEvent();
                }

                return;
            }

            if (cmdStruct.Command == MotionCommand.HoldSidestep)
            {
                // vfptr[3]

                if (!IsStandingStill())
                {
                    SendMovementEvent();
                }

                return;
            }

            // vfptr[2] - Bookkeep
            if (!BookkeepCommandAndModifyIfNecessary(cmdStruct.Command, start, speed, false, false))
            {
                SendMovementEvent();
                return;
            }

            // vfptr[4].OnAction - ApplyHoldKeysToCommand
            ApplyHoldKeysToCommand(ref cmdStruct.Command, speed);

            // vfptr[13].OnAction - MovePlayer
            MovePlayer(cmdStruct.Command, start, speed, false, false);

            // vfptr[6].OnAction - SendMovementEvent
            if (cmdStruct.Command != MotionCommand.Jump)
            {
                SendMovementEvent();
            }
        }