Convert AllPlayerControls into System.Collections.Generic.List<PlayerControl> from IEnumerable

This commit is contained in:
Gurge44 committed 2023-10-25 16:04:16 +02:00
1 parent f978733f31
commit 51bbfa919b
46 files changed
+289 -146

No files matched your search

+9 -6
View File
@@ -93,8 +93,9 @@ internal static class FFAManager
KBScore = new();
RoundTime = FFA_GameTime.GetInt() + 8;
foreach (var pc in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl pc = Main.AllAlivePlayerControls[i];
KBScore.TryAdd(pc.PlayerId, 0);
}
}
@@ -155,7 +156,7 @@ internal static class FFAManager
}
catch
{
return Main.AllPlayerControls.Count();
return Main.AllPlayerControls.Count;
}
}
public static string GetHudText()
@@ -166,7 +167,7 @@ internal static class FFAManager
{
if (killer == null || target == null || Options.CurrentGameMode != CustomGameMode.FFA) return;
if (target.inVent) return;
var totalalive = Main.AllAlivePlayerControls.Count();
var totalalive = Main.AllAlivePlayerControls.Count;
if (FFAShieldedList.TryGetValue(target.PlayerId, out var dur))
{
killer.Notify(GetString("FFA_TargetIsShielded"));
@@ -299,7 +300,7 @@ internal static class FFAManager
{
if (GameStates.IsMeeting) return string.Empty;
if (target != null && seer.PlayerId != target.PlayerId) return string.Empty;
if (Main.AllAlivePlayerControls.Count() != 2) return string.Empty;
if (Main.AllAlivePlayerControls.Count != 2) return string.Empty;
string arrows = string.Empty;
PlayerControl otherPlayer = null;
@@ -351,8 +352,9 @@ internal static class FFAManager
List<byte> changePositionPlayers = new();
foreach (var pc in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl pc = Main.AllAlivePlayerControls[i];
if (changePositionPlayers.Contains(pc.PlayerId) || !pc.IsAlive() || pc.onLadder || pc.inVent) continue;
var filtered = Main.AllAlivePlayerControls.Where(a =>
@@ -381,8 +383,9 @@ internal static class FFAManager
if (Main.NormalOptions.MapId == 4) return;
foreach (var pc in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl pc = Main.AllAlivePlayerControls[i];
if (pc == null) return;
bool sync = false;
+3 -2
View File
@@ -96,8 +96,9 @@ internal static class SoloKombatManager
KBScore = new();
RoundTime = KB_GameTime.GetInt() + 8;
foreach (var pc in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl pc = Main.AllAlivePlayerControls[i];
PlayerHPMax.TryAdd(pc.PlayerId, KB_HPMax.GetFloat());
PlayerHP.TryAdd(pc.PlayerId, KB_HPMax.GetFloat());
PlayerHPReco.TryAdd(pc.PlayerId, KB_RecoverPerSecond.GetFloat());
@@ -209,7 +210,7 @@ internal static class SoloKombatManager
}
catch
{
return Main.AllPlayerControls.Count();
return Main.AllPlayerControls.Count;
}
}
public static string GetHudText()
+2 -1
View File
@@ -44,8 +44,9 @@ public static class AntiBlackout
{
int numImpostors = 0;
int numCrewmates = 0;
foreach (var pc in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl pc = Main.AllPlayerControls[i];
if (pc.Data.Role.IsImpostor) numImpostors++;
else numCrewmates++;
}
+2 -6
View File
@@ -85,14 +85,10 @@ public static class Camouflage
if (oldIsCamouflage != IsCamouflage)
{
foreach (var pc in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl pc = Main.AllPlayerControls[i];
RpcSetSkin(pc);
if (!IsCamouflage)
{
pc.RpcRemovePet();
}
}
Utils.NotifyRoles();
}
+12 -4
View File
@@ -16,7 +16,7 @@ internal class CustomRoleSelector
// 开始职业抽取
RoleResult = new();
var rd = IRandom.Instance;
int playerCount = Main.AllAlivePlayerControls.Count();
int playerCount = Main.AllAlivePlayerControls.Count;
int optImpNum = Main.RealOptionsData.GetInt(Int32OptionNames.NumImpostors);
int optNonNeutralKillingNum = 0;
int optNeutralKillingNum = 0;
@@ -60,15 +60,23 @@ internal class CustomRoleSelector
if (Options.CurrentGameMode == CustomGameMode.SoloKombat)
{
RoleResult = new();
foreach (var pc in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl pc = Main.AllAlivePlayerControls[i];
RoleResult.Add(pc, CustomRoles.KB_Normal);
}
return;
}
if (Options.CurrentGameMode == CustomGameMode.FFA)
{
RoleResult = new();
foreach (var pc in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl pc = Main.AllAlivePlayerControls[i];
RoleResult.Add(pc, CustomRoles.Killer);
}
return;
}
@@ -320,7 +328,7 @@ internal class CustomRoleSelector
}
}
var AllPlayer = Main.AllAlivePlayerControls.ToList();
var AllPlayer = Main.AllAlivePlayerControls;
while (AllPlayer.Any() && rolesToAssign.Any())
{
+2 -1
View File
@@ -45,8 +45,9 @@ class DisableDevice
if (frame != 0) return;
if (!DoDisable) return;
foreach (var pc in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl pc = Main.AllPlayerControls[i];
try
{
if (pc.IsModClient()) continue;
+4 -2
View File
@@ -118,8 +118,9 @@ static class ExtendedPlayerControl
}
public static void RpcSetNameEx(this PlayerControl player, string name)
{
foreach (var seer in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl seer = Main.AllPlayerControls[i];
Main.LastNotifyNames[(player.PlayerId, seer.PlayerId)] = name;
}
HudManagerPatch.LastSetNameDesyncCount++;
@@ -1325,8 +1326,9 @@ static class ExtendedPlayerControl
public static Dictionary<string, int> GetAllPlayerLocationsCount()
{
Dictionary<string, int> playerRooms = new();
foreach (var pc in Main.AllAlivePlayerControls)
for (int i1 = 0; i1 < Main.AllAlivePlayerControls.Count; i1++)
{
PlayerControl pc = Main.AllAlivePlayerControls[i1];
if (!pc.IsAlive() || Pelican.IsEaten(pc.PlayerId)) return null;
var Rooms = ShipStatus.Instance.AllRooms;
if (Rooms == null) return null;
+4 -3
View File
@@ -19,8 +19,9 @@ public static class GuessManager
public static string GetFormatString()
{
string text = GetString("PlayerIdList");
foreach (var pc in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl pc = Main.AllAlivePlayerControls[i];
string id = pc.PlayerId.ToString();
string name = pc.GetRealName();
text += $"\n{id} → {name}";
@@ -763,8 +764,8 @@ public static class GuessManager
var rd = IRandom.Instance;
string msg;
string[] command = new string[] { "bet", "bt", "guess", "gs", "shoot", "st", "赌", "猜", "审判", "tl", "判", "审" };
var x = Main.AllAlivePlayerControls.ToArray();
var totalAlive = Main.AllAlivePlayerControls.Count();
var x = Main.AllAlivePlayerControls;
var totalAlive = Main.AllAlivePlayerControls.Count;
for (int i = 0; i < 20; i++)
{
//msg = "/";
+5 -1
View File
@@ -32,8 +32,12 @@ public static class MafiaRevengeManager
if (msg == "/rv")
{
string text = GetString("PlayerIdList");
foreach (var npc in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl npc = Main.AllAlivePlayerControls[i];
text += "\n" + npc.PlayerId.ToString() + " → (" + npc.GetDisplayRoleName() + ") " + npc.GetRealName();
}
Utils.SendMessage(text, pc.PlayerId);
return true;
}
+1 -1
View File
@@ -242,7 +242,7 @@ public abstract class OptionItem
public static void SyncAllOptions(int targetId = -1)
{
if (
Main.AllPlayerControls.Count() <= 1
Main.AllPlayerControls.Count <= 1
|| AmongUsClient.Instance.AmHost == false
|| PlayerControl.LocalPlayer == null
) return;
+6 -2
View File
@@ -23,7 +23,7 @@ public static class RetributionistRevengeManager
else pc.ShowPopUp(GetString("RetributionistKillDisable"));
return true;
}
int playerCount = Main.AllAlivePlayerControls.Count();
int playerCount = Main.AllAlivePlayerControls.Count;
{
if (playerCount <= Options.MinimumPlayersAliveToRetri.GetInt())
{
@@ -54,8 +54,12 @@ public static class RetributionistRevengeManager
if (msg == "/ret")
{
string text = GetString("PlayerIdList");
foreach (var npc in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl npc = Main.AllAlivePlayerControls[i];
text += "\n" + npc.PlayerId.ToString() + " → (" + npc.GetDisplayRoleName() + ") " + npc.GetRealName();
}
Utils.SendMessage(text, pc.PlayerId);
return true;
}
+22 -11
View File
@@ -73,8 +73,11 @@ public static class Utils
}
public static void TPAll(Vector2 location)
{
foreach (PlayerControl pc in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl pc = Main.AllAlivePlayerControls[i];
TP(pc.NetTransform, location);
}
}
public static void TP(CustomNetworkTransform nt, Vector2 location)
@@ -195,8 +198,9 @@ public static class Utils
public static void TargetDies(PlayerControl killer, PlayerControl target)
{
if (!target.Data.IsDead || GameStates.IsMeeting) return;
foreach (var seer in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl seer = Main.AllPlayerControls[i];
if (KillFlashCheck(killer, target, seer))
{
seer.KillFlash();
@@ -296,7 +300,7 @@ public static class Utils
}
public static string GetRoleMode(CustomRoles role, bool parentheses = true)
{
if (Options.HideGameSettings.GetBool() && Main.AllPlayerControls.Count() > 1)
if (Options.HideGameSettings.GetBool() && Main.AllPlayerControls.Count > 1)
return string.Empty;
string mode = role.GetMode() switch
{
@@ -1174,8 +1178,9 @@ public static class Utils
public static List<PlayerControl> GetPlayersInRadius(float radius, Vector2 from)
{
var list = new List<PlayerControl>();
foreach (var tg in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl tg = Main.AllAlivePlayerControls[i];
var dis = Vector2.Distance(from, tg.transform.position);
if (Pelican.IsEaten(tg.PlayerId) || Medic.ProtectList.Contains(tg.PlayerId) || tg.inVent) continue;
@@ -1760,8 +1765,9 @@ public static class Utils
var taskState = GetPlayerById(Terrorist.PlayerId).GetPlayerTaskState();
if (taskState.IsTaskFinished && (!Main.PlayerStates[Terrorist.PlayerId].IsSuicide() || Options.CanTerroristSuicideWin.GetBool())) //タスクが完了で(自殺じゃない OR 自殺勝ちが許可)されていれば
{
foreach (var pc in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl pc = Main.AllPlayerControls[i];
if (pc.Is(CustomRoles.Terrorist))
{
if (Main.PlayerStates[pc.PlayerId].deathReason == PlayerState.DeathReason.Vote)
@@ -2094,8 +2100,9 @@ public static class Utils
seer.RpcSetNamePrivate(SelfName, true, force: NoCache);
//seerが死んでいる場合など、必要なときのみ第二ループを実行する
foreach (var target in Main.AllPlayerControls)
for (int i1 = 0; i1 < Main.AllPlayerControls.Count; i1++)
{
PlayerControl target = Main.AllPlayerControls[i1];
//targetがseer自身の場合は何もしない
if (target.PlayerId == seer.PlayerId) continue;
logger.Info("NotifyRoles-Loop2-" + target.GetNameWithRole().RemoveHtmlTags() + ":START");
@@ -2538,8 +2545,9 @@ public static class Utils
//Pirate.AfterMeetingTask();
if (Options.UsePets.GetBool())
foreach (var pc in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl pc = Main.AllAlivePlayerControls[i];
switch (pc.GetCustomRole())
{
case CustomRoles.Doormaster:
@@ -2649,8 +2657,9 @@ public static class Utils
if (GameStates.IsMeeting)
{
//网红死亡消息提示
foreach (var pc in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl pc = Main.AllPlayerControls[i];
if (!Options.ImpKnowCyberStarDead.GetBool() && pc.GetCustomRole().IsImpostor()) continue;
if (!Options.NeutralKnowCyberStarDead.GetBool() && pc.GetCustomRole().IsNeutral()) continue;
SendMessage(string.Format(GetString("CyberStarDead"), target.GetRealName()), pc.PlayerId, ColorString(GetRoleColor(CustomRoles.CyberStar), GetString("CyberStarNewsTitle")));
@@ -2757,8 +2766,9 @@ public static class Utils
{
int doused = 0, all = 0; //学校で習った書き方
//多分この方がMain.isDousedでforeachするより他のアーソニストの分ループ数少なくて済む
foreach (var pc in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl pc = Main.AllAlivePlayerControls[i];
if (pc.PlayerId == playerId) continue; //塗れない人は除外 (死んでたり切断済みだったり あとアーソニスト自身も)
all++;
@@ -2773,7 +2783,7 @@ public static class Utils
{
int draw = 0;
int all = Options.RevolutionistDrawCount.GetInt();
int max = Main.AllAlivePlayerControls.Count();
int max = Main.AllAlivePlayerControls.Count;
if (!Main.PlayerStates[playerId].IsDead) max--;
winnerList = new();
if (all > max) all = max;
@@ -2836,8 +2846,9 @@ public static class Utils
if (Main.PlayerStates == null) return false;
//マフィアを除いた生きているインポスターの人数 Number of Living Impostors excluding mafia
int LivingImpostorsNum = 0;
foreach (var pc in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl pc = Main.AllAlivePlayerControls[i];
var role = pc.GetCustomRole();
if (role != CustomRoles.Mafia && role.IsImpostor()) LivingImpostorsNum++;
}
+16 -5
View File
@@ -204,8 +204,9 @@ internal class ChatCommands
if (GameStates.IsLobby || !Options.EnableKillerLeftCommand.GetBool()) break;
int impnum = 0;
int neutralnum = 0;
foreach (var players in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl players = Main.AllAlivePlayerControls[i];
if (Options.ShowImpRemainOnEject.GetBool())
{
if (players.GetCustomRole().IsImpostor())
@@ -390,8 +391,9 @@ internal class ChatCommands
Utils.SendMessage(GetString("Message.CanNotUseInLobby"), PlayerControl.LocalPlayer.PlayerId);
break;
}
foreach (var pc in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl pc = Main.AllPlayerControls[i];
pc.RpcSetNameEx(pc.GetRealName(isMeeting: true));
}
ChatUpdatePatch.DoBlockChat = false;
@@ -402,8 +404,12 @@ internal class ChatCommands
case "/id":
canceled = true;
string msgText = GetString("PlayerIdList");
foreach (var pc in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl pc = Main.AllPlayerControls[i];
msgText += "\n" + pc.PlayerId.ToString() + " → " + Main.AllPlayerNames[pc.PlayerId];
}
Utils.SendMessage(msgText, PlayerControl.LocalPlayer.PlayerId);
break;
@@ -903,8 +909,12 @@ internal class ChatCommands
if (Options.ApplyModeratorList.GetValue() == 0 || !IsPlayerModerator(player.FriendCode)) break;
string msgText = GetString("PlayerIdList");
foreach (var pc in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl pc = Main.AllPlayerControls[i];
msgText += "\n" + pc.PlayerId.ToString() + " → " + Main.AllPlayerNames[pc.PlayerId];
}
Utils.SendMessage(msgText, player.PlayerId);
break;
case "/kick":
@@ -989,8 +999,9 @@ internal class ChatCommands
if (GameStates.IsLobby || !Options.EnableKillerLeftCommand.GetBool()) break;
int impnum = 0;
int neutralnum = 0;
foreach (var players in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl players = Main.AllAlivePlayerControls[i];
if (Options.ShowImpRemainOnEject.GetBool())
{
if (players.GetCustomRole().IsImpostor())
+2 -2
View File
@@ -147,8 +147,8 @@ public class ChatManager
string msg = "<size=0>.</size>";
List<CustomRoles> roles = Enum.GetValues(typeof(CustomRoles)).Cast<CustomRoles>().Where(x => x is not CustomRoles.KB_Normal and not CustomRoles.Killer).ToList();
string[] specialTexts = new string[] { "bet", "bt", "guess", "gs", "shoot", "st", "赌", "猜", "审判", "tl", "判", "审", "trial" };
var totalAlive = Main.AllAlivePlayerControls.Count();
var x = Main.AllAlivePlayerControls.ToArray();
var totalAlive = Main.AllAlivePlayerControls.Count;
var x = Main.AllAlivePlayerControls;
var filtered = chatHistory.Where(a => Utils.GetPlayerById(Convert.ToByte(((string[])a.Split(':'))[0].Trim())).IsAlive()).ToList();
+18 -8
View File
@@ -109,8 +109,9 @@ class GameEndChecker
}
if (CustomWinnerHolder.WinnerTeam is not CustomWinner.Draw and not CustomWinner.None and not CustomWinner.Error)
{
foreach (var pc in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl pc = Main.AllPlayerControls[i];
switch (pc.GetCustomRole())
{
case CustomRoles.DarkHide when !pc.Data.IsDead && ((CustomWinnerHolder.WinnerTeam == CustomWinner.Impostor && !reason.Equals(GameOverReason.ImpostorBySabotage)) || CustomWinnerHolder.WinnerTeam == CustomWinner.DarkHide || (CustomWinnerHolder.WinnerTeam == CustomWinner.Crewmate && !reason.Equals(GameOverReason.HumansByTask) && DarkHide.IsWinKill[pc.PlayerId] == true && DarkHide.SnatchesWin.GetBool())):
@@ -241,8 +242,9 @@ class GameEndChecker
//Ruthless Romantic partner win condition
if (RuthlessRomantic.IsEnable && (CustomWinnerHolder.WinnerIds.Contains(RuthlessRomantic.playerIdList[0]) || (Main.PlayerStates.TryGetValue(RuthlessRomantic.playerIdList[0], out var pz) && CustomWinnerHolder.WinnerRoles.Contains(pz.MainRole))))
foreach (var pc in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl pc = Main.AllPlayerControls[i];
if (Romantic.BetPlayer.TryGetValue(pc.PlayerId, out var betTarget))
{
CustomWinnerHolder.WinnerIds.Add(betTarget);
@@ -260,9 +262,12 @@ class GameEndChecker
//中立共同胜利
if (Options.NeutralWinTogether.GetBool() && CustomWinnerHolder.WinnerIds.Any(x => GetPlayerById(x) != null && GetPlayerById(x).GetCustomRole().IsNeutral()))
{
foreach (var pc in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl pc = Main.AllPlayerControls[i];
if (pc.GetCustomRole().IsNeutral() && !CustomWinnerHolder.WinnerIds.Contains(pc.PlayerId))
CustomWinnerHolder.WinnerIds.Add(pc.PlayerId);
}
}
else if (Options.NeutralRoleWinTogether.GetBool())
{
@@ -270,9 +275,12 @@ class GameEndChecker
{
var pc = GetPlayerById(id);
if (pc == null || !pc.GetCustomRole().IsNeutral()) continue;
foreach (var tar in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl tar = Main.AllPlayerControls[i];
if (!CustomWinnerHolder.WinnerIds.Contains(tar.PlayerId) && tar.GetCustomRole() == pc.GetCustomRole())
CustomWinnerHolder.WinnerIds.Add(tar.PlayerId);
}
}
}
}
@@ -291,8 +299,9 @@ class GameEndChecker
//ゴーストロール化
List<byte> ReviveRequiredPlayerIds = new();
var winner = CustomWinnerHolder.WinnerTeam;
foreach (var pc in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl pc = Main.AllPlayerControls[i];
if (winner == CustomWinner.Draw)
{
SetGhostRole(ToGhostImpostor: true);
@@ -386,7 +395,7 @@ class GameEndChecker
{
reason = GameOverReason.ImpostorByKill;
if (CustomRolesHelper.RoleExist(CustomRoles.Sunnyboy) && Main.AllAlivePlayerControls.Count() > 1) return false;
if (CustomRolesHelper.RoleExist(CustomRoles.Sunnyboy) && Main.AllAlivePlayerControls.Count > 1) return false;
int Imp = AlivePlayersCount(CountTypes.Impostor);
int Crew = AlivePlayersCount(CountTypes.Crew);
@@ -431,8 +440,9 @@ class GameEndChecker
{ (CustomRoles.Agitater, CustomWinner.Agitater), AlivePlayersCount(CountTypes.Agitater) },
};
foreach (var x in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl x = Main.AllAlivePlayerControls[i];
if (x.GetCustomRole().IsImpostor() && x.Is(CustomRoles.DualPersonality)) Imp++;
if (x.GetCustomRole().IsCrewmate() && x.Is(CustomRoles.DualPersonality)) Crew++;
if (x.GetCustomRole().IsImpostor() && x.Is(CustomRoles.Admired) && x.Is(CustomRoles.DualPersonality)) Crew++;
@@ -577,7 +587,7 @@ class GameEndChecker
return true;
}
else if (Main.AllAlivePlayerControls.Count() == 1)
else if (Main.AllAlivePlayerControls.Count == 1)
{
var winner = Main.AllAlivePlayerControls.FirstOrDefault();
+4 -2
View File
@@ -110,8 +110,9 @@ class ExileControllerWrapUpPatch
if (NiceSwapper.Vote.Any() && NiceSwapper.VoteTwo.Any())
{
foreach (var swapper in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl swapper = Main.AllAlivePlayerControls[i];
if (swapper.Is(CustomRoles.NiceSwapper))
{
NiceSwapper.NiceSwappermax[swapper.PlayerId]--;
@@ -122,8 +123,9 @@ class ExileControllerWrapUpPatch
}
}
foreach (var pc in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl pc = Main.AllPlayerControls[i];
pc.ResetKillCooldown();
if (pc.Is(CustomRoles.Warlock))
+8 -5
View File
@@ -66,19 +66,22 @@ class CoBeginPatch
{
var logger = Logger.Handler("Info");
logger.Info("------------Display Names------------");
foreach (var pc in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl pc = Main.AllPlayerControls[i];
logger.Info($"{(pc.AmOwner ? "[*]" : string.Empty),-3}{pc.PlayerId,-2}:{pc.name.PadRightV2(20)}:{pc.cosmetics.nameText.text} ({Palette.ColorNames[pc.Data.DefaultOutfit.ColorId].ToString().Replace("Color", string.Empty)})");
pc.cosmetics.nameText.text = pc.name;
}
logger.Info("------------Roles------------");
foreach (var pc in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl pc = Main.AllPlayerControls[i];
logger.Info($"{(pc.AmOwner ? "[*]" : string.Empty),-3}{pc.PlayerId,-2}:{pc?.Data?.PlayerName?.PadRightV2(20)}:{pc.GetAllRoleName().RemoveHtmlTags()}");
}
logger.Info("------------Platforms------------");
foreach (var pc in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl pc = Main.AllPlayerControls[i];
try
{
var text = pc.AmOwner ? "[*]" : " ";
@@ -105,7 +108,7 @@ class CoBeginPatch
}
logger.Info("-------------Other Information-------------");
logger.Info($"Number of players: {Main.AllPlayerControls.Count()}");
logger.Info($"Number of players: {Main.AllPlayerControls.Count}");
Main.AllPlayerControls.Do(x => Main.PlayerStates[x.PlayerId].InitTask(x));
GameData.Instance.RecomputeTaskCounts();
TaskState.InitialTotalTasks = GameData.Instance.TotalTasks;
@@ -527,7 +530,7 @@ class IntroCutsceneDestroyPatch
{
try
{
for (int i = 0; i < Main.AllPlayerControls.Count(); i++)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
var pc = Main.AllPlayerControls.ElementAt(i);
if (pc.PlayerId == 0) continue;
+8 -4
View File
@@ -429,8 +429,9 @@ class CheckForEndVotingPatch
goto EndOfSession;
}
foreach (var pc in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl pc = Main.AllAlivePlayerControls[i];
var pc_role = pc.GetCustomRole();
if (pc_role.IsImpostor() && pc != exiledPlayer.Object)
impnum++;
@@ -580,8 +581,9 @@ class CheckForEndVotingPatch
private static PlayerControl PickRevengeTarget(PlayerControl exiledplayer/*, PlayerState.DeathReason deathReason*/)//道連れ先選定
{
List<PlayerControl> TargetList = new();
foreach (var candidate in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl candidate = Main.AllAlivePlayerControls[i];
if (candidate == exiledplayer || Main.AfterMeetingDeathPlayers.ContainsKey(candidate.PlayerId)) continue;
}
if (TargetList == null || !TargetList.Any()) return null;
@@ -736,8 +738,9 @@ class MeetingHudStartPatch
AddMsg(string.Format(GetString("BaitAdviceAlive"), string.Join(separator, baitAliveList)), 255, Utils.ColorString(Utils.GetRoleColor(CustomRoles.Bait), GetString("BaitAliveTitle")));
}
string MimicMsg = string.Empty;
foreach (var pc in Main.AllPlayerControls)
for (int i1 = 0; i1 < Main.AllPlayerControls.Count; i1++)
{
PlayerControl pc = Main.AllPlayerControls[i1];
//黑手党死后技能提示
if (pc.Is(CustomRoles.Mafia) && !pc.IsAlive())
AddMsg(GetString("MafiaDeadMsg"), pc.PlayerId);
@@ -908,8 +911,9 @@ class MeetingHudStartPatch
{
_ = _ = new LateTask(() =>
{
foreach (var pc in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl pc = Main.AllPlayerControls[i];
pc.RpcSetNameEx(pc.GetRealName(isMeeting: true));
}
ChatUpdatePatch.DoBlockChat = false;
+2 -1
View File
@@ -44,8 +44,9 @@ class EndGamePatch
//winnerListリセット
TempData.winners = new Il2CppSystem.Collections.Generic.List<WinningPlayerData>();
var winner = new List<PlayerControl>();
foreach (var pc in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl pc = Main.AllPlayerControls[i];
if (CustomWinnerHolder.WinnerIds.Contains(pc.PlayerId)) winner.Add(pc);
}
foreach (var team in CustomWinnerHolder.WinnerRoles)
+12 -8
View File
@@ -281,8 +281,9 @@ class ExternalRpcPetPatch
//if (!pc.IsModClient()) pc.RpcGuardAndKill(pc);
pc.Notify(GetString("TimeMasterOnGuard"), Options.TimeMasterSkillDuration.GetFloat());
Main.TimeMasterCD.TryAdd(pc.PlayerId, Utils.GetTimeStamp());
foreach (var player in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl player = Main.AllPlayerControls[i];
if (Main.TimeMasterBackTrack.ContainsKey(player.PlayerId))
{
var position = Main.TimeMasterBackTrack[player.PlayerId];
@@ -327,8 +328,9 @@ class ExternalRpcPetPatch
UnityEngine.Vector2 cppos = cp.transform.position;
System.Collections.Generic.Dictionary<PlayerControl, float> cpdistance = new();
float dis;
foreach (PlayerControl p in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl p = Main.AllAlivePlayerControls[i];
if (p.PlayerId == cp.PlayerId) continue;
if (!Options.WarlockCanKillSelf.GetBool() && p.PlayerId == pc.PlayerId) continue;
if (!Options.WarlockCanKillAllies.GetBool() && p.GetCustomRole().IsImpostor()) continue;
@@ -426,8 +428,9 @@ class ExternalRpcPetPatch
}
Logger.Info("炸弹爆炸了", "Boom");
CustomSoundsManager.RPCPlayCustomSoundAll("Boom");
foreach (var tg in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl tg = Main.AllPlayerControls[i];
if (!tg.IsModClient()) tg.KillFlash();
var pos = pc.transform.position;
var dis = UnityEngine.Vector2.Distance(pos, tg.transform.position);
@@ -443,8 +446,8 @@ class ExternalRpcPetPatch
}
_ = new LateTask(() =>
{
bool totalAlive = Main.AllAlivePlayerControls.Any();
if (Options.BomberDiesInExplosion.GetBool() && totalAlive && !GameStates.IsEnded)
var totalAlive = Main.AllAlivePlayerControls.Count;
if (Options.BomberDiesInExplosion.GetBool() && totalAlive > 1 && !GameStates.IsEnded)
{
Main.PlayerStates[pc.PlayerId].deathReason = PlayerState.DeathReason.Bombed;
pc.RpcMurderPlayerV3(pc);
@@ -461,8 +464,9 @@ class ExternalRpcPetPatch
}
Logger.Info("炸弹爆炸了", "Boom");
CustomSoundsManager.RPCPlayCustomSoundAll("Boom");
foreach (var tg in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl tg = Main.AllPlayerControls[i];
if (!tg.IsModClient()) tg.KillFlash();
var pos = pc.transform.position;
var dis = UnityEngine.Vector2.Distance(pos, tg.transform.position);
@@ -478,8 +482,8 @@ class ExternalRpcPetPatch
}
_ = new LateTask(() =>
{
bool totalAlive = Main.AllAlivePlayerControls.Any();
if (totalAlive && !GameStates.IsEnded)
var totalAlive = Main.AllAlivePlayerControls.Count;
if (totalAlive > 1 && !GameStates.IsEnded)
{
Main.PlayerStates[pc.PlayerId].deathReason = PlayerState.DeathReason.Bombed;
pc.RpcMurderPlayerV3(pc);
+37 -19
View File
@@ -768,8 +768,9 @@ class CheckMurderPatch
// }
if (Main.ForCrusade.Contains(target.PlayerId))
{
foreach (var player in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl player = Main.AllPlayerControls[i];
if (player.Is(CustomRoles.Crusader) && player.IsAlive() && !killer.Is(CustomRoles.Pestilence) && !killer.Is(CustomRoles.Minimalism))
{
player.RpcMurderPlayerV3(killer);
@@ -861,8 +862,9 @@ class CheckMurderPatch
if (Main.TimeMasterInProtect.ContainsKey(target.PlayerId) && killer.PlayerId != target.PlayerId)
if (Main.TimeMasterInProtect[target.PlayerId] + Options.TimeMasterSkillDuration.GetInt() >= Utils.GetTimeStamp(DateTime.UtcNow))
{
foreach (var player in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl player = Main.AllPlayerControls[i];
if (!killer.Is(CustomRoles.Pestilence))
{
if (Main.TimeMasterBackTrack.ContainsKey(player.PlayerId))
@@ -1103,7 +1105,7 @@ class MurderPlayerPatch
Wildling.OnMurderPlayer(killer, target);
break;
case CustomRoles.Underdog:
int playerCount = Main.AllAlivePlayerControls.Count();
int playerCount = Main.AllAlivePlayerControls.Count;
if (playerCount < Options.UnderdogMaximumPlayersNeededToKill.GetInt())
Main.AllPlayerKillCooldown[killer.PlayerId] = Options.UnderdogKillCooldown.GetFloat();
else Main.AllPlayerKillCooldown[killer.PlayerId] = Options.UnderdogKillCooldownWithMorePlayersAlive.GetFloat();
@@ -1254,8 +1256,9 @@ class ShapeshiftPatch
Vector2 cppos = cp.transform.position;//呪われた人の位置
Dictionary<PlayerControl, float> cpdistance = new();
float dis;
foreach (PlayerControl p in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl p = Main.AllAlivePlayerControls[i];
if (p.PlayerId == cp.PlayerId) continue;
if (!Options.WarlockCanKillSelf.GetBool() && p.PlayerId == shapeshifter.PlayerId) continue;
if (!Options.WarlockCanKillAllies.GetBool() && p.GetCustomRole().IsImpostor()) continue;
@@ -1329,8 +1332,9 @@ class ShapeshiftPatch
{
Logger.Info("炸弹爆炸了", "Boom");
CustomSoundsManager.RPCPlayCustomSoundAll("Boom");
foreach (var tg in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl tg = Main.AllPlayerControls[i];
if (!tg.IsModClient()) tg.KillFlash();
var pos = shapeshifter.transform.position;
var dis = Vector2.Distance(pos, tg.transform.position);
@@ -1346,7 +1350,7 @@ class ShapeshiftPatch
}
_ = new LateTask(() =>
{
var totalAlive = Main.AllAlivePlayerControls.Count();
var totalAlive = Main.AllAlivePlayerControls.Count;
if (Options.BomberDiesInExplosion.GetBool() && totalAlive > 1 && !GameStates.IsEnded)
{
Main.PlayerStates[shapeshifter.PlayerId].deathReason = PlayerState.DeathReason.Bombed;
@@ -1366,8 +1370,9 @@ class ShapeshiftPatch
{
Logger.Info("炸弹爆炸了", "Boom");
CustomSoundsManager.RPCPlayCustomSoundAll("Boom");
foreach (var tg in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl tg = Main.AllPlayerControls[i];
if (!tg.IsModClient()) tg.KillFlash();
var pos = shapeshifter.transform.position;
var dis = Vector2.Distance(pos, tg.transform.position);
@@ -1383,7 +1388,7 @@ class ShapeshiftPatch
}
_ = new LateTask(() =>
{
var totalAlive = Main.AllAlivePlayerControls.Count();
var totalAlive = Main.AllAlivePlayerControls.Count;
if (totalAlive > 1 && !GameStates.IsEnded)
{
Main.PlayerStates[shapeshifter.PlayerId].deathReason = PlayerState.DeathReason.Bombed;
@@ -1808,8 +1813,9 @@ class ReportDeadBodyPatch
if (Options.InhibitorCDAfterMeetings.GetFloat() != Options.InhibitorCD.GetFloat() || Options.SaboteurCD.GetFloat() != Options.SaboteurCDAfterMeetings.GetFloat())
{
foreach (var x in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl x = Main.AllAlivePlayerControls[i];
if (x.Is(CustomRoles.Inhibitor))
{
Main.AllPlayerKillCooldown[x.PlayerId] = Options.InhibitorCDAfterMeetings.GetFloat();
@@ -2557,8 +2563,9 @@ class FixedUpdatePatch
Vector2 puppeteerPos = player.transform.position;//PuppeteerListのKeyの位置
Dictionary<byte, float> targetDistance = new();
float dis;
foreach (var target in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl target = Main.AllAlivePlayerControls[i];
{
if (target.PlayerId != player.PlayerId && !target.Is(CustomRoleTypes.Impostor) && !target.Is(CustomRoles.Pestilence))
{
@@ -2603,8 +2610,9 @@ class FixedUpdatePatch
Vector2 puppeteerPos = player.transform.position;//PuppeteerListのKeyの位置
Dictionary<byte, float> targetDistance = new();
float dis;
foreach (var target in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl target = Main.AllAlivePlayerControls[i];
if (target.PlayerId != player.PlayerId && !target.Is(CustomRoles.Pestilence))
{
dis = Vector2.Distance(puppeteerPos, target.transform.position);
@@ -2646,8 +2654,9 @@ class FixedUpdatePatch
}
if (GameStates.IsInGame && Main.RefixCooldownDelay <= 0)
foreach (var pc in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl pc = Main.AllPlayerControls[i];
if (pc.Is(CustomRoles.Vampire) || pc.Is(CustomRoles.Warlock) || pc.Is(CustomRoles.Assassin) || pc.Is(CustomRoles.Undertaker) || pc.Is(CustomRoles.Poisoner))
Main.AllPlayerKillCooldown[pc.PlayerId] = Options.DefaultKillCooldown * 2;
}
@@ -3280,8 +3289,9 @@ class EnterVentPatch
//if (!pc.IsModClient()) pc.RpcGuardAndKill(pc);
pc.Notify(GetString("TimeMasterOnGuard"), Options.TimeMasterSkillDuration.GetFloat());
Main.TimeMasterCD.TryAdd(pc.PlayerId, Utils.GetTimeStamp());
foreach (var player in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl player = Main.AllPlayerControls[i];
if (Main.TimeMasterBackTrack.ContainsKey(player.PlayerId))
{
var position = Main.TimeMasterBackTrack[player.PlayerId];
@@ -3312,7 +3322,7 @@ class CoEnterVentPatch
{
if (!AmongUsClient.Instance.AmHost) return true;
if (Options.CurrentGameMode == CustomGameMode.FFA && FFAManager.FFA_DisableVentingWhenTwoPlayersAlive.GetBool() && Main.AllAlivePlayerControls.Count() <= 2)
if (Options.CurrentGameMode == CustomGameMode.FFA && FFAManager.FFA_DisableVentingWhenTwoPlayersAlive.GetBool() && Main.AllAlivePlayerControls.Count <= 2)
{
var pc = __instance.myPlayer;
if (pc.killTimer <= 0)
@@ -3369,8 +3379,9 @@ class CoEnterVentPatch
if (__instance.myPlayer.IsDouseDone())
{
CustomSoundsManager.RPCPlayCustomSoundAll("Boom");
foreach (var pc in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl pc = Main.AllAlivePlayerControls[i];
if (pc != __instance.myPlayer)
{
//生存者は焼殺
@@ -3380,7 +3391,12 @@ class CoEnterVentPatch
Main.PlayerStates[pc.PlayerId].SetDead();
}
}
foreach (var pc in Main.AllPlayerControls) pc.KillFlash();
for (int i1 = 0; i1 < Main.AllPlayerControls.Count; i1++)
{
PlayerControl pc = Main.AllPlayerControls[i1];
pc.KillFlash();
}
CustomWinnerHolder.ShiftWinnerAndSetWinner(CustomWinner.Arsonist); //焼殺で勝利した人も勝利させる
CustomWinnerHolder.WinnerIds.Add(__instance.myPlayer.PlayerId);
return true;
@@ -3391,8 +3407,9 @@ class CoEnterVentPatch
if (douseCount >= Options.ArsonistMinPlayersToIgnite.GetInt()) // Don't check for max, since the player would not be able to ignite at all if they somehow get more players doused than the max
{
if (douseCount > Options.ArsonistMaxPlayersToIgnite.GetInt()) Logger.Warn("Arsonist Ignited with more players doused than the maximum amount in the settings", "Arsonist Ignite");
foreach (var pc in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl pc = Main.AllAlivePlayerControls[i];
if (!__instance.myPlayer.IsDousedPlayer(pc)) continue;
pc.KillFlash();
pc.SetRealKiller(__instance.myPlayer);
@@ -3400,7 +3417,7 @@ class CoEnterVentPatch
pc.RpcMurderPlayerV3(pc);
Main.PlayerStates[pc.PlayerId].SetDead();
}
var apc = Main.AllAlivePlayerControls.Count();
var apc = Main.AllAlivePlayerControls.Count;
if (apc == 1)
{
CustomWinnerHolder.ShiftWinnerAndSetWinner(CustomWinner.Arsonist);
@@ -3591,8 +3608,9 @@ class PlayerControlSetRolePatch
{
var targetIsKiller = target.Is(CustomRoleTypes.Impostor) || Main.ResetCamPlayerList.Contains(target.PlayerId);
var ghostRoles = new Dictionary<PlayerControl, RoleTypes>();
foreach (var seer in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl seer = Main.AllPlayerControls[i];
var self = seer.PlayerId == target.PlayerId;
var seerIsKiller = seer.Is(CustomRoleTypes.Impostor) || Main.ResetCamPlayerList.Contains(seer.PlayerId);
if (target.Is(CustomRoles.EvilSpirit))
+44 -16
View File
@@ -154,16 +154,19 @@ internal class ChangeRoleSettings
Logger.Error(msg, "CoStartGame");
}
foreach (var target in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
foreach (var seer in Main.AllPlayerControls)
PlayerControl target = Main.AllPlayerControls[i];
for (int i1 = 0; i1 < Main.AllPlayerControls.Count; i1++)
{
PlayerControl seer = Main.AllPlayerControls[i1];
var pair = (target.PlayerId, seer.PlayerId);
Main.LastNotifyNames[pair] = target.name;
}
}
foreach (var pc in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl pc = Main.AllPlayerControls[i];
var colorId = pc.Data.DefaultOutfit.ColorId;
if (AmongUsClient.Instance.AmHost && Options.FormatNameMode.GetInt() == 1) pc.RpcSetName(Palette.GetColorName(colorId));
Main.PlayerStates[pc.PlayerId] = new(pc.PlayerId);
@@ -356,8 +359,9 @@ internal class SelectRolesPatch
{
//CustomRpcSenderとRpcSetRoleReplacerの初期化
Dictionary<byte, CustomRpcSender> senders = new();
foreach (var pc in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl pc = Main.AllPlayerControls[i];
senders[pc.PlayerId] = new CustomRpcSender($"{pc.name}'s SetRole Sender", SendOption.Reliable, false)
.StartMessage(pc.GetClientId());
}
@@ -433,8 +437,9 @@ internal class SelectRolesPatch
//Utils.ApplySuffix();
foreach (var pc in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl pc = Main.AllPlayerControls[i];
pc.Data.IsDead = false; //プレイヤーの死を解除する
if (Main.PlayerStates[pc.PlayerId].MainRole != CustomRoles.NotAssigned) continue; //既にカスタム役職が割り当てられていればスキップ
var role = CustomRoles.NotAssigned;
@@ -494,12 +499,16 @@ internal class SelectRolesPatch
{
ExtendedPlayerControl.RpcSetCustomRole(pair.Key, pair.Value.MainRole);
foreach (var subRole in pair.Value.SubRoles)
for (int i = 0; i < pair.Value.SubRoles.Count; i++)
{
CustomRoles subRole = pair.Value.SubRoles[i];
ExtendedPlayerControl.RpcSetCustomRole(pair.Key, subRole);
}
}
foreach (var pc in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl pc = Main.AllPlayerControls[i];
if (pc.Data.Role.Role == RoleTypes.Shapeshifter) Main.CheckShapeshift.Add(pc.PlayerId, false);
switch (pc.GetCustomRole())
{
@@ -554,16 +563,25 @@ internal class SelectRolesPatch
SwordsMan.Add(pc.PlayerId);
break;
case CustomRoles.Arsonist:
foreach (var ar in Main.AllPlayerControls)
for (int i1 = 0; i1 < Main.AllPlayerControls.Count; i1++)
{
PlayerControl ar = Main.AllPlayerControls[i1];
Main.isDoused.Add((pc.PlayerId, ar.PlayerId), false);
}
break;
case CustomRoles.Revolutionist:
foreach (var ar in Main.AllPlayerControls)
for (int i1 = 0; i1 < Main.AllPlayerControls.Count; i1++)
{
PlayerControl ar = Main.AllPlayerControls[i1];
Main.isDraw.Add((pc.PlayerId, ar.PlayerId), false);
}
break;
case CustomRoles.Farseer:
foreach (var ar in Main.AllPlayerControls)
for (int i1 = 0; i1 < Main.AllPlayerControls.Count; i1++)
{
PlayerControl ar = Main.AllPlayerControls[i1];
Main.isRevealed.Add((pc.PlayerId, ar.PlayerId), false);
}
Farseer.RandomRole.Add(pc.PlayerId, Farseer.GetRandomCrewRoleString());
@@ -971,8 +989,11 @@ internal class SelectRolesPatch
HudManager.Instance.SetHudActive(true);
List<PlayerControl> AllPlayers = new();
CustomRpcSender sender = CustomRpcSender.Create("SelectRoles Sender", SendOption.Reliable);
foreach (var pc in Main.AllPlayerControls)
for (int i2 = 0; i2 < Main.AllPlayerControls.Count; i2++)
{
PlayerControl pc = Main.AllPlayerControls[i2];
pc.ResetKillCooldown();
}
//役職の人数を戻す
var roleOpt = Main.NormalOptions.roleOptions;
@@ -1000,8 +1021,9 @@ internal class SelectRolesPatch
}
GameOptionsSender.AllSenders.Clear();
foreach (var pc in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl pc = Main.AllPlayerControls[i];
GameOptionsSender.AllSenders.Add(
new PlayerGameOptionsSender(pc)
);
@@ -1031,8 +1053,11 @@ internal class SelectRolesPatch
var othersRole = player.PlayerId == hostId ? RoleTypes.Crewmate : RoleTypes.Scientist;
//Desync役職視点
foreach (var target in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl target = Main.AllPlayerControls[i];
rolesMap[(player.PlayerId, target.PlayerId)] = player.PlayerId != target.PlayerId ? othersRole : selfRole;
}
//他者視点
foreach (var seer in Main.AllPlayerControls.Where(x => player.PlayerId != x.PlayerId))
@@ -1047,11 +1072,13 @@ internal class SelectRolesPatch
}
public static void MakeDesyncSender(Dictionary<byte, CustomRpcSender> senders, Dictionary<(byte, byte), RoleTypes> rolesMap)
{
foreach (var seer in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl seer = Main.AllPlayerControls[i];
var sender = senders[seer.PlayerId];
foreach (var target in Main.AllPlayerControls)
for (int i1 = 0; i1 < Main.AllPlayerControls.Count; i1++)
{
PlayerControl target = Main.AllPlayerControls[i1];
if (rolesMap.TryGetValue((seer.PlayerId, target.PlayerId), out var role))
{
sender.RpcSetRole(seer, role, target.GetClientId());
@@ -1127,8 +1154,9 @@ internal class SelectRolesPatch
private static void AssignLoversRoles(int RawCount = -1)
{
var allPlayers = new List<PlayerControl>();
foreach (var pc in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl pc = Main.AllPlayerControls[i];
if (pc.Is(CustomRoles.GM)
|| (pc.HasSubRole() && pc.GetCustomSubRoles().Count >= Options.NoLimitAddonsNumMax.GetInt())
//|| pc.Is(CustomRoles.Ntr)
+2 -1
View File
@@ -29,8 +29,9 @@ public static class LastImpostor
if (Options.CurrentGameMode == CustomGameMode.SoloKombat || Options.CurrentGameMode == CustomGameMode.FFA
|| !CustomRoles.LastImpostor.IsEnable() || Main.AliveImpostorCount != 1)
return;
foreach (var pc in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl pc = Main.AllAlivePlayerControls[i];
if (CanBeLastImpostor(pc))
{
pc.RpcSetCustomRole(CustomRoles.LastImpostor);
+5 -5
View File
@@ -70,12 +70,12 @@ public static class Marshall
if (!IsExposed[marshallId])
{
foreach (var target in Main.AllAlivePlayerControls)
{
// if (!IsMarshallTarget(target)) continue;
//foreach (var target in Main.AllAlivePlayerControls)
//{
// // if (!IsMarshallTarget(target)) continue;
// TargetArrow.Add(target.PlayerId, snitchId);
}
// // TargetArrow.Add(target.PlayerId, snitchId);
//}
IsExposed[marshallId] = true;
}
+6 -2
View File
@@ -48,8 +48,9 @@ internal class Monitor
Count--; if (Count > 0) return; Count = 5;
bool Admin = false, Camera = false, DoorLog = false, Vital = false;
foreach (PlayerControl pc in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl pc = Main.AllAlivePlayerControls[i];
if (Pelican.IsEaten(pc.PlayerId) || pc.inVent) continue;
try
{
@@ -119,8 +120,11 @@ internal class Monitor
byte pc = playerIdList[i];
Utils.NotifyRoles(SpecifySeer: Utils.GetPlayerById(pc));
}
foreach (PlayerControl pc in Main.AllPlayerControls)
for (int i1 = 0; i1 < Main.AllPlayerControls.Count; i1++)
{
PlayerControl pc = Main.AllPlayerControls[i1];
FixedUpdatePatch.Postfix(pc);
}
}
}
}
+2 -1
View File
@@ -59,8 +59,9 @@ public static class Mortician
var pos = target.GetTruePosition();
float minDis = float.MaxValue;
string minName = string.Empty;
foreach (var pc in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl pc = Main.AllAlivePlayerControls[i];
if (pc.PlayerId == target.PlayerId) continue;
var dis = Vector2.Distance(pc.GetTruePosition(), pos);
if (dis < minDis && dis < 1.5f)
+4 -2
View File
@@ -86,8 +86,9 @@ public static class Snitch
if (!IsExposed[snitchId] && snitchTask.RemainingTasksCount <= RemainingTasksToBeFound)
{
foreach (var target in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl target = Main.AllAlivePlayerControls[i];
if (!IsSnitchTarget(target)) continue;
TargetArrow.Add(target.PlayerId, snitchId);
@@ -97,8 +98,9 @@ public static class Snitch
if (IsComplete[snitchId] || !snitchTask.IsTaskFinished) return;
foreach (var target in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl target = Main.AllAlivePlayerControls[i];
if (!IsSnitchTarget(target)) continue;
var targetId = target.PlayerId;
+2 -1
View File
@@ -83,8 +83,9 @@ public static class Tracefinder
var pos = target.GetTruePosition();
float minDis = float.MaxValue;
string minName = string.Empty;
foreach (var pc in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl pc = Main.AllAlivePlayerControls[i];
if (pc.PlayerId == target.PlayerId) continue;
var dis = Vector2.Distance(pc.GetTruePosition(), pos);
if (dis < minDis && dis < 1.5f)
+6 -2
View File
@@ -46,8 +46,9 @@ internal class AntiAdminer
Count--; if (Count > 0) return; Count = 5;
bool Admin = false, Camera = false, DoorLog = false, Vital = false;
foreach (PlayerControl pc in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl pc = Main.AllAlivePlayerControls[i];
if (Pelican.IsEaten(pc.PlayerId) || pc.inVent || pc.GetCustomRole().IsImpostor()) continue;
try
{
@@ -117,8 +118,11 @@ internal class AntiAdminer
byte pc = playerIdList[i];
Utils.NotifyRoles(SpecifySeer: Utils.GetPlayerById(pc));
}
foreach (PlayerControl pc in Main.AllPlayerControls)
for (int i1 = 0; i1 < Main.AllPlayerControls.Count; i1++)
{
PlayerControl pc = Main.AllPlayerControls[i1];
FixedUpdatePatch.Postfix(pc);
}
}
}
}
+2 -1
View File
@@ -70,8 +70,9 @@ public static class EvilTracker
CanSetTarget.Add(playerId, CurrentTargetMode != TargetMode.Never);
//ImpostorsIdはEvilTracker内で共有
ImpostorsId[playerId] = new();
foreach (var target in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl target = Main.AllAlivePlayerControls[i];
var targetId = target.PlayerId;
if (targetId != playerId && target.Is(CustomRoleTypes.Impostor))
{
+3 -2
View File
@@ -113,8 +113,9 @@ public static class FireWorks
case FireWorksState.ReadyFire:
Logger.Info("花火を爆破", "FireWorks");
bool suicide = false;
foreach (var target in Main.AllAlivePlayerControls)
for (int i1 = 0; i1 < Main.AllAlivePlayerControls.Count; i1++)
{
PlayerControl target = Main.AllAlivePlayerControls[i1];
for (int i = 0; i < fireWorksPosition[pc.PlayerId].Count; i++)
{
Vector3 pos = fireWorksPosition[pc.PlayerId][i];
@@ -137,7 +138,7 @@ public static class FireWorks
}
if (suicide)
{
var totalAlive = Main.AllAlivePlayerControls.Count();
var totalAlive = Main.AllAlivePlayerControls.Count;
//自分が最後の生き残りの場合は勝利のために死なない
if (totalAlive != 1)
{
+2 -1
View File
@@ -139,8 +139,9 @@ public static class Sniper
//至近距離で外す対策に一歩後ろから判定を開始する
snipePos -= dir;
foreach (var target in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl target = Main.AllAlivePlayerControls[i];
//自分には当たらない
if (target.PlayerId == sniper.PlayerId) continue;
//死んでいない対象の方角ベクトル作成
+2 -1
View File
@@ -54,8 +54,9 @@ namespace TOHE.Roles.Impostor
TwistLimit[shapeshifter.PlayerId] -= 1;
var rd = IRandom.Instance;
foreach (var pc in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl pc = Main.AllAlivePlayerControls[i];
if (changePositionPlayers.Contains(pc.PlayerId) || Pelican.IsEaten(pc.PlayerId) || !pc.IsAlive() || pc.onLadder || pc.inVent || GameStates.IsMeeting)
{
continue;
+2 -1
View File
@@ -190,8 +190,9 @@ public static class Witch
SpelledPlayer[id].Clear();
}
var spelledIdList = new List<byte>();
foreach (var pc in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl pc = Main.AllAlivePlayerControls[i];
var dic = SpelledPlayer.Where(x => x.Value.Contains(pc.PlayerId));
if (!dic.Any()) continue;
var whichId = dic.FirstOrDefault().Key;
+2 -1
View File
@@ -93,8 +93,9 @@ public static class DarkHide
MessageExtensions.WriteNetObject(SabotageFixWriter, killer);
AmongUsClient.Instance.FinishRpcImmediately(SabotageFixWriter);
foreach (var target in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl target = Main.AllPlayerControls[i];
if (target.PlayerId == killer.PlayerId || target.Data.Disconnected) continue;
SabotageFixWriter = AmongUsClient.Instance.StartRpcImmediately(ShipStatus.Instance.NetId, (byte)RpcCalls.RepairSystem, SendOption.Reliable, target.GetClientId());
SabotageFixWriter.Write((byte)SystemTypes.Electrical);
+2 -1
View File
@@ -68,8 +68,9 @@ public static class Executioner
{
List<PlayerControl> targetList = new();
var rand = IRandom.Instance;
foreach (var target in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl target = Main.AllPlayerControls[i];
if (playerId == target.PlayerId) continue;
else if (!CanTargetImpostor.GetBool() && target.Is(CustomRoleTypes.Impostor)) continue;
else if (!CanTargetNeutralKiller.GetBool() && target.IsNeutralKiller()) continue;
+4 -1
View File
@@ -49,8 +49,11 @@ public static class Gamer
{
playerIdList.Add(playerId);
GamerHealth.TryAdd(playerId, SelfHealthMax.GetInt());
foreach (var pc in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl pc = Main.AllAlivePlayerControls[i];
PlayerHealth.TryAdd(pc.PlayerId, HealthMax.GetInt());
}
if (!AmongUsClient.Instance.AmHost) return;
if (!Main.ResetCamPlayerList.Contains(playerId))
+2 -1
View File
@@ -199,8 +199,9 @@ public static class HexMaster
HexedPlayer[id].Clear();
}
var hexedIdList = new List<byte>();
foreach (var pc in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl pc = Main.AllAlivePlayerControls[i];
var dic = HexedPlayer.Where(x => x.Value.Contains(pc.PlayerId));
if (!dic.Any()) continue;
var whichId = dic.FirstOrDefault().Key;
+2 -1
View File
@@ -71,8 +71,9 @@ public static class Lawyer
{
List<PlayerControl> targetList = new();
var rand = IRandom.Instance;
foreach (var target in Main.AllPlayerControls)
for (int i = 0; i < Main.AllPlayerControls.Count; i++)
{
PlayerControl target = Main.AllPlayerControls[i];
if (playerId == target.PlayerId) continue;
else if (!CanTargetImpostor.GetBool() && target.Is(CustomRoleTypes.Impostor)) continue;
else if (!CanTargetNeutralKiller.GetBool() && target.IsNeutralKiller()) continue;
+2 -1
View File
@@ -377,8 +377,9 @@ public static class Magician
snipePos -= dir;
foreach (var target in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl target = Main.AllAlivePlayerControls[i];
if (target.PlayerId == sniper.PlayerId) continue;
var target_pos = target.transform.position - snipePos;
if (target_pos.magnitude < 1) continue;
+4 -4
View File
@@ -76,11 +76,11 @@ public static class PlagueBearer
}
public static (int, int) PlaguedPlayerCount(byte playerId)
{
int plagued = 0, all = 0; //学校で習った書き方
//多分この方がMain.isDousedでforeachするより他のアーソニストの分ループ数少なくて済む
foreach (var pc in Main.AllAlivePlayerControls)
int plagued = 0, all = 0;
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
if (pc.PlayerId == playerId) continue; //塗れない人は除外 (死んでたり切断済みだったり あとアーソニスト自身も)
PlayerControl pc = Main.AllAlivePlayerControls[i];
if (pc.PlayerId == playerId) continue;
all++;
if (isPlagued(playerId, pc.PlayerId))
+2 -1
View File
@@ -53,8 +53,9 @@ public static class Postman
{
byte tempTarget = byte.MaxValue;
foreach (var pc in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl pc = Main.AllAlivePlayerControls[i];
if (wereTargets.Contains(pc.PlayerId)) continue;
tempTarget = pc.PlayerId;
break;
+2 -1
View File
@@ -130,8 +130,9 @@ namespace TOHE.Roles.Neutral
}
var infectedIdList = new List<byte>();
foreach (var pc in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl pc = Main.AllAlivePlayerControls[i];
bool isInfected = InfectedPlayer.Contains(pc.PlayerId);
if (!isInfected) continue;
+2 -1
View File
@@ -128,8 +128,9 @@ public static class Vulture
var pos = target.GetTruePosition();
float minDis = float.MaxValue;
foreach (var pc in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl pc = Main.AllAlivePlayerControls[i];
if (pc.PlayerId == target.PlayerId) continue;
var dis = Vector2.Distance(pc.GetTruePosition(), pos);
if (dis < minDis && dis < 1.5f)
+2 -1
View File
@@ -100,8 +100,9 @@ public static class WeaponMaster
case 1:
_ = new LateTask(() =>
{
foreach (var player in Main.AllAlivePlayerControls)
for (int i = 0; i < Main.AllAlivePlayerControls.Count; i++)
{
PlayerControl player = Main.AllAlivePlayerControls[i];
if (Pelican.IsEaten(player.PlayerId)) continue;
if (player == killer) continue;
if (player.Is(CustomRoles.Pestilence) || Main.VeteranInProtect.ContainsKey(target.PlayerId)) continue;
+2 -2
View File
@@ -234,8 +234,8 @@ public class Main : BasePlugin
public static byte GodfatherTarget = byte.MaxValue;
public static IEnumerable<PlayerControl> AllPlayerControls => PlayerControl.AllPlayerControls.ToArray().Where(p => p != null);
public static IEnumerable<PlayerControl> AllAlivePlayerControls => PlayerControl.AllPlayerControls.ToArray().Where(p => p != null && p.IsAlive() && !p.Data.Disconnected && !Pelican.IsEaten(p.PlayerId));
public static List<PlayerControl> AllPlayerControls => PlayerControl.AllPlayerControls.ToArray().Where(p => p != null).ToList();
public static List<PlayerControl> AllAlivePlayerControls => PlayerControl.AllPlayerControls.ToArray().Where(p => p != null && p.IsAlive() && !p.Data.Disconnected && !Pelican.IsEaten(p.PlayerId)).ToList();
public static Main Instance;