extends RefCounted ## The resource economy: ResourceStore rules (pouch capacity, deposit, paying pouch first then ## shed, all-or-nothing, validation), FarmState keeping materials, gather points, and upgrades ## through JSON, and on the real farm (FarmSim stepped by hand): the gather points' layout, ## gathering by day only (charges, rooted, cancelled by letting go / a hit / fear, a full pouch, ## nightfall), the shed drop-off, overnight regrowth, retry restoring the morning's materials, ## patching's straw cost, buying the Straw Stuffing upgrade from the workbench's menu, Alien ## Goop (#4): dropped only by killed Aliens (thieves) at a config-tunable rate, credited like a ## gathered material, stealable from the shed once it's the stock on top, and surviving retry, ## and hidden/reveal shop items (#5): an item flagged "hidden" shows only "?" and can't be bought ## until enough Alien Goop has been collected in total, then shows and buys normally. const P := CampaignController.Phase const DT := 1.0 / 60.0 func run(r: GameTestRunner) -> void: _store(r) _state(r) _goop_persistence(r) await _hidden_items(r) var farm := (load("res://game/scenes/farm.tscn") as PackedScene).instantiate() as Node3D r.root.add_child(farm) await r.process_frame await r.physics_frame var sim := farm.get_node("FarmSim") as FarmSim sim.set_physics_process(false) sim.waves.enabled = false var player := farm.get_node("Player") as PlayerCharacter _layout(r, sim) _gathering(r, sim, player) _deposit_and_night(r, sim, player) _patch_cost(r, sim) _stuffing(r, sim, player) _goop_drops(r, sim) farm.queue_free() await r.process_frame func _store(r: GameTestRunner) -> void: var s := ResourceStore.new() r.check(s.add_to_pouch("wood", 10) == 10 and s.add_to_pouch("straw", 10) == 5 and s.pouch_total() == 15 and s.pouch_room() == 0, "the pouch takes only what fits (15 units across materials)") var moved := s.deposit() r.check(moved == {"wood": 10, "straw": 5} and s.pouch_total() == 0 and s.shed["wood"] == 10, "deposit moves the whole pouch into the shed") s = ResourceStore.new() s.shed["wood"] = 3 s.pouch["wood"] = 2 r.check(s.available("wood") == 5 and s.pay({"wood": 4}) and s.pouch["wood"] == 0 and s.shed["wood"] == 1, "costs are paid from the pouch first, then the shed") r.check(not s.pay({"wood": 2}) and s.shed["wood"] == 1 and s.missing({"wood": 2}) == {"wood": 1}, "a cost that can't be met pays nothing and says what's missing") s.shed["straw"] = 5 r.check(not s.pay({"straw": 1, "scrap": 3}) and s.shed["straw"] == 5, "a cost is all-or-nothing across materials") r.check(ResourceStore.describe({"straw": 2, "wood": 6}) == "6 wood, 2 straw", "costs read in material order") s.pouch["scrap"] = 4 var back := ResourceStore.from_dict(JSON.parse_string(JSON.stringify(s.to_dict()))) r.check(back != null and back.to_dict() == s.to_dict(), "the store round-trips through JSON") var bad := { "a negative amount": func(d: Dictionary) -> void: d["shed"]["wood"] = -1, "an unknown material": func(d: Dictionary) -> void: d["pouch"]["gold"] = 1, "an overfull pouch": func(d: Dictionary) -> void: d["pouch"]["wood"] = 99, "a missing part": func(d: Dictionary) -> void: d.erase("shed"), } for label: String in bad: var d := s.to_dict() d["shed"] = (d["shed"] as Dictionary).duplicate() d["pouch"] = (d["pouch"] as Dictionary).duplicate() (bad[label] as Callable).call(d) r.check(ResourceStore.from_dict(d) == null, "the store rejects %s" % label) func _state(r: GameTestRunner) -> void: var cfg := (load("res://game/resources/game_config.tres") as GameConfig).duplicate() as GameConfig var s := FarmState.create(cfg) r.check(s.resources.shed == {"wood": cfg.start_wood, "scrap": cfg.start_scrap, "straw": cfg.start_straw, "alien_goop": cfg.start_alien_goop} and s.resources.pouch_capacity == cfg.pouch_capacity, "a new farm starts with the configured stock and pouch size (Alien Goop a 4th material, starting at 0)") s.resources.add_to_pouch("scrap", 3) s.resources.add_to_pouch("alien_goop", 2) s.gather_charges = {"Snag": 1, "Wreck": 0} s.upgrades = {"straw_stuffing": 1} var d := s.to_dict() var back := FarmState.from_dict(JSON.parse_string(JSON.stringify(d))) r.check(back != null and back.to_dict() == d, "FarmState keeps materials (including Alien Goop), used gather points, and upgrades through JSON") d["gather_charges"] = {"Snag": -2} r.check(FarmState.from_dict(d) == null, "FarmState rejects negative gather charges") ## Alien Goop round-trips like the other materials: a retry discards what was gained since the ## morning (same mechanic _deposit_and_night checks for wood/scrap below), and the morning ## snapshot itself (what SaveGame writes) survives a JSON round-trip. func _goop_persistence(r: GameTestRunner) -> void: var cfg := (load("res://game/resources/game_config.tres") as GameConfig).duplicate() as GameConfig var c := r.make_campaign(cfg) var morning := c.state.to_dict() c.begin_day() c.state.resources.add_to_pouch("alien_goop", 5) c.state.resources.shed["alien_goop"] = 3 c.advance_phase() # DAY -> DUSK c.advance_phase() # DUSK -> NIGHT c.retry_night() r.check(c.state.phase == P.MORNING and c.state.resources.to_dict() == morning["resources"], "a retry discards Alien Goop gained since the morning, same as the other materials") var back := FarmState.from_dict(JSON.parse_string(JSON.stringify(morning))) r.check(back != null and back.resources.shed.get("alien_goop", -1) == 0, "the morning snapshot (what's saved) round-trips Alien Goop through JSON") ## Hidden shop items (#5): an item definition can set "hidden": true (optionally its own ## "reveal_goop", else GameConfig.hidden_reveal_goop) so the workbench shows only a bare "?" (no ## name, text, or cost) and refuses the purchase (blocker()/buy(), so this also covers the co-op ## buy-request path) until Upgrades.goop_collected() reaches the threshold; then it shows and buys ## normally for its defined cost. No real upgrade ships hidden yet (#7/#8 will add Alien Ray and ## Radar), so this flags a duplicated long_range/sticky_tar to exercise the mechanism. func _hidden_items(r: GameTestRunner) -> void: var seed_cfg := (load("res://game/resources/game_config.tres") as GameConfig).duplicate(true) as GameConfig var c := r.make_campaign(seed_cfg) var cfg := c.config # what blocker()/buy()/refresh() actually read (CampaignController._ready duplicates it) cfg.upgrades = cfg.upgrades.duplicate(true) cfg.upgrades["long_range"] = cfg.upgrades["long_range"].duplicate(true) cfg.upgrades["long_range"]["hidden"] = true cfg.hidden_reveal_goop = 5 var s := c.state c.begin_day() s.resources.shed = cfg.costs["long_range"].duplicate() r.check(Upgrades.goop_collected(s) == 0 and not Upgrades.revealed(s, cfg, "long_range"), "a hidden item starts undiscovered (0 Alien Goop collected)") r.check(Upgrades.blocker(c, "long_range") == "Not discovered yet", "its blocker reason doesn't describe it") r.check(Upgrades.buy(c, "long_range") == "Long-range defenses: not discovered yet" and not Upgrades.owned(s, "long_range"), "buy() refuses a hidden item below threshold too (also covers the co-op buy-request path)") var panel := UpgradePanel.new() r.root.add_child(panel) await r.process_frame panel.setup(c, null, null) panel.refresh() var row := panel._rows["long_range"] as Button r.check(row.text == "?" and row.disabled, "the panel shows a bare '?' for a hidden item, disabled") s.record_event("gathered_alien_goop", 4) r.check(Upgrades.goop_collected(s) == 4 and not Upgrades.revealed(s, cfg, "long_range"), "still hidden one goop short of the threshold") panel.refresh() r.check(row.text == "?", "still just '?' one goop short") s.record_event("gathered_alien_goop", 1) r.check(Upgrades.goop_collected(s) == 5 and Upgrades.revealed(s, cfg, "long_range"), "revealed once goop collected reaches the threshold") r.check(Upgrades.blocker(c, "long_range") == "", "no longer blocked once revealed (affordable, daytime)") panel.refresh() r.check(row.text.contains("Long-range defenses") and row.text.contains("Turrets reach 30% farther") and not row.disabled, "the panel shows the normal name/text/cost once revealed: '%s'" % row.text) var msg := Upgrades.buy(c, "long_range") r.check(Upgrades.owned(s, "long_range") and msg.contains("done:"), "revealed, it buys normally for its defined cost") panel.queue_free() var back := FarmState.from_dict(JSON.parse_string(JSON.stringify(s.to_dict()))) r.check(back != null and Upgrades.revealed(back, cfg, "long_range") and Upgrades.owned(back, "long_range"), "reveal and ownership both survive a save (JSON) round-trip") # A second item, with its own reveal_goop: a completed night's goop (night_log, via totals()) # and the current cycle's own (night_events) both count toward it, and a retry (which restores # the morning snapshot) drops only the failed night's own, keeping the completed night's. cfg.upgrades["sticky_tar"] = cfg.upgrades["sticky_tar"].duplicate(true) cfg.upgrades["sticky_tar"]["hidden"] = true cfg.upgrades["sticky_tar"]["reveal_goop"] = 3 s.night_events.clear() # isolate night 1's remaining goop from the 5 already recorded above s.record_event("gathered_alien_goop", 2) c.advance_phase() # DAY -> DUSK c.advance_phase() # DUSK -> NIGHT c.advance_phase() # NIGHT -> DAWN c.advance_phase() # DAWN -> MORNING of night 2 (closes night 1's log; night_events clears) r.check(Upgrades.goop_collected(s) == 2 and not Upgrades.revealed(s, cfg, "sticky_tar"), "a completed night's goop (night_log, via totals()) counts toward a different item's own reveal_goop threshold") s.record_event("gathered_alien_goop", 1) r.check(Upgrades.revealed(s, cfg, "sticky_tar"), "the current cycle's own goop (night_events) also counts, revealing it") var retry_ok := c.retry_night() r.check(retry_ok and not Upgrades.revealed(c.state, cfg, "sticky_tar") and Upgrades.goop_collected(c.state) == 2, "a retry (restoring the morning snapshot) drops the failed night's own goop, un-revealing it, but keeps the earlier completed night's") func _layout(r: GameTestRunner, sim: FarmSim) -> void: var by_material := {} var names := {} for n in sim.interactions.nodes: by_material[n.material] = int(by_material.get(n.material, 0)) + 1 names[String(n.name)] = true var zone := sim.zones.zone_at(n.global_position) var want := {"wood": FarmZone.Kind.WOOD, "scrap": FarmZone.Kind.SCRAP, "straw": FarmZone.Kind.STRAW}[n.material] as FarmZone.Kind r.check(zone != null and zone.kind == want and n.get_child_count() >= 2, "%s (%s) stands in its zone with its props" % [n.name, n.material]) var inside := {} var outside := {} for n in sim.interactions.nodes: var bucket := inside if sim.zones.is_inside_fence(n.global_position) else outside bucket[n.material] = int(bucket.get(n.material, 0)) + 1 if bucket == outside: r.check(n.yield_amount > 2 and sim.zones.zone_at(n.global_position).outside, "%s, outside the fence, yields more (%d)" % [n.name, n.yield_amount]) for m in ResourceStore.MATERIALS: r.check(int(inside.get(m, 0)) >= 3 and int(inside.get(m, 0)) <= 5, "3-5 gather points for %s on the farm (%d)" % [m, int(inside.get(m, 0))]) r.check(int(outside.get(m, 0)) >= 2, "and more outside the fence (%d)" % int(outside.get(m, 0))) r.check(sim.zones.outside_zones().size() == 4 and sim.zones.zone(FarmZone.Kind.WOOD).display_name == "Woodlot", "four gathering areas outside, and the farm's own zones still come first") r.check(names.size() == sim.interactions.nodes.size(), "gather point names are unique (they key the farm state)") # The scarecrow's body must be able to stand within reach of every point (and the workbench), # walking there from its start: out through the gaps for the points outside. var nav := FarmNavigation.new() nav.build(sim.get_parent(), sim.zones.roam, 0.5, FarmSim.SCARECROW_RADIUS, 1 | 4) var from := nav.nearest_free(nav.cell_of(sim.player.global_position.x, sim.player.global_position.z)) var walk := nav.distance_field(PackedInt32Array([from])) var spots: Array[Node3D] = [] spots.assign(sim.interactions.nodes) spots.append(sim.interactions.workbench) for n in spots: var reach: float = n.reach var c := Vector2(n.global_position.x, n.global_position.z) var closest := INF for cell in nav.free_cells_in(Rect2(c - Vector2.ONE * reach, Vector2.ONE * reach * 2.0)): if walk[cell] < FarmNavigation.UNREACHABLE: closest = minf(closest, nav.cell_center(cell).distance_to(c)) r.check(closest <= reach - 0.25, "the scarecrow can walk to within reach of %s (%.1f of %.1f m)" % [n.name, closest, reach]) r.check(sim.interactions.workbench != null and sim.zones.zone(FarmZone.Kind.WORK_AREA).contains(sim.interactions.workbench.global_position), "the workbench stands in the work area") func _gathering(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void: var it := sim.interactions var res := sim.campaign.state.resources var tree := _node(it, "DeadTree") var msgs: Array[String] = [] it.message.connect(func(t: String, _c: Color) -> void: msgs.append(t)) _stand_at(player, tree) _hold(sim, 30) r.check(res.pouch_total() == 0 and msgs.has("Gathering is for daytime"), "no gathering before the day starts (once per press: %d)" % msgs.size()) Input.action_release("interact") sim.campaign.begin_day() _step(sim, 1) _hold(sim, 30) r.check(it.gathering == tree and player.rooted and not it.can_shoot(), "holding interact gathers: rooted, no shooting") _hold(sim, roundi(sim.config.gather_time * 60.0) - 30 + 2) r.check(res.pouch["wood"] == tree.yield_amount and it.charges(tree) == tree.max_charges - 1, "after %.1f s: +%d wood in the pouch, one charge used" % [sim.config.gather_time, tree.yield_amount]) _hold(sim, roundi(sim.config.gather_time * 60.0) + 4) r.check(it.charges(tree) == 0 and res.pouch["wood"] == tree.yield_amount * 2, "holding on gathers again until the point runs out") _hold(sim, 10) r.check(it.gathering == null and msgs.has("Nothing left here; it grows back overnight"), "a used-up point can't be gathered") # Next to both a used-up point and a full one, interact goes to the full one. var logs := _node(it, "LogPile") player.global_position = (tree.global_position + logs.global_position) * 0.5 player.global_position.y = 0.0 Input.action_release("interact") _step(sim, 1) var both := Vector2(player.global_position.x - tree.global_position.x, player.global_position.z - tree.global_position.z).length() <= tree.reach \ and Vector2(player.global_position.x - logs.global_position.x, player.global_position.z - logs.global_position.z).length() <= logs.reach _hold(sim, 5) r.check(both and it.gathering == logs, "between a used-up point and a full one, the full one is gathered") Input.action_release("interact") _step(sim, 1) res.pouch["wood"] = tree.yield_amount * 2 Input.action_release("interact") _step(sim, 1) var snag := _node(it, "Snag") _stand_at(player, snag) _hold(sim, 40) Input.action_release("interact") _step(sim, 1) r.check(it.gathering == null and it.charges(snag) == snag.max_charges and not player.rooted, "letting go early gathers nothing") _hold(sim, 40) sim.scarecrow.try_damage(1) r.check(it.gathering == null, "a hit stops gathering") sim.scarecrow.invulnerable_left = 0.0 sim.campaign.state.scarecrow_hp = sim.campaign.state.scarecrow_max_hp Input.action_release("interact") _step(sim, 1) _hold(sim, 40) sim.scarecrow.use_fear() sim.scarecrow.fear_left = 0.0 r.check(it.gathering == null, "using fear stops gathering") Input.action_release("interact") _step(sim, 1) res.add_to_pouch("scrap", res.pouch_room() - 1) _hold(sim, 20) r.check(it.gathering == null and msgs.has("Pouch full: drop it off at the supply shed") and it.charges(snag) == snag.max_charges, "without room for the whole yield, nothing is gathered (and no charge is wasted)") Input.action_release("interact") _step(sim, 1) func _deposit_and_night(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void: var c := sim.campaign var res := c.state.resources var it := sim.interactions var shed_before: Dictionary = res.shed.duplicate() var pouch: Dictionary = res.pouch.duplicate() var moved: Array[Dictionary] = [] it.deposited.connect(func(m: Dictionary) -> void: moved.append(m)) var shed := sim.zones.zone(FarmZone.Kind.SUPPLY_SHED) player.global_position = shed.global_position + Vector3(0.0, 0.0, 2.0) _step(sim, 1) r.check(res.pouch_total() == 0 and moved.size() == 1 and res.shed["wood"] == int(shed_before["wood"]) + int(pouch["wood"]) and res.shed["scrap"] == int(shed_before["scrap"]) + int(pouch["scrap"]), "walking into the supply shed stores the pouch") var tree := _node(it, "DeadTree") var deadfall := _node(it, "Deadfall") c.state.gather_charges["Deadfall"] = 0 deadfall.regen_per_night = 1 c.advance_phase() c.advance_phase() r.check(c.state.phase == P.NIGHT, "night falls") _stand_at(player, _node(it, "LogPile")) _hold(sim, 30) r.check(it.gathering == null and res.pouch_total() == 0, "no gathering at night") Input.action_release("interact") _step(sim, 1) c.advance_phase() c.advance_phase() r.check(c.state.phase == P.MORNING and it.charges(tree) == tree.max_charges and it.charges(deadfall) == 1, "overnight the points grow back (a point regrowing 1 a night has 1 again)") deadfall.regen_per_night = 20 # Retry brings back the morning's materials and points. var morning := c.state.to_dict() c.begin_day() _stand_at(player, _node(it, "Wreck")) _hold(sim, roundi(sim.config.gather_time * 60.0) + 2) Input.action_release("interact") _step(sim, 1) r.check(res.pouch["scrap"] > 0, "scrap gathered on day 2") c.advance_phase() c.advance_phase() c.state.scarecrow_hp = 0 _step(sim, 1) c.retry_night() _step(sim, 1) r.check(c.state.resources.to_dict() == morning["resources"] and c.state.gather_charges == morning["gather_charges"], "retry restores the morning's materials and gather points") func _patch_cost(r: GameTestRunner, sim: FarmSim) -> void: var s := sim.campaign.state var kit := sim.scarecrow var denied: Array[Dictionary] = [] kit.patch_denied.connect(func(m: Dictionary) -> void: denied.append(m)) s.resources.shed["straw"] = 2 s.resources.pouch["straw"] = 0 s.scarecrow_hp = 5 Input.action_press("patch") _step(sim, roundi(sim.config.patch_time * 60.0) + 2) r.check(s.scarecrow_hp == 5 + sim.config.patch_heal and s.resources.available("straw") == 0, "a patch costs 2 straw") _step(sim, 30) r.check(not kit.patching and denied.size() == 1 and denied[0] == {"straw": 2}, "without straw the patch is refused, once per press") Input.action_release("patch") _step(sim, 1) s.scarecrow_hp = s.scarecrow_max_hp func _stuffing(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void: var c := sim.campaign var s := c.state var it := sim.interactions var bench := it.workbench var menu := sim.upgrade_panel var add := int(sim.config.upgrades["straw_stuffing"]["add"]) var msgs: Array[String] = [] it.message.connect(func(t: String, _col: Color) -> void: msgs.append(t)) menu.message.connect(func(t: String, _col: Color) -> void: msgs.append(t)) player.global_position = bench.global_position + Vector3(0.0, 0.0, 1.2) _press(sim) r.check(not menu.is_open and msgs[-1] == "The work area is for daytime", "no upgrades during the morning review") c.begin_day() s.resources.shed = {"wood": 0, "scrap": 0, "straw": 3} _press(sim) r.check(menu.is_open and player.rooted and not it.can_shoot(), "interact at the workbench opens the upgrade menu; the scarecrow stands still") var row := menu._rows["straw_stuffing"] as Button r.check(row.disabled and row.text.contains("Need 4 wood, 9 straw more"), "short of materials, the row says what's missing: '%s'" % row.text) s.resources.shed = {"wood": 3, "scrap": 0, "straw": 12} s.resources.pouch = {"wood": 1, "scrap": 0, "straw": 0} menu.refresh() var max_hp := s.scarecrow_max_hp row.pressed.emit() r.check(Upgrades.owned(s, "straw_stuffing") and s.scarecrow_max_hp == max_hp + add and s.scarecrow_hp == s.scarecrow_max_hp, "Straw stuffing: +%d max HP (%s)" % [add, msgs[-1]]) r.check(s.resources.shed == {"wood": 0, "scrap": 0, "straw": 0} and s.resources.pouch["wood"] == 0, "it costs 12 straw and 4 wood") r.check(row.disabled and row.text.contains("Done"), "it can only be bought once") _press(sim) r.check(not menu.is_open and not player.rooted, "interact again closes the menu") _press(sim) menu.close() ## Alien Goop (#4): dropped only by killed Aliens (thieves), at GameConfig's rate and quantity, ## credited like a gathered material (respecting the pouch's capacity), and stealable from the ## shed like any other material once it's the one on top. func _goop_drops(r: GameTestRunner, sim: FarmSim) -> void: var es := sim.enemies var s := sim.campaign.state var cfg := sim.config var pouch_cap_before := s.resources.pouch_capacity s.resources.pouch_capacity = 1000000 # room for every drop; isolates the chance roll from capacity # Statistical: over many kills, the drop rate roughly matches the config chance (the drop # roll uses a seeded RNG, so this is also reproducible run to run). const N := 1000 var before := int(s.night_events.get("gathered_alien_goop", 0)) for i in N: var h := es.spawn(EnemySystem.TYPE_THIEF, 12.0, -30.0, Vector2.UP) es.apply_hit_handle(h, 99) _step(sim, 1) var gained := int(s.night_events.get("gathered_alien_goop", 0)) - before var rate := float(gained) / float(N * cfg.alien_goop_drop_qty) r.check(absf(rate - cfg.alien_goop_drop_chance) < 0.06, "killing %d Aliens drops goop about %.0f%% of the time (got %.1f%%, %d units)" % [N, cfg.alien_goop_drop_chance * 100.0, rate * 100.0, gained]) # Type restriction: only thieves ("Alien") drop goop, not crows or fence breakers. var before2 := int(s.night_events.get("gathered_alien_goop", 0)) for i in 50: var hc := es.spawn(EnemySystem.TYPE_CROW, 12.0, -30.0, Vector2.UP) es.apply_hit_handle(hc, 99) _step(sim, 1) var hb := es.spawn(EnemySystem.TYPE_BREAKER, 12.0, -30.0, Vector2.UP) es.apply_hit_handle(hb, 99) _step(sim, 1) r.check(int(s.night_events.get("gathered_alien_goop", 0)) == before2, "only Aliens (thieves) drop goop, not crows or fence breakers") # Deterministic: a guaranteed drop is credited like a gathered material, capped by pouch room. cfg.alien_goop_drop_chance = 1.0 cfg.alien_goop_drop_qty = 3 s.resources.pouch_capacity = s.resources.pouch_total() + 2 # room for only 2 of the 3 var pouch_before := s.resources.pouch_total() var h2 := es.spawn(EnemySystem.TYPE_THIEF, 12.0, -30.0, Vector2.UP) es.apply_hit_handle(h2, 99) _step(sim, 1) r.check(s.resources.pouch_total() == pouch_before + 2, "a drop only adds what fits in the pouch (2 of 3, the pouch nearly full)") cfg.alien_goop_drop_chance = 0.33 cfg.alien_goop_drop_qty = 1 s.resources.pouch_capacity = pouch_cap_before # Stealable from the shed: once goop is the shed's most-stocked material, a supply claim # takes it, and the shed's own pile wiring gives the thief somewhere real to stand. s.resources.shed = {"wood": 0, "scrap": 0, "straw": 0, "alien_goop": 20} var sack := sim.loot._claim_home(LootSystem.Category.SUPPLY) r.check(sack > 0 and sim.loot.sack_material[sack] == "alien_goop" and sim.loot.home[sack] != Vector2.ZERO, "a sack claimed at the shed takes goop when it's the most-stocked material, at a real spot") s.resources.shed = {"wood": 0, "scrap": 0, "straw": 0, "alien_goop": 0} func _node(it: Interactions, node_name: String) -> GatherNode: for n in it.nodes: if n.name == node_name: return n return null ## Puts the scarecrow next to a gather point, within its reach. func _stand_at(player: PlayerCharacter, n: GatherNode) -> void: var to_center := Vector3(n.global_position.x, 0.0, n.global_position.z) player.global_position = to_center + Vector3(n.reach * 0.7, 0.0, 0.0) func _hold(sim: FarmSim, ticks: int) -> void: Input.action_press("interact") _step(sim, ticks) func _press(sim: FarmSim) -> void: Input.action_release("interact") _step(sim, 1) Input.action_press("interact") _step(sim, 1) Input.action_release("interact") _step(sim, 1) func _step(sim: FarmSim, n: int) -> void: for i in n: sim.step(DT)