Skip to content

Commit

Permalink
I am less Inefficient :D
Browse files Browse the repository at this point in the history
  • Loading branch information
XoMiya-WPC committed Oct 21, 2021
1 parent 1a067f0 commit 0c74f9c
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions WhoAreMyTeammates/Handlers/EventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ public void ShowBroadcast(WamtBroadcast wamt)
{
Log.Debug("Class Broadcast Disabled - Skipping....", WhoAreMyTeammates.Instance.Config.EnableDebug);
return;
}

}
var players = Player.Get(wamt.Team);
int playerCount = players.Count();
//var MaxCap = false;
if (wamt.MaxPlayers != -1)
{
Log.Debug("Attention - Detected Upper Limit to players - Moving to compare...", WhoAreMyTeammates.Instance.Config.EnableDebug);
if (players.Count() >= wamt.MaxPlayers)
if (playerCount >= wamt.MaxPlayers)
{
Log.Debug($"Max Players for {wamt.Team} ({wamt.MaxPlayers}) has been exceeded! Current count: {players.Count()}. Skipping...", WhoAreMyTeammates.Instance.Config.EnableDebug);
Log.Debug($"Max Players for {wamt.Team} ({wamt.MaxPlayers}) has been exceeded! Current count: {playerCount}. Skipping...", WhoAreMyTeammates.Instance.Config.EnableDebug);
return;
}
}

if (players.Count() == 1)
if (playerCount == 1)
{
Log.Debug("CallDelayed - Only one player is in this team.", WhoAreMyTeammates.Instance.Config.EnableDebug);
Timing.CallDelayed(wamt.Delay, () => players.First().Broadcast(WhoAreMyTeammates.Instance.Config.WamtBCTime, wamt.AloneContents));
Expand All @@ -73,15 +73,16 @@ public void ShowBroadcast(WamtBroadcast wamt)
if (name.Side == Side.Scp)
{
names += $"{ScpText[name.Role]}, ";
continue;
Log.Debug("Added SCP to names var", WhoAreMyTeammates.Instance.Config.EnableDebug);
continue;

}
names += $"{name.Nickname}, ";
}
}
contentsFormatted = wamt.Contents.Replace("%list%", names);
Log.Debug("Formated names to contentsFormatted (%list%)", WhoAreMyTeammates.Instance.Config.EnableDebug);
contentsFormatted = contentsFormatted.Replace("%count%", players.Count().ToString());
contentsFormatted = contentsFormatted.Replace("%count%", playerCount.ToString());
Log.Debug("Formated names to contentsFormatted (%count%)", WhoAreMyTeammates.Instance.Config.EnableDebug);
foreach (var player in players)
{
Expand Down

0 comments on commit 0c74f9c

Please sign in to comment.