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

Move code from Entity.h into EntityRegistry.h

This commit is contained in:
ζeh Matt
2021-11-26 16:40:18 +02:00
parent 7b3afe91af
commit cb76165448
3 changed files with 39 additions and 53 deletions

View File

@@ -1,45 +0,0 @@
/*****************************************************************************
* 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.
*****************************************************************************/
#pragma once
#include "EntityBase.h"
constexpr uint16_t MAX_ENTITIES = 65535;
EntityBase* GetEntity(size_t sprite_idx);
template<typename T> T* GetEntity(size_t sprite_idx)
{
auto spr = GetEntity(sprite_idx);
return spr != nullptr ? spr->As<T>() : nullptr;
}
EntityBase* TryGetEntity(size_t spriteIndex);
template<typename T> T* TryGetEntity(size_t sprite_idx)
{
auto spr = TryGetEntity(sprite_idx);
return spr != nullptr ? spr->As<T>() : nullptr;
}
EntityBase* CreateEntity(EntityType type);
template<typename T> T* CreateEntity()
{
return static_cast<T*>(CreateEntity(T::cEntityType));
}
// Use only with imports that must happen at a specified index
EntityBase* CreateEntityAt(const uint16_t index, const EntityType type);
// Use only with imports that must happen at a specified index
template<typename T> T* CreateEntityAt(const uint16_t index)
{
return static_cast<T*>(CreateEntityAt(index, T::cEntityType));
}

View File

@@ -14,14 +14,38 @@
#include <array>
#pragma pack(push, 1)
struct EntitiesChecksum
{
std::array<std::byte, 20> raw;
constexpr uint16_t MAX_ENTITIES = 65535;
std::string ToString() const;
};
#pragma pack(pop)
EntityBase* GetEntity(size_t sprite_idx);
template<typename T> T* GetEntity(size_t sprite_idx)
{
auto spr = GetEntity(sprite_idx);
return spr != nullptr ? spr->As<T>() : nullptr;
}
EntityBase* TryGetEntity(size_t spriteIndex);
template<typename T> T* TryGetEntity(size_t sprite_idx)
{
auto spr = TryGetEntity(sprite_idx);
return spr != nullptr ? spr->As<T>() : nullptr;
}
EntityBase* CreateEntity(EntityType type);
template<typename T> T* CreateEntity()
{
return static_cast<T*>(CreateEntity(T::cEntityType));
}
// Use only with imports that must happen at a specified index
EntityBase* CreateEntityAt(const uint16_t index, const EntityType type);
// Use only with imports that must happen at a specified index
template<typename T> T* CreateEntityAt(const uint16_t index)
{
return static_cast<T*>(CreateEntityAt(index, T::cEntityType));
}
void ResetAllEntities();
void ResetEntitySpatialIndices();
@@ -30,6 +54,14 @@ void EntitySetCoordinates(const CoordsXYZ& entityPos, EntityBase* entity);
void EntityRemove(EntityBase* entity);
uint16_t RemoveFloatingEntities();
#pragma pack(push, 1)
struct EntitiesChecksum
{
std::array<std::byte, 20> raw;
std::string ToString() const;
};
#pragma pack(pop)
EntitiesChecksum GetAllEntitiesChecksum();
void EntitySetFlashing(EntityBase* entity, bool flashing);

View File

@@ -207,7 +207,6 @@
<ClInclude Include="EditorObjectSelectionSession.h" />
<ClInclude Include="entity\Balloon.h" />
<ClInclude Include="entity\Duck.h" />
<ClInclude Include="entity\Entity.h" />
<ClInclude Include="entity\EntityBase.h" />
<ClInclude Include="entity\EntityList.h" />
<ClInclude Include="entity\EntityRegistry.h" />