Task #4: Alien Goop resource and drop-on-kill from Aliens
Add alien_goop as a 4th ResourceStore material alongside wood/scrap/straw, dropped only by killed Aliens (TYPE_THIEF) at a config-tunable rate/quantity (GameConfig.alien_goop_drop_chance default 0.33, alien_goop_drop_qty default 1), credited straight into the pouch like a gathered material via a new enemy_removed hook in FarmSim (seeded RNG for reproducible trials). It's stealable from the shed through the existing most-stocked-material sack mechanic once it outranks the others (ShedStock gets a placeholder front/ label spot for it, reusing the wood pile's proven-walkable spot; no new art). ResourceStore.from_dict() now treats a shed/pouch entry missing a material as 0 instead of rejecting it (old saves predate Alien Goop), and to_dict() always fills in every material so round-trips are consistent regardless of how the live dict was built; every method summing across MATERIALS reads with get(m, 0) so a hand-built 3-key dict elsewhere doesn't error out. New checks in test_economy.gd: _goop_persistence (retry discards goop gained since the morning; the morning snapshot round-trips through JSON) and _goop_drops (1000-kill statistical drop-rate check against config, type restriction to Aliens only, pouch-capacity-respecting credit, and shed-theft eligibility). Updated _state()'s and test_cycle.gd's hardcoded 3-key shed dicts for the new 4th material. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
aa50e97311
commit
1ab666e5e4
9 changed files with 178 additions and 37 deletions
|
|
@ -53,6 +53,16 @@ const PILES := {
|
|||
"front": Vector2(6.75, -16.25),
|
||||
"label": Vector3(6.2, 3.2, -18.4),
|
||||
},
|
||||
## No pile of its own yet (placeholder: it never shows props), but it needs a real front/label
|
||||
## spot so a supply thief sent for it (once it's the shed's most-stocked material) has
|
||||
## somewhere reachable to stand; the wood pile's spot is already proven walkable.
|
||||
"alien_goop": {
|
||||
"adopt": [],
|
||||
"extra": [],
|
||||
"per": 1,
|
||||
"front": Vector2(2.6, -18.6),
|
||||
"label": Vector3(4.2, 2.6, -18.3),
|
||||
},
|
||||
}
|
||||
|
||||
var campaign: CampaignController
|
||||
|
|
@ -114,13 +124,15 @@ static func props_for(material: String, amount: int, slot_count: int) -> int:
|
|||
|
||||
|
||||
## Shows each pile for the shed's stock (after the navigation is built; then on every change).
|
||||
## Reads the shed with get(m, 0): a shed dict replaced elsewhere without every material present
|
||||
## (tests, old saves) is treated as 0 for a pile not in it, rather than erroring.
|
||||
func refresh() -> void:
|
||||
var shed := campaign.state.resources.shed
|
||||
for m: String in slots:
|
||||
var list: Array = slots[m]
|
||||
var n := props_for(m, int(shed[m]), list.size())
|
||||
var n := props_for(m, int(shed.get(m, 0)), list.size())
|
||||
shown[m] = n
|
||||
_last[m] = int(shed[m])
|
||||
_last[m] = int(shed.get(m, 0))
|
||||
for i in list.size():
|
||||
var on := i < n
|
||||
(list[i] as Node3D).visible = on
|
||||
|
|
@ -133,7 +145,7 @@ func _process(_delta: float) -> void:
|
|||
return
|
||||
var shed := campaign.state.resources.shed
|
||||
for m: String in slots:
|
||||
if int(shed[m]) != int(_last.get(m, -1)):
|
||||
if int(shed.get(m, 0)) != int(_last.get(m, -1)):
|
||||
refresh()
|
||||
break
|
||||
var near := player != null
|
||||
|
|
@ -142,4 +154,4 @@ func _process(_delta: float) -> void:
|
|||
var at: Vector3 = PILES[m]["label"]
|
||||
l.visible = near and Vector2(player.global_position.x - at.x, player.global_position.z - at.z).length() < LABEL_RANGE
|
||||
if l.visible:
|
||||
l.text = "%s %d" % [m.capitalize(), int(shed[m])]
|
||||
l.text = "%s %d" % [m.capitalize(), int(shed.get(m, 0))]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue