1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-11-14 06:49:15 +00:00
re3/src/objects/ParticleObject.cpp

1247 lines
34 KiB
C++
Raw Normal View History

2019-05-15 14:52:37 +00:00
#include "common.h"
2020-04-17 13:31:11 +00:00
2019-05-15 14:52:37 +00:00
#include "ParticleObject.h"
2019-08-15 01:43:00 +00:00
#include "Timer.h"
#include "General.h"
#include "ParticleMgr.h"
#include "Particle.h"
#include "Camera.h"
#include "Game.h"
#include "DMAudio.h"
2020-11-19 18:07:32 +00:00
#include "screendroplets.h"
2019-05-15 14:52:37 +00:00
2019-05-29 00:52:30 +00:00
2020-04-17 05:54:14 +00:00
CParticleObject gPObjectArray[MAX_PARTICLEOBJECTS];
2019-08-15 01:43:00 +00:00
2020-04-17 05:54:14 +00:00
CParticleObject *CParticleObject::pCloseListHead;
CParticleObject *CParticleObject::pFarListHead;
CParticleObject *CParticleObject::pUnusedListHead;
2019-08-15 01:43:00 +00:00
CAudioHydrant List[MAX_AUDIOHYDRANTS];
2020-11-19 18:07:32 +00:00
CAudioHydrant *CAudioHydrant::Get(int n) { return &List[n]; }
2019-08-15 01:43:00 +00:00
bool
CAudioHydrant::Add(CParticleObject *particleobject)
2019-05-29 00:52:30 +00:00
{
2019-08-15 01:43:00 +00:00
for ( int32 i = 0; i < MAX_AUDIOHYDRANTS; i++ )
{
if ( List[i].AudioEntity == AEHANDLE_NONE )
{
List[i].AudioEntity = DMAudio.CreateEntity(AUDIOTYPE_FIREHYDRANT, particleobject);
if ( AEHANDLE_IS_FAILED(List[i].AudioEntity) )
return false;
DMAudio.SetEntityStatus(List[i].AudioEntity, true);
List[i].pParticleObject = particleobject;
return true;
}
}
return false;
2019-05-29 00:52:30 +00:00
}
2019-08-15 01:43:00 +00:00
void
CAudioHydrant::Remove(CParticleObject *particleobject)
2019-05-29 00:52:30 +00:00
{
2019-08-15 01:43:00 +00:00
for ( int32 i = 0; i < MAX_AUDIOHYDRANTS; i++ )
{
if ( List[i].pParticleObject == particleobject )
{
DMAudio.DestroyEntity(List[i].AudioEntity);
List[i].AudioEntity = AEHANDLE_NONE;
2020-07-03 17:26:35 +00:00
List[i].pParticleObject = nil;
2019-08-15 01:43:00 +00:00
}
}
}
CParticleObject::CParticleObject() :
CPlaceable(),
m_nFrameCounter(0),
m_nState(POBJECTSTATE_INITIALISED),
2020-07-03 17:26:35 +00:00
m_pNext(nil),
m_pPrev(nil),
2020-05-11 23:24:57 +00:00
m_nRemoveTimer(0)
2019-08-15 01:43:00 +00:00
{
;
}
CParticleObject::~CParticleObject()
{
}
void
CParticleObject::Initialise()
{
2020-07-03 17:26:35 +00:00
pCloseListHead = nil;
pFarListHead = nil;
2019-08-15 01:43:00 +00:00
pUnusedListHead = &gPObjectArray[0];
for ( int32 i = 0; i < MAX_PARTICLEOBJECTS; i++ )
{
if ( i == 0 )
2020-07-03 17:26:35 +00:00
gPObjectArray[i].m_pPrev = nil;
2019-08-15 01:43:00 +00:00
else
gPObjectArray[i].m_pPrev = &gPObjectArray[i - 1];
if ( i == MAX_PARTICLEOBJECTS-1 )
2020-07-03 17:26:35 +00:00
gPObjectArray[i].m_pNext = nil;
2019-08-15 01:43:00 +00:00
else
gPObjectArray[i].m_pNext = &gPObjectArray[i + 1];
gPObjectArray[i].m_nState = POBJECTSTATE_FREE;
}
}
CParticleObject *
CParticleObject::AddObject(uint16 type, CVector const &pos, uint8 remove)
{
CRGBA color(0, 0, 0, 0);
CVector target(0.0f, 0.0f, 0.0f);
return AddObject(type, pos, target, 0.0f, 0, color, remove);
}
CParticleObject *
CParticleObject::AddObject(uint16 type, CVector const &pos, float size, uint8 remove)
{
CRGBA color(0, 0, 0, 0);
CVector target(0.0f, 0.0f, 0.0f);
return AddObject(type, pos, target, size, 0, color, remove);
}
CParticleObject *
CParticleObject::AddObject(uint16 type, CVector const &pos, CVector const &target, float size, uint8 remove)
{
CRGBA color(0, 0, 0, 0);
return AddObject(type, pos, target, size, 0, color, remove);
}
CParticleObject *
CParticleObject::AddObject(uint16 type, CVector const &pos, CVector const &target, float size, uint32 lifeTime, RwRGBA const &color, uint8 remove)
{
CParticleObject *pobj = pUnusedListHead;
2020-07-03 17:26:35 +00:00
if ( pobj == nil )
2019-08-15 01:43:00 +00:00
{
printf("Error: No particle objects available!\n");
2020-07-03 17:26:35 +00:00
return nil;
2019-08-15 01:43:00 +00:00
}
MoveToList(&pUnusedListHead, &pCloseListHead, pobj);
pobj->m_nState = POBJECTSTATE_UPDATE_CLOSE;
pobj->m_Type = (eParticleObjectType)type;
2020-05-02 12:28:19 +00:00
pobj->SetPosition(pos);
2019-08-15 01:43:00 +00:00
pobj->m_vecTarget = target;
pobj->m_nNumEffectCycles = 1;
pobj->m_nSkipFrames = 1;
pobj->m_nCreationChance = 0;
pobj->m_nFrameCounter = 0;
pobj->m_bRemove = remove;
2020-07-03 17:26:35 +00:00
pobj->m_pParticle = nil;
2019-08-15 01:43:00 +00:00
if ( lifeTime != 0 )
pobj->m_nRemoveTimer = CTimer::GetTimeInMilliseconds() + lifeTime;
else
pobj->m_nRemoveTimer = 0;
if ( color.alpha != 0 )
2020-04-10 21:21:34 +00:00
pobj->m_Color = color;
2019-08-15 01:43:00 +00:00
else
pobj->m_Color.alpha = 0;
pobj->m_fSize = size;
pobj->m_fRandVal = 0.0f;
2020-07-02 23:18:06 +00:00
switch ( type )
2019-08-15 01:43:00 +00:00
{
2020-07-02 23:18:06 +00:00
case POBJECT_PAVEMENT_STEAM:
2019-08-15 01:43:00 +00:00
{
2020-07-02 23:18:06 +00:00
pobj->m_ParticleType = PARTICLE_STEAM_NY;
pobj->m_nNumEffectCycles = 1;
pobj->m_nSkipFrames = 3;
pobj->m_nCreationChance = 8;
break;
}
case POBJECT_PAVEMENT_STEAM_SLOWMOTION:
{
pobj->m_ParticleType = PARTICLE_STEAM_NY_SLOWMOTION;
pobj->m_nNumEffectCycles = 1;
pobj->m_nSkipFrames = 1;
pobj->m_nCreationChance = 8;
break;
}
case POBJECT_WALL_STEAM:
{
pobj->m_ParticleType = PARTICLE_STEAM_NY;
pobj->m_nNumEffectCycles = 1;
pobj->m_nSkipFrames = 3;
pobj->m_nCreationChance = 8;
break;
}
case POBJECT_WALL_STEAM_SLOWMOTION:
{
pobj->m_ParticleType = PARTICLE_STEAM_NY_SLOWMOTION;
pobj->m_nNumEffectCycles = 1;
pobj->m_nSkipFrames = 1;
pobj->m_nCreationChance = 8;
break;
}
case POBJECT_DARK_SMOKE:
{
pobj->m_ParticleType = PARTICLE_STEAM_NY;
pobj->m_nNumEffectCycles = 1;
pobj->m_nSkipFrames = 3;
pobj->m_nCreationChance = 8;
pobj->m_Color = CRGBA(16, 16, 16, 255);
break;
}
case POBJECT_WATER_FOUNTAIN_VERT:
{
pobj->m_ParticleType = PARTICLE_WATER_HYDRANT;
pobj->m_nNumEffectCycles = 1;
pobj->m_nSkipFrames = 1;
pobj->m_nCreationChance = 0;
pobj->m_vecTarget = CVector(0.0f, 0.0f, 0.1f);
break;
}
case POBJECT_WATER_FOUNTAIN_HORIZ:
{
pobj->m_ParticleType = PARTICLE_WATER_HYDRANT;
pobj->m_nNumEffectCycles = 1;
pobj->m_nSkipFrames = 1;
pobj->m_nCreationChance = 0;
break;
}
case POBJECT_FIRE_HYDRANT:
{
pobj->m_ParticleType = PARTICLE_WATER_HYDRANT;
pobj->m_nNumEffectCycles = 1;
pobj->m_nSkipFrames = 1;
pobj->m_nCreationChance = 0;
pobj->m_vecTarget = CVector(0.0f, 0.0f, 0.3f);
pobj->m_nRemoveTimer = CTimer::GetTimeInMilliseconds() + 5000;
CAudioHydrant::Add(pobj);
break;
}
case POBJECT_CAR_WATER_SPLASH:
case POBJECT_PED_WATER_SPLASH:
{
pobj->m_ParticleType = PARTICLE_CAR_SPLASH;
pobj->m_nNumEffectCycles = 0;
pobj->m_nSkipFrames = 1;
pobj->m_nCreationChance = 0;
2020-11-19 18:07:32 +00:00
#ifdef SCREEN_DROPLETS
ScreenDroplets::RegisterSplash(pobj);
#endif
2020-07-02 23:18:06 +00:00
break;
}
case POBJECT_SPLASHES_AROUND:
{
pobj->m_ParticleType = PARTICLE_SPLASH;
pobj->m_nNumEffectCycles = 15;
pobj->m_nSkipFrames = 2;
pobj->m_nCreationChance = 0;
break;
}
case POBJECT_SMALL_FIRE:
{
pobj->m_ParticleType = PARTICLE_FLAME;
pobj->m_nNumEffectCycles = 1;
pobj->m_nSkipFrames = 2;
pobj->m_nCreationChance = 2;
pobj->m_vecTarget = CVector(0.0f, 0.0f, 0.0f);
break;
}
case POBJECT_BIG_FIRE:
{
pobj->m_ParticleType = PARTICLE_FLAME;
pobj->m_nNumEffectCycles = 1;
pobj->m_nSkipFrames = 2;
pobj->m_nCreationChance = 4;
pobj->m_vecTarget = CVector(0.0f, 0.0f, 0.0f);
break;
}
case POBJECT_DRY_ICE:
{
pobj->m_ParticleType = PARTICLE_SMOKE;
pobj->m_nNumEffectCycles = 1;
pobj->m_nSkipFrames = 1;
pobj->m_nCreationChance = 0;
pobj->m_vecTarget = CVector(0.0f, 0.0f, 0.0f);
break;
}
case POBJECT_DRY_ICE_SLOWMOTION:
{
pobj->m_ParticleType = PARTICLE_SMOKE_SLOWMOTION;
pobj->m_nNumEffectCycles = 1;
pobj->m_nSkipFrames = 1;
pobj->m_nCreationChance = 0;
pobj->m_vecTarget = CVector(0.0f, 0.0f, 0.0f);
break;
}
case POBJECT_FIRE_TRAIL:
{
pobj->m_ParticleType = PARTICLE_EXPLOSION_MEDIUM;
pobj->m_nNumEffectCycles = 1;
pobj->m_nSkipFrames = 3;
pobj->m_nCreationChance = 2;
pobj->m_fRandVal = 0.01f;
break;
}
case POBJECT_SMOKE_TRAIL:
{
pobj->m_ParticleType = PARTICLE_FIREBALL_SMOKE;
pobj->m_nNumEffectCycles = 1;
pobj->m_nSkipFrames = 1;
pobj->m_nCreationChance = 2;
pobj->m_fRandVal = 0.02f;
break;
}
case POBJECT_FIREBALL_AND_SMOKE:
{
pobj->m_ParticleType = PARTICLE_FLAME;
pobj->m_nNumEffectCycles = 1;
pobj->m_nSkipFrames = 1;
pobj->m_nCreationChance = 0;
pobj->m_fRandVal = 0.1f;
break;
}
case POBJECT_ROCKET_TRAIL:
{
pobj->m_ParticleType = PARTICLE_FLAME;
pobj->m_nNumEffectCycles = 1;
pobj->m_nSkipFrames = 2;
pobj->m_nCreationChance = 8;
pobj->m_fRandVal = 0.1f;
break;
}
case POBJECT_EXPLOSION_ONCE:
{
pobj->m_ParticleType = PARTICLE_EXPLOSION_LARGE;
pobj->m_nNumEffectCycles = 1;
pobj->m_nSkipFrames = 1;
pobj->m_nCreationChance = 0;
pobj->m_nRemoveTimer = CTimer::GetTimeInMilliseconds();
break;
2019-08-15 01:43:00 +00:00
}
}
return pobj;
}
2020-07-02 23:18:06 +00:00
CParticleObject *
CParticleObject::AddObject(tParticleType type, CVector const &pos, CVector const &target, float size, uint32 lifeTime, uint8 numEffectCycles, uint8 skipFrames, uint16 creationChance, uint8 remove)
{
CParticleObject *pobj = pUnusedListHead;
2020-07-03 17:26:35 +00:00
ASSERT(pobj != nil);
2020-07-02 23:18:06 +00:00
2020-07-03 17:26:35 +00:00
if ( pobj == nil )
2020-07-02 23:18:06 +00:00
{
printf("Error: No particle objects available!\n");
2020-07-03 17:26:35 +00:00
return nil;
2020-07-02 23:18:06 +00:00
}
MoveToList(&pUnusedListHead, &pCloseListHead, pobj);
pobj->m_nState = POBJECTSTATE_UPDATE_CLOSE;
pobj->m_Type = (eParticleObjectType)-1;
pobj->m_ParticleType = type;
pobj->SetPosition(pos);
pobj->m_vecTarget = target;
pobj->m_nNumEffectCycles = numEffectCycles;
pobj->m_nSkipFrames = skipFrames;
pobj->m_nCreationChance = creationChance;
pobj->m_nFrameCounter = 0;
pobj->m_bRemove = remove;
if ( lifeTime != 0 )
pobj->m_nRemoveTimer = CTimer::GetTimeInMilliseconds() + lifeTime;
else
pobj->m_nRemoveTimer = 0;
pobj->m_Color.alpha = 0;
pobj->m_fSize = size;
pobj->m_fRandVal = 0.0f;
return pobj;
}
2019-08-15 01:43:00 +00:00
void
CParticleObject::RemoveObject(void)
{
switch ( this->m_nState )
{
case POBJECTSTATE_UPDATE_CLOSE:
{
MoveToList(&pCloseListHead, &pUnusedListHead, this);
this->m_nState = POBJECTSTATE_FREE;
break;
}
case POBJECTSTATE_UPDATE_FAR:
{
MoveToList(&pFarListHead, &pUnusedListHead, this);
this->m_nState = POBJECTSTATE_FREE;
break;
}
}
}
void
CParticleObject::UpdateAll(void)
{
{
CParticleObject *pobj = pCloseListHead;
CParticleObject *nextpobj;
2020-07-03 17:26:35 +00:00
if ( pobj != nil )
2019-08-15 01:43:00 +00:00
{
do
{
nextpobj = pobj->m_pNext;
pobj->UpdateClose();
pobj = nextpobj;
}
2020-07-03 17:26:35 +00:00
while ( nextpobj != nil );
2019-08-15 01:43:00 +00:00
}
}
{
int32 frame = CTimer::GetFrameCounter() & 31;
int32 counter = 0;
CParticleObject *pobj = pFarListHead;
CParticleObject *nextpobj;
2020-07-03 17:26:35 +00:00
if ( pobj != nil )
2019-08-15 01:43:00 +00:00
{
do
{
nextpobj = pobj->m_pNext;
if ( counter == frame )
2019-08-15 01:43:00 +00:00
{
pobj->UpdateFar();
frame += 32;
2019-08-15 01:43:00 +00:00
}
counter++;
pobj = nextpobj;
}
2020-07-03 17:26:35 +00:00
while ( nextpobj != nil );
2019-08-15 01:43:00 +00:00
}
}
}
void CParticleObject::UpdateClose(void)
{
if ( !CGame::playingIntro )
{
if ( (this->GetPosition() - TheCamera.GetPosition()).MagnitudeSqr2D() > SQR(100.0f) )
{
if ( this->m_bRemove )
{
if ( this->m_Type == POBJECT_FIRE_HYDRANT )
CAudioHydrant::Remove(this);
MoveToList(&pCloseListHead, &pUnusedListHead, this);
this->m_nState = POBJECTSTATE_FREE;
}
else
{
MoveToList(&pCloseListHead, &pFarListHead, this);
this->m_nState = POBJECTSTATE_UPDATE_FAR;
}
return;
}
}
if ( ++this->m_nFrameCounter >= this->m_nSkipFrames )
{
this->m_nFrameCounter = 0;
int32 randVal;
2019-08-15 01:43:00 +00:00
if ( this->m_nCreationChance != 0 )
randVal = CGeneral::GetRandomNumber() % this->m_nCreationChance;
if ( this->m_nCreationChance == 0
|| randVal == 0 && this->m_nCreationChance < 0
|| randVal != 0 && this->m_nCreationChance > 0)
2019-08-15 01:43:00 +00:00
{
switch ( this->m_Type )
{
case POBJECT_SMALL_FIRE:
{
CVector pos = this->GetPosition();
CVector vel = this->m_vecTarget;
float size = this->m_fSize;
CVector flamevel;
flamevel.x = vel.x;
flamevel.y = vel.y;
flamevel.z = CGeneral::GetRandomNumberInRange(0.0125f*size, 0.1f*size);
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_FLAME, pos, flamevel, nil, size);
2019-08-15 01:43:00 +00:00
CVector possmoke = pos;
possmoke.x += CGeneral::GetRandomNumberInRange(0.625f*-size, size*0.625f);
possmoke.y += CGeneral::GetRandomNumberInRange(0.625f*-size, size*0.625f);
possmoke.z += CGeneral::GetRandomNumberInRange(0.625f* size, size*2.5f);
CParticle::AddParticle(PARTICLE_CARFLAME_SMOKE, possmoke, vel);
break;
}
case POBJECT_BIG_FIRE:
{
CVector pos = this->GetPosition();
CVector vel = this->m_vecTarget;
float size = this->m_fSize;
float s = 0.7f*size;
CVector flamevel;
flamevel.x = vel.x;
flamevel.y = vel.y;
flamevel.z = CGeneral::GetRandomNumberInRange(0.0125f*s, 0.1f*s);
float flamesize = 0.8f*size;
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_FLAME, pos, flamevel, nil, flamesize);
2019-08-15 01:43:00 +00:00
for ( int32 i = 0; i < 4; i++ )
{
CVector smokepos = pos;
smokepos.x += CGeneral::GetRandomNumberInRange(0.625f*-size, 0.625f*size);
smokepos.y += CGeneral::GetRandomNumberInRange(0.625f*-size, 0.625f*size);
smokepos.z += CGeneral::GetRandomNumberInRange(0.625f* size, 3.5f *size);
CParticle::AddParticle(PARTICLE_CARFLAME_SMOKE, smokepos, vel);
}
break;
}
case POBJECT_FIREBALL_AND_SMOKE:
{
2020-07-03 17:26:35 +00:00
if ( this->m_pParticle == nil )
2019-08-15 01:43:00 +00:00
{
CVector pos = this->GetPosition();
CVector vel = this->m_vecTarget;
float size = this->m_fSize;
CVector expvel = 1.2f*vel;
float expsize = 1.2f*size;
2020-07-03 17:26:35 +00:00
this->m_pParticle = CParticle::AddParticle(PARTICLE_EXPLOSION_MEDIUM, pos, expvel, nil, expsize);
2019-08-15 01:43:00 +00:00
}
else
{
CVector pos = this->GetPosition(); // this->m_pParticle->m_vecPosition ?
CVector vel = this->m_vecTarget;
float size = this->m_fSize;
CVector veloffset = 0.35f*vel;
CVector fireballvel = vel;
for ( int32 i = 0; i < this->m_nNumEffectCycles; i++ )
{
fireballvel.x += CGeneral::GetRandomNumberInRange(-veloffset.x, veloffset.x);
fireballvel.y += CGeneral::GetRandomNumberInRange(-veloffset.y, veloffset.y);
fireballvel.z += CGeneral::GetRandomNumberInRange(-veloffset.z, veloffset.z);
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_FIREBALL_SMOKE, pos, fireballvel, nil, size);
2019-08-15 01:43:00 +00:00
}
}
break;
}
case POBJECT_ROCKET_TRAIL:
{
2020-07-03 17:26:35 +00:00
if ( this->m_pParticle == nil )
2019-08-15 01:43:00 +00:00
{
CVector pos = this->GetPosition();
CVector vel = this->m_vecTarget;
float size = this->m_fSize;
2020-07-03 17:26:35 +00:00
this->m_pParticle = CParticle::AddParticle(PARTICLE_EXPLOSION_MEDIUM, pos, vel, nil, size);
2019-08-15 01:43:00 +00:00
}
else
{
CVector pos = this->m_pParticle->m_vecPosition;
CVector vel = this->m_vecTarget;
float size = this->m_fSize;
float fireballsize = size * 1.5f;
CVector fireballvel = vel * -0.8f;
for ( int32 i = 0; i < this->m_nNumEffectCycles; i++ )
{
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_FIREBALL_SMOKE, pos, fireballvel, nil, fireballsize);
2019-08-15 01:43:00 +00:00
}
}
break;
}
case POBJECT_FIRE_TRAIL:
{
for ( int32 i = 0; i < this->m_nNumEffectCycles; i++ )
{
CVector vel = this->m_vecTarget;
if ( vel.x != 0.0f )
vel.x += CGeneral::GetRandomNumberInRange(-this->m_fRandVal, this->m_fRandVal);
if ( vel.y != 0.0f )
vel.y += CGeneral::GetRandomNumberInRange(-this->m_fRandVal, this->m_fRandVal);
if ( vel.z != 0.0f )
vel.z += CGeneral::GetRandomNumberInRange(-this->m_fRandVal, this->m_fRandVal);
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(this->m_ParticleType, this->GetPosition(), vel, nil, this->m_fSize,
2019-08-15 01:43:00 +00:00
CGeneral::GetRandomNumberInRange(-6.0f, 6.0f));
}
break;
}
case POBJECT_PED_WATER_SPLASH:
{
CRGBA colorsmoke(255, 255, 255, 196);
CVector pos = this->GetPosition();
CVector vel = this->m_vecTarget;
for ( int32 i = 0; i < 3; i++ )
{
int32 angle = 90 * i;
float fCos = CParticle::Cos(angle);
float fSin = CParticle::Sin(angle);
CVector splashpos;
CVector splashvel;
splashpos = pos + CVector(0.75f*fCos, 0.75f*fSin, 0.0f);
splashvel = vel + CVector(0.05f*fCos, 0.05f*fSin, CGeneral::GetRandomNumberInRange(0.04f, 0.08f));
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_RUBBER_SMOKE, splashpos, splashvel, nil,
2019-08-15 01:43:00 +00:00
CGeneral::GetRandomNumberInRange(0.1f, 0.8f), colorsmoke);
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil,
2019-08-15 01:43:00 +00:00
CGeneral::GetRandomNumberInRange(0.1f, 0.5f), this->m_Color);
splashpos = pos + CVector(0.75f*fCos, 0.75f*-fSin, 0.0f);
splashvel = vel + CVector(0.05f*fCos, 0.05f*-fSin, CGeneral::GetRandomNumberInRange(0.04f, 0.08f));
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_RUBBER_SMOKE, splashpos, splashvel, nil,
2019-08-15 01:43:00 +00:00
CGeneral::GetRandomNumberInRange(0.1f, 0.8f), colorsmoke);
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil,
2019-08-15 01:43:00 +00:00
CGeneral::GetRandomNumberInRange(0.1f, 0.5f), this->m_Color);
splashpos = pos + CVector(0.75f*-fCos, 0.75f*fSin, 0.0f);
splashvel = vel + CVector(0.05f*-fCos, 0.05f*fSin, CGeneral::GetRandomNumberInRange(0.04f, 0.08f));
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_RUBBER_SMOKE, splashpos, splashvel, nil,
2019-08-15 01:43:00 +00:00
CGeneral::GetRandomNumberInRange(0.1f, 0.8f), colorsmoke);
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil,
2019-08-15 01:43:00 +00:00
CGeneral::GetRandomNumberInRange(0.1f, 0.5f), this->m_Color);
splashpos = pos + CVector(0.75f*-fCos, 0.75f*-fSin, 0.0f);
splashvel = vel + CVector(0.05f*-fCos, 0.05f*-fSin, CGeneral::GetRandomNumberInRange(0.04f, 0.08f));
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_RUBBER_SMOKE, splashpos, splashvel, nil,
2019-08-15 01:43:00 +00:00
CGeneral::GetRandomNumberInRange(0.1f, 0.8f), colorsmoke);
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil,
2019-08-15 01:43:00 +00:00
CGeneral::GetRandomNumberInRange(0.1f, 0.5f), this->m_Color);
}
for ( int32 i = 0; i < 1; i++ )
{
int32 angle = 180 * (i + 1);
float fCos = CParticle::Cos(angle);
float fSin = CParticle::Sin(angle);
CVector splashpos;
CVector splashvel;
splashpos = pos + CVector(0.5f*fCos, 0.5f*fSin, 0.0f);
splashvel = vel;
splashvel.x += CGeneral::GetRandomNumberInRange(-0.25f, 0.25f) * fCos;
splashvel.y += CGeneral::GetRandomNumberInRange(-0.25f, 0.25f) * fSin;
splashvel.z += CGeneral::GetRandomNumberInRange(0.05f, 0.25f);
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil,
2019-08-15 01:43:00 +00:00
CGeneral::GetRandomNumberInRange(0.4f, 1.0f), this->m_Color);
splashpos = pos + CVector(0.5f*fCos, 0.5f*-fSin, 0.0f);
splashvel = vel;
splashvel.x += CGeneral::GetRandomNumberInRange(-0.25f, 0.25f) * fCos;
splashvel.y += CGeneral::GetRandomNumberInRange(-0.25f, 0.25f) * -fSin;
splashvel.z += CGeneral::GetRandomNumberInRange(0.05f, 0.25f);
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil,
2019-08-15 01:43:00 +00:00
CGeneral::GetRandomNumberInRange(0.4f, 1.0f), this->m_Color);
splashpos = pos + CVector(0.5f*-fCos, 0.5f*fSin, 0.0f);
splashvel = vel;
splashvel.x += CGeneral::GetRandomNumberInRange(-0.25f, 0.25f) * -fCos;
splashvel.y += CGeneral::GetRandomNumberInRange(-0.25f, 0.25f) * fSin;
splashvel.z += CGeneral::GetRandomNumberInRange(0.05f, 0.25f);
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil,
2019-08-15 01:43:00 +00:00
CGeneral::GetRandomNumberInRange(0.4f, 1.0f), this->m_Color);
splashpos = pos + CVector(0.5f*-fCos, 0.5f*-fSin, 0.0f);
splashvel = vel;
splashvel.x += CGeneral::GetRandomNumberInRange(-0.25f, 0.25f) * -fCos;
splashvel.y += CGeneral::GetRandomNumberInRange(-0.25f, 0.25f) * -fSin;
splashvel.z += CGeneral::GetRandomNumberInRange(0.05f, 0.25f);
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil,
2019-08-15 01:43:00 +00:00
CGeneral::GetRandomNumberInRange(0.4f, 1.0f), this->m_Color);
}
2020-04-23 08:24:03 +00:00
2019-08-15 01:43:00 +00:00
break;
}
case POBJECT_CAR_WATER_SPLASH:
{
CRGBA colorsmoke(255, 255, 255, 196);
CVector pos = this->GetPosition();
CVector vel = this->m_vecTarget;
float size = CGeneral::GetRandomNumberInRange(1.0f, 2.5f);
for ( int32 i = 0; i < 3; i++ )
{
int32 angle = 90 * i;
float fCos = CParticle::Cos(angle);
float fSin = CParticle::Sin(angle);
CVector splashpos;
CVector splashvel;
splashpos = pos + CVector(2.0f*fCos, 2.0f*fSin, 0.0f);
splashvel = vel;
splashvel.x += CGeneral::GetRandomNumberInRange(-0.5f, 0.5f) * fCos;
splashvel.y += CGeneral::GetRandomNumberInRange(-0.5f, 0.5f) * fSin;
splashvel.z += CGeneral::GetRandomNumberInRange(0.01f, 0.03f);
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_RUBBER_SMOKE, splashpos, splashvel, nil, size, colorsmoke);
CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil, 0.0f, this->m_Color);
2019-08-15 01:43:00 +00:00
splashpos = pos + CVector(2.0f*fCos, 2.0f*-fSin, 0.0f);
splashvel = vel;
splashvel.x += CGeneral::GetRandomNumberInRange(-0.5f, 0.5f) * fCos;
splashvel.y += CGeneral::GetRandomNumberInRange(-0.5f, 0.5f) * -fSin;
splashvel.z += CGeneral::GetRandomNumberInRange(0.01f, 0.03f);
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_RUBBER_SMOKE, splashpos, splashvel, nil, size, colorsmoke);
CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil, 0.0f, this->m_Color);
2019-08-15 01:43:00 +00:00
splashpos = pos + CVector(2.0f*-fCos, 2.0f*fSin, 0.0f);
splashvel = vel;
splashvel.x += CGeneral::GetRandomNumberInRange(-0.5f, 0.5f) * -fCos;
splashvel.y += CGeneral::GetRandomNumberInRange(-0.5f, 0.5f) * fSin;
splashvel.z += CGeneral::GetRandomNumberInRange(0.01f, 0.03f);
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_RUBBER_SMOKE, splashpos, splashvel, nil, size, colorsmoke);
CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil, 0.0f, this->m_Color);
2019-08-15 01:43:00 +00:00
splashpos = pos + CVector(2.0f*-fCos, 2.0f*-fSin, 0.0f);
splashvel = vel;
splashvel.x += CGeneral::GetRandomNumberInRange(-0.5f, 0.5f) * -fCos;
splashvel.y += CGeneral::GetRandomNumberInRange(-0.5f, 0.5f) * -fSin;
splashvel.z += CGeneral::GetRandomNumberInRange(0.01f, 0.03f);
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_RUBBER_SMOKE, splashpos, splashvel, nil, size, colorsmoke);
CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil, 0.0f, this->m_Color);
2019-08-15 01:43:00 +00:00
}
for ( int32 i = 0; i < 1; i++ )
{
int32 angle = 180 * (i + 1);
float fCos = CParticle::Cos(angle);
float fSin = CParticle::Sin(angle);
CVector splashpos;
CVector splashvel;
splashpos = pos + CVector(1.25f*fCos, 1.25f*fSin, 0.0f);
splashvel = vel;
splashvel.x += CGeneral::GetRandomNumberInRange(-0.1f, 0.1f) * fCos;
splashvel.y += CGeneral::GetRandomNumberInRange(-0.1f, 0.1f) * fSin;
splashvel.z += CGeneral::GetRandomNumberInRange(0.26f, 0.53f);
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil, 0.0f, this->m_Color);
2019-08-15 01:43:00 +00:00
splashpos = pos + CVector(1.25f*fCos, 1.25f*-fSin, 0.0f);
splashvel = vel;
splashvel.x += CGeneral::GetRandomNumberInRange(-0.1f, 0.1f) * fCos;
splashvel.y += CGeneral::GetRandomNumberInRange(-0.1f, 0.1f) * -fSin;
splashvel.z += CGeneral::GetRandomNumberInRange(0.26f, 0.53f);
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil, 0.0f, this->m_Color);
2019-08-15 01:43:00 +00:00
splashpos = pos + CVector(1.25f*-fCos, 1.25f*fSin, 0.0f);
splashvel = vel;
splashvel.x += CGeneral::GetRandomNumberInRange(-0.1f, 0.1f) * -fCos;
splashvel.y += CGeneral::GetRandomNumberInRange(-0.1f, 0.1f) * fSin;
splashvel.z += CGeneral::GetRandomNumberInRange(0.26f, 0.53f);
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil, 0.0f, this->m_Color);
2019-08-15 01:43:00 +00:00
splashpos = pos + CVector(1.25f*-fCos, 1.25f*-fSin, 0.0f);
splashvel = vel;
splashvel.x += CGeneral::GetRandomNumberInRange(-0.1f, 0.1f) * -fCos;
splashvel.y += CGeneral::GetRandomNumberInRange(-0.1f, 0.1f) * -fSin;
splashvel.z += CGeneral::GetRandomNumberInRange(0.26f, 0.53f);
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil, 0.0f, this->m_Color);
2019-08-15 01:43:00 +00:00
}
2020-07-02 23:18:06 +00:00
2019-08-15 01:43:00 +00:00
break;
}
case POBJECT_SPLASHES_AROUND:
{
CVector pos = this->GetPosition();
float size = this->m_fSize;
for ( int32 i = 0; i < this->m_nNumEffectCycles; i++ )
{
CVector splashpos = pos;
splashpos.x += CGeneral::GetRandomNumberInRange(-size, size);
splashpos.y += CGeneral::GetRandomNumberInRange(-size, size);
if ( CGeneral::GetRandomNumber() & 1 )
{
CParticle::AddParticle(PARTICLE_RAIN_SPLASH, splashpos, CVector(0.0f, 0.0f, 0.0f),
2020-07-03 17:26:35 +00:00
nil, 0.1f, this->m_Color);
2019-08-15 01:43:00 +00:00
}
else
{
CParticle::AddParticle(PARTICLE_RAIN_SPLASHUP, splashpos, CVector(0.0f, 0.0f, 0.0f),
2020-07-03 17:26:35 +00:00
nil, 0.12f, this->m_Color);
2019-08-15 01:43:00 +00:00
}
}
break;
}
2020-07-02 23:18:06 +00:00
case POBJECT_FIRE_HYDRANT:
2019-08-15 01:43:00 +00:00
{
CVector pos = this->GetPosition();
2020-07-02 23:18:06 +00:00
CVector vel = this->m_vecTarget;
2019-08-15 01:43:00 +00:00
2020-07-02 23:18:06 +00:00
if ( (TheCamera.GetPosition() - pos).Magnitude() > 5.0f )
{
for ( int32 i = 0; i < 1; i++ )
{
int32 angle = 180 * i;
float fCos = CParticle::Cos(angle);
float fSin = CParticle::Sin(angle);
CVector splashpos, splashvel;
splashpos = pos + CVector(0.01f*fCos, 0.01f*fSin, 0.0f);
splashvel = vel + CVector(0.0f, 0.0f, CGeneral::GetRandomNumberInRange(0.004f, 0.008f));
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil,
2020-07-02 23:18:06 +00:00
CGeneral::GetRandomNumberInRange(0.005f, 0.0075f), this->m_Color, 0, 0, 1, 300);
splashpos = pos + CVector(0.01f*fCos, 0.01f*-fSin, 0.0f);
splashvel = vel + CVector(0.0f, 0.0f, CGeneral::GetRandomNumberInRange(0.004f, 0.008f));
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil,
2020-07-02 23:18:06 +00:00
CGeneral::GetRandomNumberInRange(0.005f, 0.0075f), this->m_Color, 0, 0, 1, 300);
splashpos = pos + CVector(0.01f*-fCos, 0.01f*fSin, 0.0f);
splashvel = vel + CVector(0.0f, 0.0f, CGeneral::GetRandomNumberInRange(0.004f, 0.008f));
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil,
2020-07-02 23:18:06 +00:00
CGeneral::GetRandomNumberInRange(0.005f, 0.0075f), this->m_Color, 0, 0, 1, 300);
splashpos = pos + CVector(0.01f*-fCos, 0.01f*-fSin, 0.0f);
splashvel = vel + CVector(0.0f, 0.0f, CGeneral::GetRandomNumberInRange(0.004f, 0.008f));
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil,
2020-07-02 23:18:06 +00:00
CGeneral::GetRandomNumberInRange(0.005f, 0.0075f), this->m_Color, 0, 0, 1, 300);
}
for ( int32 i = 0; i < this->m_nNumEffectCycles; i++ )
{
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(this->m_ParticleType, pos, vel, nil, 0.0f, this->m_Color);
2020-07-02 23:18:06 +00:00
}
}
2019-08-15 01:43:00 +00:00
break;
}
2020-07-02 23:18:06 +00:00
case POBJECT_WATER_FOUNTAIN_VERT:
2019-08-15 01:43:00 +00:00
{
2020-07-02 23:18:06 +00:00
CVector pos = this->GetPosition();
2019-08-15 01:43:00 +00:00
CVector vel = this->m_vecTarget;
2020-07-02 23:18:06 +00:00
for ( int32 i = 0; i < 2; i++ )
{
int32 angle = 180 * i;
float fCos = CParticle::Cos(angle);
float fSin = CParticle::Sin(angle);
CVector splashpos, splashvel;
splashpos = pos + CVector(0.015f*fCos, 0.015f*fSin, 0.0f);
splashvel = vel + CVector(0.015f*fCos, 0.015f*fSin, CGeneral::GetRandomNumberInRange(0.004f, 0.008f));
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_SPLASH, splashpos, splashvel, nil,
2020-07-02 23:18:06 +00:00
CGeneral::GetRandomNumberInRange(0.001f, 0.005f), this->m_Color, 0, 0, 1, 1000);
splashpos = pos + CVector(0.015f*fCos, 0.015f*-fSin, 0.0f);
splashvel = vel + CVector(0.015f*fCos, 0.015f*-fSin, CGeneral::GetRandomNumberInRange(0.004f, 0.008f));
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_SPLASH, splashpos, splashvel, nil,
2020-07-02 23:18:06 +00:00
CGeneral::GetRandomNumberInRange(0.001f, 0.005f), this->m_Color, 0, 0, 1, 1000);
splashpos = pos + CVector(0.015f*-fCos, 0.015f*fSin, 0.0f);
splashvel = vel + CVector(0.015f*-fCos, 0.015f*fSin, CGeneral::GetRandomNumberInRange(0.004f, 0.008f));
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_SPLASH, splashpos, splashvel, nil,
2020-07-02 23:18:06 +00:00
CGeneral::GetRandomNumberInRange(0.001f, 0.005f), this->m_Color, 0, 0, 1, 1000);
splashpos = pos + CVector(0.015f*-fCos, 0.015f*-fSin, 0.0f);
splashvel = vel + CVector(0.015f*-fCos, 0.015f*-fSin, CGeneral::GetRandomNumberInRange(0.004f, 0.008f));
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_SPLASH, splashpos, splashvel, nil,
2020-07-02 23:18:06 +00:00
CGeneral::GetRandomNumberInRange(0.001f, 0.005f), this->m_Color, 0, 0, 1, 1000);
}
2019-08-15 01:43:00 +00:00
2020-07-02 23:18:06 +00:00
break;
}
case POBJECT_WATER_FOUNTAIN_HORIZ:
{
2019-08-15 01:43:00 +00:00
CVector pos = this->GetPosition();
2020-07-02 23:18:06 +00:00
CVector vel = this->m_vecTarget;
2019-08-15 01:43:00 +00:00
2020-07-02 23:18:06 +00:00
for ( int32 i = 0; i < 3; i++ )
{
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(PARTICLE_CAR_SPLASH, pos, vel, nil, 0.001f, this->m_Color, 0, 0, 1, 1000);
2020-07-02 23:18:06 +00:00
}
2019-08-15 01:43:00 +00:00
break;
}
default:
{
if ( this->m_fRandVal != 0.0f )
{
for ( int32 i = 0; i < this->m_nNumEffectCycles; i++ )
{
CVector vel = this->m_vecTarget;
if ( vel.x != 0.0f )
vel.x += CGeneral::GetRandomNumberInRange(-this->m_fRandVal, this->m_fRandVal);
if ( vel.y != 0.0f )
vel.y += CGeneral::GetRandomNumberInRange(-this->m_fRandVal, this->m_fRandVal);
if ( vel.z != 0.0f )
vel.z += CGeneral::GetRandomNumberInRange(-this->m_fRandVal, this->m_fRandVal);
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(this->m_ParticleType, this->GetPosition(), vel, nil,
2019-08-15 01:43:00 +00:00
this->m_fSize, this->m_Color);
}
}
else
{
for ( int32 i = 0; i < this->m_nNumEffectCycles; i++ )
{
2020-07-03 17:26:35 +00:00
CParticle::AddParticle(this->m_ParticleType, this->GetPosition(), this->m_vecTarget, nil,
2019-08-15 01:43:00 +00:00
this->m_fSize, this->m_Color);
}
}
break;
}
}
}
}
if ( this->m_nRemoveTimer != 0 && this->m_nRemoveTimer < CTimer::GetTimeInMilliseconds() )
{
MoveToList(&pCloseListHead, &pUnusedListHead, this);
this->m_nState = POBJECTSTATE_FREE;
if ( this->m_Type == POBJECT_FIRE_HYDRANT )
CAudioHydrant::Remove(this);
}
}
void
CParticleObject::UpdateFar(void)
{
if ( this->m_nRemoveTimer != 0 && this->m_nRemoveTimer < CTimer::GetTimeInMilliseconds() )
{
MoveToList(&pFarListHead, &pUnusedListHead, this);
this->m_nState = POBJECTSTATE_FREE;
if ( this->m_Type == POBJECT_FIRE_HYDRANT )
CAudioHydrant::Remove(this);
}
CVector2D dist = this->GetPosition() - TheCamera.GetPosition();
if ( dist.MagnitudeSqr() < SQR(100.0f)/*10000.0f*/ )
{
MoveToList(&pFarListHead, &pCloseListHead, this);
this->m_nState = POBJECTSTATE_UPDATE_CLOSE;
}
}
bool
CParticleObject::SaveParticle(uint8 *buffer, uint32 *length)
{
2020-07-03 17:26:35 +00:00
ASSERT( buffer != nil );
ASSERT( length != nil );
2019-08-15 01:43:00 +00:00
int32 numObjects = 0;
2020-07-03 17:26:35 +00:00
for ( CParticleObject *p = pCloseListHead; p != nil; p = p->m_pNext )
2019-08-15 01:43:00 +00:00
++numObjects;
2020-07-03 17:26:35 +00:00
for ( CParticleObject *p = pFarListHead; p != nil; p = p->m_pNext )
2019-08-15 01:43:00 +00:00
++numObjects;
*(int32 *)buffer = numObjects;
buffer += sizeof(int32);
int32 objectsLength = sizeof(CParticleObject) * (numObjects + 1);
int32 dataLength = objectsLength + sizeof(int32);
2020-07-03 17:26:35 +00:00
for ( CParticleObject *p = pCloseListHead; p != nil; p = p->m_pNext )
2019-08-15 01:43:00 +00:00
{
2020-05-13 00:01:42 +00:00
#if 0 // todo better
2020-05-11 23:24:57 +00:00
*(CParticleObject*)buffer = *p;
#else
2019-08-15 01:43:00 +00:00
memcpy(buffer, p, sizeof(CParticleObject));
2020-05-11 23:24:57 +00:00
#endif
2019-08-15 01:43:00 +00:00
buffer += sizeof(CParticleObject);
}
2020-07-03 17:26:35 +00:00
for ( CParticleObject *p = pFarListHead; p != nil; p = p->m_pNext )
2019-08-15 01:43:00 +00:00
{
2020-05-13 00:01:42 +00:00
#if 0 // todo better
2020-05-11 23:24:57 +00:00
*(CParticleObject*)buffer = *p;
#else
2019-08-15 01:43:00 +00:00
memcpy(buffer, p, sizeof(CParticleObject));
2020-05-11 23:24:57 +00:00
#endif
2019-08-15 01:43:00 +00:00
buffer += sizeof(CParticleObject);
}
*length = dataLength;
return true;
}
bool
CParticleObject::LoadParticle(uint8 *buffer, uint32 length)
{
2020-07-03 17:26:35 +00:00
ASSERT( buffer != nil );
2019-08-15 01:43:00 +00:00
RemoveAllParticleObjects();
int32 numObjects = *(int32 *)buffer;
buffer += sizeof(int32);
if ( length != sizeof(CParticleObject) * (numObjects + 1) + sizeof(int32) )
return false;
if ( numObjects == 0 )
return true;
int32 i = 0;
while ( i < numObjects )
{
CParticleObject *dst = pUnusedListHead;
CParticleObject *src = (CParticleObject *)buffer;
buffer += sizeof(CParticleObject);
2020-07-03 17:26:35 +00:00
if ( dst == nil )
2019-08-15 01:43:00 +00:00
return false;
MoveToList(&pUnusedListHead, &pCloseListHead, dst);
dst->m_nState = POBJECTSTATE_UPDATE_CLOSE;
dst->m_Type = src->m_Type;
dst->m_ParticleType = src->m_ParticleType;
2020-05-02 12:28:19 +00:00
dst->SetPosition(src->GetPosition());
2019-08-15 01:43:00 +00:00
dst->m_vecTarget = src->m_vecTarget;
dst->m_nFrameCounter = src->m_nFrameCounter;
dst->m_bRemove = src->m_bRemove;
2020-07-03 17:26:35 +00:00
dst->m_pParticle = nil;
2019-08-15 01:43:00 +00:00
dst->m_nRemoveTimer = src->m_nRemoveTimer;
dst->m_Color = src->m_Color;
dst->m_fSize = src->m_fSize;
dst->m_fRandVal = src->m_fRandVal;
dst->m_nNumEffectCycles = src->m_nNumEffectCycles;
dst->m_nSkipFrames = src->m_nSkipFrames;
dst->m_nCreationChance = src->m_nCreationChance;
i++;
}
return true;
}
2020-07-02 23:18:06 +00:00
void
CParticleObject::RemoveAllExpireableParticleObjects(void)
{
{
CParticleObject *pobj = pCloseListHead;
CParticleObject *nextpobj;
2020-07-03 17:26:35 +00:00
if ( pobj != nil )
2020-07-02 23:18:06 +00:00
{
do
{
nextpobj = pobj->m_pNext;
if ( pobj->m_nRemoveTimer != 0 )
{
MoveToList(&pCloseListHead, &pUnusedListHead, pobj);
pobj->m_nState = POBJECTSTATE_FREE;
}
pobj = nextpobj;
}
2020-07-03 17:26:35 +00:00
while ( nextpobj != nil );
2020-07-02 23:18:06 +00:00
}
}
{
CParticleObject *pobj = pFarListHead;
CParticleObject *nextpobj;
2020-07-03 17:26:35 +00:00
if ( pobj != nil )
2020-07-02 23:18:06 +00:00
{
do
{
nextpobj = pobj->m_pNext;
if ( pobj->m_nRemoveTimer != 0 )
{
MoveToList(&pFarListHead, &pUnusedListHead, pobj);
pobj->m_nState = POBJECTSTATE_FREE;
}
pobj = nextpobj;
}
2020-07-03 17:26:35 +00:00
while ( nextpobj != nil );
2020-07-02 23:18:06 +00:00
}
}
}
2019-08-15 01:43:00 +00:00
void
CParticleObject::RemoveAllParticleObjects(void)
{
pUnusedListHead = &gPObjectArray[0];
2020-07-03 17:26:35 +00:00
pCloseListHead = nil;
pFarListHead = nil;
2019-08-15 01:43:00 +00:00
for ( int32 i = 0; i < MAX_PARTICLEOBJECTS; i++ )
{
if ( i == 0 )
2020-07-03 17:26:35 +00:00
gPObjectArray[i].m_pPrev = nil;
2019-08-15 01:43:00 +00:00
else
gPObjectArray[i].m_pPrev = &gPObjectArray[i - 1];
if ( i == MAX_PARTICLEOBJECTS-1 )
2020-07-03 17:26:35 +00:00
gPObjectArray[i].m_pNext = nil;
2019-08-15 01:43:00 +00:00
else
gPObjectArray[i].m_pNext = &gPObjectArray[i + 1];
gPObjectArray[i].m_nState = POBJECTSTATE_FREE;
}
}
void
CParticleObject::MoveToList(CParticleObject **from, CParticleObject **to, CParticleObject *obj)
{
2020-07-03 17:26:35 +00:00
ASSERT( from != nil );
ASSERT( to != nil );
ASSERT( obj != nil );
2019-08-15 01:43:00 +00:00
2020-07-03 17:26:35 +00:00
if ( obj->m_pPrev == nil )
2019-08-15 01:43:00 +00:00
{
*from = obj->m_pNext;
if ( *from )
2020-07-03 17:26:35 +00:00
(*from)->m_pPrev = nil;
2019-08-15 01:43:00 +00:00
}
else
{
2020-07-03 17:26:35 +00:00
if ( obj->m_pNext == nil )
obj->m_pPrev->m_pNext = nil;
2019-08-15 01:43:00 +00:00
else
{
obj->m_pNext->m_pPrev = obj->m_pPrev;
obj->m_pPrev->m_pNext = obj->m_pNext;
}
}
obj->m_pNext = *to;
2020-07-03 17:26:35 +00:00
obj->m_pPrev = nil;
2019-08-15 01:43:00 +00:00
*to = obj;
if ( obj->m_pNext )
obj->m_pNext->m_pPrev = obj;
}