Merge task #6: Supply Shed shop (weapons move from the workbench)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
86755d886c
17 changed files with 260 additions and 64 deletions
|
|
@ -77,6 +77,7 @@ costs = {
|
||||||
upgrades = {
|
upgrades = {
|
||||||
"corn_shooter": {
|
"corn_shooter": {
|
||||||
"name": "Corn shooter",
|
"name": "Corn shooter",
|
||||||
|
"shop": "shed",
|
||||||
"text": "A gun that fires corn kernels, from afar",
|
"text": "A gun that fires corn kernels, from afar",
|
||||||
"track": "Weapon"
|
"track": "Weapon"
|
||||||
},
|
},
|
||||||
|
|
@ -104,6 +105,7 @@ upgrades = {
|
||||||
},
|
},
|
||||||
"pumpkin_bomb": {
|
"pumpkin_bomb": {
|
||||||
"name": "Pumpkin bombs",
|
"name": "Pumpkin bombs",
|
||||||
|
"shop": "shed",
|
||||||
"text": "Throw a pumpkin that bursts, hurting everything within 3 m (one every 4 s)",
|
"text": "Throw a pumpkin that bursts, hurting everything within 3 m (one every 4 s)",
|
||||||
"track": "Weapon"
|
"track": "Weapon"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@
|
||||||
[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"]
|
||||||
[ext_resource type="Script" uid="uid://cj88bbt6nct61" path="res://game/scripts/gather_node.gd" id="108_gather"]
|
[ext_resource type="Script" uid="uid://cj88bbt6nct61" path="res://game/scripts/gather_node.gd" id="108_gather"]
|
||||||
[ext_resource type="Script" uid="uid://dr1dglq0p05hu" path="res://game/scripts/workbench.gd" id="109_workbench"]
|
[ext_resource type="Script" uid="uid://dr1dglq0p05hu" path="res://game/scripts/workbench.gd" id="109_workbench"]
|
||||||
|
[ext_resource type="Script" uid="uid://bxd4bqbbuwrw2" path="res://game/scripts/shed_counter.gd" id="237_shed_counter"]
|
||||||
[ext_resource type="Script" uid="uid://kmuyj86rfjj2" path="res://game/scripts/build_hud.gd" id="110_build_hud"]
|
[ext_resource type="Script" uid="uid://kmuyj86rfjj2" path="res://game/scripts/build_hud.gd" id="110_build_hud"]
|
||||||
[ext_resource type="Script" uid="uid://bp7dq566avk2v" path="res://game/scripts/phase_hud.gd" id="111_phase_hud"]
|
[ext_resource type="Script" uid="uid://bp7dq566avk2v" path="res://game/scripts/phase_hud.gd" id="111_phase_hud"]
|
||||||
[ext_resource type="Script" uid="uid://cwll33writ0hq" path="res://game/scripts/review_panel.gd" id="112_review"]
|
[ext_resource type="Script" uid="uid://cwll33writ0hq" path="res://game/scripts/review_panel.gd" id="112_review"]
|
||||||
|
|
@ -2281,6 +2282,10 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.8, 0, 2.4)
|
||||||
[node name="barrel_010_1" parent="Zones/SupplyShed" unique_id=306653999 instance=ExtResource("210_barrel_010")]
|
[node name="barrel_010_1" parent="Zones/SupplyShed" unique_id=306653999 instance=ExtResource("210_barrel_010")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.7, 0, 2.9)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.7, 0, 2.9)
|
||||||
|
|
||||||
|
[node name="ShedCounter" type="Node3D" parent="Zones/SupplyShed"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 3.5)
|
||||||
|
script = ExtResource("237_shed_counter")
|
||||||
|
|
||||||
[node name="WorkArea" type="Node3D" parent="Zones" unique_id=1622333960]
|
[node name="WorkArea" type="Node3D" parent="Zones" unique_id=1622333960]
|
||||||
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 28.599358, 0, -25.317692)
|
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 28.599358, 0, -25.317692)
|
||||||
script = ExtResource("201_farm_zone")
|
script = ExtResource("201_farm_zone")
|
||||||
|
|
@ -3046,7 +3051,16 @@ 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", "sun", "world_environment")]
|
[node name="ShedPanel" type="CenterContainer" parent="Hud"]
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
mouse_filter = 2
|
||||||
|
script = ExtResource("114_upgrades")
|
||||||
|
|
||||||
|
[node name="FarmSim" type="Node" parent="." unique_id=117307361 node_paths=PackedStringArray("campaign", "zones", "player", "camera", "toasts", "alerts", "hud", "end_panel", "resource_hud", "build_hud", "phase_hud", "asset_hud", "review_panel", "upgrade_panel", "shed_panel", "sun", "world_environment")]
|
||||||
script = ExtResource("102_farm_sim")
|
script = ExtResource("102_farm_sim")
|
||||||
campaign = NodePath("../Campaign")
|
campaign = NodePath("../Campaign")
|
||||||
zones = NodePath("../Zones")
|
zones = NodePath("../Zones")
|
||||||
|
|
@ -3062,5 +3076,6 @@ phase_hud = NodePath("../Hud/PhaseHud")
|
||||||
asset_hud = NodePath("../Hud/AssetHud")
|
asset_hud = NodePath("../Hud/AssetHud")
|
||||||
review_panel = NodePath("../Hud/ReviewPanel")
|
review_panel = NodePath("../Hud/ReviewPanel")
|
||||||
upgrade_panel = NodePath("../Hud/UpgradePanel")
|
upgrade_panel = NodePath("../Hud/UpgradePanel")
|
||||||
|
shed_panel = NodePath("../Hud/ShedPanel")
|
||||||
sun = NodePath("../Sun")
|
sun = NodePath("../Sun")
|
||||||
world_environment = NodePath("../WorldEnvironment")
|
world_environment = NodePath("../WorldEnvironment")
|
||||||
|
|
|
||||||
|
|
@ -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(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.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.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:
|
_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])
|
sim.build.dismantle_request = func(id: int) -> void: _request(["dismantle", id])
|
||||||
if sim.upgrade_panel != null:
|
if sim.upgrade_panel != null:
|
||||||
sim.upgrade_panel.buy_request = func(id: String) -> void: _request(["buy", id])
|
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:
|
if sim.audio != null:
|
||||||
sim.audio.remote_cues = true
|
sim.audio.remote_cues = true
|
||||||
if sim.tutorial != null:
|
if sim.tutorial != null:
|
||||||
|
|
@ -624,6 +627,8 @@ func _apply_state(d: Dictionary, everything: bool = false) -> void:
|
||||||
sim.shed_stock.refresh()
|
sim.shed_stock.refresh()
|
||||||
if sim.upgrade_panel != null and sim.upgrade_panel.is_open:
|
if sim.upgrade_panel != null and sim.upgrade_panel.is_open:
|
||||||
sim.upgrade_panel.refresh()
|
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:
|
if c.state.phase == CampaignController.Phase.MORNING and sim.review_panel != null:
|
||||||
sim.review_panel.refresh()
|
sim.review_panel.refresh()
|
||||||
|
|
||||||
|
|
@ -682,6 +687,9 @@ func _apply_event(e: Array) -> void:
|
||||||
"workbench":
|
"workbench":
|
||||||
if sim.upgrade_panel != null and c.is_daytime():
|
if sim.upgrade_panel != null and c.is_daytime():
|
||||||
sim.upgrade_panel.open()
|
sim.upgrade_panel.open()
|
||||||
|
"shed":
|
||||||
|
if sim.shed_panel != null and c.is_daytime():
|
||||||
|
sim.shed_panel.open()
|
||||||
|
|
||||||
|
|
||||||
func _apply_snap(data: PackedByteArray) -> void:
|
func _apply_snap(data: PackedByteArray) -> void:
|
||||||
|
|
@ -766,7 +774,7 @@ func _apply_avatar(a: Avatar, rec: Dictionary) -> void:
|
||||||
var ch := String(rec["ch"])
|
var ch := String(rec["ch"])
|
||||||
if ch != "" and (not body.rooted or body.channel_clip != StringName(ch)):
|
if ch != "" and (not body.rooted or body.channel_clip != StringName(ch)):
|
||||||
body.start_channel(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()
|
body.stop_channel()
|
||||||
var it := a.interactions
|
var it := a.interactions
|
||||||
it.focus = _gather_node(String(rec["fo"]))
|
it.focus = _gather_node(String(rec["fo"]))
|
||||||
|
|
@ -880,7 +888,7 @@ func _reset_world() -> void:
|
||||||
## replaced soon; standing still sends little).
|
## replaced soon; standing still sends little).
|
||||||
func _send_input() -> void:
|
func _send_input() -> void:
|
||||||
var a := sim.local_avatar
|
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)
|
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)
|
if rec != _last_input or _input_age >= INPUT_KEEPALIVE - 0.001: # (sums of 1/60 fall a hair short)
|
||||||
_last_input = rec
|
_last_input = rec
|
||||||
|
|
@ -894,16 +902,20 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||||
_sender.note(event)
|
_sender.note(event)
|
||||||
|
|
||||||
|
|
||||||
## The upgrade menu closes here on the same rules as solo (Interactions): walking off,
|
## Either shop's menu closes here on the same rules as solo (Interactions): walking off its
|
||||||
## nightfall, build mode.
|
## counter's reach, nightfall, build mode.
|
||||||
func _close_menu_if_needed() -> void:
|
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:
|
if panel == null or not panel.is_open:
|
||||||
return
|
return
|
||||||
var bench := sim.interactions.workbench
|
|
||||||
var p := sim.local_avatar.position()
|
var p := sim.local_avatar.position()
|
||||||
if not sim.campaign.is_daytime() or sim.build.active or bench == null \
|
if not sim.campaign.is_daytime() or sim.build.active or counter == null \
|
||||||
or Vector2(bench.global_position.x, bench.global_position.z).distance_to(p) > bench.reach + 0.5:
|
or Vector2(counter.global_position.x, counter.global_position.z).distance_to(p) > counter.reach + 0.5:
|
||||||
panel.close()
|
panel.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -245,6 +245,9 @@ func setup(p_sim: FarmSim) -> void:
|
||||||
if sim.upgrade_panel != null:
|
if sim.upgrade_panel != null:
|
||||||
sim.upgrade_panel.bought.connect(func(_id: String) -> void: play("upgrade"))
|
sim.upgrade_panel.bought.connect(func(_id: String) -> void: play("upgrade"))
|
||||||
wire_buttons(sim.upgrade_panel)
|
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:
|
if sim.review_panel != null:
|
||||||
wire_buttons(sim.review_panel)
|
wire_buttons(sim.review_panel)
|
||||||
if sim.end_panel != null:
|
if sim.end_panel != null:
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ const NIGHT_PLANS: Array[String] = [
|
||||||
@export var asset_hud: AssetHud
|
@export var asset_hud: AssetHud
|
||||||
@export var review_panel: ReviewPanel
|
@export var review_panel: ReviewPanel
|
||||||
@export var upgrade_panel: UpgradePanel
|
@export var upgrade_panel: UpgradePanel
|
||||||
|
@export var shed_panel: UpgradePanel
|
||||||
@export var sun: DirectionalLight3D
|
@export var sun: DirectionalLight3D
|
||||||
@export var world_environment: WorldEnvironment
|
@export var world_environment: WorldEnvironment
|
||||||
|
|
||||||
|
|
@ -260,6 +261,13 @@ func _ready() -> void:
|
||||||
var w := ScarecrowCombat.WEAPON_IDS.find(id)
|
var w := ScarecrowCombat.WEAPON_IDS.find(id)
|
||||||
if w > 0:
|
if w > 0:
|
||||||
combat.equip(w))
|
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:
|
if resource_hud != null:
|
||||||
resource_hud.setup(campaign)
|
resource_hud.setup(campaign)
|
||||||
resource_hud.structures = structures
|
resource_hud.structures = structures
|
||||||
|
|
@ -307,6 +315,8 @@ func _ready() -> void:
|
||||||
interactions.message.connect(toasts.push)
|
interactions.message.connect(toasts.push)
|
||||||
if upgrade_panel != null:
|
if upgrade_panel != null:
|
||||||
upgrade_panel.message.connect(toasts.push)
|
upgrade_panel.message.connect(toasts.push)
|
||||||
|
if shed_panel != null:
|
||||||
|
shed_panel.message.connect(toasts.push)
|
||||||
build.message.connect(toasts.push)
|
build.message.connect(toasts.push)
|
||||||
waves.arrived.connect(func(h: int, at: Vector2) -> void:
|
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)))
|
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:
|
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.
|
## 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.structures = structures
|
||||||
interactions.build = build
|
interactions.build = build
|
||||||
interactions.upgrade_panel = upgrade_panel
|
interactions.upgrade_panel = upgrade_panel
|
||||||
|
interactions.shed_panel = shed_panel
|
||||||
build.player = a.body
|
build.player = a.body
|
||||||
build.combat = a.combat
|
build.combat = a.combat
|
||||||
build.kit = a.kit
|
build.kit = a.kit
|
||||||
if upgrade_panel != null:
|
if upgrade_panel != null:
|
||||||
upgrade_panel.player = a.body
|
upgrade_panel.player = a.body
|
||||||
|
if shed_panel != null:
|
||||||
|
shed_panel.player = a.body
|
||||||
if camera is FollowCamera:
|
if camera is FollowCamera:
|
||||||
(camera as FollowCamera).target = a.body
|
(camera as FollowCamera).target = a.body
|
||||||
(camera as FollowCamera).snap_to_target()
|
(camera as FollowCamera).snap_to_target()
|
||||||
|
|
@ -732,6 +745,8 @@ func _on_phase_changed(phase: CampaignController.Phase, _previous: CampaignContr
|
||||||
a.remote.release()
|
a.remote.release()
|
||||||
if upgrade_panel != null:
|
if upgrade_panel != null:
|
||||||
upgrade_panel.close()
|
upgrade_panel.close()
|
||||||
|
if shed_panel != null:
|
||||||
|
shed_panel.close()
|
||||||
if review_panel != null:
|
if review_panel != null:
|
||||||
review_panel.refresh() # after the farm is back in sync (the pen's gate)
|
review_panel.refresh() # after the farm is back in sync (the pen's gate)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -125,16 +125,18 @@ extends Resource
|
||||||
}
|
}
|
||||||
|
|
||||||
@export_group("Upgrades")
|
@export_group("Upgrades")
|
||||||
## Bought once each by day at the work area's workbench, for costs[id] (Upgrades). Each changes
|
## Bought once each by day, for costs[id] (Upgrades), either at the work area's workbench (the
|
||||||
## one stat: "mult" multiplies it, "add" adds to it. Stats are GameConfig settings, plus
|
## default shop) or the supply shed's counter ("shop": "shed": weapons and other purchasable
|
||||||
## scarecrow_max_hp (the scarecrow's, in FarmState) and barrier_hp (fences' and gates' health).
|
## items, Upgrades.shop_of, UpgradePanel's shop filter). Each changes one stat: "mult" multiplies
|
||||||
## One without a stat unlocks something instead (sprint: PlayerCharacter; the corn shooter and
|
## it, "add" adds to it. Stats are GameConfig settings, plus scarecrow_max_hp (the scarecrow's, in
|
||||||
## pumpkin bombs: ScarecrowCombat). "requires": another upgrade that must be bought first.
|
## 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 = {
|
@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"},
|
"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"},
|
"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},
|
"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},
|
"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},
|
"straw_stuffing": {"name": "Straw stuffing", "text": "+2 max health", "track": "Scarecrow", "stat": "scarecrow_max_hp", "add": 2},
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,37 @@
|
||||||
class_name Interactions
|
class_name Interactions
|
||||||
extends Node3D
|
extends Node3D
|
||||||
## The scarecrow's hands: gathering at GatherNodes, buying at the Workbench, repairing damaged
|
## The scarecrow's hands: gathering at GatherNodes, buying at the Workbench or the supply shed's
|
||||||
## structures, and dropping the pouch off at the supply shed. Nothing here works in build mode.
|
## ShedCounter, repairing damaged structures, and dropping the pouch off at the supply shed.
|
||||||
## * Focus: the nearest gather point or workbench within its reach, preferring points with
|
## Nothing here works in build mode.
|
||||||
## charges left over used-up ones; nearby points show their charges, the focused one its
|
## * Focus: the nearest gather point, workbench, or shed counter within its reach, preferring
|
||||||
## prompt (or why it can't be used).
|
## 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
|
## * 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 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
|
## 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.
|
## 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.
|
## 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,
|
## * Workbench / shed counter: press interact by day to open that shop's menu (UpgradePanel,
|
||||||
## walking away, or nightfall closes it. Nothing else happens here while it's open.
|
## 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: 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
|
## 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.
|
## 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.
|
## * 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
|
## 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
|
## 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 gathered(material: String, amount: int, node: GatherNode)
|
||||||
signal deposited(moved: Dictionary)
|
signal deposited(moved: Dictionary)
|
||||||
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
|
||||||
|
## 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 LABEL_RANGE := 7.0
|
||||||
const REPAIR_REACH := 1.4
|
const REPAIR_REACH := 1.4
|
||||||
|
|
@ -41,11 +47,13 @@ var zones: FarmZones
|
||||||
var structures: StructureSystem
|
var structures: StructureSystem
|
||||||
var build: BuildMode
|
var build: BuildMode
|
||||||
var upgrade_panel: UpgradePanel
|
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.
|
## The partner's input on the host (co-op), and whether this one draws the gather labels.
|
||||||
var remote: RemoteControls
|
var remote: RemoteControls
|
||||||
var show_labels := true
|
var show_labels := true
|
||||||
var nodes: Array[GatherNode] = []
|
var nodes: Array[GatherNode] = []
|
||||||
var workbench: Workbench
|
var workbench: Workbench
|
||||||
|
var shed_counter: ShedCounter
|
||||||
var focus: Node3D
|
var focus: Node3D
|
||||||
var gathering: GatherNode
|
var gathering: GatherNode
|
||||||
var gather_elapsed: float = 0.0
|
var gather_elapsed: float = 0.0
|
||||||
|
|
@ -76,6 +84,8 @@ func setup(cfg: GameConfig, p_campaign: CampaignController, p_player: PlayerChar
|
||||||
nodes.append(n)
|
nodes.append(n)
|
||||||
elif n is Workbench and workbench == null:
|
elif n is Workbench and workbench == null:
|
||||||
workbench = n
|
workbench = n
|
||||||
|
elif n is ShedCounter and shed_counter == null:
|
||||||
|
shed_counter = n
|
||||||
kit.damaged.connect(func(_hp: int) -> void: cancel())
|
kit.damaged.connect(func(_hp: int) -> void: cancel())
|
||||||
kit.fear_used.connect(func(_p: Vector3, _n: int) -> void: cancel())
|
kit.fear_used.connect(func(_p: Vector3, _n: int) -> void: cancel())
|
||||||
_repair_label = Label3D.new()
|
_repair_label = Label3D.new()
|
||||||
|
|
@ -114,7 +124,8 @@ func channeling() -> bool:
|
||||||
|
|
||||||
|
|
||||||
func can_shoot() -> 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.
|
## 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 not kit.alive or (build != null and build.active) or (remote != null and (remote.build_active or remote.ui_open)):
|
||||||
if upgrade_panel != null:
|
if upgrade_panel != null:
|
||||||
upgrade_panel.close()
|
upgrade_panel.close()
|
||||||
|
if shed_panel != null:
|
||||||
|
shed_panel.close()
|
||||||
cancel()
|
cancel()
|
||||||
repair_target = -1
|
repair_target = -1
|
||||||
focus = null
|
focus = null
|
||||||
return
|
return
|
||||||
var p := Vector2(player.global_position.x, player.global_position.z)
|
var p := Vector2(player.global_position.x, player.global_position.z)
|
||||||
if upgrade_panel != null and upgrade_panel.is_open:
|
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
|
_step_menu(upgrade_panel, workbench, p, pressed)
|
||||||
if pressed or not campaign.is_daytime() or bench.distance_to(p) > workbench.reach + 0.5 or (build != null and build.active):
|
return
|
||||||
upgrade_panel.close()
|
if shed_panel != null and shed_panel.is_open:
|
||||||
|
_step_menu(shed_panel, shed_counter, p, pressed)
|
||||||
return
|
return
|
||||||
if _shed != null and _shed.contains(player.global_position) and campaign.state.resources.pouch_total() > 0:
|
if _shed != null and _shed.contains(player.global_position) and campaign.state.resources.pouch_total() > 0:
|
||||||
var moved := campaign.state.resources.deposit()
|
var moved := campaign.state.resources.deposit()
|
||||||
|
|
@ -197,6 +211,23 @@ func step(dt: float) -> void:
|
||||||
upgrade_panel.open()
|
upgrade_panel.open()
|
||||||
elif remote != null:
|
elif remote != null:
|
||||||
workbench_requested.emit()
|
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).
|
## 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:
|
if d <= workbench.reach and d < best_d:
|
||||||
best = workbench
|
best = workbench
|
||||||
best_d = d
|
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
|
return best
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -289,6 +325,9 @@ func _process(delta: float) -> void:
|
||||||
if workbench != null and show_labels:
|
if workbench != null and show_labels:
|
||||||
var near := Vector2(workbench.global_position.x - p.x, workbench.global_position.z - p.z).length() < LABEL_RANGE
|
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)
|
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
|
var shown := (repairing if repairing >= 0 else repair_target) if show_labels else -1
|
||||||
_repair_label.visible = shown >= 0
|
_repair_label.visible = shown >= 0
|
||||||
if shown >= 0:
|
if shown >= 0:
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ func refresh() -> void:
|
||||||
_title.text = "The farmers are away"
|
_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("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("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:
|
else:
|
||||||
var e: Dictionary = s.night_log[s.night_log.size() - 1]
|
var e: Dictionary = s.night_log[s.night_log.size() - 1]
|
||||||
_title.text = "Morning of day %d of %d" % [s.night, nights]
|
_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:
|
## 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
|
## 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
|
## (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 := Vector2(22.0, 16.0)
|
||||||
const PIP_GAP := 5.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:
|
func _weapon_row(l: Label, text: String, w: int, lit: bool) -> void:
|
||||||
var color := Color(0.95, 0.95, 0.95)
|
var color := Color(0.95, 0.95, 0.95)
|
||||||
if not combat.owns(w):
|
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)
|
color = Color(0.55, 0.55, 0.55)
|
||||||
elif lit:
|
elif lit:
|
||||||
color = Color(1.0, 0.85, 0.3)
|
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.",
|
"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.",
|
"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.",
|
"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.",
|
"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.",
|
"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.",
|
"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:
|
if sim == null:
|
||||||
return
|
return
|
||||||
var s := sim.campaign.state
|
var s := sim.campaign.state
|
||||||
if not enabled or dismissed or s.night != 1 or sim.campaign.is_over() \
|
if not enabled or dismissed or s.night != 1 or sim.campaign.is_over() or sim._menu_open():
|
||||||
or (sim.upgrade_panel != null and sim.upgrade_panel.is_open):
|
|
||||||
_show("")
|
_show("")
|
||||||
return
|
return
|
||||||
_check_done()
|
_check_done()
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,13 @@
|
||||||
class_name UpgradePanel
|
class_name UpgradePanel
|
||||||
extends CenterContainer
|
extends CenterContainer
|
||||||
## The workbench's upgrade menu (Upgrades): one row per upgrade, by track, with what it does and
|
## A shop's menu (Upgrades): one row per upgrade or item sold by this instance's shop (shop,
|
||||||
## what it costs. A done one says so; one you can't afford says what's missing. It opens with
|
## Upgrades.shop_of), by track, with what it does and what it costs. A done one says so; one you
|
||||||
## interact at the workbench by day (Interactions). Buy with a click, or the arrows / d-pad and
|
## can't afford says what's missing. The work area's instance (shop "workbench": player/weapon
|
||||||
## Enter / A. Close it with Close, Escape / B, interact again, by walking off, or at nightfall.
|
## stat and buildable upgrades) opens with interact at the workbench by day; the supply shed's
|
||||||
## The scarecrow stands still and can't shoot while it's open.
|
## (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 message(text: String, color: Color)
|
||||||
signal bought(id: String)
|
signal bought(id: String)
|
||||||
|
|
@ -13,6 +16,8 @@ var campaign: CampaignController
|
||||||
var structures: StructureSystem
|
var structures: StructureSystem
|
||||||
var player: PlayerCharacter
|
var player: PlayerCharacter
|
||||||
var is_open := false
|
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.
|
## Co-op partner: ask the host to buy (upgrade id); the result comes back as a message.
|
||||||
var buy_request: Callable
|
var buy_request: Callable
|
||||||
|
|
||||||
|
|
@ -21,15 +26,16 @@ var _title: Label
|
||||||
var _close: Button
|
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
|
campaign = p_campaign
|
||||||
structures = p_structures
|
structures = p_structures
|
||||||
player = p_player
|
player = p_player
|
||||||
|
shop = p_shop
|
||||||
var box := get_node("Panel/Margin/Box") as VBoxContainer
|
var box := get_node("Panel/Margin/Box") as VBoxContainer
|
||||||
var track := ""
|
var track := ""
|
||||||
for id in Upgrades.ORDER:
|
for id in Upgrades.ORDER:
|
||||||
var u: Dictionary = campaign.config.upgrades.get(id, {})
|
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
|
continue
|
||||||
if String(u.get("track", "")) != track:
|
if String(u.get("track", "")) != track:
|
||||||
track = String(u.get("track", ""))
|
track = String(u.get("track", ""))
|
||||||
|
|
@ -122,7 +128,8 @@ func refresh() -> void:
|
||||||
if why != "" and why != "Done":
|
if why != "" and why != "Done":
|
||||||
b.text += " %s" % why
|
b.text += " %s" % why
|
||||||
b.disabled = 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:
|
func _buy(id: String) -> void:
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,18 @@
|
||||||
class_name Upgrades
|
class_name Upgrades
|
||||||
extends RefCounted
|
extends RefCounted
|
||||||
## The work area's upgrades (definitions in GameConfig.upgrades, costs in GameConfig.costs):
|
## The farm's upgrades and shop items (definitions in GameConfig.upgrades, costs in
|
||||||
## bought once each, by day, at the workbench's menu (UpgradePanel), and kept in
|
## GameConfig.costs): bought once each, by day, at one of two shops (shop_of, "workbench" by
|
||||||
## FarmState.upgrades (id -> 1), so they carry over between nights and come back with a retry.
|
## default: player/weapon stat and buildable upgrades, at the work area; "shed": weapons and
|
||||||
## Systems ask value() for a stat with the owned upgrades applied instead of reading GameConfig
|
## other purchasable items, at the supply shed's counter), each its own UpgradePanel instance.
|
||||||
## directly: the corn shooter's fire rate and shot damage, fear's radius and cooldown, fences' and gates'
|
## Bought ones are kept in FarmState.upgrades (id -> 1), so they carry over between nights and
|
||||||
## health (barrier_hp), the automated defense's range, and the traps' slow time. Straw stuffing
|
## come back with a retry. Systems ask value() for a stat with the owned upgrades applied instead
|
||||||
## raises the scarecrow's max health (FarmState) when bought, and the Bigger pouch upgrade raises
|
## of reading GameConfig directly: the corn shooter's fire rate and shot damage, fear's radius and
|
||||||
## pouch_capacity (ResourceStore) the same way. Sprint, the corn shooter, and pumpkin bombs change
|
## cooldown, fences' and gates' health (barrier_hp), the automated defense's range, and the traps'
|
||||||
## no stat: owning them unlocks sprinting (PlayerCharacter) and the two weapons (ScarecrowCombat).
|
## slow time. Straw stuffing raises the scarecrow's max health (FarmState) when bought, and the
|
||||||
## Rapid fire and heavy seeds need the corn shooter first ("requires").
|
## 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.
|
## Menu order, grouped by track.
|
||||||
const ORDER: Array[String] = ["corn_shooter", "rapid_fire", "heavy_seeds", "pumpkin_bomb", "wide_fear", "quick_fear",
|
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, {})
|
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"
|
## 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
|
## (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
|
## a running total, not a current balance (spending or being robbed of goop doesn't un-reveal
|
||||||
|
|
|
||||||
|
|
@ -135,10 +135,12 @@ func _requests() -> void:
|
||||||
client.build.place_request.call("fence", 30.0, -30.0, 0)
|
client.build.place_request.call("fence", 30.0, -30.0, 0)
|
||||||
_pump(20)
|
_pump(20)
|
||||||
r.check(host.structures.count() == before + 1, "a placement out of the partner's reach is refused by the host")
|
r.check(host.structures.count() == before + 1, "a placement out of the partner's reach is refused by the host")
|
||||||
client.upgrade_panel.buy_request.call("corn_shooter")
|
r.check(not host.upgrade_panel._rows.has("corn_shooter") and host.shed_panel._rows.has("corn_shooter"),
|
||||||
|
"the corn shooter is sold at the supply shed's menu, not the workbench's (also on the partner's replica)")
|
||||||
|
client.shed_panel.buy_request.call("corn_shooter")
|
||||||
_pump(20)
|
_pump(20)
|
||||||
r.check(Upgrades.owned(host.campaign.state, "corn_shooter") and Upgrades.owned(client.campaign.state, "corn_shooter"),
|
r.check(Upgrades.owned(host.campaign.state, "corn_shooter") and Upgrades.owned(client.campaign.state, "corn_shooter"),
|
||||||
"the partner buys an upgrade at the workbench (the host does it)")
|
"the partner buys a weapon at the supply shed (the host does it)")
|
||||||
|
|
||||||
|
|
||||||
## Standing still by day: the clock runs, nothing else changes.
|
## Standing still by day: the clock runs, nothing else changes.
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,9 @@ extends RefCounted
|
||||||
## Goop (#4): dropped only by killed Aliens (thieves) at a config-tunable rate, credited like a
|
## Goop (#4): dropped only by killed Aliens (thieves) at a config-tunable rate, credited like a
|
||||||
## gathered material, stealable from the shed once it's the stock on top, and surviving retry,
|
## gathered material, stealable from the shed once it's the stock on top, and surviving retry,
|
||||||
## and hidden/reveal shop items (#5): an item flagged "hidden" shows only "?" and can't be bought
|
## and hidden/reveal shop items (#5): an item flagged "hidden" shows only "?" and can't be bought
|
||||||
## until enough Alien Goop has been collected in total, then shows and buys normally.
|
## until enough Alien Goop has been collected in total, then shows and buys normally; and the
|
||||||
|
## supply shed's own shop (#6): weapons (corn_shooter, pumpkin_bomb) bought at its counter
|
||||||
|
## (ShedCounter), not the workbench, with the walk-in pouch deposit unaffected.
|
||||||
|
|
||||||
const P := CampaignController.Phase
|
const P := CampaignController.Phase
|
||||||
const DT := 1.0 / 60.0
|
const DT := 1.0 / 60.0
|
||||||
|
|
@ -33,6 +35,7 @@ func run(r: GameTestRunner) -> void:
|
||||||
_deposit_and_night(r, sim, player)
|
_deposit_and_night(r, sim, player)
|
||||||
_patch_cost(r, sim)
|
_patch_cost(r, sim)
|
||||||
_stuffing(r, sim, player)
|
_stuffing(r, sim, player)
|
||||||
|
_shed_shop(r, sim, player)
|
||||||
_goop_drops(r, sim)
|
_goop_drops(r, sim)
|
||||||
farm.queue_free()
|
farm.queue_free()
|
||||||
await r.process_frame
|
await r.process_frame
|
||||||
|
|
@ -415,6 +418,43 @@ func _stuffing(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void
|
||||||
menu.close()
|
menu.close()
|
||||||
|
|
||||||
|
|
||||||
|
## #6: weapons (corn_shooter, pumpkin_bomb) moved to their own shop at the supply shed's counter
|
||||||
|
## (ShedCounter, shop "shed"), separate from the workbench's upgrade menu; buying one there works
|
||||||
|
## the same way, and the shed's walk-in pouch deposit still needs no interact and isn't gated by
|
||||||
|
## the counter's reach or its shop being open.
|
||||||
|
func _shed_shop(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void:
|
||||||
|
var c := sim.campaign
|
||||||
|
var s := c.state
|
||||||
|
var it := sim.interactions
|
||||||
|
var counter := it.shed_counter
|
||||||
|
var bench_menu := sim.upgrade_panel
|
||||||
|
var menu := sim.shed_panel
|
||||||
|
r.check(counter != null and menu != null, "the supply shed has its own counter and shop menu")
|
||||||
|
r.check(not bench_menu._rows.has("corn_shooter") and not bench_menu._rows.has("pumpkin_bomb")
|
||||||
|
and menu._rows.has("corn_shooter") and menu._rows.has("pumpkin_bomb"),
|
||||||
|
"the workbench no longer sells the weapons; the shed's menu does")
|
||||||
|
s.upgrades.erase("corn_shooter")
|
||||||
|
s.resources.shed = {"wood": 4, "scrap": 10, "straw": 0}
|
||||||
|
player.global_position = counter.global_position + Vector3(0.0, 0.0, 1.2)
|
||||||
|
_press(sim)
|
||||||
|
r.check(menu.is_open and not bench_menu.is_open and player.rooted and not it.can_shoot(),
|
||||||
|
"interact at the shed counter opens the shed's shop, not the workbench's")
|
||||||
|
var row := menu._rows["corn_shooter"] as Button
|
||||||
|
row.pressed.emit()
|
||||||
|
r.check(Upgrades.owned(s, "corn_shooter") and s.resources.shed == {"wood": 0, "scrap": 0, "straw": 0},
|
||||||
|
"buying the corn shooter from the shed's menu works, for its usual cost")
|
||||||
|
_press(sim)
|
||||||
|
r.check(not menu.is_open and not player.rooted, "interact again closes the shed's shop")
|
||||||
|
var shed_zone := sim.zones.zone(FarmZone.Kind.SUPPLY_SHED)
|
||||||
|
player.global_position = Vector3(shed_zone.global_position.x, 0.0, shed_zone.global_position.z - 4.0)
|
||||||
|
r.check(Vector2(player.global_position.x, player.global_position.z).distance_to(Vector2(counter.global_position.x, counter.global_position.z)) > counter.reach,
|
||||||
|
"well outside the counter's reach, but still in the shed")
|
||||||
|
s.resources.pouch = {"wood": 2, "scrap": 0, "straw": 0}
|
||||||
|
_step(sim, 1)
|
||||||
|
r.check(s.resources.pouch.get("wood", 0) == 0 and s.resources.shed.get("wood", 0) == 2,
|
||||||
|
"walking into the shed zone still auto-deposits the pouch, away from the counter and with its shop closed")
|
||||||
|
|
||||||
|
|
||||||
## Alien Goop (#4): dropped only by killed Aliens (thieves), at GameConfig's rate and quantity,
|
## Alien Goop (#4): dropped only by killed Aliens (thieves), at GameConfig's rate and quantity,
|
||||||
## credited like a gathered material (respecting the pouch's capacity), and stealable from the
|
## credited like a gathered material (respecting the pouch's capacity), and stealable from the
|
||||||
## shed like any other material once it's the one on top.
|
## shed like any other material once it's the one on top.
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,9 @@ extends RefCounted
|
||||||
## The scarecrow's three weapons on the real farm (FarmSim stepped by hand at 60 Hz): only the
|
## The scarecrow's three weapons on the real farm (FarmSim stepped by hand at 60 Hz): only the
|
||||||
## pitchfork to start; its stab (in reach and in the arc of the aim only, the nearest few, its
|
## pitchfork to start; its stab (in reach and in the arc of the aim only, the nearest few, its
|
||||||
## damage, once per interval, again and again while fire is held, not through a wall); the corn
|
## damage, once per interval, again and again while fire is held, not through a wall); the corn
|
||||||
## shooter and pumpkin bombs bought at the workbench (rapid fire and heavy seeds need the corn
|
## shooter and pumpkin bombs bought at the supply shed, not the workbench (rapid fire and heavy
|
||||||
## shooter first; a weapon bought goes into its hand, bombs into the off-hand); switching the main
|
## seeds, bought at the workbench, need the corn shooter first; a weapon bought goes into its
|
||||||
|
## hand, bombs into the off-hand); switching the main
|
||||||
## weapon (Tab / 1-2, owned ones only, not in build mode, never the bombs; one no longer owned
|
## weapon (Tab / 1-2, owned ones only, not in build mode, never the bombs; one no longer owned
|
||||||
## falls back to the pitchfork); the off-hand on its own button (right mouse / LT: with the main
|
## falls back to the pitchfork); the off-hand on its own button (right mouse / LT: with the main
|
||||||
## weapon in hand, both at once, held, not with the right click that leaves build mode); a bomb's
|
## weapon in hand, both at once, held, not with the right click that leaves build mode); a bomb's
|
||||||
|
|
@ -132,17 +133,21 @@ func _unlocks(r: GameTestRunner, farm: Node3D, sim: FarmSim) -> void:
|
||||||
r.check(Upgrades.blocker(c, "rapid_fire") == "Needs the corn shooter first" and Upgrades.buy(c, "heavy_seeds", st).contains("needs the corn shooter")
|
r.check(Upgrades.blocker(c, "rapid_fire") == "Needs the corn shooter first" and Upgrades.buy(c, "heavy_seeds", st).contains("needs the corn shooter")
|
||||||
and not Upgrades.owned(s, "heavy_seeds"), "rapid fire and heavy seeds need the corn shooter first")
|
and not Upgrades.owned(s, "heavy_seeds"), "rapid fire and heavy seeds need the corn shooter first")
|
||||||
r.check(Upgrades.buy(c, "corn_shooter", st).contains("done:") and combat.owns(W.CORN_SHOOTER) and Upgrades.blocker(c, "rapid_fire") == "",
|
r.check(Upgrades.buy(c, "corn_shooter", st).contains("done:") and combat.owns(W.CORN_SHOOTER) and Upgrades.blocker(c, "rapid_fire") == "",
|
||||||
"the corn shooter is bought at the workbench; then rapid fire can be")
|
"the corn shooter is bought at the supply shed; then rapid fire (at the workbench) can be")
|
||||||
var panel := farm.get_node("Hud/UpgradePanel") as UpgradePanel
|
var bench_panel := farm.get_node("Hud/UpgradePanel") as UpgradePanel
|
||||||
|
var panel := farm.get_node("Hud/ShedPanel") as UpgradePanel
|
||||||
|
r.check(not bench_panel._rows.has("corn_shooter") and not bench_panel._rows.has("pumpkin_bomb")
|
||||||
|
and panel._rows.has("corn_shooter") and panel._rows.has("pumpkin_bomb"),
|
||||||
|
"the weapons are sold at the supply shed's menu, not the workbench's")
|
||||||
panel._buy("pumpkin_bomb")
|
panel._buy("pumpkin_bomb")
|
||||||
r.check(combat.owns(W.PUMPKIN_BOMB) and combat.offhand == W.PUMPKIN_BOMB and combat.weapon == W.PITCHFORK,
|
r.check(combat.owns(W.PUMPKIN_BOMB) and combat.offhand == W.PUMPKIN_BOMB and combat.weapon == W.PITCHFORK,
|
||||||
"pumpkin bombs bought from the menu go into the off-hand, the pitchfork staying in hand")
|
"pumpkin bombs bought from the shed's menu go into the off-hand, the pitchfork staying in hand")
|
||||||
var pivots := combat.models._pivots
|
var pivots := combat.models._pivots
|
||||||
r.check(pivots[2].visible and pivots[0].visible and not pivots[1].visible, "both show on the scarecrow")
|
r.check(pivots[2].visible and pivots[0].visible and not pivots[1].visible, "both show on the scarecrow")
|
||||||
r.check(pivots[0].position.x > 0.0 and pivots[2].position.x < 0.0, "the pitchfork in the right hand, the pumpkin in the left")
|
r.check(pivots[0].position.x > 0.0 and pivots[2].position.x < 0.0, "the pitchfork in the right hand, the pumpkin in the left")
|
||||||
s.upgrades.erase("corn_shooter")
|
s.upgrades.erase("corn_shooter")
|
||||||
panel._buy("corn_shooter")
|
panel._buy("corn_shooter")
|
||||||
r.check(combat.weapon == W.CORN_SHOOTER and combat.offhand == W.PUMPKIN_BOMB, "the corn shooter bought from the menu goes into the hand")
|
r.check(combat.weapon == W.CORN_SHOOTER and combat.offhand == W.PUMPKIN_BOMB, "the corn shooter bought from the shed's menu goes into the hand")
|
||||||
|
|
||||||
|
|
||||||
func _switching(r: GameTestRunner, sim: FarmSim) -> void:
|
func _switching(r: GameTestRunner, sim: FarmSim) -> void:
|
||||||
|
|
@ -308,7 +313,7 @@ func _hud(r: GameTestRunner, farm: Node3D, sim: FarmSim) -> void:
|
||||||
hud._process(0.0)
|
hud._process(0.0)
|
||||||
var rows: Array = hud._weapon_rows.map(func(l: Label) -> String: return l.text)
|
var rows: Array = hud._weapon_rows.map(func(l: Label) -> String: return l.text)
|
||||||
var off: Array = hud._offhand_rows.map(func(l: Label) -> String: return l.text)
|
var off: Array = hud._offhand_rows.map(func(l: Label) -> String: return l.text)
|
||||||
r.check(rows == ["1 Pitchfork", "2 Corn shooter (workbench)"], "the HUD lists the main weapons by number: %s" % [rows])
|
r.check(rows == ["1 Pitchfork", "2 Corn shooter (supply shed)"], "the HUD lists the main weapons by number: %s" % [rows])
|
||||||
r.check(charged == ["Pumpkin bombs"] and off == ["Pumpkin bombs %.0f s" % ceilf(cfg.bomb_cooldown)],
|
r.check(charged == ["Pumpkin bombs"] and off == ["Pumpkin bombs %.0f s" % ceilf(cfg.bomb_cooldown)],
|
||||||
"and the off-hand's bombs, with their recharge: %s, %s" % [charged, off])
|
"and the off-hand's bombs, with their recharge: %s, %s" % [charged, off])
|
||||||
r.check(hud._weapon_title.visible and hud._weapon_hint.text.contains("Tab") and hud._offhand_title.text.contains("right mouse"),
|
r.check(hud._weapon_title.visible and hud._weapon_hint.text.contains("Tab") and hud._offhand_title.text.contains("right mouse"),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue