#pragma once #include "anm2.h" #include #include constexpr int STAT_PLAYER_COUNT = 2; constexpr int STAT_TRACKER_COUNT = 10; constexpr float STAT_THRESHOLD_FINE = 0.01f; constexpr float STAT_THRESHOLD_COARSE = 0.1f; // The stats the stats HUD tracks, in the order of hudstats2.anm2's frames. The last two are tracked but never shown. enum StatHudStat : int { STAT_SPEED, STAT_TEARS, STAT_DAMAGE, STAT_RANGE, STAT_SHOT_SPEED, STAT_LUCK, STAT_DEVIL_CHANCE, STAT_ANGEL_CHANCE, STAT_UNUSED, STAT_PLANETARIUM_CHANCE }; // Which stats RecomputeStats recomputes, a bit per stat. Either deal chance bit recomputes both. enum StatHudFlag : uint32_t { STAT_FLAG_SPEED = 1 << STAT_SPEED, STAT_FLAG_TEARS = 1 << STAT_TEARS, STAT_FLAG_DAMAGE = 1 << STAT_DAMAGE, STAT_FLAG_RANGE = 1 << STAT_RANGE, STAT_FLAG_SHOT_SPEED = 1 << STAT_SHOT_SPEED, STAT_FLAG_LUCK = 1 << STAT_LUCK, STAT_FLAG_DEVIL_CHANCE = 1 << STAT_DEVIL_CHANCE, STAT_FLAG_ANGEL_CHANCE = 1 << STAT_ANGEL_CHANCE, STAT_FLAG_UNUSED = 1 << STAT_UNUSED, STAT_FLAG_PLANETARIUM_CHANCE = 1 << STAT_PLANETARIUM_CHANCE, STAT_FLAGS_ALL = 0xffffffff }; // A stat the stats HUD shows: its value, the value before its change, the change shown and for how long, and the // smallest change worth showing. struct StatTracker { float change = 0; float previous = 0; float threshold = STAT_THRESHOLD_FINE; float value = 0; int changeTimer = 0; void set(float newValue, bool isAnimated); }; // The stats one player shows. struct StatHUDPlayer { std::array stats{}; Entity_Player* player = nullptr; }; // The stats HUD (REPENTOGON's StatHUD) under the pickups, with the found HUD option: speed, tears, damage, range, shot // speed, luck and the deal chances, for up to two players, each change shown beside its stat for a while. struct StatHUD { ANM2 sprite; std::array players{}; bool isDualityOwned = false; void reset(); int player_slot_get(Entity_Player* player); void Update(); void Render(Vector at); void RecomputeStats(int playerId, uint32_t flags); void update_player(Entity_Player* oldPlayer, Entity_Player* newPlayer); };