Skip to content

Commit

Permalink
fix collectable logic
Browse files Browse the repository at this point in the history
  • Loading branch information
krazyjakee committed Oct 5, 2024
1 parent ef69c0a commit fbf3d98
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
6 changes: 0 additions & 6 deletions addons/nodot/autoload/CollectableManager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ class Collectable:
var node: Node

func _init(collectable_node: Node):
if collectable_node.actual_collectable_root_node:
node = collectable_node.actual_collectable_root_node
else:
node = collectable_node
node.position = Vector3.ZERO

icon = collectable_node.icon
display_name = collectable_node.display_name
description = collectable_node.description
Expand Down
11 changes: 6 additions & 5 deletions addons/nodot/kits/FirstPerson/FirstPersonItemsContainer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ func _ready() -> void:
)

GlobalSignal.add_listener("carry_ended", self, "on_carry_ended")

func _physics_process(delta: float) -> void:

func _input(event: InputEvent) -> void:
if not character.is_authority(): return

if get_input():
reload()

func _physics_process(delta: float) -> void:
action()

func get_input():
Expand Down Expand Up @@ -150,9 +154,6 @@ func action():
zoom()
"zoomout":
zoomout()

if character.input_states["reload"]:
reload()

func discharge() -> void:
if !enabled: return
Expand Down
16 changes: 16 additions & 0 deletions addons/nodot/kits/FirstPerson/FirstPersonMouseInput.gd
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ func action(delta: float):
if not is_multiplayer_authority(): return
if !enabled or is_editor or !character.input_enabled: return

if Input.is_action_pressed(action_action):
input_buffer.append({"type": "mouse_action", "action": "action"})

var input: Dictionary = get_input(delta)

character.input_states["mouse_action"] = input.mouse_action
Expand All @@ -92,6 +95,19 @@ func get_input(delta: float) -> Dictionary:
var look_angle: Vector2 = Vector2.ZERO
var mouse_action: String = ""

if Input.is_action_pressed(item_next_action):
input_buffer.append({"type": "mouse_action", "action": "next_item"})
elif Input.is_action_pressed(item_previous_action):
input_buffer.append({"type": "mouse_action", "action": "previous_item"})
elif Input.is_action_pressed(action_action):
input_buffer.append({"type": "mouse_action", "action": "action"})
elif Input.is_action_just_released(action_action):
input_buffer.append({"type": "mouse_action", "action": "release_action"})
elif Input.is_action_pressed(zoom_action):
input_buffer.append({"type": "mouse_action", "action": "zoom"})
elif Input.is_action_just_released(zoom_action):
input_buffer.append({"type": "mouse_action", "action": "zoomout"})

for entry in input_buffer:
if entry["type"] == "mouse_motion":
var mouse_movement: Vector2 = entry["event"]
Expand Down

0 comments on commit fbf3d98

Please sign in to comment.