コード例 #1
0
        public override void AddSpectator(SkyPlayer player)
        {
            player.IsGameSpectator = true;

            //Set an invisibily effect on top of the scale to completely 'remove' the player
            player.SetEffect(new Invisibility {
                Duration = int.MaxValue, Particles = false
            });

            player.SetNameTagVisibility(false);

            McpeSetEntityData mcpeSetEntityData = McpeSetEntityData.CreateObject();

            mcpeSetEntityData.runtimeEntityId = player.EntityId;
            mcpeSetEntityData.metadata        = player.GetMetadata();
            mcpeSetEntityData.metadata[(int)Entity.MetadataFlags.Scale] = new MetadataFloat(0.5f);              // Scale

            //Avoid changing the local player's scale
            foreach (SkyPlayer gamePlayer in GetAllPlayers())
            {
                if (gamePlayer == player)
                {
                    continue;
                }

                gamePlayer.SendPackage(mcpeSetEntityData);
            }

            //Update slot held for other players
            player.Inventory.SetHeldItemSlot(player.Inventory.InHandSlot, false);
        }