summaryrefslogtreecommitdiff
path: root/client/player
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-12-25 19:37:20 +0100
committermetamuffin <metamuffin@disroot.org>2024-12-25 20:01:43 +0100
commit4083df5cfe76e42506c5356cf23d3dc9f3b6e6bf (patch)
tree5ec12de003c38f0891c215721593c7ea49ff2c16 /client/player
parent15be00667282a253fb438fec9d6347f5af89d9a0 (diff)
downloadhurrycurry-4083df5cfe76e42506c5356cf23d3dc9f3b6e6bf.tar
hurrycurry-4083df5cfe76e42506c5356cf23d3dc9f3b6e6bf.tar.bz2
hurrycurry-4083df5cfe76e42506c5356cf23d3dc9f3b6e6bf.tar.zst
variable hand count
Diffstat (limited to 'client/player')
-rw-r--r--client/player/controllable_player.gd12
-rw-r--r--client/player/player.gd31
2 files changed, 22 insertions, 21 deletions
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: