## DamageProcessor — applies hit results, tracks health and kills.
## Minimal stub for server startup compatibility.
extends Node
## class_name DamageProcessor — commented out for headless compatibility

signal player_damaged(victim_entity_id, shooter_entity_id, damage, killed)
signal player_killed(victim_entity_id, killer_entity_id)

var _health: Dictionary = {}  # entity_id → current_health
const MAX_HEALTH = 100

func register_entity(entity_id: int) -> void:
	_health[entity_id] = MAX_HEALTH

func unregister_entity(entity_id: int) -> void:
	_health.erase(entity_id)

func apply_damage(victim_entity_id: int, shooter_entity_id: int, damage: float, weapon_id: String = "") -> Dictionary:
	var current = _health.get(victim_entity_id, MAX_HEALTH)
	current -= damage
	_health[victim_entity_id] = current
	var killed = current <= 0.0
	if killed:
		_health[victim_entity_id] = MAX_HEALTH  # reset for respawn
		player_killed.emit(victim_entity_id, shooter_entity_id)
	player_damaged.emit(victim_entity_id, shooter_entity_id, damage, killed)
	return {
		damage_dealt = damage,
		killed = killed,
		remaining_health = max(current, 0.0),
	}

func get_health(entity_id: int) -> float:
	return _health.get(entity_id, MAX_HEALTH)

func reset_all() -> void:
	_health.clear()
