class_name MaskData extends Resource

enum MaskType { MELEE, RANGED, SPIT }

@export_group("Assets")
@export var mask_name: String
@export var texture: Texture2D
@export var drop_texture: Texture2D
@export var spawn_sfx : Resource

@export_group("Combat")
@export var attack_scene: PackedScene
@export var cooldown: float = 0.5
@export var damage: int = 1
@export var is_parented_to_attacker: bool = false

func activate(attacker: Node2D, target_pos: Vector2) -> void:
	if not attack_scene:
		return
		
	var atk : MaskAbility = attack_scene.instantiate()
	
	if is_parented_to_attacker:
		attacker.add_child(atk)
		atk.position = Vector2.ZERO
	else:
		attacker.get_parent().add_child(atk)
		atk.position = attacker.position

	atk.start_position = attacker.position
	atk.target_position = target_pos

	var from_player = attacker.is_in_group("player")
	atk.from_player = from_player

	if not from_player:
		atk.modulate = Color("#0000ff")

	atk.mask_ready()
	SoundManager.play_sfx(spawn_sfx)
