Compare commits
6 Commits
bfec08ff02
...
main
Author | SHA1 | Date | |
---|---|---|---|
e3330c7f42
|
|||
9e3b595f71
|
|||
69a918d4ec
|
|||
db3ee3a685
|
|||
cb4dd41358
|
|||
ded6f51c5d
|
@ -11,6 +11,6 @@ var terrain: Terrain3D
|
||||
var instance_id: int
|
||||
|
||||
func _enter_tree():
|
||||
instance_id = OS.get_process_id() % 2
|
||||
instance_id = 0 #OS.get_process_id() % 2
|
||||
account = Account.new()
|
||||
account.name = "user%d" % instance_id
|
||||
|
@ -24,6 +24,7 @@ func connect_events():
|
||||
%Client.upload_changed.connect(ui.network.set_upload)
|
||||
|
||||
%Chat.message_received.connect(ui.chat.add_message)
|
||||
%Chat.message_received.connect(show_chat_bubble)
|
||||
ui.chat.message_submitted.connect( %Chat.send_message)
|
||||
|
||||
func start():
|
||||
@ -45,6 +46,9 @@ func start_offline():
|
||||
func start_online():
|
||||
%Login.send_login()
|
||||
|
||||
func show_chat_bubble(player: Player, message: String):
|
||||
player.chat.show_message(message)
|
||||
|
||||
func pause(enabled: bool):
|
||||
get_tree().paused = enabled
|
||||
Audio.mute(enabled)
|
||||
|
15
client/audio/Audio.gd
Normal file
15
client/audio/Audio.gd
Normal file
@ -0,0 +1,15 @@
|
||||
extends Node
|
||||
|
||||
var ui: AudioStreamPlayer
|
||||
|
||||
func _ready():
|
||||
ui = $UI
|
||||
assert(ui)
|
||||
|
||||
func play_ui(stream: AudioStream):
|
||||
ui.stream = stream
|
||||
ui.play()
|
||||
|
||||
func mute(enabled: bool):
|
||||
var master_sound = AudioServer.get_bus_index("Master")
|
||||
AudioServer.set_bus_mute(master_sound, enabled)
|
19
client/audio/Audio.tscn
Normal file
19
client/audio/Audio.tscn
Normal file
@ -0,0 +1,19 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://ev7uecbluell"]
|
||||
|
||||
[ext_resource type="Script" path="res://audio/Audio.gd" id="1_nv42i"]
|
||||
[ext_resource type="AudioStream" uid="uid://b36mntcqlt553" path="res://assets/audio/ambience/Wind-Vegetation-Leaves-Gusts.wav" id="2_fkia1"]
|
||||
|
||||
[node name="Audio" type="Node"]
|
||||
process_thread_group = 2
|
||||
process_thread_group_order = 0
|
||||
process_thread_messages = 0
|
||||
script = ExtResource("1_nv42i")
|
||||
|
||||
[node name="Ambience" type="AudioStreamPlayer" parent="."]
|
||||
stream = ExtResource("2_fkia1")
|
||||
autoplay = true
|
||||
bus = &"Ambience"
|
||||
|
||||
[node name="UI" type="AudioStreamPlayer" parent="."]
|
||||
max_polyphony = 3
|
||||
bus = &"UI"
|
@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=14 format=3 uid="uid://cb2t7bvvf3gwh"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://b358op5h1y83m" path="res://assets/slime/Slime.blend" id="1_1h1hj"]
|
||||
[ext_resource type="PackedScene" uid="uid://b358op5h1y83m" path="res://assets/enemies/slime/Slime.blend" id="1_1h1hj"]
|
||||
[ext_resource type="Script" path="res://enemy/Enemy.gd" id="1_r5888"]
|
||||
[ext_resource type="PackedScene" uid="uid://2bbycjulf00g" path="res://player/health/HealthComponent.tscn" id="2_fsqxc"]
|
||||
[ext_resource type="PackedScene" uid="uid://x102pryt2s5a" path="res://player/movement/MovementComponent.tscn" id="3_2phqx"]
|
||||
|
@ -1,7 +1,7 @@
|
||||
[gd_scene load_steps=14 format=3 uid="uid://dl4vcp04t8iyr"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://cdoxs0s8xh1b3" path="res://particle/FadeOut.tres" id="1_dd0n2"]
|
||||
[ext_resource type="Texture2D" uid="uid://c3wx3cgn8x62m" path="res://assets/particles/particles-single.png" id="1_hhudy"]
|
||||
[ext_resource type="Texture2D" uid="uid://c3wx3cgn8x62m" path="res://assets/effects/particles/particles-single.png" id="1_hhudy"]
|
||||
[ext_resource type="Script" path="res://item/soul/Soul.gd" id="1_mm7cb"]
|
||||
[ext_resource type="Texture2D" uid="uid://cfkwtmj6tc3wa" path="res://item/soul/color_ramp.tres" id="3_ibw0j"]
|
||||
[ext_resource type="AudioStream" uid="uid://l6d76tn8ys5n" path="res://assets/audio/effects/Games-Video-Event-Collect-Item.wav" id="5_cxtbb"]
|
||||
|
@ -1,6 +1,6 @@
|
||||
extends PacketHandler
|
||||
|
||||
signal message_received(message: String)
|
||||
signal message_received(player: Player, message: String)
|
||||
|
||||
func send_message(message: String):
|
||||
var buffer := StreamPeerBuffer.new()
|
||||
@ -14,10 +14,18 @@ func handle_packet(data: PackedByteArray):
|
||||
|
||||
var player_id := buffer.get_string()
|
||||
var player := Global.players.get_player(player_id)
|
||||
|
||||
if !player:
|
||||
return
|
||||
|
||||
var message := buffer.get_utf8_string()
|
||||
message = escape_bbcode(message)
|
||||
|
||||
Log.info("%s: %s" % [player.name, message])
|
||||
message_received.emit("[color=#e0e0e0]%s:[/color] %s" % [player.name, escape_bbcode(message)])
|
||||
emit.call_deferred(player, message)
|
||||
|
||||
func emit(player: Player, message: String):
|
||||
message_received.emit(player, message)
|
||||
|
||||
func escape_bbcode(text: String) -> String:
|
||||
return text.replace("[", "[lb]")
|
||||
|
@ -10,12 +10,18 @@ func handle_packet(data: PackedByteArray):
|
||||
var error := buffer.get_8()
|
||||
if error != 0:
|
||||
Log.info("[%s] Login failed." % Global.account.name)
|
||||
failure.emit()
|
||||
emit_failure.call_deferred()
|
||||
return
|
||||
|
||||
Global.account.id = buffer.get_string()
|
||||
Global.account.auth_token = buffer.get_string()
|
||||
|
||||
emit_success.call_deferred()
|
||||
|
||||
func emit_failure():
|
||||
failure.emit()
|
||||
|
||||
func emit_success():
|
||||
success.emit()
|
||||
|
||||
func send_login():
|
||||
|
@ -4,6 +4,9 @@ signal success
|
||||
|
||||
func handle_packet(_data: PackedByteArray):
|
||||
logout()
|
||||
emit.call_deferred()
|
||||
|
||||
func emit():
|
||||
success.emit()
|
||||
|
||||
func logout():
|
||||
|
@ -12,7 +12,10 @@ func _init():
|
||||
|
||||
func handle_packet(data: PackedByteArray):
|
||||
var id := data[0]
|
||||
var ping := get_time() - history[id]
|
||||
var ping := Time.get_unix_time_from_system() - history[id]
|
||||
emit.call_deferred(ping)
|
||||
|
||||
func emit(ping: float):
|
||||
changed.emit(ping)
|
||||
|
||||
func send_ping():
|
||||
@ -20,9 +23,6 @@ func send_ping():
|
||||
buffer.put_u8(Packet.PING)
|
||||
buffer.put_u8(count)
|
||||
%Client.send(buffer.data_array)
|
||||
history[count] = get_time()
|
||||
history[count] = Time.get_unix_time_from_system()
|
||||
count = (count + 1) % HISTORY_SIZE
|
||||
|
||||
func get_time() -> float:
|
||||
return Time.get_unix_time_from_system()
|
||||
|
||||
|
@ -21,7 +21,7 @@ func handle_packet(data: PackedByteArray):
|
||||
|
||||
Log.info("Add player: %s %s @ %v" % [player_id, player_name, server_position])
|
||||
|
||||
spawn_player(player_id, player_name, server_position)
|
||||
spawn_player.call_deferred(player_id, player_name, server_position)
|
||||
|
||||
func spawn_player(id: String, nick: String, position: Vector3) -> Player:
|
||||
var player: Player
|
||||
|
@ -17,4 +17,11 @@ func on_jump():
|
||||
func handle_packet(data: PackedByteArray):
|
||||
var player_id := data.get_string_from_ascii()
|
||||
var player := Global.players.get_player(player_id)
|
||||
player.controller.jumped.emit()
|
||||
|
||||
if !player || !player.controller:
|
||||
return
|
||||
|
||||
emit.call_deferred(player.controller)
|
||||
|
||||
func emit(controller: Controller):
|
||||
controller.jumped.emit()
|
||||
|
@ -34,7 +34,10 @@ func handle_packet(data: PackedByteArray):
|
||||
|
||||
controller.server_position.x = x
|
||||
controller.server_position.z = z
|
||||
controller.direction_changed.emit(Vector3(direction_x, 0, direction_z))
|
||||
emit.call_deferred(controller, Vector3(direction_x, 0, direction_z))
|
||||
|
||||
func emit(controller: Controller, direction: Vector3):
|
||||
controller.direction_changed.emit(direction)
|
||||
|
||||
func _process(_delta: float):
|
||||
if !Global.player:
|
||||
|
@ -22,6 +22,12 @@ func handle_packet(data: PackedByteArray):
|
||||
var player_id_length := buffer.get_size() - 1
|
||||
var player_id := buffer.get_string(player_id_length)
|
||||
var slot := buffer.get_u8()
|
||||
|
||||
var player := Global.players.get_player(player_id)
|
||||
player.controller.used_skill.emit(slot)
|
||||
|
||||
if !player || !player.controller:
|
||||
return
|
||||
|
||||
emit.call_deferred(player.controller, slot)
|
||||
|
||||
func emit(controller: Controller, slot: int):
|
||||
controller.used_skill.emit(slot)
|
||||
|
@ -21,5 +21,5 @@ func handle_packet(packet: PackedByteArray):
|
||||
push_warning("Unknown packet type %d" % type)
|
||||
return
|
||||
|
||||
handler.handle_packet.call_deferred(packet.slice(1))
|
||||
handler.handle_packet(packet.slice(1))
|
||||
download += packet.size()
|
||||
|
@ -10,6 +10,7 @@ var state: StateComponent
|
||||
var performance: PerformanceComponent
|
||||
var animation: AnimationComponent
|
||||
var physics: CharacterBody3D
|
||||
var chat: ChatComponent
|
||||
|
||||
func _enter_tree():
|
||||
movement = $Movement
|
||||
@ -17,6 +18,7 @@ func _enter_tree():
|
||||
performance = $Performance
|
||||
animation = $Animation
|
||||
physics = $Physics
|
||||
chat = $Chat
|
||||
|
||||
## Name
|
||||
signal name_changed(new_name: String)
|
||||
|
@ -1,21 +1,22 @@
|
||||
[gd_scene load_steps=32 format=3 uid="uid://2lcnu3dy54lx"]
|
||||
[gd_scene load_steps=33 format=3 uid="uid://2lcnu3dy54lx"]
|
||||
|
||||
[ext_resource type="Script" path="res://player/Player.gd" id="1_8gebs"]
|
||||
[ext_resource type="PackedScene" uid="uid://c8j7t4yg7anb0" path="res://assets/female/Female.blend" id="2_8nah6"]
|
||||
[ext_resource type="PackedScene" uid="uid://c8j7t4yg7anb0" path="res://assets/character/female/Female.blend" id="2_8nah6"]
|
||||
[ext_resource type="PackedScene" uid="uid://2bbycjulf00g" path="res://player/health/HealthComponent.tscn" id="2_np5ag"]
|
||||
[ext_resource type="Resource" uid="uid://yaq8ui3f6fwa" path="res://skill/slash/slash.tres" id="2_x58e1"]
|
||||
[ext_resource type="Resource" uid="uid://ba1filjaldakv" path="res://skill/spin/spin.tres" id="3_l76ly"]
|
||||
[ext_resource type="PackedScene" uid="uid://cgqbkj8wbcatv" path="res://assets/hair/PonyTail.blend" id="3_umw6q"]
|
||||
[ext_resource type="Skin" uid="uid://bbqyiue1vj37f" path="res://assets/hoodie/Hoodie_Skin.tres" id="4_b1tg1"]
|
||||
[ext_resource type="ArrayMesh" uid="uid://dbmluwi2atit" path="res://assets/hoodie/Hoodie_Mesh.res" id="5_mkrgn"]
|
||||
[ext_resource type="PackedScene" uid="uid://cgqbkj8wbcatv" path="res://assets/character/hairstyles/ponytail/PonyTail.blend" id="3_umw6q"]
|
||||
[ext_resource type="Skin" uid="uid://bbqyiue1vj37f" path="res://assets/character/clothes/hoodie/Hoodie_Skin.tres" id="4_b1tg1"]
|
||||
[ext_resource type="ArrayMesh" uid="uid://dbmluwi2atit" path="res://assets/character/clothes/hoodie/Hoodie_Mesh.res" id="5_mkrgn"]
|
||||
[ext_resource type="Resource" uid="uid://cnusbw23jf672" path="res://skill/dash/dash.tres" id="5_pnues"]
|
||||
[ext_resource type="PackedScene" uid="uid://6jpnl6c4fdvo" path="res://player/hud/HUDComponent.tscn" id="7_fwgtd"]
|
||||
[ext_resource type="PackedScene" uid="uid://qecdmrg6mbws" path="res://assets/swords/heirloom/Heirloom.blend" id="7_u8433"]
|
||||
[ext_resource type="PackedScene" uid="uid://qecdmrg6mbws" path="res://assets/weapons/swords/heirloom/Heirloom.blend" id="7_u8433"]
|
||||
[ext_resource type="PackedScene" uid="uid://x102pryt2s5a" path="res://player/movement/MovementComponent.tscn" id="8_25qd0"]
|
||||
[ext_resource type="PackedScene" uid="uid://urt8b7grv0qq" path="res://player/chat/ChatComponent.tscn" id="8_pmnom"]
|
||||
[ext_resource type="PackedScene" uid="uid://clnfp813k7lep" path="res://player/footsteps/FootstepsComponent.tscn" id="8_xklbo"]
|
||||
[ext_resource type="PackedScene" uid="uid://d0onbq0ad1ap4" path="res://player/rotation/RotationComponent.tscn" id="9_agxqu"]
|
||||
[ext_resource type="PackedScene" uid="uid://bivxnxwi863o0" path="res://player/animation/AnimationComponent.tscn" id="10_bcaeg"]
|
||||
[ext_resource type="AnimationLibrary" uid="uid://d4n0puibh4hyt" path="res://assets/animations/human.blend" id="11_d0e6r"]
|
||||
[ext_resource type="AnimationLibrary" uid="uid://d4n0puibh4hyt" path="res://assets/character/animations/human.blend" id="11_d0e6r"]
|
||||
[ext_resource type="AudioStream" uid="uid://dlqcgg8v3lvhm" path="res://assets/audio/footsteps/Footsteps-Human-Dirt-00.wav" id="12_h5nrh"]
|
||||
[ext_resource type="AudioStream" uid="uid://bcn7rvvayhnib" path="res://assets/audio/footsteps/Footsteps-Human-Dirt-02.wav" id="14_6dv65"]
|
||||
[ext_resource type="PackedScene" uid="uid://b8xf4ltqyorjv" path="res://player/skills/SkillsComponent.tscn" id="14_6idcf"]
|
||||
@ -105,12 +106,23 @@ bone_idx = 44
|
||||
transform = Transform3D(-4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0, 1, 0.197644, 0, 0)
|
||||
|
||||
[node name="HUD" parent="." node_paths=PackedStringArray("health") instance=ExtResource("7_fwgtd")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.8, 0)
|
||||
visible = false
|
||||
layers = 512
|
||||
visibility_range_end = 50.0
|
||||
visibility_range_end_margin = 10.0
|
||||
visibility_range_fade_mode = 1
|
||||
health = NodePath("../Health")
|
||||
|
||||
[node name="Chat" parent="." instance=ExtResource("8_pmnom")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.37, 0)
|
||||
visible = false
|
||||
layers = 512
|
||||
visibility_range_end = 50.0
|
||||
visibility_range_end_margin = 10.0
|
||||
visibility_range_fade_mode = 1
|
||||
offset = Vector2(200, -44)
|
||||
|
||||
[node name="Attractor" type="GPUParticlesAttractorSphere3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||
strength = 15.0
|
||||
|
@ -1,12 +1,10 @@
|
||||
class_name AnimationComponent
|
||||
extends CharacterComponent
|
||||
|
||||
@export var skip_frames: int = 0
|
||||
|
||||
var animations: AnimationPlayer
|
||||
var state: StateComponent
|
||||
var accumulated_delta: float
|
||||
var skipped_frames: int
|
||||
var delay: float
|
||||
|
||||
func _ready():
|
||||
state = character.get_node("State")
|
||||
@ -16,12 +14,9 @@ func _ready():
|
||||
func _process(delta: float):
|
||||
accumulated_delta += delta
|
||||
|
||||
if skipped_frames >= skip_frames:
|
||||
if accumulated_delta >= delay:
|
||||
animations.advance(accumulated_delta)
|
||||
accumulated_delta = 0
|
||||
skipped_frames = 0
|
||||
else:
|
||||
skipped_frames += 1
|
||||
|
||||
func on_transition(_from: StateComponent.State, to: StateComponent.State):
|
||||
match to:
|
||||
|
10
client/player/chat/ChatBubble.gd
Normal file
10
client/player/chat/ChatBubble.gd
Normal file
@ -0,0 +1,10 @@
|
||||
class_name ChatBubble
|
||||
extends Control
|
||||
|
||||
var label: Label
|
||||
|
||||
func _ready():
|
||||
label = %Label
|
||||
|
||||
func show_message(message: String):
|
||||
label.text = message
|
46
client/player/chat/ChatBubble.tscn
Normal file
46
client/player/chat/ChatBubble.tscn
Normal file
@ -0,0 +1,46 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://epb22atgo7af"]
|
||||
|
||||
[ext_resource type="Script" path="res://player/chat/ChatBubble.gd" id="1_dscmj"]
|
||||
[ext_resource type="LabelSettings" uid="uid://cvqtha83d263j" path="res://player/chat/LabelSettings.tres" id="1_u5tc1"]
|
||||
[ext_resource type="Texture2D" uid="uid://d22tgtevi4ukp" path="res://assets/ui/chat/speech-bubble-blur.png" id="2_e5alo"]
|
||||
|
||||
[node name="ChatBubble" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_dscmj")
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 2
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_top = -512.0
|
||||
offset_right = 512.0
|
||||
grow_vertical = 0
|
||||
texture = ExtResource("2_e5alo")
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_left = -0.00520833
|
||||
anchor_top = 1.00556
|
||||
anchor_right = 0.00885417
|
||||
anchor_bottom = 0.991667
|
||||
offset_left = 82.0
|
||||
offset_top = -374.0
|
||||
offset_right = 427.0
|
||||
offset_bottom = -139.0
|
||||
grow_vertical = 0
|
||||
text = "I think we gotta do this in hard mode."
|
||||
label_settings = ExtResource("1_u5tc1")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
autowrap_mode = 3
|
||||
clip_text = true
|
||||
text_overrun_behavior = 3
|
||||
metadata/_edit_use_anchors_ = true
|
46
client/player/chat/ChatComponent.gd
Normal file
46
client/player/chat/ChatComponent.gd
Normal file
@ -0,0 +1,46 @@
|
||||
class_name ChatComponent
|
||||
extends Sprite3D
|
||||
|
||||
@export var duration: float
|
||||
@export var alpha_curve: Curve
|
||||
|
||||
var sub_viewport: SubViewport
|
||||
var bubble: ChatBubble
|
||||
var time := 0.0
|
||||
|
||||
func _ready():
|
||||
sub_viewport = %SubViewport
|
||||
bubble = %ChatBubble
|
||||
|
||||
assert(alpha_curve)
|
||||
assert(duration > 0)
|
||||
assert(sub_viewport)
|
||||
assert(bubble)
|
||||
|
||||
texture = sub_viewport.get_texture()
|
||||
|
||||
func show_message(message: String):
|
||||
bubble.show_message(message)
|
||||
time = 0
|
||||
set_enabled(true)
|
||||
|
||||
func _process(delta):
|
||||
time += delta
|
||||
|
||||
if time > duration:
|
||||
time = duration
|
||||
set_enabled(false)
|
||||
|
||||
modulate.a = alpha_curve.sample(time / duration)
|
||||
|
||||
func set_enabled(enabled: bool):
|
||||
visible = enabled
|
||||
set_process(enabled)
|
||||
|
||||
match enabled:
|
||||
true:
|
||||
sub_viewport.render_target_clear_mode = SubViewport.CLEAR_MODE_ALWAYS
|
||||
sub_viewport.render_target_update_mode = SubViewport.UPDATE_WHEN_VISIBLE
|
||||
false:
|
||||
sub_viewport.render_target_clear_mode = SubViewport.CLEAR_MODE_NEVER
|
||||
sub_viewport.render_target_update_mode = SubViewport.UPDATE_DISABLED
|
28
client/player/chat/ChatComponent.tscn
Normal file
28
client/player/chat/ChatComponent.tscn
Normal file
@ -0,0 +1,28 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://urt8b7grv0qq"]
|
||||
|
||||
[ext_resource type="Script" path="res://player/chat/ChatComponent.gd" id="1_3o8hk"]
|
||||
[ext_resource type="PackedScene" uid="uid://epb22atgo7af" path="res://player/chat/ChatBubble.tscn" id="2_yfr7m"]
|
||||
|
||||
[sub_resource type="Curve" id="Curve_426w0"]
|
||||
_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(0.05, 1), 0.0, 0.0, 0, 0, Vector2(0.8, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
|
||||
point_count = 4
|
||||
|
||||
[node name="Chat" type="Sprite3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.83994, 0)
|
||||
centered = false
|
||||
offset = Vector2(400, -30)
|
||||
pixel_size = 0.001
|
||||
billboard = 1
|
||||
render_priority = 1
|
||||
region_rect = Rect2(0, 0, 84, 26)
|
||||
script = ExtResource("1_3o8hk")
|
||||
duration = 3.5
|
||||
alpha_curve = SubResource("Curve_426w0")
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="."]
|
||||
unique_name_in_owner = true
|
||||
disable_3d = true
|
||||
transparent_bg = true
|
||||
|
||||
[node name="ChatBubble" parent="SubViewport" instance=ExtResource("2_yfr7m")]
|
||||
unique_name_in_owner = true
|
6
client/player/chat/LabelSettings.tres
Normal file
6
client/player/chat/LabelSettings.tres
Normal file
@ -0,0 +1,6 @@
|
||||
[gd_resource type="LabelSettings" format=3 uid="uid://cvqtha83d263j"]
|
||||
|
||||
[resource]
|
||||
font_size = 54
|
||||
font_color = Color(0.12549, 0.12549, 0.12549, 1)
|
||||
shadow_color = Color(0, 0, 0, 0.12549)
|
@ -15,8 +15,7 @@ var ik_time: float
|
||||
|
||||
func _ready():
|
||||
if owner != Global.player:
|
||||
queue_free()
|
||||
return
|
||||
set_enabled(false)
|
||||
|
||||
for foot_name in feet_names:
|
||||
var foot = Foot.new()
|
||||
@ -94,3 +93,7 @@ func get_foot_rotation(old: Basis, normal: Vector3) -> Basis:
|
||||
new = new.orthonormalized()
|
||||
new = new.rotated(Vector3.UP, PI)
|
||||
return new
|
||||
|
||||
func set_enabled(enabled: bool):
|
||||
set_process(enabled)
|
||||
set_physics_process(enabled)
|
||||
|
@ -18,4 +18,4 @@ func on_health_changed():
|
||||
elif value < 0.75:
|
||||
texture_progress = medium
|
||||
else:
|
||||
texture_progress = high
|
||||
texture_progress = high
|
||||
|
@ -17,6 +17,9 @@ func _ready():
|
||||
character.controlled.connect(on_controlled)
|
||||
|
||||
func _process(delta: float):
|
||||
if (physics_position - character.position).length_squared() < 0.00001:
|
||||
return
|
||||
|
||||
character.position = Math.damp_vector(character.position, physics_position, ticks_per_second * delta)
|
||||
|
||||
func _physics_process(delta: float):
|
||||
|
36
client/player/performance/AnimationPerformance.gd
Normal file
36
client/player/performance/AnimationPerformance.gd
Normal file
@ -0,0 +1,36 @@
|
||||
class_name AnimationPerformance
|
||||
|
||||
const DELAY_INVISIBLE := 1.0
|
||||
const DELAY_VISIBLE := 0.5
|
||||
|
||||
static var quality_budget: Array[int] = [
|
||||
10, # Full animation quality
|
||||
5, # 2.5 ms delay
|
||||
5, # 5.0 ms delay
|
||||
5, # 7.5 ms delay
|
||||
5, # 10.0 ms delay
|
||||
5, # 12.5 ms delay
|
||||
5, # 15 ms delay
|
||||
5, # 17.5 ms delay
|
||||
5, # 20 ms delay
|
||||
]
|
||||
|
||||
static func update_animation_quality(visible_players: Array[Player]):
|
||||
var delay := 0.0
|
||||
var count := 0
|
||||
var index := 0
|
||||
|
||||
for player in visible_players:
|
||||
if index >= quality_budget.size():
|
||||
player.performance.delay_visible = DELAY_VISIBLE
|
||||
player.animation.delay = DELAY_VISIBLE
|
||||
continue
|
||||
|
||||
player.performance.delay_visible = delay
|
||||
player.animation.delay = delay
|
||||
count += 1
|
||||
|
||||
if count >= quality_budget[index]:
|
||||
index += 1
|
||||
delay += 0.025
|
||||
count = 0
|
@ -1,25 +1,11 @@
|
||||
class_name PerformanceComponent
|
||||
extends VisibleOnScreenNotifier3D
|
||||
|
||||
const SKIP_FRAMES_INVISIBLE := 16
|
||||
const SKIP_FRAMES_VISIBLE := 8
|
||||
|
||||
static var quality_budget: Array[int] = [
|
||||
10, # 0 skipped frames
|
||||
10, # 1 skipped frame
|
||||
10, # 2 skipped frames
|
||||
10, # 3 skipped frames
|
||||
10, # 4 skipped frames
|
||||
10, # 5 skipped frames
|
||||
10, # 6 skipped frames
|
||||
10, # 7 skipped frames
|
||||
]
|
||||
|
||||
@export var animation: AnimationComponent
|
||||
|
||||
var camera_distance_squared: float
|
||||
var on_screen: bool
|
||||
var skip_frames_visible: int
|
||||
var delay_visible: float
|
||||
|
||||
func _ready():
|
||||
assert(animation)
|
||||
@ -28,13 +14,13 @@ func _ready():
|
||||
|
||||
func on_screen_entered():
|
||||
on_screen = true
|
||||
animation.skip_frames = skip_frames_visible
|
||||
animation.delay = delay_visible
|
||||
|
||||
func on_screen_exited():
|
||||
on_screen = false
|
||||
animation.skip_frames = SKIP_FRAMES_INVISIBLE
|
||||
animation.delay = AnimationPerformance.DELAY_INVISIBLE
|
||||
|
||||
static func update_all_animations():
|
||||
static func get_visible_players_sorted_by_distance() -> Array[Player]:
|
||||
var visible_players: Array[Player] = []
|
||||
|
||||
for player in Global.players.id_to_player.values():
|
||||
@ -43,30 +29,13 @@ static func update_all_animations():
|
||||
if player.performance.on_screen:
|
||||
visible_players.append(player)
|
||||
else:
|
||||
player.performance.animation.skip_frames = SKIP_FRAMES_INVISIBLE
|
||||
player.performance.animation.delay = AnimationPerformance.DELAY_INVISIBLE
|
||||
|
||||
if Global.player:
|
||||
Global.player.performance.camera_distance_squared = 0
|
||||
|
||||
visible_players.sort_custom(PerformanceComponent.distance_sort)
|
||||
|
||||
var skip_frames := 0
|
||||
var count := 0
|
||||
|
||||
for player in visible_players:
|
||||
if skip_frames >= quality_budget.size():
|
||||
player.performance.skip_frames_visible = SKIP_FRAMES_VISIBLE
|
||||
player.animation.skip_frames = SKIP_FRAMES_VISIBLE
|
||||
continue
|
||||
|
||||
player.performance.skip_frames_visible = skip_frames
|
||||
player.animation.skip_frames = skip_frames
|
||||
count += 1
|
||||
|
||||
if count >= quality_budget[skip_frames]:
|
||||
skip_frames += 1
|
||||
count = 0
|
||||
return visible_players
|
||||
|
||||
static func distance_sort(a: Player, b: Player) -> bool:
|
||||
return a.performance.camera_distance_squared < b.performance.camera_distance_squared
|
||||
|
||||
return a.performance.camera_distance_squared < b.performance.camera_distance_squared
|
@ -22,6 +22,7 @@ buses/default_bus_layout="res://world/AudioBusLayout.tres"
|
||||
[autoload]
|
||||
|
||||
Global="*res://Global.tscn"
|
||||
Audio="*res://audio/Audio.tscn"
|
||||
|
||||
[debug]
|
||||
|
||||
|
@ -1,5 +0,0 @@
|
||||
class_name Audio
|
||||
|
||||
static func mute(enabled: bool):
|
||||
var master_sound = AudioServer.get_bus_index("Master")
|
||||
AudioServer.set_bus_mute(master_sound, enabled)
|
10
client/ui/button/Button.gd
Normal file
10
client/ui/button/Button.gd
Normal file
@ -0,0 +1,10 @@
|
||||
extends Button
|
||||
|
||||
@export var hover: AudioStream
|
||||
@export var click: AudioStream
|
||||
|
||||
func _ready():
|
||||
assert(hover)
|
||||
assert(click)
|
||||
mouse_entered.connect(Audio.play_ui.bind(hover))
|
||||
button_down.connect(Audio.play_ui.bind(click))
|
15
client/ui/button/Button.tscn
Normal file
15
client/ui/button/Button.tscn
Normal file
@ -0,0 +1,15 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://bul4bacam6s78"]
|
||||
|
||||
[ext_resource type="Script" path="res://ui/button/Button.gd" id="1_75erh"]
|
||||
[ext_resource type="AudioStream" uid="uid://bxg5jpc7glw8s" path="res://assets/audio/ui/hover.wav" id="2_7ak8k"]
|
||||
[ext_resource type="AudioStream" uid="uid://bfa480mk0nwj" path="res://assets/audio/ui/click.wav" id="3_o67x3"]
|
||||
|
||||
[node name="Button" type="Button"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_75erh")
|
||||
hover = ExtResource("2_7ak8k")
|
||||
click = ExtResource("3_o67x3")
|
@ -3,5 +3,5 @@ extends VBoxContainer
|
||||
|
||||
signal message_submitted(message: String)
|
||||
|
||||
func add_message(message: String):
|
||||
%Messages.append_text("%s\n" % message)
|
||||
func add_message(player: Player, message: String):
|
||||
%Messages.append_text("[color=#e0e0e0]%s:[/color] %s\n" % [player.name, message])
|
@ -26,5 +26,8 @@ func on_text_submitted(message: String):
|
||||
text = ""
|
||||
release_focus()
|
||||
|
||||
if !message:
|
||||
return
|
||||
|
||||
var chat := owner as Chat
|
||||
chat.message_submitted.emit(message)
|
||||
|
@ -8,4 +8,4 @@ func set_download(download: int):
|
||||
%Receive.text = "%d bytes" % download
|
||||
|
||||
func set_upload(upload: int):
|
||||
%Send.text = "%d bytes" % upload
|
||||
%Send.text = "%d bytes" % upload
|
||||
|
@ -1,7 +1,8 @@
|
||||
[gd_scene load_steps=16 format=3 uid="uid://bqpbrju7mc7d5"]
|
||||
[gd_scene load_steps=17 format=3 uid="uid://bqpbrju7mc7d5"]
|
||||
|
||||
[ext_resource type="Script" path="res://ui/settings/Settings.gd" id="1_gx3lf"]
|
||||
[ext_resource type="Script" path="res://ui/label/ParentNameLabel.gd" id="2_72a3s"]
|
||||
[ext_resource type="PackedScene" uid="uid://bul4bacam6s78" path="res://ui/button/Button.tscn" id="3_42una"]
|
||||
[ext_resource type="Script" path="res://ui/settings/video/Preset.gd" id="3_il1yi"]
|
||||
[ext_resource type="Script" path="res://ui/settings/video/RenderScale.gd" id="4_owrjf"]
|
||||
[ext_resource type="Script" path="res://ui/settings/video/ScaleMode.gd" id="5_monk2"]
|
||||
@ -55,17 +56,17 @@ script = ExtResource("2_72a3s")
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Low" type="Button" parent="TabContainer/Video/VBoxContainer/Preset/HBoxContainer"]
|
||||
[node name="Low" parent="TabContainer/Video/VBoxContainer/Preset/HBoxContainer" instance=ExtResource("3_42una")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Low"
|
||||
|
||||
[node name="Medium" type="Button" parent="TabContainer/Video/VBoxContainer/Preset/HBoxContainer"]
|
||||
[node name="Medium" parent="TabContainer/Video/VBoxContainer/Preset/HBoxContainer" instance=ExtResource("3_42una")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Medium"
|
||||
|
||||
[node name="High" type="Button" parent="TabContainer/Video/VBoxContainer/Preset/HBoxContainer"]
|
||||
[node name="High" parent="TabContainer/Video/VBoxContainer/Preset/HBoxContainer" instance=ExtResource("3_42una")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "High"
|
||||
@ -272,6 +273,9 @@ layout_mode = 2
|
||||
[node name="Ambience" parent="TabContainer/Audio/VBoxContainer" instance=ExtResource("14_pvo80")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="UI" parent="TabContainer/Audio/VBoxContainer" instance=ExtResource("14_pvo80")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Skills" parent="TabContainer/Audio/VBoxContainer" instance=ExtResource("14_pvo80")]
|
||||
layout_mode = 2
|
||||
|
||||
|
@ -12,4 +12,4 @@ texture_margin_left = 24.0
|
||||
texture_margin_top = 24.0
|
||||
texture_margin_right = 24.0
|
||||
texture_margin_bottom = 24.0
|
||||
modulate_color = Color(1, 1, 1, 0.752941)
|
||||
modulate_color = Color(1, 1, 1, 0.878431)
|
||||
|
@ -30,15 +30,21 @@ bus/4/volume_db = -12.9785
|
||||
bus/4/send = &"Master"
|
||||
bus/4/effect/0/effect = SubResource("AudioEffectReverb_hjj00")
|
||||
bus/4/effect/0/enabled = true
|
||||
bus/5/name = &"Footsteps"
|
||||
bus/5/name = &"UI"
|
||||
bus/5/solo = false
|
||||
bus/5/mute = false
|
||||
bus/5/bypass_fx = false
|
||||
bus/5/volume_db = -4.5
|
||||
bus/5/send = &"Effects"
|
||||
bus/6/name = &"Skills"
|
||||
bus/5/volume_db = 0.0
|
||||
bus/5/send = &"Master"
|
||||
bus/6/name = &"Footsteps"
|
||||
bus/6/solo = false
|
||||
bus/6/mute = false
|
||||
bus/6/bypass_fx = false
|
||||
bus/6/volume_db = 0.0
|
||||
bus/6/volume_db = -4.5
|
||||
bus/6/send = &"Effects"
|
||||
bus/7/name = &"Skills"
|
||||
bus/7/solo = false
|
||||
bus/7/mute = false
|
||||
bus/7/bypass_fx = false
|
||||
bus/7/volume_db = 0.0
|
||||
bus/7/send = &"Effects"
|
||||
|
@ -10,7 +10,8 @@ func _ready():
|
||||
timer.timeout.connect(tick)
|
||||
|
||||
func tick():
|
||||
PerformanceComponent.update_all_animations()
|
||||
var visible_players := PerformanceComponent.get_visible_players_sorted_by_distance()
|
||||
AnimationPerformance.update_animation_quality(visible_players)
|
||||
|
||||
func add(player: Player):
|
||||
if has(player.id):
|
||||
@ -20,7 +21,7 @@ func add(player: Player):
|
||||
id_to_player[player.id] = player
|
||||
|
||||
func get_player(id: String) -> Player:
|
||||
return id_to_player[id] as Player
|
||||
return id_to_player.get(id) as Player
|
||||
|
||||
func has(id: String) -> bool:
|
||||
return id_to_player.has(id)
|
||||
|
@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=19 format=3 uid="uid://be6mcpdaobs5u"]
|
||||
[gd_scene load_steps=18 format=3 uid="uid://be6mcpdaobs5u"]
|
||||
|
||||
[ext_resource type="Terrain3DStorage" uid="uid://c38e3dyrl8lao" path="res://assets/terrain/Storage.res" id="1_xsh2l"]
|
||||
[ext_resource type="Terrain3DMaterial" uid="uid://nhcs8ekjedbb" path="res://world/terrain/Material.tres" id="2_3ekjf"]
|
||||
@ -15,7 +15,6 @@
|
||||
[ext_resource type="FastNoiseLite" uid="uid://d3f4lk8q04haa" path="res://world/trees/TreeNoise.tres" id="14_6v5re"]
|
||||
[ext_resource type="Environment" uid="uid://dixa0yso2s1u3" path="res://world/Environment.tres" id="16_i8t0h"]
|
||||
[ext_resource type="Script" path="res://world/Sun.gd" id="17_nxk5c"]
|
||||
[ext_resource type="AudioStream" uid="uid://b36mntcqlt553" path="res://assets/audio/ambience/Wind-Vegetation-Leaves-Gusts.wav" id="18_8j4nl"]
|
||||
|
||||
[sub_resource type="FastNoiseLite" id="FastNoiseLite_yp2fx"]
|
||||
seed = 100
|
||||
@ -80,8 +79,3 @@ transform = Transform3D(-0.350207, 0.827032, -0.439741, 0, 0.469472, 0.882948, 0
|
||||
light_energy = 1.8
|
||||
shadow_enabled = true
|
||||
script = ExtResource("17_nxk5c")
|
||||
|
||||
[node name="Ambience" type="AudioStreamPlayer" parent="."]
|
||||
stream = ExtResource("18_8j4nl")
|
||||
autoplay = true
|
||||
bus = &"Ambience"
|
||||
|
@ -1,7 +1,7 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://hvc8oecqweko"]
|
||||
|
||||
[ext_resource type="Material" uid="uid://bdsblfaxbipaa" path="res://world/grass/GrassMaterial.tres" id="1_xchh7"]
|
||||
[ext_resource type="MultiMesh" uid="uid://dog5aq5n2q025" path="res://assets/grass/grass.multimesh" id="2_cpr6g"]
|
||||
[ext_resource type="MultiMesh" uid="uid://dog5aq5n2q025" path="res://assets/world/grass/grass.multimesh" id="2_cpr6g"]
|
||||
|
||||
[node name="Grass" type="MultiMeshInstance3D"]
|
||||
layers = 2
|
||||
|
@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://djilgnhedvmtm"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://b0w38xjifulq6" path="res://assets/house/House.blend" id="1_0ihm4"]
|
||||
[ext_resource type="PackedScene" uid="uid://b0w38xjifulq6" path="res://assets/world/house/House.blend" id="1_0ihm4"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_egbsr"]
|
||||
size = Vector3(5, 3.5, 5)
|
||||
|
@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://tr0tn0pkr1ea"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://8rgrrx6wbdvf" path="res://assets/tree/Callistemon.blend" id="1_ngx2x"]
|
||||
[ext_resource type="PackedScene" uid="uid://8rgrrx6wbdvf" path="res://assets/world/tree/Callistemon.blend" id="1_ngx2x"]
|
||||
|
||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_6f3jh"]
|
||||
height = 1.5
|
||||
|
@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://cuuwwdce1u8n8"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://ctsrv1aeqj0h" path="res://assets/tree/Sapling.blend" id="1_lb0yq"]
|
||||
[ext_resource type="PackedScene" uid="uid://ctsrv1aeqj0h" path="res://assets/world/tree/Sapling.blend" id="1_lb0yq"]
|
||||
|
||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_qu7ax"]
|
||||
height = 1.5
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
SpawnPoint = Vector3{584.98, 9.5, 394.68}
|
||||
SpawnPoint = Vector3{584.98, 9.8, 394.68}
|
||||
accounts = map[string]*Account{}
|
||||
)
|
||||
|
||||
@ -19,7 +19,7 @@ func init() {
|
||||
func MakeTestAccounts() {
|
||||
for i := range 500 {
|
||||
angle := rand.Float64() * math.Pi * 2
|
||||
distance := rand.Float64() * 12.0
|
||||
distance := rand.Float64() * 25.0
|
||||
|
||||
accounts[fmt.Sprintf("user%d", i)] = &Account{
|
||||
ID: fmt.Sprintf("id%d", i),
|
||||
|
Reference in New Issue
Block a user