29#include <unordered_map>
37#include "Ecs_Entity.h"
42#include "PrefabFactory.h"
45#include "third_party/nlohmann/json.hpp"
52 struct LevelParseResult;
56 struct LevelDefinition;
57 struct EntityInstance;
243 template <
typename T>
392 template <
typename T,
typename...
Args>
418 return pool->GetComponent(entity);
421 template <
typename T>
437 template <
typename T>
443 throw std::runtime_error(
"Component pool not registered.");
450 template <
typename T>
542 << (
settings.enabled ?
"enabled" :
"disabled") <<
"\n";
574 SYSTEM_LOG <<
"World::ToggleCollisionOverlay: Collision overlay "
575 << (
settings.showCollisionOverlay ?
"enabled" :
"disabled") <<
"\n";
592 SYSTEM_LOG <<
"World::ToggleNavigationOverlay: Navigation overlay "
593 << (
settings.showNavigationOverlay ?
"enabled" :
"disabled") <<
"\n";
608 return settings.showCollisionOverlay;
623 return settings.showNavigationOverlay;
655 template <
typename T>
662 template <
typename T>
682 InstantiationResult&
result);
686 InstantiationResult&
result);
691 InstantiationResult&
result);
696 const std::shared_ptr<Olympe::Editor::EntityInstance>&
entityInstance,
698 InstantiationResult::PassStats& stats);
722 InstantiationResult::PassStats& stats);
756 int zOrder,
const std::string& encoding);
758 int width,
int height,
int zOrder,
const std::string& encoding);
Core ECS component definitions.
RenderLayer
Render layer enumeration for Z-ordering.
std::bitset< MAX_COMPONENTS > ComponentSignature
ComponentTypeID GetComponentTypeID_Static()
std::uint64_t ComponentTypeID
void RegisterInputEntityWithManager(EntityID e)
void AddComponent(EntityID entity, Args &&... args)
bool HasComponent(EntityID entity) const
T & GetComponent(EntityID entity)
static EventQueue & Get()
Factory class for creating entities from prefab blueprints.
Manages tilesets loaded from Tiled maps.
const std::vector< TilesetInfo > & GetTilesets() const
Get all loaded tilesets.
void Clear()
Clear all loaded tilesets.
std::vector< TilesetInfo > m_tilesets
All loaded tilesets.
void LoadTilesets(const nlohmann::json &tilesetsJson)
Load tilesets from JSON data.
bool GetTileTexture(uint32_t gid, SDL_Texture *&outTexture, SDL_Rect &outSrcRect, const TilesetInfo *&outTileset)
Get texture and source rect for a tile by GID.
Core ECS manager and world coordinator.
void NotifyBlueprintEditorEntityCreated(EntityID entity)
int GetTileHeight() const
std::queue< EntityID > m_freeEntityIDs
void ToggleCollisionOverlay()
Toggle collision overlay visibility.
bool m_isometricOriginCached
bool InstantiatePass1_VisualLayers(const Olympe::Editor::LevelDefinition &levelDef, InstantiationResult &result)
const std::vector< EntityID > & GetAllEntities() const
Get all active entity IDs.
bool IsNavigationOverlayVisible()
Get navigation overlay state.
EntityID CreateMissingPrefabPlaceholder(const Olympe::Editor::EntityInstance &entityInstance, InstantiationResult::PassStats &stats)
Create a red placeholder entity for missing prefabs.
int GetChunkOriginX() const
std::vector< std::unique_ptr< Level > > m_levels
EntityID InstantiateEntity(const std::shared_ptr< Olympe::Editor::EntityInstance > &entityInstance, PrefabFactory &factory, InstantiationResult::PassStats &stats)
Unified entity instantiation helper (used by all Phase 5 passes) Types are already normalized,...
void Initialize_ECS_Systems()
void UnloadCurrentLevel()
bool LoadLevelFromTiled(const std::string &tiledMapPath)
bool IsCollisionOverlayVisible()
Get collision overlay state.
void NotifyBlueprintEditorEntityDestroyed(EntityID entity)
void Render_ECS_Systems()
void LoadTileLayer(const nlohmann::json &layerJson, InstantiationResult &result)
std::string ExtractPrefabName(const std::string &prefabPath)
Extract prefab name from prefab path (removes path and extension)
const std::vector< TileChunk > & GetTileChunks() const
void LoadTileData(const nlohmann::json &dataJson, const std::string &layerName, int width, int height, int zOrder, const std::string &encoding)
void HandleSpecialComponentRegistration(EntityID entity, typename std::enable_if<!std::is_same< T, PlayerBinding_data >::value >::type *=nullptr)
static World & Get()
Get singleton instance (short form)
T & AddComponent(EntityID entity, Args &&... args)
bool HasComponent(EntityID entity) const
bool IsEntityValid(EntityID entity) const
void SyncGridWithLevel(const Olympe::Editor::LevelDefinition &levelDef)
Synchronize grid settings with loaded level Extracts map orientation and tile dimensions from LevelDe...
void LoadTileChunk(const nlohmann::json &chunkJson, const std::string &layerName, int zOrder, const std::string &encoding)
bool LoadLevelDependencies(const nlohmann::json &levelJson)
const std::vector< std::unique_ptr< Level > > & GetLevels() const
std::unordered_map< ComponentTypeID, std::unique_ptr< IComponentPool > > m_componentPools
void ValidateLevelPrefabs(const Olympe::Editor::LevelDefinition &levelDef)
void SetMapBounds(int minTileX, int minTileY, int maxTileX, int maxTileY, int chunkOriginX, int chunkOriginY)
RenderLayer GetDefaultLayerForType(EntityType type) const
Get the default render layer for an entity type Automatically assigns appropriate layer based on enti...
TilesetManager m_tilesetManager
void Notify_ECS_Systems(EntityID entity, ComponentSignature signature)
T & GetComponent(EntityID entity)
std::unordered_map< EntityID, ComponentSignature > m_entitySignatures
RenderLayer CalculateLayerFromZOrder(float zOrder) const
Calculate layer index from zOrder value (for Tiled levels) Maps zOrder ranges to layer indices for pr...
RenderLayer GetEntityLayer(EntityID entity) const
Get entity render layer.
virtual ~World()
Destructor.
void RemoveComponent(EntityID entity)
void GenerateCollisionAndNavigationMaps(const Olympe::Tiled::TiledMap &tiledMap, const Olympe::Editor::LevelDefinition &levelDef)
int GetChunkOriginY() const
bool InstantiatePass2_SpatialStructure(const Olympe::Editor::LevelDefinition &levelDef, InstantiationResult &result)
float m_cachedIsometricOriginX
void ToggleNavigationOverlay()
Toggle navigation overlay visibility.
void RegisterPlayerEntity(EntityID entity)
Register a player entity that was loaded from a level file Validates required components and delegate...
const std::string & GetMapOrientation() const
float m_cachedIsometricOriginY
float GetIsometricOriginX() const
float GetIsometricOriginY() const
void ToggleGrid()
Toggle grid visibility.
std::vector< std::unique_ptr< ECS_System > > m_systems
std::vector< EntityID > m_entities
void Process_ECS_Systems()
void RenderDebug_ECS_Systems()
std::vector< TileChunk > m_tileChunks
bool IsGridEnabled()
Get current grid state.
void HandleSpecialComponentRegistration(EntityID entity, typename std::enable_if< std::is_same< T, PlayerBinding_data >::value >::type *=nullptr)
int m_nextCustomLayerIndex
void Add_ECS_System(std::unique_ptr< ECS_System > system)
bool InstantiatePass5_Relationships(const Olympe::Editor::LevelDefinition &levelDef, InstantiationResult &result)
TilesetManager & GetTilesetManager()
std::string m_mapOrientation
static World & GetInstance()
Get singleton instance.
void SetEntityLayer(EntityID entity, RenderLayer layer)
Set entity render layer (updates position.z)
void DestroyEntity(EntityID entity)
World()
Default constructor.
int GetNextCustomLayerIndex()
Get next available custom layer index (for dynamic layers)
void AddLevel(std::unique_ptr< Level > level)
void ExtractCustomProperties(const nlohmann::json &overrides, LevelInstanceParameters &instanceParams, const Olympe::Editor::EntityInstance *entityInstance=nullptr, const PrefabBlueprint *prefab=nullptr)
Extract custom properties from JSON overrides into LevelInstanceParameters.
Represents a chunk of tiles for rendering.
int zOrder
Render order (Z-coordinate)
int height
Chunk height (in tiles)
int x
Chunk X position (in tiles)
TileChunk()
Default constructor.
int width
Chunk width (in tiles)
int y
Chunk Y position (in tiles)
std::string layerName
Name of the source layer.
std::vector< uint32_t > tileGIDs
Tile Global IDs (with flip flags)
Information about a loaded tileset.
int columns
Number of columns in atlas.
std::string name
Tileset name.
int tileoffsetX
Global X offset for all tiles.
SDL_Texture * texture
Atlas texture (image-based)
int imagewidth
Total atlas width.
uint32_t firstgid
First Global ID in this tileset.
int tileoffsetY
Global Y offset for all tiles.
int imageheight
Total atlas height.
TilesetInfo()
Default constructor with explicit initialization.
int spacing
Spacing between tiles.
int margin
Margin around atlas.
int tileheight
Height of each tile.
bool isCollection
True if collection tileset.
std::map< uint32_t, SDL_Texture * > individualTiles
Per-tile textures.
int tilewidth
Width of each tile.
uint32_t lastgid
Last Global ID (firstgid + tilecount - 1)
std::map< uint32_t, SDL_Rect > individualSrcRects
Per-tile source rects.
std::vector< std::string > failedObjects
PassStats pass2_spatialStructure
PassStats pass5_relationships
PassStats pass3_staticObjects
std::map< std::string, EntityID > entityRegistry
std::vector< EntityID > sectors
int GetTotalCreated() const
PassStats pass1_visualLayers
PassStats pass4_dynamicObjects
std::map< int, EntityID > objectIdToEntity
int GetTotalFailed() const
PrefabRegistry prefabRegistry
DataManager::LevelPreloadResult preloadResult
std::vector< std::string > errors
std::vector< std::string > missingPrefabs