Task #6: Supply Shed as its own weapon shop, separate from the Workbench
Adds a second UpgradePanel instance (shop "shed") at the Supply Shed's new
ShedCounter node, opened by interact like the Workbench. corn_shooter and
pumpkin_bomb move there ("shop": "shed" in GameConfig.upgrades); the
Workbench's panel (shop "workbench", the default) keeps rapid_fire,
heavy_seeds, and the rest, with "requires" still crossing shops. Co-op buys
go through the same ["buy", id] host gate; a shed_requested signal mirrors
workbench_requested so the partner's own shed panel opens. The shed's
walk-in pouch deposit is unaffected (no interact, not gated by the
counter's reach).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
1ccf825bbf
commit
308854d52c
17 changed files with 260 additions and 64 deletions
|
|
@ -162,6 +162,7 @@ func start_host(p_sim: FarmSim, p_link: CoopLink, p_my_name: String, p_partner_n
|
|||
_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:
|
||||
|
|
@ -206,6 +207,8 @@ func start_client(p_sim: FarmSim, p_link: CoopLink, p_my_name: String) -> void:
|
|||
sim.build.dismantle_request = func(id: int) -> void: _request(["dismantle", id])
|
||||
if sim.upgrade_panel != null:
|
||||
sim.upgrade_panel.buy_request = func(id: String) -> void: _request(["buy", id])
|
||||
if sim.shed_panel != null:
|
||||
sim.shed_panel.buy_request = func(id: String) -> void: _request(["buy", id])
|
||||
if sim.audio != null:
|
||||
sim.audio.remote_cues = true
|
||||
if sim.tutorial != null:
|
||||
|
|
@ -624,6 +627,8 @@ func _apply_state(d: Dictionary, everything: bool = false) -> void:
|
|||
sim.shed_stock.refresh()
|
||||
if sim.upgrade_panel != null and sim.upgrade_panel.is_open:
|
||||
sim.upgrade_panel.refresh()
|
||||
if sim.shed_panel != null and sim.shed_panel.is_open:
|
||||
sim.shed_panel.refresh()
|
||||
if c.state.phase == CampaignController.Phase.MORNING and sim.review_panel != null:
|
||||
sim.review_panel.refresh()
|
||||
|
||||
|
|
@ -682,6 +687,9 @@ func _apply_event(e: Array) -> void:
|
|||
"workbench":
|
||||
if sim.upgrade_panel != null and c.is_daytime():
|
||||
sim.upgrade_panel.open()
|
||||
"shed":
|
||||
if sim.shed_panel != null and c.is_daytime():
|
||||
sim.shed_panel.open()
|
||||
|
||||
|
||||
func _apply_snap(data: PackedByteArray) -> void:
|
||||
|
|
@ -766,7 +774,7 @@ func _apply_avatar(a: Avatar, rec: Dictionary) -> void:
|
|||
var ch := String(rec["ch"])
|
||||
if ch != "" and (not body.rooted or body.channel_clip != StringName(ch)):
|
||||
body.start_channel(StringName(ch))
|
||||
elif ch == "" and body.rooted and not (sim.upgrade_panel != null and sim.upgrade_panel.is_open):
|
||||
elif ch == "" and body.rooted and not sim._menu_open():
|
||||
body.stop_channel()
|
||||
var it := a.interactions
|
||||
it.focus = _gather_node(String(rec["fo"]))
|
||||
|
|
@ -880,7 +888,7 @@ func _reset_world() -> void:
|
|||
## replaced soon; standing still sends little).
|
||||
func _send_input() -> void:
|
||||
var a := sim.local_avatar
|
||||
var ui := sim.upgrade_panel != null and sim.upgrade_panel.is_open
|
||||
var ui := sim._menu_open()
|
||||
var rec := _sender.record(a.combat, a.body, sim.build.active, ui, sim.local_frozen)
|
||||
if rec != _last_input or _input_age >= INPUT_KEEPALIVE - 0.001: # (sums of 1/60 fall a hair short)
|
||||
_last_input = rec
|
||||
|
|
@ -894,16 +902,20 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||
_sender.note(event)
|
||||
|
||||
|
||||
## The upgrade menu closes here on the same rules as solo (Interactions): walking off,
|
||||
## nightfall, build mode.
|
||||
## Either shop's menu closes here on the same rules as solo (Interactions): walking off its
|
||||
## counter's reach, nightfall, build mode.
|
||||
func _close_menu_if_needed() -> void:
|
||||
var panel := sim.upgrade_panel
|
||||
_close_menu(sim.upgrade_panel, sim.interactions.workbench)
|
||||
_close_menu(sim.shed_panel, sim.interactions.shed_counter)
|
||||
|
||||
|
||||
## counter: Workbench or ShedCounter (both just need global_position and reach).
|
||||
func _close_menu(panel: UpgradePanel, counter) -> void:
|
||||
if panel == null or not panel.is_open:
|
||||
return
|
||||
var bench := sim.interactions.workbench
|
||||
var p := sim.local_avatar.position()
|
||||
if not sim.campaign.is_daytime() or sim.build.active or bench == null \
|
||||
or Vector2(bench.global_position.x, bench.global_position.z).distance_to(p) > bench.reach + 0.5:
|
||||
if not sim.campaign.is_daytime() or sim.build.active or counter == null \
|
||||
or Vector2(counter.global_position.x, counter.global_position.z).distance_to(p) > counter.reach + 0.5:
|
||||
panel.close()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -245,6 +245,9 @@ func setup(p_sim: FarmSim) -> void:
|
|||
if sim.upgrade_panel != null:
|
||||
sim.upgrade_panel.bought.connect(func(_id: String) -> void: play("upgrade"))
|
||||
wire_buttons(sim.upgrade_panel)
|
||||
if sim.shed_panel != null:
|
||||
sim.shed_panel.bought.connect(func(_id: String) -> void: play("upgrade"))
|
||||
wire_buttons(sim.shed_panel)
|
||||
if sim.review_panel != null:
|
||||
wire_buttons(sim.review_panel)
|
||||
if sim.end_panel != null:
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ const NIGHT_PLANS: Array[String] = [
|
|||
@export var asset_hud: AssetHud
|
||||
@export var review_panel: ReviewPanel
|
||||
@export var upgrade_panel: UpgradePanel
|
||||
@export var shed_panel: UpgradePanel
|
||||
@export var sun: DirectionalLight3D
|
||||
@export var world_environment: WorldEnvironment
|
||||
|
||||
|
|
@ -260,6 +261,13 @@ func _ready() -> void:
|
|||
var w := ScarecrowCombat.WEAPON_IDS.find(id)
|
||||
if w > 0:
|
||||
combat.equip(w))
|
||||
if shed_panel != null:
|
||||
shed_panel.setup(campaign, structures, player, "shed")
|
||||
interactions.shed_panel = shed_panel
|
||||
shed_panel.bought.connect(func(id: String) -> void: # a new weapon goes into its hand
|
||||
var w := ScarecrowCombat.WEAPON_IDS.find(id)
|
||||
if w > 0:
|
||||
combat.equip(w))
|
||||
if resource_hud != null:
|
||||
resource_hud.setup(campaign)
|
||||
resource_hud.structures = structures
|
||||
|
|
@ -307,6 +315,8 @@ func _ready() -> void:
|
|||
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)))
|
||||
|
|
@ -386,7 +396,7 @@ func _step_replica(dt: float) -> void:
|
|||
|
||||
|
||||
func _menu_open() -> bool:
|
||||
return upgrade_panel != null and upgrade_panel.is_open
|
||||
return (upgrade_panel != null and upgrade_panel.is_open) or (shed_panel != null and shed_panel.is_open)
|
||||
|
||||
|
||||
## Co-op: while this machine's scarecrow is down, the camera watches the partner's.
|
||||
|
|
@ -512,11 +522,14 @@ func set_local(a: Avatar) -> void:
|
|||
interactions.structures = structures
|
||||
interactions.build = build
|
||||
interactions.upgrade_panel = upgrade_panel
|
||||
interactions.shed_panel = shed_panel
|
||||
build.player = a.body
|
||||
build.combat = a.combat
|
||||
build.kit = a.kit
|
||||
if upgrade_panel != null:
|
||||
upgrade_panel.player = a.body
|
||||
if shed_panel != null:
|
||||
shed_panel.player = a.body
|
||||
if camera is FollowCamera:
|
||||
(camera as FollowCamera).target = a.body
|
||||
(camera as FollowCamera).snap_to_target()
|
||||
|
|
@ -732,6 +745,8 @@ func _on_phase_changed(phase: CampaignController.Phase, _previous: CampaignContr
|
|||
a.remote.release()
|
||||
if upgrade_panel != null:
|
||||
upgrade_panel.close()
|
||||
if shed_panel != null:
|
||||
shed_panel.close()
|
||||
if review_panel != null:
|
||||
review_panel.refresh() # after the farm is back in sync (the pen's gate)
|
||||
|
||||
|
|
|
|||
|
|
@ -125,16 +125,18 @@ extends Resource
|
|||
}
|
||||
|
||||
@export_group("Upgrades")
|
||||
## Bought once each by day at the work area's workbench, for costs[id] (Upgrades). Each changes
|
||||
## one stat: "mult" multiplies it, "add" adds to it. Stats are GameConfig settings, plus
|
||||
## scarecrow_max_hp (the scarecrow's, in FarmState) and barrier_hp (fences' and gates' health).
|
||||
## One without a stat unlocks something instead (sprint: PlayerCharacter; the corn shooter and
|
||||
## pumpkin bombs: ScarecrowCombat). "requires": another upgrade that must be bought first.
|
||||
## Bought once each by day, for costs[id] (Upgrades), either at the work area's workbench (the
|
||||
## default shop) or the supply shed's counter ("shop": "shed": weapons and other purchasable
|
||||
## items, Upgrades.shop_of, UpgradePanel's shop filter). Each changes one stat: "mult" multiplies
|
||||
## it, "add" adds to it. Stats are GameConfig settings, plus scarecrow_max_hp (the scarecrow's, in
|
||||
## FarmState) and barrier_hp (fences' and gates' health). One without a stat unlocks something
|
||||
## instead (sprint: PlayerCharacter; the corn shooter and pumpkin bombs: ScarecrowCombat).
|
||||
## "requires": another upgrade that must be bought first (from either shop).
|
||||
@export var upgrades: Dictionary = {
|
||||
"corn_shooter": {"name": "Corn shooter", "text": "A gun that fires corn kernels, from afar", "track": "Weapon"},
|
||||
"corn_shooter": {"name": "Corn shooter", "text": "A gun that fires corn kernels, from afar", "track": "Weapon", "shop": "shed"},
|
||||
"rapid_fire": {"name": "Rapid fire", "text": "The corn shooter fires a third faster", "track": "Weapon", "stat": "fire_rate", "mult": 1.333, "requires": "corn_shooter"},
|
||||
"heavy_seeds": {"name": "Heavy seeds", "text": "Each kernel does 2 damage", "track": "Weapon", "stat": "shot_damage", "add": 1, "requires": "corn_shooter"},
|
||||
"pumpkin_bomb": {"name": "Pumpkin bombs", "text": "Throw a pumpkin that bursts, hurting everything within 3 m (one every 4 s)", "track": "Weapon"},
|
||||
"pumpkin_bomb": {"name": "Pumpkin bombs", "text": "Throw a pumpkin that bursts, hurting everything within 3 m (one every 4 s)", "track": "Weapon", "shop": "shed"},
|
||||
"wide_fear": {"name": "Wide fear", "text": "Fear reaches 30% farther", "track": "Fear", "stat": "fear_radius", "mult": 1.3},
|
||||
"quick_fear": {"name": "Quick fear", "text": "Fear recharges 20% faster", "track": "Fear", "stat": "fear_cooldown", "mult": 0.8},
|
||||
"straw_stuffing": {"name": "Straw stuffing", "text": "+2 max health", "track": "Scarecrow", "stat": "scarecrow_max_hp", "add": 2},
|
||||
|
|
|
|||
|
|
@ -1,31 +1,37 @@
|
|||
class_name Interactions
|
||||
extends Node3D
|
||||
## The scarecrow's hands: gathering at GatherNodes, buying at the Workbench, repairing damaged
|
||||
## structures, and dropping the pouch off at the supply shed. Nothing here works in build mode.
|
||||
## * Focus: the nearest gather point or workbench within its reach, preferring points with
|
||||
## charges left over used-up ones; nearby points show their charges, the focused one its
|
||||
## prompt (or why it can't be used).
|
||||
## The scarecrow's hands: gathering at GatherNodes, buying at the Workbench or the supply shed's
|
||||
## ShedCounter, repairing damaged structures, and dropping the pouch off at the supply shed.
|
||||
## Nothing here works in build mode.
|
||||
## * Focus: the nearest gather point, workbench, or shed counter within its reach, preferring
|
||||
## gather points with charges left over used-up ones; nearby points show their charges, the
|
||||
## focused one its prompt (or why it can't be used).
|
||||
## * Gather: hold interact by day (D8) at a point with charges left and room in the pouch for
|
||||
## the whole yield (so a charge is never half wasted).
|
||||
## The scarecrow is rooted for gather_time looping the point's clip, then yield_amount goes
|
||||
## into the pouch ("+2 wood" pops up) and one charge is used. Keep holding to gather again.
|
||||
## Letting go, a hit, fear, nightfall, or a full pouch cancels it.
|
||||
## * Workbench: press interact by day to open the upgrade menu (UpgradePanel); interact again,
|
||||
## walking away, or nightfall closes it. Nothing else happens here while it's open.
|
||||
## * Workbench / shed counter: press interact by day to open that shop's menu (UpgradePanel,
|
||||
## shop "workbench" or "shed"); interact again, walking away, or nightfall closes it. Nothing
|
||||
## else happens here while one is open.
|
||||
## * Repair: a damaged structure within REPAIR_REACH comes first. Hold interact for
|
||||
## repair_time (any phase) to repair it fully for StructureSystem.repair_cost (paid at the
|
||||
## end); it is refused, once per press, without the materials.
|
||||
## * Deposit: walking into the Supply Shed zone empties the pouch into the shed.
|
||||
## * Deposit: walking into the Supply Shed zone empties the pouch into the shed (no interact,
|
||||
## and not gated by the shed counter's reach or the shed shop being open).
|
||||
## * Overnight (the end of the dawn grace) every used point regains regen_per_night charges.
|
||||
## In co-op each scarecrow has its own Interactions. The partner's, on the host, reads its
|
||||
## RemoteControls (remote), asks the partner's game to open its own upgrade menu
|
||||
## (workbench_requested), and leaves the gather labels to the local player's (show_labels).
|
||||
## (workbench_requested / shed_requested), and leaves the gather labels to the local player's
|
||||
## (show_labels).
|
||||
|
||||
signal gathered(material: String, amount: int, node: GatherNode)
|
||||
signal deposited(moved: Dictionary)
|
||||
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
|
||||
## A remote kit pressed interact at the shed counter by day (its game opens the shed's shop).
|
||||
signal shed_requested
|
||||
|
||||
const LABEL_RANGE := 7.0
|
||||
const REPAIR_REACH := 1.4
|
||||
|
|
@ -41,11 +47,13 @@ var zones: FarmZones
|
|||
var structures: StructureSystem
|
||||
var build: BuildMode
|
||||
var upgrade_panel: UpgradePanel
|
||||
var shed_panel: UpgradePanel
|
||||
## The partner's input on the host (co-op), and whether this one draws the gather labels.
|
||||
var remote: RemoteControls
|
||||
var show_labels := true
|
||||
var nodes: Array[GatherNode] = []
|
||||
var workbench: Workbench
|
||||
var shed_counter: ShedCounter
|
||||
var focus: Node3D
|
||||
var gathering: GatherNode
|
||||
var gather_elapsed: float = 0.0
|
||||
|
|
@ -76,6 +84,8 @@ func setup(cfg: GameConfig, p_campaign: CampaignController, p_player: PlayerChar
|
|||
nodes.append(n)
|
||||
elif n is Workbench and workbench == null:
|
||||
workbench = n
|
||||
elif n is ShedCounter and shed_counter == null:
|
||||
shed_counter = n
|
||||
kit.damaged.connect(func(_hp: int) -> void: cancel())
|
||||
kit.fear_used.connect(func(_p: Vector3, _n: int) -> void: cancel())
|
||||
_repair_label = Label3D.new()
|
||||
|
|
@ -114,7 +124,8 @@ func channeling() -> bool:
|
|||
|
||||
|
||||
func can_shoot() -> bool:
|
||||
return not channeling() and not (upgrade_panel != null and upgrade_panel.is_open) and not (remote != null and remote.ui_open)
|
||||
return not channeling() and not (upgrade_panel != null and upgrade_panel.is_open) \
|
||||
and not (shed_panel != null and shed_panel.is_open) and not (remote != null and remote.ui_open)
|
||||
|
||||
|
||||
## One physics tick, after the scarecrow kit.
|
||||
|
|
@ -130,15 +141,18 @@ func step(dt: float) -> void:
|
|||
if not kit.alive or (build != null and build.active) or (remote != null and (remote.build_active or remote.ui_open)):
|
||||
if upgrade_panel != null:
|
||||
upgrade_panel.close()
|
||||
if shed_panel != null:
|
||||
shed_panel.close()
|
||||
cancel()
|
||||
repair_target = -1
|
||||
focus = null
|
||||
return
|
||||
var p := Vector2(player.global_position.x, player.global_position.z)
|
||||
if upgrade_panel != null and upgrade_panel.is_open:
|
||||
var bench := Vector2(workbench.global_position.x, workbench.global_position.z) if workbench != null else p
|
||||
if pressed or not campaign.is_daytime() or bench.distance_to(p) > workbench.reach + 0.5 or (build != null and build.active):
|
||||
upgrade_panel.close()
|
||||
_step_menu(upgrade_panel, workbench, p, pressed)
|
||||
return
|
||||
if shed_panel != null and shed_panel.is_open:
|
||||
_step_menu(shed_panel, shed_counter, p, pressed)
|
||||
return
|
||||
if _shed != null and _shed.contains(player.global_position) and campaign.state.resources.pouch_total() > 0:
|
||||
var moved := campaign.state.resources.deposit()
|
||||
|
|
@ -197,6 +211,23 @@ func step(dt: float) -> void:
|
|||
upgrade_panel.open()
|
||||
elif remote != null:
|
||||
workbench_requested.emit()
|
||||
elif focus is ShedCounter and pressed:
|
||||
if not campaign.is_daytime():
|
||||
message.emit("The supply shed is for daytime", Color(1.0, 0.8, 0.5))
|
||||
elif shed_panel != null:
|
||||
shed_panel.open()
|
||||
elif remote != null:
|
||||
shed_requested.emit()
|
||||
|
||||
|
||||
## A shop's menu is open: closes it on interact again, by walking off its counter's reach, at
|
||||
## nightfall, or entering build mode (workbench: Workbench; shed: ShedCounter; both just need
|
||||
## global_position and reach).
|
||||
func _step_menu(panel: UpgradePanel, counter, p: Vector2, pressed: bool) -> void:
|
||||
var at := Vector2(counter.global_position.x, counter.global_position.z) if counter != null else p
|
||||
var reach: float = counter.reach if counter != null else 0.0
|
||||
if pressed or not campaign.is_daytime() or at.distance_to(p) > reach + 0.5 or (build != null and build.active):
|
||||
panel.close()
|
||||
|
||||
|
||||
## Why a point can't be gathered right now ("" if it can).
|
||||
|
|
@ -257,6 +288,11 @@ func _nearest(p: Vector2) -> Node3D:
|
|||
if d <= workbench.reach and d < best_d:
|
||||
best = workbench
|
||||
best_d = d
|
||||
if shed_counter != null:
|
||||
var d := Vector2(shed_counter.global_position.x, shed_counter.global_position.z).distance_to(p)
|
||||
if d <= shed_counter.reach and d < best_d:
|
||||
best = shed_counter
|
||||
best_d = d
|
||||
return best
|
||||
|
||||
|
||||
|
|
@ -289,6 +325,9 @@ func _process(delta: float) -> void:
|
|||
if workbench != null and show_labels:
|
||||
var near := Vector2(workbench.global_position.x - p.x, workbench.global_position.z - p.z).length() < LABEL_RANGE
|
||||
workbench.show_state(campaign, near and kit.alive, focus == workbench)
|
||||
if shed_counter != null and show_labels:
|
||||
var near := Vector2(shed_counter.global_position.x - p.x, shed_counter.global_position.z - p.z).length() < LABEL_RANGE
|
||||
shed_counter.show_state(campaign, near and kit.alive, focus == shed_counter)
|
||||
var shown := (repairing if repairing >= 0 else repair_target) if show_labels else -1
|
||||
_repair_label.visible = shown >= 0
|
||||
if shown >= 0:
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ func refresh() -> void:
|
|||
_title.text = "The farmers are away"
|
||||
lines.append("Keep the farm safe for %d nights until they come home: the crops, the animals in the pen, and the supplies in the shed." % nights)
|
||||
lines.append("By day, gather wood, scrap, and straw (hold E), store them at the barn, and build defenses (B). There's more to gather off the farm, to the north, east, and south.")
|
||||
lines.append("At night, stab aliens with your pitchfork (left mouse), scare them off (Q), and pick up anything they drop. A dropped animal runs off: walk up to it and lead it back to the pen. The workbench sells a corn shooter (switch weapons with Tab or 1-2) and pumpkin bombs (throw them with right mouse).")
|
||||
lines.append("At night, stab aliens with your pitchfork (left mouse), scare them off (Q), and pick up anything they drop. A dropped animal runs off: walk up to it and lead it back to the pen. The supply shed sells a corn shooter (switch weapons with Tab or 1-2) and pumpkin bombs (throw them with right mouse).")
|
||||
else:
|
||||
var e: Dictionary = s.night_log[s.night_log.size() - 1]
|
||||
_title.text = "Morning of day %d of %d" % [s.night, nights]
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ extends Control
|
|||
## recharging); plus a red screen tint when the scarecrow is hit. Bottom-right, the weapons:
|
||||
## the main ones by number, the one in hand marked, and how to switch; under them the off-hand
|
||||
## (pumpkin bombs, marked when one is ready, else its recharge) and its button. The ones not
|
||||
## bought yet are greyed out (from the workbench).
|
||||
## bought yet are greyed out (with where to buy them: Upgrades.shop_of).
|
||||
|
||||
const PIP := Vector2(22.0, 16.0)
|
||||
const PIP_GAP := 5.0
|
||||
|
|
@ -156,7 +156,8 @@ func _update_weapons() -> void:
|
|||
func _weapon_row(l: Label, text: String, w: int, lit: bool) -> void:
|
||||
var color := Color(0.95, 0.95, 0.95)
|
||||
if not combat.owns(w):
|
||||
text += " (workbench)"
|
||||
var shop := Upgrades.shop_of(campaign.config, ScarecrowCombat.WEAPON_IDS[w]) if campaign != null else "workbench"
|
||||
text += " (%s)" % ("supply shed" if shop == "shed" else "workbench")
|
||||
color = Color(0.55, 0.55, 0.55)
|
||||
elif lit:
|
||||
color = Color(1.0, 0.85, 0.3)
|
||||
|
|
|
|||
42
game/scripts/shed_counter.gd
Normal file
42
game/scripts/shed_counter.gd
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
class_name ShedCounter
|
||||
extends Node3D
|
||||
## The supply shed's purchase counter, where the scarecrow buys weapons and other items sold
|
||||
## there (Upgrades, UpgradePanel, shop "shed"): press interact here by day to open the shed's
|
||||
## shop. Its label shows how many of the shed's items are done. Separate from the shed's walk-in
|
||||
## pouch drop-off (Interactions.step, FarmZone.Kind.SUPPLY_SHED), which needs no interact and has
|
||||
## no counter of its own.
|
||||
|
||||
## How close the scarecrow's center has to be to this node's origin.
|
||||
@export var reach: float = 2.2
|
||||
|
||||
var _label: Label3D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_label = Label3D.new()
|
||||
_label.billboard = BaseMaterial3D.BILLBOARD_ENABLED
|
||||
_label.no_depth_test = true
|
||||
_label.shaded = false
|
||||
_label.font_size = 40
|
||||
_label.outline_size = 10
|
||||
_label.pixel_size = 0.0075
|
||||
_label.modulate = Color(0.85, 0.75, 1.0)
|
||||
_label.position = Vector3(0.0, 2.2, 0.0)
|
||||
_label.visible = false
|
||||
add_child(_label)
|
||||
|
||||
|
||||
func show_state(campaign: CampaignController, show: bool, focused: bool) -> void:
|
||||
_label.visible = show
|
||||
if not show:
|
||||
return
|
||||
var done := 0
|
||||
var total := 0
|
||||
for id in Upgrades.ORDER:
|
||||
if Upgrades.shop_of(campaign.config, id) != "shed":
|
||||
continue
|
||||
total += 1
|
||||
if Upgrades.owned(campaign.state, id):
|
||||
done += 1
|
||||
var hint := ("[E / X] Shop" if campaign.is_daytime() else "Shop by day") if focused else "Shop"
|
||||
_label.text = "%s\n%d of %d done" % [hint, done, total]
|
||||
1
game/scripts/shed_counter.gd.uid
Normal file
1
game/scripts/shed_counter.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bxd4bqbbuwrw2
|
||||
|
|
@ -17,7 +17,7 @@ const TEXT := {
|
|||
"store": "Your pouch only holds so much: walk onto the barn's apron (the Supply Shed) to store what you carry.",
|
||||
"build": "Press [B / d-pad up] to build. Pick a fence [1], place it with left mouse / RT. Aliens have to break through fences.",
|
||||
"dusk": "Dusk: aliens come at nightfall, from every side of the farm.",
|
||||
"shoot": "Aim with the mouse or the right stick and hold left mouse / RT to stab with your pitchfork. The workbench sells a corn shooter (switch with [Tab / 1-2]) and pumpkin bombs for your off-hand: throw them with [right mouse / LT].",
|
||||
"shoot": "Aim with the mouse or the right stick and hold left mouse / RT to stab with your pitchfork. The supply shed sells a corn shooter (switch with [Tab / 1-2]) and pumpkin bombs for your off-hand: throw them with [right mouse / LT].",
|
||||
"fear": "Crowded? [Q / LB] Fear scares off everything nearby, and they drop what they carry.",
|
||||
"recover": "Something was dropped! Walk over it to bring it home. A dropped animal follows you back to the pen.",
|
||||
"patch": "Hurt? Hold [F / Y] to patch up with straw. Health carries over to the next night.",
|
||||
|
|
@ -92,8 +92,7 @@ func _process(delta: float) -> void:
|
|||
if sim == null:
|
||||
return
|
||||
var s := sim.campaign.state
|
||||
if not enabled or dismissed or s.night != 1 or sim.campaign.is_over() \
|
||||
or (sim.upgrade_panel != null and sim.upgrade_panel.is_open):
|
||||
if not enabled or dismissed or s.night != 1 or sim.campaign.is_over() or sim._menu_open():
|
||||
_show("")
|
||||
return
|
||||
_check_done()
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
class_name UpgradePanel
|
||||
extends CenterContainer
|
||||
## The workbench's upgrade menu (Upgrades): one row per upgrade, by track, with what it does and
|
||||
## what it costs. A done one says so; one you can't afford says what's missing. It opens with
|
||||
## interact at the workbench by day (Interactions). Buy with a click, or the arrows / d-pad and
|
||||
## Enter / A. Close it with Close, Escape / B, interact again, by walking off, or at nightfall.
|
||||
## The scarecrow stands still and can't shoot while it's open.
|
||||
## A shop's menu (Upgrades): one row per upgrade or item sold by this instance's shop (shop,
|
||||
## Upgrades.shop_of), by track, with what it does and what it costs. A done one says so; one you
|
||||
## can't afford says what's missing. The work area's instance (shop "workbench": player/weapon
|
||||
## stat and buildable upgrades) opens with interact at the workbench by day; the supply shed's
|
||||
## (shop "shed": weapons and other purchasable items) opens with interact at the shed's counter by
|
||||
## day (Interactions). Buy with a click, or the arrows / d-pad and Enter / A. Close it with Close,
|
||||
## Escape / B, interact again, by walking off, or at nightfall. The scarecrow stands still and
|
||||
## can't shoot while either is open.
|
||||
|
||||
signal message(text: String, color: Color)
|
||||
signal bought(id: String)
|
||||
|
|
@ -13,6 +16,8 @@ var campaign: CampaignController
|
|||
var structures: StructureSystem
|
||||
var player: PlayerCharacter
|
||||
var is_open := false
|
||||
## Which shop this instance lists ("workbench" or "shed"); set by setup().
|
||||
var shop := "workbench"
|
||||
## Co-op partner: ask the host to buy (upgrade id); the result comes back as a message.
|
||||
var buy_request: Callable
|
||||
|
||||
|
|
@ -21,15 +26,16 @@ var _title: Label
|
|||
var _close: Button
|
||||
|
||||
|
||||
func setup(p_campaign: CampaignController, p_structures: StructureSystem, p_player: PlayerCharacter) -> void:
|
||||
func setup(p_campaign: CampaignController, p_structures: StructureSystem, p_player: PlayerCharacter, p_shop: String = "workbench") -> void:
|
||||
campaign = p_campaign
|
||||
structures = p_structures
|
||||
player = p_player
|
||||
shop = p_shop
|
||||
var box := get_node("Panel/Margin/Box") as VBoxContainer
|
||||
var track := ""
|
||||
for id in Upgrades.ORDER:
|
||||
var u: Dictionary = campaign.config.upgrades.get(id, {})
|
||||
if u.is_empty():
|
||||
if u.is_empty() or Upgrades.shop_of(campaign.config, id) != shop:
|
||||
continue
|
||||
if String(u.get("track", "")) != track:
|
||||
track = String(u.get("track", ""))
|
||||
|
|
@ -122,7 +128,8 @@ func refresh() -> void:
|
|||
if why != "" and why != "Done":
|
||||
b.text += " %s" % why
|
||||
b.disabled = why != ""
|
||||
_title.text = "Upgrades at the work area (%d of %d done)" % [done, _rows.size()]
|
||||
var place := "Upgrades at the work area" if shop == "workbench" else "Shop at the supply shed"
|
||||
_title.text = "%s (%d of %d done)" % [place, done, _rows.size()]
|
||||
|
||||
|
||||
func _buy(id: String) -> void:
|
||||
|
|
|
|||
|
|
@ -1,15 +1,18 @@
|
|||
class_name Upgrades
|
||||
extends RefCounted
|
||||
## The work area's upgrades (definitions in GameConfig.upgrades, costs in GameConfig.costs):
|
||||
## bought once each, by day, at the workbench's menu (UpgradePanel), and kept in
|
||||
## FarmState.upgrades (id -> 1), so they carry over between nights and come back with a retry.
|
||||
## Systems ask value() for a stat with the owned upgrades applied instead of reading GameConfig
|
||||
## directly: the corn shooter's fire rate and shot damage, fear's radius and cooldown, fences' and gates'
|
||||
## health (barrier_hp), the automated defense's range, and the traps' slow time. Straw stuffing
|
||||
## raises the scarecrow's max health (FarmState) when bought, and the Bigger pouch upgrade raises
|
||||
## pouch_capacity (ResourceStore) the same way. Sprint, the corn shooter, and pumpkin bombs change
|
||||
## no stat: owning them unlocks sprinting (PlayerCharacter) and the two weapons (ScarecrowCombat).
|
||||
## Rapid fire and heavy seeds need the corn shooter first ("requires").
|
||||
## The farm's upgrades and shop items (definitions in GameConfig.upgrades, costs in
|
||||
## GameConfig.costs): bought once each, by day, at one of two shops (shop_of, "workbench" by
|
||||
## default: player/weapon stat and buildable upgrades, at the work area; "shed": weapons and
|
||||
## other purchasable items, at the supply shed's counter), each its own UpgradePanel instance.
|
||||
## Bought ones are kept in FarmState.upgrades (id -> 1), so they carry over between nights and
|
||||
## come back with a retry. Systems ask value() for a stat with the owned upgrades applied instead
|
||||
## of reading GameConfig directly: the corn shooter's fire rate and shot damage, fear's radius and
|
||||
## cooldown, fences' and gates' health (barrier_hp), the automated defense's range, and the traps'
|
||||
## slow time. Straw stuffing raises the scarecrow's max health (FarmState) when bought, and the
|
||||
## Bigger pouch upgrade raises pouch_capacity (ResourceStore) the same way. Sprint, the corn
|
||||
## shooter, and pumpkin bombs change no stat: owning them unlocks sprinting (PlayerCharacter) and
|
||||
## the two weapons (ScarecrowCombat). Rapid fire and heavy seeds (bought at the workbench) need
|
||||
## the corn shooter (bought at the shed) first ("requires" crosses shops freely).
|
||||
|
||||
## Menu order, grouped by track.
|
||||
const ORDER: Array[String] = ["corn_shooter", "rapid_fire", "heavy_seeds", "pumpkin_bomb", "wide_fear", "quick_fear",
|
||||
|
|
@ -24,6 +27,14 @@ static func cost(cfg: GameConfig, id: String) -> Dictionary:
|
|||
return cfg.costs.get(id, {})
|
||||
|
||||
|
||||
## Which shop sells an upgrade: "workbench" (the default: player/weapon stat and buildable
|
||||
## upgrades, at the work area) or "shed" (weapons and other purchasable items, at the supply
|
||||
## shed's counter). UpgradePanel filters ORDER by this to build the two shops' rows; "requires"
|
||||
## can still cross shops (e.g. rapid_fire at the workbench requiring corn_shooter from the shed).
|
||||
static func shop_of(cfg: GameConfig, id: String) -> String:
|
||||
return String(cfg.upgrades.get(id, {}).get("shop", "workbench"))
|
||||
|
||||
|
||||
## Total Alien Goop collected this vacation so far: every completed night's "gathered_alien_goop"
|
||||
## (FarmState.totals(), from night_log) plus the current cycle's own count (night_events). This is
|
||||
## a running total, not a current balance (spending or being robbed of goop doesn't un-reveal
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue