grunk/src/equipment/tool.gd

42 lines
795 B
GDScript3
Raw Normal View History

class_name Tool extends Node3D
## Abstract base class for spraygun types
2025-04-09 18:15:04 -06:00
const HUD_ACCEL := 36.0
var firing := false
2025-03-12 19:29:31 -06:00
@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()
2025-03-12 19:29:31 -06:00
2025-04-09 18:45:52 -06:00
func _physics_process(delta: float) -> void:
2025-03-12 19:29:31 -06:00
if hud_tool:
2025-04-09 18:45:52 -06:00
var weight := clampf(HUD_ACCEL * delta, 0.0, 1.0)
2025-04-09 18:15:04 -06:00
hud_tool.global_basis = global_basis
2025-04-09 18:45:52 -06:00
hud_tool.global_position = hud_tool.global_position.lerp(global_position, weight)