Split client and server

This commit is contained in:
2024-01-24 00:09:50 +01:00
parent 532a1faa21
commit 26c52a00b3
59 changed files with 335 additions and 142 deletions

View File

@ -0,0 +1,56 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://tgmbtt7u172g"
path="res://.godot/imported/Arena.blend-c720f6651d38b4cfd30aa3f4d2266924.scn"
[deps]
source_file="res://world/Arena.blend"
dest_files=["res://.godot/imported/Arena.blend-c720f6651d38b4cfd30aa3f4d2266924.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/apply_root_scale=true
nodes/root_scale=1.0
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={
"nodes": {
"PATH:Plane": {
"physics/shape_type": 2
}
}
}
gltf/naming_version=1
gltf/embedded_image_handling=1
blender/nodes/visible=0
blender/nodes/punctual_lights=true
blender/nodes/cameras=true
blender/nodes/custom_properties=true
blender/nodes/modifiers=1
blender/meshes/colors=false
blender/meshes/uvs=true
blender/meshes/normals=true
blender/meshes/tangents=true
blender/meshes/skins=2
blender/meshes/export_bones_deforming_mesh_only=false
blender/materials/unpack_enabled=true
blender/materials/export_materials=1
blender/animation/limit_playback=true
blender/animation/always_sample=true
blender/animation/group_tracks=true

23
client/world/Camera.gd Normal file
View File

@ -0,0 +1,23 @@
extends Camera3D
@export var center: Node3D
@export var follow_speed: float
func _ready():
Global.camera = self
func _process(delta):
if Global.player == null:
return
center.position = lerp(center.position, Global.player.position, follow_speed * delta)
# @export var shake_strength: float
# var noise = FastNoiseLite.new()
# func shake(time):
# var trauma_sq := 1.0
# var h_offset := noise.get_noise_2d(time, 0) * trauma_sq * shake_strength
# var v_offset := noise.get_noise_2d(time, 1) * trauma_sq * shake_strength
# rotate_x(noise.get_noise_2d(time, 2) * trauma_sq * shake_strength)
# rotate_y(noise.get_noise_2d(time, 3) * trauma_sq * shake_strength)
# rotate_z(noise.get_noise_2d(time, 4) * trauma_sq * shake_strength)

View File

@ -0,0 +1,3 @@
[gd_resource type="CameraAttributesPractical" format=3 uid="uid://b835orxyqq6w5"]
[resource]

139
client/world/Client.tscn Normal file
View File

@ -0,0 +1,139 @@
[gd_scene load_steps=19 format=3 uid="uid://b40y7iuskv1ar"]
[ext_resource type="Script" path="res://world/Game.gd" id="1_pux6q"]
[ext_resource type="Script" path="res://network/Client.gd" id="2_1ofik"]
[ext_resource type="Script" path="res://network/Ping.gd" id="3_4h5la"]
[ext_resource type="Script" path="res://network/Login.gd" id="4_k8n1i"]
[ext_resource type="Script" path="res://network/Spawn.gd" id="5_7n5ie"]
[ext_resource type="PackedScene" uid="uid://2lcnu3dy54lx" path="res://player/Player.tscn" id="5_22pku"]
[ext_resource type="PackedScene" uid="uid://mgyg01l21t0j" path="res://world/World.tscn" id="7_fb4vs"]
[ext_resource type="Environment" uid="uid://dixa0yso2s1u3" path="res://world/Environment.tres" id="8_5uta8"]
[ext_resource type="PackedScene" uid="uid://cch67vqpsmtej" path="res://ui/debug/DebugLabel.tscn" id="8_jr2jn"]
[ext_resource type="Script" path="res://ui/debug/FPSLabel.gd" id="9_0imyg"]
[ext_resource type="CameraAttributesPractical" uid="uid://b835orxyqq6w5" path="res://world/CameraAttributes.tres" id="9_w4cdu"]
[ext_resource type="Script" path="res://world/Sun.gd" id="10_mlmor"]
[ext_resource type="Script" path="res://ui/debug/PingLabel.gd" id="10_pu6sd"]
[ext_resource type="Script" path="res://ui/debug/PositionLabel.gd" id="11_k0017"]
[ext_resource type="Script" path="res://ui/debug/VelocityLabel.gd" id="12_dgr41"]
[ext_resource type="Script" path="res://world/Camera.gd" id="13_y4waa"]
[ext_resource type="Material" uid="uid://ddy5gkw0k16dq" path="res://shader/OutlineMaterial.tres" id="14_hobco"]
[sub_resource type="QuadMesh" id="QuadMesh_7yiqd"]
material = ExtResource("14_hobco")
flip_faces = true
size = Vector2(2, 2)
[node name="Main" type="Node"]
script = ExtResource("1_pux6q")
[node name="Client" type="Node" parent="."]
unique_name_in_owner = true
script = ExtResource("2_1ofik")
[node name="Ping" type="Node" parent="Client"]
unique_name_in_owner = true
script = ExtResource("3_4h5la")
[node name="Timer" type="Timer" parent="Client/Ping"]
autostart = true
[node name="Login" type="Node" parent="Client"]
script = ExtResource("4_k8n1i")
[node name="Timer" type="Timer" parent="Client/Login"]
wait_time = 10.0
autostart = true
[node name="Spawn" type="Node" parent="Client"]
script = ExtResource("5_7n5ie")
player_scene = ExtResource("5_22pku")
[node name="Players" type="Node3D" parent="."]
unique_name_in_owner = true
[node name="World" parent="." instance=ExtResource("7_fb4vs")]
[node name="Sun" type="DirectionalLight3D" parent="World"]
transform = Transform3D(0.984808, 0.122788, -0.122788, 0, 0.707107, 0.707107, 0.173648, -0.696364, 0.696364, 0, 10, 0)
shadow_enabled = true
directional_shadow_mode = 0
script = ExtResource("10_mlmor")
[node name="Environment" type="WorldEnvironment" parent="World"]
environment = ExtResource("8_5uta8")
camera_attributes = ExtResource("9_w4cdu")
[node name="UI" type="Control" parent="."]
layout_mode = 3
anchors_preset = 0
[node name="CanvasLayer" type="CanvasLayer" parent="UI"]
[node name="TopLeftMargin" type="MarginContainer" parent="UI/CanvasLayer"]
offset_right = 40.0
offset_bottom = 50.0
[node name="VBoxContainer" type="VBoxContainer" parent="UI/CanvasLayer/TopLeftMargin"]
layout_mode = 2
[node name="FPS" parent="UI/CanvasLayer/TopLeftMargin/VBoxContainer" instance=ExtResource("8_jr2jn")]
layout_mode = 2
script = ExtResource("9_0imyg")
[node name="Ping" parent="UI/CanvasLayer/TopLeftMargin/VBoxContainer" instance=ExtResource("8_jr2jn")]
layout_mode = 2
script = ExtResource("10_pu6sd")
[node name="BottomLeftMargin" type="MarginContainer" parent="UI/CanvasLayer"]
anchors_preset = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_top = -10.0
offset_right = 10.0
grow_vertical = 0
[node name="VBoxContainer" type="VBoxContainer" parent="UI/CanvasLayer/BottomLeftMargin"]
layout_mode = 2
[node name="Position" parent="UI/CanvasLayer/BottomLeftMargin/VBoxContainer" instance=ExtResource("8_jr2jn")]
layout_mode = 2
script = ExtResource("11_k0017")
[node name="Velocity" parent="UI/CanvasLayer/BottomLeftMargin/VBoxContainer" instance=ExtResource("8_jr2jn")]
layout_mode = 2
script = ExtResource("12_dgr41")
[node name="Viewport" type="SubViewportContainer" parent="."]
texture_filter = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
stretch = true
[node name="SubViewport" type="SubViewport" parent="Viewport"]
handle_input_locally = false
size = Vector2i(1152, 648)
render_target_update_mode = 4
[node name="CameraPivot" type="Node3D" parent="Viewport/SubViewport"]
[node name="Camera" type="Camera3D" parent="Viewport/SubViewport/CameraPivot" node_paths=PackedStringArray("center")]
transform = Transform3D(0.707107, 0.353554, -0.612372, 0, 0.866026, 0.5, 0.707107, -0.353554, 0.612372, -10, 10, 10)
projection = 1
current = true
fov = 90.0
size = 10.0
far = 100.0
script = ExtResource("13_y4waa")
center = NodePath("..")
follow_speed = 5.0
[node name="PostProcessing" type="MeshInstance3D" parent="Viewport/SubViewport/CameraPivot/Camera"]
unique_name_in_owner = true
extra_cull_margin = 16384.0
mesh = SubResource("QuadMesh_7yiqd")
[connection signal="timeout" from="Client/Ping/Timer" to="Client/Ping" method="send_ping"]
[connection signal="timeout" from="Client/Login/Timer" to="Client/Login" method="send_login"]

View File

@ -0,0 +1,10 @@
[gd_resource type="Environment" format=3 uid="uid://dixa0yso2s1u3"]
[resource]
background_mode = 1
background_color = Color(0.317647, 0.541176, 0.713726, 1)
ambient_light_source = 3
ambient_light_color = Color(0.607843, 0.756863, 0.92549, 1)
ambient_light_sky_contribution = 0.17
tonemap_mode = 2
ssao_intensity = 16.0

24
client/world/Game.gd Normal file
View File

@ -0,0 +1,24 @@
extends Node
func _ready():
# Capture mouse
#Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
# Mute audio
var master_sound = AudioServer.get_bus_index("Master")
AudioServer.set_bus_mute(master_sound, true)
func _input(event):
if event.is_action_pressed("toggle_fullscreen"):
toggle_fullscreen()
func toggle_fullscreen():
var mode = DisplayServer.window_get_mode()
match mode:
DisplayServer.WINDOW_MODE_FULLSCREEN:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
_:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
return

4
client/world/Global.gd Normal file
View File

@ -0,0 +1,4 @@
extends Node
var camera: Camera3D
var player: Player

6
client/world/RotateY.gd Normal file
View File

@ -0,0 +1,6 @@
extends Node3D
@export var speed: float = 1.0
func _process(delta):
rotate_y(speed * delta)

5
client/world/Sun.gd Normal file
View File

@ -0,0 +1,5 @@
@tool
extends DirectionalLight3D
# func _process(_delta):
# (%PostProcessing as MeshInstance3D).mesh.surface_get_material(0).set_shader_parameter("light_direction", -global_basis.z)

View File

@ -0,0 +1,50 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://hnn0n1xc2qt7"
path="res://.godot/imported/Tree.blend-8edaf7c4bb18f0f1f1c8fa5b8380d9ea.scn"
[deps]
source_file="res://world/Tree.blend"
dest_files=["res://.godot/imported/Tree.blend-8edaf7c4bb18f0f1f1c8fa5b8380d9ea.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/apply_root_scale=true
nodes/root_scale=1.0
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={}
gltf/naming_version=1
gltf/embedded_image_handling=1
blender/nodes/visible=0
blender/nodes/punctual_lights=true
blender/nodes/cameras=true
blender/nodes/custom_properties=true
blender/nodes/modifiers=1
blender/meshes/colors=false
blender/meshes/uvs=true
blender/meshes/normals=true
blender/meshes/tangents=true
blender/meshes/skins=2
blender/meshes/export_bones_deforming_mesh_only=false
blender/materials/unpack_enabled=true
blender/materials/export_materials=1
blender/animation/limit_playback=true
blender/animation/always_sample=true
blender/animation/group_tracks=true

28
client/world/World.tscn Normal file
View File

@ -0,0 +1,28 @@
[gd_scene load_steps=4 format=3 uid="uid://mgyg01l21t0j"]
[ext_resource type="PackedScene" uid="uid://tgmbtt7u172g" path="res://world/Arena.blend" id="1_1sh4g"]
[ext_resource type="PackedScene" uid="uid://hnn0n1xc2qt7" path="res://world/Tree.blend" id="2_lunhk"]
[ext_resource type="PackedScene" uid="uid://cb2t7bvvf3gwh" path="res://enemy/Slime.tscn" id="3_uuodv"]
[node name="World" type="Node3D"]
[node name="Arena" parent="." instance=ExtResource("1_1sh4g")]
[node name="Trees" type="Node3D" parent="."]
[node name="Tree" parent="Trees" instance=ExtResource("2_lunhk")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 5.11323, 0, -4.64839)
[node name="Tree2" parent="Trees" instance=ExtResource("2_lunhk")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 5.11323, 0, 5.35161)
[node name="Enemies" type="Node3D" parent="."]
[node name="Slime" parent="Enemies" instance=ExtResource("3_uuodv")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 8.53558, 1.28057, -3.79687)
[node name="Slime2" parent="Enemies" instance=ExtResource("3_uuodv")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 7.00829, 1.28057, -1.95247)
[node name="Slime3" parent="Enemies" instance=ExtResource("3_uuodv")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 8.53558, 1.28057, -0.306177)