2023-10-02 13:45:13 +00:00
|
|
|
extends Node
|
|
|
|
class_name Colored
|
|
|
|
|
|
|
|
@export var shader: Shader
|
|
|
|
|
2023-10-03 00:33:09 +00:00
|
|
|
@onready var parent: Sprite2D = get_parent()
|
|
|
|
|
|
|
|
var hue: float:
|
2023-10-02 21:24:01 +00:00
|
|
|
get:
|
|
|
|
return hue
|
|
|
|
set(value):
|
|
|
|
hue = value
|
|
|
|
if parent.material:
|
|
|
|
parent.material.set_shader_parameter("hue", value)
|
|
|
|
|
2023-10-02 13:45:13 +00:00
|
|
|
|
|
|
|
func _ready():
|
|
|
|
var material = ShaderMaterial.new()
|
|
|
|
material.shader = shader
|
|
|
|
parent.material = material
|
2023-10-14 00:27:55 +00:00
|
|
|
randomize_hue()
|
2023-10-02 21:24:01 +00:00
|
|
|
|
2023-10-03 00:33:09 +00:00
|
|
|
|
|
|
|
func randomize_hue():
|
|
|
|
hue = Randomizer.rng.randf()
|