diff --git a/mod/Jailbreak.Warden/Global/WardenBehavior.cs b/mod/Jailbreak.Warden/Global/WardenBehavior.cs index a97654f7..f063cec4 100644 --- a/mod/Jailbreak.Warden/Global/WardenBehavior.cs +++ b/mod/Jailbreak.Warden/Global/WardenBehavior.cs @@ -8,6 +8,7 @@ using Jailbreak.Public.Behaviors; using Jailbreak.Public.Extensions; using Jailbreak.Public.Mod.Logs; +using Jailbreak.Public.Mod.Rebel; using Jailbreak.Public.Mod.Warden; using Microsoft.Extensions.Logging; @@ -17,17 +18,28 @@ public class WardenBehavior : IPluginBehavior, IWardenService { private ILogger _logger; private IRichLogService _logs; - private IWardenNotifications _notifications; + private ISpecialTreatmentService _specialTreatment; + private IRebelService _rebels; + private ISet _bluePrisoners = new HashSet(); + private BasePlugin _parent; private bool _hasWarden; private CCSPlayerController? _warden; - public WardenBehavior(ILogger logger, IWardenNotifications notifications, IRichLogService logs) + public WardenBehavior(ILogger logger, IWardenNotifications notifications, IRichLogService logs, + ISpecialTreatmentService specialTreatment, IRebelService rebels) { _logger = logger; _notifications = notifications; _logs = logs; + _specialTreatment = specialTreatment; + _rebels = rebels; + } + + public void Start(BasePlugin parent) + { + _parent = parent; } /// @@ -57,7 +69,7 @@ public bool TrySetWarden(CCSPlayerController controller) if (_warden.Pawn.Value != null) { _warden.Pawn.Value.RenderMode = RenderMode_t.kRenderTransColor; - _warden.Pawn.Value.Render = Color.Blue; + _warden.Pawn.Value.Render = Color.FromArgb(254, 0, 0, 255); Utilities.SetStateChanged(_warden.Pawn.Value, "CBaseModelEntity", "m_clrRender"); } @@ -66,6 +78,8 @@ public bool TrySetWarden(CCSPlayerController controller) .ToAllCenter(); _logs.Append( _logs.Player(_warden), "is now the warden."); + + _parent.AddTimer(3, UnmarkPrisonersBlue); return true; } @@ -121,6 +135,53 @@ private void ProcessWardenDeath() .ToAllCenter(); _notifications.BECOME_NEXT_WARDEN.ToAllChat(); + + MarkPrisonersBlue(); + } + + private void UnmarkPrisonersBlue() + { + foreach (var player in _bluePrisoners) + { + var pawn = player.Pawn.Value; + if (pawn == null) + continue; + if(IgnoreColor(player)) + continue; + pawn.RenderMode = RenderMode_t.kRenderNormal; + pawn.Render = Color.FromArgb(254, 255, 255, 255); + Utilities.SetStateChanged(pawn, "CBaseModelEntity", "m_clrRender"); + } + _bluePrisoners.Clear(); + } + + private void MarkPrisonersBlue() + { + foreach(CCSPlayerController player in Utilities.GetPlayers()) + { + if(!player.IsReal() || player.Team != CsTeam.Terrorist) + continue; + if(IgnoreColor(player)) + continue; + + var pawn = player.Pawn.Value; + if(pawn == null) + continue; + pawn.RenderMode = RenderMode_t.kRenderTransColor; + pawn.Render = Color.FromArgb(254, 0, 0, 255); + Utilities.SetStateChanged(pawn, "CBaseModelEntity", "m_clrRender"); + + _bluePrisoners.Add(player); + } + } + + private bool IgnoreColor(CCSPlayerController player) + { + if (_specialTreatment.IsSpecialTreatment(player)) + return true; + if (_rebels.IsRebel(player)) + return true; + return false; } [GameEventHandler] diff --git a/src/Jailbreak/JailbreakServiceCollection.cs b/src/Jailbreak/JailbreakServiceCollection.cs index 7a5f2f9d..3081a93c 100644 --- a/src/Jailbreak/JailbreakServiceCollection.cs +++ b/src/Jailbreak/JailbreakServiceCollection.cs @@ -35,9 +35,9 @@ public void ConfigureServices(IServiceCollection serviceCollection) serviceCollection.AddJailbreakGeneric(); serviceCollection.AddJailbreakLogs(); + serviceCollection.AddJailbreakRebel(); serviceCollection.AddJailbreakWarden(); serviceCollection.AddJailbreakTeams(); - serviceCollection.AddJailbreakRebel(); serviceCollection.AddJailbreakDebug(); serviceCollection.AddJailbreakLastRequest();