public static void KillPlayer(this PlayerControl killer, PlayerControl target, PlayerControl killerAnimation) { DeadPlayers.Add(new DeadPlayer(target, killerAnimation, DateTime.UtcNow)); KillOverlayShowOnePatch.killerAnimation = killerAnimation.Data; killer.MurderPlayer(target); if (killerAnimation.GetRole().Faction != Faction.Mafia || LocalRole.Faction != Faction.Mafia || killerAnimation == LocalPlayer) { return; } switch (Main.OptionMafiaSharedKillCooldown) { case 0: // None break; case 1: // Killer LocalPlayer.GetAbility <AbilityKill>() ?.SetCooldown(killerAnimation.GetAbility <AbilityKill>().Cooldown); break; case 2: // Self LocalPlayer.GetAbility <AbilityKill>()?.SetOnCooldown(); break; case 3: // Custom float cooldown = Main.OptionMafiaCustomSharedKillCooldown; LocalPlayer.GetAbility <AbilityKill>()?.SetCooldown(cooldown); break; } }
// TODO: Move Functionality to Sheriff-Class and only call from here public static void Postfix(PlayerControl __instance, [HarmonyArgument(0)] GameData.PlayerInfo target) { if (__instance == null || LocalPlayer == null || DeadPlayers.Count <= 0) { return; } if (!(LocalRole is Sheriff sheriff)) { return; } DeadPlayer deadPlayer = DeadPlayers.FirstOrDefault(x => target != null && x.Victim?.PlayerId == target.PlayerId); if (deadPlayer == null) { return; } if (__instance.PlayerId != sheriff.Owner.PlayerId) { return; } List <string> hints = deadPlayer.hintMessages.ToList(); var hintAmount = (int)(Main.OptionSheriffMaxHintAmount - (int)(deadPlayer.KillAge / 1000F / Main.OptionSheriffHintDecreaseInterval)); if (hintAmount < Main.OptionSheriffMinHintAmount) { hintAmount = (int)Main.OptionSheriffMinHintAmount; } for (var i = 0; i < hintAmount; i++) { string hint = hints[Rng.Next(hints.Count)]; hints.Remove(hint); if (string.IsNullOrWhiteSpace(hint)) { return; } if (AmongUsClient.Instance.AmClient) { HudManager.Instance?.Chat.AddChat(LocalPlayer, $"{deadPlayer.Victim.Data.PlayerName}: {hint}"); } if (hint.IndexOf("who", StringComparison.OrdinalIgnoreCase) >= 0) { Telemetry.Instance?.SendWho(); } } }
private void RemoveDeadPlayers() { var deadPlayers = Players.Where(p => p.Health == 0).ToList(); foreach (var deadPlayer in deadPlayers) { DeadPlayers.AddLast(deadPlayer); Players.Remove(deadPlayer); } }
private decimal TotalSumOfDeathsGroupedPerPlayer(int id) { var totalDeaths = 0m; var playerKilled = DeadPlayers.FirstOrDefault(atWhere => atWhere.Id == id); if (playerKilled != null) { totalDeaths = playerKilled.TotalKills; } return(totalDeaths); }
private void AddNewDeadPlayer(Player victim) { var player = FindPlayer(victim.Id); if (player == null) { player = victim; } var newDeadPlayer = new DeadPlayer(player.Id, player.Name); newDeadPlayer.Sum(); DeadPlayers.Add(newDeadPlayer); }
private static string GetKillerKillCount(DeadPlayer deadPlayer) { return ($"The killer has already killed a total of {DeadPlayers.Count(player => player.Killer.PlayerId == deadPlayer.Killer.PlayerId).ToString()} players."); }
private DeadPlayer FindPlayerDead(int id) { return(DeadPlayers.FirstOrDefault(atWhere => atWhere.Id == id)); }