Add BigRock: 2×2 mineable boulder with full mining/path/save support

A new entity for multi-tile rock formations. Same duck-typed contract as
single-tile Rock so MineProvider scans both transparently via World.rocks.

Differences from Rock:
  • Occupies a 2×2 footprint anchored at origin_tile (top-left).
  • Renders a single 32×32 Sprite2D drawn from the FG_Grasslands_Spring 2×2
    cluster sprites at (22, 3) brown and (30, 3) gray.
  • Blocks pathfinding on all four footprint tiles — pawns route around it.
  • MineProvider asks `rock.approach_tile_for(pawn.tile)` for the walk
    destination, so the pawn stands beside the boulder instead of trying to
    path into the blocked footprint. Rock returns its own tile (walkable);
    BigRock picks the nearest walkable perimeter neighbour.
  • Mining takes 480 ticks (4× Rock) and drops 4 stone, one per footprint tile.

All init work happens in setup() rather than _ready(): the calling pattern is
`add_child(big); big.setup(origin)`, and _ready fires inside add_child with
origin_tile still at its zero default — anything reading origin_tile from
_ready would stamp the pathfinder at the wrong tile.

Wired through SaveSystem: factory preload, spawn-priority tier 0 (same as
Rock — static structures spawn before pawns), and a `&"big_rock"` factory.

World seed adds two demo boulders near the small-rock cluster
(65, 58) + (56, 64) so the visual contrast is on-screen from boot.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
megaproxy 2026-05-12 14:34:24 +01:00
parent 725d3fb701
commit 938e871bf1
6 changed files with 292 additions and 4 deletions

View file

@ -28,6 +28,7 @@ const SAVE_VERSION: int = 2
const _PAWN_SCENE: PackedScene = preload("res://scenes/pawn/pawn.tscn")
const _TREE_SCENE: PackedScene = preload("res://scenes/entities/tree.tscn")
const _ROCK_SCENE: PackedScene = preload("res://scenes/entities/rock.tscn")
const _BIG_ROCK_SCENE: PackedScene = preload("res://scenes/entities/big_rock.tscn")
const _ITEM_SCENE: PackedScene = preload("res://scenes/entities/item.tscn")
const _WALL_SCENE: PackedScene = preload("res://scenes/entities/wall.tscn")
const _FLOOR_SCENE: PackedScene = preload("res://scenes/entities/floor.tscn")
@ -314,6 +315,7 @@ func _collect_entities() -> Array:
const _SPAWN_PRIORITY: Dictionary = {
&"tree": 0,
&"rock": 0,
&"big_rock": 0,
&"wall": 0,
&"floor": 0,
&"door": 1,
@ -348,6 +350,7 @@ func _sort_by_spawn_priority(entity_dicts: Array) -> Array:
func _register_factories() -> void:
_factories[&"tree"] = _spawn_tree
_factories[&"rock"] = _spawn_rock
_factories[&"big_rock"] = _spawn_big_rock
_factories[&"item"] = _spawn_item
_factories[&"wall"] = _spawn_wall
_factories[&"floor"] = _spawn_floor
@ -387,6 +390,14 @@ func _spawn_rock(world_scene: Node, d: Dictionary) -> void:
ent.queue_redraw()
func _spawn_big_rock(world_scene: Node, d: Dictionary) -> void:
var ent = _BIG_ROCK_SCENE.instantiate()
world_scene.add_child(ent)
ent.setup(Vector2i(int(d.get("origin_x", 0)), int(d.get("origin_y", 0))))
ent.mine_progress = int(d.get("mine_progress", 0))
ent.queue_redraw()
func _spawn_item(world_scene: Node, d: Dictionary) -> void:
var ent = _ITEM_SCENE.instantiate()
world_scene.add_child(ent)