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>
This commit is contained in:
1 parent
b85591bdf4
commit
69a354f843
140 files changed
+23561
-20206
No files matched your search
+253
-24
@@ -1,12 +1,77 @@
|
||||
#include "entity_effect.h"
|
||||
#include "entity_tear.h"
|
||||
#include "game.h"
|
||||
#include "log.h"
|
||||
#include "lua_engine.h"
|
||||
#include "manager.h"
|
||||
#include "room.h"
|
||||
#include "sfx_manager.h"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
|
||||
// The creep variants the players leave (holy water trail, black, red, white, holy water, green, Lemon Mishap, Lemon
|
||||
// Party, 204, Black Powder, milk, Black Powder's pentagram).
|
||||
constexpr std::array<int, 12> PLAYER_CREEPS = {54, 45, 46, 44, 37, 53, 32, 78, 204, 92, 90, 93};
|
||||
|
||||
constexpr int EFFECT_BLOOD_SPLAT = 7;
|
||||
constexpr int EFFECT_BULLET_POOF = 11;
|
||||
constexpr int EFFECT_TEAR_POOF_A = 12;
|
||||
constexpr int EFFECT_TEAR_POOF_B = 13;
|
||||
constexpr int EFFECT_RIPPLE_POOF = 14;
|
||||
constexpr int EFFECT_TEAR_POOF_SMALL = 79;
|
||||
constexpr int EFFECT_TEAR_POOF_VERYSMALL = 80;
|
||||
constexpr int EFFECT_IMPACT = 97;
|
||||
constexpr int EFFECT_BOOMERANG = 60;
|
||||
constexpr int EFFECT_PORTAL_TELEPORT = 161;
|
||||
constexpr int EFFECT_TIMER = 119;
|
||||
constexpr int EFFECT_ENEMY_SOUL = 179;
|
||||
constexpr int EFFECT_ANIMA_CHAIN = 193;
|
||||
constexpr int EFFECT_REDEMPTION = 185;
|
||||
|
||||
// The variants whose Init, Update and Render are reconstructed: the tear poofs and the blood stains.
|
||||
constexpr std::array<int, 8> EFFECT_RECONSTRUCTED_VARIANTS = {
|
||||
EFFECT_BLOOD_SPLAT, EFFECT_BULLET_POOF, EFFECT_TEAR_POOF_A, EFFECT_TEAR_POOF_B,
|
||||
EFFECT_RIPPLE_POOF, EFFECT_TEAR_POOF_SMALL, EFFECT_TEAR_POOF_VERYSMALL, EFFECT_IMPACT};
|
||||
// The poofs that turn with their rotation.
|
||||
constexpr std::array<int, 5> EFFECT_TURNED_POOFS = {EFFECT_TEAR_POOF_A, EFFECT_TEAR_POOF_B, EFFECT_TEAR_POOF_SMALL,
|
||||
EFFECT_TEAR_POOF_VERYSMALL, EFFECT_IMPACT};
|
||||
|
||||
// The blood stain animations by the scale it was spawned at: the first whose limit is above it, the last past all.
|
||||
constexpr std::array<float, 5> STAIN_SCALE_LIMITS = {0.4f, 0.6f, 0.8f, 1.2f, 2.0f};
|
||||
constexpr std::array<const char*, 6> STAIN_ANIMATIONS = {"Size1BloodStains", "Size2BloodStains", "Size3BloodStains",
|
||||
"Size4BloodStains", "Size5BloodStains", "Size6BloodStains"};
|
||||
constexpr float STAIN_ALPHA_MIN = 0.5f;
|
||||
constexpr float STAIN_ALPHA_STEP = 0.1f;
|
||||
constexpr int STAIN_ALPHA_STEPS = 6;
|
||||
|
||||
// The ripple poof's animations for small spawn scales, which it draws larger.
|
||||
constexpr float RIPPLE_TINY_SCALE = 0.5f;
|
||||
constexpr float RIPPLE_SMALL_SCALE = 0.75f;
|
||||
constexpr float RIPPLE_TINY_GROWTH = 2;
|
||||
constexpr float RIPPLE_SMALL_GROWTH = 1.33333f;
|
||||
|
||||
constexpr float PAUSE_VELOCITY_DECAY = 0.6f;
|
||||
constexpr float RIGHT_ANGLE = 90;
|
||||
constexpr int SOUND_BOOMERANG_LOOP = 837;
|
||||
constexpr int SOUND_PORTAL_ENTITY_LOOP = 846;
|
||||
constexpr int SOUND_CHAIN_LOOP = 503;
|
||||
constexpr int LUA_CALLBACK_POST_EFFECT_INIT = 54;
|
||||
constexpr int LUA_CALLBACK_POST_EFFECT_UPDATE = 55;
|
||||
constexpr int LUA_CALLBACK_POST_EFFECT_RENDER = 56;
|
||||
|
||||
// Stops where a mod has a function for one of the effect's Lua callbacks, which LuaEngine does not run yet.
|
||||
static void lua_callback_check(int callback, const char* name)
|
||||
{
|
||||
if (static_cast<LuaEngine*>(g_luaEngine)->enabledCallbacks[callback]) reconstruction_missing(name);
|
||||
}
|
||||
|
||||
template <size_t N>
|
||||
static bool is_listed(const std::array<int, N>& list, int value)
|
||||
{
|
||||
return std::find(list.begin(), list.end(), value) != list.end();
|
||||
}
|
||||
|
||||
// 0060c400 Only a boss spawn pentagram holds the doors shut.
|
||||
bool Entity_Effect::CanShutDoors()
|
||||
{
|
||||
@@ -45,62 +110,226 @@ bool Entity_Effect::IsPlayerCreep(int effectVariant)
|
||||
return std::find(PLAYER_CREEPS.begin(), PLAYER_CREEPS.end(), effectVariant) != PLAYER_CREEPS.end();
|
||||
}
|
||||
|
||||
// The rest of Entity_Effect is not reconstructed yet.
|
||||
|
||||
// 005cdb20
|
||||
void Entity_Effect::Init(int, int, int, uint32_t)
|
||||
// 005cdb20 Starts the effect from its config's sprite with no timeout, rotation or extra data. A crawlspace removes
|
||||
// its blood stains at once. The tear poofs face a random quarter turn and the ripple a random side.
|
||||
// Only the tear poofs and the blood stains are reconstructed yet.
|
||||
void Entity_Effect::Init(int entityType, int entityVariant, int entitySubType, uint32_t seed)
|
||||
{
|
||||
reconstruction_missing("Entity_Effect::Init 005cdb20");
|
||||
extraData.reset();
|
||||
Entity::Init(entityType, entityVariant, entitySubType, seed);
|
||||
hitList.clear();
|
||||
maxHitPoints = 0;
|
||||
if (config)
|
||||
{
|
||||
sprite.Load(config->anm2Path, GRAPHICS_DEFER);
|
||||
sprite.Play(sprite.GetDefaultAnimationName());
|
||||
}
|
||||
|
||||
state = 0;
|
||||
timeout = -1;
|
||||
lifespan = 1;
|
||||
parentOffset = {};
|
||||
rotation = 0;
|
||||
isFollowing = false;
|
||||
scale = 1;
|
||||
minRadius = 0;
|
||||
maxRadius = 0;
|
||||
damageSource = 0;
|
||||
varData = {};
|
||||
if (!is_listed(EFFECT_RECONSTRUCTED_VARIANTS, variant))
|
||||
reconstruction_missing("Entity_Effect::Init 005cdb20: this effect variant");
|
||||
if (g_game->room->roomType == ROOM_DUNGEON && variant == EFFECT_BLOOD_SPLAT)
|
||||
{
|
||||
isVisible = false;
|
||||
return Remove();
|
||||
}
|
||||
|
||||
if (variant == EFFECT_BLOOD_SPLAT) sortingLayer = SORTING_BACKGROUND;
|
||||
if (variant == EFFECT_RIPPLE_POOF)
|
||||
{
|
||||
sortingLayer = SORTING_BACKGROUND;
|
||||
sprite.isFlipX = Random() & 1;
|
||||
}
|
||||
entityGridCollisionClass = GRIDCOLL_NONE;
|
||||
entityCollisionClass = ENTCOLL_NONE;
|
||||
if (is_listed(EFFECT_TURNED_POOFS, variant))
|
||||
{
|
||||
rotation = (float)(Random() & 3) * RIGHT_ANGLE;
|
||||
isUnknown176 = true;
|
||||
}
|
||||
if (variant == EFFECT_IMPACT) sprite.isFlipX = !(Random() & 1);
|
||||
|
||||
sprite.LoadGraphics();
|
||||
if (g_game->deathmatchManager.is_active())
|
||||
reconstruction_missing("Entity_Effect::Init 005cdb20: the versus mode's entity registration");
|
||||
lua_callback_check(LUA_CALLBACK_POST_EFFECT_INIT, "LuaEngine::PostEffectInit 00861330");
|
||||
}
|
||||
|
||||
// 005d4380
|
||||
// 005d4380 Runs the effect for a frame at the room's time scale, held in place while paused and kept on its parent
|
||||
// while following it, then counts its timeout down to its death.
|
||||
void Entity_Effect::Update()
|
||||
{
|
||||
reconstruction_missing("Entity_Effect::Update 005d4380");
|
||||
speedMultiplier = g_game->room->GetTimeScale(this);
|
||||
if (pauseTimer != 0)
|
||||
{
|
||||
uint64_t savedFlags = flags;
|
||||
bool wasDead = isDead;
|
||||
|
||||
if (pausePosition.x == 0 && pausePosition.y == 0) pausePosition = pos;
|
||||
if (pauseTimer > 0) pauseTimer--;
|
||||
pos = pausePosition;
|
||||
velocity = vector_make(velocity.x * PAUSE_VELOCITY_DECAY, velocity.y * PAUSE_VELOCITY_DECAY);
|
||||
AddEntityFlags(FLAG_NO_SPRITE_UPDATE);
|
||||
Entity::Update();
|
||||
flags = savedFlags;
|
||||
if (wasDead == isDead) return;
|
||||
}
|
||||
|
||||
Entity::Update();
|
||||
if (isFollowing && parent)
|
||||
{
|
||||
pos = vector_make(parent->pos.x + parentOffset.x, parent->pos.y + parentOffset.y);
|
||||
velocity = parent->velocity;
|
||||
posOffset = parent->posOffset;
|
||||
}
|
||||
else if (isFollowing)
|
||||
{
|
||||
velocity = {};
|
||||
isFollowing = false;
|
||||
}
|
||||
|
||||
if (variant == EFFECT_BLOOD_SPLAT) stain_update();
|
||||
else poof_update();
|
||||
if (timeout > 0 && --timeout < 1) isDead = true;
|
||||
pausePosition = pos;
|
||||
lua_callback_check(LUA_CALLBACK_POST_EFFECT_UPDATE, "LuaEngine::PostEffectUpdate 00861410");
|
||||
}
|
||||
|
||||
// 005d2520
|
||||
// Turns a poof by its rotation, mirrored unless flipped, and removes it once its animation ends. A ripple first
|
||||
// draws its small sizes larger with their own animations.
|
||||
void Entity_Effect::poof_update()
|
||||
{
|
||||
if (variant == EFFECT_RIPPLE_POOF && state == 0)
|
||||
{
|
||||
float spawnScale = sprite.scale.x;
|
||||
if (spawnScale <= RIPPLE_TINY_SCALE)
|
||||
{
|
||||
sprite.scale = vector_make(sprite.scale.x * RIPPLE_TINY_GROWTH, sprite.scale.y * RIPPLE_TINY_GROWTH);
|
||||
sprite.Play("Poof_Tiny");
|
||||
}
|
||||
else if (spawnScale <= RIPPLE_SMALL_SCALE)
|
||||
{
|
||||
sprite.scale = vector_make(sprite.scale.x * RIPPLE_SMALL_GROWTH, sprite.scale.y * RIPPLE_SMALL_GROWTH);
|
||||
sprite.Play("Poof_Small");
|
||||
}
|
||||
state = 1;
|
||||
}
|
||||
sprite.rotation = sprite.isFlipX ? rotation : -rotation;
|
||||
if (sprite.IsFinished()) Remove();
|
||||
}
|
||||
|
||||
// Settles a blood stain on its first update: the stain animation for the scale it was spawned at on a random frame,
|
||||
// its own scale, random flips, a random strength for an opaque color, and the floor to be drawn into.
|
||||
// A glowing stain, whose color is brighter than white, fades with a light instead, which is not reconstructed yet.
|
||||
void Entity_Effect::stain_update()
|
||||
{
|
||||
if (state != 0) reconstruction_missing("Entity_Effect::Update 005d4380: a glowing blood stain's fade");
|
||||
float spawnScale = sprite.scale.x;
|
||||
sprite.scale = vector_make(scale, scale);
|
||||
|
||||
auto limit = std::find_if(STAIN_SCALE_LIMITS.begin(), STAIN_SCALE_LIMITS.end(),
|
||||
[spawnScale](float scaleLimit) { return spawnScale < scaleLimit; });
|
||||
const char* animation = STAIN_ANIMATIONS[limit - STAIN_SCALE_LIMITS.begin()];
|
||||
if (const AnimationData* data = sprite.GetAnimationData(animation))
|
||||
sprite.SetFrame(animation, (int)(data->length == 0 ? 0 : Random() % (uint32_t)data->length));
|
||||
sprite.isFlipX = Random() % 2 == 0;
|
||||
sprite.isFlipY = Random() % 2 == 0;
|
||||
|
||||
ColorMod stainColor = sprite.color;
|
||||
bool isGlowing = color._tint[3] > 1;
|
||||
if (stainColor._tint[3] >= 1)
|
||||
stainColor._tint[3] = (float)(Random() % STAIN_ALPHA_STEPS) * STAIN_ALPHA_STEP + STAIN_ALPHA_MIN;
|
||||
sprite.color = stainColor;
|
||||
if (isGlowing) reconstruction_missing("Entity_Effect::Update 005d4380: a glowing blood stain");
|
||||
AddEntityFlags(FLAG_RENDER_FLOOR);
|
||||
}
|
||||
|
||||
// 005d2520 Moves the effect half a step between updates, keeping a following effect on its parent.
|
||||
void Entity_Effect::Interpolate()
|
||||
{
|
||||
reconstruction_missing("Entity_Effect::Interpolate 005d2520");
|
||||
if (pauseTimer != 0) return;
|
||||
|
||||
Entity::Interpolate();
|
||||
if (!isFollowing || !parent) return;
|
||||
pos = vector_make(parent->pos.x + parentOffset.x, parent->pos.y + parentOffset.y);
|
||||
posOffset = parent->posOffset;
|
||||
}
|
||||
|
||||
// 00607620
|
||||
void Entity_Effect::Render(const Vector&)
|
||||
// 00607620 Draws the effect's sprite at its place on screen.
|
||||
void Entity_Effect::Render(const Vector& offset)
|
||||
{
|
||||
reconstruction_missing("Entity_Effect::Render 00607620");
|
||||
if (!isVisible) return;
|
||||
|
||||
Vector screen = render_position_get(vector_make(pos.x + posOffset.x, pos.y + posOffset.y), RENDER_SNAPPED);
|
||||
renderPosition = vector_make(screen.x + offset.x, screen.y + offset.y);
|
||||
sprite.Render(SpriteDraw{renderPosition, {}, {}});
|
||||
lua_callback_check(LUA_CALLBACK_POST_EFFECT_RENDER, "LuaEngine::PostEffectRender 008614f0");
|
||||
}
|
||||
|
||||
// 005d2420
|
||||
// 005d2420 Stops the boomerang and portal loops unless another such effect still plays them, then removes it.
|
||||
void Entity_Effect::Remove()
|
||||
{
|
||||
reconstruction_missing("Entity_Effect::Remove 005d2420");
|
||||
bool isBoomerangShared = false;
|
||||
bool isPortalShared = false;
|
||||
|
||||
for (Entity* entity : g_game->room->entityList.updateEL)
|
||||
{
|
||||
if (entity->type != ENTITY_EFFECT || entity == this) continue;
|
||||
if (entity->variant == EFFECT_BOOMERANG) isBoomerangShared = true;
|
||||
else if (entity->variant == EFFECT_PORTAL_TELEPORT) isPortalShared = true;
|
||||
}
|
||||
if (!isBoomerangShared) g_manager->sfxManager.Stop(SOUND_BOOMERANG_LOOP);
|
||||
if (!isPortalShared) g_manager->sfxManager.Stop(SOUND_PORTAL_ENTITY_LOOP);
|
||||
Entity::Remove();
|
||||
}
|
||||
|
||||
// 0060c370
|
||||
// 0060c370 Glowing Hourglass removes a timer, and sets Redemption back to idle.
|
||||
void Entity_Effect::TriggerGlowingHourglass()
|
||||
{
|
||||
reconstruction_missing("Entity_Effect::guard_check_icall 0060c370");
|
||||
if (variant == EFFECT_REDEMPTION)
|
||||
reconstruction_missing("Entity_Effect::TriggerGlowingHourglass 0060c370: Redemption's idle restart");
|
||||
if (variant == EFFECT_TIMER) Remove();
|
||||
}
|
||||
|
||||
// 0060abb0
|
||||
// 0060abb0 Gives an enemy soul to the player it flew to and stops a hidden Anima chain's sound, then lets go of its
|
||||
// links and extra data.
|
||||
void Entity_Effect::ClearReferences()
|
||||
{
|
||||
reconstruction_missing("Entity_Effect::ClearReferences 0060abb0");
|
||||
if (variant == EFFECT_ENEMY_SOUL && target && target->type == ENTITY_PLAYER)
|
||||
reconstruction_missing("Entity_Effect::ClearReferences 0060abb0: the Urn of Souls' soul");
|
||||
if (variant == EFFECT_ANIMA_CHAIN && subtype == 0 && !isVisible) g_manager->sfxManager.Stop(SOUND_CHAIN_LOOP);
|
||||
Entity::ClearReferences();
|
||||
extraData.reset();
|
||||
}
|
||||
|
||||
// 004564b0 Follows an entity, keeping the offset it has from it now.
|
||||
// The original reads a null entity's position and crashes. This only lets go of the parent.
|
||||
void Entity_Effect::FollowParent(Entity* newParent)
|
||||
{
|
||||
parent = newParent;
|
||||
if (!newParent) return;
|
||||
isFollowing = true;
|
||||
parentOffset = vector_make(pos.x - newParent->pos.x, pos.y - newParent->pos.y);
|
||||
}
|
||||
|
||||
// The rest of Entity_Effect is not reconstructed yet.
|
||||
|
||||
// 00435290
|
||||
void Entity_Effect::render_player_target(const Vector&, int)
|
||||
{
|
||||
reconstruction_missing("Entity_Effect::render_player_target 00435290");
|
||||
}
|
||||
|
||||
// 004564b0
|
||||
void Entity_Effect::FollowParent(Entity*)
|
||||
{
|
||||
reconstruction_missing("Entity_Effect::FollowParent 004564b0");
|
||||
}
|
||||
|
||||
// 005d2a70
|
||||
void Entity_Effect::update_mr_me()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user