Curation round 7: Game::Start, level generation, Room, Camera, the Entity hierarchy, Entity_Player, the run frame
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>
This commit is contained in:
1 parent
addd027977
commit
b85591bdf4
146 files changed
+20124
-200863
No files matched your search
+464
-4
@@ -1,9 +1,17 @@
|
||||
#include "game.h"
|
||||
#include "data.h"
|
||||
#include "entity_player.h"
|
||||
#include "log.h"
|
||||
#include "manager.h"
|
||||
#include "lua_engine.h"
|
||||
#include "menu_manager.h"
|
||||
#include "render_passes.h"
|
||||
#include "room.h"
|
||||
#include "room_transition.h"
|
||||
#include "victory_run_prompt.h"
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <numbers>
|
||||
#include <optional>
|
||||
|
||||
constexpr const char* STAGES_XML = "stages.xml";
|
||||
@@ -12,6 +20,7 @@ constexpr const char* MINIBOSSES_XML = "minibosses.xml";
|
||||
constexpr const char* GIANTBOOK_XML = "giantbook.xml";
|
||||
constexpr const char* BOSS_OVERLAYS_XML = "bossoverlays.xml";
|
||||
constexpr const char* AMBUSH_XML = "ambush.xml";
|
||||
constexpr const char* ITEM_POOLS_XML = "itempools.xml";
|
||||
constexpr const char* PRELOAD_XML = "preload.xml";
|
||||
constexpr std::array<std::string_view, 4> PRELOAD_GROUPS = {"common", "enemy", "pickups", "icons"};
|
||||
constexpr const char* COMPLETION_WIDGET_ANM2 = "gfx/ui/completion_widget.anm2";
|
||||
@@ -37,8 +46,12 @@ constexpr float COLOR_CHANNEL_MAX = 255;
|
||||
// The attributes of a giant book layer's tint channels.
|
||||
constexpr std::array<std::string_view, 4> TINT_ATTRIBUTES = {"r", "g", "b", "a"};
|
||||
|
||||
constexpr uint32_t CHALLENGE_BACKASSWARDS = 44;
|
||||
constexpr int DIMENSION_DEATH_CERTIFICATE = 2;
|
||||
constexpr int STAGE_DARK_ROOM = 11;
|
||||
// The fortune generator's xorshift (shift index 35), the start's fade in speed, and the cover an instant fade starts on.
|
||||
constexpr uint32_t FORTUNE_RNG_SHIFT = 35;
|
||||
constexpr float START_FADE_SPEED = 0.04f;
|
||||
constexpr float FADE_IN_ALPHA_INSTANT = 1e-05f;
|
||||
constexpr int STAGE_ID_DEATH_CERTIFICATE = 35;
|
||||
|
||||
// How a co-op award is decided, beside its name.
|
||||
@@ -456,6 +469,145 @@ void Game::create_render_surfaces()
|
||||
surface_create(colormodSurface, COLORMOD_SURFACE);
|
||||
}
|
||||
|
||||
// 006f5320 Starts a new run on a character, challenge, seeds and difficulty: the run's seeds (a challenge's own
|
||||
// effects), whether progress is frozen, the item and boss pools, the player, the first floor (Backasswards' Dark Room),
|
||||
// then saves it, fades in from black and runs the first room's update and the mods' game start.
|
||||
void Game::Start(int playerType, uint32_t startChallenge, const Seeds& seeds, Difficulty startDifficulty)
|
||||
{
|
||||
Manager& manager = *g_manager;
|
||||
|
||||
isStarted = true;
|
||||
onlinePlayerStats._end = onlinePlayerStats._begin;
|
||||
for (CoopAward& award : coopAwards) award.userIds.clear();
|
||||
isOnlineStatsFinalized = false;
|
||||
difficulty = startDifficulty;
|
||||
challenge = startChallenge;
|
||||
trapdoorLoopVolume = 0;
|
||||
victoryLap = 0;
|
||||
isConsoleUsedThisRun = manager.isConsoleEnabled;
|
||||
hud.LoadGraphics();
|
||||
|
||||
if (seeds.gameStartSeed == 0) log_printf(LOG_ASSERT, "Start seed is not initialized");
|
||||
seedEffects = seeds;
|
||||
if (challenge != 0)
|
||||
{
|
||||
seedEffects.ClearSeedEffects();
|
||||
for (int effect : GetChallengeParams().seedEffects) seedEffects.AddSeedEffect(effect);
|
||||
}
|
||||
fortuneRNG.SetSeed(seedEffects.GetNextSeed(), FORTUNE_RNG_SHIFT);
|
||||
|
||||
bool isReadOnly = seedEffects.isCustomRun || seedEffects.AchievementUnlocksDisallowed() ||
|
||||
Manager::AchievementUnlocksDisallowed() || isRerun || challenge != 0;
|
||||
manager.persistentGameData.SetReadOnly(isReadOnly);
|
||||
uint32_t startSeed = seedEffects.GetStartSeed();
|
||||
std::string seedText = Seeds::Seed2String(seedEffects.GetStartSeed());
|
||||
log_printf(LOG_INFO, "RNG Start Seed: %s (%u) [New, %d]\n", seedText.c_str(), startSeed, manager.currentSaveSlot);
|
||||
|
||||
proceduralItemManager.Init();
|
||||
std::string itemPoolsPath = manager.modManager.TryRedirectPath(ITEM_POOLS_XML);
|
||||
itemPool.Init(seedEffects.GetNextSeed(), itemPoolsPath);
|
||||
bossPool.init(seedEffects.GetStartSeed());
|
||||
playerManager.init_main_player(playerType, seedEffects.GetPlayerInitSeed());
|
||||
SetNextStage();
|
||||
if (challenge == CHALLENGE_BACKASSWARDS) SetStage(STAGE_DARK_ROOM, STAGETYPE_ORIGINAL);
|
||||
Init(true);
|
||||
|
||||
std::vector<Entity_Player*> players = playerManager.playerList;
|
||||
for (Entity_Player* player : players)
|
||||
if (player->variant == PLAYER_VARIANT_PLAYER) player->InitPostLevelInitStats();
|
||||
|
||||
Manager::save_game_state();
|
||||
playerManager.trigger_new_room_effects();
|
||||
Fadein(START_FADE_SPEED, FADE_ICON_SHOW, kcolor_rgba(0, 0, 0, 1));
|
||||
pause_screen_reset(pauseScreen);
|
||||
encounteredBosses.clear();
|
||||
room->Update();
|
||||
framesSinceRoomTransition = 0;
|
||||
static_cast<LuaEngine*>(g_luaEngine)->PostGameStart(false);
|
||||
}
|
||||
|
||||
// 006f5210 Fades the screen in from a color at a speed, from full (or nearly no) cover as the instant fade asks, with
|
||||
// or without the loading icon. The players cannot move until it ends.
|
||||
void Game::Fadein(float speed, FadeIcon icon, KColor color)
|
||||
{
|
||||
fadeInColor = color;
|
||||
fadeInColor._alpha = isInstantFadeIn ? FADE_IN_ALPHA_INSTANT : 1;
|
||||
fadeSpeed = speed;
|
||||
isFadeInIconShown = icon == FADE_ICON_SHOW;
|
||||
for (Entity_Player* player : playerManager.playerList) player->isControlsEnabled = false;
|
||||
}
|
||||
|
||||
// 006f9000 Copies the run into a game state to save: its rules and seeds, the counters and histories of the run, the
|
||||
// Ascent's saved stages, the nightmare stage bar, the ambush wave, the score, the boss and item pools, then the floor
|
||||
// (after leaving the room), the players and the versus rules.
|
||||
// The saved flags are the first 53 of the run's state flags.
|
||||
void Game::store_game_state(GameState& state)
|
||||
{
|
||||
state.Clear();
|
||||
state.seeds = seedEffects;
|
||||
state.playerManagerSeed = playerManager.rng._seed;
|
||||
state.fortuneSeed = fortuneRNG._seed;
|
||||
state.challenge = (int)challenge;
|
||||
state.isRerun = isRerun;
|
||||
state.isConsoleUsedThisRun = isConsoleUsedThisRun;
|
||||
state.difficulty = difficulty;
|
||||
state.gameStateFlags = std::bitset<SAVED_GAME_STATE_FLAG_COUNT>(gameStateFlags);
|
||||
|
||||
state.lastDevilRoomStage = lastDevilRoomStage;
|
||||
state.treasureRoomsVisited = treasureRoomsVisited;
|
||||
state.planetariumsVisited = planetariumsVisited;
|
||||
state.stagesWithoutHeartsPicked = stagesWithoutHeartsPicked;
|
||||
state.stagesWithoutDamage = stagesWithoutDamage;
|
||||
state.devilRoomDeals = devilRoomDeals;
|
||||
state.shopVisits = shopVisits;
|
||||
state.donationModGreed = donationModGreed;
|
||||
state.donationModAngel = donationModAngel;
|
||||
state.reviveMachineCoinsLeft = reviveMachineCoinsLeft;
|
||||
state.reviveMachineUses = reviveMachineUses;
|
||||
state.bossRushParTime = bossRushParTime;
|
||||
state.blueWombParTime = blueWombParTime;
|
||||
state.frameCount = frameCount;
|
||||
state.timeCounter = timeCounter;
|
||||
state.stageNameNumeral = stageNameNumeral;
|
||||
state.victoryLap = victoryLap;
|
||||
state.lastLevelWithoutHalfHp = lastLevelWithoutHalfHp;
|
||||
state.lastLevelWithDamage = lastLevelWithDamage;
|
||||
state.encounteredBosses = encounteredBosses;
|
||||
state.pixelationTimer = pixelationTimer;
|
||||
state.pixelationDuration = pixelationDuration;
|
||||
state.magicSkinUses = magicSkinUses;
|
||||
state.erasedEntities = erasedEntities;
|
||||
|
||||
state.isAscent = ascentTimer > 0;
|
||||
state.backwardsStages = backwardsStages;
|
||||
state.deathCertificateExitTimer = deathCertificateExitTimer;
|
||||
state.nightmareStageIcons = g_manager->nightmareScene.stageIcons;
|
||||
state.isAmbushActive = ambush._isActive;
|
||||
state.ambushWave = ambush._currentWave > 0 ? ambush._currentWave - 1 : ambush._currentWave;
|
||||
scoreSheet.store_state(state.scoreSheet);
|
||||
|
||||
bossPool.store_game_state(state.bossPool);
|
||||
if (!proceduralItemManager.proceduralItems.empty())
|
||||
reconstruction_missing("Game::store_game_state 006f9000: the TMTRAINER items' seeds (ProceduralItem +0x8)");
|
||||
itemPool.StoreGameState(state.itemPool);
|
||||
reconstruction_missing("Game::store_game_state 006f9000: Room::on_leave 007efa50, Level::store_game_state "
|
||||
"00747e10, PlayerManager::store_game_state 009bd150 and the versus rules "
|
||||
"(DeathmatchTypeBase slot 1 and StoreGameState 0042bd70)");
|
||||
}
|
||||
|
||||
// 009b5cb0 Closes the pause screen for a new run on Resume, with its paper's animation stopped, the options listed
|
||||
// again, My Stuff closed and the quit prompt reset.
|
||||
// The original also stops the full-size paper and resets fields of it, which pause_screen.h leaves out.
|
||||
void pause_screen_reset(PauseScreen& pauseScreen)
|
||||
{
|
||||
pauseScreen.state = PAUSE_HIDDEN;
|
||||
pauseScreen.selectedElement = PAUSE_ITEM_RESUME;
|
||||
pauseScreen.menuSprite.animState.SetAnimationData(nullptr);
|
||||
pauseScreen.menuOptions.load_graphics();
|
||||
pauseScreen.myStuff.reset();
|
||||
pauseScreen.genericPrompt.Initialize(PROMPT_SMALL);
|
||||
}
|
||||
|
||||
void Game::Exit(bool)
|
||||
{
|
||||
reconstruction_missing("Game::Exit 006fa0c0");
|
||||
@@ -466,9 +618,317 @@ void Game::Update()
|
||||
reconstruction_missing("Game::Update 006fadc0");
|
||||
}
|
||||
|
||||
constexpr const char* BLOOM_SHADER = "Bloom";
|
||||
constexpr const char* COLOR_MOD_SHADER = "ColorMod";
|
||||
constexpr const char* COLOR_OFFSET_SHADER = "ColorOffset";
|
||||
constexpr const char* HALLUCINATION_SHADER = "Hallucination";
|
||||
constexpr const char* OLD_TV_SHADER = "OldTV";
|
||||
constexpr const char* PIXELATION_SHADER = "Pixelation";
|
||||
constexpr const char* SCREEN_SIZE_UNIFORM = "ScreenSize";
|
||||
constexpr KColor SCREEN_WHITE = kcolor_rgba(1, 1, 1, 1);
|
||||
constexpr RNG ROOM_SNAPSHOT_RNG = {0, 9, 5, 25};
|
||||
constexpr int ROOM_SNAPSHOT_FRAME = 30;
|
||||
constexpr uint32_t ROOM_SNAPSHOT_CHANCE = 3;
|
||||
constexpr int HALLUCINATION_FLASH_FRAMES = 20;
|
||||
constexpr float HALLUCINATION_FLASH_ALPHA = 0.5f;
|
||||
constexpr int HALLUCINATION_FADE_FRAMES = 10;
|
||||
constexpr float HALLUCINATION_CLEAR = 0.999f;
|
||||
constexpr uint32_t CLICKER_FLIPS = 4;
|
||||
constexpr float PIXELATION_SCALE = 0.3f;
|
||||
constexpr float PIXELATION_MIN = 0.0001f;
|
||||
constexpr float BLOOM_RATIO = 2;
|
||||
constexpr float OLD_TV_TIME_SCALE = 0.05f;
|
||||
constexpr float ASCENT_FADE_FRAMES = 90;
|
||||
constexpr uint32_t DEBUG_FLAG_PLAYER_INFO = 1 << 11;
|
||||
constexpr uint32_t DEBUG_FLAG_LUA_MEMORY = 1 << 13;
|
||||
constexpr int STAGE_TRANSITION_OUT = 2;
|
||||
constexpr int STAGE_TRANSITION_IN = 3;
|
||||
constexpr int ITEM_OVERLAY_SHOWING = 1;
|
||||
constexpr float PI = std::numbers::pi_v<float>;
|
||||
|
||||
// Draws a whole surface over the screen in a color.
|
||||
static void screen_surface_draw(KAGE::Graphics::ImageBase& surface, KColor color)
|
||||
{
|
||||
SourceQuad whole = KAGE::Graphics::source_quad_rect({}, vector_make(1, 1));
|
||||
whole._coordinateSpace = KAGE::Graphics::COORDINATES_NORMALIZED;
|
||||
surface.Render(whole, KAGE::Graphics::color_quad_rect({}, vector_make(g_screenWidth, g_screenHeight), SCREEN_WHITE),
|
||||
color);
|
||||
}
|
||||
|
||||
// Draws into an effect surface until effect_pass_end.
|
||||
static void effect_pass_begin(KAGE::Graphics::ImagePtr& surface)
|
||||
{
|
||||
KAGE::Graphics::manager.render_target_push(surface.get(), KAGE::Graphics::TARGET_SCREEN_SIZE,
|
||||
KAGE::Graphics::PRESENT_FLUSH);
|
||||
}
|
||||
|
||||
// Finishes an effect surface and goes back to the target before it, cleared.
|
||||
static void effect_pass_end()
|
||||
{
|
||||
KAGE::Graphics::Manager& graphics = KAGE::Graphics::manager;
|
||||
graphics.Present(KAGE::Graphics::PRESENT_FINISH);
|
||||
graphics.render_target_pop(KAGE::Graphics::PRESENT_FLUSH);
|
||||
graphics.Clear();
|
||||
}
|
||||
|
||||
// Makes an effect's shader current when it loaded, and sets one of its floats.
|
||||
static void effect_shader_set(std::string_view shaderName, std::string_view uniformName, float value)
|
||||
{
|
||||
shader_select(shaderName);
|
||||
KAGE::Graphics::Shader* shader = KAGE::Graphics::manager.currentShader;
|
||||
if (shader) shader->set_uniform(uniformName, KAGE::Graphics::UNIFORM_FLOAT, &value);
|
||||
}
|
||||
|
||||
// Gives the current shader a surface's size and its texture's as ScreenSize.
|
||||
static void screen_size_set(const KAGE::Graphics::ImageBase& surface)
|
||||
{
|
||||
std::array<float, 4> size = {(float)surface.width, (float)surface.height, (float)surface.textureWidth,
|
||||
(float)surface.textureHeight};
|
||||
KAGE::Graphics::Shader* shader = KAGE::Graphics::manager.currentShader;
|
||||
if (shader) shader->set_uniform(SCREEN_SIZE_UNIFORM, KAGE::Graphics::UNIFORM_VEC4, size.data());
|
||||
}
|
||||
|
||||
// Whether the screen pixelates: a pixelation room transition going out or coming in.
|
||||
// A stage transition decides with StageTransition's own check (009301d0), which waits for its takeover.
|
||||
static bool is_pixelating(Game& game)
|
||||
{
|
||||
int stageState = game.stageTransition._state;
|
||||
if (stageState == STAGE_TRANSITION_OUT || stageState == STAGE_TRANSITION_IN)
|
||||
reconstruction_missing("Game::Render 006fbc10: StageTransition's pixelation check 009301d0");
|
||||
return game.roomTransition.get_fade_progress() >= 0 && game.roomTransition.animation == TRANSITION_PIXELATION;
|
||||
}
|
||||
|
||||
// Whether this frame captures the room for a hallucination to flash back to: 30 frames into a room, the first room
|
||||
// of a run always, then one room in three by its spawn seed.
|
||||
// The original also captured while the flag held 0xff, which Game's bool no longer holds.
|
||||
static bool is_room_snapshot(Game& game)
|
||||
{
|
||||
if (game.room->GetFrameCount() != ROOM_SNAPSHOT_FRAME) return false;
|
||||
|
||||
RNG rng = ROOM_SNAPSHOT_RNG;
|
||||
rng._seed = game.room->descriptor->spawnSeed;
|
||||
return rng.Next() % ROOM_SNAPSHOT_CHANCE == 0 || !game.isRoomSnapshotTaken;
|
||||
}
|
||||
|
||||
// Draws the color modifier's surface back through its shader, in the modifier's color.
|
||||
static void color_modifier_resolve(Game& game)
|
||||
{
|
||||
KAGE::Graphics::Manager& graphics = KAGE::Graphics::manager;
|
||||
ColorModState& modifier = game.currentColorModifier;
|
||||
|
||||
effect_pass_end();
|
||||
shader_select(COLOR_MOD_SHADER);
|
||||
graphics.blendMode = KAGE::Graphics::BLEND_MODE_OPAQUE;
|
||||
if (KAGE::Graphics::Shader* shader = graphics.currentShader)
|
||||
{
|
||||
shader->set_uniform("Amount", KAGE::Graphics::UNIFORM_FLOAT, &modifier._amount);
|
||||
shader->set_uniform("Brightness", KAGE::Graphics::UNIFORM_FLOAT, &modifier._brightness);
|
||||
shader->set_uniform("Contrast", KAGE::Graphics::UNIFORM_FLOAT, &modifier._contrast);
|
||||
}
|
||||
screen_surface_draw(*game.colormodSurface, kcolor_rgba(modifier._red, modifier._green, modifier._blue, 1));
|
||||
graphics.blendMode.SetMode(KAGE::Graphics::BLEND_NORMAL);
|
||||
graphics.shader_default_set();
|
||||
}
|
||||
|
||||
// Draws the bloom surface back, glowing most halfway through the bloom.
|
||||
static void bloom_resolve(Game& game)
|
||||
{
|
||||
KAGE::Graphics::ImageBase& surface = *game.bloomSurface;
|
||||
float half = (float)game.bloomDuration * 0.5f;
|
||||
float amount = std::sin((1 - std::abs((float)game.bloomTimer - half) / half) * PI * 0.5f) * game.bloomStrength;
|
||||
std::array<float, 2> ratio = {BLOOM_RATIO / (float)surface.textureWidth,
|
||||
BLOOM_RATIO / (float)surface.textureHeight};
|
||||
|
||||
effect_pass_end();
|
||||
KAGE::Graphics::manager.blendMode = KAGE::Graphics::BLEND_MODE_OPAQUE;
|
||||
effect_shader_set(BLOOM_SHADER, "BloomAmount", amount);
|
||||
if (KAGE::Graphics::Shader* shader = KAGE::Graphics::manager.currentShader)
|
||||
shader->set_uniform("Ratio", KAGE::Graphics::UNIFORM_VEC2, ratio.data());
|
||||
screen_surface_draw(surface, SCREEN_WHITE);
|
||||
}
|
||||
|
||||
// Flashes the giant book clicker over a hallucination fading in or out, flipped another way each frame.
|
||||
static void clicker_render(Game& game, float amount)
|
||||
{
|
||||
KAGE::Graphics::ImageBase& clicker = *game.giantBookClickerImage;
|
||||
uint32_t flip = g_manager->framecount % CLICKER_FLIPS;
|
||||
bool isFlipX = flip == 1 || flip == 3;
|
||||
bool isFlipY = flip == 2 || flip == 3;
|
||||
float width = (float)clicker.width;
|
||||
float height = (float)clicker.height;
|
||||
Vector corner = vector_make(isFlipX ? width : 0, isFlipY ? height : 0);
|
||||
Vector size = vector_make(isFlipX ? -width : width, isFlipY ? -height : height);
|
||||
|
||||
shader_select(COLOR_OFFSET_SHADER);
|
||||
apply_sprite_shader_params(COLOR_DEFAULT, SPRITE_SHADER_COLOR_APPLY, clicker);
|
||||
clicker.Render(KAGE::Graphics::source_quad_rect(corner, size),
|
||||
KAGE::Graphics::color_quad_rect({}, vector_make(g_screenWidth, g_screenHeight), SCREEN_WHITE),
|
||||
kcolor_rgba(1, 1, 1, 1 - amount));
|
||||
}
|
||||
|
||||
// Draws the hallucination surface back through its shader, fading over its first and last 10 frames with the clicker.
|
||||
static void hallucination_resolve(Game& game)
|
||||
{
|
||||
int fadeOutStart = game.hallucinationDuration - HALLUCINATION_FADE_FRAMES;
|
||||
float amount = 1;
|
||||
if (game.hallucinationTimer > fadeOutStart)
|
||||
amount = 1 - (float)(game.hallucinationTimer - fadeOutStart) / HALLUCINATION_FADE_FRAMES;
|
||||
else if (game.hallucinationTimer < HALLUCINATION_FADE_FRAMES)
|
||||
amount = (float)game.hallucinationTimer / HALLUCINATION_FADE_FRAMES;
|
||||
|
||||
effect_pass_end();
|
||||
KAGE::Graphics::manager.blendMode = KAGE::Graphics::BLEND_MODE_OPAQUE;
|
||||
effect_shader_set(HALLUCINATION_SHADER, "Amount", amount);
|
||||
screen_size_set(*game.hallucinationSurface);
|
||||
screen_surface_draw(*game.hallucinationSurface, SCREEN_WHITE);
|
||||
if (amount < HALLUCINATION_CLEAR) clicker_render(game, amount);
|
||||
}
|
||||
|
||||
// Draws what a run shows over its room: the debug shapes, the HUD, the transitions and overlays, then the prompts and
|
||||
// menus of a run between the popup layers, and the mods' shaders.
|
||||
// The debug shapes stay empty until DebugRenderer's takeover, and the online stats screen never shows offline.
|
||||
static void overlays_render(Game& game)
|
||||
{
|
||||
KAGE::Graphics::Manager& graphics = KAGE::Graphics::manager;
|
||||
PopupQueue& popups = g_manager->popupQueue;
|
||||
bool isFighting = game.deathmatchManager.state == DEATHMATCH_FIGHT;
|
||||
int stageState = game.stageTransition._state;
|
||||
|
||||
popups.render_layer(0);
|
||||
game.hud.Render();
|
||||
if (isFighting) game.deathmatchManager.type->FUN_0042aca0();
|
||||
if (stageState == STAGE_TRANSITION_OUT || stageState == STAGE_TRANSITION_IN) game.stageTransition.Render();
|
||||
else graphics.blendMode.SetMode(KAGE::Graphics::BLEND_NORMAL);
|
||||
if (game.itemOverlay._state != 0 && game.itemOverlay._state != ITEM_OVERLAY_SHOWING) game.itemOverlay.Render();
|
||||
if (game.bossOverlay._state != 0) reconstruction_missing("Game::Render 006fbc10: BossOverlay's render 00421400");
|
||||
popups.render_layer(1);
|
||||
|
||||
const AnimationState& prompt = game.genericPrompt.sprite.animState;
|
||||
if (prompt.animData && prompt.isPlaying)
|
||||
{
|
||||
game.genericPrompt.Render();
|
||||
if (game.genericPrompt.isOnlineVote)
|
||||
reconstruction_missing("Game::Render 006fbc10: the online vote count under the prompt");
|
||||
}
|
||||
if (game.pauseScreen.state != PAUSE_HIDDEN) game.pauseScreen.Render();
|
||||
game.emoteWheel.Render();
|
||||
game.revivePlayerMenu.Render();
|
||||
if (game.gameOver._state != 0) game.gameOver.Render();
|
||||
game.leaderboard.Render();
|
||||
popups.render_layer(2);
|
||||
|
||||
for (auto& mod : g_manager->modManager.mods)
|
||||
if (mod->isLoaded && !mod->shaders.empty())
|
||||
reconstruction_missing("Game::Render 006fbc10: the mods' shaders 008f74c0");
|
||||
}
|
||||
|
||||
// Resolves the effect surfaces in turn (the room snapshot, bloom, pixelation, hallucination, old TV), then draws the
|
||||
// Ascent's white, the fade in (with the loading icon) or out, and the debug displays.
|
||||
static void effects_resolve(Game& game, bool isRoomSnapshot, bool isOldTv)
|
||||
{
|
||||
KAGE::Graphics::Manager& graphics = KAGE::Graphics::manager;
|
||||
OptionsConfig& options = g_manager->optionsConfig;
|
||||
Vector screen = vector_make(g_screenWidth, g_screenHeight);
|
||||
|
||||
if (isRoomSnapshot)
|
||||
{
|
||||
effect_pass_end();
|
||||
graphics.blendMode = KAGE::Graphics::BLEND_MODE_OPAQUE;
|
||||
screen_surface_draw(*game.hallucinationSnapshot, SCREEN_WHITE);
|
||||
}
|
||||
if (game.bloomTimer > 0 && options.render.isBloomEnabled) bloom_resolve(game);
|
||||
if (options.render.isPixelationEnabled && is_pixelating(game))
|
||||
{
|
||||
effect_pass_end();
|
||||
float amount = std::max(game.roomTransition.get_fade_progress() * PIXELATION_SCALE, PIXELATION_MIN);
|
||||
effect_shader_set(PIXELATION_SHADER, "PixelationAmount", amount);
|
||||
screen_size_set(*game.pixelationSurface);
|
||||
screen_surface_draw(*game.pixelationSurface, SCREEN_WHITE);
|
||||
}
|
||||
if (game.hallucinationTimer > 0) hallucination_resolve(game);
|
||||
if (isOldTv)
|
||||
{
|
||||
effect_pass_end();
|
||||
graphics.blendMode = KAGE::Graphics::BLEND_MODE_OPAQUE;
|
||||
effect_shader_set(OLD_TV_SHADER, "Time", (float)game.frameCount * OLD_TV_TIME_SCALE);
|
||||
screen_size_set(*game.oldTvSurface);
|
||||
screen_surface_draw(*game.oldTvSurface, SCREEN_WHITE);
|
||||
}
|
||||
graphics.shader_default_set();
|
||||
|
||||
if (game.ascentTimer > 0)
|
||||
{
|
||||
float alpha = std::clamp((float)game.ascentTimer / ASCENT_FADE_FRAMES, 0.0f, 1.0f);
|
||||
graphics.blendMode.SetMode(KAGE::Graphics::BLEND_ADDITIVE);
|
||||
render_color_shader_pass(KAGE::Graphics::color_quad_rect({}, screen, kcolor_rgba(1, 1, 1, alpha)));
|
||||
graphics.blendMode.SetMode(KAGE::Graphics::BLEND_NORMAL);
|
||||
}
|
||||
if (game.fadeInColor._alpha > 0)
|
||||
{
|
||||
graphics.blendMode.SetMode(KAGE::Graphics::BLEND_NORMAL);
|
||||
render_color_shader_pass(KAGE::Graphics::color_quad_rect({}, screen, game.fadeInColor));
|
||||
if (game.isFadeInIconShown) Manager::render_loading_icon(game.fadeInColor._alpha);
|
||||
}
|
||||
else if (game.fadeOutColor._alpha > 0)
|
||||
render_color_shader_pass(KAGE::Graphics::color_quad_rect({}, screen, game.fadeOutColor));
|
||||
|
||||
if (game.debugFlags & DEBUG_FLAG_PLAYER_INFO && !game.playerManager.playerList.empty())
|
||||
reconstruction_missing("Game::Render 006fbc10: the player debug info");
|
||||
if (game.debugFlags & DEBUG_FLAG_LUA_MEMORY) reconstruction_missing("render_debug_lua_memory 00872090");
|
||||
}
|
||||
|
||||
// 006fbc10 Draws the run's frame. The room, or the room transition, draws through the effect surfaces that are on (old
|
||||
// TV, hallucination, pixelation, bloom, the room snapshot and the color modifier) with Lua's post render and a
|
||||
// hallucination's flash back to the snapshot. The overlays of a run come over it, then the effects resolve, and the
|
||||
// console comes last. A versus screen shows without the color modifier.
|
||||
// The online parts (the vote count, the stats screen, the desync warning) never show offline.
|
||||
void Game::Render()
|
||||
{
|
||||
reconstruction_missing("Game::Render 006fbc10");
|
||||
KAGE::Graphics::Manager& graphics = KAGE::Graphics::manager;
|
||||
OptionsConfig& options = g_manager->optionsConfig;
|
||||
bool isFighting = deathmatchManager.state == DEATHMATCH_FIGHT;
|
||||
bool isOldTv = seedEffects.HasSeedEffect(SEED_OLD_TV);
|
||||
bool isTransitionShown = roomTransition.mode == TRANSITION_OUT || roomTransition.mode == TRANSITION_IN;
|
||||
|
||||
if (isWindowResizePending) reconstruction_missing("Game::recreate_render_targets 007084c0");
|
||||
room->render_lighting();
|
||||
if (isFighting) deathmatchManager.type->vfunc_5();
|
||||
if (isOldTv) effect_pass_begin(oldTvSurface);
|
||||
if (hallucinationTimer > 0) effect_pass_begin(hallucinationSurface);
|
||||
if (options.render.isPixelationEnabled && is_pixelating(*this)) effect_pass_begin(pixelationSurface);
|
||||
if (bloomTimer > 0 && options.render.isBloomEnabled)
|
||||
{
|
||||
graphics.Clear();
|
||||
effect_pass_begin(bloomSurface);
|
||||
}
|
||||
bool isRoomSnapshot = is_room_snapshot(*this);
|
||||
if (isRoomSnapshot)
|
||||
{
|
||||
effect_pass_begin(hallucinationSnapshot);
|
||||
isRoomSnapshotTaken = true;
|
||||
}
|
||||
g_manager->modManager.shader_render_targets_push();
|
||||
bool isVersusScreen = roomTransition.mode == TRANSITION_OUT && roomTransition.bossIntroBossId != 0;
|
||||
bool isColorModified = !isVersusScreen && options.render.isColorModifierEnabled;
|
||||
if (isColorModified) effect_pass_begin(colormodSurface);
|
||||
|
||||
graphics.Clear();
|
||||
graphics.blendMode.SetMode(KAGE::Graphics::BLEND_NORMAL);
|
||||
if (isTransitionShown) roomTransition.Render();
|
||||
else room->Render();
|
||||
static_cast<LuaEngine*>(g_luaEngine)->PostRender();
|
||||
bool isFlashing = hallucinationTimer > std::max(hallucinationDuration - HALLUCINATION_FLASH_FRAMES, 0);
|
||||
if (isFlashing && !isRoomSnapshot && hallucinationSnapshot)
|
||||
{
|
||||
int flashFrame = hallucinationTimer - hallucinationDuration + HALLUCINATION_FLASH_FRAMES;
|
||||
float alpha = std::sin((float)flashFrame * PI / HALLUCINATION_FLASH_FRAMES) * HALLUCINATION_FLASH_ALPHA;
|
||||
screen_surface_draw(*hallucinationSnapshot, kcolor_rgba(1, 1, 1, alpha));
|
||||
}
|
||||
if (isColorModified) color_modifier_resolve(*this);
|
||||
|
||||
overlays_render(*this);
|
||||
effects_resolve(*this, isRoomSnapshot, isOldTv);
|
||||
console.Render();
|
||||
}
|
||||
|
||||
// 006fd350 Whether the run's frame stands still: an open console or pause menu while offline, a freeze, the death or
|
||||
@@ -480,7 +940,7 @@ bool Game::IsPaused()
|
||||
|
||||
if (console.state != CONSOLE_CLOSED && isOffline) return true;
|
||||
return freezeFrames > 0 || gameOver._state != 0 || leaderboard.displayState != LEADERBOARD_HIDDEN ||
|
||||
stageTransition._state != 0 || roomTransition._mode != 0 || itemOverlay._state == ITEM_OVERLAY_ACTIVE ||
|
||||
stageTransition._state != 0 || roomTransition.mode != 0 || itemOverlay._state == ITEM_OVERLAY_ACTIVE ||
|
||||
(pauseScreen.is_pausing() && isOffline) || g_manager->state != MANAGER_STATE_GAME ||
|
||||
genericPrompt.IsActive() || onlineStatsScreen.isActive;
|
||||
}
|
||||
@@ -495,7 +955,7 @@ bool Game::IsGreedMode()
|
||||
// Certificate floor in its dimension, else the floor's stage and type. It never used its argument.
|
||||
int Game::GetStageID()
|
||||
{
|
||||
if (g_game->challenge == CHALLENGE_BACKASSWARDS)
|
||||
if (g_game->challenge == CHALLENGE_RED_REDEMPTION)
|
||||
reconstruction_missing("Game::GetStageID 00738470: Level::GetRoomStageType 0074f690 on Game's room list");
|
||||
if (currentDimensionIdx == DIMENSION_DEATH_CERTIFICATE) return STAGE_ID_DEATH_CERTIFICATE;
|
||||
return RoomConfig::GetStageID(stage, stageType, ROOM_MODE_CURRENT);
|
||||
|
||||
Reference in new issue
Block a user