diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/game.gd | 14 | ||||
-rw-r--r-- | client/global.gd | 9 | ||||
-rw-r--r-- | client/multiplayer.gd | 3 | ||||
-rw-r--r-- | client/player/controllable_player.gd | 12 | ||||
-rw-r--r-- | client/player/player.gd | 31 |
5 files changed, 36 insertions, 33 deletions
diff --git a/client/game.gd b/client/game.gd index 9a6b8808..9502d2fc 100644 --- a/client/game.gd +++ b/client/game.gd @@ -144,13 +144,13 @@ func handle_packet(p): player_instance.position_ = last_position "move_item": if "player" in p.from and "player" in p.to: - players[p.from.player[0]].pass_to(players[p.to.player[0]], p.from.player[1], p.to.player[1]) + players[p.from.player[0]].pass_to(players[p.to.player[0]], int(p.from.player[1]), int(p.to.player[1])) elif "tile" in p.from and "player" in p.to: var t: Tile = map.get_tile_instance(p.from.tile) - players[p.to.player[0]].take_item(t, p.to.player[1]) + players[p.to.player[0]].take_item(t, int(p.to.player[1])) elif "player" in p.from and "tile" in p.to: var t: Tile = map.get_tile_instance(p.to.tile) - players[p.from.player[0]].put_item(t, p.from.player[1]) + players[p.from.player[0]].put_item(t, int(p.from.player[1])) elif "tile" in p.from and "tile" in p.to: var from_tile2: Tile = map.get_tile_instance(p.from.tile) var to_tile2: Tile = map.get_tile_instance(p.to.tile) @@ -160,13 +160,13 @@ func handle_packet(p): var t: Tile = map.get_tile_instance(p.item.tile) t.progress(p.position, p.speed, p.warn, players.get(p.player)) else: - players[p.item.player[0]].progress(p.position, p.speed, p.warn, p.item.player[1]) + players[p.item.player[0]].progress(p.position, p.speed, p.warn, int(p.item.player[1])) "clear_progress": if "tile" in p.item: var t: Tile = map.get_tile_instance(p.item.tile) t.finish() else: - players[p.item.player[0]].finish(p.item.player[1]) + players[p.item.player[0]].finish(int(p.item.player[1])) "set_item": var location: Dictionary = p["location"] if p.item != null: @@ -180,8 +180,8 @@ func handle_packet(p): else: var pl: Player = players[p.location.player[0]] var h = p.location.player[1] - var i = ItemFactory.produce(item_names[p.item], pl.hand_base[G.hand_to_index(h)]) - i.position = pl.hand_base[G.hand_to_index(h)].global_position + var i = ItemFactory.produce(item_names[p.item], pl.hand_base[h]) + i.position = pl.hand_base[h].global_position add_child(i) i.name = item_names[p.item] pl.set_item(i, h) diff --git a/client/global.gd b/client/global.gd index ce24f85d..93c73e13 100644 --- a/client/global.gd +++ b/client/global.gd @@ -269,7 +269,8 @@ func configure_viewport_aa(vp: Viewport, aa: String) -> void: vp.msaa_3d = Viewport.MSAA_4X vp.screen_space_aa = Viewport.SCREEN_SPACE_AA_DISABLED -static func hand_to_index(h): - match h: - "left": return 0 - "right": return 1 +static func index_to_hand(i): + match i: + 0: return "left" + 1: return "right" + _: return "unknown" diff --git a/client/multiplayer.gd b/client/multiplayer.gd index 14eaf482..11a5bd84 100644 --- a/client/multiplayer.gd +++ b/client/multiplayer.gd @@ -66,6 +66,7 @@ func fix_packet_types(val): if typeof(val[k]) == TYPE_ARRAY and val[k].size() == 2 and typeof(val[k][0]) == TYPE_FLOAT and typeof(val[k][1]) == TYPE_FLOAT: if k in ["tile"]: newval[k] = Vector2i(val[k][0], val[k][1]) elif k in ["pos", "position"]: newval[k] = Vector2(val[k][0], val[k][1]) + else: newval[k] = val[k] # TODO reenable when fixed # elif k in ["player", "id"] and typeof(val[k]) == TYPE_FLOAT: # newval[k] = int(val[k]) @@ -106,7 +107,7 @@ func send_movement(player, pos: Vector2, direction: Vector2, boost: bool): "boost": boost }) -func send_tile_interact(player, pos: Vector2i, edge: bool, hand: String): +func send_tile_interact(player, pos: Vector2i, edge: bool, hand: int): @warning_ignore("incompatible_ternary") send_packet({ "type": "interact", diff --git a/client/player/controllable_player.gd b/client/player/controllable_player.gd index d241bc2e..99625762 100644 --- a/client/player/controllable_player.gd +++ b/client/player/controllable_player.gd @@ -190,13 +190,13 @@ func _on_vibration_timeout(): Input.vibrate_handheld(100, vibration_strength) vibration_timer.start() -func put_item(tile: Tile, h): +func put_item(tile: Tile, h: int): super(tile, h) if Global.get_setting("gameplay.vibration"): Input.start_joy_vibration(0, 0.1, 0.0, 0.075) Input.vibrate_handheld(75, 0.1) -func take_item(tile: Tile, h): +func take_item(tile: Tile, h: int): super(tile, h) if Global.get_setting("gameplay.vibration"): Input.start_joy_vibration(0, 0.1, 0.0, 0.075) @@ -210,18 +210,18 @@ func interact(): # clear last interaction if target has moved since if last_interaction != null and not last_interaction == target: - game.mp.send_tile_interact(game.player_id, last_interaction, false, "left") + game.mp.send_tile_interact(game.player_id, last_interaction, false, 0) marker.set_interacting(false) last_interaction = null marker.set_interactive(game.get_tile_interactive(target)) marker_target = tile.item_base.global_position - for h in ["left", "right"]: - if Input.is_action_just_pressed("interact_"+h) and last_interaction == null: + for h in [0, 1]: + if Input.is_action_just_pressed("interact_"+G.index_to_hand(h)) and last_interaction == null: last_interaction = target game.mp.send_tile_interact(game.player_id, target, true, h) tile.interact() marker.set_interacting(true) - if Input.is_action_just_released("interact_"+h): + if Input.is_action_just_released("interact_"+G.index_to_hand(h)): last_interaction = null game.mp.send_tile_interact(game.player_id, target, false, h) marker.set_interacting(false) diff --git a/client/player/player.gd b/client/player/player.gd index 223d2c88..39b9fb3e 100644 --- a/client/player/player.gd +++ b/client/player/player.gd @@ -50,6 +50,7 @@ var current_item_message = null var _anim_angle: float = 0.0 var hand_base_position = [DEFAULT_HAND_BASE_POSITION_LEFT, DEFAULT_HAND_BASE_POSITION_RIGHT] +const DEFAULT_HAND_BASE_POSITION_BOTH: 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) @@ -100,42 +101,42 @@ func update_username_tag(state): tag.text = username tag.visible = state -func set_item(i: Item, h): - if hand[G.hand_to_index(h)] != null: hand[G.hand_to_index(h)].remove() +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[0] = 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[G.hand_to_index(h)] = i - if hand[G.hand_to_index(h)] != null: hand[G.hand_to_index(h)].owned_by = hand_base[G.hand_to_index(h)] + hand[h] = i + if hand[h] != null: hand[h].owned_by = hand_base[h] -func remove_item(h): - var i = hand[G.hand_to_index(h)] +func remove_item(h: int): + var i = hand[h] if i == null: push_error("holding nothing") - hand[G.hand_to_index(h)] = null + hand[h] = null character.holding = false return i -func progress(position__: float, speed: float, warn: bool, h): - if hand[G.hand_to_index(h)] != null: hand[G.hand_to_index(h)].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(h): - if hand[G.hand_to_index(h)] != null: hand[G.hand_to_index(h)].finish() +func finish(h: int): + if hand[h] != null: hand[h].finish() -func take_item(tile: Tile, h): - if hand[G.hand_to_index(h)] != 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, h) -func put_item(tile: Tile, h): +func put_item(tile: Tile, h: int): var i = remove_item(h) i.put() tile.put_item(i) -func pass_to(player: Player, hfrom, hto): +func pass_to(player: Player, hfrom: int, hto: int): var i = remove_item(hfrom) i.player_owned_timer = 0 if player.hand != null: |