Esempio n. 1
0
        protected override void BroadCastMovement(Player[] players, Player[] updatedPlayers)
        {
            if (updatedPlayers.Length == 0) return;

            var moveEntity = McpeMoveEntity.CreateObject(players.Count());
            moveEntity.entities = new EntityLocations();

            //var rotateHead = McpeRotateHead.CreateObject(players.Count());
            //rotateHead.entities = new EntityHeadRotations();

            foreach (var player in updatedPlayers)
            {
                Entity entity;
                if (!_playerEntities.TryGetValue(player, out entity)) continue;

                entity.KnownPosition = (PlayerLocation) player.KnownPosition.Clone();
                if (entity.EntityTypeId == 10)
                {
                    //BUG: Duck has it's value reversed
                    entity.KnownPosition.Pitch = -player.KnownPosition.Pitch;
                }
                moveEntity.entities.Add(entity.EntityId, entity.KnownPosition);
                //rotateHead.entities.Add(entity.EntityId, entity.KnownPosition);
            }

            moveEntity.Encode();
            //rotateHead.Encode();

            new Task(() => RelayBroadcast(moveEntity)).Start();
            //new Task(() => RelayBroadcast(rotateHead)).Start();
        }