aboutsummaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/game.gd33
-rw-r--r--client/global.gd6
-rw-r--r--client/menu/communicate/popup_message/popup_message.gd2
-rw-r--r--client/menu/settings/input/input_value_node.gd1
-rw-r--r--client/multiplayer.gd8
-rw-r--r--client/player/controllable_player.gd35
-rw-r--r--client/player/onscreen_controls/controls.gd4
-rw-r--r--client/player/player.gd74
-rw-r--r--client/project.godot8
9 files changed, 103 insertions, 68 deletions
diff --git a/client/game.gd b/client/game.gd
index e7d39aa2..6c152d8a 100644
--- a/client/game.gd
+++ b/client/game.gd
@@ -53,6 +53,7 @@ var tile_collide: Array = []
var tile_interact: Array = []
var maps: Array = []
var bot_algos: Array
+var hand_count = 0
var text_message_history: Array[TextMessage] = []
var join_state: JoinState = JoinState.SPECTATING
@@ -95,6 +96,7 @@ func handle_packet(p):
tile_interact = p["data"]["tile_interact"]
maps = p["data"]["maps"]
bot_algos = p["data"]["bot_algos"]
+ hand_count = p["data"]["hand_count"]
tile_index_by_name.clear()
for id in tile_names.size():
@@ -128,8 +130,9 @@ func handle_packet(p):
if p.id == player_id:
set_join_state(JoinState.SPECTATING)
camera.target = $Center
- if player.hand != null:
- player.hand.queue_free()
+ for h in player.hand:
+ if h != null:
+ h.queue_free()
players.erase(p.id)
player.queue_free()
update_players.emit(players)
@@ -143,13 +146,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].pass_to(players[p.to.player])
+ 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].take_item(t)
+ 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].put_item(t)
+ 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)
@@ -159,13 +162,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].progress(p.position, p.speed, p.warn)
+ 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].finish()
+ players[p.item.player[0]].finish(int(p.item.player[1]))
"set_item":
var location: Dictionary = p["location"]
if p.item != null:
@@ -177,21 +180,23 @@ func handle_packet(p):
i.name = item_names[p.item]
t.set_item(i)
else:
- var pl: Player = players[p.location.player]
- var i = ItemFactory.produce(item_names[p.item], pl.hand_base)
- i.position = pl.hand_base.global_position
+ 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[h])
+ i.position = pl.hand_base[h].global_position
add_child(i)
i.name = item_names[p.item]
- pl.set_item(i)
+ pl.set_item(i, h)
else:
if "tile" in p.location:
var t: Tile = map.get_tile_instance(p.location.tile)
t.finish()
t.set_item(null)
else:
- var player: Player = players[p.location.player]
- player.finish()
- player.set_item(null)
+ var pl: Player = players[p.location.player[0]]
+ var h = p.location.player[1]
+ pl.finish(h)
+ pl.set_item(null, h)
"update_map":
var neighbors: Array = p["neighbors"]
if p.kind != null:
diff --git a/client/global.gd b/client/global.gd
index 374f0e44..93c73e13 100644
--- a/client/global.gd
+++ b/client/global.gd
@@ -268,3 +268,9 @@ func configure_viewport_aa(vp: Viewport, aa: String) -> void:
"ms4x":
vp.msaa_3d = Viewport.MSAA_4X
vp.screen_space_aa = Viewport.SCREEN_SPACE_AA_DISABLED
+
+static func index_to_hand(i):
+ match i:
+ 0: return "left"
+ 1: return "right"
+ _: return "unknown"
diff --git a/client/menu/communicate/popup_message/popup_message.gd b/client/menu/communicate/popup_message/popup_message.gd
index 98bd94e3..56c8961a 100644
--- a/client/menu/communicate/popup_message/popup_message.gd
+++ b/client/menu/communicate/popup_message/popup_message.gd
@@ -141,7 +141,7 @@ func _input(_event):
Global.set_hint("has_rotated", true)
if any_action_just_pressed(["zoom_in", "zoom_out"]):
Global.set_hint("has_zoomed", true)
- if Input.is_action_just_pressed("interact"):
+ if Input.is_action_just_pressed("interact_left") or Input.is_action_just_pressed("interact_right"):
Global.set_hint("has_interacted", true)
if Input.is_action_just_pressed("reset"):
Global.set_hint("has_reset", true)
diff --git a/client/menu/settings/input/input_value_node.gd b/client/menu/settings/input/input_value_node.gd
index 44a65ec5..9cf8327a 100644
--- a/client/menu/settings/input/input_value_node.gd
+++ b/client/menu/settings/input/input_value_node.gd
@@ -72,5 +72,4 @@ func events_equal(e1: InputEvent, e2: InputEvent) -> bool:
func _on_add_pressed() -> void:
listening = not listening
-
add_button.text = tr("c.settings.input.press_any_key") if listening else add_text
diff --git a/client/multiplayer.gd b/client/multiplayer.gd
index 57031221..5a9406ab 100644
--- a/client/multiplayer.gd
+++ b/client/multiplayer.gd
@@ -21,8 +21,8 @@ extends Node
signal packet(packet: Dictionary)
signal connection_closed()
-static var VERSION_MAJOR: int = 7
-static var VERSION_MINOR: int = 5
+static var VERSION_MAJOR: int = 8
+static var VERSION_MINOR: int = 0
var connected := false
var socket := WebSocketPeer.new()
@@ -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,11 +107,12 @@ func send_movement(player, pos: Vector2, direction: Vector2, boost: bool):
"boost": boost
})
-func send_tile_interact(player, pos: Vector2i, edge: bool):
+func send_tile_interact(player, pos: Vector2i, edge: bool, hand: int):
@warning_ignore("incompatible_ternary")
send_packet({
"type": "interact",
"player": player,
+ "hand": hand,
"pos": [pos.x, pos.y] if edge else null,
})
diff --git a/client/player/controllable_player.gd b/client/player/controllable_player.gd
index 9db36ad4..99625762 100644
--- a/client/player/controllable_player.gd
+++ b/client/player/controllable_player.gd
@@ -83,7 +83,7 @@ func _process_movement(delta):
var boost = Input.is_action_pressed("boost") or (Global.get_setting("gameplay.latch_boost") and boosting)
- if Input.is_action_pressed("interact") or Input.is_action_just_released("interact"):
+ if Input.is_action_pressed("interact_left") or Input.is_action_just_released("interact_left") or Input.is_action_pressed("interact_right") or Input.is_action_just_released("interact_right"):
input *= 0
else:
target = Vector2i(
@@ -167,8 +167,8 @@ func aabb_point_distance(mi: Vector2, ma: Vector2, p: Vector2) -> float:
func update_position(_new_position: Vector2, _new_rotation: float, _new_boosting: bool):
pass
-func progress(position__: float, speed: float, warn: bool):
- super(position__, speed, warn)
+func progress(position__: float, speed: float, warn: bool, h):
+ super(position__, speed, warn, h)
if warn:
current_vibration_strength = position__
current_vibration_change = speed
@@ -190,14 +190,14 @@ func _on_vibration_timeout():
Input.vibrate_handheld(100, vibration_strength)
vibration_timer.start()
-func put_item(tile: Tile):
- super(tile)
+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):
- super(tile)
+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)
Input.vibrate_handheld(75, 0.1)
@@ -210,19 +210,20 @@ 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)
+ 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
- if Input.is_action_just_pressed("interact") and last_interaction == null:
- last_interaction = target
- game.mp.send_tile_interact(game.player_id, target, true)
- tile.interact()
- marker.set_interacting(true)
- if Input.is_action_just_released("interact"):
- last_interaction = null
- game.mp.send_tile_interact(game.player_id, target, false)
- marker.set_interacting(false)
+ 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_"+G.index_to_hand(h)):
+ last_interaction = null
+ game.mp.send_tile_interact(game.player_id, target, false, h)
+ marker.set_interacting(false)
else:
marker.visible = false
diff --git a/client/player/onscreen_controls/controls.gd b/client/player/onscreen_controls/controls.gd
index 0d240ddb..06efb82e 100644
--- a/client/player/onscreen_controls/controls.gd
+++ b/client/player/onscreen_controls/controls.gd
@@ -42,11 +42,11 @@ func _on_boost_released():
boost.modulate = Color.WHITE
func _on_interact_pressed():
- Input.action_press("interact")
+ Input.action_press("interact_left")
interact.modulate = modulate_color
func _on_interact_released():
- Input.action_release("interact")
+ Input.action_release("interact_left")
interact.modulate = Color.WHITE
func _on_pause_pressed():
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)
diff --git a/client/project.godot b/client/project.godot
index a0b11050..2239120b 100644
--- a/client/project.godot
+++ b/client/project.godot
@@ -108,13 +108,19 @@ rotate_down={
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":1.0,"script":null)
]
}
-interact={
+interact_left={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":true,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":74,"key_label":0,"unicode":106,"location":0,"echo":false,"script":null)
]
}
+interact_right={
+"deadzone": 0.5,
+"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":true,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
+, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":76,"key_label":0,"unicode":108,"location":0,"echo":false,"script":null)
+]
+}
boost={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194325,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)