Esempio n. 1
0
        public override void SetTeam(Team team)
        {
            if (Team == team)
            {
                return;
            }

            var prevTeam = Team;

            KillCharacter(WeaponGame);

            Team              = team;
            LastActionTick    = Server.Tick;
            TeamChangeTick    = Server.Tick;
            SpectatorMode     = SpectatorMode.FreeView;
            SpectatorId       = -1;
            SpectatorFlag     = null;
            DeadSpectatorMode = false;
            RespawnTick       = Server.Tick + Server.TickSpeed / 2;

            Server.SendPackMsg(new GameMsg_SvTeam()
            {
                ClientId     = ClientId,
                Team         = team,
                Silent       = true, // TODO
                CooldownTick = TeamChangeTick,
            }, MsgFlags.Vital, -1);

            if (prevTeam == Team.Spectators)
            {
                InactivityTickCounter = 0;
            }

            if (Team == Team.Spectators)
            {
                for (var i = 0; i < GameContext.Players.Length; i++)
                {
                    if (GameContext.Players[i] == null)
                    {
                        continue;
                    }

                    if (GameContext.Players[i].SpectatorMode == SpectatorMode.Player &&
                        GameContext.Players[i].SpectatorId == ClientId)
                    {
                        if (GameContext.Players[i].DeadSpectatorMode)
                        {
                            GameContext.Players[i].UpdateDeadSpecMode();
                        }
                        else
                        {
                            GameContext.Players[i].SpectatorMode = SpectatorMode.FreeView;
                            GameContext.Players[i].SpectatorId   = -1;
                        }
                    }
                }
            }

            TeamChanged?.Invoke(this, prevTeam, team);
        }
Esempio n. 2
0
        private static TeamChanged CreateTeamChangedEvent(int gameId, int currentTeamId, int newTeamId, Base.Enums.Events.TeamChangeReason changeReason)
        {
            var teamChanged = new TeamChanged();

            teamChanged.ChangeReason = changeReason;
            teamChanged.GameId       = gameId;
            teamChanged.LastTeamId   = currentTeamId;
            teamChanged.NewTeamId    = newTeamId;
            return(teamChanged);
        }
Esempio n. 3
0
 private void OnPlayerSwapped(PlayerSwappedArgs playerSwapped)
 {
     TeamChanged?.Invoke(playerSwapped.CurrentPlayer.Team);
 }
 private void OnTeamChanged(int newTeam)
 {
     TeamChanged?.Invoke(team);
 }
Esempio n. 5
0
 public void TeamChanged(TeamChanged args)
 {
     HubContext.Clients.Group(args.GameId.ToString()).TeamChanged(args);
 }