54 lines
1.7 KiB
GDScript3
54 lines
1.7 KiB
GDScript3
|
|
class_name Cue extends CueMultiplayer
|
||
|
|
|
||
|
|
|
||
|
|
func _ready() -> void:
|
||
|
|
cue_shape = pool_cue_tip.get_node("shape")
|
||
|
|
|
||
|
|
await get_tree().process_frame
|
||
|
|
|
||
|
|
setup_multiplayer()
|
||
|
|
reset_state()
|
||
|
|
|
||
|
|
func _input(event: InputEvent) -> void:
|
||
|
|
if not Globals.multiplayer_data.can_do_request(): return
|
||
|
|
|
||
|
|
if not Globals.multiplayer_data.is_multiplayer_active:
|
||
|
|
if event.is_action_pressed("aim_pulse"):
|
||
|
|
rpc_input("aim_pulse")
|
||
|
|
elif event.is_action_released("aim_release"):
|
||
|
|
rpc_input("aim_release")
|
||
|
|
else:
|
||
|
|
if event.is_action_pressed("aim_pulse"):
|
||
|
|
self.rpc_id(1, "rpc_input", "aim_pulse")
|
||
|
|
elif event.is_action_released("aim_release"):
|
||
|
|
self.rpc_id(1, "rpc_input", "aim_release")
|
||
|
|
|
||
|
|
|
||
|
|
func _process(delta: float) -> void:
|
||
|
|
# NOTE: Need on outter of check so that it updates per client
|
||
|
|
Globals.game_state.update_cue_cam_position.emit(
|
||
|
|
cue_cam_marker.global_rotation,
|
||
|
|
cue_cam_marker.global_position
|
||
|
|
)
|
||
|
|
|
||
|
|
if not Globals.multiplayer_data.can_do_request(): return
|
||
|
|
|
||
|
|
if not Globals.multiplayer_data.is_multiplayer_active:
|
||
|
|
if Input.is_action_pressed("aim_rotate_left"):
|
||
|
|
rpc_process("aim_rotate_left", delta)
|
||
|
|
elif Input.is_action_pressed("aim_rotate_right"):
|
||
|
|
rpc_process("aim_rotate_right", delta)
|
||
|
|
elif Input.is_action_pressed("aim_incline"):
|
||
|
|
rpc_process("aim_incline", delta)
|
||
|
|
elif Input.is_action_pressed("aim_decline"):
|
||
|
|
rpc_process("aim_decline", delta)
|
||
|
|
else:
|
||
|
|
if Input.is_action_pressed("aim_rotate_left"):
|
||
|
|
self.rpc_id(1, "rpc_process", "aim_rotate_left", delta)
|
||
|
|
elif Input.is_action_pressed("aim_rotate_right"):
|
||
|
|
self.rpc_id(1, "rpc_process", "aim_rotate_right", delta)
|
||
|
|
elif Input.is_action_pressed("aim_incline"):
|
||
|
|
self.rpc_id(1, "rpc_process", "aim_incline", delta)
|
||
|
|
elif Input.is_action_pressed("aim_decline"):
|
||
|
|
self.rpc_id(1, "rpc_process", "aim_decline", delta)
|