feat: Add EnhancedGridMap for dynamic grid generation, pathfinding, and network synchronization, and introduce core game scripts for Tekton entities and managers.
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
extends StaticBody3D
|
||||
|
||||
@onready var mesh_instance: MeshInstance3D = $MeshInstance3D
|
||||
|
||||
# Sync the chosen shape so all clients see the same one
|
||||
@export var shape_index: int = -1:
|
||||
set(value):
|
||||
shape_index = value
|
||||
if is_inside_tree():
|
||||
_update_mesh_from_index()
|
||||
|
||||
func _ready():
|
||||
if multiplayer.is_server():
|
||||
# Only randomize if not already set (Main.gd sets it now)
|
||||
if shape_index == -1:
|
||||
shape_index = randi() % 4
|
||||
_update_mesh_from_index()
|
||||
else:
|
||||
# Client side:
|
||||
if shape_index != -1:
|
||||
_update_mesh_from_index()
|
||||
else:
|
||||
# If we spawned but data hasn't arrived (unlikely with spawn=true but possible),
|
||||
# we wait. The setter will trigger update when data arrives.
|
||||
# But just in case, we can try to request it or use a default
|
||||
pass
|
||||
|
||||
func _update_mesh_from_index():
|
||||
if not mesh_instance: return
|
||||
|
||||
var shapes = [
|
||||
_create_cylinder(),
|
||||
_create_box(),
|
||||
_create_prism(),
|
||||
_create_sphere()
|
||||
]
|
||||
|
||||
var idx = shape_index % shapes.size()
|
||||
var selected_mesh = shapes[idx]
|
||||
|
||||
# Apply Material
|
||||
var mat = StandardMaterial3D.new()
|
||||
mat.albedo_color = Color(0.2, 0.2, 0.25)
|
||||
mat.metallic = 0.5
|
||||
mat.roughness = 0.5
|
||||
selected_mesh.material = mat
|
||||
|
||||
mesh_instance.mesh = selected_mesh
|
||||
|
||||
# Deprecated: _randomize_shape (Logic moved to server init and sync)
|
||||
# func _randomize_shape(): ...
|
||||
|
||||
func _create_cylinder() -> CylinderMesh:
|
||||
var mesh = CylinderMesh.new()
|
||||
mesh.top_radius = 1.4
|
||||
mesh.bottom_radius = 1.4
|
||||
mesh.height = 0.6
|
||||
return mesh
|
||||
|
||||
func _create_box() -> BoxMesh:
|
||||
var mesh = BoxMesh.new()
|
||||
mesh.size = Vector3(3.2, 0.6, 3.2)
|
||||
return mesh
|
||||
|
||||
func _create_prism() -> PrismMesh:
|
||||
var mesh = PrismMesh.new()
|
||||
mesh.size = Vector3(3.2, 0.6, 3.2)
|
||||
return mesh
|
||||
|
||||
func _create_sphere() -> SphereMesh:
|
||||
# A flattened sphere acting like a dome stand
|
||||
var mesh = SphereMesh.new()
|
||||
mesh.radius = 1.4
|
||||
mesh.height = 1.0 # Flattened
|
||||
mesh.is_hemisphere = true
|
||||
return mesh
|
||||
Reference in New Issue
Block a user