- 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
48 lines
1.2 KiB
GDScript
48 lines
1.2 KiB
GDScript
extends Area3D
|
|
## An item lying on the ground (stick, stone, flint). Look at it and press E.
|
|
## Lives on collision layer 2, so the player walks through it but the
|
|
## interaction ray still finds it.
|
|
|
|
var item_id := "stick"
|
|
var amount := 1
|
|
var uid := "" ## stable id for saves (see props.gd)
|
|
var taken := false
|
|
|
|
func setup(id: String, mesh: Mesh, material: Material, radius: float) -> void:
|
|
item_id = id
|
|
collision_layer = 2
|
|
collision_mask = 0
|
|
monitoring = false
|
|
var mi := MeshInstance3D.new()
|
|
mi.mesh = mesh
|
|
mi.material_override = material
|
|
add_child(mi)
|
|
var cs := CollisionShape3D.new()
|
|
var sph := SphereShape3D.new()
|
|
sph.radius = radius
|
|
cs.shape = sph
|
|
cs.position = Vector3(0, radius * 0.5, 0)
|
|
add_child(cs)
|
|
|
|
func interact_prompt(_player: Node) -> String:
|
|
return "[E] Pick up %s" % ItemDB.item_name(item_id)
|
|
|
|
func interact(player: Node) -> void:
|
|
Actions.pickup(player, self)
|
|
|
|
signal taken_now(pickup: Node)
|
|
|
|
## Picked up: hidden (not freed) so it can reappear later (props.gd regrowth).
|
|
func collected() -> void:
|
|
if taken:
|
|
return
|
|
taken = true
|
|
visible = false
|
|
collision_layer = 0
|
|
taken_now.emit(self)
|
|
|
|
func regrow() -> void:
|
|
taken = false
|
|
visible = true
|
|
collision_layer = 2
|