Skip to content

Commit

Permalink
heehaw
Browse files Browse the repository at this point in the history
  • Loading branch information
Misfiy committed May 3, 2024
1 parent 391c1ef commit dd85255
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
10 changes: 9 additions & 1 deletion SpectatorList/Config.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
using Exiled.API.Interfaces;
using System.Collections.Generic;
using System.ComponentModel;
using Exiled.API.Interfaces;
using PlayerRoles;

namespace SpectatorList
{
public class Config : IConfig
{
public bool IsEnabled { get; set; } = true;
public bool Debug { get; set; } = false;
[Description("A list of teams the hints should be hidden for")]
public List<Team> HiddenFor { get; set; } = new List<Team>();
[Description("How often in seconds to refresh the hud")]
public float RefreshRate { get; set; } = 2;
public string FullText { get; set; } = "<size=23><align=right><voffset=750>%display%</size></voffset></align>";
public string PlayerDisplay { get; set; } = "%name%";
}
}
12 changes: 7 additions & 5 deletions SpectatorList/EventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ namespace SpectatorList
{
public class EventHandler
{
private Config _config => SpectatorList.Instance.Config;

public EventHandler() => Timing.RunCoroutine(DoList());

private IEnumerator<float> DoList()
{
while (true)
for (; ;)
{
if (Round.IsEnded)
{
Expand All @@ -23,7 +25,7 @@ private IEnumerator<float> DoList()

foreach (Player player in Player.List)
{
if (player.IsDead) continue;
if (player.IsDead || _config.HiddenFor.Contains(player.Role.Team)) continue;

int count = player.CurrentSpectatingPlayers.Count(p => p.Role != RoleTypeId.Overwatch);

Expand All @@ -32,13 +34,13 @@ private IEnumerator<float> DoList()

foreach (Player spectator in player.CurrentSpectatingPlayers.Where(p => p.Role != RoleTypeId.Overwatch))
{
sb.AppendLine(spectator.DisplayNickname);
sb.AppendLine(_config.PlayerDisplay.Replace("%name%", spectator.DisplayNickname));
}

player.ShowHint($"<size=23><align=right><voffset=750>{sb}</size></voffset></align>", SpectatorList.Instance.Config.RefreshRate + 0.15f);
player.ShowHint(_config.FullText.Replace("%display%", sb.ToString()), _config.RefreshRate + 0.15f);
}

yield return Timing.WaitForSeconds(SpectatorList.Instance.Config.RefreshRate);
yield return Timing.WaitForSeconds(_config.RefreshRate);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion SpectatorList/SpectatorList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class SpectatorList : Plugin<Config>

public override string Name { get; } = "Spectator List";
public override string Author { get; } = "@misfiy";
public override Version Version { get; } = new Version(1,0,0);
public override Version Version { get; } = new Version(1,1,0);
public override Version RequiredExiledVersion { get; } = new Version(8, 8, 1);

private EventHandler _handler;
Expand Down

0 comments on commit dd85255

Please sign in to comment.