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_bit(1): # player object
		firewall.set_collision_layer_bit(1, false)
		firewall.set_collision_layer_bit(2, true)
		ammo -= 1
	elif activator.get_collision_layer_bit(2): # enemy object
		firewall.set_collision_layer_bit(1, true)
		firewall.set_collision_layer_bit(2, false)
	else:
		assert(false, "who are you, activator?")
	

func discard(world, activator):
	pass
