P1 iron: nuggets, ore, clay, kiln, smelter, forge, iron tools and arrows, lantern, tool wear and repair
This commit is contained in:
@@ -36,8 +36,50 @@ var _orig_shapes: Array = [] ## [CollisionShape3D, shape, position] befor
|
||||
signal depleted_now(node: Node)
|
||||
|
||||
func display_name() -> String:
|
||||
if is_iron:
|
||||
return "Rusty boulder (iron ore)"
|
||||
return "Tree" if kind == "tree" else "Boulder"
|
||||
|
||||
# --- rusty boulders (iron ore) ---------------------------------------------------
|
||||
|
||||
var is_iron := false
|
||||
var ore_vis: Node3D ## the rust streaks, following the boulder's instance
|
||||
static var _patch_mesh: ArrayMesh
|
||||
|
||||
## Turns this boulder into a rusty one: iron ore when it breaks, and red-brown
|
||||
## streaks on its surface (`hull` = the rock mesh's points, unscaled).
|
||||
func make_iron(hull: PackedVector3Array) -> void:
|
||||
is_iron = true
|
||||
drops_final = {"stone": [2, 4], "iron_ore": [2, 4]}
|
||||
chip_color = Color(0.55, 0.3, 0.18)
|
||||
if DisplayServer.get_name() == "headless":
|
||||
return
|
||||
if _patch_mesh == null:
|
||||
var n := FastNoiseLite.new()
|
||||
n.seed = 5
|
||||
n.frequency = 2.0
|
||||
var st := ProcMesh._begin()
|
||||
ProcMesh._blob(st, Vector3.ZERO, Vector3(0.13, 0.1, 0.018), n, 0.25, Color(0.48, 0.24, 0.12), RandomNumberGenerator.new(), 0)
|
||||
_patch_mesh = ProcMesh._commit(st)
|
||||
ore_vis = Node3D.new()
|
||||
ore_vis.top_level = true
|
||||
add_child(ore_vis)
|
||||
# Streaks on the upper surface, spread out.
|
||||
var up: Array = []
|
||||
for q: Vector3 in hull:
|
||||
if q.y > 0.15:
|
||||
up.append(q)
|
||||
up.sort_custom(func(a, b): return a.x + a.z * 0.37 < b.x + b.z * 0.37)
|
||||
var mat := ItemDB.item_material()
|
||||
for i in range(mini(6, up.size())):
|
||||
var q: Vector3 = up[int(float(i) / 6.0 * up.size())]
|
||||
var mi := MeshInstance3D.new()
|
||||
mi.mesh = _patch_mesh
|
||||
mi.material_override = mat
|
||||
mi.transform = Transform3D(Basis.looking_at(-q.normalized(), Vector3.UP if absf(q.normalized().y) < 0.95 else Vector3.RIGHT), q * 0.97)
|
||||
ore_vis.add_child(mi)
|
||||
ore_vis.global_transform = base_xf
|
||||
|
||||
func interact_prompt(player: Node) -> String:
|
||||
var tool: Dictionary = ItemDB.get_item(player.held_item_id()).get("tool", {})
|
||||
var verb := "Chop" if kind == "tree" else "Mine"
|
||||
@@ -101,6 +143,8 @@ func _rock_xf() -> Transform3D:
|
||||
func _set_instance(xf: Transform3D) -> void:
|
||||
if mmi != null and index >= 0:
|
||||
mmi.multimesh.set_instance_transform(index, xf)
|
||||
if ore_vis != null:
|
||||
ore_vis.global_transform = xf # (shrinks, shakes, hides and regrows with it)
|
||||
|
||||
## Restores saved damage when a world loads. hp <= 0 = already felled/mined
|
||||
## (no animation, no drops).
|
||||
|
||||
Reference in New Issue
Block a user