Merge branch 'main' of ssh://git.gieszer.link:2222/unfa/liblast

remotes/1705377932733043820/tmp_refs/heads/unbroken
unfa 2021-09-11 22:25:18 +02:00
commit 7be3893dd5
4 changed files with 16 additions and 32 deletions

View File

@ -199,17 +199,14 @@ func die(killer_pid: int):
main.chat.rpc(&'chat_notification', "Player [/i][b][color=" + main.player_list.players[self.get_network_authority()].color.to_html() + "]" + main.player_list.players[self.get_network_authority()].name + "[/color][/b][i] was killed by " + main.player_list.players[killer_pid].name )
#queue_free()
func update_color(pid) -> void: #change player's wolrdmodel color
## @onready var player_material =
## var material = player_material
if pid != self.get_network_authority():
print("Requesting color change for a different PID")
return
func update_player(info) -> void:
update_color(info.color)
func update_color(color) -> void: #change player's wolrdmodel color
#var pid = self.get_network_authority()
var player_material = mesh.mesh.surface_get_material(0).duplicate()
player_material.albedo_color = main.player_list.get(self.get_network_authority()).color
print("Updating color of player pid ", self.get_network_authority(), " to ", player_material.albedo_color )
mesh.mesh.surface_set_material(0, player_material)
player_material.albedo_color = color
mesh.set_surface_override_material(0, player_material)
func _physics_process(delta):
# rpc_unreliable(&'set_global_transform', global_transform)

View File

@ -2,7 +2,7 @@
[ext_resource type="Script" path="res://Assets/Characters/Player.gd" id="1"]
[ext_resource type="PackedScene" uid="uid://bemrov0tiy08n" path="res://Assets/Weapons/Weapon.tscn" id="3"]
[ext_resource type="Texture2D" uid="uid://cguy76rs8e220" path="res://Assets/Effects/Flame.png" id="3_jw7jd"]
[ext_resource type="Texture2D" uid="uid://pnh872qjk0oy" path="res://Assets/Effects/Flame.png" id="3_jw7jd"]
[sub_resource type="StandardMaterial3D" id="4"]
albedo_color = Color(0.545098, 0.545098, 0.545098, 1)

View File

@ -1,10 +1,10 @@
[gd_scene load_steps=12 format=3 uid="uid://bff5uslrxesjx"]
[ext_resource type="Texture2D" uid="uid://blnjjtjifk22i" path="res://Assets/HUD/Vignette.png" id="1"]
[ext_resource type="Texture2D" uid="uid://dlw3sb5tygqf4" path="res://Assets/HUD/Vignette.png" id="1"]
[ext_resource type="Script" path="res://Assets/HUD/HUD.gd" id="1_wc430"]
[ext_resource type="Texture2D" uid="uid://cvckx0ssydl4d" path="res://Assets/HUD/Crosshair.png" id="2"]
[ext_resource type="AudioStream" uid="uid://bomutmdekfv3m" path="res://Assets/SFX/UI_Confirm_Kill.wav" id="3"]
[ext_resource type="AudioStream" uid="uid://184gasqdlb20" path="res://Assets/SFX/UI_Confirm_Hit.wav" id="4"]
[ext_resource type="Texture2D" uid="uid://cjfjsnff41st1" path="res://Assets/HUD/Crosshair.png" id="2"]
[ext_resource type="AudioStream" uid="uid://cbehcynykrbqn" path="res://Assets/SFX/UI_Confirm_Kill.wav" id="3"]
[ext_resource type="AudioStream" uid="uid://b4th1lwwyw40k" path="res://Assets/SFX/UI_Confirm_Hit.wav" id="4"]
[ext_resource type="Script" path="res://Assets/HUD/Crosshair.gd" id="5"]
[ext_resource type="Script" path="res://Assets/HUD/Chat.gd" id="6"]
[ext_resource type="Theme" uid="uid://ddtu7o1dbp0s8" path="res://Assets/HUD/Theme.tres" id="7"]

View File

@ -224,22 +224,9 @@ func update_hud():
@rpc(any) func player_list_update(info, pid = get_tree().get_rpc_sender_id()):
var new_info = PlayerInfo.new()
new_info.deserialize(info)
print("Recieved player info: ", info)
if player_list.players.has(pid):
var old_name = player_list.get(pid).name
if old_name != new_info.name:
chat.chat_notification("Player [b]" + old_name + "[/b] changed name to [b]" + new_info.name + "[/b]")
var old_color = player_list.get(pid).color
if old_color != new_info.color:
#chat.chat_notification("Player [b]" + new_info.name + "[/b] changed color to [b][color=" + new_info.color.to_html() + "]" + new_info.name + "[/color][/b]")
$Players.get_node(str(pid)).update_color(pid)
elif get_tree().multiplayer.get_network_unique_id() == 1:
for i in player_list.players.keys(): #notify existing players the new one has joined
# if i != pid:
chat.rpc_id(i, &'chat_notification', "Player [b]" + new_info.name + "[/b] joined")
var player = $Players.get_node(str(pid))
player.update_player(new_info)
player_list.set(pid, new_info) # server relays other PID's data
@ -247,7 +234,7 @@ func update_hud():
update_hud()
#if pid == get_tree().multiplayer.get_network_unique_id():
func push_local_player_info(): #
func push_local_player_info():
var id = get_tree().multiplayer.get_network_unique_id()
#print("PLayer info vsr2str: ", var2str(player_list.get(id)) )
@ -263,7 +250,7 @@ func push_local_player_info(): #
assert(player_node != null, "Attempting to delete a player node that does not exist")
player_node.name = str(player_node.name) + "_dead" # avoids name collision when instancing another player scene
player_node.queue_free()
spawn_queue[pid] = uptime + respawn_delay
func create_player(pid: int, is_local:= false, respawn:= false) -> void: