feat(boss): EnemyManager 外部驱动移动接口(register/unregister_external_mover + set_entity_pos + 跳过)
This commit is contained in:
@@ -25,6 +25,7 @@ var _next_entity_id: int = 1
|
|||||||
var _visible_flags: PackedByteArray = PackedByteArray()
|
var _visible_flags: PackedByteArray = PackedByteArray()
|
||||||
|
|
||||||
var _offscreen_sep_counter: int = 0
|
var _offscreen_sep_counter: int = 0
|
||||||
|
var _external_movers: Dictionary = {} # entity_id → true:移动由外部系统(BossManager)接管,_gd_update_movement 跳过
|
||||||
var _cs_node: Node = null
|
var _cs_node: Node = null
|
||||||
|
|
||||||
## ADR-A4:精英寻路。W1–14 杂鱼永远 Boid;W15+ Elite/Boss 按需挂 NavigationAgent2D,
|
## ADR-A4:精英寻路。W1–14 杂鱼永远 Boid;W15+ Elite/Boss 按需挂 NavigationAgent2D,
|
||||||
@@ -96,9 +97,13 @@ func _update_spatial_grid() -> void:
|
|||||||
func _gd_update_movement(delta: float) -> void:
|
func _gd_update_movement(delta: float) -> void:
|
||||||
var player_pos: Vector2 = PlayerManager.get_position()
|
var player_pos: Vector2 = PlayerManager.get_position()
|
||||||
var has_pf: bool = not _pathfinders.is_empty() # 无精英时零额外开销
|
var has_pf: bool = not _pathfinders.is_empty() # 无精英时零额外开销
|
||||||
|
var has_ext: bool = not _external_movers.is_empty()
|
||||||
for i in _active_count:
|
for i in _active_count:
|
||||||
if has_pf and _pathfinders.has(_slot_entity_map.get(i, -1)):
|
var eid_i: int = _slot_entity_map.get(i, -1)
|
||||||
|
if has_pf and _pathfinders.has(eid_i):
|
||||||
continue # 寻路精英由 _update_pathfinding_movement 处理
|
continue # 寻路精英由 _update_pathfinding_movement 处理
|
||||||
|
if has_ext and _external_movers.has(eid_i):
|
||||||
|
continue # Boss 等外部驱动实体由 BossManager 移动
|
||||||
var base: int = i * ENEMY_STRIDE
|
var base: int = i * ENEMY_STRIDE
|
||||||
var ex: float = _data[base + 0]
|
var ex: float = _data[base + 0]
|
||||||
var ey: float = _data[base + 1]
|
var ey: float = _data[base + 1]
|
||||||
@@ -226,6 +231,22 @@ func get_pos_by_id(entity_id: int) -> Vector2:
|
|||||||
var base: int = slot * ENEMY_STRIDE
|
var base: int = slot * ENEMY_STRIDE
|
||||||
return Vector2(_data[base + 0], _data[base + 1])
|
return Vector2(_data[base + 0], _data[base + 1])
|
||||||
|
|
||||||
|
## 外部系统(BossManager)接管移动:注册后 _gd_update_movement 跳过该实体
|
||||||
|
func register_external_mover(entity_id: int) -> void:
|
||||||
|
_external_movers[entity_id] = true
|
||||||
|
|
||||||
|
func unregister_external_mover(entity_id: int) -> void:
|
||||||
|
_external_movers.erase(entity_id)
|
||||||
|
|
||||||
|
## 外部系统写回实体坐标(BossManager 驱动移动/冲刺用)
|
||||||
|
func set_entity_pos(entity_id: int, pos: Vector2) -> void:
|
||||||
|
var slot: int = _entity_index_map.get(entity_id, -1)
|
||||||
|
if slot < 0:
|
||||||
|
return
|
||||||
|
var base: int = slot * ENEMY_STRIDE
|
||||||
|
_data[base + 0] = pos.x
|
||||||
|
_data[base + 1] = pos.y
|
||||||
|
|
||||||
## S1 完整伤害接口:从 DamageContextPool 取 context,计算公式后扣 HP
|
## S1 完整伤害接口:从 DamageContextPool 取 context,计算公式后扣 HP
|
||||||
## 公式(S1 简化):final_dmg = base_damage * mult
|
## 公式(S1 简化):final_dmg = base_damage * mult
|
||||||
## S4 起补充 resistance / armor(参见 combat_mechanics_depth.md §4)
|
## S4 起补充 resistance / armor(参见 combat_mechanics_depth.md §4)
|
||||||
@@ -321,6 +342,7 @@ func reset() -> void:
|
|||||||
_visible_flags.fill(0)
|
_visible_flags.fill(0)
|
||||||
_entity_index_map.clear()
|
_entity_index_map.clear()
|
||||||
_slot_entity_map.clear()
|
_slot_entity_map.clear()
|
||||||
|
_external_movers.clear()
|
||||||
_next_entity_id = 1
|
_next_entity_id = 1
|
||||||
# ADR-A4:释放所有寻路精英节点
|
# ADR-A4:释放所有寻路精英节点
|
||||||
for eid in _pathfinders.keys():
|
for eid in _pathfinders.keys():
|
||||||
|
|||||||
Reference in New Issue
Block a user