[gd_scene load_steps=14 format=4 uid="uid://dx7otbnngehj2"]

[ext_resource type="TileSet" uid="uid://cygngaiobann6" path="res://tiles/tileset.tres" id="1_2dn5a"]
[ext_resource type="Script" uid="uid://mb2mnfri0ti" path="res://rooms/caves.gd" id="1_j34b7"]
[ext_resource type="Script" uid="uid://dtdbkfoaaejw0" path="res://objects/player_camera_2d.gd" id="2_yponf"]
[ext_resource type="Script" uid="uid://c027jkwb3uac4" path="res://objects/door_zone.gd" id="3_y0efj"]
[ext_resource type="PackedScene" uid="uid://enj7slqj7o2o" path="res://objects/npcs/zombie.tscn" id="5_8al1q"]

[sub_resource type="RectangleShape2D" id="RectangleShape2D_j34b7"]
size = Vector2(64, 10)

[sub_resource type="GDScript" id="GDScript_j34b7"]
script/source = "extends Area2D

@export var camera: PlayerCamera2D
@export var auto_limit: bool
@export var limit: Vector4i

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta: float) -> void:
	pass


func _on_body_entered(body:  Node2D) -> void:
	if body is Player:
		if auto_limit:
			var rect := Rect2i((get_node(\"CollisionShape2D\") as CollisionShape2D).shape.get_rect())
			rect.position += Vector2i((get_node(\"CollisionShape2D\") as CollisionShape2D).position)
			limit.x = rect.position.x
			limit.y = rect.position.y
			limit.z = rect.end.x
			limit.w = rect.end.y
		camera.limit_left = limit.x
		camera.limit_top = limit.y
		camera.limit_right = limit.z
		camera.limit_bottom = limit.w
"

[sub_resource type="RectangleShape2D" id="RectangleShape2D_8al1q"]
size = Vector2(640, 240)

[sub_resource type="RectangleShape2D" id="RectangleShape2D_wcxe8"]
size = Vector2(800, 272)

[sub_resource type="RectangleShape2D" id="RectangleShape2D_0gf5r"]
size = Vector2(608, 656)

[sub_resource type="RectangleShape2D" id="RectangleShape2D_bf2p6"]
size = Vector2(320, 240)

[sub_resource type="RectangleShape2D" id="RectangleShape2D_nkurl"]
size = Vector2(928, 240)

[sub_resource type="RectangleShape2D" id="RectangleShape2D_0fyj3"]
size = Vector2(992, 352)

[node name="Caves" type="Node2D"]
script = ExtResource("1_j34b7")

[node name="BackgroundTileMapLayer" type="TileMapLayer" parent="."]
tile_map_data = PackedByteArray("[encoded data, 8628 characters]")
tile_set = ExtResource("1_2dn5a")
collision_enabled = false

[node name="WallTileMapLayer" type="TileMapLayer" parent="."]
tile_map_data = PackedByteArray("[encoded data, 7156 characters]")
tile_set = ExtResource("1_2dn5a")

[node name="PlayerCamera2D" type="Camera2D" parent="."]
limit_left = -288
limit_top = -32
limit_right = 1216
limit_bottom = 1152
script = ExtResource("2_yponf")
metadata/_custom_type_script = "uid://dtdbkfoaaejw0"

[node name="DoorLabs" type="Area2D" parent="."]
position = Vector2(160, 10)
script = ExtResource("3_y0efj")
TargetRoomPath = "uid://dg3jjeldcoi0k"
TargetDoor = "DoorCaves"
PreserveX = true
PreserveVelocity = true
metadata/_custom_type_script = "uid://c027jkwb3uac4"

[node name="CollisionShape2D" type="CollisionShape2D" parent="DoorLabs"]
position = Vector2(0, -5)
shape = SubResource("RectangleShape2D_j34b7")

[node name="PlayerSpawn" type="Marker2D" parent="."]
position = Vector2(160, 128)

[node name="Zone1" type="Area2D" parent="." node_paths=PackedStringArray("camera")]
visible = false
script = SubResource("GDScript_j34b7")
camera = NodePath("../PlayerCamera2D")
auto_limit = true

[node name="CollisionShape2D" type="CollisionShape2D" parent="Zone1"]
position = Vector2(32, 120)
shape = SubResource("RectangleShape2D_8al1q")

[node name="Zone2" type="Area2D" parent="." node_paths=PackedStringArray("camera")]
visible = false
script = SubResource("GDScript_j34b7")
camera = NodePath("../PlayerCamera2D")
auto_limit = true

[node name="CollisionShape2D" type="CollisionShape2D" parent="Zone2"]
position = Vector2(752, 104)
shape = SubResource("RectangleShape2D_wcxe8")

[node name="Zone3" type="Area2D" parent="." node_paths=PackedStringArray("camera")]
visible = false
script = SubResource("GDScript_j34b7")
camera = NodePath("../PlayerCamera2D")
auto_limit = true

[node name="CollisionShape2D" type="CollisionShape2D" parent="Zone3"]
position = Vector2(912, 568)
shape = SubResource("RectangleShape2D_0gf5r")

[node name="Zone4" type="Area2D" parent="." node_paths=PackedStringArray("camera")]
visible = false
script = SubResource("GDScript_j34b7")
camera = NodePath("../PlayerCamera2D")
auto_limit = true

[node name="CollisionShape2D" type="CollisionShape2D" parent="Zone4"]
position = Vector2(960, 1016)
shape = SubResource("RectangleShape2D_bf2p6")

[node name="Zone5" type="Area2D" parent="." node_paths=PackedStringArray("camera")]
visible = false
script = SubResource("GDScript_j34b7")
camera = NodePath("../PlayerCamera2D")
auto_limit = true

[node name="CollisionShape2D" type="CollisionShape2D" parent="Zone5"]
position = Vector2(336, 1016)
shape = SubResource("RectangleShape2D_nkurl")

[node name="Zone6" type="Area2D" parent="." node_paths=PackedStringArray("camera")]
visible = false
script = SubResource("GDScript_j34b7")
camera = NodePath("../PlayerCamera2D")
auto_limit = true

[node name="CollisionShape2D" type="CollisionShape2D" parent="Zone6"]
position = Vector2(-624, 1008)
shape = SubResource("RectangleShape2D_0fyj3")

[node name="Zombie" parent="." instance=ExtResource("5_8al1q")]
position = Vector2(480, 128)

[node name="Zombie2" parent="." instance=ExtResource("5_8al1q")]
position = Vector2(672, 64)

[connection signal="body_entered" from="DoorLabs" to="DoorLabs" method="_on_body_entered"]
[connection signal="body_exited" from="DoorLabs" to="DoorLabs" method="_on_body_exited"]
[connection signal="body_entered" from="Zone1" to="Zone1" method="_on_body_entered"]
[connection signal="body_entered" from="Zone2" to="Zone2" method="_on_body_entered"]
[connection signal="body_entered" from="Zone3" to="Zone3" method="_on_body_entered"]
[connection signal="body_entered" from="Zone4" to="Zone4" method="_on_body_entered"]
[connection signal="body_entered" from="Zone5" to="Zone5" method="_on_body_entered"]
[connection signal="body_entered" from="Zone6" to="Zone6" method="_on_body_entered"]
