Files
OpenRCT2-Web/src/openrct2/entity/EntityBase.cpp
T

78 lines
1.9 KiB
C++
Raw Normal View History

2021-05-09 19:12:44 +01:00
/*****************************************************************************
* Copyright (c) 2014-2021 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
2021-11-26 16:49:37 +02:00
#include "EntityBase.h"
2021-05-09 19:12:44 +01:00
#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)
2021-05-09 19:12:44 +01:00
{
stream << Type;
stream << sprite_index;
stream << x;
stream << y;
stream << z;
stream << sprite_direction;
2021-05-09 19:12:44 +01:00
}