Skip to content

Commit

Permalink
Fix color
Browse files Browse the repository at this point in the history
  • Loading branch information
MSWS committed Feb 3, 2024
1 parent f4518b1 commit 88345fd
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions mod/Jailbreak.Rebel/RebelManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void Start(BasePlugin parent)
{
parent.RegisterEventHandler<EventPlayerDisconnect>(OnPlayerDisconnect);
parent.RegisterEventHandler<EventRoundStart>(OnRoundStart);

parent.AddTimer(1f, () =>
{
foreach (var player in GetActiveRebels())
Expand All @@ -40,8 +40,11 @@ private HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info)
rebelTimes.Clear();
foreach (var player in Utilities.GetPlayers())
{
ApplyRebelColor(player);
if (!player.IsValid)
continue;
ApplyRebelColor(player);
}

return HookResult.Continue;
}

Expand Down Expand Up @@ -99,13 +102,10 @@ private void ApplyRebelColor(CCSPlayerController player)
{
if (!player.IsValid || player.Pawn.Value == null)
return;
var percentage = GetRebelTimePercentage(player);
player.PrintToConsole("Rebel percentage: " + percentage);
var inverse = 1 - percentage;
var inverseInt = (int)(inverse * 255);
var color = Color.FromArgb(254, (int) Math.Round(percentage * 255.0), inverseInt, inverseInt);
var percentRGB = (int)Math.Round(GetRebelTimePercentage(player) * 255.0);
var color = Color.FromArgb(254, 255, percentRGB, percentRGB);
player.PrintToConsole("Color: " + color.ToString());
if (percentage <= 0)
if (percentRGB <= 0)
{
color = Color.FromArgb(254, 255, 255, 255);
}
Expand Down

0 comments on commit 88345fd

Please sign in to comment.