Kelsidavis-WoWee/include/core/animation_callback_handler.hpp
Paul 6dcc06697b refactor(core): decompose Application::setupUICallbacks() into 7 domain handlers
Extract ~1,700 lines / 60+ inline [this]-capturing lambdas from the monolithic
Application::setupUICallbacks() into 7 focused callback handler classes following
the ToastManager/ChatPanel::setupCallbacks() pattern already in the codebase.

New handlers (include/core/ + src/core/):
  - NPCInteractionCallbackHandler  NPC greeting/farewell/vendor/aggro voice
  - AudioCallbackHandler           Music, positional sound, level-up, achievement, LFG
  - EntitySpawnCallbackHandler     Creature/player/GO spawn, despawn, move, state
  - AnimationCallbackHandler       Death, respawn, combat, emotes, charge, sprint, vehicle
  - TransportCallbackHandler       Mount, taxi, transport spawn/move
  - WorldEntryCallbackHandler      World entry, unstuck, hearthstone, bind point
  - UIScreenCallbackHandler        Auth, realm selection, char selection/creation/deletion

application.cpp:  4,462 → 2,791 lines  (−1,671)
setupUICallbacks: ~1,700 → ~50 lines (thin orchestrator)

Deduplication:
  resolveSoundEntryPath()   — was 3× copy-paste of SoundEntries.dbc lookup
  resolveNpcVoiceType()     — was 4× copy-paste of display-ID→voice detection
  precacheNearbyTiles()     — was 3× copy-paste of 17×17 tile loop
  4 helper lambdas          — promoted to private methods on WorldEntryCallbackHandler

State migration out of Application:
  charge* (6 vars)          → AnimationCallbackHandler
  hearth*/worldEntry*/taxi* → WorldEntryCallbackHandler
  pendingCreatedCharacterName_ → UIScreenCallbackHandler

Bug fixes:
  - Duplicate `namespace core {` in application.hpp caused wowee::std pollution
  - AppState forward decl in ui_screen_callback_handler.hpp was at wrong scope
  - world_loader.cpp accessed moved member vars directly via friend; now uses handler API
2026-04-05 16:48:17 +03:00

50 lines
1.5 KiB
C++

#pragma once
#include <cstdint>
#include <glm/glm.hpp>
namespace wowee {
namespace rendering { class Renderer; }
namespace game { class GameHandler; }
namespace core { class EntitySpawner; }
namespace core {
/// Handles animation callbacks: death, respawn, swing, hit reaction, spell cast, emote,
/// stun, stealth, health, ghost, stand state, loot, sprint, vehicle, charge.
/// Owns charge rush state (interpolated in update).
class AnimationCallbackHandler {
public:
AnimationCallbackHandler(EntitySpawner& entitySpawner,
rendering::Renderer& renderer,
game::GameHandler& gameHandler);
void setupCallbacks();
/// Called each frame from Application::update() to drive charge interpolation.
/// Returns true if charge is active (player is externally driven).
bool updateCharge(float deltaTime);
// Charge state queries (used by Application::update for externallyDrivenMotion)
bool isCharging() const { return chargeActive_; }
// Reset charge state (logout/disconnect)
void resetChargeState();
private:
EntitySpawner& entitySpawner_;
rendering::Renderer& renderer_;
game::GameHandler& gameHandler_;
// Charge rush state (moved from Application)
bool chargeActive_ = false;
float chargeTimer_ = 0.0f;
float chargeDuration_ = 0.0f;
glm::vec3 chargeStartPos_{0.0f}; // Render coordinates
glm::vec3 chargeEndPos_{0.0f}; // Render coordinates
uint64_t chargeTargetGuid_ = 0;
};
} // namespace core
} // namespace wowee