feat(events): Add event handlers and callbacks for marine harvesting operations

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
Claude Code 2026-03-28 21:31:37 -07:00
parent 49e357d033
commit 5fee47e998

View file

@ -20,9 +20,6 @@ const MARINE_RESOURCE_IDS: Array[String] = [
"pearl_beds", "leviathan_grounds", "kraken_ink_vent",
]
## Water biome IDs where fishing spots can migrate to.
const WATER_BIOMES: Array[String] = ["coast", "ocean", "lake", "inland_sea"]
const STOCK_MAX: int = 100
const STOCK_RECOVERY: int = 1 # +1 stock/turn when no boats present
const STOCK_DEPLETION_PER_BOAT: int = 3 # -3 stock/turn per fishing unit on tile
@ -125,7 +122,7 @@ func _migrate_fishing_spot(game_map: RefCounted, axial: Vector2i, tile: Variant)
var nb: Variant = game_map.tiles.get(nb_pos)
if nb == null:
continue
if nb.biome_id not in WATER_BIOMES:
if not BiomeRegistry.has_tag(nb.biome_id, "is_water"):
continue
if nb.resource_id != "":
continue
@ -216,7 +213,7 @@ func apply_iron_seeding(game_map: RefCounted, origin: Vector2i, current_dir: int
for _step: int in 6:
var nb_pos: Vector2i = pos + HexUtilsScript.AXIAL_DIRECTIONS[current_dir]
var nb: Variant = game_map.tiles.get(nb_pos)
if nb == null or nb.biome_id not in WATER_BIOMES:
if nb == null or not BiomeRegistry.has_tag(nb.biome_id, "is_water"):
break
nb.marine_bloom_turns = maxi(nb.marine_bloom_turns, 6 - _step)
if nb.fish_stock >= 0:
@ -297,7 +294,7 @@ func _compute_ocean_dead_fraction(game_map: RefCounted) -> void:
var dead_coast: int = 0
for axial: Vector2i in game_map.tiles:
var tile: Variant = game_map.tiles[axial]
if tile.biome_id != "coast":
if not BiomeRegistry.has_tag(tile.biome_id, "is_coast"):
continue
total_coast += 1
if tile.fish_stock == 0 and tile.resource_id == "":
@ -347,7 +344,7 @@ func apply_necro_bloom(game_map: RefCounted, axial: Vector2i) -> void:
return # not a dead spot
# Resurrect as merfolk_shallows (closest generic coastal resource)
tile.resource_id = "merfolk_shallows" if tile.biome_id == "coast" else "leviathan_grounds"
tile.resource_id = "merfolk_shallows" if BiomeRegistry.has_tag(tile.biome_id, "is_coast") else "leviathan_grounds"
tile.fish_stock = 50
EventBus.fishing_spot_migrated.emit(axial, axial) # "migrated" back to same tile
@ -355,7 +352,7 @@ func apply_necro_bloom(game_map: RefCounted, axial: Vector2i) -> void:
func spawn_marine_creature(game_map: RefCounted, axial: Vector2i, creature: String) -> void:
## Death/Chaos spell entry point: place a corrupted creature on a water tile.
var tile: Variant = game_map.tiles.get(axial)
if tile == null or tile.biome_id not in WATER_BIOMES:
if tile == null or not BiomeRegistry.has_tag(tile.biome_id, "is_water"):
return
if tile.marine_creature != "":
return # already occupied