mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-04 13:42:55 +01:00
Add a way to invalidate entity tweening
This commit is contained in:
@@ -35,6 +35,14 @@ struct EntitySpriteData
|
||||
ScreenRect SpriteRect;
|
||||
};
|
||||
|
||||
namespace EntityRenderFlags
|
||||
{
|
||||
// Disables tweening for this tick, this is helpful when entities are teleported
|
||||
// and should not be tweened.
|
||||
constexpr uint32_t kInvalidateTweening = (1U << 0);
|
||||
|
||||
} // namespace EntityRenderFlags
|
||||
|
||||
struct EntityBase
|
||||
{
|
||||
EntityType Type;
|
||||
@@ -42,6 +50,8 @@ struct EntityBase
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
int32_t z;
|
||||
// Rendering specific flags, this should not be stored in the save file.
|
||||
uint32_t RenderFlags;
|
||||
EntitySpriteData SpriteData;
|
||||
// Used as direction or rotation depending on the entity.
|
||||
uint8_t Orientation;
|
||||
|
||||
@@ -273,6 +273,7 @@ static void EntityReset(EntityBase* entity)
|
||||
|
||||
entity->Id = entityIndex;
|
||||
entity->Type = EntityType::Null;
|
||||
entity->RenderFlags = 0;
|
||||
}
|
||||
|
||||
static constexpr uint16_t MAX_MISC_SPRITES = 300;
|
||||
|
||||
@@ -15,22 +15,28 @@
|
||||
#include "EntityRegistry.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
void EntityTweener::AddEntity(EntityBase* entity)
|
||||
{
|
||||
entity->RenderFlags &= ~EntityRenderFlags::kInvalidateTweening;
|
||||
|
||||
Entities.push_back(entity);
|
||||
PrePos.emplace_back(entity->GetLocation());
|
||||
}
|
||||
|
||||
void EntityTweener::PopulateEntities()
|
||||
{
|
||||
for (auto ent : EntityList<Guest>())
|
||||
{
|
||||
Entities.push_back(ent);
|
||||
PrePos.emplace_back(ent->GetLocation());
|
||||
AddEntity(ent);
|
||||
}
|
||||
for (auto ent : EntityList<Staff>())
|
||||
{
|
||||
Entities.push_back(ent);
|
||||
PrePos.emplace_back(ent->GetLocation());
|
||||
AddEntity(ent);
|
||||
}
|
||||
for (auto ent : EntityList<Vehicle>())
|
||||
{
|
||||
Entities.push_back(ent);
|
||||
PrePos.emplace_back(ent->GetLocation());
|
||||
AddEntity(ent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,9 +63,16 @@ void EntityTweener::PostTick()
|
||||
}
|
||||
}
|
||||
|
||||
static bool CanTweenEntity(EntityBase* ent)
|
||||
{
|
||||
if (ent->Is<Guest>() || ent->Is<Staff>() || ent->Is<Vehicle>())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void EntityTweener::RemoveEntity(EntityBase* entity)
|
||||
{
|
||||
if (!entity->Is<Peep>() && !entity->Is<Vehicle>())
|
||||
if (!CanTweenEntity(entity))
|
||||
{
|
||||
// Only peeps and vehicles are tweened, bail if type is incorrect.
|
||||
return;
|
||||
@@ -79,6 +92,9 @@ void EntityTweener::Tween(float alpha)
|
||||
if (ent == nullptr)
|
||||
continue;
|
||||
|
||||
if (ent->RenderFlags & EntityRenderFlags::kInvalidateTweening)
|
||||
continue;
|
||||
|
||||
auto& posA = PrePos[i];
|
||||
auto& posB = PostPos[i];
|
||||
|
||||
@@ -102,6 +118,9 @@ void EntityTweener::Restore()
|
||||
if (ent == nullptr)
|
||||
continue;
|
||||
|
||||
if (ent->RenderFlags & EntityRenderFlags::kInvalidateTweening)
|
||||
continue;
|
||||
|
||||
EntitySetCoordinates(PostPos[i], ent);
|
||||
ent->Invalidate();
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ class EntityTweener
|
||||
|
||||
private:
|
||||
void PopulateEntities();
|
||||
void AddEntity(EntityBase* entity);
|
||||
|
||||
public:
|
||||
static EntityTweener& Get();
|
||||
|
||||
Reference in New Issue
Block a user