mirror of https://github.com/OpenRCT2/OpenRCT2.git
Move particle structs to particle files
This commit is contained in:
parent
3199029168
commit
63bcb3c3e5
|
@ -38,6 +38,7 @@
|
|||
#include "../world/Map.h"
|
||||
#include "../world/MoneyEffect.h"
|
||||
#include "../world/Park.h"
|
||||
#include "../world/Particle.h"
|
||||
#include "../world/Scenery.h"
|
||||
#include "../world/Sprite.h"
|
||||
#include "../world/Surface.h"
|
||||
|
@ -894,8 +895,8 @@ void Guest::Tick128UpdateGuest(int32_t index)
|
|||
{
|
||||
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::Crash, { x, y, z });
|
||||
|
||||
sprite_misc_explosion_cloud_create({ x, y, z + 16 });
|
||||
sprite_misc_explosion_flare_create({ x, y, z + 16 });
|
||||
ExplosionCloud::Create({ x, y, z + 16 });
|
||||
ExplosionFlare::Create({ x, y, z + 16 });
|
||||
|
||||
Remove();
|
||||
return;
|
||||
|
|
|
@ -3600,7 +3600,7 @@ void Vehicle::UpdateCollisionSetup()
|
|||
|
||||
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::Crash, { train->x, train->y, train->z });
|
||||
|
||||
sprite_misc_explosion_cloud_create({ train->x, train->y, train->z });
|
||||
ExplosionCloud::Create({ train->x, train->y, train->z });
|
||||
|
||||
for (int32_t i = 0; i < 10; i++)
|
||||
{
|
||||
|
@ -5358,8 +5358,8 @@ void Vehicle::CrashOnLand()
|
|||
sub_state = 2;
|
||||
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::Crash, { x, y, z });
|
||||
|
||||
sprite_misc_explosion_cloud_create({ x, y, z });
|
||||
sprite_misc_explosion_flare_create({ x, y, z });
|
||||
ExplosionCloud::Create({ x, y, z });
|
||||
ExplosionFlare::Create({ x, y, z });
|
||||
|
||||
uint8_t numParticles = std::min(sprite_width, static_cast<uint8_t>(7));
|
||||
|
||||
|
@ -5459,7 +5459,7 @@ void Vehicle::UpdateCrash()
|
|||
{
|
||||
int32_t xOffset = (scenario_rand() & 2) - 1;
|
||||
int32_t yOffset = (scenario_rand() & 2) - 1;
|
||||
sprite_misc_explosion_cloud_create({ curVehicle->x + xOffset, curVehicle->y + yOffset, curVehicle->z });
|
||||
ExplosionCloud::Create({ curVehicle->x + xOffset, curVehicle->y + yOffset, curVehicle->z });
|
||||
}
|
||||
}
|
||||
if (curVehicle->var_C8 + 7281 > 0xFFFF)
|
||||
|
@ -7225,28 +7225,6 @@ void Vehicle::UpdateSpinningCar()
|
|||
Invalidate();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006734B2
|
||||
*/
|
||||
static void steam_particle_create(const CoordsXYZ& coords)
|
||||
{
|
||||
auto surfaceElement = map_get_surface_element_at(coords);
|
||||
if (surfaceElement != nullptr && coords.z > surfaceElement->GetBaseZ())
|
||||
{
|
||||
SteamParticle* steam = CreateEntity<SteamParticle>();
|
||||
if (steam == nullptr)
|
||||
return;
|
||||
|
||||
steam->sprite_width = 20;
|
||||
steam->sprite_height_negative = 18;
|
||||
steam->sprite_height_positive = 16;
|
||||
steam->frame = 256;
|
||||
steam->time_to_move = 0;
|
||||
steam->MoveTo(coords);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006D63D4
|
||||
|
@ -7298,7 +7276,7 @@ void Vehicle::UpdateAdditionalAnimation()
|
|||
}();
|
||||
int32_t directionIndex = sprite_direction >> 1;
|
||||
auto offset = SteamParticleOffsets[typeIndex][directionIndex];
|
||||
steam_particle_create({ x + offset.x, y + offset.y, z + offset.z });
|
||||
SteamParticle::Create({ x + offset.x, y + offset.y, z + offset.z });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,10 @@
|
|||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "SpriteBase.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class EntityTweener
|
||||
|
|
|
@ -143,3 +143,108 @@ void CrashSplashParticle::Update()
|
|||
sprite_remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006734B2
|
||||
*/
|
||||
void SteamParticle::Create(const CoordsXYZ& coords)
|
||||
{
|
||||
auto surfaceElement = map_get_surface_element_at(coords);
|
||||
if (surfaceElement != nullptr && coords.z > surfaceElement->GetBaseZ())
|
||||
{
|
||||
SteamParticle* steam = CreateEntity<SteamParticle>();
|
||||
if (steam == nullptr)
|
||||
return;
|
||||
|
||||
steam->sprite_width = 20;
|
||||
steam->sprite_height_negative = 18;
|
||||
steam->sprite_height_positive = 16;
|
||||
steam->frame = 256;
|
||||
steam->time_to_move = 0;
|
||||
steam->MoveTo(coords);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00673200
|
||||
*/
|
||||
void SteamParticle::Update()
|
||||
{
|
||||
// Move up 1 z every 3 ticks (Starts after 4 ticks)
|
||||
Invalidate();
|
||||
time_to_move++;
|
||||
if (time_to_move >= 4)
|
||||
{
|
||||
time_to_move = 1;
|
||||
MoveTo({ x, y, z + 1 });
|
||||
}
|
||||
frame += 64;
|
||||
if (frame >= (56 * 64))
|
||||
{
|
||||
sprite_remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x0067363D
|
||||
*/
|
||||
void ExplosionCloud::Create(const CoordsXYZ& cloudPos)
|
||||
{
|
||||
auto* entity = CreateEntity<ExplosionCloud>();
|
||||
if (entity != nullptr)
|
||||
{
|
||||
entity->sprite_width = 44;
|
||||
entity->sprite_height_negative = 32;
|
||||
entity->sprite_height_positive = 34;
|
||||
entity->MoveTo(cloudPos + CoordsXYZ{ 0, 0, 4 });
|
||||
entity->frame = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00673385
|
||||
*/
|
||||
void ExplosionCloud::Update()
|
||||
{
|
||||
Invalidate();
|
||||
frame += 128;
|
||||
if (frame >= (36 * 128))
|
||||
{
|
||||
sprite_remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x0067366B
|
||||
*/
|
||||
void ExplosionFlare::Create(const CoordsXYZ& flarePos)
|
||||
{
|
||||
auto* entity = CreateEntity<ExplosionFlare>();
|
||||
if (entity != nullptr)
|
||||
{
|
||||
entity->sprite_width = 25;
|
||||
entity->sprite_height_negative = 85;
|
||||
entity->sprite_height_positive = 8;
|
||||
entity->MoveTo(flarePos + CoordsXYZ{ 0, 0, 4 });
|
||||
entity->frame = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006733B4
|
||||
*/
|
||||
void ExplosionFlare::Update()
|
||||
{
|
||||
Invalidate();
|
||||
frame += 64;
|
||||
if (frame >= (124 * 64))
|
||||
{
|
||||
sprite_remove(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,3 +39,29 @@ struct CrashSplashParticle : MiscEntity
|
|||
void Update();
|
||||
void Serialise(DataSerialiser& stream);
|
||||
};
|
||||
|
||||
struct ExplosionFlare : MiscEntity
|
||||
{
|
||||
static constexpr auto cEntityType = EntityType::ExplosionFlare;
|
||||
static void Create(const CoordsXYZ& flarePos);
|
||||
void Update();
|
||||
void Serialise(DataSerialiser& stream);
|
||||
};
|
||||
|
||||
struct ExplosionCloud : MiscEntity
|
||||
{
|
||||
static constexpr auto cEntityType = EntityType::ExplosionCloud;
|
||||
static void Create(const CoordsXYZ& cloudPos);
|
||||
void Update();
|
||||
void Serialise(DataSerialiser& stream);
|
||||
};
|
||||
|
||||
struct SteamParticle : MiscEntity
|
||||
{
|
||||
static constexpr auto cEntityType = EntityType::SteamParticle;
|
||||
uint16_t time_to_move;
|
||||
|
||||
static void Create(const CoordsXYZ& coords);
|
||||
void Update();
|
||||
void Serialise(DataSerialiser& stream);
|
||||
};
|
||||
|
|
|
@ -445,88 +445,6 @@ SpriteBase* CreateEntityAt(const uint16_t index, const EntityType type)
|
|||
PrepareNewEntity(entity, type);
|
||||
return entity;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00673200
|
||||
*/
|
||||
void SteamParticle::Update()
|
||||
{
|
||||
// Move up 1 z every 3 ticks (Starts after 4 ticks)
|
||||
Invalidate();
|
||||
time_to_move++;
|
||||
if (time_to_move >= 4)
|
||||
{
|
||||
time_to_move = 1;
|
||||
MoveTo({ x, y, z + 1 });
|
||||
}
|
||||
frame += 64;
|
||||
if (frame >= (56 * 64))
|
||||
{
|
||||
sprite_remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x0067363D
|
||||
*/
|
||||
void sprite_misc_explosion_cloud_create(const CoordsXYZ& cloudPos)
|
||||
{
|
||||
auto* sprite = CreateEntity<ExplosionCloud>();
|
||||
if (sprite != nullptr)
|
||||
{
|
||||
sprite->sprite_width = 44;
|
||||
sprite->sprite_height_negative = 32;
|
||||
sprite->sprite_height_positive = 34;
|
||||
sprite->MoveTo(cloudPos + CoordsXYZ{ 0, 0, 4 });
|
||||
sprite->frame = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00673385
|
||||
*/
|
||||
void ExplosionCloud::Update()
|
||||
{
|
||||
Invalidate();
|
||||
frame += 128;
|
||||
if (frame >= (36 * 128))
|
||||
{
|
||||
sprite_remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x0067366B
|
||||
*/
|
||||
void sprite_misc_explosion_flare_create(const CoordsXYZ& flarePos)
|
||||
{
|
||||
MiscEntity* sprite = CreateEntity<ExplosionFlare>();
|
||||
if (sprite != nullptr)
|
||||
{
|
||||
sprite->sprite_width = 25;
|
||||
sprite->sprite_height_negative = 85;
|
||||
sprite->sprite_height_positive = 8;
|
||||
sprite->MoveTo(flarePos + CoordsXYZ{ 0, 0, 4 });
|
||||
sprite->frame = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006733B4
|
||||
*/
|
||||
void ExplosionFlare::Update()
|
||||
{
|
||||
Invalidate();
|
||||
frame += 64;
|
||||
if (frame >= (124 * 64))
|
||||
{
|
||||
sprite_remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T> void MiscUpdateAllType()
|
||||
{
|
||||
|
|
|
@ -15,31 +15,6 @@
|
|||
|
||||
#include <array>
|
||||
|
||||
class DataSerialiser;
|
||||
|
||||
struct ExplosionFlare : MiscEntity
|
||||
{
|
||||
static constexpr auto cEntityType = EntityType::ExplosionFlare;
|
||||
void Update();
|
||||
void Serialise(DataSerialiser& stream);
|
||||
};
|
||||
|
||||
struct ExplosionCloud : MiscEntity
|
||||
{
|
||||
static constexpr auto cEntityType = EntityType::ExplosionCloud;
|
||||
void Update();
|
||||
void Serialise(DataSerialiser& stream);
|
||||
};
|
||||
|
||||
struct SteamParticle : MiscEntity
|
||||
{
|
||||
static constexpr auto cEntityType = EntityType::SteamParticle;
|
||||
uint16_t time_to_move;
|
||||
|
||||
void Update();
|
||||
void Serialise(DataSerialiser& stream);
|
||||
};
|
||||
|
||||
#pragma pack(push, 1)
|
||||
/**
|
||||
* Sprite structure.
|
||||
|
@ -88,8 +63,6 @@ void sprite_misc_update_all();
|
|||
void sprite_set_coordinates(const CoordsXYZ& spritePos, SpriteBase* sprite);
|
||||
void sprite_remove(SpriteBase* sprite);
|
||||
uint16_t remove_floating_sprites();
|
||||
void sprite_misc_explosion_cloud_create(const CoordsXYZ& cloudPos);
|
||||
void sprite_misc_explosion_flare_create(const CoordsXYZ& flarePos);
|
||||
|
||||
rct_sprite_checksum sprite_checksum();
|
||||
|
||||
|
|
Loading…
Reference in New Issue