diff options
Diffstat (limited to 'client/player/player.gd')
| -rw-r--r-- | client/player/player.gd | 74 |
1 files changed, 45 insertions, 29 deletions
diff --git a/client/player/player.gd b/client/player/player.gd index c314dad2..031cba29 100644 --- a/client/player/player.gd +++ b/client/player/player.gd @@ -41,16 +41,17 @@ var marker_target = Vector3(0, 0, 0) var clear_timer: Timer = Timer.new() -var hand: Item = null -var hand_base: Node3D = Node3D.new() +var hand = [null, null] +var hand_base var character_idx: int var is_customer: bool var current_item_message = null var _anim_angle: float = 0.0 -var hand_base_position: Vector3 = DEFAULT_HAND_BASE_POSITION -const DEFAULT_HAND_BASE_POSITION: Vector3 = Vector3(0, .425, .4) +const DEFAULT_HAND_BASE_POSITION_CENTER: Vector3 = Vector3(0, .425, .4) +const DEFAULT_HAND_BASE_POSITION_LEFT: Vector3 = Vector3(.3, .425, .4) +const DEFAULT_HAND_BASE_POSITION_RIGHT: Vector3 = Vector3(-.3, .425, .4) func _init(_id: int, new_name: String, pos: Vector2, new_character_idx: int, new_game: Game): add_child(movement_base) @@ -62,9 +63,22 @@ func _init(_id: int, new_name: String, pos: Vector2, new_character_idx: int, new game = new_game username = new_name - hand_base.name = "HandBase" - hand_base.position = hand_base_position - movement_base.add_child(hand_base) + if game.hand_count == 1: + var center = Node3D.new() + center.name = "HandBaseCenter" + center.position = DEFAULT_HAND_BASE_POSITION_CENTER + hand_base = [center] + else: + var left = Node3D.new() + var right = Node3D.new() + left.name = "HandBaseLeft" + right.name = "HandBaseRight" + left.position = DEFAULT_HAND_BASE_POSITION_LEFT + right.position = DEFAULT_HAND_BASE_POSITION_RIGHT + hand_base = [left, right] + + for h in hand_base: + movement_base.add_child(h) movement_base.add_child(chat_bubble) movement_base.add_child(item_bubble) @@ -96,45 +110,47 @@ func update_username_tag(state): tag.text = username tag.visible = state -func set_item(i: Item): - if hand != null: hand.remove() - if i != null: - @warning_ignore("static_called_on_instance") - hand_base_position = DEFAULT_HAND_BASE_POSITION - Vector3(0.,i.height() * 0.5, 0.) +func set_item(i: Item, h: int): + if hand[h] != null: hand[h].remove() + # if i != null: + # @warning_ignore("static_called_on_instance") + # hand_base_position[h] = DEFAULT_HAND_BASE_POSITION_LEFT - Vector3(0.,i.height() * 0.5, 0.) + # @warning_ignore("static_called_on_instance") + # hand_base_position[1] = DEFAULT_HAND_BASE_POSITION_RIGHT - Vector3(0.,i.height() * 0.5, 0.) character.holding = i != null - hand = i - if hand != null: hand.owned_by = hand_base + hand[h] = i + if hand[h] != null: hand[h].owned_by = hand_base[h] -func remove_item(): - var i = hand +func remove_item(h: int): + var i = hand[h] if i == null: push_error("holding nothing") - hand = null + hand[h] = null character.holding = false return i -func progress(position__: float, speed: float, warn: bool): - if hand != null: hand.progress(position__, speed, warn) +func progress(position__: float, speed: float, warn: bool, h: int): + if hand[h] != null: hand[h].progress(position__, speed, warn) -func finish(): - if hand != null: hand.finish() +func finish(h: int): + if hand[h] != null: hand[h].finish() -func take_item(tile: Tile): - if hand != null: push_error("already holding an item") +func take_item(tile: Tile, h: int): + if hand[h] != null: push_error("already holding an item") var i = tile.take_item() i.take() - set_item(i) + set_item(i, h) -func put_item(tile: Tile): - var i = remove_item() +func put_item(tile: Tile, h: int): + var i = remove_item(h) i.put() tile.put_item(i) -func pass_to(player: Player): - var i = remove_item() +func pass_to(player: Player, hfrom: int, hto: int): + var i = remove_item(hfrom) i.player_owned_timer = 0 if player.hand != null: push_error("target is already holding an item") - player.set_item(i) + player.set_item(i, hto) func _process(delta): _anim_angle = fmod(_anim_angle + delta, TAU) |