extends CharacterBody2D

@onready var playerP = $"../Player"
var max_collisions = 0

var dealtScale := 1.5

func _ready() -> void:
	pass # Replace with function body.


func _physics_process(delta: float) -> void:
	if playerP.transitioning: return
	move_and_collide(velocity * delta)


func _on_area_entered(area: Area2D) -> void:
	if area.get_meta("playerHitbox", 0) != 0:
		var player = area.get_parent()
		
		player.speedScale = dealtScale * pow(0.8, Globals.unlockedUpgrades.get("rollback", 0))
		player.speedUp = 0.5
		player.damageScale += dealtScale * pow(0.8, Globals.unlockedUpgrades.get("rollback", 0))
		player.knockback = Vector2(sin(rotation) * 500 * [0.5, -0.5].pick_random(), cos(rotation) * 500 * [0.5, -0.5].pick_random())
		
		player.hitsfx.play()
		
		queue_free()


func _on_body_entered(body: Node2D) -> void:
	queue_free()
