feat: add C6 special interactions

This commit is contained in:
goose
2026-10-03 12:54:52 -04:00
parent 68d35bf94b
commit 7e93cf0b5b
16 changed files with 439 additions and 1 deletions
+30
View File
@@ -3,6 +3,8 @@ extends RefCounted
const TurnResolverType = preload("res://scripts/domain/turn_resolver.gd")
const InteractionResolverType = preload("res://scripts/domain/interaction_resolver.gd")
const TrapEngineType = preload("res://scripts/domain/world/trap_engine.gd")
const SpecialInteractionsType = preload("res://scripts/domain/world/special_interactions.gd")
var player: ActorState
# Legacy renderer/game seams alias the active floor aggregate until their consumers
@@ -12,6 +14,7 @@ var enemies: Dictionary[StringName, ActorState]
var map: GridMapState
var visible_cells: Dictionary[Vector2i, bool] = {}
var explored_cells: Dictionary[Vector2i, bool] = {}
var content_catalog: ContentCatalog
var exit_reached := false
func _init(new_map: GridMapState, new_player: ActorState, new_enemies: Dictionary[StringName, ActorState]) -> void:
@@ -36,6 +39,10 @@ func set_floor_state(new_floor_state: FloorState) -> void:
update_exploration()
func get_context_target() -> StringName:
if content_catalog != null:
var special_target := SpecialInteractionsType.prompt_target(self)
if not special_target.is_empty():
return special_target
if exit_reached:
return &"exit_reached"
if map.get_cell(player.cell) == GridMapState.CellKind.STAIRS:
@@ -51,11 +58,34 @@ func get_context_target() -> StringName:
return &""
func try_player_action(direction: Vector2i) -> Array[TurnResult]:
# A visible secret can be found before crossing its wall; discovery consumes
# the attempted exploration action so the revelation is journaled distinctly.
if content_catalog != null:
var secret_results := SpecialInteractionsType.reveal_visible(self, visible_cells)
if not secret_results.is_empty():
update_exploration()
return secret_results
var results := TurnResolverType.resolve_player_action(self, direction)
if content_catalog != null and results.size() == 1 and results[0].kind == &"moved":
var discoveries := TrapEngineType.discover_visible(floor_state, player, visible_cells, content_catalog)
if not discoveries.is_empty():
results = discoveries + results
update_exploration()
return results
update_exploration()
return results
func try_interact() -> Array[TurnResult]:
if content_catalog != null:
var special_target := SpecialInteractionsType.prompt_target(self)
if special_target == &"trap":
var trap_cell := SpecialInteractionsType.trap_cell_at_or_adjacent(self)
var outcome := TrapEngineType.disarm(floor_state, player, trap_cell, content_catalog)
var kind: StringName = &"trap_disarmed" if bool(outcome.get("success", false)) else &"trap_disarm_failed"
var message := "You disarm the trap." if bool(outcome.get("success", false)) else "You fail to disarm the trap."
return [TurnResult.new(player.id, kind, player.cell, trap_cell, &"", 0, message, {"trap_id": outcome.get("trap_id", &"")})]
if special_target in [&"shrine", &"quest_board"]:
return [SpecialInteractionsType.resolve(self)]
var results := InteractionResolverType.resolve(self)
if results[0].kind != &"nothing_to_interact":
update_exploration()