Curation round 9: floors and walls, room transitions, collision, the first enemies, saving, damage, pickups
Seven agents took over the backdrop's floor and wall rendering, room transitions (StartRoomTransition, on_leave, room_enter), grid collision with tear hits and decal baking, Entity_NPC's core with the AI dispatch and the first enemies (flies, Gaper, Pooter, Clotty, Horf, Dip, Spider), the run's save, player damage, PlayerManager::Update, ShowName, pickups, slots and the common effects. Integration added LuaEngine::PostNewLevel/PostNewRoom, one shared lua_callback_check (4 copies merged) and the enemy type range the original checks. Under gdb a run draws its rooms with floors and walls, walks between rooms, fights Gapers with contact damage and the damage flash, and collects pickups. Next: tears hitting enemies, pathfinding, item pedestals, death. 2891 functions taken over. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
69a354f843
commit
48933cd312
59 files changed
+13387
-6056
No files matched your search
+189
-12
@@ -1,26 +1,203 @@
|
||||
#include "entity_slot.h"
|
||||
#include "entity_config.h"
|
||||
#include "game.h"
|
||||
#include "log.h"
|
||||
#include "manager.h"
|
||||
#include "room.h"
|
||||
#include <array>
|
||||
|
||||
// Lua's SlotVariant: the machines and beggars.
|
||||
enum SlotVariant : int
|
||||
{
|
||||
SLOT_MACHINE = 1,
|
||||
SLOT_BLOOD_DONATION_MACHINE,
|
||||
SLOT_FORTUNE_TELLING_MACHINE,
|
||||
SLOT_BEGGAR,
|
||||
SLOT_DEVIL_BEGGAR,
|
||||
SLOT_SHELL_GAME,
|
||||
SLOT_KEY_MASTER,
|
||||
SLOT_DONATION_MACHINE,
|
||||
SLOT_BOMB_BUM,
|
||||
SLOT_SHOP_RESTOCK_MACHINE,
|
||||
SLOT_GREED_DONATION_MACHINE,
|
||||
SLOT_MOMS_DRESSER,
|
||||
SLOT_BATTERY_BUM,
|
||||
SLOT_ISAAC_SECRET,
|
||||
SLOT_HELL_GAME,
|
||||
SLOT_CRANE_GAME,
|
||||
SLOT_CONFESSIONAL,
|
||||
SLOT_ROTTEN_BEGGAR,
|
||||
SLOT_REVIVE_MACHINE
|
||||
};
|
||||
|
||||
// The event counters the donation machines show (DONATION_MACHINE_COUNTER, GREED_DONATION_MACHINE_COUNTER).
|
||||
constexpr int EVENT_DONATION_MACHINE = 20;
|
||||
constexpr int EVENT_GREED_DONATION_MACHINE = 115;
|
||||
|
||||
// The run's state flags of a broken or jammed donation machine.
|
||||
constexpr int GAME_STATE_DONATION_SLOT_BROKEN = 17;
|
||||
constexpr int GAME_STATE_DONATION_SLOT_JAMMED = 18;
|
||||
constexpr int GAME_STATE_GREED_SLOT_JAMMED = 34;
|
||||
|
||||
// The animations a jammed donation machine plays, one at random.
|
||||
constexpr std::array<const char*, 4> COIN_JAM_ANIMATIONS = {"CoinJam", "CoinJam2", "CoinJam3", "CoinJam4"};
|
||||
|
||||
constexpr int SLOT_STATE_IDLE = 1;
|
||||
constexpr int SLOT_STATE_JAMMED = 3;
|
||||
constexpr int REVIVE_MACHINE_EXCLUDED_ROOM = -20;
|
||||
constexpr int DIGIT_BASE = 10;
|
||||
constexpr int HUNDREDS = 100;
|
||||
constexpr float MACHINE_OFFSET_Y = -8;
|
||||
constexpr float BEGGAR_OFFSET_Y = 8;
|
||||
constexpr float BLOOD_MACHINE_OFFSET_X = -5;
|
||||
constexpr float MACHINE_WIDTH = 1.5f;
|
||||
constexpr float SHELL_GAME_WIDTH = 3;
|
||||
constexpr float MACHINE_DEPTH = 0.75f;
|
||||
|
||||
// Whether the run counts toward achievements (Game::AchievementUnlocksDisallowed 00705080, which Game does not declare
|
||||
// yet): not on a custom seed, a seed or mod that blocks them, or a rerun.
|
||||
static bool achievements_disallowed()
|
||||
{
|
||||
Game& game = *g_game;
|
||||
return game.seedEffects.isCustomRun || game.seedEffects.AchievementUnlocksDisallowed() ||
|
||||
Manager::AchievementUnlocksDisallowed() || game.isRerun;
|
||||
}
|
||||
|
||||
// 0065d200 Starts a slot from its config's sprite, sized and offset for its kind. The donation machines show their
|
||||
// save's count and break or jam as the run left them, the dresser appears on a first visit, and the Revive Machine
|
||||
// only stays in co-op. In Greed mode the blood donation machine is a devil beggar.
|
||||
// Isaac's secret closet and the Revive Machine's setup are not reconstructed yet.
|
||||
void Entity_Slot::Init(int entityType, int entityVariant, int entitySubType, uint32_t seed)
|
||||
{
|
||||
bool isGreed = g_game->difficulty == DIFFICULTY_GREED || g_game->difficulty == DIFFICULTY_GREEDIER;
|
||||
int kind = isGreed && entityVariant == SLOT_BLOOD_DONATION_MACHINE ? SLOT_DEVIL_BEGGAR : entityVariant;
|
||||
|
||||
persistentData = &g_manager->persistentGameData;
|
||||
Entity::Init(entityType, kind, entitySubType, seed);
|
||||
if (config)
|
||||
{
|
||||
sprite.Load(config->anm2Path, GRAPHICS_LOAD);
|
||||
sprite.Play(sprite.GetDefaultAnimationName());
|
||||
}
|
||||
|
||||
targetPosition = {};
|
||||
posOffset = {};
|
||||
sizeMulti = vector_make(1, 1);
|
||||
donationValue = 0;
|
||||
triggerTimer = 0;
|
||||
unkShort1 = 0;
|
||||
touch = 0;
|
||||
isUnknown544 = false;
|
||||
isUnknown418 = false;
|
||||
state = SLOT_STATE_IDLE;
|
||||
prizeAnm2.Reset();
|
||||
prizeCollectible = 0;
|
||||
|
||||
switch (kind)
|
||||
{
|
||||
case SLOT_MACHINE:
|
||||
case SLOT_BLOOD_DONATION_MACHINE:
|
||||
case SLOT_FORTUNE_TELLING_MACHINE:
|
||||
case SLOT_CRANE_GAME:
|
||||
case SLOT_CONFESSIONAL:
|
||||
posOffset.y = MACHINE_OFFSET_Y;
|
||||
sizeMulti = vector_make(MACHINE_WIDTH, MACHINE_DEPTH);
|
||||
if (kind == SLOT_BLOOD_DONATION_MACHINE) posOffset.x = BLOOD_MACHINE_OFFSET_X;
|
||||
break;
|
||||
case SLOT_SHELL_GAME:
|
||||
case SLOT_HELL_GAME:
|
||||
posOffset.y = MACHINE_OFFSET_Y;
|
||||
sizeMulti = vector_make(SHELL_GAME_WIDTH, MACHINE_DEPTH);
|
||||
prizeAnm2 = sprite;
|
||||
break;
|
||||
case SLOT_BEGGAR:
|
||||
case SLOT_DEVIL_BEGGAR:
|
||||
case SLOT_KEY_MASTER:
|
||||
case SLOT_BOMB_BUM:
|
||||
case SLOT_BATTERY_BUM:
|
||||
case SLOT_ROTTEN_BEGGAR:
|
||||
posOffset.y = BEGGAR_OFFSET_Y;
|
||||
break;
|
||||
case SLOT_DONATION_MACHINE:
|
||||
{
|
||||
posOffset.y = MACHINE_OFFSET_Y;
|
||||
sizeMulti = vector_make(MACHINE_WIDTH, MACHINE_DEPTH);
|
||||
counter_show(persistentData->eventCounters[EVENT_DONATION_MACHINE]);
|
||||
bool isOnline = g_manager->netplayManager.is_online();
|
||||
bool isBroken = g_game->GetStateFlag((GameStateFlag)GAME_STATE_DONATION_SLOT_BROKEN) ||
|
||||
(isOnline ? g_game->challenge != 0 || g_game->dailyChallenge._id != 0
|
||||
: achievements_disallowed());
|
||||
if (isBroken) Remove();
|
||||
if (g_game->GetStateFlag((GameStateFlag)GAME_STATE_DONATION_SLOT_JAMMED))
|
||||
{
|
||||
sprite.Play(COIN_JAM_ANIMATIONS[Random() & 3]);
|
||||
state = SLOT_STATE_JAMMED;
|
||||
}
|
||||
AddEntityFlags(FLAG_NO_KNOCKBACK);
|
||||
break;
|
||||
}
|
||||
case SLOT_GREED_DONATION_MACHINE:
|
||||
posOffset.y = MACHINE_OFFSET_Y;
|
||||
sizeMulti = vector_make(MACHINE_WIDTH, MACHINE_DEPTH);
|
||||
counter_show(persistentData->eventCounters[EVENT_GREED_DONATION_MACHINE]);
|
||||
if (achievements_disallowed() && !g_manager->netplayManager.is_online()) Remove();
|
||||
if (g_game->GetStateFlag((GameStateFlag)GAME_STATE_GREED_SLOT_JAMMED))
|
||||
{
|
||||
sprite.Play(COIN_JAM_ANIMATIONS[Random() & 3]);
|
||||
state = SLOT_STATE_JAMMED;
|
||||
}
|
||||
break;
|
||||
case SLOT_SHOP_RESTOCK_MACHINE:
|
||||
posOffset.y = MACHINE_OFFSET_Y;
|
||||
sizeMulti = vector_make(MACHINE_WIDTH, MACHINE_DEPTH);
|
||||
AddEntityFlags(FLAG_NO_KNOCKBACK);
|
||||
break;
|
||||
case SLOT_MOMS_DRESSER:
|
||||
sizeMulti = vector_make(MACHINE_WIDTH, MACHINE_DEPTH);
|
||||
if (!g_game->room->isFirstVisit) sprite.Play("Idle");
|
||||
else
|
||||
{
|
||||
sprite.Play("Appear");
|
||||
isVisible = false;
|
||||
}
|
||||
break;
|
||||
case SLOT_ISAAC_SECRET:
|
||||
reconstruction_missing("Entity_Slot::Init 0065d200: Isaac's secret closet");
|
||||
case SLOT_REVIVE_MACHINE:
|
||||
if (!g_game->playerManager.IsCoopPlay() || g_game->currentRoomIdx == REVIVE_MACHINE_EXCLUDED_ROOM) Remove();
|
||||
else reconstruction_missing("Entity_Slot::Init 0065d200: the Revive Machine in co-op (FUN_006655e0)");
|
||||
break;
|
||||
}
|
||||
entityGridCollisionClass = GRIDCOLL_NONE;
|
||||
timeout = 0;
|
||||
}
|
||||
|
||||
// Shows a donation count on the machine's three digit layers.
|
||||
void Entity_Slot::counter_show(int count)
|
||||
{
|
||||
sprite.SetFrame("Prize", 0);
|
||||
sprite.SetLayerFrame(1, count / HUNDREDS % DIGIT_BASE);
|
||||
sprite.SetLayerFrame(2, count / DIGIT_BASE % DIGIT_BASE);
|
||||
sprite.SetLayerFrame(3, count % DIGIT_BASE);
|
||||
}
|
||||
|
||||
// 00665370 Draws the slot, and a shell game's prize while it plays.
|
||||
void Entity_Slot::Render(const Vector& offset)
|
||||
{
|
||||
Entity::Render(offset);
|
||||
bool isShellGame = variant == SLOT_SHELL_GAME || variant == SLOT_HELL_GAME;
|
||||
if (isShellGame && prizeAnm2.animState.animData && prizeAnm2.animState.isPlaying)
|
||||
prizeAnm2.Render(SpriteDraw{renderPosition, {}, {}});
|
||||
}
|
||||
|
||||
// The rest of Entity_Slot is not reconstructed yet.
|
||||
|
||||
// 0065d200
|
||||
void Entity_Slot::Init(int, int, int, uint32_t)
|
||||
{
|
||||
reconstruction_missing("Entity_Slot::Init 0065d200");
|
||||
}
|
||||
|
||||
// 0065d950
|
||||
void Entity_Slot::Update()
|
||||
{
|
||||
reconstruction_missing("Entity_Slot::Update 0065d950");
|
||||
}
|
||||
|
||||
// 00665370
|
||||
void Entity_Slot::Render(const Vector&)
|
||||
{
|
||||
reconstruction_missing("Entity_Slot::Render 00665370");
|
||||
}
|
||||
|
||||
// 00664560
|
||||
bool Entity_Slot::TakeDamage(float, uint64_t, const EntityRef&, int)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user