Bläddra i källkod

:truck: Tidy project

Use folder organization.
DricomDragon 2 år sedan
förälder
incheckning
1e31030a2a

netnet/player.gd → netnet/component/entity/player/player.gd


+ 3 - 3
netnet/player.tscn

@@ -1,7 +1,7 @@
-[gd_scene load_steps=7 format=3 uid="uid://cw8w6clmxedi6"]
+[gd_scene load_steps=7 format=3]
 
-[ext_resource type="Script" path="res://player.gd" id="1_hwwnj"]
-[ext_resource type="Script" path="res://player_input.gd" id="2_ju3m6"]
+[ext_resource type="Script" path="res://component/entity/player/player.gd" id="1_hwwnj"]
+[ext_resource type="Script" path="res://component/entity/player/player_input.gd" id="2_ju3m6"]
 
 [sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_fb1vy"]
 properties/0/path = NodePath(".:player")

+ 2 - 0
netnet/player_input.gd

@@ -6,6 +6,7 @@ extends MultiplayerSynchronizer
 # Synchronized property.
 @export var direction := Vector2()
 
+
 func _ready():
 	# Only process for the local player
 	set_process(get_multiplayer_authority() == multiplayer.get_unique_id())
@@ -15,6 +16,7 @@ func _ready():
 func jump():
 	jumping = true
 
+
 func _process(delta):
 	# Get the input direction and handle the movement/deceleration.
 	# As good practice, you should replace UI actions with custom gameplay actions.

netnet/sphere.tscn → netnet/component/entity/sphere/sphere.tscn


+ 1 - 1
netnet/project.godot

@@ -12,5 +12,5 @@ config_version=5
 
 config/name="Network Example Gd4"
 config/description="Scene replication example in 3D with Godot 4"
-run/main_scene="res://multiplayer.tscn"
+run/main_scene="res://run/multiplayer.tscn"
 config/features=PackedStringArray("4.0")

+ 1 - 1
netnet/level.gd

@@ -27,7 +27,7 @@ func _exit_tree():
 
 
 func add_player(id: int):
-	var character = preload("res://player.tscn").instantiate()
+	var character = preload("res://component/entity/player/player.tscn").instantiate()
 	# Set player id.
 	character.player = id
 	# Randomize character position.

+ 4 - 4
netnet/level.tscn

@@ -1,7 +1,7 @@
-[gd_scene load_steps=6 format=3 uid="uid://efwjm4hfeqf2"]
+[gd_scene load_steps=6 format=3]
 
-[ext_resource type="PackedScene" uid="uid://c6br8h3si2ypg" path="res://sphere.tscn" id="1_8awbr"]
-[ext_resource type="Script" path="res://level.gd" id="1_p4gvl"]
+[ext_resource type="PackedScene" uid="uid://c6br8h3si2ypg" path="res://component/entity/sphere/sphere.tscn" id="1_8awbr"]
+[ext_resource type="Script" path="res://run/levels/flatland/level.gd" id="1_p4gvl"]
 
 [sub_resource type="WorldBoundaryShape3D" id="WorldBoundaryShape3D_s66iy"]
 
@@ -41,6 +41,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.09399, 4.03106, 0)
 [node name="Players" type="Node3D" parent="."]
 
 [node name="MultiplayerSpawner" type="MultiplayerSpawner" parent="."]
-_spawnable_scenes = PackedStringArray("res://player.tscn")
+_spawnable_scenes = PackedStringArray("res://component/entity/player/player.tscn")
 spawn_path = NodePath("../Players")
 spawn_limit = 4

+ 4 - 2
netnet/multiplayer.gd

@@ -39,6 +39,7 @@ func _on_connect_pressed():
 	multiplayer.multiplayer_peer = peer
 	start_game()
 
+
 func start_game():
 	# Hide the UI and unpause to start the game.
 	$UI.hide()
@@ -46,7 +47,7 @@ func start_game():
 	# Only change level on the server.
 	# Clients will instantiate the level via the spawner.
 	if multiplayer.is_server():
-		change_level.call_deferred(load("res://level.tscn"))
+		change_level.call_deferred(load("res://run/levels/flatland/level.tscn"))
 
 
 # Call this function deferred and only on the main authority (server).
@@ -59,9 +60,10 @@ func change_level(scene: PackedScene):
 	# Add new level.
 	level.add_child(scene.instantiate())
 
+
 # The server can restart the level by pressing HOME.
 func _input(event):
 	if not multiplayer.is_server():
 		return
 	if event.is_action("ui_home") and Input.is_action_just_pressed("ui_home"):
-		change_level.call_deferred(load("res://level.tscn"))
+		change_level.call_deferred(load("res://run/levels/flatland/level.tscn"))

+ 3 - 3
netnet/multiplayer.tscn

@@ -1,14 +1,14 @@
 [gd_scene load_steps=2 format=3 uid="uid://bvnwjpd0f3oa0"]
 
-[ext_resource type="Script" path="res://multiplayer.gd" id="1_jiv4u"]
+[ext_resource type="Script" path="res://run/multiplayer.gd" id="1_t2go4"]
 
 [node name="Multiplayer" type="Node"]
-script = ExtResource("1_jiv4u")
+script = ExtResource("1_t2go4")
 
 [node name="Level" type="Node" parent="."]
 
 [node name="LevelSpawner" type="MultiplayerSpawner" parent="."]
-_spawnable_scenes = PackedStringArray("res://level.tscn")
+_spawnable_scenes = PackedStringArray("res://run/levels/flatland/level.tscn")
 spawn_path = NodePath("../Level")
 spawn_limit = 1