Old Tam speaks (Kokoro); CC0 birdsong, crickets and owls; no plants through floors; menu and marker fixes
This commit is contained in:
@@ -165,6 +165,30 @@ func _try_regrow(uid: String) -> void:
|
||||
node.regrow()
|
||||
regrown.emit(uid)
|
||||
|
||||
## Clears the pickups (sticks, stones, flax, grass) under a newly built
|
||||
## floor, wall or roof: a short ray up from each nearby one finds the piece.
|
||||
func clear_under(piece: Node3D) -> void:
|
||||
if not is_instance_valid(piece) or not is_inside_tree():
|
||||
return
|
||||
await get_tree().physics_frame # (the piece's collider is in the world from the next step)
|
||||
if not is_instance_valid(piece):
|
||||
return
|
||||
var space := get_world_3d().direct_space_state
|
||||
var at := piece.global_position
|
||||
for pk in pickups.values():
|
||||
if not is_instance_valid(pk) or pk.taken:
|
||||
continue
|
||||
var p: Vector3 = pk.global_position
|
||||
if Vector2(p.x - at.x, p.z - at.z).length() > 4.0:
|
||||
continue
|
||||
var q := PhysicsRayQueryParameters3D.create(p + Vector3(0, 0.02, 0), p + Vector3(0, 2.6, 0))
|
||||
q.collision_mask = 4 # building pieces (build_piece.gd BUILD_LAYER)
|
||||
q.hit_from_inside = true # (a floor's footing reaches into the ground, round the pickup)
|
||||
if not space.intersect_ray(q).is_empty():
|
||||
pk.collected()
|
||||
if Net.is_server():
|
||||
WorldNet.taken(WorldNet.pickup_key(pk)) # (gone for everyone playing too)
|
||||
|
||||
## Something built (or being built) where a tree or rock would come back.
|
||||
func _built_over(pos: Vector3, r: float) -> bool:
|
||||
var sph := SphereShape3D.new()
|
||||
|
||||
@@ -859,6 +859,11 @@ func spawn_piece(def: Dictionary, xf: Transform3D, extra: Dictionary = {}) -> No
|
||||
build.recompute()
|
||||
if piece.kind == "floor":
|
||||
_update_grass_cuts()
|
||||
# Sticks, stones and plants it's built over are gone (cleared as if picked,
|
||||
# so a server tells everyone and the save keeps it; regrowth won't put them
|
||||
# back under a building). Also on load, for huts built before this.
|
||||
if piece.is_in_group("build") and not WorldNet.is_client():
|
||||
props.clear_under.call_deferred(piece)
|
||||
if server_mode and not _applying:
|
||||
piece_added.emit(piece)
|
||||
return piece
|
||||
|
||||
Reference in New Issue
Block a user