Skip to content

Commit

Permalink
format rainbow.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
sjrc6 committed Oct 7, 2024
1 parent 9662319 commit 7f97f14
Showing 1 changed file with 62 additions and 60 deletions.
122 changes: 62 additions & 60 deletions src/game/client/components/rainbow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,71 +12,73 @@

void CRainbow::TransformColor(unsigned char mode, int tick, CTeeRenderInfo *pinfo)
{
if (!mode)
return;
if(!mode)
return;

int deftick = tick % 255;

const ColorHSLA playercolbody = ColorHSLA(g_Config.m_ClPlayerColorBody);
const ColorHSLA playercolfeet = ColorHSLA(g_Config.m_ClPlayerColorFeet);

const ColorRGBA col = color_cast<ColorRGBA>(ColorHSLA((float)deftick / 255.0f, 1.0f, 0.5f));
if (mode == COLORMODE_RAINBOW)
{
pinfo->m_CustomColoredSkin = true;
pinfo->m_ColorBody = col;
pinfo->m_ColorFeet = col;
pinfo->m_BloodColor = col;
return;
}else if (mode == COLORMODE_PULSE)
{
pinfo->m_CustomColoredSkin = true;
pinfo->m_ColorBody.s = 1.0f;
pinfo->m_ColorFeet.s = 1.0f;
pinfo->m_BloodColor.s = 1.0f;
pinfo->m_ColorBody.l = 0.5f + fabs(((float)deftick / 255.0f) - 0.5f);
pinfo->m_ColorFeet.l = 0.5f + fabs(((float)deftick / 255.0f) - 0.5f);
pinfo->m_BloodColor.l = 0.5f + 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;
int deftick = tick % 255;

return;
}else if (mode == COLORMODE_DARKNESS)
{
pinfo->m_CustomColoredSkin = true;
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);
return;
}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;
return;
}
const ColorHSLA playercolbody = ColorHSLA(g_Config.m_ClPlayerColorBody);
const ColorHSLA playercolfeet = ColorHSLA(g_Config.m_ClPlayerColorFeet);

const ColorRGBA col = color_cast<ColorRGBA>(ColorHSLA((float)deftick / 255.0f, 1.0f, 0.5f));
if(mode == COLORMODE_RAINBOW)
{
pinfo->m_CustomColoredSkin = true;
pinfo->m_ColorBody = col;
pinfo->m_ColorFeet = col;
pinfo->m_BloodColor = col;
return;
}
else if(mode == COLORMODE_PULSE)
{
pinfo->m_CustomColoredSkin = true;
pinfo->m_ColorBody.s = 1.0f;
pinfo->m_ColorFeet.s = 1.0f;
pinfo->m_BloodColor.s = 1.0f;
pinfo->m_ColorBody.l = 0.5f + fabs(((float)deftick / 255.0f) - 0.5f);
pinfo->m_ColorFeet.l = 0.5f + fabs(((float)deftick / 255.0f) - 0.5f);
pinfo->m_BloodColor.l = 0.5f + 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;

return;
}
else if(mode == COLORMODE_DARKNESS)
{
pinfo->m_CustomColoredSkin = true;
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);
return;
}
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;
return;
}
}

void CRainbow::OnRender()
{
for(int i = 0; i < MAX_CLIENTS; i++)
{
// check if local player
bool Local = m_pClient->m_Snap.m_LocalClientId == i;

for (int i = 0; i < MAX_CLIENTS; i++)
{
// 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);
}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);
}

}

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);
}
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);
}
}
}

0 comments on commit 7f97f14

Please sign in to comment.