forked from unfa/liblast
Fixed smart fridge
This commit is contained in:
parent
6622d27977
commit
f420a7c68a
3 changed files with 19 additions and 2 deletions
5
Assets/Characters/SmartFridge/SmartFridge.gd
Normal file
5
Assets/Characters/SmartFridge/SmartFridge.gd
Normal file
|
@ -0,0 +1,5 @@
|
|||
extends "res://Player.gd"
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
|
@ -1,9 +1,11 @@
|
|||
[gd_scene load_steps=3 format=2]
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://Player.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Assets/Characters/SmartFridge/SmartFridge.gltf" type="PackedScene" id=2]
|
||||
[ext_resource path="res://Assets/Characters/SmartFridge/SmartFridge.gd" type="Script" id=3]
|
||||
|
||||
[node name="SmartFridge" instance=ExtResource( 1 )]
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="SmartFridge" parent="." index="6" instance=ExtResource( 2 )]
|
||||
transform = Transform( -1, 0, -3.25841e-07, 0, 1, 0, 3.25841e-07, 0, -1, 0, 0, 0.313989 )
|
||||
|
|
12
Game.gd
12
Game.gd
|
@ -39,6 +39,7 @@ func set_local_player(player):
|
|||
on_player_added(player)
|
||||
|
||||
var player_data = get_player_data()
|
||||
print(player_data)
|
||||
|
||||
rpc("set_player_data", player_data)
|
||||
|
||||
|
@ -264,8 +265,14 @@ func get_character_scene(character_name):
|
|||
|
||||
remote func check_players(player_data):
|
||||
for player_name in player_data:
|
||||
var data = player_data[player_name]
|
||||
|
||||
if $Players.has_node(player_name):
|
||||
var p = $Players.get_node(player_name)
|
||||
if data["char_class"] != p.player_class:
|
||||
$Players.remove_child(p)
|
||||
|
||||
if not $Players.has_node(player_name):
|
||||
var data = player_data[player_name]
|
||||
var player = get_character_scene(data["char_class"]).instance()
|
||||
|
||||
player.name = player_name
|
||||
|
@ -277,6 +284,8 @@ remote func check_players(player_data):
|
|||
player.set_nickname(data["nickname"])
|
||||
|
||||
on_player_added(player)
|
||||
|
||||
print(player.player_class)
|
||||
|
||||
func join_game():
|
||||
var player = player_scene.instance()
|
||||
|
@ -316,6 +325,7 @@ func on_peer_connected(id):
|
|||
|
||||
master func set_player_data(player_data):
|
||||
check_players(player_data)
|
||||
|
||||
var new_player_data = get_player_data()
|
||||
|
||||
rpc("check_players", new_player_data)
|
||||
|
|
Loading…
Reference in a new issue