extends CharacterBody2D

class_name Player

@export var speed = 200
@export var special_ability: Ability
@export var ranged: RangedWeaponComponent
@export var melee: MeleeWeaponComponent
@export var stats: StatsComponent

var movement: PlayerMovement
var combat: PlayerCombat

# Last direction for idle state
var last_direction = Vector2.DOWN

@onready var animated_sprite = $PlayerSprite

func _ready():
	combat = PlayerCombat.new()

	movement = PlayerMovement.new()
	movement.player = self
	movement.animated_sprite = animated_sprite
	movement.speed = speed

	combat.player = self
	combat.animated_sprite = animated_sprite

	Log.pr("Adding projectile size additive modifier")
	ranged.add_modifier(ProjectileSizeAdditive.new())
	#Log.pr(weapon.stats.get_stat("projectile_size")) # Size is now 1.0 + 0.5 = 1.5
# Size is now 1.0 + 0.5 = 1.5

# Add the multiplicative size modifier (1.5x multiplier)
	Log.pr("Adding projectile size multiplicative modifier")
	#weapon.add_modifier(ProjectileSizeMultiplicative.new())
	#Log.pr(weapon.stats.get_stat("projectile_size"))
# Size is now 1.5 * 1.5 = 2.25

# Add another additive size modifier (+0.7 or 70% increase)
	Log.pr("Adding another projectile size additive modifier", 2)
	var another_size_mod = ProjectileSizeAdditive.new()
	another_size_mod.size_increase = 0.7
	#weapon.add_modifier(another_size_mod)
	#Log.pr(weapon.stats.get_stat("projectile_size"))

	ranged.add_modifier(FireRateAdditive.new())
	

func _physics_process(delta):
	movement.process(delta)
	combat.process(delta)
