class_name CameraLimits
extends Node2D
## Manages camera limit nodes and calculates camera limit positions.

var limT : Node2D
var limL : Node2D
var limB : Node2D
var limR : Node2D


func _ready() -> void:
	_get_limit_nodes()

#region Camera Limits
func _get_limit_nodes() -> void:
	limT = get_node("TopLimit") as Node2D
	limL = get_node("LeftLimit") as Node2D
	limB = get_node("BottomLimit") as Node2D
	limR = get_node("RightLimit") as Node2D

func get_camera_limits() -> Vector4:
	return vec4(_get_limc_origin() + global_position, _get_limc_end() + global_position)

func _get_limc_origin() -> Vector2:
	return Vector2(limL.position.x, limT.position.y)
	
func _get_limc_end() -> Vector2:
	return Vector2(limR.position.x, limB.position.y)
#endregion

#region Housekeeping
func vec4(v1 : Vector2, v2 : Vector2) -> Vector4:
	return Vector4(v1.x, v1.y, v2.x, v2.y)
#endregion
