grunk/src/equipment/tool.gd

47 lines
874 B
GDScript

class_name Tool extends Node3D
## Abstract base class for spraygun types
@export var hud_accel := 50.0
var firing := false
@onready var hud_tool: Node3D = %HUDTool
func _fire() -> void:
pass
func _idle() -> void:
pass
## Toggles between this tool's normal & alternate modes
func switch_mode() -> void:
# TODO: bonk if no mode switch is defined
pass
## Called each frame that this tool is being fired.
func fire() -> void:
firing = true
_fire()
## Called each frame that this tool is not being fired.
func idle() -> void:
firing = false
_idle()
## Is this tool available to the player?
func unlocked() -> bool:
return true
func _physics_process(delta: float) -> void:
if hud_tool:
var weight := 1 - exp(-hud_accel * delta)
hud_tool.global_basis = global_basis
hud_tool.global_position = hud_tool.global_position.lerp(global_position, weight)