extends Node

@export var FireWall: PackedScene
@export var max_range = 10
@export var min_range = 5
@export var max_ammo = 5
var ammo = max_ammo

func activate(world, activator):
	var firewall = FireWall.instantiate()
	var target = activator.get_target_pos()
	firewall.position = activator.position
	firewall.position += firewall.position.direction_to(target) \
		* clamp(firewall.position.distance_to(target), min_range, max_range)
	if activator.get_collision_layer_value(1): # player object
		firewall.get_node("Area2D").set_collision_layer_value(1, false)
		firewall.get_node("Area2D").set_collision_layer_value(2, true)
	elif activator.get_collision_layer_value(2): # enemy object
		firewall.get_node("Area2D").set_collision_layer_value(1, true)
		firewall.get_node("Area2D").set_collision_layer_value(2, false)
	else:
		assert(false, "who are you, activator?")
	world.add_child(firewall)
	

func discard(world, activator):
	pass
