feat: add 30x20 demo map and chest interaction
This commit is contained in:
@@ -22,7 +22,10 @@ func get_context_target() -> StringName:
|
||||
return &"exit_reached"
|
||||
if map.get_cell(player.cell) == GridMapState.CellKind.STAIRS:
|
||||
return &"stairs"
|
||||
for direction in [Vector2i.UP, Vector2i.RIGHT, Vector2i.DOWN, Vector2i.LEFT, Vector2i(1, -1), Vector2i(1, 1), Vector2i(-1, 1), Vector2i(-1, -1)]:
|
||||
for direction in InteractionResolverType.TARGET_OFFSETS:
|
||||
if map.get_cell(player.cell + direction) == GridMapState.CellKind.CHEST:
|
||||
return &"chest"
|
||||
for direction in InteractionResolverType.TARGET_OFFSETS:
|
||||
if map.get_cell(player.cell + direction) == GridMapState.CellKind.CLOSED_DOOR:
|
||||
return &"closed_door"
|
||||
return &""
|
||||
|
||||
@@ -25,8 +25,8 @@ func is_inside(cell: Vector2i) -> bool:
|
||||
|
||||
func is_walkable(cell: Vector2i) -> bool:
|
||||
var kind := get_cell(cell)
|
||||
return kind == CellKind.FLOOR or kind == CellKind.CHEST or kind == CellKind.STAIRS
|
||||
return kind == CellKind.FLOOR or kind == CellKind.STAIRS
|
||||
|
||||
func is_opaque(cell: Vector2i) -> bool:
|
||||
var kind := get_cell(cell)
|
||||
return kind == CellKind.WALL or kind == CellKind.CLOSED_DOOR
|
||||
return kind == CellKind.WALL or kind == CellKind.CLOSED_DOOR or kind == CellKind.CHEST
|
||||
|
||||
@@ -24,7 +24,14 @@ static func resolve(state: GameState) -> Array[TurnResult]:
|
||||
TurnResolverType.append_enemy_response(state, results)
|
||||
return results
|
||||
|
||||
var door_cell := _find_closed_door(state)
|
||||
var chest_cell := _find_cell_of_kind(state, GridMapState.CellKind.CHEST)
|
||||
if chest_cell.x >= 0:
|
||||
state.map.set_cell(chest_cell, GridMapState.CellKind.FLOOR)
|
||||
results.append(TurnResultType.new(state.player.id, &"chest_opened", state.player.cell, chest_cell, &"", 0, "You open the chest."))
|
||||
TurnResolverType.append_enemy_response(state, results)
|
||||
return results
|
||||
|
||||
var door_cell := _find_cell_of_kind(state, GridMapState.CellKind.CLOSED_DOOR)
|
||||
if door_cell.x >= 0:
|
||||
state.map.set_cell(door_cell, GridMapState.CellKind.FLOOR)
|
||||
results.append(TurnResultType.new(state.player.id, &"door_opened", state.player.cell, door_cell, &"", 0, "You open the door."))
|
||||
@@ -34,9 +41,9 @@ static func resolve(state: GameState) -> Array[TurnResult]:
|
||||
results.append(TurnResultType.new(state.player.id, &"nothing_to_interact", state.player.cell, state.player.cell, &"", 0, "Nothing to interact with."))
|
||||
return results
|
||||
|
||||
static func _find_closed_door(state: GameState) -> Vector2i:
|
||||
static func _find_cell_of_kind(state: GameState, kind: GridMapState.CellKind) -> Vector2i:
|
||||
for offset in TARGET_OFFSETS:
|
||||
var cell := state.player.cell + offset
|
||||
if state.map.get_cell(cell) == GridMapState.CellKind.CLOSED_DOOR:
|
||||
if state.map.get_cell(cell) == kind:
|
||||
return cell
|
||||
return Vector2i(-1, -1)
|
||||
|
||||
Reference in New Issue
Block a user