Player Hit System
Source file: client/engine/systems/systems_functions/PlayerHitSystem.cpp
Purpose: Reset the player's animation back to the default after the hit animation completes.
Components used:
PlayerTag(filters affected entities)AnimatedSprite(current animation and elapsed time)GameWorld(last_delta_for timing)
Behavior
- Iterates entities with
PlayerTagandAnimatedSprite. - If current animation is "Hit", increments
elapsedTimebygame_world.last_delta_. - When
elapsedTimeexceeds the current animation'sframeDuration, switches to "Default" and resetselapsedTimeto 0.
Main signature
void PlayerHitSystem(Eng::registry ®, GameWorld &game_world,
Eng::sparse_array<Component::AnimatedSprite> &animated_sprites,
Eng::sparse_array<Component::PlayerTag> &player_tags);
Notes
- Assumes "Hit" is non-looping and has at least one frame.
- Only affects players; other entities rely on
DeathAnimationSystemor their own systems.