Rename states

This commit is contained in:
Sergeanur 2020-08-31 21:35:05 +03:00
parent df67c73d81
commit 6778640b52
2 changed files with 12 additions and 12 deletions

View File

@ -172,24 +172,26 @@ CStinger::Process()
&& pOwner->GetPedState() == PED_DEPLOY_STINGER && pOwner->GetPedState() == PED_DEPLOY_STINGER
&& RpAnimBlendClumpGetAssociation(pOwner->GetClump(), ANIM_WEAPON_THROWU)->currentTime > 0.39f) && RpAnimBlendClumpGetAssociation(pOwner->GetClump(), ANIM_WEAPON_THROWU)->currentTime > 0.39f)
{ {
m_nSpikeState = STINGERSTATE_STATE1; m_nSpikeState = STINGERSTATE_DEPLOYING;
for (int i = 0; i < NUM_STINGER_SEGMENTS; i++) for (int i = 0; i < NUM_STINGER_SEGMENTS; i++)
CWorld::Add(pSpikes[i]); CWorld::Add(pSpikes[i]);
pOwner->SetIdle(); pOwner->SetIdle();
} }
break; break;
case STINGERSTATE_STATE2: case STINGERSTATE_DEPLOYED:
if (pOwner != nil && pOwner->m_nPedType == PEDTYPE_COP) if (pOwner != nil && pOwner->m_nPedType == PEDTYPE_COP)
((CCopPed*)pOwner)->m_bThrowsSpikeTrap = false; ((CCopPed*)pOwner)->m_bThrowsSpikeTrap = false;
break; break;
case STINGERSTATE_STATE3: case STINGERSTATE_UNDEPLOYING:
if (CTimer::GetTimeInMilliseconds() > m_nTimeOfDeploy + 2500) if (CTimer::GetTimeInMilliseconds() > m_nTimeOfDeploy + 2500)
m_nSpikeState = STINGERSTATE_REMOVE; m_nSpikeState = STINGERSTATE_REMOVE;
// no break // no break
case STINGERSTATE_STATE1: case STINGERSTATE_DEPLOYING:
if (m_nSpikeState != STINGERSTATE_STATE1 || CTimer::GetTimeInMilliseconds() <= m_nTimeOfDeploy + 2500) { if (m_nSpikeState == STINGERSTATE_DEPLOYING && CTimer::GetTimeInMilliseconds() > m_nTimeOfDeploy + 2500)
m_nSpikeState = STINGERSTATE_DEPLOYED;
else {
float progress = (CTimer::GetTimeInMilliseconds() - m_nTimeOfDeploy) / 2500.0f; float progress = (CTimer::GetTimeInMilliseconds() - m_nTimeOfDeploy) / 2500.0f;
if (m_nSpikeState != STINGERSTATE_STATE1) if (m_nSpikeState != STINGERSTATE_DEPLOYING)
progress = 1.0f - progress; progress = 1.0f - progress;
float degangle = progress * ARRAY_SIZE(m_vPositions); float degangle = progress * ARRAY_SIZE(m_vPositions);
@ -221,8 +223,7 @@ CStinger::Process()
} }
pSpikes[spike]->SetPosition(pos3d); pSpikes[spike]->SetPosition(pos3d);
} }
} else }
m_nSpikeState = STINGERSTATE_STATE2;
break; break;
case STINGERSTATE_REMOVE: case STINGERSTATE_REMOVE:
Remove(); Remove();

View File

@ -13,12 +13,11 @@ public:
class CStinger class CStinger
{ {
// TODO: better names
enum { enum {
STINGERSTATE_NONE = 0, STINGERSTATE_NONE = 0,
STINGERSTATE_STATE1, STINGERSTATE_DEPLOYING,
STINGERSTATE_STATE2, STINGERSTATE_DEPLOYED,
STINGERSTATE_STATE3, STINGERSTATE_UNDEPLOYING,
STINGERSTATE_REMOVE, STINGERSTATE_REMOVE,
}; };