2025-06-28 17:14:54 -06:00
|
|
|
extends SurfaceSnapTool
|
2025-03-13 10:29:25 -06:00
|
|
|
# the wimpy toothbrush
|
|
|
|
|
|
|
|
const PAINT_COLOR := Color(1, 0, 0, 0.3)
|
|
|
|
const BRUSH_SCALE := 0.2
|
|
|
|
|
2025-03-13 11:25:11 -06:00
|
|
|
@export var damage := 0.0063 # ~8 seconds to destroy standard nodule
|
|
|
|
|
2025-03-13 10:29:25 -06:00
|
|
|
@onready var texture_idle: TextureRect = %TextureIdle
|
|
|
|
@onready var texture_used: TextureRect = %TextureUsed
|
|
|
|
@onready var brush_animation: AnimationPlayer = %BrushAnimation
|
|
|
|
|
|
|
|
|
2025-04-19 17:13:36 -06:00
|
|
|
func unlocked() -> bool:
|
2025-07-05 15:52:42 -06:00
|
|
|
return World.instance and World.instance.manager.toothbrush_unlocked
|
2025-04-19 17:13:36 -06:00
|
|
|
|
|
|
|
|
2025-03-13 10:29:25 -06:00
|
|
|
func _fire() -> void:
|
2025-04-21 16:48:08 -06:00
|
|
|
if raycast.is_colliding() and not World.instance.manager.is_tank_full():
|
2025-03-13 10:29:25 -06:00
|
|
|
brush_animation.play("brush")
|
|
|
|
var collider := raycast.get_collider()
|
2025-07-03 18:05:06 -06:00
|
|
|
var gunk_component := Gunkable.get_component(collider)
|
|
|
|
if gunk_component:
|
|
|
|
gunk_component.paint_dot(
|
2025-03-13 10:29:25 -06:00
|
|
|
raycast.get_collision_point(),
|
|
|
|
raycast.get_collision_normal(),
|
|
|
|
BRUSH_SCALE,
|
|
|
|
PAINT_COLOR
|
|
|
|
)
|
2025-07-03 18:05:06 -06:00
|
|
|
if collider is Sprayable:
|
|
|
|
(collider as Sprayable).hit(damage)
|
2025-03-13 10:29:25 -06:00
|
|
|
else:
|
|
|
|
brush_animation.stop()
|
|
|
|
|
|
|
|
texture_idle.visible = false
|
|
|
|
texture_used.visible = true
|
|
|
|
|
|
|
|
|
|
|
|
func _idle() -> void:
|
|
|
|
texture_idle.visible = true
|
|
|
|
texture_used.visible = false
|