Merge task #23: no zone banner or message feed
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
481f195f34
18 changed files with 37 additions and 286 deletions
15
README.md
15
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,
|
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,
|
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
|
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-only `PlayerBounds` on physics layer 3). `FarmNavigation` rasterizes the farm's
|
||||||
scarecrow walks in. `FarmNavigation` rasterizes the farm's collision into a 0.5 m grid for
|
collision into a 0.5 m grid for ground enemies. Details, travel times, and how to edit:
|
||||||
ground enemies. Details, travel times, and how to edit: [`game/LAYOUT.md`](game/LAYOUT.md).
|
[`game/LAYOUT.md`](game/LAYOUT.md).
|
||||||
`game/tools/render_overview.gd` renders a top-down picture (`--zones` draws the zones).
|
`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
|
* **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.
|
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 "!" 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.
|
- 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
|
- **`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
|
- 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 farm loses it for good.
|
||||||
- The scarecrow's weapons (`ScarecrowCombat`): mouse or right-stick aim, hold fire. It starts
|
- 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
|
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,
|
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,
|
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,
|
thief_behavior.gd, loot_system.gd, farm_projectiles.gd, scarecrow_combat.gd,
|
||||||
weapon_models.gd, pumpkin_bombs.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,
|
end_panel.gd, resource_store.gd, gather_node.gd, workbench.gd,
|
||||||
interactions.gd, resource_hud.gd, structure_system.gd, build_mode.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,
|
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
|
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
|
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,
|
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
|
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
|
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
|
exactly once, touch recovery, stale handles after slot reuse, shots hitting thieves and cruising
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ it acts.
|
||||||
|
|
||||||
| Piece | File | Does |
|
| 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 |
|
| `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 |
|
| `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 |
|
| `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
|
`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
|
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:
|
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
|
the hello and the welcome carry `CoopSession.PROTOCOL`, and a mismatch ends the session (the
|
||||||
message on both sides.
|
partner's main menu says why).
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
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
|
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
|
translucent box, so it can be moved and resized there.
|
||||||
name when the scarecrow walks in.
|
|
||||||
|
|
||||||
| Zone | Rectangle (x, z) | What's there | Purpose |
|
| 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 |
|
| 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.
|
`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_zones()` lists these, and `zone_at()` finds both.
|
||||||
(outside the fence)").
|
|
||||||
|
|
||||||
**The South Fields** (#20) are the strip of plowed soil between the map's south edge (z 35) and the
|
**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
|
old farm's south fence (z ≈ 46.4). Their hay rests on the soil there, south of the later crop
|
||||||
|
|
|
||||||
|
|
@ -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.
|
is loose where it fell and roams from there. If that's inside the pen, it's home again.
|
||||||
- **Leading animals home (D6).**
|
- **Leading animals home (D6).**
|
||||||
- Walk up to a loose animal and it follows the scarecrow, walking its trail in line, gates
|
- 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).
|
- 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.
|
- 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.
|
- 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.
|
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
|
- **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.
|
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
|
- 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
|
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.
|
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.
|
**2 straw**. The straw is paid when the patch completes.
|
||||||
- Releasing early, taking a hit, or using fear cancels it.
|
- Releasing early, taking a hit, or using fear cancels it.
|
||||||
- Keep holding to patch again.
|
- Keep holding to patch again.
|
||||||
- It isn't available at full health, while gathering, or without the straw (a message says
|
- It isn't available at full health, while gathering, or without the straw (an error sound
|
||||||
what's missing).
|
plays).
|
||||||
- It works in any phase (D8).
|
- It works in any phase (D8).
|
||||||
- **Defeat:** at **0 HP** the scarecrow falls and the game is over at once (scarecrow first,
|
- **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
|
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 East Road: scrap, the abandoned car;
|
||||||
- the South Fields: straw, on the old plowed fields.
|
- the South Fields: straw, on the old plowed fields.
|
||||||
- They grow back overnight like the others. Gathering is still daytime only.
|
- 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,
|
- Building, the enemies' paths, and the night stay inside the fence.
|
||||||
a scarecrow still outside gets a warning.
|
|
||||||
- **Work area:** press E / X at the tool table, by day, to open the upgrade menu (below).
|
- **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
|
- **Persistence:** materials (shed and pouch), used gather points, and upgrades carry over
|
||||||
between nights and are restored by a retry.
|
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
|
- 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,
|
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.
|
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:
|
- 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
|
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.
|
120 ms in total over 47 ticks, at most 2.6 ms in one tick.
|
||||||
|
|
|
||||||
|
|
@ -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://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://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://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://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://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"]
|
[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="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="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="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://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://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"]
|
[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)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 54.8, 1.5, -6.3)
|
||||||
shape = SubResource("BoxShape3D_bounds_we")
|
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="Hud" type="CanvasLayer" parent="." unique_id=666315498]
|
||||||
|
|
||||||
[node name="Alerts" type="Control" parent="Hud" unique_id=110836126]
|
[node name="Alerts" type="Control" parent="Hud" unique_id=110836126]
|
||||||
|
|
@ -3691,14 +3684,6 @@ grow_vertical = 2
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
script = ExtResource("103_threats")
|
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]
|
[node name="ScarecrowHud" type="Control" parent="Hud" unique_id=1120148247]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
|
|
@ -3785,13 +3770,12 @@ grow_vertical = 2
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
script = ExtResource("114_upgrades")
|
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")
|
script = ExtResource("102_farm_sim")
|
||||||
campaign = NodePath("../Campaign")
|
campaign = NodePath("../Campaign")
|
||||||
zones = NodePath("../Zones")
|
zones = NodePath("../Zones")
|
||||||
player = NodePath("../Player")
|
player = NodePath("../Player")
|
||||||
camera = NodePath("../Camera")
|
camera = NodePath("../Camera")
|
||||||
toasts = NodePath("../Hud/ToastFeed")
|
|
||||||
alerts = NodePath("../Hud/Alerts")
|
alerts = NodePath("../Hud/Alerts")
|
||||||
hud = NodePath("../Hud/ScarecrowHud")
|
hud = NodePath("../Hud/ScarecrowHud")
|
||||||
end_panel = NodePath("../Hud/EndPanel")
|
end_panel = NodePath("../Hud/EndPanel")
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,9 @@ extends Node3D
|
||||||
## cancel leaves build mode.
|
## cancel leaves build mode.
|
||||||
## The scarecrow doesn't shoot, gather, or repair while building (FarmSim, Interactions).
|
## 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,
|
## 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).
|
## 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)
|
signal toggled(on: bool)
|
||||||
## A placement was refused (the reason); a structure was taken down.
|
## A placement was refused (the reason); a structure was taken down.
|
||||||
signal refused(reason: String)
|
signal refused(reason: String)
|
||||||
|
|
@ -122,10 +121,8 @@ func step(_dt: float) -> void:
|
||||||
hover = -1
|
hover = -1
|
||||||
return
|
return
|
||||||
var e := campaign.state.structure(hover)
|
var e := campaign.state.structure(hover)
|
||||||
var back := structures.dismantle(hover)
|
structures.dismantle(hover)
|
||||||
dismantled.emit(String(e["type"]))
|
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
|
hover = -1
|
||||||
return
|
return
|
||||||
reason = structures.validate(type(), cursor.x, cursor.y, rot, me, kit.slot)
|
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)
|
place_request.call(type(), cursor.x, cursor.y, rot)
|
||||||
elif reason == "":
|
elif reason == "":
|
||||||
structures.place(type(), cursor.x, cursor.y, rot, kit.slot)
|
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:
|
else:
|
||||||
message.emit(reason, Color(1.0, 0.8, 0.5))
|
|
||||||
refused.emit(reason)
|
refused.emit(reason)
|
||||||
elif p[&"cancel"]:
|
elif p[&"cancel"]:
|
||||||
set_active(false)
|
set_active(false)
|
||||||
|
|
|
||||||
|
|
@ -84,8 +84,6 @@ func cycle_scenario() -> void:
|
||||||
if _scenario >= 0:
|
if _scenario >= 0:
|
||||||
plan = load("res://game/resources/scenarios/%s.tres" % SCENARIOS[_scenario]) as NightPlan
|
plan = load("res://game/resources/scenarios/%s.tres" % SCENARIOS[_scenario]) as NightPlan
|
||||||
sim.waves.debug_plan = plan
|
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:
|
func _describe() -> String:
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ extends Node
|
||||||
## welcome (reliable, once) the farm state, the phase, tonight's time, the loot, the names
|
## welcome (reliable, once) the farm state, the phase, tonight's time, the loot, the names
|
||||||
## refused (reliable) the partner's game speaks another PROTOCOL
|
## refused (reliable) the partner's game speaks another PROTOCOL
|
||||||
## batch (reliable, each tick with news) events in order: phase changes (with the state),
|
## 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,
|
## the end of the campaign, sounds, loot news, breaches, fear bursts, attacks,
|
||||||
## breaches, fear bursts, gather popups, opening a shop's menu (the workbench's, the
|
## 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
|
## shed's), a purchase the partner made (bought: the slot and the upgrade id, so a
|
||||||
## new weapon goes into its hand); enemies removed
|
## new weapon goes into its hand); enemies removed
|
||||||
## state (reliable, at most STATE_HZ, when it changed) the farm state (the phase clock
|
## 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:
|
_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])
|
_removed.append([h, int(reason), x, z])
|
||||||
_foe_sent.erase(h))
|
_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:
|
_hook(sim.loot.loot_event, func(kind: StringName, id: int, at: Vector3) -> void:
|
||||||
_events.append(["loot", String(kind), id, at]))
|
_events.append(["loot", String(kind), id, at]))
|
||||||
_hook(sim.structures.destroyed, func(id: int, type: String, at: Vector3) -> void:
|
_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.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(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(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.workbench_requested, func() -> void: _events.append(["workbench"]))
|
||||||
_hook(a.interactions.shed_requested, func() -> void: _events.append(["shed"]))
|
_hook(a.interactions.shed_requested, func() -> void: _events.append(["shed"]))
|
||||||
_hook(a.interactions.gathered, func(m: String, amount: int, n: GatherNode) -> void:
|
_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]]))
|
_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:
|
if sim.audio != null:
|
||||||
sim.audio.forward = func(cue: String, at: Vector3) -> void: _events.append(["sound", cue, at])
|
sim.audio.forward = func(cue: String, at: Vector3) -> void: _events.append(["sound", cue, at])
|
||||||
_ensure_coop()
|
_ensure_coop()
|
||||||
_state_hash = 0
|
_state_hash = 0
|
||||||
_loot_hash = 0
|
_loot_hash = 0
|
||||||
_welcome_sent = false # sent when the partner says hello (then it is surely listening)
|
_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)
|
partner_joined.emit(partner_name)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -249,14 +241,9 @@ func stop(reason: String = "") -> void:
|
||||||
sim.audio.forward = Callable()
|
sim.audio.forward = Callable()
|
||||||
if was == Role.HOST:
|
if was == Role.HOST:
|
||||||
var gone_name := partner_name
|
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.avatars[0].player_name = ""
|
||||||
sim.player.set_tag("", Color.WHITE)
|
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)
|
partner_left.emit(gone_name)
|
||||||
else:
|
else:
|
||||||
ended.emit(reason)
|
ended.emit(reason)
|
||||||
|
|
@ -503,10 +490,7 @@ func _host_message(kind: String, data: Variant) -> void:
|
||||||
partner_name = String(hello.get("name", partner_name))
|
partner_name = String(hello.get("name", partner_name))
|
||||||
if int(hello.get("v", 1)) != PROTOCOL:
|
if int(hello.get("v", 1)) != PROTOCOL:
|
||||||
link.send("refused", {"v": PROTOCOL}, true)
|
link.send("refused", {"v": PROTOCOL}, true)
|
||||||
var who := _display(partner_name, "Your friend")
|
|
||||||
stop()
|
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
|
return
|
||||||
a.player_name = partner_name
|
a.player_name = partner_name
|
||||||
_tag_all()
|
_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)
|
var why := sim.structures.validate(type, x, z, rot, a.position(), a.slot)
|
||||||
if why == "":
|
if why == "":
|
||||||
sim.structures.place(type, x, z, rot, a.slot) # paid from P2's pouch, then the shed
|
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:
|
else:
|
||||||
_events.append(["toast", why, Color(1.0, 0.8, 0.5)])
|
|
||||||
_events.append(["sound", "error", Vector3.INF])
|
_events.append(["sound", "error", Vector3.INF])
|
||||||
"dismantle":
|
"dismantle":
|
||||||
var e := c.state.structure(int(r[1]))
|
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:
|
if e.is_empty() or a.position().distance_to(Vector2(e["x"], e["z"])) > sim.config.build_range:
|
||||||
return
|
return
|
||||||
var back := sim.structures.dismantle(int(r[1]))
|
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)])
|
|
||||||
"buy":
|
"buy":
|
||||||
var id := String(r[1])
|
var id := String(r[1])
|
||||||
if Upgrades.shop_of(c.config, id) == "workbench" and (sim.structures == null or not sim.structures.workbench_available()):
|
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
|
return
|
||||||
var was := Upgrades.owned(c.state, id)
|
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
|
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)])
|
|
||||||
if not was and Upgrades.owned(c.state, id):
|
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
|
_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:
|
if sim.day_night != null:
|
||||||
sim.day_night.snap()
|
sim.day_night.snap()
|
||||||
_is_welcomed = true
|
_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()
|
welcomed.emit()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -697,14 +673,8 @@ func _apply_event(e: Array) -> void:
|
||||||
"sound":
|
"sound":
|
||||||
if sim.audio != null:
|
if sim.audio != null:
|
||||||
sim.audio.play_remote(String(e[1]), e[2])
|
sim.audio.play_remote(String(e[1]), e[2])
|
||||||
"toast":
|
|
||||||
if sim.toasts != null:
|
|
||||||
sim.toasts.push(String(e[1]), e[2])
|
|
||||||
"loot":
|
"loot":
|
||||||
sim.loot.loot_event.emit(StringName(e[1]), int(e[2]), e[3])
|
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":
|
"destroyed":
|
||||||
sim.structures.show_debris(e[3])
|
sim.structures.show_debris(e[3])
|
||||||
sim.structures.destroyed.emit(int(e[1]), String(e[2]), 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:
|
func _tag_all() -> void:
|
||||||
for a in sim.avatars:
|
for a in sim.avatars:
|
||||||
a.body.set_tag(a.label(), a.color())
|
a.body.set_tag(a.label(), a.color())
|
||||||
|
|
||||||
|
|
||||||
static func _display(n: String, fallback: String) -> String:
|
|
||||||
return n if n != "" else fallback
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,6 @@ const NIGHT_PLANS: Array[String] = [
|
||||||
@export var zones: FarmZones
|
@export var zones: FarmZones
|
||||||
@export var player: PlayerCharacter
|
@export var player: PlayerCharacter
|
||||||
@export var camera: Camera3D
|
@export var camera: Camera3D
|
||||||
@export var toasts: ToastFeed
|
|
||||||
@export var alerts: AlertManager
|
@export var alerts: AlertManager
|
||||||
@export var hud: ScarecrowHud
|
@export var hud: ScarecrowHud
|
||||||
@export var end_panel: EndPanel
|
@export var end_panel: EndPanel
|
||||||
|
|
@ -322,24 +321,6 @@ func _ready() -> void:
|
||||||
|
|
||||||
campaign.phase_changed.connect(_on_phase_changed)
|
campaign.phase_changed.connect(_on_phase_changed)
|
||||||
campaign.night_ending.connect(_on_night_ending)
|
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:
|
if alerts != null:
|
||||||
alerts.setup(self)
|
alerts.setup(self)
|
||||||
load_msec = Time.get_ticks_msec() - t0
|
load_msec = Time.get_ticks_msec() - t0
|
||||||
|
|
@ -751,30 +732,10 @@ func _breaker_goals() -> PackedInt32Array:
|
||||||
return out
|
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:
|
func _on_phase_changed(phase: CampaignController.Phase, _previous: CampaignController.Phase) -> void:
|
||||||
match phase:
|
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:
|
CampaignController.Phase.DAWN:
|
||||||
behavior.retreat_all(enemies)
|
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:
|
CampaignController.Phase.MORNING:
|
||||||
if partner == null and not replica:
|
if partner == null and not replica:
|
||||||
campaign.state.coop = false # a co-op save continued alone: solo rules
|
campaign.state.coop = false # a co-op save continued alone: solo rules
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,8 @@ extends Node3D
|
||||||
|
|
||||||
signal gathered(material: String, amount: int, node: GatherNode)
|
signal gathered(material: String, amount: int, node: GatherNode)
|
||||||
signal deposited(moved: Dictionary)
|
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)
|
signal message(text: String, color: Color)
|
||||||
## A remote kit pressed interact at the workbench by day (its game opens the upgrade menu).
|
## A remote kit pressed interact at the workbench by day (its game opens the upgrade menu).
|
||||||
signal workbench_requested
|
signal workbench_requested
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ extends Node3D
|
||||||
## it never shows up mid-night, since a unit only sprouts between mornings.
|
## 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).
|
## 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
|
## 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.
|
## recoveries, strays, and supply losses count toward the night's record.
|
||||||
|
|
||||||
enum Category { CROP, ANIMAL, SUPPLY }
|
enum Category { CROP, ANIMAL, SUPPLY }
|
||||||
|
|
|
||||||
|
|
@ -97,9 +97,7 @@ func _ready() -> void:
|
||||||
coop_menu.set_status(text))
|
coop_menu.set_status(text))
|
||||||
lobby.failed.connect(func(text: String) -> void:
|
lobby.failed.connect(func(text: String) -> void:
|
||||||
if coop_menu.is_open:
|
if coop_menu.is_open:
|
||||||
coop_menu.set_status(text)
|
coop_menu.set_status(text))
|
||||||
elif sim.toasts != null:
|
|
||||||
sim.toasts.push(text, Color(1.0, 0.6, 0.4)))
|
|
||||||
lobby.lobbies_found.connect(func(list: Array) -> void: coop_menu.show_lobbies(list))
|
lobby.lobbies_found.connect(func(list: Array) -> void: coop_menu.show_lobbies(list))
|
||||||
lobby.partner_arrived.connect(_on_partner_arrived)
|
lobby.partner_arrived.connect(_on_partner_arrived)
|
||||||
lobby.joined.connect(_on_joined)
|
lobby.joined.connect(_on_joined)
|
||||||
|
|
@ -347,10 +345,9 @@ func _on_settings_closed() -> void:
|
||||||
|
|
||||||
|
|
||||||
func _set_hud(on: bool) -> void:
|
func _set_hud(on: bool) -> void:
|
||||||
for layer_name in ["Hud", "ZoneBanner"]:
|
var layer := farm.get_node_or_null("Hud") as CanvasLayer
|
||||||
var layer := farm.get_node_or_null(layer_name) as CanvasLayer
|
if layer != null:
|
||||||
if layer != null:
|
layer.visible = on
|
||||||
layer.visible = on
|
|
||||||
|
|
||||||
|
|
||||||
func _place_menu_camera() -> void:
|
func _place_menu_camera() -> void:
|
||||||
|
|
@ -366,8 +363,6 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||||
settings.microphone = not settings.microphone
|
settings.microphone = not settings.microphone
|
||||||
sim.coop.set_microphone(settings.microphone)
|
sim.coop.set_microphone(settings.microphone)
|
||||||
settings.save_to(settings_path)
|
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()
|
get_viewport().set_input_as_handled()
|
||||||
return
|
return
|
||||||
if not event.is_action_pressed("pause"):
|
if not event.is_action_pressed("pause"):
|
||||||
|
|
|
||||||
|
|
@ -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)
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
uid://f647f4bijmdy
|
|
||||||
|
|
@ -9,6 +9,8 @@ extends CenterContainer
|
||||||
## Escape / B, interact again, by walking off, or at nightfall. The scarecrow stands still and
|
## Escape / B, interact again, by walking off, or at nightfall. The scarecrow stands still and
|
||||||
## can't shoot while either is open.
|
## 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 message(text: String, color: Color)
|
||||||
signal bought(id: String)
|
signal bought(id: String)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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)
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
uid://dbfcgsdrh5v60
|
|
||||||
|
|
@ -5,7 +5,7 @@ extends RefCounted
|
||||||
## arrive) and the gaps in what's left of the perimeter fence (the north and east sides, without
|
## 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),
|
## 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
|
## 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
|
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
|
## 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)
|
_enemy_routes(r, zones, nav)
|
||||||
_scarecrow(r, farm, zones)
|
_scarecrow(r, farm, zones)
|
||||||
_travel_times(r, farm, zones)
|
_travel_times(r, farm, zones)
|
||||||
await _banner(r, farm, zones)
|
|
||||||
farm.queue_free()
|
farm.queue_free()
|
||||||
await r.process_frame
|
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)"
|
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]])
|
% [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
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue