1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

Move remaining EntityBase functions to EntityBase.cpp

This commit is contained in:
ζeh Matt
2021-11-27 15:12:57 +02:00
parent bcb527d331
commit 496fdfd3eb
4 changed files with 76 additions and 76 deletions

View File

@@ -11,6 +11,62 @@
#include "../core/DataSerialiser.h"
// Required for GetEntity to return a default
template<> bool EntityBase::Is<EntityBase>() const
{
return true;
}
CoordsXYZ EntityBase::GetLocation() const
{
return { x, y, z };
}
void EntityBase::SetLocation(const CoordsXYZ& newLocation)
{
x = newLocation.x;
y = newLocation.y;
z = newLocation.z;
}
void EntityBase::Invalidate()
{
if (x == LOCATION_NULL)
return;
int32_t maxZoom = 0;
switch (Type)
{
case EntityType::Vehicle:
case EntityType::Guest:
case EntityType::Staff:
maxZoom = 2;
break;
case EntityType::CrashedVehicleParticle:
case EntityType::JumpingFountain:
maxZoom = 0;
break;
case EntityType::Duck:
maxZoom = 1;
break;
case EntityType::SteamParticle:
case EntityType::MoneyEffect:
case EntityType::ExplosionCloud:
case EntityType::CrashSplash:
case EntityType::ExplosionFlare:
case EntityType::Balloon:
maxZoom = 2;
break;
case EntityType::Litter:
maxZoom = 0;
break;
default:
break;
}
viewports_invalidate(SpriteRect, maxZoom);
}
void EntityBase::Serialise(DataSerialiser& stream)
{
stream << Type;

View File

@@ -72,17 +72,6 @@ static constexpr size_t GetSpatialIndexOffset(const CoordsXY& loc)
return tileX * MAXIMUM_MAP_SIZE_TECHNICAL + tileY;
}
// Required for GetEntity to return a default
template<> bool EntityBase::Is<EntityBase>() const
{
return true;
}
template<> bool EntityBase::Is<Litter>() const
{
return Type == EntityType::Litter;
}
constexpr bool EntityTypeIsMiscEntity(const EntityType type)
{
switch (type)
@@ -102,21 +91,6 @@ constexpr bool EntityTypeIsMiscEntity(const EntityType type)
}
}
template<> bool EntityBase::Is<SteamParticle>() const
{
return Type == EntityType::SteamParticle;
}
template<> bool EntityBase::Is<ExplosionFlare>() const
{
return Type == EntityType::ExplosionFlare;
}
template<> bool EntityBase::Is<ExplosionCloud>() const
{
return Type == EntityType::ExplosionCloud;
}
uint16_t GetEntityListCount(EntityType type)
{
return static_cast<uint16_t>(gEntityLists[EnumValue(type)].size());
@@ -162,44 +136,6 @@ const std::vector<uint16_t>& GetEntityTileList(const CoordsXY& spritePos)
return gEntitySpatialIndex[GetSpatialIndexOffset(spritePos)];
}
void EntityBase::Invalidate()
{
if (x == LOCATION_NULL)
return;
int32_t maxZoom = 0;
switch (Type)
{
case EntityType::Vehicle:
case EntityType::Guest:
case EntityType::Staff:
maxZoom = 2;
break;
case EntityType::CrashedVehicleParticle:
case EntityType::JumpingFountain:
maxZoom = 0;
break;
case EntityType::Duck:
maxZoom = 1;
break;
case EntityType::SteamParticle:
case EntityType::MoneyEffect:
case EntityType::ExplosionCloud:
case EntityType::CrashSplash:
case EntityType::ExplosionFlare:
case EntityType::Balloon:
maxZoom = 2;
break;
case EntityType::Litter:
maxZoom = 0;
break;
default:
break;
}
viewports_invalidate(SpriteRect, maxZoom);
}
static void ResetEntityLists()
{
for (auto& list : gEntityLists)
@@ -529,18 +465,6 @@ void EntityBase::MoveTo(const CoordsXYZ& newLocation)
}
}
CoordsXYZ EntityBase::GetLocation() const
{
return { x, y, z };
}
void EntityBase::SetLocation(const CoordsXYZ& newLocation)
{
x = newLocation.x;
y = newLocation.y;
z = newLocation.z;
}
void EntitySetCoordinates(const CoordsXYZ& entityPos, EntityBase* entity)
{
auto screenCoords = translate_3d_to_2d_with_z(get_current_rotation(), entityPos);

View File

@@ -8,6 +8,11 @@
#include "EntityList.h"
#include "EntityRegistry.h"
template<> bool EntityBase::Is<Litter>() const
{
return Type == EntityType::Litter;
}
static bool isLocationLitterable(const CoordsXYZ& mapPos)
{
TileElement* tileElement;

View File

@@ -16,6 +16,21 @@
#include <iterator>
template<> bool EntityBase::Is<SteamParticle>() const
{
return Type == EntityType::SteamParticle;
}
template<> bool EntityBase::Is<ExplosionFlare>() const
{
return Type == EntityType::ExplosionFlare;
}
template<> bool EntityBase::Is<ExplosionCloud>() const
{
return Type == EntityType::ExplosionCloud;
}
template<> bool EntityBase::Is<VehicleCrashParticle>() const
{
return Type == EntityType::CrashedVehicleParticle;