[gd_scene load_steps=10 format=2]

[ext_resource path="res://assets/neutral object/coin_pixelized.png" type="Texture" id=1]
[ext_resource path="res://src/BenefitialObjects/Coin.gd" type="Script" id=2]
[ext_resource path="res://assets/sounds/MAGIC_SPELL_Attacking_Climbing_Bells_stereo.wav" type="AudioStream" id=316]
[ext_resource path="res://assets/environment/blocks/Empty-Navigation-Tile.png" type="Texture" id=317]

[sub_resource type="CircleShape2D" id=1]
radius = 44.7557

[sub_resource type="Animation" id=2]
resource_name = "fade_out"
length = 0.1
tracks/0/type = "value"
tracks/0/path = NodePath(".:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.1 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ) ]
}
tracks/1/type = "method"
tracks/1/path = NodePath(".")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = false
tracks/1/keys = {
"times": PoolRealArray( 0.1 ),
"transitions": PoolRealArray( 1 ),
"values": [ {
"args": [  ],
"method": "queue_free"
} ]
}

[sub_resource type="Animation" id=3]
resource_name = "oscilating"
length = 2.4
loop = true
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite2:position")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 1.2 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Vector2( 0, 2.62356 ), Vector2( 0, 1 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("Sprite:position")
tracks/1/interp = 2
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0, 1.2 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Vector2( 0.0564967, 2.37292 ), Vector2( 0.056, 1 ) ]
}

[sub_resource type="Shader" id=5]
code = "shader_type canvas_item;

uniform float ring_radius : hint_range(0.1, 0.5, 0.01) = 0.4;
uniform float thickness_scalar : hint_range(0.0, 0.99, 0.05) = 0.7;
uniform float oscillation_scalar : hint_range(0.0, 0.25, 0.005) = 0.025;
uniform float speed : hint_range(0.0, 50.0, 0.1) = 1.0;
uniform vec4 main_color : hint_color = vec4(1.0,1.0,1.0,1.0);
uniform vec4 lerp_color : hint_color = vec4(1.0,1.0,1.0,1.0);

float range_lerp(float value, float min1, float min2, float max1, float max2){
	return min2 + (max2 - min2) * ((value - min1) / (max1 - min1));
}

void fragment() {
	// Calculate the distance between the current pixel and the center of the unit
	float dist = distance(UV, vec2(0.5, 0.5));

	// Add a slight oscillation to the size of the ring
	float o = cos(TIME * speed);
	float ring_size = ring_radius + o * oscillation_scalar;
	
	float inner_hardness = 0.0;
	// Solve for ring alpha channel
	float alpha = step(dist, ring_size) * smoothstep(ring_size * (1.0 - thickness_scalar), ring_size, dist);
	
	// Solve w mix amount for optional color lerping
	float w = range_lerp(o, -1.0, 1.0, 1.0, 0.0);
	
	// Output the final color
	COLOR = vec4(mix(main_color.rgb, lerp_color.rgb, w), alpha );
}

"

[sub_resource type="ShaderMaterial" id=6]
shader = SubResource( 5 )
shader_param/ring_radius = 0.45
shader_param/thickness_scalar = 0.2
shader_param/oscillation_scalar = 0.01
shader_param/speed = 1.0
shader_param/main_color = Color( 1, 1, 1, 0.286275 )
shader_param/lerp_color = Color( 0.658824, 0.901961, 0.8, 1 )

[node name="Coin" type="Area2D"]
position = Vector2( -6, -6 )
scale = Vector2( 0.8, 0.8 )
collision_layer = 4
monitorable = false
script = ExtResource( 2 )

[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( 3.8147e-06, 2.49189 )
scale = Vector2( 0.18, 0.18 )
shape = SubResource( 1 )

[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
autoplay = "oscilating"
anims/fade_out = SubResource( 2 )
anims/oscilating = SubResource( 3 )

[node name="Sprite2" type="Sprite" parent="."]
position = Vector2( 0, 1.28561 )
scale = Vector2( -0.484, -0.5 )
texture = ExtResource( 1 )

[node name="Sprite" type="Sprite" parent="."]
material = SubResource( 6 )
position = Vector2( 0.0560874, 1.24152 )
texture = ExtResource( 317 )

[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 316 )
volume_db = -15.0
pitch_scale = 1.09
bus = "Effects"

[connection signal="body_entered" from="." to="." method="_on_body_entered"]
[connection signal="finished" from="AudioStreamPlayer" to="." method="collected"]
