public override bool CanSeeEntity(Entity other) { Player target = other as Player; if (target == null) { return(true); // not a player } if (target == this) { return(true); // always see self } // hidden via /hide or /ohide // TODO: Just use Entities.CanSee if (target.hidden) { return(Rank >= target.hideRank); } if (!ZSGame.Instance.Running || Game.Referee) { return(true); } ZSData data = ZSGame.TryGet(target); return(data == null || !(target.Game.Referee || data.Invisible)); }
unsafe static void UpdatePosition(Player p) { Player[] players = PlayerInfo.Online.Items; byte * src = stackalloc byte[16 * 256]; // 16 = size of absolute update, with extended positions byte * ptr = src; foreach (Player pl in players) { if (p == pl || p.level != pl.level || !p.CanSeeEntity(pl)) { continue; } Orientation rot = pl.Rot; byte pitch = rot.HeadX; if (Server.flipHead || p.flipHead) { pitch = FlippedPitch(pitch); } // flip head when infected, but doesn't support model if (!p.hasChangeModel) { ZSData data = ZSGame.TryGet(p); if (data != null && data.Infected) { pitch = FlippedPitch(pitch); } } rot.HeadX = pitch; Entities.GetPositionPacket(ref ptr, pl.id, pl.hasExtPositions, p.hasExtPositions, pl.tempPos, pl.lastPos, rot, pl.lastRot); } int count = (int)(ptr - src); if (count == 0) { return; } byte[] packet = new byte[count]; for (int i = 0; i < packet.Length; i++) { packet[i] = src[i]; } p.Send(packet); }