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); }
public override void SetPlayerTeam(SkyPlayer player, GameTeam oldTeam, GameTeam team) { if (oldTeam != null) { TeamPlayerDict[oldTeam].Remove(player); } if (team != null) { TeamPlayerDict[team].Add(player); if (team.IsSpectator) { AddSpectator(player); } else { player.IsGameSpectator = false; //Re-update visible characteristics player.RemoveEffect(new Invisibility()); player.BroadcastSetEntityData(); player.SetNameTagVisibility(true); player.Inventory.SetHeldItemSlot(player.Inventory.InHandSlot, false); } } }