Esempio n. 1
0
        public override void OnSnapshot(int snappingClient,
                                        out SnapshotPlayerInfo playerInfo,
                                        out SnapshotSpectatorInfo spectatorInfo,
                                        out SnapshotDemoClientInfo demoClientInfo)
        {
            playerInfo     = null;
            spectatorInfo  = null;
            demoClientInfo = null;

            if (!IsDummy && !Server.ClientInGame(ClientId))
            {
                return;
            }

            playerInfo = Server.SnapshotItem <SnapshotPlayerInfo>(ClientId);
            if (playerInfo == null)
            {
                return;
            }

            playerInfo.PlayerFlags = PlayerFlags & PlayerFlags.Chatting;

            if (Server.IsAuthed(ClientId))
            {
                playerInfo.PlayerFlags |= PlayerFlags.Admin;
            }
            if (!GameContext.GameController.IsPlayerReadyMode() || IsReadyToPlay)
            {
                playerInfo.PlayerFlags |= PlayerFlags.Ready;
            }
            if (RespawnDisabled && (Character == null || !Character.IsAlive))
            {
                playerInfo.PlayerFlags |= PlayerFlags.Dead;
            }
            if (snappingClient != -1 && (Team == Team.Spectators || DeadSpectatorMode) && snappingClient == SpectatorId)
            {
                playerInfo.PlayerFlags |= PlayerFlags.Watching;
            }

            playerInfo.Latency = snappingClient == -1
                ? Latency.Min
                : GameContext.Players[snappingClient].ActualLatency[ClientId];
            playerInfo.Score = GameContext.GameController.Score(ClientId);

            if (ClientId == snappingClient && (Team == Team.Spectators || DeadSpectatorMode))
            {
                spectatorInfo = Server.SnapshotItem <SnapshotSpectatorInfo>(ClientId);
                if (spectatorInfo == null)
                {
                    return;
                }

                spectatorInfo.SpectatorMode = SpectatorMode;
                spectatorInfo.SpectatorId   = SpectatorId;

                if (SpectatorFlag != null)
                {
                    spectatorInfo.X = (int)SpectatorFlag.Position.x;
                    spectatorInfo.Y = (int)SpectatorFlag.Position.y;
                }
                else
                {
                    spectatorInfo.X = (int)ViewPos.x;
                    spectatorInfo.Y = (int)ViewPos.y;
                }
            }

            if (snappingClient == -1)
            {
                demoClientInfo = Server.SnapshotItem <SnapshotDemoClientInfo>(ClientId);
                if (demoClientInfo == null)
                {
                    return;
                }

                demoClientInfo.Local   = 0;
                demoClientInfo.Team    = Team;
                demoClientInfo.Name    = Server.ClientName(ClientId);
                demoClientInfo.Clan    = Server.ClientClan(ClientId);
                demoClientInfo.Country = Server.ClientCountry(ClientId);

                for (var part = SkinPart.Body; part < SkinPart.NumParts; part++)
                {
                    demoClientInfo[part] = TeeInfo[part];
                }
            }
        }
Esempio n. 2
0
 public abstract void OnSnapshot(int snappingClient,
                                 out SnapshotPlayerInfo playerInfo,
                                 out SnapshotSpectatorInfo spectatorInfo,
                                 out SnapshotDemoClientInfo demoClientInfo);