Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/features/exhaust.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ void ExhaustFx::Init()

for (auto& e : data.m_pDummies) {
RenderSmokeFx(pVeh, e.second);
if (e.second.pFxSysem && data.lastNitroFrame != CTimer::m_FrameCounter) {
if (e.second.pFxSysem->m_nPlayStatus == eFxSystemPlayStatus::FX_PLAYING) {
e.second.pFxSysem->Stop();
}
}
} });
ogFunc1 = injector::GetBranchDestination(0x6AB344, true).get();
injector::MakeCALL(0x6AB344, hkAddExhaustParticles1, true);
Expand All @@ -135,6 +140,7 @@ ExhaustData ExhaustFx::LoadData(CVehicle *pVeh, RwFrame *pFrame)
ExhaustData f;
f.sName = GetFrameNodeName(pFrame);
f.pFrame = pFrame;
f.bNitroEffect = true;

auto &jsonData = DataMgr::Get(pVeh->m_nModelIndex);
if (jsonData.contains("exhausts") && jsonData["exhausts"].contains(f.sName))
Expand Down Expand Up @@ -279,6 +285,8 @@ void ExhaustFx::RenderNitroFx(CVehicle *pVeh, float power)
return;
}

data.lastNitroFrame = CTimer::m_FrameCounter;

for (auto &e : data.m_pDummies)
{
if (!e.second.bNitroEffect)
Expand Down Expand Up @@ -338,6 +346,15 @@ void ExhaustFx::RenderNitroFx(CVehicle *pVeh, float power)

void ExhaustFx::Reload(CVehicle* pVeh)
{
if (pVeh) {
auto &data = m_VehData.Get(pVeh);
for (auto &e : data.m_pDummies) {
if (e.second.pFxSysem) {
e.second.pFxSysem->Kill();
e.second.pFxSysem = nullptr;
}
}
}
nReloadCount++;
}

Expand Down
9 changes: 8 additions & 1 deletion src/features/exhausts.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,24 @@ struct ExhaustData
float fLifeTime = 1.0f; // Longer lifetime for larger pipes
float fSpeedMul = 1.0f; // Speed multiplier
float fSizeMul = 1.0f;
bool bNitroEffect = false;
bool bNitroEffect = true;
FxSystem_c *pFxSysem = nullptr;
};

struct ExhaustVehData {
bool isUsed = false;
size_t reloadCount = 0;
unsigned int lastNitroFrame = 0;
std::vector<std::pair<std::string, ExhaustData>> m_pDummies;
ExhaustVehData(CVehicle *pVeh) { isUsed = false; }

~ExhaustVehData() {
for (auto &e : m_pDummies) {
if (e.second.pFxSysem) {
e.second.pFxSysem->Kill();
e.second.pFxSysem = nullptr;
}
}
}
};

Expand Down