Trying something that will probably never happen
Signed-off-by: Nikolai Rodionov <allanger@badhouseplants.net>
This commit is contained in:
		
							
								
								
									
										2
									
								
								.tool-versions
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								.tool-versions
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,2 @@
 | 
				
			|||||||
 | 
					golang 1.24.1
 | 
				
			||||||
 | 
					rust 1.85.0
 | 
				
			||||||
@@ -2,6 +2,7 @@
 | 
				
			|||||||
# -- of the models that are managed by the client and not by the server
 | 
					# -- of the models that are managed by the client and not by the server
 | 
				
			||||||
class_name ClientSpace extends Node3D
 | 
					class_name ClientSpace extends Node3D
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@export var player_server_node: ServerSideCharacter = null
 | 
				
			||||||
# Called when the node enters the scene tree for the first time.
 | 
					# Called when the node enters the scene tree for the first time.
 | 
				
			||||||
func _ready() -> void:
 | 
					func _ready() -> void:
 | 
				
			||||||
	pass # Replace with function body.
 | 
						pass # Replace with function body.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,6 +3,7 @@ class_name MapController extends Node3D
 | 
				
			|||||||
@onready var spawn_controller: SpawnController = $SpawnLocations
 | 
					@onready var spawn_controller: SpawnController = $SpawnLocations
 | 
				
			||||||
var player_space: Node3D = null
 | 
					var player_space: Node3D = null
 | 
				
			||||||
var player_controller: PlayerNode = null
 | 
					var player_controller: PlayerNode = null
 | 
				
			||||||
 | 
					var client_space: ClientSpace = null
 | 
				
			||||||
# Called when the node enters the scene tree for the first time.
 | 
					# Called when the node enters the scene tree for the first time.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func _ready() -> void:
 | 
					func _ready() -> void:
 | 
				
			||||||
@@ -15,6 +16,7 @@ func _ready() -> void:
 | 
				
			|||||||
	player_space.name = "PlayerSpace"
 | 
						player_space.name = "PlayerSpace"
 | 
				
			||||||
	add_child(player_space)
 | 
						add_child(player_space)
 | 
				
			||||||
	spawn_controller.player_space = player_space
 | 
						spawn_controller.player_space = player_space
 | 
				
			||||||
 | 
						client_space.player_server_node = player_space.find_child(str(multiplayer.get_unique_id()))
 | 
				
			||||||
	if multiplayer.is_server():
 | 
						if multiplayer.is_server():
 | 
				
			||||||
		pass
 | 
							pass
 | 
				
			||||||
	else:
 | 
						else:
 | 
				
			||||||
@@ -29,21 +31,20 @@ func request_state():
 | 
				
			|||||||
		spawn_controller.spawn_player(player_casted.player_id, player_casted.global_transform)
 | 
							spawn_controller.spawn_player(player_casted.player_id, player_casted.global_transform)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func add_client_space() -> Error :
 | 
					func add_client_space() -> Error :
 | 
				
			||||||
	return load_scene("levels/base/client_space/client_space.tscn")
 | 
						var path := consts.SCENES_PATH + "levels/base/client_space/client_space.tscn"
 | 
				
			||||||
 | 
					 | 
				
			||||||
func load_scene(rel_path: String) -> Error :
 | 
					 | 
				
			||||||
	var path := consts.SCENES_PATH + rel_path
 | 
					 | 
				
			||||||
	logger.info("loading scene from " + path)
 | 
						logger.info("loading scene from " + path)
 | 
				
			||||||
	if not ResourceLoader.exists(path):
 | 
						if not ResourceLoader.exists(path):
 | 
				
			||||||
		logger.error("scene " + path + " doesn't exist")
 | 
							logger.error("scene " + path + " doesn't exist")
 | 
				
			||||||
		return ERR_DOES_NOT_EXIST
 | 
							return ERR_DOES_NOT_EXIST
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var scene: PackedScene = ResourceLoader.load(path)
 | 
						var scene: PackedScene = ResourceLoader.load(path)
 | 
				
			||||||
	if scene.can_instantiate():
 | 
						if scene.can_instantiate():
 | 
				
			||||||
		# -- TODO: May we should case to a real type instead
 | 
							# -- TODO: May we should case to a real type instead
 | 
				
			||||||
		var node: Variant = scene.instantiate()
 | 
							var node: ClientSpace = scene.instantiate()
 | 
				
			||||||
		player_controller = node as PlayerNode
 | 
							#node.player_server_id = multiplayer.get_unique_id()
 | 
				
			||||||
		logger.info("loading scene: " + path)
 | 
							logger.info("loading scene: " + path)
 | 
				
			||||||
		add_child(node)
 | 
							add_child(node)
 | 
				
			||||||
 | 
							client_space = node
 | 
				
			||||||
	else:
 | 
						else:
 | 
				
			||||||
		logger.error("can't initialize")
 | 
							logger.error("can't initialize")
 | 
				
			||||||
		return ERR_CANT_OPEN
 | 
							return ERR_CANT_OPEN
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,4 +11,5 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.9, 0)
 | 
				
			|||||||
shape = SubResource("CapsuleShape3D_g8geq")
 | 
					shape = SubResource("CapsuleShape3D_g8geq")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[node name="CameraMountPoint" type="Node3D" parent="."]
 | 
					[node name="CameraMountPoint" type="Node3D" parent="."]
 | 
				
			||||||
 | 
					editor_description = "It is used for rotating the real camera mount"
 | 
				
			||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.167045, 1.31595, 0)
 | 
					transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.167045, 1.31595, 0)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,6 +19,8 @@ var is_connected_to_server = false
 | 
				
			|||||||
# Called when the node enters the scene tree for the first time.
 | 
					# Called when the node enters the scene tree for the first time.
 | 
				
			||||||
func _ready() -> void:
 | 
					func _ready() -> void:
 | 
				
			||||||
	set_multiplayer_authority(multiplayer.get_unique_id())
 | 
						set_multiplayer_authority(multiplayer.get_unique_id())
 | 
				
			||||||
 | 
						# -- We need to get the position of the controller node on the server
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	camera_mount.global_transform = camera_mount_point.global_transform
 | 
						camera_mount.global_transform = camera_mount_point.global_transform
 | 
				
			||||||
	camera_gt_prev = camera_mount.global_transform
 | 
						camera_gt_prev = camera_mount.global_transform
 | 
				
			||||||
	camera_gt_cur = camera_mount.global_transform
 | 
						camera_gt_cur = camera_mount.global_transform
 | 
				
			||||||
@@ -81,8 +83,8 @@ func _physics_process(delta: float) -> void:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func _process(delta: float) -> void:
 | 
					func _process(delta: float) -> void:
 | 
				
			||||||
	# -- TODO: Rewrite it
 | 
						# -- TODO: Rewrite it
 | 
				
			||||||
	if not is_connected_to_server:
 | 
						#if not is_connected_to_server:
 | 
				
			||||||
		var map_controller: MapController = find_parent("Map")
 | 
							#var map_controller: MapController = find_parent("Map")
 | 
				
			||||||
	if update_camera:
 | 
						if update_camera:
 | 
				
			||||||
		update_camera_transform()
 | 
							update_camera_transform()
 | 
				
			||||||
		update_camera = false
 | 
							update_camera = false
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,8 +8,7 @@
 | 
				
			|||||||
script = ExtResource("1_v31xn")
 | 
					script = ExtResource("1_v31xn")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[node name="CameraMount" parent="." instance=ExtResource("2_csswn")]
 | 
					[node name="CameraMount" parent="." instance=ExtResource("2_csswn")]
 | 
				
			||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.80384, 0)
 | 
					transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.47638, -0.25714)
 | 
				
			||||||
camera_name = "PlayerCamera"
 | 
					camera_name = "PlayerCamera"
 | 
				
			||||||
input_camera = true
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
[node name="Character" parent="." instance=ExtResource("1_1fx4c")]
 | 
					[node name="Character" parent="." instance=ExtResource("1_1fx4c")]
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user