mirror of https://github.com/OpenRCT2/OpenRCT2.git
Implement As and Is functions for SpriteBase
This commit is contained in:
parent
f21ddb0723
commit
1758f2a133
|
@ -323,6 +323,11 @@ const bool gSpriteTypeToSlowWalkMap[] = {
|
|||
|
||||
// clang-format on
|
||||
|
||||
template<> bool SpriteBase::Is<Peep>() const
|
||||
{
|
||||
return sprite_identifier == SPRITE_IDENTIFIER_PEEP;
|
||||
}
|
||||
|
||||
bool rct_sprite::IsPeep() const
|
||||
{
|
||||
return peep.sprite_identifier == SPRITE_IDENTIFIER_PEEP;
|
||||
|
|
|
@ -726,6 +726,11 @@ static const struct
|
|||
|
||||
// clang-format on
|
||||
|
||||
template<> bool SpriteBase::Is<Vehicle>() const
|
||||
{
|
||||
return sprite_identifier == SPRITE_IDENTIFIER_VEHICLE;
|
||||
}
|
||||
|
||||
static bool vehicle_move_info_valid(int32_t trackSubposition, int32_t typeAndDirection, int32_t offset)
|
||||
{
|
||||
if (trackSubposition >= static_cast<int32_t>(std::size(gTrackVehicleInfo)))
|
||||
|
|
|
@ -19,6 +19,11 @@ bool rct_sprite::IsBalloon()
|
|||
return this->balloon.sprite_identifier == SPRITE_IDENTIFIER_MISC && this->balloon.type == SPRITE_MISC_BALLOON;
|
||||
}
|
||||
|
||||
template<> bool SpriteBase::Is<Balloon>() const
|
||||
{
|
||||
return sprite_identifier == SPRITE_IDENTIFIER_MISC && type == SPRITE_MISC_BALLOON;
|
||||
}
|
||||
|
||||
Balloon* rct_sprite::AsBalloon()
|
||||
{
|
||||
Balloon* result = nullptr;
|
||||
|
|
|
@ -74,6 +74,11 @@ static constexpr const uint8_t * DuckAnimations[] =
|
|||
};
|
||||
// clang-format on
|
||||
|
||||
template<> bool SpriteBase::Is<Duck>() const
|
||||
{
|
||||
return sprite_identifier == SPRITE_IDENTIFIER_MISC && type == SPRITE_MISC_DUCK;
|
||||
}
|
||||
|
||||
bool rct_sprite::IsDuck()
|
||||
{
|
||||
return this->duck.sprite_identifier == SPRITE_IDENTIFIER_MISC && this->duck.type == SPRITE_MISC_DUCK;
|
||||
|
|
|
@ -80,6 +80,12 @@ const uint8_t _fountainPatternFlags[] = {
|
|||
FOUNTAIN_FLAG::FAST // FAST_RANDOM_CHASERS
|
||||
};
|
||||
|
||||
template<> bool SpriteBase::Is<JumpingFountain>() const
|
||||
{
|
||||
return sprite_identifier == SPRITE_IDENTIFIER_MISC
|
||||
&& (type == SPRITE_MISC_JUMPING_FOUNTAIN_SNOW || type == SPRITE_MISC_JUMPING_FOUNTAIN_WATER);
|
||||
}
|
||||
|
||||
void JumpingFountain::StartAnimation(const int32_t newType, const CoordsXY& newLoc, const TileElement* tileElement)
|
||||
{
|
||||
int32_t randomIndex;
|
||||
|
|
|
@ -18,6 +18,11 @@
|
|||
|
||||
static constexpr const CoordsXY _moneyEffectMoveOffset[] = { { 1, -1 }, { 1, 1 }, { -1, 1 }, { -1, -1 } };
|
||||
|
||||
template<> bool SpriteBase::Is<MoneyEffect>() const
|
||||
{
|
||||
return sprite_identifier == SPRITE_IDENTIFIER_MISC && type == SPRITE_MISC_MONEY_EFFECT;
|
||||
}
|
||||
|
||||
bool rct_sprite::IsMoneyEffect()
|
||||
{
|
||||
return this->money_effect.sprite_identifier == SPRITE_IDENTIFIER_MISC
|
||||
|
|
|
@ -14,6 +14,15 @@
|
|||
|
||||
#include <iterator>
|
||||
|
||||
template<> bool SpriteBase::Is<VehicleCrashParticle>() const
|
||||
{
|
||||
return sprite_identifier == SPRITE_IDENTIFIER_MISC && type == SPRITE_MISC_CRASHED_VEHICLE_PARTICLE;
|
||||
}
|
||||
|
||||
template<> bool SpriteBase::Is<CrashSplashParticle>() const
|
||||
{
|
||||
return sprite_identifier == SPRITE_IDENTIFIER_MISC && type == SPRITE_MISC_CRASH_SPLASH;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006735A1
|
||||
|
|
|
@ -52,6 +52,26 @@ static CoordsXYZ _spritelocations2[MAX_SPRITES];
|
|||
static size_t GetSpatialIndexOffset(int32_t x, int32_t y);
|
||||
static void move_sprite_to_list(SpriteBase* sprite, SPRITE_LIST newListIndex);
|
||||
|
||||
template<> bool SpriteBase::Is<Litter>() const
|
||||
{
|
||||
return sprite_identifier == SPRITE_IDENTIFIER_LITTER;
|
||||
}
|
||||
|
||||
template<> bool SpriteBase::Is<SteamParticle>() const
|
||||
{
|
||||
return sprite_identifier == SPRITE_IDENTIFIER_MISC && type == SPRITE_MISC_STEAM_PARTICLE;
|
||||
}
|
||||
|
||||
template<> bool SpriteBase::Is<ExplosionFlare>() const
|
||||
{
|
||||
return sprite_identifier == SPRITE_IDENTIFIER_MISC && type == SPRITE_MISC_EXPLOSION_FLARE;
|
||||
}
|
||||
|
||||
template<> bool SpriteBase::Is<ExplosionCloud>() const
|
||||
{
|
||||
return sprite_identifier == SPRITE_IDENTIFIER_MISC && type == SPRITE_MISC_EXPLOSION_CLOUD;
|
||||
}
|
||||
|
||||
std::string rct_sprite_checksum::ToString() const
|
||||
{
|
||||
std::string result;
|
||||
|
|
|
@ -100,6 +100,14 @@ struct VehicleCrashParticle : SpriteGeneric
|
|||
int32_t acceleration_z;
|
||||
};
|
||||
|
||||
struct ExplosionFlare : SpriteGeneric
|
||||
{
|
||||
};
|
||||
|
||||
struct ExplosionCloud : SpriteGeneric
|
||||
{
|
||||
};
|
||||
|
||||
struct CrashSplashParticle : SpriteGeneric
|
||||
{
|
||||
};
|
||||
|
|
|
@ -33,6 +33,16 @@ struct SpriteBase
|
|||
uint8_t sprite_direction;
|
||||
|
||||
void MoveTo(const CoordsXYZ& newLocation);
|
||||
template<typename T> bool Is() const;
|
||||
template<typename T> T* As()
|
||||
{
|
||||
T* result = nullptr;
|
||||
if (Is<T>())
|
||||
{
|
||||
result = reinterpret_cast<T*>(this);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
struct SpriteGeneric : SpriteBase
|
||||
|
|
Loading…
Reference in New Issue