Move interactable input handling into Player2D so we can selectively block it from working if OldComputer is open
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
We probably could have special-cased that check in Interactable now that I think about it
This commit is contained in:
1 parent
f061e1905f
commit
93baf56fd5
4 files changed
+17
-9
No files matched your search
+10
-6
@@ -7,7 +7,7 @@ var checked_teleport
|
||||
var telecam_speed_mult = 4
|
||||
var enabled = true
|
||||
var cooldown = 2
|
||||
var is_interactable = false
|
||||
var _is_interactable = false
|
||||
|
||||
func disable():
|
||||
enabled = false
|
||||
@@ -17,10 +17,12 @@ func enable():
|
||||
enabled = true
|
||||
$Sprite2D.modulate = Color.WHITE
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if not (is_interactable and Input.is_action_just_released("interact")):
|
||||
return
|
||||
func is_interactable() -> bool:
|
||||
return _is_interactable
|
||||
|
||||
func interact() -> void:
|
||||
if not is_interactable():
|
||||
return
|
||||
interacted.emit()
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
@@ -29,11 +31,13 @@ func _physics_process(delta: float) -> void:
|
||||
func _on_approach(body) -> void:
|
||||
if body!=%Player2D:
|
||||
return
|
||||
is_interactable = true
|
||||
_is_interactable = true
|
||||
self.add_to_group("nearby_interactables")
|
||||
$Sprite2D/ButtonPrompt.show()
|
||||
|
||||
func _on_abandon(body) -> void:
|
||||
if body!=%Player2D:
|
||||
return
|
||||
is_interactable = false
|
||||
_is_interactable = false
|
||||
self.remove_from_group("nearby_interactables")
|
||||
$Sprite2D/ButtonPrompt.hide()
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
extends Interactable
|
||||
|
||||
func _on_interacted() -> void:
|
||||
#%OldComputer.open()
|
||||
%OldComputer.open()
|
||||
|
||||
#Accomodate some collision antics.
|
||||
var new_spawn_point = global_position + Vector2(0,-10)
|
||||
|
||||
@@ -123,6 +123,10 @@ func _process(delta: float) -> void:
|
||||
%OldComputer.close()
|
||||
return
|
||||
|
||||
if Input.is_action_just_released("interact"):
|
||||
for interactable in get_tree().get_nodes_in_group("nearby_interactables"):
|
||||
interactable.interact()
|
||||
|
||||
if Input.is_action_just_pressed("jump"):
|
||||
%OldComputer.close()
|
||||
|
||||
|
||||
+2
-2
@@ -11,10 +11,10 @@
|
||||
[ext_resource type="Texture2D" uid="uid://dyxbitw8hbd3s" path="res://art/player/crouch/frame2.png" id="7_lu0ka"]
|
||||
[ext_resource type="Texture2D" uid="uid://bfyd1tro3s0gl" path="res://art/player/crystal2.png" id="7_oy4pt"]
|
||||
[ext_resource type="Texture2D" uid="uid://dh7a1knyqn5nd" path="res://art/player/running/frame3.png" id="7_pmt5n"]
|
||||
[ext_resource type="Texture2D" uid="uid://lk0f1qyswyxv" path="res://art/player/running/frame1.png" id="8_3prq1"]
|
||||
[ext_resource type="Texture2D" uid="uid://lk0f1qyswyxv" path="res://art/player/idle/frame1.png" id="8_3prq1"]
|
||||
[ext_resource type="Texture2D" uid="uid://yf13nw31k8ua" path="res://art/player/running/frame4.png" id="8_nj6as"]
|
||||
[ext_resource type="Texture2D" uid="uid://du5i0tg6u1lal" path="res://art/player/crystal3.png" id="8_ukfft"]
|
||||
[ext_resource type="Texture2D" uid="uid://lmje8plw76e1" path="res://art/player/running/frame2.png" id="9_lu0ka"]
|
||||
[ext_resource type="Texture2D" uid="uid://lmje8plw76e1" path="res://art/player/idle/frame2.png" id="9_lu0ka"]
|
||||
[ext_resource type="Texture2D" uid="uid://bko8dvawpul3c" path="res://art/player/crystal4.png" id="9_ur4nw"]
|
||||
[ext_resource type="Texture2D" uid="uid://m5djssna67e1" path="res://art/player/crouch/frame3.png" id="9_w0gjo"]
|
||||
[ext_resource type="Texture2D" uid="uid://ba4kjeulthw1g" path="res://art/hats/dunce1.png" id="10_5s8kx"]
|
||||
|
||||
Reference in new issue
Block a user