2025-03-12 11:03:41 -06:00
|
|
|
class_name Tool extends Node3D
|
|
|
|
## Abstract base class for spraygun types
|
|
|
|
|
2025-04-09 18:15:04 -06:00
|
|
|
const HUD_ACCEL := 36.0
|
|
|
|
|
2025-03-12 11:03:41 -06:00
|
|
|
var firing := false
|
|
|
|
|
2025-03-12 19:29:31 -06:00
|
|
|
@onready var hud_tool: Node3D = %HUDTool
|
|
|
|
|
2025-03-12 11:03:41 -06:00
|
|
|
|
|
|
|
func _fire() -> void:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
func _idle() -> void:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2025-03-12 11:23:21 -06:00
|
|
|
## Toggles between this tool's normal & alternate modes
|
|
|
|
func switch_mode() -> void:
|
|
|
|
# TODO: bonk if no mode switch is defined
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2025-03-12 11:03:41 -06:00
|
|
|
## 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)
|