GFRegionMap2D¶
API Reference / Standard / 类索引
- 路径:
addons/gf/standard/foundation/math/gf_region_map_2d.gd - 模块:
Standard - 继承:
RefCounted - API:
public - 类别:运行时服务 (
runtime_service) - 首次版本:
3.17.0
通用二维区域分块数据映射。 按固定区域尺寸管理格子数据,并追踪发生变化的区域,适合大地图、编辑器批处理或局部保存。
成员概览¶
| 类型 | 名称 | 签名 |
|---|---|---|
| 属性 | region_size |
var region_size: Vector2i = Vector2i(32, 32) |
| 属性 | duplicate_values |
var duplicate_values: bool = true |
| 方法 | get_region_key_for_cell |
func get_region_key_for_cell(cell: Vector2i) -> Vector2i: |
| 方法 | set_cell |
func set_cell(cell: Vector2i, value: Variant) -> void: |
| 方法 | get_cell |
func get_cell(cell: Vector2i, default_value: Variant = null) -> Variant: |
| 方法 | erase_cell |
func erase_cell(cell: Vector2i) -> bool: |
| 方法 | has_cell |
func has_cell(cell: Vector2i) -> bool: |
| 方法 | get_region_cells |
func get_region_cells(region_key: Vector2i) -> Array[Vector2i]: |
| 方法 | get_region_snapshot |
func get_region_snapshot(region_key: Vector2i) -> Dictionary: |
| 方法 | get_region_keys |
func get_region_keys() -> Array[Vector2i]: |
| 方法 | get_dirty_region_keys |
func get_dirty_region_keys() -> Array[Vector2i]: |
| 方法 | clear_dirty |
func clear_dirty(region_key: Variant = null) -> void: |
| 方法 | clear |
func clear() -> void: |
| 方法 | get_debug_snapshot |
func get_debug_snapshot() -> Dictionary: |
属性¶
region_size¶
- API:
public
每个区域包含的格子尺寸。
duplicate_values¶
- API:
public
读写值时是否复制集合类型。
方法¶
get_region_key_for_cell¶
- API:
public
根据格坐标获取区域键。
参数:
| 名称 | 说明 |
|---|---|
cell |
格坐标。 |
返回:区域键。
set_cell¶
- API:
public
设置格子数据。
参数:
| 名称 | 说明 |
|---|---|
cell |
格坐标。 |
value |
格子数据。 |
结构:
value: Variant cell value stored in the region map.
get_cell¶
- API:
public
获取格子数据。
参数:
| 名称 | 说明 |
|---|---|
cell |
格坐标。 |
default_value |
缺失时返回的默认值。 |
返回:格子数据。
结构:
default_value: Variant fallback value returned when the cell is missing.return: Variant cell value or default_value.
erase_cell¶
- API:
public
移除格子数据。
参数:
| 名称 | 说明 |
|---|---|
cell |
格坐标。 |
返回:移除成功返回 true。
has_cell¶
- API:
public
检查格子是否存在。
参数:
| 名称 | 说明 |
|---|---|
cell |
格坐标。 |
返回:存在返回 true。
get_region_cells¶
- API:
public
获取区域内全部格子坐标。
参数:
| 名称 | 说明 |
|---|---|
region_key |
区域键。 |
返回:格坐标列表。
get_region_snapshot¶
- API:
public
获取区域数据快照。
参数:
| 名称 | 说明 |
|---|---|
region_key |
区域键。 |
返回:区域数据字典。
结构:
return: Dictionary mapping Vector2i cells to stored cell values.
get_region_keys¶
- API:
public
获取已存在的区域键。
返回:区域键列表。
get_dirty_region_keys¶
- API:
public
获取脏区域键。
返回:脏区域键列表。
clear_dirty¶
- API:
public
清理脏区域标记。
参数:
| 名称 | 说明 |
|---|---|
region_key |
指定区域;为 null 时清空全部。 |
结构:
region_key: Variant null or Vector2i region key.
clear¶
- API:
public
清空全部区域数据。
get_debug_snapshot¶
- API:
public
获取调试快照。
返回:调试快照字典。
结构:
return: Dictionary with region_size, region_count, and dirty_region_count.