Exemple #1
0
        public void UpdatePlayerMovement(ClientPlayerMovement msg)
        {
            if (body == null)
            {
                Create();
            }

            body.SetActive(true);

            var arms = (ArmsController)playerView.GetComponent(typeof(ArmsController));

            if (arms != null)
            {
                arms.SetWorldIKTarget(null, null);
                UnityEngine.GameObject.Destroy(arms);
            }

            animator.updating = true;
            smoothTransform.SetEnabled();

            var subroot     = GuidHelper.FindComponent <SubRoot>(msg.subGuid);
            var newPosition = (subroot != null) ? (msg.subPosition + subroot.transform.position) : msg.position;

            SetSubRoot(subroot);
            SetPilotingChair(null);
            SetVehicle(null);

            smoothTransform.Correct(newPosition, msg.bodyRotation, msg.velocity, msg.timestamp);
            animator.Correct(msg);
        }
        public void Correct(ClientPlayerMovement msg)
        {
            underwater     = msg.underwater;
            targetVelocity = msg.velocity;
            lookRotation   = msg.lookRotation;
            mode           = msg.mode;

            main.SetBool("is_underwater", msg.underwater && msg.motorMode != Player.MotorMode.Vehicle);
            main.SetBool("using_pda", msg.usingPda);
            main.SetBool("using_tool", msg.usingTool);
            main.SetBool("holding_tool", msg.handTool != TechType.None);
            main.SetBool("cyclops_steering", msg.mode == Player.Mode.Piloting);
            main.SetBool("jump", msg.falling);

            if (toolActive != null)
            {
                SetToolAnimation(toolActive, false);
                toolActive = null;
            }

            if (inventory != null)
            {
                toolActive = inventory.Get(msg.handGuid);
            }

            if (toolActive != null)
            {
                SetToolAnimation(toolActive, true);
            }
        }
Exemple #3
0
        private void Process(ClientPlayerMovement msg)
        {
            RemotePlayer remotePlayer;

            if (remotePlayers.TryGetValue(msg.id, out remotePlayer))
            {
                remotePlayer.UpdatePlayerMovement(msg);
            }
            else if (msg.id == self.id)
            {
                var player = Player.main;
                player.SetPosition(msg.position, msg.lookRotation);
                player.OnPlayerPositionCheat();

                var subroot = GuidHelper.FindComponent <SubRoot>(msg.subGuid);
                if (subroot != null)
                {
                    var respawn = subroot.gameObject.GetComponentInChildren <RespawnPoint>();
                    if (respawn != null)
                    {
                        player.SetPosition(respawn.GetSpawnPosition());
                        player.SetCurrentSub(subroot);
                    }
                }
            }
        }
Exemple #4
0
        private void Process(Client client, ClientPlayerMovement msg)
        {
            msg.id = client.id;
            client.player.movement = msg;
            client.SetVehicle(null);

            SendToAll(client.peer, msg, DeliveryMethod.Sequenced);
        }
Exemple #5
0
        private static void UpdatePlayer(Player player)
        {
            var res = new ClientPlayerMovement();

            res.timestamp    = DayNightCycle.main.timePassedAsDouble;
            res.id           = Multiplayer.main.self.id;
            res.position     = player.transform.position;
            res.velocity     = player.playerController.velocity;
            res.lookRotation = Player.main.camRoot.GetAimingTransform().rotation;

            var subroot = Player.main.currentSub;

            if (subroot != null)
            {
                res.subGuid     = GuidHelper.Get(subroot.gameObject);
                res.subPosition = player.transform.position - subroot.transform.position;
            }

            if (MainCameraControl.main != null)
            {
                res.bodyRotation = MainCameraControl.main.viewModel.transform.rotation;
            }

            var tool = Inventory.main.GetHeldTool();

            if (tool != null)
            {
                res.handTool  = tool.pickupable.GetTechType();
                res.usingTool = tool.isInUse;
                res.handGuid  = GuidHelper.Get(tool.gameObject);
            }
            else
            {
                res.handTool = TechType.None;
            }

            res.mode       = player.GetMode();
            res.motorMode  = player.motorMode;
            res.underwater = player.IsUnderwater();
            res.falling    = player.GetPlayFallingAnimation();
            res.usingPda   = player.GetPDA().isInUse;

            Multiplayer.main.Send(res, DeliveryMethod.Sequenced);
        }
 void HandleMovement(ClientPlayerMovement packet)
 {
     HandleMovementOpcode(packet.GetOpcode(), packet.Status);
 }
Exemple #7
0
 void HandleMovement(ClientPlayerMovement packet)
 {
     HandleMovementOpcode(packet.GetOpcode(), packet.movementInfo);
 }