[gd_scene load_steps=22 format=3 uid="uid://1rxw4k4wq3ni"]

[ext_resource type="Texture2D" uid="uid://dbq6cn2hp6ijx" path="res://Assets/Sprites/Enemies/PiranhaPlant.png" id="1_2imih"]
[ext_resource type="Script" uid="uid://d23hoj2qc2whq" path="res://Scripts/Classes/Entities/Enemies/PiranhaPlant.gd" id="1_jbk0f"]
[ext_resource type="Script" uid="uid://cbal8ms2oe1ik" path="res://Scripts/Classes/Components/ResourceSetterNew.gd" id="3_471w1"]
[ext_resource type="JSON" path="res://Assets/Sprites/Enemies/PiranhaPlant.json" id="4_xp8sq"]
[ext_resource type="Script" uid="uid://chj8hu207lrh" path="res://Scripts/Classes/Components/EnemyPlayerDetection.gd" id="6_471w1"]
[ext_resource type="Script" uid="uid://dri2d5jtu0fbq" path="res://Scripts/Classes/Components/FireballDetection.gd" id="7_471w1"]
[ext_resource type="Script" uid="uid://5octqlf4ohel" path="res://Scripts/Classes/Components/ScoreNoteSpawner.gd" id="8_xp8sq"]
[ext_resource type="Script" uid="uid://cpwloakvp672a" path="res://Scripts/Parts/EditorVisibleNode.gd" id="9_tmwyr"]
[ext_resource type="Script" uid="uid://bbww34oiexbx2" path="res://Scripts/Classes/Components/ShellDetection.gd" id="10_uohcg"]
[ext_resource type="Script" uid="uid://d0mqkvopasu8k" path="res://Scripts/Classes/Components/SecondQuestReplaceComponent.gd" id="10_xreuf"]
[ext_resource type="Script" uid="uid://ba18grqjixded" path="res://Scripts/Classes/Components/ExplosionDetection.gd" id="11_8y1e5"]
[ext_resource type="Script" uid="uid://ctfbuoxtnnl0q" path="res://Scripts/Classes/Components/EditorPropertyExposer.gd" id="12_ofvpu"]

[sub_resource type="AtlasTexture" id="AtlasTexture_xp8sq"]
atlas = ExtResource("1_2imih")
region = Rect2(0, 24, 16, 24)

[sub_resource type="AtlasTexture" id="AtlasTexture_uohcg"]
atlas = ExtResource("1_2imih")
region = Rect2(16, 24, 16, 24)

[sub_resource type="SpriteFrames" id="SpriteFrames_q2sci"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_xp8sq")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_uohcg")
}],
"loop": true,
"name": &"default",
"speed": 5.0
}]

[sub_resource type="RectangleShape2D" id="RectangleShape2D_k3xt6"]
size = Vector2(6, 13)

[sub_resource type="Animation" id="Animation_471w1"]
resource_name = "Hide"
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(0, 12)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Sprite:visible")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("Sprite/Hitbox:monitoring")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}

[sub_resource type="Animation" id="Animation_6l0c7"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(0, -12)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Sprite:visible")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("Sprite/Hitbox:monitoring")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}

[sub_resource type="Animation" id="Animation_t8k64"]
resource_name = "Rise"
length = 4.5
step = 0.1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.5, 2, 2.5),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 0,
"values": [Vector2(0, 12), Vector2(0, -12), Vector2(0, -12), Vector2(0, 12)]
}
tracks/1/type = "method"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Timer")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 4.5),
"transitions": PackedFloat32Array(1, 1),
"values": [{
"args": [],
"method": &"stop"
}, {
"args": [-1],
"method": &"start"
}]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("Sprite:visible")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0, 4.5),
"transitions": PackedFloat32Array(1, 1),
"update": 1,
"values": [true, false]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("Sprite/Hitbox:monitoring")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0, 2.5),
"transitions": PackedFloat32Array(1, 1),
"update": 1,
"values": [true, false]
}

[sub_resource type="AnimationLibrary" id="AnimationLibrary_471w1"]
_data = {
&"Hide": SubResource("Animation_471w1"),
&"RESET": SubResource("Animation_6l0c7"),
&"Rise": SubResource("Animation_t8k64")
}

[sub_resource type="GDScript" id="GDScript_ofvpu"]
script/source = "extends Node

var starting_position = Vector2(-1, -1)

func _ready() -> void:
	if starting_position == Vector2(-1, -1):
		starting_position = owner.global_position

func _process(_delta: float) -> void:
	const OFFSETS = [Vector2.ZERO, Vector2(0, -16), Vector2(-16, 0), Vector2.ZERO]
	if Global.level_editor != null:
		owner.global_rotation_degrees = [0, 180, 90, -90][owner.plant_direction]
		# guzlad: only do the offset calculations if the directions actually need them, stops wasting time for other directions
		if (owner.plant_direction == 1 or owner.plant_direction == 2):	
			var offset = OFFSETS[owner.plant_direction]
			owner.global_position = Vector2((owner.get_meta(\"tile_position\") + Vector2i(1, 1)) * 16) + offset
"

[node name="PirannhaPlant" type="CharacterBody2D" node_paths=PackedStringArray("on_screen_enabler", "score_note_adder") groups=["Enemies"]]
z_index = -5
script = ExtResource("1_jbk0f")
on_screen_enabler = NodePath("VisibleOnScreenEnabler2D")
score_note_adder = NodePath("ScoreNoteSpawner")
metadata/_custom_type_script = "uid://bpydbpyjk1mt4"

[node name="Sprite" type="AnimatedSprite2D" parent="."]
visible = false
position = Vector2(0, -12)
sprite_frames = SubResource("SpriteFrames_q2sci")
autoplay = "default"
frame_progress = 0.985799
offset = Vector2(0, 1)

[node name="Hitbox" type="Area2D" parent="Sprite"]
position = Vector2(0, 12)
monitoring = false

[node name="CollisionShape2D" type="CollisionShape2D" parent="Sprite/Hitbox"]
position = Vector2(0, -6)
shape = SubResource("RectangleShape2D_k3xt6")

[node name="UpsideDownExtension" type="CollisionShape2D" parent="Sprite/Hitbox"]
position = Vector2(0, -14)
shape = SubResource("RectangleShape2D_k3xt6")
debug_color = Color(0, 0.6, 0, 0.419608)

[node name="ResourceSetterNew" type="Node" parent="Sprite" node_paths=PackedStringArray("node_to_affect")]
script = ExtResource("3_471w1")
node_to_affect = NodePath("..")
property_name = "sprite_frames"
resource_json = ExtResource("4_xp8sq")
metadata/_custom_type_script = "uid://cbal8ms2oe1ik"

[node name="Animation" type="AnimationPlayer" parent="."]
libraries = {
&"": SubResource("AnimationLibrary_471w1")
}
autoplay = "Hide"

[node name="Timer" type="Timer" parent="."]
wait_time = 0.5
autostart = true

[node name="VisibleOnScreenEnabler2D" type="VisibleOnScreenEnabler2D" parent="."]
self_modulate = Color(1, 1, 1, 0)
position = Vector2(0, -5)
scale = Vector2(1, 2.9)

[node name="EnemyPlayerDetection" type="Node" parent="." node_paths=PackedStringArray("hitbox")]
script = ExtResource("6_471w1")
hitbox = NodePath("../Sprite/Hitbox")
metadata/_custom_type_script = "uid://chj8hu207lrh"

[node name="FireballDetection" type="Node" parent="." node_paths=PackedStringArray("hitbox")]
script = ExtResource("7_471w1")
hitbox = NodePath("../Sprite/Hitbox")
metadata/_custom_type_script = "uid://dri2d5jtu0fbq"

[node name="ScoreNoteSpawner" type="Node" parent="."]
script = ExtResource("8_xp8sq")
add_score = true
play_sfx = true
metadata/_custom_type_script = "uid://5octqlf4ohel"

[node name="ShellDetection" type="Node" parent="." node_paths=PackedStringArray("hitbox")]
script = ExtResource("10_uohcg")
hitbox = NodePath("../Sprite/Hitbox")
metadata/_custom_type_script = "uid://bbww34oiexbx2"

[node name="LevelEditorVisibleNode" type="Node2D" parent="."]
script = ExtResource("9_tmwyr")
metadata/_custom_type_script = "uid://cpwloakvp672a"

[node name="Sprite" type="AnimatedSprite2D" parent="LevelEditorVisibleNode"]
position = Vector2(0, -12)
sprite_frames = SubResource("SpriteFrames_q2sci")
autoplay = "default"
frame_progress = 0.985799
offset = Vector2(0, 1)

[node name="ResourceSetterNew" type="Node" parent="LevelEditorVisibleNode/Sprite" node_paths=PackedStringArray("node_to_affect")]
script = ExtResource("3_471w1")
node_to_affect = NodePath("..")
property_name = "sprite_frames"
resource_json = ExtResource("4_xp8sq")
metadata/_custom_type_script = "uid://cbal8ms2oe1ik"

[node name="SecondQuestReplacer" type="Node" parent="."]
script = ExtResource("10_xreuf")
new_scene = "uid://kj5pw3xhq8f7"
metadata/_custom_type_script = "uid://d0mqkvopasu8k"

[node name="ExplosionDetection" type="Node" parent="." node_paths=PackedStringArray("hitbox")]
script = ExtResource("11_8y1e5")
hitbox = NodePath("../Sprite/Hitbox")
metadata/_custom_type_script = "uid://ba18grqjixded"

[node name="EditorPropertyExposer" type="Node" parent="."]
script = ExtResource("12_ofvpu")
properties = Array[String](["plant_direction"])
metadata/_custom_type_script = "uid://ctfbuoxtnnl0q"

[node name="Node" type="Node" parent="."]
process_mode = 3
script = SubResource("GDScript_ofvpu")

[connection signal="timeout" from="Timer" to="." method="on_timeout"]
[connection signal="hammer_player_hit" from="EnemyPlayerDetection" to="." method="die_from_hammer"]
[connection signal="hammer_player_hit" from="EnemyPlayerDetection" to="ScoreNoteSpawner" method="spawn_note" binds= [200]]
[connection signal="invincible_player_hit" from="EnemyPlayerDetection" to="." method="die_from_object"]
[connection signal="invincible_player_hit" from="EnemyPlayerDetection" to="ScoreNoteSpawner" method="spawn_note" binds= [200]]
[connection signal="player_hit" from="EnemyPlayerDetection" to="." method="damage_player"]
[connection signal="player_stomped_on" from="EnemyPlayerDetection" to="." method="damage_player"]
[connection signal="fireball_hit" from="FireballDetection" to="." method="die_from_object"]
[connection signal="fireball_hit" from="FireballDetection" to="ScoreNoteSpawner" method="spawn_note" binds= [200]]
[connection signal="moving_shell_entered" from="ShellDetection" to="." method="die_from_object"]
[connection signal="moving_shell_entered" from="ShellDetection" to="ScoreNoteSpawner" method="play_death_sfx" unbinds=1]
[connection signal="explosion_entered" from="ExplosionDetection" to="." method="die_from_object"]
[connection signal="explosion_entered" from="ExplosionDetection" to="ScoreNoteSpawner" method="spawn_note" binds= [200]]
