M1c: weather, snap building, shelter, beds and regrowth
- 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
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
extends StaticBody3D
|
||||
## Base for placed pieces (campfire, workbench, chest, later walls/floors).
|
||||
## Builds the visual from the item's procedural mesh and a box collider from
|
||||
## the item's footprint. Subclasses add behaviour.
|
||||
## 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 = {}
|
||||
@@ -9,11 +10,19 @@ 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 = ItemDB.mesh_for(item_id)
|
||||
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()
|
||||
@@ -21,7 +30,6 @@ func setup(d: Dictionary) -> void:
|
||||
cs.shape = box
|
||||
cs.position = aabb.get_center()
|
||||
add_child(cs)
|
||||
_build()
|
||||
|
||||
func _build() -> void:
|
||||
pass
|
||||
@@ -34,3 +42,7 @@ func interact_prompt(_player: Node) -> String:
|
||||
|
||||
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 ""
|
||||
|
||||
Reference in New Issue
Block a user