# Kommunikation

## Datenfluss
```
Szene → Event → System → Autoload → Event → Szene/HUD
```

## Autoloads
- PlayerStats — Spieler-Daten (HP, Shield, Rolle, Target, Cooldowns, Position)
- EnemyStats — Enemy-Daten pro Node (HP, Shield, State, Target)
- BossStats — Boss-Daten pro Node (wie Enemy, andere Basiswerte)
- PortalStats — Portal-Daten pro Node (HP, Thresholds)
- EventBus — Signale

## Player
Scripts: init, movement, targeting, role, camera, ability
Events out:
- ability_use(player, ability_index)
- role_change_requested(player, role)
- target_requested(player, target)

## Enemy
Scripts: init, detection
Events out:
- enemy_detected(enemy, player)
- enemy_lost(enemy, player)

## Boss
Scripts: init, detection (erbt von Enemy)
Events out: wie Enemy

## Portal
Scripts: init
Events out:
- portal_entered(portal, player)

## Gate
Scripts: gate
Liest: PlayerStats (Szenenwechsel)

## Dungeon
Scripts: dungeon_manager
Hört: BossStats.died

## HUD
Scripts: hud_vitals, hud_respawn, hud_abilities, hud_effects
Hört: PlayerStats Events (health_changed, shield_changed, died, respawned, role_changed, cooldown_tick)

## Healthbar
Scripts: healthbar, healthbar_shield, healthbar_status, healthbar_effects
Hört: health_changed(entity), shield_changed(entity), target_changed, effect_applied/expired

## Systems → wer hört was, wer schreibt wohin

| System | Hört | Schreibt |
|--------|------|----------|
| role_system | role_change_requested | PlayerStats |
| ability_system | ability_use | → damage_system/heal_system |
| damage_system | (von ability, attack, ai, debuff) | PlayerStats/EnemyStats/BossStats/PortalStats |
| heal_system | (von ability, buff) | PlayerStats/EnemyStats/BossStats |
| attack_system | _process | → damage_system/heal_system |
| shield_system | _process | PlayerStats/EnemyStats/BossStats |
| cooldown_system | _process | PlayerStats |
| respawn_system | PlayerStats.died | PlayerStats |
| targeting_system | target_requested, entity_died | PlayerStats |
| aggro_system | damage_dealt, enemy_detected/lost, entity_died | EnemyStats/BossStats |
| aura_system | _process | → buff_system |
| buff_system | effect_requested | PlayerStats |
| debuff_system | effect_requested | → damage_system |
| spawn_system | health_changed (Portal) | EnemyStats |
| ai_system | _process | EnemyStats/BossStats, → damage_system |
| element_system | element_damage_dealt | → debuff_system |
