Files
isaac-port/src/mod_manager.h
T
shweetandClaude Opus 5.5 69a354f843 Curation round 8: the first room plays: Isaac walks and shoots tears
Eight agents took over Room::Init's pieces, RailManager, Room::Render/render_lighting/Update, the GridEntity hierarchy
(walls, doors, rocks, pits, poop ...), Game::Update and interpolate_update, the run's save, update_ingame_input,
Game::Spawn with the entity factory and grid collision, the player's movement and tears through Weapon/Weapon_Tears,
PlayerManager's positions, the camera focus, MinimapConfig, PlayerHUD, mod shader rendering, Entity_Tear and
Entity_Effect. Integration wrote Level::get_secret_exit_kind, shared the secret-exit enum (four copies merged) and
fixed the generator's vtable-stub check (word boundary and namespace, not a substring).
Under gdb a run reaches the first room: doors, HUD with hearts and minimap, WASD movement with acceleration, arrow-key
tears that fly and splash. Floor and walls (Backdrop::RenderFloor/RenderWalls) and room transitions are next.
The official build/isaac reaches the start room and stops at Entity_NPC::Redirect. 2770 functions taken over.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 06:43:01 -05:00

150 lines
4.5 KiB
C++

#pragma once
#include "anm2.h"
#include "kage_graphics.h"
#include <list>
#include <map>
#include <memory>
#include <string>
#include <string_view>
#include <unordered_map>
#include <vector>
// The sprites a mod can replace, by their slot in ModEntry::contentSprites.
enum ModContentSprite
{
MOD_SPRITE_CHARACTER_MENU,
MOD_SPRITE_CHARACTER_PORTRAITS,
MOD_SPRITE_DEATH_SCREEN,
MOD_SPRITE_COOP_MENU,
MOD_SPRITE_CHARACTER_MENU_ALT,
MOD_SPRITE_CHARACTER_PORTRAITS_ALT,
MOD_SPRITE_DEATH_SCREEN_ALT,
MOD_SPRITE_COOP_MENU_ALT,
MOD_SPRITE_CARD_FRONTS,
MOD_SPRITE_CONTROLS,
MOD_SPRITE_CONTROLS_ALT,
MOD_SPRITE_DEATH_ITEMS,
MOD_SPRITE_DEATH_ENEMIES,
MOD_SPRITE_COUNT
};
// What ModManager::modBanStatus says about playing online, each with its own popup.
enum ModBanStatus
{
MOD_BAN_UNCHECKED,
MOD_BAN_NONE,
MOD_BAN_ACTIVE,
MOD_BAN_PERMANENT,
MOD_BAN_NEEDS_RESTART
};
// A shader a mod's shaders.xml declares: its GLSL and the vertex parameters it takes, each with its float count, the
// KAGE shader built from them and the render target Game::Render draws through it.
// Destruction, which frees both, is the default.
struct ModShader
{
std::map<std::string, int> parameters;
std::unique_ptr<KAGE::Graphics::Shader> shader;
std::string fragmentSource;
std::string name;
std::string vertexSource;
KAGE::Graphics::ImagePtr renderTarget;
int parametersSize = 0;
void load();
void render_target_create();
void render_target_release();
void render_target_push();
void render();
};
// Construction (008f2d80) and destruction (008f2fb0) are the defaults.
// A mod folder ListMods found: its metadata.xml, its folders, whether it loads, and what its content replaced.
struct ModEntry
{
std::array<ANM2, MOD_SPRITE_COUNT> contentSprites;
std::list<ModShader> shaders;
std::map<int, int> collectibleIdMap;
std::map<int, int> trinketIdMap;
std::vector<std::string> tags;
std::string contentDirectory;
std::string dataDirectory;
std::string directory;
std::string metadataDescription;
std::string metadataVersion;
std::string metadataVisibility;
std::string metadataWorkshopID;
std::string name;
std::string resourcesDirectory;
bool isEnabled = true;
bool isLoaded = true;
bool isOutdated = false;
std::string GetContentPath(std::string_view fileName);
void WriteMetadata();
void load_content_anm2(ModContentSprite slot, std::string_view relativePath);
void load_menu_sprites();
};
// Rebirth's Mod names the same object: its methods (008f99c0, 008f9cb0, 008f9e50) are ModEntry's.
struct Mod : ModEntry
{
};
// A game path a mod replaces, and the mod that does, or no mod when none does.
struct RedirectedPath
{
ModEntry* modEntry = nullptr;
std::string filePath;
};
// Where and how a mod's sprite is drawn in a menu.
struct ModSpriteDraw
{
std::array<int, BLEND_PART_COUNT> blendMode{};
ColorMod color = COLOR_DEFAULT;
Vector position{};
Vector scale = vector_make(1, 1);
};
// Destruction (008f2ff0, 008fc570) is the default.
// The installed mods: listing them, loading their content into the game's configs, their shaders, the game paths
// their resources replace, and what they mean for online play.
// Steam Workshop downloads (008fa390, 008fb120, 008f9f40) are dropped, with the progress text and loading sprite
// Manager::Render showed while they ran.
struct ModManager
{
ANM2 modDefaultsSprite;
std::unordered_map<std::string, RedirectedPath> redirectedPaths;
std::vector<std::unique_ptr<ModEntry>> mods;
ModEntry* loadingMod = nullptr;
ModBanStatus modBanStatus = MOD_BAN_UNCHECKED;
ModManager();
void ListMods();
void LoadModContent();
void LoadModItemPools();
void LoadModBossPools();
void LoadModCurses();
void LoadModRooms(int stageId, int mode);
void LoadShaders();
void Reset();
void TriggerResize();
std::string TryRedirectPath(std::string_view filePath);
bool is_any_mod_loaded();
void mods_unload();
void create_shader_render_targets();
void shader_render_targets_push();
void shader_render_targets_release();
void shaders_render();
void unload_shaders();
static void RenderCustomCharacterMenu(int characterId, Vector& renderPos, ANM2& defaultSprite);
static void RenderCustomGameOver(int playerType, Vector& position);
void RenderCustomCharacterPortraits(int characterId, ModSpriteDraw& draw);
void RenderCustomCollectionItem(unsigned int itemId, ModSpriteDraw& draw);
};