P1 iron: nuggets, ore, clay, kiln, smelter, forge, iron tools and arrows, lantern, tool wear and repair

This commit is contained in:
Paul Bailey
2026-11-05 00:31:07 +00:00
parent ab1f417c32
commit 24c280d885
24 changed files with 1334 additions and 43 deletions

View File

@@ -24,6 +24,9 @@ const PIECES := {
"build": preload("res://scripts/building/build_piece.gd"),
"door": preload("res://scripts/building/door.gd"),
"bed": preload("res://scripts/building/bed.gd"),
"kiln": preload("res://scripts/building/processor.gd"),
"smelter": preload("res://scripts/building/processor.gd"),
"forge": preload("res://scripts/building/forge.gd"),
}
const BuildPiece = preload("res://scripts/building/build_piece.gd")
const UITheme = preload("res://scripts/ui/theme.gd")
@@ -311,6 +314,8 @@ func skip_time(secs: float) -> void:
day_night.apply(true)
weather.snap()
props.skip_time(secs)
for m in get_tree().get_nodes_in_group("processor"):
m.step(secs) # (kilns and smelters work through the night)
for f in get_tree().get_nodes_in_group("heat"):
if f.has_method("burn"):
f.burn(secs)
@@ -537,6 +542,8 @@ func piece_entry(piece: Node3D) -> Dictionary:
func dropped_entry(d: Node3D) -> Dictionary:
var e := {"item": d.item_id, "count": d.amount, "xf": _xf_to_array(d.global_transform)}
if not d.extra.is_empty():
e["extra"] = d.extra
if d.has_meta("nid"):
e["nid"] = int(d.get_meta("nid"))
return e
@@ -570,7 +577,10 @@ func add_piece_entry(e: Dictionary) -> Node3D:
func add_dropped_entry(e: Dictionary) -> Node3D:
if ItemDB.get_item(e.get("item", "")).is_empty():
return null
var d := _make_dropped(e.item, int(e.get("count", 1)), _array_to_xf(e.xf))
var ex: Dictionary = {}
if e.get("extra") is Dictionary and e.extra.has("dur"):
ex = {"dur": int(e.extra.dur)}
var d := _make_dropped(e.item, int(e.get("count", 1)), _array_to_xf(e.xf), ex)
if e.has("nid"):
d.set_meta("nid", int(e.nid))
return d
@@ -772,17 +782,20 @@ func _on_net_left(_reason: String) -> void:
## Leaves `count` of an item lying in the world at `xf` (an arrow stuck in a
## tree, a thrown spear, meat that didn't fit). Saved with the world.
## Online only the server drops things (our game never does: returns null).
func drop_item(id: String, count: int, xf: Transform3D) -> Node3D:
## `extra` is what's special about it (a worn tool's "dur"), kept when it's
## picked up again.
func drop_item(id: String, count: int, xf: Transform3D, extra: Dictionary = {}) -> Node3D:
if net_sync != null:
push_warning("[world] drop_item(%s) on a client: only the server drops items" % id)
return null
return _make_dropped(id, count, xf)
return _make_dropped(id, count, xf, extra)
func _make_dropped(id: String, count: int, xf: Transform3D) -> Node3D:
func _make_dropped(id: String, count: int, xf: Transform3D, extra: Dictionary = {}) -> Node3D:
var pk: Area3D = preload("res://scripts/world/pickup.gd").new()
pk.setup(id, ItemDB.mesh_for(id), ItemDB.item_material(), 0.3)
pk.amount = count
pk.dropped = true
pk.extra = extra.duplicate()
_dropped.add_child(pk)
pk.global_transform = xf
if server_mode and not _applying: