public static void AddTeamChange(Player player, MpTeam newTeam) { if (NetworkMatch.m_postgame) { return; } TeamChanges.Add(new TeamChange { Time = NetworkMatch.m_match_elapsed_seconds, PlayerName = player.m_mp_name, PreviousTeam = player.m_mp_team, CurrentTeam = newTeam }); var obj = JObject.FromObject(new { name = "Stats", type = "TeamChange", time = NetworkMatch.m_match_elapsed_seconds, playerName = player.m_mp_name, previousTeam = TeamName(player.m_mp_team), currentTeam = TeamName(newTeam) }, new JsonSerializer() { NullValueHandling = NullValueHandling.Ignore }); TrackerPostStats(obj); }
public static void MaybeSubtractPointForTeam(MpTeam team) { if (NetworkMatch.GetMode() != MatchMode.MONSTERBALL && NetworkMatch.GetMode() != CTF.MatchModeCTF) { NetworkMatch.SubtractPointForTeam(team); } }
private static bool Prefix(MpTeam team, ref LevelData.SpawnPoint __result) { // Check mode, bail if not Anarchy or Team Anarchy. var mode = NetworkMatch.GetMode(); if (mode != MatchMode.ANARCHY && mode != MatchMode.TEAM_ANARCHY) { return(true); } var respawnPointCandidates = GetRespawnPointCandidates(team); if (respawnPointCandidates.Count == 0) { __result = (LevelData.SpawnPoint)_NetworkSpawnPoints_GetRandomRespawnPointWithoutFiltering_Method.Invoke(null, new object[] { }); } else if (NetworkManager.m_Players.Count == 0) { __result = respawnPointCandidates[UnityEngine.Random.Range(0, respawnPointCandidates.Count)]; } else { var scores = GetRespawnPointScores(team, respawnPointCandidates, true); __result = scores.OrderByDescending(s => s.Value).First().Key; } lastRespawn[__result] = DateTime.Now; return(false); }
public static int DrawScoresForTeam(UIElement uie, MpTeam team, Vector2 pos, float col1, float col2, float col3, float col4, float col5) { //return (int)uie.GetType().GetMethod("DrawScoresForTeam", BindingFlags.NonPublic).Invoke(uie, // new object[] { team, pos, col1, col2, col3, col4, col5 }); return((int)AccessTools.Method(typeof(UIElement), "DrawScoresForTeam").Invoke(uie, new object[] { team, pos, col1, col2, col3, col4, col5 })); }
private static bool Prefix(int sender_connection_id, LobbyChatMessage msg) { MpTeam team = NetworkMatch.GetTeamFromLobbyData(sender_connection_id); MPChatCommand cmd = new MPChatCommand(msg.m_text, sender_connection_id, msg.m_sender_name, team, true); return(cmd.Execute()); }
private static void Prefix(Collider other, MonsterBallGoal __instance) { if (other.gameObject.layer == 31 && Overload.NetworkManager.IsServer()) { MpTeam mpTeam = (__instance.m_team != MpTeam.TEAM0) ? MpTeam.TEAM0 : MpTeam.TEAM1; if (mpTeam == MonsterballAddon.CurrentPlayer.m_mp_team) { ServerStatLog.AddGoal(); MonsterballAddon.PlayerStats[MonsterballAddon.CurrentPlayer.netId].Goals++; if (MonsterballAddon.LastPlayer != null) { MonsterballAddon.PlayerStats[MonsterballAddon.LastPlayer.netId].GoalAssists++; } } else { ServerStatLog.AddBlunder(); MonsterballAddon.PlayerStats[MonsterballAddon.CurrentPlayer.netId].Blunders++; } NetworkServer.SendToAll(MessageTypes.MsgMonsterballPlayerStats, new MonsterballAddon.PlayerStatesMessage() { m_player_states = MonsterballAddon.PlayerStats }); } }
static bool Prefix(UIElement __instance, ref Vector2 pos) { if (MPModPrivateData.MatchMode == ExtMatchMode.RACE) { Race.DrawMpMiniScoreboard(ref pos, __instance); return(false); } if (NetworkMatch.GetMode() == MatchMode.ANARCHY || MPTeams.NetworkMatchTeamCount == 2) { return(true); } int match_time_remaining = NetworkMatch.m_match_time_remaining; int match_time = (int)NetworkMatch.m_match_elapsed_seconds; pos.y -= 15f; __instance.DrawDigitsTime(pos + Vector2.right * 95f, (float)match_time_remaining, 0.45f, (match_time <= 10 || match_time_remaining >= 10) ? UIManager.m_col_ui2 : UIManager.m_col_em5, __instance.m_alpha, false); pos.y -= 3f; MpTeam myTeam = GameManager.m_local_player.m_mp_team; foreach (var team in MPTeams.TeamsByScore) { pos.y += 28f; int score = NetworkMatch.GetTeamScore(team); MPTeams.DrawTeamScoreSmall(__instance, pos, team, score, 98f, team == myTeam); } pos.y += 6f; return(false); }
public static void AddFlagEvent(Player player, string @event, MpTeam flagTeam) { if (NetworkMatch.m_postgame) { return; } var capture = new FlagStat() { Time = NetworkMatch.m_match_elapsed_seconds, Event = @event, Scorer = player?.m_mp_name, ScorerTeam = player != null ? player.m_mp_team : flagTeam }; var obj = JObject.FromObject(new { name = "Stats", type = "CTF", time = capture.Time, @event, scorer = capture.Scorer, scorerTeam = TeamName(capture.ScorerTeam), }, new JsonSerializer() { NullValueHandling = NullValueHandling.Ignore }); FlagStats.Add(capture); TrackerPostStats(obj); }
static int DrawScoresForTeam(UIElement uie, MpTeam team, ref Vector2 pos) { float m_alpha = (float)AccessTools.Field(typeof(UIElement), "m_alpha").GetValue(uie); List <Player> players = NetworkManager.m_PlayersForScoreboard; List <int> list = new List <int>(); for (int i = 0; i < players.Count; i++) { if (players[i].m_mp_team == team && !players[i].m_spectator) { list.Add(i); } } list.Sort((int a, int b) => players[a].m_kills != players[b].m_kills ? players[b].m_kills.CompareTo(players[a].m_kills) : (players[a].m_assists != players[b].m_assists ? players[b].m_assists.CompareTo(players[a].m_assists) : players[a].m_deaths.CompareTo(players[b].m_deaths)) ); Color color = MPTeams.TeamColor(team, team == GameManager.m_local_player.m_mp_team ? 2 : 0); for (int j = 0; j < list.Count; j++) { Player player = NetworkManager.m_PlayersForScoreboard[list[j]]; var stats = MonsterballAddon.PlayerStats[player.netId]; if (player && !player.m_spectator) { float num = (!player.gameObject.activeInHierarchy) ? 0.3f : 1f; if (j % 2 == 0) { UIManager.DrawQuadUI(pos, 400f, 13f, UIManager.m_col_ub0, m_alpha * num * 0.1f, 13); } if (player.isLocalPlayer) { UIManager.DrawQuadUI(pos, 410f, 12f, color, m_alpha * num * 0.15f, 20); UIManager.DrawQuadUI(pos - Vector2.up * 12f, 400f, 1.2f, color, m_alpha * num * 0.5f, 4); UIManager.DrawQuadUI(pos + Vector2.up * 12f, 400f, 1.2f, color, m_alpha * num * 0.5f, 4); } UIManager.DrawSpriteUI(pos + Vector2.right * (col1 - 35f), 0.11f, 0.11f, color, m_alpha * num, Player.GetMpModifierIcon(player.m_mp_mod1, true)); UIManager.DrawSpriteUI(pos + Vector2.right * (col1 - 15f), 0.11f, 0.11f, color, m_alpha * num, Player.GetMpModifierIcon(player.m_mp_mod2, false)); uie.DrawPlayerNameBasic(pos + Vector2.right * col1, player.m_mp_name, color, player.m_mp_rank_true, 0.6f, num, player.m_mp_platform, col2 - col1 - 10f); uie.DrawDigitsVariable(pos + Vector2.right * col2, stats.Goals, 0.65f, StringOffset.CENTER, color, m_alpha * num); if (MPModPrivateData.AssistScoring) { uie.DrawDigitsVariable(pos + Vector2.right * col3, stats.GoalAssists, 0.65f, StringOffset.CENTER, color, m_alpha * num); } uie.DrawDigitsVariable(pos + Vector2.right * col4, stats.Blunders, 0.65f, StringOffset.CENTER, color, m_alpha * num); uie.DrawDigitsVariable(pos + Vector2.right * col5, player.m_kills, 0.65f, StringOffset.CENTER, color, m_alpha * num); if (MPModPrivateData.AssistScoring) { uie.DrawDigitsVariable(pos + Vector2.right * col6, player.m_assists, 0.65f, StringOffset.CENTER, color, m_alpha * num); } uie.DrawDigitsVariable(pos + Vector2.right * col7, player.m_deaths, 0.65f, StringOffset.CENTER, color, m_alpha * num); uie.DrawDigitsVariable(pos + Vector2.right * col8, player.m_avg_ping_ms, 0.65f, StringOffset.CENTER, uie.GetPingColor(player.m_avg_ping_ms), m_alpha * num); pos.y += 25f; } } return(list.Count); }
public static Color TeamColor(MpTeam team, int mod) { int cIdx = colorIdx[TeamNum(team)]; float sat = cIdx == 8 ? 0.01f : cIdx == 4 && mod == 5 ? 0.6f : 0.95f - mod * 0.05f; float bright = mod == 5 ? 0.95f : 0.5f + mod * 0.1f; return(HSBColor.ConvertToColor(colors[cIdx], sat, bright)); }
static void Prefix(ref MpTeam team, ref int glow_color, ref int decal_color) { if (team == MpTeam.ANARCHY) { return; } glow_color = decal_color = MPTeams.TeamColorIdx(team); team = MpTeam.ANARCHY; // prevent original team color assignment }
static bool Prefix(MpTeam team, ref Color __result) { if (team < MpTeam.NUM_TEAMS) { return(true); } __result = MPTeams.TeamColor(team, 2); return(false); }
public static MpTeam NextTeam(MpTeam team) { team = team + 1; if (team == MpTeam.ANARCHY) { team = team + 1; } return(team == MPTEAM_NUM || AllTeams.IndexOf(x => x == team) >= NetworkMatchTeamCount ? MpTeam.TEAM0 : team); }
static void DrawTeamHeader(UIElement uie, Vector2 pos, MpTeam team, float w = 255f) { Color c = TeamColor(team, 1); Color c2 = TeamColor(team, 4); c.a = uie.m_alpha; UIManager.DrawQuadBarHorizontal(pos, 13f, 13f, w * 2f, c, 7); uie.DrawStringSmall(NetworkMatch.GetTeamName(team), pos, 0.6f, StringOffset.CENTER, c2, 1f, -1f); }
static bool Prefix(MpTeam team, ref string __result) { if (team < MpTeam.NUM_TEAMS) { return(true); } __result = MPTeams.TeamName(team) + " TEAM"; return(false); }
public static string TeamName(MpTeam team) { var c = MenuManager.mpc_decal_color; MenuManager.mpc_decal_color = colorIdx[TeamNum(team)]; var ret = MenuManager.GetMpDecalColor(); MenuManager.mpc_decal_color = c; return(ret); }
static bool Prefix(UIElement __instance, ref Vector2 pos) { if (!GameplayManager.IsMultiplayerActive || NetworkMatch.GetMode() == MatchMode.ANARCHY || MPTeams.NetworkMatchTeamCount == 2) { return(true); } var uie = __instance; pos.x -= 4f; pos.y -= 5f; Vector2 temp_pos; temp_pos.y = pos.y; temp_pos.x = pos.x - 100f; uie.DrawStringSmall(NetworkMatch.GetModeString(MatchMode.NUM), temp_pos, 0.4f, StringOffset.LEFT, UIManager.m_col_ub0, 1f, 130f); temp_pos.x = pos.x + 95f; int match_time_remaining = NetworkMatch.m_match_time_remaining; int num3 = (int)NetworkMatch.m_match_elapsed_seconds; uie.DrawDigitsTime(temp_pos, (float)match_time_remaining, 0.45f, (num3 <= 10 || match_time_remaining >= 10) ? UIManager.m_col_ui2 : UIManager.m_col_em5, uie.m_alpha, false); temp_pos.x = pos.x - 100f; temp_pos.y = temp_pos.y - 20f; uie.DrawPing(temp_pos); pos.y += 24f; MpTeam myTeam = GameManager.m_local_player.m_mp_team; foreach (var team in MPTeams.TeamsByScore) { MPTeams.DrawTeamScoreSmall(__instance, pos, team, NetworkMatch.GetTeamScore(team), 98f, team == myTeam); pos.y += 28f; } pos.y += 6f - 28f; pos.y += 22f; pos.x += 100f; uie.DrawRecentKillsMP(pos); if (GameManager.m_player_ship.m_wheel_select_state == WheelSelectState.QUICK_CHAT) { pos.y = UIManager.UI_TOP + 128f; pos.x = -448f; uie.DrawQuickChatWheel(pos); } else { pos.y = UIManager.UI_TOP + 60f; pos.x = UIManager.UI_LEFT + 5f; uie.DrawQuickChatMP(pos); } return(false); }
static bool Prefix(UIElement __instance, ref Vector2 pos) { var mode = NetworkMatch.GetMode(); var fitSingle = MPTeams.NetworkMatchTeamCount == 2 && NetworkMatch.m_players.Count <= 8; if (MPModPrivateData.MatchMode == ExtMatchMode.RACE) { return(true); } if (mode == MatchMode.ANARCHY || ((mode == MatchMode.TEAM_ANARCHY || mode == MatchMode.MONSTERBALL) && fitSingle)) { return(true); } float colReduce = fitSingle ? 0 : 50f; float col1 = fitSingle ? -330f : -250f; float col2 = 100f - colReduce; float col3 = 190f - colReduce; float col4 = 280f - colReduce; float col5 = 350f - colReduce; MpTeam myTeam = GameManager.m_local_player.m_mp_team; int col = 0; float x = pos.x; float y = pos.y; float[] ys = new float[2] { pos.y, pos.y }; foreach (var team in MPTeams.TeamsByScore) { pos.x = x + (fitSingle ? 0 : col == 0 ? -325f : 325f); pos.y = ys[col]; MPTeams.DrawTeamScore(__instance, pos, team, NetworkMatch.GetTeamScore(team), col5, team == myTeam); pos.y += 35f; if (ys[col] == y || fitSingle) // only draw header for first team in column { MPTeams.DrawScoreHeader(__instance, pos, col1, col2, col3, col4, col5, false); pos.y += 15f; __instance.DrawVariableSeparator(pos, 350f); pos.y += 20f; } int num = MPTeams.DrawScoresForTeam(__instance, team, pos, col1, col2, col3, col4, col5); pos.y += (float)num * 25f + 35f; ys[col] = pos.y; if (!fitSingle) { col = 1 - col; } } pos.y = Mathf.Max(ys[0], ys[1]); return(false); }
static void DrawTeamScore(UIElement uie, ref Vector2 pos, MpTeam team, int score, float w = 350f, bool my_team = false) { Color c = MPTeams.TeamColor(team, my_team ? 2 : 0); Color color = MPTeams.TeamColor(team, my_team ? 4 : 2); c.a = uie.m_alpha; if (my_team) { UIManager.DrawQuadBarHorizontal(pos, 18f, 18f, w * 2f, c, 7); } UIManager.DrawQuadBarHorizontal(pos, 15f, 15f, w * 2f, c, 7); uie.DrawDigitsVariable(pos + Vector2.right * w, score, 0.7f, StringOffset.RIGHT, color, uie.m_alpha); uie.DrawStringSmall(NetworkMatch.GetTeamName(team), pos - Vector2.right * (w + 9f), 0.6f, StringOffset.LEFT, color, 1f, -1f); }
private static void Prefix(Collider other, MonsterBallGoal __instance) { if (other.gameObject.layer == 31 && NetworkManager.IsServer()) { MpTeam mpTeam = (__instance.m_team != MpTeam.TEAM0) ? MpTeam.TEAM0 : MpTeam.TEAM1; if (mpTeam == MonsterballAddon.CurrentPlayer.m_mp_team) { ServerStatLog.AddGoal(); } else { ServerStatLog.AddBlunder(); } } }
private static void LogEvent(CTFEvent evt, Player player, MpTeam flag) { switch (evt) { case CTFEvent.RETURN: ServerStatLog.AddFlagEvent(player, "Return", flag); break; case CTFEvent.PICKUP: ServerStatLog.AddFlagEvent(player, "Pickup", flag); break; case CTFEvent.SCORE: ServerStatLog.AddFlagEvent(player, "Capture", flag); break; } }
public static void AddKill(DamageInfo di) { if (NetworkMatch.m_postgame) { return; } Kills.Add(new Kill { Time = NetworkMatch.m_match_elapsed_seconds, Attacker = Attacker, Defender = Defender, Assisted = Assisted, AttackerTeam = AttackerTeam, DefenderTeam = DefenderTeam, AssistedTeam = AssistedTeam, Weapon = di.weapon }); var obj = JObject.FromObject(new { name = "Stats", type = "Kill", time = NetworkMatch.m_match_elapsed_seconds, attacker = Attacker, attackerTeam = Attacker == null ? null : TeamName(AttackerTeam), defender = Defender, defenderTeam = Defender == null ? null : TeamName(DefenderTeam), assisted = Assisted, assistedTeam = Assisted == null ? null : TeamName(AssistedTeam), weapon = di.weapon.ToString() }, new JsonSerializer() { NullValueHandling = NullValueHandling.Ignore }); TrackerPostStats(obj); Attacker = null; Defender = null; Assisted = null; AttackerTeam = MpTeam.ANARCHY; DefenderTeam = MpTeam.ANARCHY; AssistedTeam = MpTeam.ANARCHY; }
public static void DrawMpScoreboardRaw(UIElement uie, ref Vector2 pos) { float col1 = -330f; // Player float col2 = 100f; // Score/Kills float col3 = 190f; // Assists float col4 = 280f; // Deaths float col5 = 350f; // Ping MpTeam myTeam = GameManager.m_local_player.m_mp_team; foreach (MpTeam team in MPTeams.TeamsByScore) { DrawTeamScore(uie, pos, team, NetworkMatch.GetTeamScore(team), 350f, GameManager.m_local_player.m_mp_team == myTeam); pos.y += 35f; DrawScoreHeader(uie, pos, col1, col2, col3, col4, col5); pos.y += 15f; uie.DrawVariableSeparator(pos, 350f); pos.y += 20f; int num = DrawScoresForTeam(uie, team, pos, col1, col2, col3, col4, col5); pos.y += (float)num * 25f + 50f; } }
public static List <LevelData.SpawnPoint> GetRespawnPointCandidates(MpTeam team) { var respawnPointCandidates = ( from s in (List <int>)_NetworkSpawnPoints_GetRespawnPointCandidates_Method.Invoke(null, new object[] { team }) select GameManager.m_level_data.m_player_spawn_points[s] ).ToList(); IEnumerable <LevelData.SpawnPoint> validItemSpawnPoints; if (NetworkManager.IsServer()) { validItemSpawnPoints = MPRespawn.spawnPointsFromItems.Where(i => Item.HasLiveItem == null || i.index > Item.HasLiveItem.Length || !Item.HasLiveItem[i.index]).Select(i => i.spawnPoint); } else { validItemSpawnPoints = MPRespawn.spawnPointsFromItems.Where(i => !Item.m_ItemList.Exists(it => Math.Abs(it.transform.position.x - i.spawnPoint.position.x) < 0.1f && Math.Abs(it.transform.position.y - i.spawnPoint.position.y) < 0.1f && Math.Abs(it.transform.position.z - i.spawnPoint.position.z) < 0.1f)).Select(i => i.spawnPoint); } respawnPointCandidates.AddRange(validItemSpawnPoints); return(respawnPointCandidates); }
static bool Prefix(ref MpTeam __result, int connection_id) { if (!NetworkMatch.IsTeamMode(NetworkMatch.GetMode())) { __result = MpTeam.ANARCHY; return(false); } if (NetworkMatch.GetMode() == MatchMode.ANARCHY || (MPTeams.NetworkMatchTeamCount == 2 && !MPJoinInProgress.NetworkMatchEnabled)) // use this simple balancing method for JIP to hopefully solve JIP team imbalances { return(true); } if (NetworkMatch.m_players.TryGetValue(connection_id, out var connPlayer)) // keep team if player already exists (when called from OnUpdateGameSession) { __result = connPlayer.m_team; return(false); } int[] team_counts = new int[(int)MPTeams.MPTEAM_NUM]; foreach (var player in NetworkMatch.m_players.Values) { team_counts[(int)player.m_team]++; } MpTeam min_team = MpTeam.TEAM0; foreach (var team in MPTeams.Teams) { if (team_counts[(int)team] < team_counts[(int)min_team] || (team_counts[(int)team] == team_counts[(int)min_team] && NetworkMatch.m_team_scores[(int)team] < NetworkMatch.m_team_scores[(int)min_team])) { min_team = team; } } __result = min_team; Debug.LogFormat("GetTeamForPlayer: result {0}, conn {1}, counts {2}, scores {3}", (int)min_team, connection_id, team_counts.Join(), NetworkMatch.m_team_scores.Join()); return(false); }
public static void SetAssisted(string name, MpTeam team) { Assisted = name; AssistedTeam = team; }
public static void SetDefender(string name, MpTeam team) { Defender = name; DefenderTeam = team; }
public static void SetAttacker(string name, MpTeam team) { Attacker = name; AttackerTeam = team; }
static bool Prefix(MpTeam team, ref string __result) { __result = MPTeams.TeamName(team); return(false); }
public static int TeamColorIdx(MpTeam team) { return(colorIdx[TeamNum(team)]); }