2020-12-02 16:19:16 -05:00
|
|
|
#include "pch.h"
|
2021-01-18 04:53:24 -05:00
|
|
|
#include "Neon.h"
|
2021-01-03 06:48:07 -05:00
|
|
|
#include "Util.h"
|
2020-12-02 16:19:16 -05:00
|
|
|
|
2021-01-18 04:53:24 -05:00
|
|
|
VehicleExtendedData<Neon::NeonData> Neon::VehNeon;
|
|
|
|
RwTexture* Neon::neon_texture = nullptr;
|
2020-12-02 16:19:16 -05:00
|
|
|
|
2021-01-18 04:53:24 -05:00
|
|
|
Neon::Neon()
|
2020-12-02 16:19:16 -05:00
|
|
|
{
|
2021-02-24 16:54:45 -05:00
|
|
|
neon_texture = Util::LoadTextureFromPngFile(PLUGIN_PATH((char*)"CheatMenu\\vehicles\\neon_mask.png"));
|
|
|
|
if (!neon_texture)
|
|
|
|
flog << "WARN: Failed to load neon mask" << std::endl;
|
2020-12-25 16:22:28 -05:00
|
|
|
|
2021-02-24 16:54:45 -05:00
|
|
|
Events::vehicleRenderEvent += [](CVehicle* pVeh)
|
2020-12-25 16:22:28 -05:00
|
|
|
{
|
2021-02-24 16:54:45 -05:00
|
|
|
NeonData* data = &VehNeon.Get(pVeh);
|
2020-12-25 16:22:28 -05:00
|
|
|
if (data->neon_installed && !pVeh->IsUpsideDown())
|
2020-12-02 16:19:16 -05:00
|
|
|
{
|
2021-01-09 15:06:53 -05:00
|
|
|
CVector Pos = CModelInfo::GetModelInfo(pVeh->m_nModelIndex)->m_pColModel->m_boundBox.m_vecMin;
|
2021-02-24 16:54:45 -05:00
|
|
|
CVector center = pVeh->TransformFromObjectSpace(CVector(0.0f, 0.0f, 0.0f));
|
2020-12-25 16:22:28 -05:00
|
|
|
CVector up = pVeh->TransformFromObjectSpace(CVector(0.0f, -Pos.y - data->val, 0.0f)) - center;
|
2021-02-24 16:54:45 -05:00
|
|
|
CVector right = pVeh->TransformFromObjectSpace(CVector(Pos.x + data->val, 0.0f, 0.0f)) - center;
|
|
|
|
CShadows::StoreShadowToBeRendered(5, neon_texture, ¢er, up.x, up.y, right.x, right.y, 180, data->color.r, data->color.g, data->color.b, 2.0f, false, 1.0f, 0, true);
|
2020-12-02 16:19:16 -05:00
|
|
|
|
2020-12-25 16:22:28 -05:00
|
|
|
if (CTimer::m_snTimeInMilliseconds - data->timer > 150)
|
|
|
|
{
|
|
|
|
data->timer = CTimer::m_snTimeInMilliseconds;
|
|
|
|
|
2021-01-07 16:07:45 -05:00
|
|
|
if (data->pulsing)
|
|
|
|
{
|
|
|
|
if (data->val < 0.0f)
|
2021-02-24 16:54:45 -05:00
|
|
|
data->increment = true;
|
2020-12-25 16:22:28 -05:00
|
|
|
|
2021-01-07 16:07:45 -05:00
|
|
|
if (data->val > 0.3f)
|
|
|
|
data->increment = false;
|
2020-12-25 16:22:28 -05:00
|
|
|
|
2021-01-07 16:07:45 -05:00
|
|
|
if (data->increment)
|
|
|
|
data->val += 0.1f;
|
|
|
|
else
|
|
|
|
data->val -= 0.1f;
|
|
|
|
}
|
2020-12-25 16:22:28 -05:00
|
|
|
}
|
2020-12-02 16:19:16 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-01-18 04:53:24 -05:00
|
|
|
Neon::~Neon()
|
2020-12-02 16:19:16 -05:00
|
|
|
{
|
2020-12-25 16:22:28 -05:00
|
|
|
delete neon_texture;
|
2020-12-02 16:19:16 -05:00
|
|
|
}
|
|
|
|
|
2021-02-24 16:54:45 -05:00
|
|
|
bool Neon::IsNeonInstalled(CVehicle* pVeh)
|
2020-12-02 16:19:16 -05:00
|
|
|
{
|
2020-12-25 16:22:28 -05:00
|
|
|
return VehNeon.Get(pVeh).neon_installed;
|
2020-12-02 16:19:16 -05:00
|
|
|
}
|
|
|
|
|
2021-02-24 16:54:45 -05:00
|
|
|
bool Neon::IsPulsingEnabled(CVehicle* pVeh)
|
2021-01-07 16:07:45 -05:00
|
|
|
{
|
|
|
|
return VehNeon.Get(pVeh).pulsing;
|
|
|
|
}
|
|
|
|
|
2021-02-24 16:54:45 -05:00
|
|
|
void Neon::SetPulsing(CVehicle* pVeh, bool state)
|
2021-01-07 16:07:45 -05:00
|
|
|
{
|
|
|
|
VehNeon.Get(pVeh).pulsing = state;
|
|
|
|
}
|
|
|
|
|
2021-02-24 16:54:45 -05:00
|
|
|
void Neon::InstallNeon(CVehicle* pVeh, int red, int green, int blue)
|
2020-12-02 16:19:16 -05:00
|
|
|
{
|
2021-02-24 16:54:45 -05:00
|
|
|
CRGBA& color = VehNeon.Get(pVeh).color;
|
2020-12-25 16:22:28 -05:00
|
|
|
|
|
|
|
color.r = red;
|
|
|
|
color.g = green;
|
|
|
|
color.b = blue;
|
|
|
|
color.a = 255;
|
2020-12-02 16:19:16 -05:00
|
|
|
|
2020-12-25 16:22:28 -05:00
|
|
|
VehNeon.Get(pVeh).neon_installed = true;
|
2020-12-02 16:19:16 -05:00
|
|
|
}
|
|
|
|
|
2021-02-24 16:54:45 -05:00
|
|
|
void Neon::RemoveNeon(CVehicle* pVeh)
|
2020-12-02 16:19:16 -05:00
|
|
|
{
|
2020-12-25 16:22:28 -05:00
|
|
|
VehNeon.Get(pVeh).neon_installed = false;
|
2020-12-02 16:19:16 -05:00
|
|
|
}
|