diff --git a/mod/Jailbreak.Rebel/RebelManager.cs b/mod/Jailbreak.Rebel/RebelManager.cs index 1fd76c33..00a170a3 100644 --- a/mod/Jailbreak.Rebel/RebelManager.cs +++ b/mod/Jailbreak.Rebel/RebelManager.cs @@ -31,7 +31,6 @@ public void Start(BasePlugin basePlugin) { basePlugin.RegisterEventHandler(OnPlayerDisconnect); basePlugin.RegisterEventHandler(OnPlayerDeath); basePlugin.RegisterEventHandler(OnRoundStart); - basePlugin.RegisterListener(OnTick); basePlugin.AddTimer(1f, () => { foreach (var player in GetActiveRebels()) { @@ -45,7 +44,6 @@ public void Start(BasePlugin basePlugin) { } applyRebelColor(player); - sendTimeLeft(player); } }, TimerFlags.REPEAT); } @@ -90,16 +88,6 @@ public void UnmarkRebel(CCSPlayerController player) { public void DisableRebelForRound() { enabled = false; } - private void OnTick() { - foreach (var player in GetActiveRebels()) { - if (!player.IsReal()) continue; - - if (GetRebelTimeLeft(player) <= 0) continue; - - sendTimeLeft(player); - } - } - private HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info) { enabled = true; rebelTimes.Clear(); @@ -151,16 +139,9 @@ private void applyRebelColor(CCSPlayerController player) { player.Pawn.Value.Render = color; Utilities.SetStateChanged(player.Pawn.Value, "CBaseModelEntity", "m_clrRender"); - } - - private void sendTimeLeft(CCSPlayerController player) { - // var timeLeft = GetRebelTimeLeft(player); - // var formattedTime = TimeSpan.FromSeconds(timeLeft).ToString(@"mm\:ss"); - var color = getRebelColor(player); - var formattedColor = - $""; - player.PrintToCenterHtml( - $"You are {formattedColor}rebelling"); + player.ColorScreen( + Color.FromArgb(8 + (int)Math.Round(getRebelTimePercentage(player) * 32), + Color.Red), 1f, 1.5f, PlayerExtensions.FadeFlags.FADE_OUT); } } \ No newline at end of file diff --git a/mod/Jailbreak.Warden/SpecialTreatment/SpecialTreatmentBehavior.cs b/mod/Jailbreak.Warden/SpecialTreatment/SpecialTreatmentBehavior.cs index 9cf2e9a8..73fdf8ca 100644 --- a/mod/Jailbreak.Warden/SpecialTreatment/SpecialTreatmentBehavior.cs +++ b/mod/Jailbreak.Warden/SpecialTreatment/SpecialTreatmentBehavior.cs @@ -4,6 +4,7 @@ using Jailbreak.Formatting.Extensions; using Jailbreak.Formatting.Views.Warden; using Jailbreak.Public.Behaviors; +using Jailbreak.Public.Extensions; using Jailbreak.Public.Generic; using Jailbreak.Public.Mod.Rebel; using Jailbreak.Public.Mod.Warden; @@ -28,6 +29,8 @@ public void Grant(CCSPlayerController player) { if (rebel.IsRebel(player)) rebel.UnmarkRebel(player); setSpecialColor(player, true); + player.ColorScreen(Color.FromArgb(16, 0, 255, 0), 999999, 0.2f, + PlayerExtensions.FadeFlags.FADE_OUT); notifications.Granted.ToChat(player).ToCenter(player); @@ -41,6 +44,7 @@ public void Revoke(CCSPlayerController player) { sts.Get(player).HasSpecialTreatment = false; setSpecialColor(player, false); + player.ColorScreen(Color.FromArgb(16, 0, 255, 0), 0f, 1.5f); notifications.Revoked.ToChat(player).ToCenter(player); diff --git a/public/Jailbreak.Public/Extensions/PlayerExtensions.cs b/public/Jailbreak.Public/Extensions/PlayerExtensions.cs index 4713d6c4..2afed6d6 100644 --- a/public/Jailbreak.Public/Extensions/PlayerExtensions.cs +++ b/public/Jailbreak.Public/Extensions/PlayerExtensions.cs @@ -2,6 +2,7 @@ using CounterStrikeSharp.API; using CounterStrikeSharp.API.Core; using CounterStrikeSharp.API.Modules.Memory; +using CounterStrikeSharp.API.Modules.UserMessages; using CounterStrikeSharp.API.Modules.Utils; namespace Jailbreak.Public.Extensions; @@ -149,4 +150,31 @@ public static void SetColor(this CCSPlayerController player, Color color) { .FirstOrDefault(w => w.Value?.DesignerName == designerName) ?.Value; } + + public enum FadeFlags { + FADE_IN, FADE_OUT, FADE_STAYOUT + } + + public static void ColorScreen(this CCSPlayerController player, Color color, + float hold = 0.1f, float fade = 0.2f, FadeFlags flags = FadeFlags.FADE_IN, + bool withPurge = true) { + var fadeMsg = UserMessage.FromId(106); + + fadeMsg.SetInt("duration", Convert.ToInt32(fade * 512)); + fadeMsg.SetInt("hold_time", Convert.ToInt32(hold * 512)); + + var flag = flags switch { + FadeFlags.FADE_IN => 0x0001, + FadeFlags.FADE_OUT => 0x0002, + FadeFlags.FADE_STAYOUT => 0x0008, + _ => 0x0001 + }; + + if (withPurge) flag |= 0x0010; + + fadeMsg.SetInt("flags", flag); + fadeMsg.SetInt("color", + color.R | color.G << 8 | color.B << 16 | color.A << 24); + fadeMsg.Send(player); + } } \ No newline at end of file diff --git a/public/Jailbreak.Public/Jailbreak.Public.csproj b/public/Jailbreak.Public/Jailbreak.Public.csproj index 029c9835..ee3295a2 100644 --- a/public/Jailbreak.Public/Jailbreak.Public.csproj +++ b/public/Jailbreak.Public/Jailbreak.Public.csproj @@ -7,7 +7,7 @@ - +