grunk/src/equipment/toothbrush/toothbrush.gd

37 lines
852 B
GDScript3
Raw Normal View History

2025-03-13 10:29:25 -06:00
extends Tool
# the wimpy toothbrush
const PAINT_COLOR := Color(1, 0, 0, 0.3)
const BRUSH_SCALE := 0.2
@onready var raycast: RayCast3D = %Raycast
@onready var texture_idle: TextureRect = %TextureIdle
@onready var texture_used: TextureRect = %TextureUsed
@onready var brush_animation: AnimationPlayer = %BrushAnimation
func _fire() -> void:
if raycast.is_colliding():
brush_animation.play("brush")
var collider := raycast.get_collider()
if collider is GunkBody:
(collider as GunkBody).paint_dot(
raycast.get_collision_point(),
raycast.get_collision_normal(),
BRUSH_SCALE,
PAINT_COLOR
)
if collider is GunkNode:
(collider as GunkNode).hit()
else:
brush_animation.stop()
texture_idle.visible = false
texture_used.visible = true
func _idle() -> void:
texture_idle.visible = true
texture_used.visible = false