Skip to content

Commit

Permalink
Fix / cleanup rainbow
Browse files Browse the repository at this point in the history
  • Loading branch information
SollyBunny committed Nov 23, 2024
1 parent 12e076a commit e476f0a
Showing 1 changed file with 14 additions and 39 deletions.
53 changes: 14 additions & 39 deletions src/game/client/components/rainbow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,60 +17,35 @@ void CRainbow::TransformColor(unsigned char Mode, int Tick, CTeeRenderInfo *pinf

int DefTick = Tick % 255;

const ColorHSLA PlayerColBody = ColorHSLA(g_Config.m_ClPlayerColorBody);
const ColorHSLA PlayerColFeet = ColorHSLA(g_Config.m_ClPlayerColorFeet);

pinfo->m_CustomColoredSkin = true;
ColorRGBA Col;
if(Mode == COLORMODE_RAINBOW)
{
const ColorRGBA Col = color_cast<ColorRGBA>(ColorHSLA((float)DefTick / 255.0f, 1.0f, 0.5f));
pinfo->m_ColorBody = Col;
pinfo->m_ColorFeet = Col;
pinfo->m_BloodColor = Col;
}
Col = color_cast<ColorRGBA>(ColorHSLA((float)DefTick / 255.0f, 1.0f, 0.5f));
else if(Mode == COLORMODE_PULSE)
{
pinfo->m_ColorBody.s = 1.0f;
pinfo->m_ColorFeet.s = 1.0f;
pinfo->m_BloodColor.s = 1.0f;
pinfo->m_ColorBody.l = 0.5f + std::fabs(((float)DefTick / 255.0f) - 0.5f);
pinfo->m_ColorFeet.l = 0.5f + std::fabs(((float)DefTick / 255.0f) - 0.5f);
pinfo->m_BloodColor.l = 0.5f + std::fabs(((float)DefTick / 255.0f) - 0.5f);
pinfo->m_ColorBody.h = (float)DefTick / 255.0f;
pinfo->m_ColorFeet.h = (float)DefTick / 255.0f;
pinfo->m_BloodColor.h = (float)DefTick / 255.0f;
}
Col = color_cast<ColorRGBA>(ColorHSLA(1.0f, (float)DefTick / 255.0f, 1.0f, 0.5f + std::fabs(((float)DefTick / 255.0f) - 0.5f)));
else if(Mode == COLORMODE_DARKNESS)
{
pinfo->m_ColorBody = ColorRGBA(0.0f, 0.0f, 0.0f);
pinfo->m_ColorFeet = ColorRGBA(0.0f, 0.0f, 0.0f);
pinfo->m_BloodColor = ColorRGBA(0.0f, 0.0f, 0.0f);
}
else
{
pinfo->m_CustomColoredSkin = true;
pinfo->m_ColorBody = color_cast<ColorRGBA>(PlayerColBody);
pinfo->m_ColorFeet = color_cast<ColorRGBA>(PlayerColFeet);
// pinfo->m_BloodColor = pinfo->m_BloodColor; // TODO reset blood color
}
Col = pinfo->m_ColorBody = ColorRGBA(0.0f, 0.0f, 0.0f);
pinfo->m_ColorBody = Col;
pinfo->m_ColorFeet = Col;
pinfo->m_BloodColor = Col;
}

void CRainbow::OnRender()
{
static int Tick = 0;
++Tick;
for(int i = 0; i < MAX_CLIENTS; i++)
{
if(!m_pClient->m_Snap.m_aCharacters[i].m_Active)
continue;

// check if local player
bool Local = m_pClient->m_Snap.m_LocalClientId == i;

CTeeRenderInfo *RenderInfo = &m_pClient->m_aClients[i].m_RenderInfo;
// check if rainbow is enabled
if(g_Config.m_ClRainbow && Local) // rainbow is enabled and is own player
{
TransformColor(g_Config.m_ClRainbowMode, m_pClient->m_GameWorld.m_GameTick, RenderInfo);
}
TransformColor(g_Config.m_ClRainbowMode, Tick, RenderInfo);
else if(g_Config.m_ClRainbowOthers && !Local) // rainbow is enabled and is not own player
{
TransformColor(g_Config.m_ClRainbowMode, m_pClient->m_GameWorld.m_GameTick, RenderInfo);
}
TransformColor(g_Config.m_ClRainbowMode, Tick, RenderInfo);
}
}

0 comments on commit e476f0a

Please sign in to comment.