From 1e91ccf59436a9f4dccd0bf5d562305a7b57410e Mon Sep 17 00:00:00 2001 From: Forrest Date: Tue, 6 Oct 2026 16:02:37 -0400 Subject: [PATCH] Task #23: remove the zone banner and the message feed The user asked to drop the pop-up status lines, including replies to the player's own actions. - farm.tscn (edited as text): the ZoneBanner and Hud/ToastFeed nodes, their ext_resources, and FarmSim's toasts export are gone. zone_banner.gd and toast_feed.gd (with their .uid files) are deleted. - FarmSim: no toast wiring, no arrival_message, no outside-the-fence or sunrise lines. Main: no lobby-failure or microphone lines; _set_hud only hides Hud. CampaignDebug: F2 no longer toasts (the F1 readout shows the scenario). - CoopSession: the host no longer sends "toast" or "arrived" events, and the partner no longer handles them. The joined/left/version lines are gone (the partner's main menu still says why a session ended). A refused build request still sends the error sound. PROTOCOL stays 5: the other messages and records are unchanged, and _apply_event ignores unknown kinds, so mixed builds still work together. - BuildMode.message is removed (no test listens to it). Interactions.message and UpgradePanel.message stay because tests listen to them. - test_farm_layout: the banner checks are removed. - RULES.md, README.md, COOP.md, and LAYOUT.md no longer describe the banner or toasts. Co-Authored-By: Claude Opus 5.5 --- README.md | 15 +++--- game/COOP.md | 6 +-- game/LAYOUT.md | 6 +-- game/RULES.md | 13 +++-- game/scenes/farm.tscn | 18 +------ game/scripts/build_mode.gd | 9 +--- game/scripts/campaign_debug.gd | 2 - game/scripts/coop_session.gd | 44 ++------------- game/scripts/farm_sim.gd | 39 -------------- game/scripts/interactions.gd | 2 + game/scripts/loot_system.gd | 2 +- game/scripts/main.gd | 13 ++--- game/scripts/toast_feed.gd | 95 --------------------------------- game/scripts/toast_feed.gd.uid | 1 - game/scripts/upgrade_panel.gd | 2 + game/scripts/zone_banner.gd | 37 ------------- game/scripts/zone_banner.gd.uid | 1 - game/tests/test_farm_layout.gd | 18 +------ 18 files changed, 37 insertions(+), 286 deletions(-) delete mode 100644 game/scripts/toast_feed.gd delete mode 100644 game/scripts/toast_feed.gd.uid delete mode 100644 game/scripts/zone_banner.gd delete mode 100644 game/scripts/zone_banner.gd.uid diff --git a/README.md b/README.md index 178c107..3213263 100644 --- a/README.md +++ b/README.md @@ -64,9 +64,9 @@ pack (`assets/farm/ithappy/farm/prefabs/assets/`). arrive at random points all along the map's edge. The rest of the farm is scenery. `Zones/` holds one `FarmZone` per area (crop field, animal pen, supply shed, work area, woodlot, scrap heap, haystacks) with its props as children, the 30 `CropUnit`s of the crop field, and the perimeter (fence, gap `FarmMarker`s, and - scarecrow-only `PlayerBounds` on physics layer 3). `ZoneBanner` shows the zone's name when the - scarecrow walks in. `FarmNavigation` rasterizes the farm's collision into a 0.5 m grid for - ground enemies. Details, travel times, and how to edit: [`game/LAYOUT.md`](game/LAYOUT.md). + scarecrow-only `PlayerBounds` on physics layer 3). `FarmNavigation` rasterizes the farm's + collision into a 0.5 m grid for ground enemies. Details, travel times, and how to edit: + [`game/LAYOUT.md`](game/LAYOUT.md). `game/tools/render_overview.gd` renders a top-down picture (`--zones` draws the zones). * **Enemies and theft** — `FarmSim` (`game/scripts/farm_sim.gd`) runs the farm's simulation in a fixed order each physics tick and applies the phase rules. @@ -90,7 +90,8 @@ pack (`assets/farm/ithappy/farm/prefabs/assets/`). - a "!" over a targeted item and a filling ring while it's taken; - a token outlined in the category's color, and a badge, on the carrier or on the ground. - **`AlertManager`** draws labeled edge-of-screen arrows: grouped, prioritized, escape alerts - escalating, at most 5 at once. **`ToastFeed`** shows event toasts. + escalating, at most 5 at once. There's no message feed: events are heard, and shown by + the alerts, the HUD, and the morning review. - Shooting a carrier drops its loot, and walking up to it recovers it. A carrier that gets off the farm loses it for good. - The scarecrow's weapons (`ScarecrowCombat`): mouse or right-stick aim, hold fire. It starts @@ -291,10 +292,10 @@ game/ scenes/ main.tscn (main scene: the menus over the farm), farm.tscn, player.tscn scripts/ player_character.gd, follow_camera.gd, campaign_controller.gd, farm_state.gd, game_config.gd, campaign_debug.gd, farm_zones.gd, farm_zone.gd, farm_marker.gd, - crop_unit.gd, farm_navigation.gd, zone_banner.gd, farm_sim.gd, enemy_system.gd, + crop_unit.gd, farm_navigation.gd, farm_sim.gd, enemy_system.gd, thief_behavior.gd, loot_system.gd, farm_projectiles.gd, scarecrow_combat.gd, weapon_models.gd, pumpkin_bombs.gd, - alert_manager.gd, toast_feed.gd, scarecrow.gd, scarecrow_hud.gd, + alert_manager.gd, scarecrow.gd, scarecrow_hud.gd, end_panel.gd, resource_store.gd, gather_node.gd, workbench.gd, interactions.gd, resource_hud.gd, structure_system.gd, build_mode.gd, build_hud.gd, action_edges.gd, night_plan.gd, wave_director.gd, day_night.gd, @@ -499,7 +500,7 @@ from its morning. The farm layout suite checks one non-overlapping zone per kind 60 × 60 m map, zone lookup, the 30 crop units, the farm's edge and its side names, the remaining north and east fence with no holes outside its gaps (and the open south and west), ground-enemy routes from anywhere on the edge to every zone, that the scarecrow can walk out through a gap, -zone-to-zone travel times (at most 12 s), and the zone banner. The theft +and zone-to-zone travel times (at most 12 s). The theft suite runs crop theft on the real farm, by crows: claiming, flying in and landing, the steal timer, carrying, escaping over the fence (crop lost), one hit killing a crow and dropping its crop exactly once, touch recovery, stale handles after slot reuse, shots hitting thieves and cruising diff --git a/game/COOP.md b/game/COOP.md index 391c025..e04982b 100644 --- a/game/COOP.md +++ b/game/COOP.md @@ -97,7 +97,7 @@ it acts. | Piece | File | Does | |---|---|---| -| `CoopSession` | `game/scripts/coop_session.gd` | The protocol, on both sides: the welcome, snapshots in packed bytes 15 times a second (the clock, both scarecrows with the weapon in hand and the bomb's recharge, animals, shots, and the enemies that are due, in 16-byte records), the farm state and the loot when they change, news in order (phase changes, the end, sounds, toasts, loot news, breaches, fear bursts, attacks, pumpkin bombs thrown, gather popups), and the partner's input (with its pick of weapon) and requests. The partner's own weapons only aim and show their motion: the host attacks for it, so nothing is hit twice | +| `CoopSession` | `game/scripts/coop_session.gd` | The protocol, on both sides: the welcome, snapshots in packed bytes 15 times a second (the clock, both scarecrows with the weapon in hand and the bomb's recharge, animals, shots, and the enemies that are due, in 16-byte records), the farm state and the loot when they change, news in order (phase changes, the end, sounds, loot news, breaches, fear bursts, attacks, pumpkin bombs thrown, gather popups), and the partner's input (with its pick of weapon) and requests. The partner's own weapons only aim and show their motion: the host attacks for it, so nothing is hit twice | | `CoopLink`, `GDSyncLink` | `coop_link.gd`, `gdsync_link.gd` | The wire: GD-Sync remote calls, reliable or not, large messages compressed; the packing helpers; a loopback pair for tests | | `CoopLobby` | `coop_lobby.gd` | GD-Sync's LAN and online modes, lobbies, join by address | | `RemoteControls` | `remote_controls.gd` | The partner's buttons as the host sees them: held state, press counts (a lost packet never loses a press), aim, build mode, menus; its input record, 39 bytes | @@ -147,8 +147,8 @@ What keeps co-op small: `game/tools/net_budget.gd` measured a whole vacation (5 nights, 32 minutes, the partner always moving, no voice): 22 MB sent to the server, against 113 MB before (2026-10-04). That's about 12 KB/s: 6 from the host, 5.5 from the partner. Both machines must run the same version of the game: -the hello and the welcome carry `CoopSession.PROTOCOL`, and a mismatch ends the session with a -message on both sides. +the hello and the welcome carry `CoopSession.PROTOCOL`, and a mismatch ends the session (the +partner's main menu says why). ## Testing diff --git a/game/LAYOUT.md b/game/LAYOUT.md index df607e8..cfaa084 100644 --- a/game/LAYOUT.md +++ b/game/LAYOUT.md @@ -31,8 +31,7 @@ godot --path . --script res://game/tools/render_overview.gd -- --out=/tmp/farm.p Every zone is a `FarmZone` node under `Zones/` in `farm.tscn`: an axis-aligned rectangle with a kind, a display name, and a tint. Its props are its children. In the editor each zone draws a -translucent box, so it can be moved and resized there. The HUD banner (`ZoneBanner`) shows the -name when the scarecrow walks in. +translucent box, so it can be moved and resized there. | Zone | Rectangle (x, z) | What's there | Purpose | |---|---|---|---| @@ -282,8 +281,7 @@ Four outside zones (`FarmZone.outside`) hold more to gather. Every point there y | South Fields (straw) | (9.5, 41), 66 × 10 | FieldStackWest (−14, 41.5), FieldStackEast (36, 41.5) (4-bale stacks, 4), FieldBaleWest (−3, 42), FieldBaleEast (21, 41) (round bales, 3) | none: the south side is open | `FarmZones.zone(kind)` only ever returns the farm's own zone, and `zones()` lists only the farm's. -`outside_zones()` lists these, and `zone_at()` finds both (the zone banner says "North Grove -(outside the fence)"). +`outside_zones()` lists these, and `zone_at()` finds both. **The South Fields** (#20) are the strip of plowed soil between the map's south edge (z 35) and the old farm's south fence (z ≈ 46.4). Their hay rests on the soil there, south of the later crop diff --git a/game/RULES.md b/game/RULES.md index 3d1ba9f..939adf2 100644 --- a/game/RULES.md +++ b/game/RULES.md @@ -196,7 +196,7 @@ they roam the whole farm and are never lost on their own. is loose where it fell and roams from there. If that's inside the pen, it's home again. - **Leading animals home (D6).** - Walk up to a loose animal and it follows the scarecrow, walking its trail in line, gates - included. At most 3 follow at once; a toast says so when the line is full. + included. At most 3 follow at once. - Inside the pen it's home (penned) and stays calm for 30 s (it won't get out of an open pen). - A follower whose scarecrow gets more than 20 m away is loose where it stands. - Thieves can't take an animal that's following the scarecrow. @@ -205,7 +205,7 @@ they roam the whole farm and are never lost on their own. following it) walk through the gate, but wandering animals and enemies can't. - **The pen is open** when there's a way out that crosses no structure: nothing built yet, or a gate or fence broken or taken down. - - A toast says so when it happens, and so does the morning review. + - The morning review says so. - At night (night and dawn), one calm penned animal gets out of an open pen every 10 s. It's loose at once (no longer penned): it walks out through the opening at 1.1 m/s, then roams like any loose animal. The night's record counts it as strayed. @@ -280,8 +280,8 @@ Implemented in Step 4. The numbers are in `GameConfig`. **2 straw**. The straw is paid when the patch completes. - Releasing early, taking a hit, or using fear cancels it. - Keep holding to patch again. - - It isn't available at full health, while gathering, or without the straw (a message says - what's missing). + - It isn't available at full health, while gathering, or without the straw (an error sound + plays). - It works in any phase (D8). - **Defeat:** at **0 HP** the scarecrow falls and the game is over at once (scarecrow first, ahead of a stripped farm). A Game Over panel offers **Retry the night** (D9) and **New @@ -319,8 +319,7 @@ Implemented in Step 5. The numbers are in `GameConfig`; the gather points are li - the East Road: scrap, the abandoned car; - the South Fields: straw, on the old plowed fields. - They grow back overnight like the others. Gathering is still daytime only. - - Building, the enemies' paths, and the night stay inside the fence. At dusk and at nightfall, - a scarecrow still outside gets a warning. + - Building, the enemies' paths, and the night stay inside the fence. - **Work area:** press E / X at the tool table, by day, to open the upgrade menu (below). - **Persistence:** materials (shed and pouch), used gather points, and upgrades carry over between nights and are restored by a retry. @@ -389,7 +388,7 @@ Implemented in Step 6. The numbers are in `GameConfig`. - A fully enclosed target always has a route, which ends at the cheapest barrier. The thief stops there and hits it (2 damage every 1.2 s, so about 12 s for a fence) until it breaks, then carries on. A fence breaker does the same at 8 damage every 1.5 s. - - A broken structure leaves debris and a **"Breach!"** toast. + - A broken structure leaves debris, and the breach alarm sounds. - Enemy routes are rebuilt over a few ticks whenever structures change. There are six routes: the farm's edge, the pen, the three shed piles, and the fence breakers' targets. Measured: about 120 ms in total over 47 ticks, at most 2.6 ms in one tick. diff --git a/game/scenes/farm.tscn b/game/scenes/farm.tscn index 16a58c2..dd6e662 100644 --- a/game/scenes/farm.tscn +++ b/game/scenes/farm.tscn @@ -66,7 +66,6 @@ [ext_resource type="Script" uid="uid://bvvdfx5idf2u5" path="res://game/scripts/campaign_debug.gd" id="101_campaign_debug"] [ext_resource type="Script" uid="uid://c6auf64ahke4k" path="res://game/scripts/farm_sim.gd" id="102_farm_sim"] [ext_resource type="Script" uid="uid://clqvqr3bnsp5k" path="res://game/scripts/alert_manager.gd" id="103_threats"] -[ext_resource type="Script" uid="uid://f647f4bijmdy" path="res://game/scripts/toast_feed.gd" id="104_toasts"] [ext_resource type="Script" uid="uid://e768baxfmoit" path="res://game/scripts/scarecrow_hud.gd" id="105_scarecrow_hud"] [ext_resource type="Script" uid="uid://b6pkgit825mrl" path="res://game/scripts/end_panel.gd" id="106_end_panel"] [ext_resource type="Script" uid="uid://dc3i7w50plvjs" path="res://game/scripts/resource_hud.gd" id="107_resource_hud"] @@ -110,7 +109,6 @@ [ext_resource type="PackedScene" uid="uid://chk3qbbrouuhw" path="res://assets/farm/ithappy/farm/prefabs/assets/prop/barrel_005.tscn" id="233_barrel_005"] [ext_resource type="Script" uid="uid://dewrnp06jkx2y" path="res://game/scripts/farm_marker.gd" id="234_farm_marker"] [ext_resource type="PackedScene" uid="uid://dge2nlq7ko5pj" path="res://assets/farm/ithappy/farm/prefabs/assets/prop/pointer_002.tscn" id="235_pointer_002"] -[ext_resource type="Script" uid="uid://dbfcgsdrh5v60" path="res://game/scripts/zone_banner.gd" id="236_zone_banner"] [ext_resource type="PackedScene" uid="uid://cxtonxmvu4t6" path="res://assets/farm/ithappy/farm/prefabs/assets/plant/plant_001.tscn" id="237_plant_001"] [ext_resource type="PackedScene" uid="uid://43cd6lkj4xrm" path="res://assets/farm/ithappy/farm/prefabs/assets/plant/plant_004.tscn" id="238_plant_004"] [ext_resource type="PackedScene" uid="uid://1p6k2a6oiqne" path="res://assets/farm/ithappy/farm/prefabs/assets/plant/plant_005.tscn" id="239_plant_005"] @@ -3674,11 +3672,6 @@ shape = SubResource("BoxShape3D_bounds_we") transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 54.8, 1.5, -6.3) shape = SubResource("BoxShape3D_bounds_we") -[node name="ZoneBanner" type="CanvasLayer" parent="." unique_id=940903714 node_paths=PackedStringArray("zones", "target")] -script = ExtResource("236_zone_banner") -zones = NodePath("../Zones") -target = NodePath("../Player") - [node name="Hud" type="CanvasLayer" parent="." unique_id=666315498] [node name="Alerts" type="Control" parent="Hud" unique_id=110836126] @@ -3691,14 +3684,6 @@ grow_vertical = 2 mouse_filter = 2 script = ExtResource("103_threats") -[node name="ToastFeed" type="VBoxContainer" parent="Hud" unique_id=1261899939] -anchors_preset = 10 -anchor_right = 1.0 -offset_top = 152.0 -grow_horizontal = 2 -mouse_filter = 2 -script = ExtResource("104_toasts") - [node name="ScarecrowHud" type="Control" parent="Hud" unique_id=1120148247] layout_mode = 3 anchors_preset = 15 @@ -3785,13 +3770,12 @@ grow_vertical = 2 mouse_filter = 2 script = ExtResource("114_upgrades") -[node name="FarmSim" type="Node" parent="." unique_id=117307361 node_paths=PackedStringArray("campaign", "zones", "player", "camera", "toasts", "alerts", "hud", "end_panel", "resource_hud", "build_hud", "phase_hud", "asset_hud", "review_panel", "upgrade_panel", "shed_panel", "sun", "world_environment")] +[node name="FarmSim" type="Node" parent="." unique_id=117307361 node_paths=PackedStringArray("campaign", "zones", "player", "camera", "alerts", "hud", "end_panel", "resource_hud", "build_hud", "phase_hud", "asset_hud", "review_panel", "upgrade_panel", "shed_panel", "sun", "world_environment")] script = ExtResource("102_farm_sim") campaign = NodePath("../Campaign") zones = NodePath("../Zones") player = NodePath("../Player") camera = NodePath("../Camera") -toasts = NodePath("../Hud/ToastFeed") alerts = NodePath("../Hud/Alerts") hud = NodePath("../Hud/ScarecrowHud") end_panel = NodePath("../Hud/EndPanel") diff --git a/game/scripts/build_mode.gd b/game/scripts/build_mode.gd index 1f8c528..bf75571 100644 --- a/game/scripts/build_mode.gd +++ b/game/scripts/build_mode.gd @@ -11,10 +11,9 @@ extends Node3D ## cancel leaves build mode. ## The scarecrow doesn't shoot, gather, or repair while building (FarmSim, Interactions). ## Co-op, on the partner's machine: placing and dismantling are sent to the host (place_request, -## dismantle_request), which checks them again and does them; the result comes back as a message. +## dismantle_request), which checks them again and does them. ## The cost is checked against (and paid from) the builder's own pouch and the shed (kit.slot). -signal message(text: String, color: Color) signal toggled(on: bool) ## A placement was refused (the reason); a structure was taken down. signal refused(reason: String) @@ -122,10 +121,8 @@ func step(_dt: float) -> void: hover = -1 return var e := campaign.state.structure(hover) - var back := structures.dismantle(hover) + structures.dismantle(hover) dismantled.emit(String(e["type"])) - message.emit("Dismantled the %s%s" % [StructureSystem.NAMES[e["type"]].to_lower(), - (": %s back in the shed" % ResourceStore.describe(back)) if not back.is_empty() else ""], Color(0.85, 0.95, 1.0)) hover = -1 return reason = structures.validate(type(), cursor.x, cursor.y, rot, me, kit.slot) @@ -134,9 +131,7 @@ func step(_dt: float) -> void: place_request.call(type(), cursor.x, cursor.y, rot) elif reason == "": structures.place(type(), cursor.x, cursor.y, rot, kit.slot) - message.emit("Built a %s" % StructureSystem.NAMES[type()].to_lower(), Color(0.6, 1.0, 0.55)) else: - message.emit(reason, Color(1.0, 0.8, 0.5)) refused.emit(reason) elif p[&"cancel"]: set_active(false) diff --git a/game/scripts/campaign_debug.gd b/game/scripts/campaign_debug.gd index e8f981c..39dd752 100644 --- a/game/scripts/campaign_debug.gd +++ b/game/scripts/campaign_debug.gd @@ -84,8 +84,6 @@ func cycle_scenario() -> void: if _scenario >= 0: plan = load("res://game/resources/scenarios/%s.tres" % SCENARIOS[_scenario]) as NightPlan sim.waves.debug_plan = plan - if sim.toasts != null: - sim.toasts.push("Tonight (debug): %s" % (plan.title if plan != null else "the night's own plan"), Color(0.8, 0.9, 1.0)) func _describe() -> String: diff --git a/game/scripts/coop_session.gd b/game/scripts/coop_session.gd index 272edd6..f2ec3fc 100644 --- a/game/scripts/coop_session.gd +++ b/game/scripts/coop_session.gd @@ -10,8 +10,8 @@ extends Node ## welcome (reliable, once) the farm state, the phase, tonight's time, the loot, the names ## refused (reliable) the partner's game speaks another PROTOCOL ## batch (reliable, each tick with news) events in order: phase changes (with the state), -## the end of the campaign, sounds, toasts for the partner, loot and arrival news, -## breaches, fear bursts, gather popups, opening a shop's menu (the workbench's, the +## the end of the campaign, sounds, loot news, breaches, fear bursts, attacks, +## pumpkin bombs thrown, gather popups, opening a shop's menu (the workbench's, the ## shed's), a purchase the partner made (bought: the slot and the upgrade id, so a ## new weapon goes into its hand); enemies removed ## state (reliable, at most STATE_HZ, when it changed) the farm state (the phase clock @@ -158,9 +158,6 @@ func start_host(p_sim: FarmSim, p_link: CoopLink, p_my_name: String, p_partner_n _hook(sim.enemies.enemy_removed, func(h: int, reason: EnemySystem.Removal, x: float, z: float, _c: int, _t: int) -> void: _removed.append([h, int(reason), x, z]) _foe_sent.erase(h)) - _hook(sim.waves.arrived, func(h: int, at: Vector2) -> void: - var d := sim.enemies.resolve_handle(h) - _events.append(["arrived", sim.enemies.type[d] if d >= 0 else 0, at])) _hook(sim.loot.loot_event, func(kind: StringName, id: int, at: Vector3) -> void: _events.append(["loot", String(kind), id, at])) _hook(sim.structures.destroyed, func(id: int, type: String, at: Vector3) -> void: @@ -170,21 +167,16 @@ func start_host(p_sim: FarmSim, p_link: CoopLink, p_my_name: String, p_partner_n _hook(av.kit.fear_used, func(_p: Vector3, _n: int) -> void: _events.append(["fear", slot])) _hook(av.combat.attacked, func(w: ScarecrowCombat.Weapon) -> void: _events.append(["attack", slot, int(w)])) _hook(sim.bombs.thrown, func(from: Vector3, to: Vector3) -> void: _events.append(["bomb", from, to])) - _hook(a.interactions.message, func(text: String, color: Color) -> void: _events.append(["toast", text, color])) _hook(a.interactions.workbench_requested, func() -> void: _events.append(["workbench"])) _hook(a.interactions.shed_requested, func() -> void: _events.append(["shed"])) _hook(a.interactions.gathered, func(m: String, amount: int, n: GatherNode) -> void: _events.append(["popup", "+%d %s" % [amount, m], n.global_position + Vector3(0.0, n.top() + 1.4, 0.0), GatherNode.COLORS[m]])) - _hook(a.kit.patch_denied, func(missing: Dictionary) -> void: - _events.append(["toast", "Not enough straw to patch up: need %s more" % ResourceStore.describe(missing), Color(1.0, 0.8, 0.5)])) if sim.audio != null: sim.audio.forward = func(cue: String, at: Vector3) -> void: _events.append(["sound", cue, at]) _ensure_coop() _state_hash = 0 _loot_hash = 0 _welcome_sent = false # sent when the partner says hello (then it is surely listening) - if sim.toasts != null: - sim.toasts.push("%s joined: player 2's scarecrow is on the farm" % _display(partner_name, "P2"), Avatar.COLORS[1]) partner_joined.emit(partner_name) @@ -249,14 +241,9 @@ func stop(reason: String = "") -> void: sim.audio.forward = Callable() if was == Role.HOST: var gone_name := partner_name - var left_behind := sim.remove_partner() # their pouch, now in the shed + sim.remove_partner() # their pouch goes into the shed sim.avatars[0].player_name = "" sim.player.set_tag("", Color.WHITE) - if sim.toasts != null: - var text := "%s left: you're on your own" % _display(gone_name, "Player 2") - if not left_behind.is_empty(): - text += " (%s from their pouch is in the shed)" % ResourceStore.describe(left_behind) - sim.toasts.push(text, Color(1.0, 0.8, 0.5)) partner_left.emit(gone_name) else: ended.emit(reason) @@ -503,10 +490,7 @@ func _host_message(kind: String, data: Variant) -> void: partner_name = String(hello.get("name", partner_name)) if int(hello.get("v", 1)) != PROTOCOL: link.send("refused", {"v": PROTOCOL}, true) - var who := _display(partner_name, "Your friend") stop() - if sim.toasts != null: - sim.toasts.push("%s has another version of the game: update both to play together" % who, Color(1.0, 0.6, 0.4)) return a.player_name = partner_name _tag_all() @@ -546,25 +530,19 @@ func _do_request(r: Array) -> void: var why := sim.structures.validate(type, x, z, rot, a.position(), a.slot) if why == "": sim.structures.place(type, x, z, rot, a.slot) # paid from P2's pouch, then the shed - _events.append(["toast", "Built a %s" % StructureSystem.NAMES[type].to_lower(), Color(0.6, 1.0, 0.55)]) else: - _events.append(["toast", why, Color(1.0, 0.8, 0.5)]) _events.append(["sound", "error", Vector3.INF]) "dismantle": var e := c.state.structure(int(r[1])) if e.is_empty() or a.position().distance_to(Vector2(e["x"], e["z"])) > sim.config.build_range: return - var back := sim.structures.dismantle(int(r[1])) - _events.append(["toast", "Dismantled the %s%s" % [StructureSystem.NAMES[e["type"]].to_lower(), - (": %s back in the shed" % ResourceStore.describe(back)) if not back.is_empty() else ""], Color(0.85, 0.95, 1.0)]) + sim.structures.dismantle(int(r[1])) "buy": var id := String(r[1]) if Upgrades.shop_of(c.config, id) == "workbench" and (sim.structures == null or not sim.structures.workbench_available()): - _events.append(["toast", "The work area isn't available", Color(1.0, 0.8, 0.5)]) return var was := Upgrades.owned(c.state, id) - var text := Upgrades.buy(c, id, sim.structures, a.slot) # paid from P2's pouch, then the shed - _events.append(["toast", text, Color(0.85, 0.75, 1.0) if text.contains("done:") else Color(1.0, 0.8, 0.5)]) + Upgrades.buy(c, id, sim.structures, a.slot) # paid from P2's pouch, then the shed if not was and Upgrades.owned(c.state, id): _events.append(["bought", a.slot, id]) # the buyer's game: a new weapon into its hand @@ -626,8 +604,6 @@ func _welcome_received(w: Dictionary) -> void: if sim.day_night != null: sim.day_night.snap() _is_welcomed = true - if sim.toasts != null: - sim.toasts.push("Joined %s's farm: you're player 2" % _display(partner_name, "the host"), Avatar.COLORS[1]) welcomed.emit() @@ -697,14 +673,8 @@ func _apply_event(e: Array) -> void: "sound": if sim.audio != null: sim.audio.play_remote(String(e[1]), e[2]) - "toast": - if sim.toasts != null: - sim.toasts.push(String(e[1]), e[2]) "loot": sim.loot.loot_event.emit(StringName(e[1]), int(e[2]), e[3]) - "arrived": - if sim.toasts != null: - sim.toasts.push(FarmSim.arrival_message(int(e[1]), sim.zones.side_of(e[2])), Color(1.0, 0.75, 0.55)) "destroyed": sim.structures.show_debris(e[3]) sim.structures.destroyed.emit(int(e[1]), String(e[2]), e[3]) @@ -995,7 +965,3 @@ func _hook(sig: Signal, callable: Callable) -> void: func _tag_all() -> void: for a in sim.avatars: a.body.set_tag(a.label(), a.color()) - - -static func _display(n: String, fallback: String) -> String: - return n if n != "" else fallback diff --git a/game/scripts/farm_sim.gd b/game/scripts/farm_sim.gd index 5071020..38ff17b 100644 --- a/game/scripts/farm_sim.gd +++ b/game/scripts/farm_sim.gd @@ -39,7 +39,6 @@ const NIGHT_PLANS: Array[String] = [ @export var zones: FarmZones @export var player: PlayerCharacter @export var camera: Camera3D -@export var toasts: ToastFeed @export var alerts: AlertManager @export var hud: ScarecrowHud @export var end_panel: EndPanel @@ -322,24 +321,6 @@ func _ready() -> void: campaign.phase_changed.connect(_on_phase_changed) campaign.night_ending.connect(_on_night_ending) - if toasts != null: - toasts.loot = loot - loot.loot_event.connect(toasts.on_loot_event) - interactions.message.connect(toasts.push) - if upgrade_panel != null: - upgrade_panel.message.connect(toasts.push) - if shed_panel != null: - shed_panel.message.connect(toasts.push) - build.message.connect(toasts.push) - waves.arrived.connect(func(h: int, at: Vector2) -> void: - toasts.push(arrival_message(enemies.type[enemies.resolve_handle(h)], zones.side_of(at)), Color(1.0, 0.75, 0.55))) - structures.destroyed.connect(func(_id: int, type: String, _at: Vector3) -> void: - toasts.push("Breach! A %s was broken" % StructureSystem.NAMES[type].to_lower(), Color(1.0, 0.35, 0.3))) - animals.pen_changed.connect(func(open: bool) -> void: - if open and campaign.state.phase != CampaignController.Phase.MORNING: - toasts.push("The pen is open: at night the animals in it will get out and roam loose", Color(1.0, 0.55, 0.35))) - scarecrow.patch_denied.connect(func(missing: Dictionary) -> void: - toasts.push("Not enough straw to patch up: need %s more" % ResourceStore.describe(missing), Color(1.0, 0.8, 0.5))) if alerts != null: alerts.setup(self) load_msec = Time.get_ticks_msec() - t0 @@ -751,30 +732,10 @@ func _breaker_goals() -> PackedInt32Array: return out -## "A crow flew in from the east", "A fence breaker came in from the south-west" (side: -## FarmZones.side_of the arrival point). -static func arrival_message(type: int, side: String) -> String: - var from := " from the %s" % side if side != "" else "" - match type: - EnemySystem.TYPE_CROW: - return "A crow flew in" + from - EnemySystem.TYPE_BREAKER: - return "An alien robot came in" + from - EnemySystem.TYPE_UFO: - return "A UFO swept in" + from - return "An alien slipped in" + from - - func _on_phase_changed(phase: CampaignController.Phase, _previous: CampaignController.Phase) -> void: match phase: - CampaignController.Phase.DUSK, CampaignController.Phase.NIGHT: - if toasts != null and scarecrow.alive and not zones.is_inside_fence(player.global_position): - toasts.push("You're outside the fence: get back in before nightfall!" if phase == CampaignController.Phase.DUSK - else "Night has fallen and you're outside the fence!", Color(1.0, 0.55, 0.35)) CampaignController.Phase.DAWN: behavior.retreat_all(enemies) - if enemies.alive_count() > 0 and toasts != null: - toasts.push("Sunrise! The aliens are running for it", Color(1.0, 0.85, 0.6)) CampaignController.Phase.MORNING: if partner == null and not replica: campaign.state.coop = false # a co-op save continued alone: solo rules diff --git a/game/scripts/interactions.gd b/game/scripts/interactions.gd index 3678419..1df4704 100644 --- a/game/scripts/interactions.gd +++ b/game/scripts/interactions.gd @@ -39,6 +39,8 @@ extends Node3D signal gathered(material: String, amount: int, node: GatherNode) signal deposited(moved: Dictionary) +## What happened, or why not ("Pouch full: ..."). Nothing shows it on screen since #23; tests +## listen to it. signal message(text: String, color: Color) ## A remote kit pressed interact at the workbench by day (its game opens the upgrade menu). signal workbench_requested diff --git a/game/scripts/loot_system.gd b/game/scripts/loot_system.gd index 6afb562..9d9a013 100644 --- a/game/scripts/loot_system.gd +++ b/game/scripts/loot_system.gd @@ -35,7 +35,7 @@ extends Node3D ## it never shows up mid-night, since a unit only sprouts between mornings. ## Supplies in a carried or dropped sack still count as on the farm (FarmState.supplies_in_transit). ## Claims and carriers are enemy handles (id + generation), so a stale handle from a reused enemy -## slot can never move an item. Every change emits loot_event (toasts now, sounds later); steals, +## slot can never move an item. Every change emits loot_event (sounds, tips); steals, ## recoveries, strays, and supply losses count toward the night's record. enum Category { CROP, ANIMAL, SUPPLY } diff --git a/game/scripts/main.gd b/game/scripts/main.gd index af290ff..671513e 100644 --- a/game/scripts/main.gd +++ b/game/scripts/main.gd @@ -97,9 +97,7 @@ func _ready() -> void: coop_menu.set_status(text)) lobby.failed.connect(func(text: String) -> void: if coop_menu.is_open: - coop_menu.set_status(text) - elif sim.toasts != null: - sim.toasts.push(text, Color(1.0, 0.6, 0.4))) + coop_menu.set_status(text)) lobby.lobbies_found.connect(func(list: Array) -> void: coop_menu.show_lobbies(list)) lobby.partner_arrived.connect(_on_partner_arrived) lobby.joined.connect(_on_joined) @@ -347,10 +345,9 @@ func _on_settings_closed() -> void: func _set_hud(on: bool) -> void: - for layer_name in ["Hud", "ZoneBanner"]: - var layer := farm.get_node_or_null(layer_name) as CanvasLayer - if layer != null: - layer.visible = on + var layer := farm.get_node_or_null("Hud") as CanvasLayer + if layer != null: + layer.visible = on func _place_menu_camera() -> void: @@ -366,8 +363,6 @@ func _unhandled_input(event: InputEvent) -> void: settings.microphone = not settings.microphone sim.coop.set_microphone(settings.microphone) settings.save_to(settings_path) - if sim.toasts != null: - sim.toasts.push("Microphone %s" % ("on" if settings.microphone else "muted"), Color(0.85, 0.95, 1.0)) get_viewport().set_input_as_handled() return if not event.is_action_pressed("pause"): diff --git a/game/scripts/toast_feed.gd b/game/scripts/toast_feed.gd deleted file mode 100644 index a11c7a8..0000000 --- a/game/scripts/toast_feed.gd +++ /dev/null @@ -1,95 +0,0 @@ -class_name ToastFeed -extends VBoxContainer -## Short event messages stacked under the zone banner, each fading after a few seconds. A fixed -## pool of labels is reused (the oldest message gives way). A message that's already showing -## isn't repeated: it counts up instead ("A crow flew in from the east ×4") and stays longer, -## so a flock arriving is one line. - -const LIFE := 3.2 -const FADE := 0.6 -const SLOTS := 5 -## Loot events per category (LootSystem.Category): the text ("%s" is the item's noun) and color. -const MESSAGES := { - &"stolen": [["A crop was snatched!", "A %s was grabbed!", "Aliens took %s from the shed!"], Color(1.0, 0.6, 0.15)], - &"dropped": [["The alien dropped the crop. Grab it!", "The alien dropped the %s. Lead it back to the pen!", - "The alien dropped %s. Grab it!"], Color(1.0, 0.9, 0.3)], - &"recovered": [["Crop recovered", "The %s is back in the pen", "%s back in the shed"], Color(0.5, 1.0, 0.45)], - &"returned": [["A dropped crop went back to its plot", "The %s went back to the pen", "%s went back to the shed"], - Color(0.85, 0.95, 1.0)], - &"lost": [["A crop was carried off the farm", "A %s was lost", "%s was carried off the farm"], Color(1.0, 0.3, 0.25)], - &"following": [["", "The %s follows you: lead it back to the pen", ""], Color(0.85, 1.0, 0.7)], - &"follow_full": [["", "You can only lead %d animals at a time", ""], Color(1.0, 0.8, 0.5)], - &"strayed": [["", "A %s wandered out of the open pen!", ""], Color(1.0, 0.6, 0.15)], -} - -## Set by FarmSim: what an event's item is. -var loot: LootSystem - -var _labels: Array[Label] = [] -var _left := PackedFloat32Array() -var _base: Array[String] = [] # each slot's message without its count -var _count := PackedInt32Array() - - -func _ready() -> void: - set_anchors_preset(Control.PRESET_TOP_WIDE) - offset_top = 152.0 - mouse_filter = Control.MOUSE_FILTER_IGNORE - alignment = BoxContainer.ALIGNMENT_BEGIN - _left.resize(SLOTS) - _count.resize(SLOTS) - _base.resize(SLOTS) - for i in SLOTS: - var l := Label.new() - l.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER - l.add_theme_font_size_override("font_size", 26) - l.add_theme_color_override("font_outline_color", Color.BLACK) - l.add_theme_constant_override("outline_size", 7) - l.visible = false - add_child(l) - _labels.append(l) - - -func push(text: String, color: Color) -> void: - for i in SLOTS: - if _left[i] > FADE and _base[i] == text: - _count[i] += 1 - _labels[i].text = "%s ×%d" % [text, _count[i]] - _left[i] = LIFE - return - var slot := 0 - for i in SLOTS: - if _left[i] < _left[slot]: - slot = i - var l := _labels[slot] - _base[slot] = text - _count[slot] = 1 - l.text = text - l.add_theme_color_override("font_color", color) - l.visible = true - _left[slot] = LIFE - move_child(l, get_child_count() - 1) # newest at the bottom - - -func on_loot_event(kind: StringName, id: int, _position: Vector3) -> void: - if not MESSAGES.has(kind): - return - var m: Array = MESSAGES[kind] - var c := int(loot.category[id]) if loot != null else LootSystem.Category.CROP - var text: String = m[0][c] - if text == "": - return - if text.contains("%d"): - text = text % loot.config.max_following_animals - elif text.contains("%s"): - text = text % (loot.noun(id) if loot != null else "item") - push(text[0].to_upper() + text.substr(1), m[1]) - - -func _process(delta: float) -> void: - for i in SLOTS: - if _left[i] <= 0.0: - continue - _left[i] = maxf(_left[i] - delta, 0.0) - _labels[i].visible = _left[i] > 0.0 - _labels[i].modulate.a = clampf(_left[i] / FADE, 0.0, 1.0) diff --git a/game/scripts/toast_feed.gd.uid b/game/scripts/toast_feed.gd.uid deleted file mode 100644 index 8a50a6b..0000000 --- a/game/scripts/toast_feed.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://f647f4bijmdy diff --git a/game/scripts/upgrade_panel.gd b/game/scripts/upgrade_panel.gd index a1561cd..2f8191d 100644 --- a/game/scripts/upgrade_panel.gd +++ b/game/scripts/upgrade_panel.gd @@ -9,6 +9,8 @@ extends CenterContainer ## Escape / B, interact again, by walking off, or at nightfall. The scarecrow stands still and ## can't shoot while either is open. +## A purchase's result text. Nothing shows it on screen since #23 (the rows say what's missing); +## tests listen to it. signal message(text: String, color: Color) signal bought(id: String) diff --git a/game/scripts/zone_banner.gd b/game/scripts/zone_banner.gd deleted file mode 100644 index ac926bf..0000000 --- a/game/scripts/zone_banner.gd +++ /dev/null @@ -1,37 +0,0 @@ -class_name ZoneBanner -extends CanvasLayer -## Shows a zone's name at the top of the screen when the tracked node walks into it, then fades. - -@export var zones: FarmZones -@export var target: Node3D -@export var hold_time: float = 1.6 -@export var fade_time: float = 0.6 - -var current: FarmZone -var _label: Label -var _left: float = 0.0 - - -func _ready() -> void: - _label = Label.new() - _label.set_anchors_preset(Control.PRESET_TOP_WIDE) - _label.offset_top = 64.0 - _label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER - _label.add_theme_font_size_override("font_size", 36) - _label.add_theme_color_override("font_outline_color", Color.BLACK) - _label.add_theme_constant_override("outline_size", 8) - _label.modulate.a = 0.0 - add_child(_label) - - -func _process(delta: float) -> void: - if zones == null or target == null: - return - var zone := zones.zone_at(target.global_position) - if zone != current: - current = zone - if zone != null: - _label.text = zone.display_name - _left = hold_time + fade_time - _left = maxf(_left - delta, 0.0) - _label.modulate.a = clampf(_left / fade_time, 0.0, 1.0) diff --git a/game/scripts/zone_banner.gd.uid b/game/scripts/zone_banner.gd.uid deleted file mode 100644 index 5b59a96..0000000 --- a/game/scripts/zone_banner.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://dbfcgsdrh5v60 diff --git a/game/tests/test_farm_layout.gd b/game/tests/test_farm_layout.gd index 9da7197..dc46d73 100644 --- a/game/tests/test_farm_layout.gd +++ b/game/tests/test_farm_layout.gd @@ -5,7 +5,7 @@ extends RefCounted ## arrive) and the gaps in what's left of the perimeter fence (the north and east sides, without ## holes except their gaps; the south, the west, and the east side south of the fence are open), ## ground navigation from anywhere on the edge to every zone, scarecrow-only bounds, zone-to-zone -## travel times (printed as the table kept in game/LAYOUT.md), and the zone banner. +## travel times (printed as the table kept in game/LAYOUT.md). const RUN_SPEED := 5.0 # PlayerCharacter.run_speed ## The layout rule: no key area more than 12 s from another. It holds for the farm's original @@ -51,7 +51,6 @@ func run(r: GameTestRunner) -> void: _enemy_routes(r, zones, nav) _scarecrow(r, farm, zones) _travel_times(r, farm, zones) - await _banner(r, farm, zones) farm.queue_free() await r.process_frame @@ -374,18 +373,3 @@ func _travel_times(r: GameTestRunner, farm: Node3D, zones: FarmZones) -> void: r.check(worst[1] <= MAX_TRAVEL_SOUTH_FIELDS, "the later crop fields, at the map's south end, are at most %.0f s from any key area (worst %.1f s: %s)" % [MAX_TRAVEL_SOUTH_FIELDS, worst[1], worst_pair[1]]) - -func _banner(r: GameTestRunner, farm: Node3D, zones: FarmZones) -> void: - var banner := farm.get_node("ZoneBanner") as ZoneBanner - var player := farm.get_node("Player") as Node3D - var start := player.global_transform - for zone in zones.zones(): - player.global_position = zone.global_position + Vector3(0.0, 0.5, 0.0) - await r.process_frame # emitted before _process, so wait for the next one too - await r.process_frame - r.check(banner.current == zone, "walking into the %s shows its name" % zone.display_name) - player.global_position = Vector3(8.0, 0.5, -10.0) - await r.process_frame - await r.process_frame - r.check(banner.current == null, "walking out of every zone clears the banner") - player.global_transform = start