- Seeded weather (clear/cloudy/rain/storm, snow and blizzards on cold days and above the snowline), lightning, synthesised rain/wind/thunder sound - Rain/snow particles stopped by roofs; wet ground, settled snow and wind via global shader uniforms - Snap-together wood floor, wall, door, roof and gable with structural support, collapse and X to dismantle - Shelter detection: dry under a roof, warmer and Rested inside with a fire; rain burns an uncovered campfire faster - Bed sets the spawn point and lets you sleep through the night - Trees, boulders and ground pickups regrow; timers saved - Grass cleared under floors; shorter HUD hint - New test_weather_building suite (62 checks) and tests/run_all.sh, which also fails on script errors
49 lines
1.2 KiB
GDScript
49 lines
1.2 KiB
GDScript
extends StaticBody3D
|
|
## Base for placed pieces (campfire, workbench, chest, bed, building pieces).
|
|
## Builds the visual from the item's procedural mesh and, by default, a box
|
|
## collider from the mesh bounds. Subclasses add behaviour or their own
|
|
## colliders (_make_collision).
|
|
|
|
var item_id := ""
|
|
var def: Dictionary = {}
|
|
|
|
func setup(d: Dictionary) -> void:
|
|
def = d
|
|
item_id = d.id
|
|
add_to_group("piece")
|
|
var mi := MeshInstance3D.new()
|
|
mi.name = "Mesh"
|
|
mi.mesh = _visual_mesh()
|
|
mi.material_override = ItemDB.item_material()
|
|
add_child(mi)
|
|
_make_collision(mi)
|
|
_build()
|
|
|
|
func _visual_mesh() -> Mesh:
|
|
return ItemDB.mesh_for(item_id)
|
|
|
|
func _make_collision(mi: MeshInstance3D) -> void:
|
|
var aabb := mi.mesh.get_aabb()
|
|
var cs := CollisionShape3D.new()
|
|
var box := BoxShape3D.new()
|
|
box.size = Vector3(aabb.size.x, maxf(aabb.size.y, 0.3), aabb.size.z)
|
|
cs.shape = box
|
|
cs.position = aabb.get_center()
|
|
add_child(cs)
|
|
|
|
func _build() -> void:
|
|
pass
|
|
|
|
func display_name() -> String:
|
|
return ItemDB.item_name(item_id)
|
|
|
|
func interact_prompt(_player: Node) -> String:
|
|
return display_name()
|
|
|
|
func interact(_player: Node) -> void:
|
|
pass
|
|
|
|
## Whether X can take this piece back into your inventory (and why not).
|
|
func dismantle_block_reason() -> String:
|
|
return ""
|