generated from krampus/template-godot4
Tools are deactivated and tool HUD hidden when holding object
This commit is contained in:
parent
6b3ac1311e
commit
73afb696a2
@ -1,6 +1,9 @@
|
||||
class_name HoldComponent extends Node3D
|
||||
## Component for managing physics object holding
|
||||
|
||||
signal held
|
||||
signal dropped
|
||||
|
||||
## Held object position lerp acceleration.
|
||||
@export var hold_accel := 20.0
|
||||
|
||||
@ -43,7 +46,7 @@ func attach(prop: RigidBody3D, hold_distance: float) -> void:
|
||||
_original_collision_mask = prop.collision_mask
|
||||
prop.collision_mask = hold_collision_physics
|
||||
|
||||
Player.instance.hud.hold_hud.prop_held()
|
||||
held.emit()
|
||||
|
||||
|
||||
func drop() -> void:
|
||||
@ -52,7 +55,7 @@ func drop() -> void:
|
||||
_held_object.collision_mask = _original_collision_mask
|
||||
_held_object = null
|
||||
|
||||
Player.instance.hud.hold_hud.reset()
|
||||
dropped.emit()
|
||||
|
||||
|
||||
func holding_object() -> bool:
|
||||
|
@ -204,16 +204,18 @@ func _physics_process(delta: float) -> void:
|
||||
elif Input.is_action_just_pressed("select_stickers"):
|
||||
tool_mount.set_active(sticker_pack)
|
||||
|
||||
var tool := get_tool()
|
||||
firing = false
|
||||
if tool:
|
||||
# Tool use
|
||||
if Input.is_action_pressed("fire"):
|
||||
get_tool().fire()
|
||||
tool.fire()
|
||||
firing = true
|
||||
else:
|
||||
get_tool().idle()
|
||||
firing = false
|
||||
tool.idle()
|
||||
|
||||
if Input.is_action_just_pressed("switch_mode"):
|
||||
get_tool().switch_mode()
|
||||
tool.switch_mode()
|
||||
|
||||
# Two sneaking modes -- hold and toggle
|
||||
if Game.settings.hold_to_sneak:
|
||||
|
@ -8,11 +8,27 @@ var _active: Tool
|
||||
|
||||
func _ready() -> void:
|
||||
set_active(initial_tool)
|
||||
_deferred_init.call_deferred()
|
||||
|
||||
|
||||
func _deferred_init() -> void:
|
||||
Player.instance.hold_component.dropped.connect(show_tool)
|
||||
Player.instance.hold_component.held.connect(hide_tool)
|
||||
|
||||
|
||||
func hide_tool() -> void:
|
||||
# TODO maybe animate?
|
||||
visible = false
|
||||
|
||||
|
||||
func show_tool() -> void:
|
||||
# TODO maybe animate?
|
||||
visible = true
|
||||
|
||||
|
||||
## Returns the currently-active tool.
|
||||
func get_active() -> Tool:
|
||||
return _active
|
||||
return _active if visible else null
|
||||
|
||||
|
||||
## Sets the given tool as active.
|
||||
|
@ -13,6 +13,15 @@ var _selected_this_frame := false
|
||||
@onready var closed_hand: Label = %ClosedHand
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_deferred_init.call_deferred()
|
||||
|
||||
|
||||
func _deferred_init() -> void:
|
||||
Player.instance.hold_component.dropped.connect(reset)
|
||||
Player.instance.hold_component.held.connect(prop_held)
|
||||
|
||||
|
||||
func prop_selected() -> void:
|
||||
state = State.SELECTED
|
||||
open_hand.visible = true
|
||||
|
@ -427,10 +427,10 @@ anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -23.5555
|
||||
offset_top = -20.5418
|
||||
offset_right = -23.5555
|
||||
offset_bottom = -20.5418
|
||||
offset_left = -19.5065
|
||||
offset_top = -22.2032
|
||||
offset_right = -19.5065
|
||||
offset_bottom = -22.2032
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("4_ud8na")
|
||||
|
@ -167,8 +167,8 @@
|
||||
- [ ] wraparound desk
|
||||
- [ ] etc
|
||||
- [ ] Make sofa cushions separate physics objects
|
||||
- [ ] Object hold UX
|
||||
- [x] Object hold UX
|
||||
- [x] holdable object HUD icon
|
||||
- [ ] highlight holdable objects?
|
||||
- [ ] hide tool UI when holding
|
||||
- [x] hide tool UI when holding
|
||||
- [ ] Keep bonus tracks, taco fiesta, maybe stickers in upgrade track. Everything else comes from the [[company store]], as well as upgrades.
|
Loading…
x
Reference in New Issue
Block a user