Map module — factory + script binding for 2D tilemaps. Per-frame: TileConfigSystem (hot reload) → unified sprite+tile render. Pathfinding: newPathfinder / newPathfinderSize → A* + Flow Field group paths. FOV: newFov / newFovSize → shadowcast visibility + explored memory. 更多...
#include <Map.h>
Public 成员函数 | |
| Module_REG (Map) | |
| Map () | |
| Map. | |
| ~Map () override=default | |
| Map. | |
| TileLayer * | newLayer (int mapW, int mapH, float tileW=32.f, float tileH=32.f) |
| Creates a layer. @ownership Caller deletes unless documented otherwise. | |
| Pathfinder * | newPathfinder (TileLayer *layer) |
| Pathfinder bound to a TileLayer (syncs walkability from GIDs). | |
| Pathfinder * | newPathfinderSize (int mapW, int mapH) |
| Custom grid pathfinder (no layer); fill with setBlocked / setCellCost. | |
| Fov * | newFov (TileLayer *layer) |
| FOV bound to a TileLayer (syncs opacity from opaque GIDs). | |
| Fov * | newFovSize (int mapW, int mapH) |
| Custom grid FOV (no layer); fill with setOpaque. | |
| Fov * | newFovVolume (int mapW, int mapH, int depth) |
| Volume FOV (W×H×D voxels); mode defaults to volume. | |
| TileLayer * | newLayerFromFile (const std::string &path) |
| Load map JSON (Tiled-compatible subset or EVEngine simplified format). Creates one TileLayer per tile layer; returns the first (nullptr on failure). Refreshes the module object cache from objectgroup layers. | |
| int | loadFromFile (const std::string &path) |
| Same transactional replacement as newLayerFromFile, returning the published layer count. | |
| eve::Result< int > | loadFromFileWithObjectContract (const std::string &path, std::string_view contractJson) |
| Parse a map and validate its objects before atomically publishing it. | |
| eve::Result< int > | loadFromTextWithObjectContract (std::string_view mapJson, std::string_view contractJson) |
| Parse map JSON text and atomically publish it after object-contract admission. | |
| void | update (float dt) |
| Updates . | |
| void | render (graphics::Graphics *gfx) |
| Renders . | |
| int | pollConfigs () |
| Polls configs. | |
| int | getLastVisibleTileCount () const |
| Last tile collection counters for project-owned diagnostics UIs. | |
| int | getLastCustomVisualCount () const |
| Returns the last custom visual count. | |
| int | getLastAtlasCount () const |
| Returns the last atlas count. | |
| int | getLastVisitedChunkCount () const |
| Returns the last visited chunk count. | |
| int | getLastVisitedCellCount () const |
| Returns the last visited cell count. | |
| int | publishCollision (TileLayer *layer) |
| Generate merged collision from non-walkable tile metadata and notify adapters. | |
| int | getCollisionRectCount () const |
| Returns the collision rect count. | |
| float | getCollisionRectX (int index) const |
| Returns the collision rect x. | |
| float | getCollisionRectY (int index) const |
| Returns the collision rect y. | |
| float | getCollisionRectWidth (int index) const |
| Returns the collision rect width. | |
| float | getCollisionRectHeight (int index) const |
| Returns the collision rect height. | |
| int | getLayerCount () const |
| Returns the layer count. | |
| TileLayer * | getLayer (int index) const |
| Layer created by the most recent loadFromFile/newLayerFromFile call. | |
| int | getObjectCount () const |
| Returns the object count. | |
| std::string | getObjectName (int i) const |
| Returns the object name. | |
| std::string | getObjectType (int i) const |
| Returns the object type. | |
| float | getObjectX (int i) const |
| Returns the object x. | |
| float | getObjectY (int i) const |
| Returns the object y. | |
| float | getObjectWidth (int i) const |
| Returns the object width. | |
| float | getObjectHeight (int i) const |
| Returns the object height. | |
| int | getObjectGid (int i) const |
| Returns the object gid. | |
| int | getObjectPropertyCount (int objectIndex) const |
| Return the number of sorted custom properties on one cached object. | |
| std::string | getObjectPropertyName (int objectIndex, int propertyIndex) const |
| Return an owning custom-property name at deterministic sorted position. | |
| bool | hasObjectProperty (int objectIndex, std::string_view name) const |
| Query whether a cached object declares an exact custom-property name. | |
| std::string | getObjectProperty (int objectIndex, std::string_view name, std::string defaultValue={}) const |
| Read the owning canonical text projection of an object's custom property. | |
| std::optional< std::size_t > | findObjectByName (std::string_view name) const |
| Find the first loaded map object with an exact stable name. | |
| std::optional< std::size_t > | findObjectAt (float x, float y, std::string_view type={}) const |
| Find the first loaded object containing a point, optionally filtered by type. | |
| void | setObjects (std::vector< MapObject > objects) |
| Replace object cache (used by load / hot reload). | |
| bool | resolveDualGrid (TileLayer *logic, TileLayer *display) |
| Dual-grid resolve: paint logic (filled/empty), fill display with 15-tile autotiles on a half-offset grid. See DualGrid.h. filledGid 0 = any non-zero logic cell counts as filled. | |
| bool | resolveDualGridFilled (TileLayer *logic, TileLayer *display, int filledGid) |
| Resolve dual grid filled. | |
| int | dualGridMaskAt (TileLayer *logic, int dx, int dy, int filledGid) |
| 4-bit corner mask at display cell (dx,dy); see DualGrid.h. | |
| int | dualGridFrame (int mask) |
| Default atlas frame for mask (-1 = empty). | |
| float | dualGridOffsetX (TileLayer *logic) |
| Projection-correct half-step origin delta for a logic layer. | |
| float | dualGridOffsetY (TileLayer *logic) |
| Dual grid offset y. | |
| std::string | lastDualGridError () const |
| Last dual grid error. | |
Public 成员函数 继承自 eve::Module | |
| virtual | ~Module () |
| Module. | |
| virtual std::string | getName () const =0 |
| Returns the name. | |
详细描述
Map module — factory + script binding for 2D tilemaps. Per-frame: TileConfigSystem (hot reload) → unified sprite+tile render. Pathfinding: newPathfinder / newPathfinderSize → A* + Flow Field group paths. FOV: newFov / newFovSize → shadowcast visibility + explored memory.
构造及析构函数说明
◆ Map()
| eve::map::Map::Map | ( | ) |
◆ ~Map()
|
overridedefault |
Map.
成员函数说明
◆ dualGridFrame()
| int eve::map::Map::dualGridFrame | ( | int | mask | ) |
Default atlas frame for mask (-1 = empty).
引用了 eve::map::dualGridDefaultFrame() , 以及 mask.
◆ dualGridMaskAt()
| int eve::map::Map::dualGridMaskAt | ( | TileLayer * | logic, |
| int | dx, | ||
| int | dy, | ||
| int | filledGid | ||
| ) |
4-bit corner mask at display cell (dx,dy); see DualGrid.h.
引用了 eve::map::dualGridMaskAt(), dx , 以及 dy.
◆ dualGridOffsetX()
| float eve::map::Map::dualGridOffsetX | ( | TileLayer * | logic | ) |
Projection-correct half-step origin delta for a logic layer.
引用了 eve::map::dualGridHalfOffset(), ox , 以及 oy.
◆ dualGridOffsetY()
| float eve::map::Map::dualGridOffsetY | ( | TileLayer * | logic | ) |
◆ findObjectAt()
| std::optional< std::size_t > eve::map::Map::findObjectAt | ( | float | x, |
| float | y, | ||
| std::string_view | type = {} |
||
| ) | const |
Find the first loaded object containing a point, optionally filtered by type.
- 参数
-
x Query coordinate in the same space as MapObject::x. y Query coordinate in the same space as MapObject::y. type Exact object type, or empty to accept any type.
- 返回
- Owning cache index when present, or nullopt when no object matches.
- 备注
- Positive-size objects use an inclusive rectangle. Point objects require an exact finite coordinate match. The transient index has the same invalidation rules as findObjectByName. @thread Call on the Map module's owning simulation thread. @reentrancy No callbacks are invoked.
引用了 height, index, point, type, width, eve::map::MapObject::width, x , 以及 y.
◆ findObjectByName()
| std::optional< std::size_t > eve::map::Map::findObjectByName | ( | std::string_view | name | ) | const |
Find the first loaded map object with an exact stable name.
- 参数
-
name Object name to match; the input is borrowed only for this call.
- 返回
- Owning cache index when present, or nullopt when no object matches.
- 备注
- The index is a transient projection and may identify another object after loadFromFile, newLayerFromFile, hot reload, or setObjects. Persist object names, not indices. @thread Call on the Map module's owning simulation thread. @reentrancy No callbacks are invoked.
◆ getCollisionRectCount()
| int eve::map::Map::getCollisionRectCount | ( | ) | const |
◆ getCollisionRectHeight()
| float eve::map::Map::getCollisionRectHeight | ( | int | index | ) | const |
◆ getCollisionRectWidth()
| float eve::map::Map::getCollisionRectWidth | ( | int | index | ) | const |
◆ getCollisionRectX()
| float eve::map::Map::getCollisionRectX | ( | int | index | ) | const |
◆ getCollisionRectY()
| float eve::map::Map::getCollisionRectY | ( | int | index | ) | const |
◆ getLastAtlasCount()
| int eve::map::Map::getLastAtlasCount | ( | ) | const |
Returns the last atlas count.
◆ getLastCustomVisualCount()
| int eve::map::Map::getLastCustomVisualCount | ( | ) | const |
Returns the last custom visual count.
◆ getLastVisibleTileCount()
| int eve::map::Map::getLastVisibleTileCount | ( | ) | const |
Last tile collection counters for project-owned diagnostics UIs.
◆ getLastVisitedCellCount()
| int eve::map::Map::getLastVisitedCellCount | ( | ) | const |
Returns the last visited cell count.
◆ getLastVisitedChunkCount()
| int eve::map::Map::getLastVisitedChunkCount | ( | ) | const |
Returns the last visited chunk count.
◆ getLayer()
| TileLayer * eve::map::Map::getLayer | ( | int | index | ) | const |
◆ getLayerCount()
| int eve::map::Map::getLayerCount | ( | ) | const |
◆ getObjectCount()
◆ getObjectGid()
◆ getObjectHeight()
| float eve::map::Map::getObjectHeight | ( | int | i | ) | const |
◆ getObjectName()
| std::string eve::map::Map::getObjectName | ( | int | i | ) | const |
◆ getObjectProperty()
| std::string eve::map::Map::getObjectProperty | ( | int | objectIndex, |
| std::string_view | name, | ||
| std::string | defaultValue = {} |
||
| ) | const |
Read the owning canonical text projection of an object's custom property.
- 参数
-
objectIndex Transient object-cache index. name Exact property name borrowed only for this call. defaultValue Owning default value returned when the object or property is absent.
- 返回
- Owning property text or the supplied default; no reference into the reloadable cache escapes.
- 备注
- Tiled scalar values are projected to canonical text at load admission. Consumers parse and validate domain-specific values before publishing gameplay state. Duplicate names keep the first value. @thread Call on the Map module's owning simulation thread. @reentrancy No callbacks are invoked.
引用了 defaultValue, name , 以及 properties.
◆ getObjectPropertyCount()
| int eve::map::Map::getObjectPropertyCount | ( | int | objectIndex | ) | const |
Return the number of sorted custom properties on one cached object.
- 参数
-
objectIndex Transient object-cache index.
- 返回
- Property count, or zero for an invalid object index.
- 备注
- The count and subsequent property indices are invalidated whenever the object cache is replaced. @thread Call on the Map module's owning simulation thread. @reentrancy No callbacks are invoked.
引用了 properties.
◆ getObjectPropertyName()
| std::string eve::map::Map::getObjectPropertyName | ( | int | objectIndex, |
| int | propertyIndex | ||
| ) | const |
Return an owning custom-property name at deterministic sorted position.
- 参数
-
objectIndex Transient object-cache index. propertyIndex Property position in [0, getObjectPropertyCount()).
- 返回
- Owning property name, or an empty string for an invalid index.
- 备注
- Property indices are transient; persist property names and stable object names instead. @thread Call on the Map module's owning simulation thread. @reentrancy No callbacks are invoked.
引用了 properties.
◆ getObjectType()
| std::string eve::map::Map::getObjectType | ( | int | i | ) | const |
◆ getObjectWidth()
◆ getObjectX()
◆ getObjectY()
◆ hasObjectProperty()
| bool eve::map::Map::hasObjectProperty | ( | int | objectIndex, |
| std::string_view | name | ||
| ) | const |
Query whether a cached object declares an exact custom-property name.
- 参数
-
objectIndex Transient object-cache index. name Property name borrowed only for this call.
- 返回
- True only for a valid object index with that property. @thread Call on the Map module's owning simulation thread. @reentrancy No callbacks are invoked.
引用了 name.
◆ lastDualGridError()
◆ loadFromFile()
| int eve::map::Map::loadFromFile | ( | const std::string & | path | ) |
Same transactional replacement as newLayerFromFile, returning the published layer count.
- 返回
- Positive published layer count, or zero with the previous map preserved on failure.
引用了 eve::map::loadMapFile(), path , 以及 setObjects().
◆ loadFromFileWithObjectContract()
| eve::Result< int > eve::map::Map::loadFromFileWithObjectContract | ( | const std::string & | path, |
| std::string_view | contractJson | ||
| ) |
Parse a map and validate its objects before atomically publishing it.
- 参数
-
path Map JSON path borrowed for this call. contractJson Versioned eve.map.object-contractJSON borrowed for this call.
- 返回
- Published layer count, or a structured failure with the prior map preserved. @ownership Published layers remain module-owned; path and contract text are not retained. @thread Call on the Map module's owning simulation thread. @reentrancy No callbacks or scripts are invoked.
引用了 eve::Applied, error, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::map::loadMapFile(), eve::ParseError, path, eve::Status::success(), eve::Result< T >::success() , 以及 eve::map::validateMapObjects().
◆ loadFromTextWithObjectContract()
| eve::Result< int > eve::map::Map::loadFromTextWithObjectContract | ( | std::string_view | mapJson, |
| std::string_view | contractJson | ||
| ) |
Parse map JSON text and atomically publish it after object-contract admission.
- 参数
-
mapJson Candidate map document borrowed for this call. contractJson Versioned object contract borrowed for this call.
- 返回
- Published layer count, or a structured failure with the prior map preserved. @ownership Candidate text is not retained; successful layers remain module-owned. @thread Call on the Map module's owning simulation thread. @reentrancy No callbacks or scripts are invoked.
引用了 eve::Applied, error, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::map::loadMapText(), eve::ParseError, eve::Status::success(), eve::Result< T >::success() , 以及 eve::map::validateMapObjects().
◆ Module_REG()
| eve::map::Map::Module_REG | ( | Map | ) |
◆ newFov()
◆ newFovSize()
| Fov * eve::map::Map::newFovSize | ( | int | mapW, |
| int | mapH | ||
| ) |
◆ newFovVolume()
| Fov * eve::map::Map::newFovVolume | ( | int | mapW, |
| int | mapH, | ||
| int | depth | ||
| ) |
◆ newLayer()
Creates a layer. @ownership Caller deletes unless documented otherwise.
引用了 eve::map::TileLayer::createLayer(), tileH , 以及 tileW.
◆ newLayerFromFile()
| TileLayer * eve::map::Map::newLayerFromFile | ( | const std::string & | path | ) |
Load map JSON (Tiled-compatible subset or EVEngine simplified format). Creates one TileLayer per tile layer; returns the first (nullptr on failure). Refreshes the module object cache from objectgroup layers.
- 备注
- Replacement is transactional at the module boundary: failure preserves the current layers and object cache; success clears and hides replaced layers before publishing the new cache. Returned layers are module-owned and remain borrowed until a later successful replacement or module teardown. @thread Call on the Map module's owning simulation thread. @reentrancy No callbacks are invoked.
引用了 eve::map::loadMapFile(), path , 以及 setObjects().
◆ newPathfinder()
| Pathfinder * eve::map::Map::newPathfinder | ( | TileLayer * | layer | ) |
◆ newPathfinderSize()
| Pathfinder * eve::map::Map::newPathfinderSize | ( | int | mapW, |
| int | mapH | ||
| ) |
◆ pollConfigs()
| int eve::map::Map::pollConfigs | ( | ) |
◆ publishCollision()
| int eve::map::Map::publishCollision | ( | TileLayer * | layer | ) |
Generate merged collision from non-walkable tile metadata and notify adapters.
引用了 layer, eve::map::Orthogonal, shape, eve::map::tileGid(), tiles, v, x , 以及 y.
◆ render()
| void eve::map::Map::render | ( | graphics::Graphics * | gfx | ) |
◆ resolveDualGrid()
Dual-grid resolve: paint logic (filled/empty), fill display with 15-tile autotiles on a half-offset grid. See DualGrid.h. filledGid 0 = any non-zero logic cell counts as filled.
引用了 ok , 以及 eve::map::resolveDualGrid().
◆ resolveDualGridFilled()
Resolve dual grid filled.
引用了 eve::map::DualGridOptions::filledGid, ok , 以及 eve::map::resolveDualGrid().
◆ setObjects()
| void eve::map::Map::setObjects | ( | std::vector< MapObject > | objects | ) |
Replace object cache (used by load / hot reload).
被这些函数引用 loadFromFile() , 以及 newLayerFromFile().
◆ update()
| void eve::map::Map::update | ( | float | dt | ) |
Updates .
引用了 eve::map::TileConfigSystem::poll() , 以及 eve::map::TileRenderSystem::update().
该类的文档由以下文件生成:
Public 成员函数 继承自