This commit is contained in:
Nicholas Butzke
2026-08-02 02:20:02 -04:00
parent 61669627db
commit 922983429e
226 changed files with 34032 additions and 18521 deletions
+41
View File
@@ -4,6 +4,45 @@ class_name LevelRuntime
var _player: CharacterBody3D
## The play volume for an AUTHORED map.
##
## The code-built levels each pass their own extents, because they know them as
## constants. A hand-placed .tscn does not, so this measures the level instead —
## merge every reasonably-sized visual's world AABB, then pad it generously.
##
## Without one, a map on this runtime had no out-of-bounds handling at all: a
## player who left the geometry simply fell for ever, with no warning and no
## death. That was the state of fps_blockout.
func _build_combat_area() -> void:
var bounds := AABB()
var any := false
for child in find_children("*", "VisualInstance3D", true, false):
var vi := child as VisualInstance3D
var box := vi.get_aabb()
# Skip the sky, a directional light's own AABB, and anything else
# absurd — one of them would swallow the level and put the boundary
# somewhere useless.
if box.size.length() > 5000.0 or box.size.length() < 0.001:
continue
box = vi.global_transform * box
if not any:
bounds = box
any = true
else:
bounds = bounds.merge(box)
if not any:
bounds = AABB(Vector3(-50, -10, -50), Vector3(100, 60, 100))
# Padding, not a tight fit: the volume marks where a player is TOLD they
# have left, and a boundary hugging the geometry fires while someone is
# still standing on a legitimate ledge. Deep below, because falling out of
# the world is the case this exists to catch.
var pad := Vector3(20, 0, 20)
var size := bounds.size + pad * 2.0 + Vector3(0, 60, 0)
var centre := bounds.get_center() + Vector3(0, 20.0, 0)
CombatArea.add_to(self, size, centre)
func _ready() -> void:
# Hide mouse
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
@@ -13,6 +52,8 @@ func _ready() -> void:
if not has_node("WorldEnvironment"):
LevelEnvironment.add_to(self)
_build_combat_area()
# Multiplayer Spawning
var spawner = MultiplayerSpawner.new()