fixed host client not receiving their id
This commit is contained in:
+53
-3
@@ -1,16 +1,66 @@
|
||||
class_name EnvironmentManager
|
||||
extends Node3D
|
||||
|
||||
var player_hands: Dictionary[int, PlayerHandAssociation]
|
||||
# In gameplay order
|
||||
var hand_associations: Dictionary[int, PlayerHandAssociation]
|
||||
var _own_client_id: String
|
||||
@export var own_player_hand: PlayerHand
|
||||
|
||||
## Positions for hands in 3-player game (starting from player 2).
|
||||
@export var hand_markers_3: Array[Marker3D]
|
||||
|
||||
## Positions for hands in 4-player game (starting from player 2).
|
||||
@export var hand_markers_4: Array[Marker3D]
|
||||
|
||||
## Positions for hands in 5-player game (starting from player 2).
|
||||
@export var hand_markers_5: Array[Marker3D]
|
||||
|
||||
## Positions for hands in 6-player game (starting from player 2).
|
||||
@export var hand_markers_6: Array[Marker3D]
|
||||
|
||||
@export var player_hand_scene: PackedScene
|
||||
|
||||
func _on_web_client_tcp_client_order_received(client_ids: Array[String]) -> void:
|
||||
var marker_positions: Array[Marker3D]
|
||||
match client_ids.size():
|
||||
3:
|
||||
marker_positions = hand_markers_3
|
||||
4:
|
||||
marker_positions = hand_markers_4
|
||||
5:
|
||||
marker_positions = hand_markers_5
|
||||
6:
|
||||
marker_positions = hand_markers_6
|
||||
|
||||
var own_index: int = client_ids.find(_own_client_id)
|
||||
|
||||
var new_ids: Array[String]
|
||||
if own_index == 0:
|
||||
print("ïndex was 0 " + _own_client_id)
|
||||
# no change necessary!
|
||||
new_ids = client_ids
|
||||
elif own_index == client_ids.size() - 1:
|
||||
print("index was last " + _own_client_id)
|
||||
# you are at the end of the array
|
||||
new_ids = client_ids
|
||||
# take away own client id
|
||||
new_ids.erase(_own_client_id)
|
||||
# add it to the start of the array
|
||||
new_ids.insert(0, _own_client_id)
|
||||
else:
|
||||
print("index was middle " + _own_client_id)
|
||||
# you are somewhere in the middle of the array
|
||||
# create array with you at the start
|
||||
new_ids = client_ids.slice(own_index)
|
||||
# add the rest of the original array
|
||||
new_ids.append_array(client_ids.slice(0, own_index))
|
||||
|
||||
print("playing order! -- !")
|
||||
print(new_ids)
|
||||
|
||||
for index in client_ids.size():
|
||||
if client_ids[index] == _own_client_id:
|
||||
player_hands[index] = PlayerHandAssociation.new(
|
||||
hand_associations[index] = PlayerHandAssociation.new(
|
||||
_own_client_id,
|
||||
own_player_hand.get_path(),
|
||||
)
|
||||
@@ -19,7 +69,7 @@ func _on_web_client_tcp_client_order_received(client_ids: Array[String]) -> void
|
||||
|
||||
# TODO
|
||||
self.add_child(hand) # needs position!
|
||||
player_hands[index] = PlayerHandAssociation.new(
|
||||
hand_associations[index] = PlayerHandAssociation.new(
|
||||
client_ids[index],
|
||||
hand.get_path(),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user