tool
extends RichTextEffect

var bbcode = 'm'

func _process_custom_fx(char_fx: CharFXTransform) -> bool:
	var progress1 = (char_fx.elapsed_time * 5) - (char_fx.absolute_index*1)
	var screencenter = Vector2(320,180)
	var offset = Vector2(-190,0)
	var offset_buffer = Vector2(0,0)
	var color_buffer = Color(1,1,1,1)
	if progress1 < 5:
		offset_buffer.x =  progress1*64
		offset_buffer.y = progress1*36
		color_buffer = Color(0,0.4,0.5,1)
	else:
		offset_buffer =  screencenter
		var bri = clamp(10-(char_fx.elapsed_time*6 - float(char_fx.absolute_index) ),0,1)
		color_buffer = Color(1,0.5,0,1) + Color(bri,bri,bri,bri)
	if char_fx.elapsed_time > 5:
		var rotation = (float(char_fx.absolute_index) / 17 * PI * 2)-(PI/2)
		var time = (char_fx.elapsed_time-5)
		offset_buffer = ( Vector2(cos(rotation), sin(rotation)) * time * time  * 300 ) + screencenter
	char_fx.offset = offset_buffer + offset
	char_fx.color = color_buffer
#	char_fx.color.a = 0.1 + float(char_fx.absolute_index+1)/100
	return true
