Added basic chat

This commit is contained in:
2024-01-28 22:08:08 +01:00
parent 75801e21fd
commit a6278cedb1
17 changed files with 182 additions and 22 deletions

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=21 format=3 uid="uid://b40y7iuskv1ar"]
[gd_scene load_steps=24 format=3 uid="uid://b40y7iuskv1ar"]
[ext_resource type="Script" path="res://Game.gd" id="1_uxop2"]
[ext_resource type="Script" path="res://network/Client.gd" id="2_00qe8"]
@ -12,7 +12,7 @@
[ext_resource type="Script" path="res://network/PlayerJump.gd" id="8_p6kmr"]
[ext_resource type="Environment" uid="uid://dixa0yso2s1u3" path="res://world/Environment.tres" id="9_4u3r5"]
[ext_resource type="CameraAttributesPractical" uid="uid://b835orxyqq6w5" path="res://camera/CameraAttributes.tres" id="10_4uslp"]
[ext_resource type="PackedScene" uid="uid://tgmbtt7u172g" path="res://world/Arena.blend" id="11_ffpbh"]
[ext_resource type="Script" path="res://network/Chat.gd" id="10_27gvi"]
[ext_resource type="PackedScene" uid="uid://hnn0n1xc2qt7" path="res://world/Tree.blend" id="12_x8kho"]
[ext_resource type="PackedScene" uid="uid://cb2t7bvvf3gwh" path="res://enemy/slime/Slime.tscn" id="13_hdbbd"]
[ext_resource type="PackedScene" uid="uid://dagn5bf7ou3sd" path="res://ui/UI.tscn" id="14_ofk4r"]
@ -20,6 +20,16 @@
[ext_resource type="Script" path="res://world/PlayerManager.gd" id="16_sjldq"]
[ext_resource type="Material" uid="uid://ddy5gkw0k16dq" path="res://shader/OutlineMaterial.tres" id="16_srvfy"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_lp0k7"]
albedo_color = Color(0, 0, 0, 1)
[sub_resource type="BoxMesh" id="BoxMesh_j5fsa"]
material = SubResource("StandardMaterial3D_lp0k7")
size = Vector3(100, 1, 100)
[sub_resource type="BoxShape3D" id="BoxShape3D_yg2lt"]
size = Vector3(100, 1, 100)
[sub_resource type="QuadMesh" id="QuadMesh_7yiqd"]
material = ExtResource("16_srvfy")
flip_faces = true
@ -68,6 +78,11 @@ packet_type = 12
script = ExtResource("8_p6kmr")
packet_type = 13
[node name="Chat" type="Node" parent="Client"]
unique_name_in_owner = true
script = ExtResource("10_27gvi")
packet_type = 20
[node name="Statistics" type="Timer" parent="Client"]
autostart = true
@ -83,8 +98,6 @@ script = ExtResource("8_leyo3")
environment = ExtResource("9_4u3r5")
camera_attributes = ExtResource("10_4uslp")
[node name="Arena" parent="World" instance=ExtResource("11_ffpbh")]
[node name="Trees" type="Node3D" parent="World"]
[node name="Tree" parent="World/Trees" instance=ExtResource("12_x8kho")]
@ -104,6 +117,15 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 7.00829, 1.28057, -1.95247)
[node name="Slime3" parent="World/Enemies" instance=ExtResource("13_hdbbd")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 8.53558, 1.28057, -0.306177)
[node name="Floor" type="MeshInstance3D" parent="World"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0)
mesh = SubResource("BoxMesh_j5fsa")
[node name="StaticBody3D" type="StaticBody3D" parent="World/Floor"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="World/Floor/StaticBody3D"]
shape = SubResource("BoxShape3D_yg2lt")
[node name="Players" type="Node3D" parent="."]
unique_name_in_owner = true
script = ExtResource("16_sjldq")
@ -146,3 +168,4 @@ 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"]
[connection signal="timeout" from="Client/Statistics" to="Client" method="update_statistics"]
[connection signal="chat_message_submitted" from="UI" to="Client/Chat" method="send_message"]

View File

@ -14,5 +14,8 @@ func get_player(id: String) -> Player:
return players[id] as Player
func remove(id: String):
if !players.has(id):
return
players[id].queue_free()
players.erase(id)