Six agents took over Game::Start, Level::SetNextStage, BossPool, save_game_state, level generation to the first room (place_special_rooms, RoomDescriptor, load_room), Room, Camera, Entity/EntityList/EntityRef with a curated skeleton of every Entity_* subclass, Entity_Player, Game::Render, Manager::Update's run branch, RoomTransition, ItemInfoHUD and StatHUD. Integration wrote FirstTrinketOwner and room_shape_get_door_grid_index (checked against the decompile for every shape and slot) and folded the duplicated constants. A run now generates its floor, loads the start room and draws the HUD (under gdb); Isaac renders correctly when drawn, the room itself waits for Room::Render. 2479 functions taken over. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
298 lines
9.8 KiB
C++
298 lines
9.8 KiB
C++
#pragma once
|
|
|
|
#include "anm2.h"
|
|
#include "boss_pool.h"
|
|
#include "challenge_params.h"
|
|
#include "console.h"
|
|
#include "deathmatch_manager.h"
|
|
#include "game_state.h"
|
|
#include "generic_prompt.h"
|
|
#include "hud.h"
|
|
#include "item_pool.h"
|
|
#include "kage_graphics.h"
|
|
#include "leaderboard.h"
|
|
#include "level.h"
|
|
#include "minimap.h"
|
|
#include "online_emotes.h"
|
|
#include "online_stats_screen.h"
|
|
#include "pause_screen.h"
|
|
#include "player_manager.h"
|
|
#include "preload_manager.h"
|
|
#include "procedural_item_manager.h"
|
|
#include "revive_player_menu.h"
|
|
#include "room_config.h"
|
|
#include "room_transition.h"
|
|
#include "score_sheet.h"
|
|
#include "seeds.h"
|
|
#include <array>
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <vector>
|
|
|
|
constexpr int GLOWING_HOURGLASS_SLOTS = 2;
|
|
constexpr int GIANTBOOK_ENTRY_COUNT = 48;
|
|
constexpr int BOSS_OVERLAY_COUNT = 5;
|
|
constexpr int COOP_AWARD_COUNT = 21;
|
|
constexpr int COOP_STAT_NONE = 22;
|
|
|
|
// The xorshift every RNG of Game starts on, before a run seeds it (shift index 35).
|
|
constexpr RNG RNG_DEFAULT = {RNG_SEED_DEFAULT, 5, 9, 7};
|
|
|
|
// A screen color modifier that changes nothing.
|
|
constexpr ColorModState COLOR_MOD_NEUTRAL = {1, 1, 1, 0, 0, 1};
|
|
|
|
// The difficulty a run is played on. The two Greed ones play Greed mode.
|
|
enum Difficulty : uint32_t
|
|
{
|
|
DIFFICULTY_NORMAL,
|
|
DIFFICULTY_HARD,
|
|
DIFFICULTY_GREED,
|
|
DIFFICULTY_GREEDIER
|
|
};
|
|
|
|
// The run's state flags (Lua's GameStateFlag) the curated code reads, by bit.
|
|
enum GameStateFlag : int
|
|
{
|
|
GAME_STATE_DEVILROOM_VISITED = 6,
|
|
GAME_STATE_HEAVEN_PATH = 19,
|
|
GAME_STATE_BOSSRUSH_DONE = 33,
|
|
GAME_STATE_BOSSRUSH_DOOR_SPAWNED = 38,
|
|
GAME_STATE_BLUEWOMB_DOOR_SPAWNED = 39,
|
|
GAME_STATE_BLUEWOMB_DONE = 40,
|
|
GAME_STATE_SECRET_PATH = 44,
|
|
GAME_STATE_BACKWARDS_PATH = 48
|
|
};
|
|
|
|
// The string table keys of the co-op awards, in the order of Game's award table.
|
|
constexpr std::array<std::string_view, COOP_AWARD_COUNT> COOP_AWARD_KEYS = {
|
|
"#Online/COOP_AWARD_ETERNAL", "#Online/COOP_AWARD_HEARTLESS", "#Online/COOP_AWARD_ENVIOUS",
|
|
"#Online/COOP_AWARD_DRESSED_UP", "#Online/COOP_AWARD_PRIDEFUL", "#Online/COOP_AWARD_SAVIOR",
|
|
"#Online/COOP_AWARD_WRATHFUL", "#Online/COOP_AWARD_BIG_BOSS", "#Online/COOP_AWARD_EXPLORER",
|
|
"#Online/COOP_AWARD_EXPRESSIVE", "#Online/COOP_AWARD_GLUTTONOUS", "#Online/COOP_AWARD_RECKLESS",
|
|
"#Online/COOP_AWARD_ESCAPE_ARTIST", "#Online/COOP_AWARD_GAMBLER", "#Online/COOP_AWARD_GREEDY",
|
|
"#Online/COOP_AWARD_MYSTIC", "#Online/COOP_AWARD_PILL_POPPER", "#Online/COOP_AWARD_BIG_SPENDER",
|
|
"#Online/COOP_AWARD_JANITOR", "#Online/COOP_AWARD_LUSTFUL", "#Online/COOP_AWARD_SLOTHFUL"};
|
|
|
|
// An award the online co-op stats screen gives: its translated name, the player stat that decides it (none by default),
|
|
// whether the most or the least wins and within what threshold, the least the first stat must reach, whether a tie
|
|
// shares it, and the players who earned it.
|
|
struct CoopAward
|
|
{
|
|
std::string name;
|
|
std::vector<uint64_t> userIds;
|
|
float threshold = 0;
|
|
int minimumFirstStat = 0;
|
|
int statId = COOP_STAT_NONE;
|
|
bool isTieShared = true;
|
|
bool isMostWins = true;
|
|
};
|
|
|
|
// A layer of a giant book animation recolored by giantbook.xml.
|
|
struct GiantbookLayer
|
|
{
|
|
std::string name;
|
|
ColorMod color{};
|
|
};
|
|
|
|
// A giant book animation (the full screen item use overlays) as giantbook.xml defines it.
|
|
struct GiantbookEntry
|
|
{
|
|
std::string anm2Path;
|
|
std::string animation;
|
|
std::string gfxPath;
|
|
std::vector<GiantbookLayer> layers;
|
|
int id = 0;
|
|
};
|
|
|
|
// A boss overlay animation (the Dogma and Beast screen effects) as bossoverlays.xml defines it.
|
|
struct BossOverlayEntry
|
|
{
|
|
std::string anm2Path;
|
|
std::string animation;
|
|
int id = 0;
|
|
bool isPersistent = false;
|
|
};
|
|
|
|
// What Game::Spawn creates: an entity by type, variant and subtype at a position and velocity, from a seed.
|
|
struct EntitySpawn
|
|
{
|
|
Vector position{};
|
|
Vector velocity{};
|
|
Entity* spawner = nullptr;
|
|
int subType = 0;
|
|
int type = 0;
|
|
int variant = 0;
|
|
uint32_t seed = 0;
|
|
};
|
|
|
|
// Whether a fade in shows the loading icon.
|
|
enum FadeIcon
|
|
{
|
|
FADE_ICON_HIDE,
|
|
FADE_ICON_SHOW
|
|
};
|
|
|
|
// The run (g_game): the floor and its rooms (Level, the front of the class), the configs and pools a run
|
|
// draws from, the UI overlays and menus of a run, and the screen effects, counters and history of the run so far.
|
|
// Members of classes not taken over yet keep their generated types and start zeroed.
|
|
// The render surfaces were file globals of the original, created once by the first Game.
|
|
// The giant book and boss overlay tables live in the item and boss overlays of the original, which classes.h holds as
|
|
// bytes. They move there with those classes' takeovers.
|
|
class Game : public Level
|
|
{
|
|
public:
|
|
std::array<BackwardsStageDesc, BACKWARDS_STAGE_COUNT> backwardsStages{};
|
|
Vector mamaMegaPosition{};
|
|
|
|
RoomConfig roomConfig;
|
|
ItemPool itemPool;
|
|
Seeds seedEffects;
|
|
Console console;
|
|
std::unique_ptr<EntityFactory> entityFactory = std::make_unique<EntityFactory>();
|
|
PreloadManager preloadManager;
|
|
BossPool bossPool;
|
|
PlayerManager playerManager{};
|
|
Ambush ambush{};
|
|
DeathmatchManager deathmatchManager{};
|
|
DailyChallenge dailyChallenge{};
|
|
ProceduralItemManager proceduralItemManager;
|
|
std::array<GlowingHourglassState, GLOWING_HOURGLASS_SLOTS> glowingHourglassStates{};
|
|
std_vector onlinePlayerStats{};
|
|
std::array<CoopAward, COOP_AWARD_COUNT> coopAwards;
|
|
bool isOnlineStatsFinalized = false;
|
|
std::vector<BossId> encounteredBosses;
|
|
std::vector<ErasedEnemy> erasedEntities;
|
|
|
|
RoomTransition roomTransition{};
|
|
StageTransition stageTransition{};
|
|
ItemOverlay itemOverlay{};
|
|
std::array<GiantbookEntry, GIANTBOOK_ENTRY_COUNT> giantbookEntries;
|
|
BossOverlay bossOverlay{};
|
|
std::array<BossOverlayEntry, BOSS_OVERLAY_COUNT> bossOverlayEntries;
|
|
GameOver gameOver{};
|
|
Leaderboard leaderboard{};
|
|
HUD hud;
|
|
PauseScreen pauseScreen;
|
|
RevivePlayerMenu revivePlayerMenu;
|
|
OnlineStatsScreen onlineStatsScreen;
|
|
Minimap minimap;
|
|
ScoreSheet scoreSheet;
|
|
GenericPrompt genericPrompt{};
|
|
DebugRenderer debugRenderer{};
|
|
EmoteWheel emoteWheel;
|
|
ANM2 completionWidgetSprite;
|
|
|
|
KAGE::Graphics::ImagePtr giantBookClickerImage;
|
|
KAGE::Graphics::ImagePtr bloomSurface;
|
|
KAGE::Graphics::ImagePtr colormodSurface;
|
|
KAGE::Graphics::ImagePtr hallucinationSnapshot;
|
|
KAGE::Graphics::ImagePtr hallucinationSurface;
|
|
KAGE::Graphics::ImagePtr oldTvSurface;
|
|
KAGE::Graphics::ImagePtr pixelationSurface;
|
|
|
|
ColorModState currentColorModifier = COLOR_MOD_NEUTRAL;
|
|
ColorModState lerpColorModifier = COLOR_MOD_NEUTRAL;
|
|
ColorModState targetColorModifier = COLOR_MOD_NEUTRAL;
|
|
KColor fadeInColor{};
|
|
KColor fadeOutColor{};
|
|
RNG fortuneRNG = RNG_DEFAULT;
|
|
Vector screenShakeOffset{};
|
|
Difficulty difficulty = DIFFICULTY_NORMAL;
|
|
float bloomStrength = 0;
|
|
float darknessModifier = 0;
|
|
float darknessStrength = 0;
|
|
float dizzyIntensity = 0;
|
|
float dizzyIntensityChangeSpeed = 0;
|
|
float dizzyTargetIntensity = 0;
|
|
float fadeSpeed = 0;
|
|
float lightningIntensity = 0;
|
|
float trapdoorLoopVolume = 0;
|
|
int ascentTimer = 0;
|
|
int blueWombParTime = 0;
|
|
int bloomDuration = 0;
|
|
int bloomTimer = 0;
|
|
int bossRushParTime = 0;
|
|
int currentGlowingHourglassSlot = 0;
|
|
int darknessTimeout = 0;
|
|
int deathCertificateExitTimer = 0;
|
|
int devilRoomDeals = 0;
|
|
int donationModAngel = 0;
|
|
int donationModGreed = 0;
|
|
int emoteMenuState = 0;
|
|
int fadeOutTarget = 0;
|
|
int frameCount = 0;
|
|
int framesSinceRoomTransition = 0;
|
|
int freezeFrames = 0;
|
|
int hallucinationDuration = 0;
|
|
int hallucinationTimer = 0;
|
|
int lastDevilRoomStage = 0;
|
|
int lastLevelWithDamage = 0;
|
|
int lastLevelWithoutHalfHp = 0;
|
|
int magicSkinUses = 0;
|
|
int pixelationDuration = 0;
|
|
int pixelationTimer = 0;
|
|
int planetariumsVisited = 0;
|
|
int reviveMachineCoinsLeft = 0;
|
|
int reviveMachineUses = 0;
|
|
int rewindsThisFloor = 0;
|
|
int screenShakeTimer = 0;
|
|
int shopVisits = 0;
|
|
int stageNameNumeral = 0;
|
|
int stagesWithoutDamage = 0;
|
|
int stagesWithoutHeartsPicked = 0;
|
|
int timeCounter = 0;
|
|
int treasureRoomsVisited = 0;
|
|
int victoryLap = 0;
|
|
uint32_t challenge = 0;
|
|
uint32_t debugCurses = 0;
|
|
uint32_t debugFlags = 0;
|
|
uint64_t gameStateFlags = 0;
|
|
uint8_t restartHoldFrames = 0;
|
|
|
|
bool isColorModifierLerped = false;
|
|
bool isConsoleUsedThisRun = false;
|
|
bool isDebug = false;
|
|
bool isFadeInIconShown = false;
|
|
bool isInstantFadeIn = false;
|
|
bool isPocketItemRewindSaved = false;
|
|
bool isRerun = false;
|
|
bool isRestoringGlowingHourglassState = false;
|
|
bool isRoomRespawned = false;
|
|
bool isRoomSnapshotTaken = false;
|
|
bool isStarted = false;
|
|
bool isStartingFromState = false;
|
|
bool isStoringGlowingHourglassState = false;
|
|
bool isWindowResizePending = false;
|
|
|
|
Game();
|
|
~Game();
|
|
|
|
static void LoadConfigXmls();
|
|
bool load_giantbook_xml(std::string_view path);
|
|
bool load_bossoverlays_xml(std::string_view path);
|
|
static void LoadBossRushXml(std::string_view path);
|
|
void reset_run_state();
|
|
void ResetState();
|
|
void level_reset();
|
|
void create_render_surfaces();
|
|
|
|
void Start(int playerType, uint32_t startChallenge, const Seeds& seeds, Difficulty startDifficulty);
|
|
void Fadein(float speed, FadeIcon icon, KColor color);
|
|
void store_game_state(GameState& state);
|
|
static void Exit(bool isSaving);
|
|
void Update();
|
|
void Render();
|
|
bool IsPaused();
|
|
bool IsGreedMode();
|
|
int GetStageID();
|
|
bool GetStateFlag(GameStateFlag flag);
|
|
Entity_Player* GetPlayer(int index);
|
|
ChallengeParam& GetChallengeParams();
|
|
Entity* Spawn(const EntitySpawn& spawn);
|
|
};
|
|
|
|
void coop_awards_load(std::array<CoopAward, COOP_AWARD_COUNT>& awards);
|
|
void pause_screen_reset(PauseScreen& pauseScreen);
|