fix: rewrite TestLevelBuilder with parse-safe InputMap bootstrapping
This commit is contained in:
+17
-19
@@ -1,5 +1,6 @@
|
||||
extends Node3D
|
||||
class_name TestLevelBuilder
|
||||
|
||||
## Builds the test level ONLY from code — no .tscn SubResource references.
|
||||
## One-click playtest: attach to TestLevel root, F5.
|
||||
func _ready() -> void:
|
||||
@@ -16,6 +17,22 @@ func build() -> void:
|
||||
|
||||
|
||||
func _box_static(pos: Vector3, size: Vector3, color: Color) -> StaticBody3D:
|
||||
var body := StaticBody3D.new()
|
||||
body.name = "Static_" + str(pos)
|
||||
body.position = pos
|
||||
add_child(body)
|
||||
var shape := CollisionShape3D.new()
|
||||
shape.shape = BoxShape3D.new()
|
||||
shape.shape.size = size
|
||||
body.add_child(shape)
|
||||
var mesh := MeshInstance3D.new()
|
||||
mesh.mesh = BoxMesh.new()
|
||||
mesh.mesh.size = size
|
||||
var mat := StandardMaterial3D.new()
|
||||
mat.albedo_color = color
|
||||
mesh.mesh.surface_set_material(0, mat)
|
||||
body.add_child(mesh)
|
||||
return body
|
||||
|
||||
|
||||
func _build_input_map() -> void:
|
||||
@@ -51,22 +68,6 @@ func _build_input_map() -> void:
|
||||
events.append(ev)
|
||||
for ev in events:
|
||||
InputMap.action_add_event(action, ev)
|
||||
var body := StaticBody3D.new()
|
||||
body.name = "Static_" + str(pos)
|
||||
body.position = pos
|
||||
add_child(body)
|
||||
var shape := CollisionShape3D.new()
|
||||
shape.shape = BoxShape3D.new()
|
||||
shape.shape.size = size
|
||||
body.add_child(shape)
|
||||
var mesh := MeshInstance3D.new()
|
||||
mesh.mesh = BoxMesh.new()
|
||||
mesh.mesh.size = size
|
||||
var mat := StandardMaterial3D.new()
|
||||
mat.albedo_color = color
|
||||
mesh.mesh.surface_set_material(0, mat)
|
||||
body.add_child(mesh)
|
||||
return body
|
||||
|
||||
|
||||
func _build_floor() -> void:
|
||||
@@ -105,7 +106,6 @@ func _build_player() -> void:
|
||||
if mover_script:
|
||||
player.set_script(mover_script)
|
||||
|
||||
# State machine
|
||||
var sm := Node.new()
|
||||
sm.name = "MovementStateMachine"
|
||||
player.add_child(sm)
|
||||
@@ -114,7 +114,6 @@ func _build_player() -> void:
|
||||
if sm_script:
|
||||
sm.set_script(sm_script)
|
||||
|
||||
# State children
|
||||
var state_scripts := {
|
||||
"ground": "res://movement/states/state_ground.gd",
|
||||
"air": "res://movement/states/state_air.gd",
|
||||
@@ -131,7 +130,6 @@ func _build_player() -> void:
|
||||
if st_script:
|
||||
st.set_script(st_script)
|
||||
|
||||
# Camera
|
||||
var camera := Camera3D.new()
|
||||
camera.name = "Camera3D"
|
||||
camera.position = Vector3(0, 1.7, -3)
|
||||
|
||||
Reference in New Issue
Block a user