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
+160
-10
@@ -4,6 +4,7 @@
|
||||
#include "fx_layers.h"
|
||||
#include "game.h"
|
||||
#include "grid_entity_door.h"
|
||||
#include "level.h"
|
||||
#include "log.h"
|
||||
#include "manager.h"
|
||||
#include "platform.h"
|
||||
@@ -46,6 +47,15 @@ constexpr int MINECART_RIDDEN = 10;
|
||||
constexpr int NPC_STATE_MINECART_MOVING = 4;
|
||||
constexpr int COLLECTIBLE_GLOWING_HOURGLASS = 422;
|
||||
constexpr int COLLECTIBLE_D7 = 437;
|
||||
constexpr const char* ANIMATION_APPEAR = "Appear";
|
||||
constexpr float APPEAR_FRAME = 2;
|
||||
constexpr float SCREEN_CELL_SIZE = 26;
|
||||
constexpr int ROOM_CELLS_ACROSS = 13;
|
||||
constexpr int ROOM_CELLS_DOWN = 7;
|
||||
constexpr int DEATH_CERTIFICATE_DIMENSION = 2;
|
||||
constexpr int STAGE_ID_HOME = 35;
|
||||
constexpr int DOGMA_ROOM_VARIANT = 1000;
|
||||
constexpr uint32_t BOSS_DOGMA = 99;
|
||||
|
||||
// The items whose pickup animation an extra life plays once the player is back, from the Ankh to Lazarus' Rags: Ankh,
|
||||
// Dead Cat, 1up!, Guppy's Collar, Judas' Shadow and Lazarus' Rags.
|
||||
@@ -130,9 +140,137 @@ void RoomTransition::StartBossIntro(uint32_t, uint32_t)
|
||||
reconstruction_missing("RoomTransition::StartBossIntro 0082f1c0");
|
||||
}
|
||||
|
||||
// The distance between two rooms in screen pixels, mirrored in the mirror world: from their map cells when both lie on
|
||||
// the map of one dimension, else the size of the room on the side left through (the target's for left and up).
|
||||
static Vector room_distance_get(RoomDescriptor& current, RoomDescriptor& target, bool isOnMap, Direction direction)
|
||||
{
|
||||
Vector distance{};
|
||||
|
||||
if (isOnMap)
|
||||
{
|
||||
int columns = target.gridIndex % LEVEL_GRID_WIDTH - current.gridIndex % LEVEL_GRID_WIDTH;
|
||||
int rows = target.gridIndex / LEVEL_GRID_WIDTH - current.gridIndex / LEVEL_GRID_WIDTH;
|
||||
distance = vector_make((float)(columns * ROOM_CELLS_ACROSS) * SCREEN_CELL_SIZE,
|
||||
(float)(rows * ROOM_CELLS_DOWN) * SCREEN_CELL_SIZE);
|
||||
}
|
||||
else switch (direction)
|
||||
{
|
||||
case DIRECTION_LEFT:
|
||||
distance.x = -(float)target.data->width * SCREEN_CELL_SIZE;
|
||||
break;
|
||||
case DIRECTION_UP:
|
||||
distance.y = -(float)target.data->height * SCREEN_CELL_SIZE;
|
||||
break;
|
||||
case DIRECTION_RIGHT:
|
||||
distance.x = (float)current.data->width * SCREEN_CELL_SIZE;
|
||||
break;
|
||||
case DIRECTION_DOWN:
|
||||
distance.y = (float)current.data->height * SCREEN_CELL_SIZE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (Room::IsMirrorWorld()) distance.x = -distance.x;
|
||||
return distance;
|
||||
}
|
||||
|
||||
// How far past a screen the rooms slide through a door: the rooms' distance less the camera's change between them,
|
||||
// across mirrored in the mirror world.
|
||||
void RoomTransition::slide_offset_set(Vector distance, Vector oldScroll)
|
||||
{
|
||||
Vector newScroll = g_game->room->renderScrollOffset;
|
||||
float across = Room::IsMirrorWorld() ? oldScroll.x - newScroll.x : newScroll.x - oldScroll.x;
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
case DIRECTION_LEFT:
|
||||
slideOffset.x = across - g_screenWidth - distance.x;
|
||||
break;
|
||||
case DIRECTION_UP:
|
||||
slideOffset.y = newScroll.y - oldScroll.y - g_screenHeight - distance.y;
|
||||
break;
|
||||
case DIRECTION_RIGHT:
|
||||
slideOffset.x = -across - g_screenWidth + distance.x;
|
||||
break;
|
||||
case DIRECTION_DOWN:
|
||||
slideOffset.y = oldScroll.y - newScroll.y - g_screenHeight + distance.y;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Puts the players in the new room. A teleport keeps them hidden, else the main players not held show. The Forgotten's
|
||||
// body, the Death Certificate's floor, a teleporter's pad and the Ventricle Razor's portals place them.
|
||||
void RoomTransition::arrival_place()
|
||||
{
|
||||
Game& game = *g_game;
|
||||
Room& room = *game.room;
|
||||
bool isTeleporterRoom = room.roomType == ROOM_TELEPORTER || room.roomType == ROOM_TELEPORTER_EXIT;
|
||||
|
||||
if (animation == TRANSITION_WOMB_TELEPORT)
|
||||
{
|
||||
for (VentricleRazorPortal& portal : game.ventricleRazorPortals)
|
||||
if (portal.roomIndex == game.currentRoomIdx)
|
||||
reconstruction_missing("RoomTransition::ChangeRoom 00830950: the players jumping out of a Ventricle "
|
||||
"Razor portal (Entity_Player +0x14c, +0x98)");
|
||||
return;
|
||||
}
|
||||
if (!is_teleport())
|
||||
for (Entity_Player* player : game.playerManager.playerList)
|
||||
if (player->variant == PLAYER_VARIANT_PLAYER && !(player->flags & FLAG_HELD)) player->isVisible = true;
|
||||
|
||||
if (animation == TRANSITION_FORGOTTEN_TELEPORT && game.playerManager.roomTransitionPlayer)
|
||||
reconstruction_missing("RoomTransition::ChangeRoom 00830950: Entity_Player::Teleport 007cd950 to the body");
|
||||
else if (animation == TRANSITION_DEATH_CERTIFICATE && game.currentDimensionIdx == DEATH_CERTIFICATE_DIMENSION)
|
||||
reconstruction_missing("RoomTransition::ChangeRoom 00830950: the players placed on the Death Certificate floor");
|
||||
else if (animation == TRANSITION_DEATH_CERTIFICATE)
|
||||
for (Entity_Player* player : game.playerManager.playerList)
|
||||
{
|
||||
if (!player) continue;
|
||||
player->PlayExtraAnimation(ANIMATION_APPEAR);
|
||||
if (player->sprite.animState.animData) player->sprite.animState.SetFrameFloat(APPEAR_FRAME);
|
||||
player->isControlsEnabled = false;
|
||||
}
|
||||
else if (animation == TRANSITION_TELEPORT && teleporterTarget > 0 && isTeleporterRoom)
|
||||
reconstruction_missing("RoomTransition::ChangeRoom 00830950: Entity_Player::Teleport 007cd950 to a teleporter");
|
||||
}
|
||||
|
||||
// 00830950 Takes the players into the target room (the Glowing Hourglass rewinds the room instead), their controls on
|
||||
// while it loads, and works out how far a walk through a door slides. The new room's boss gets its versus screen
|
||||
// (Dogma's living room too), else the room plays its music. The players are placed and the new room is captured.
|
||||
void RoomTransition::ChangeRoom()
|
||||
{
|
||||
reconstruction_missing("RoomTransition::ChangeRoom 00830950");
|
||||
Game& game = *g_game;
|
||||
std::vector<Entity_Player*>& players = game.playerManager.playerList;
|
||||
RoomDescriptor& current = *game.GetRoomByIdx(game.currentRoomIdx, game.currentDimensionIdx);
|
||||
RoomDescriptor& target = *game.GetRoomByIdx(roomIndex, roomDimension);
|
||||
bool isOnMap = roomIndex >= 0 && game.currentRoomIdx >= 0 && current.dimension == target.dimension;
|
||||
Vector distance = room_distance_get(current, target, isOnMap, direction);
|
||||
Vector oldScroll = game.room->renderScrollOffset;
|
||||
|
||||
if (game.deathmatchManager.state < DEATHMATCH_INTRO)
|
||||
for (Entity_Player* player : players) player->isControlsEnabled = true;
|
||||
if (animation == TRANSITION_GLOWING_HOURGLASS) reconstruction_missing("Game::rewind 00706020");
|
||||
else
|
||||
{
|
||||
if (direction == DIRECTION_NONE) game.leaveDoor = DOOR_NONE;
|
||||
game.ChangeRoom(roomIndex, roomDimension);
|
||||
}
|
||||
for (Entity_Player* player : players) player->isControlsEnabled = false;
|
||||
if (animation == TRANSITION_WALK) slide_offset_set(distance, oldScroll);
|
||||
|
||||
Room& room = *game.room;
|
||||
RoomConfig_Room* data = room.descriptor->data;
|
||||
bool isDogmaRoom = data && data->stageId == STAGE_ID_HOME && data->type == ROOM_DEFAULT &&
|
||||
data->variant == DOGMA_ROOM_VARIANT && !room.IsClear();
|
||||
|
||||
if (room.bossId != 0 && room.GetAliveBossesCount() >= 1) StartBossIntro(room.bossId, room.secondBossId);
|
||||
else if (isDogmaRoom) StartBossIntro(BOSS_DOGMA, 0);
|
||||
else if (game.deathmatchManager.state < DEATHMATCH_INTRO) room.PlayMusic();
|
||||
|
||||
arrival_place();
|
||||
room_capture(newRoomSurface);
|
||||
}
|
||||
|
||||
// Whether a player plays an extra or item animation that holds the transition: one not looping.
|
||||
@@ -248,12 +386,25 @@ void RoomTransition::start_update(Entity_NPC* minecartNpc)
|
||||
old_room_capture();
|
||||
}
|
||||
|
||||
// Renders the room as it stands, lit, into a surface.
|
||||
void RoomTransition::room_capture(KAGE::Graphics::ImagePtr& surface)
|
||||
{
|
||||
KAGE::Graphics::Manager& graphics = KAGE::Graphics::manager;
|
||||
|
||||
g_game->room->render_lighting();
|
||||
graphics.render_target_push(surface.get(), KAGE::Graphics::TARGET_SCREEN_SIZE, KAGE::Graphics::PRESENT_FLUSH);
|
||||
graphics.Clear();
|
||||
graphics.blendMode.SetMode(KAGE::Graphics::BLEND_NORMAL);
|
||||
g_game->room->Render();
|
||||
graphics.Present(KAGE::Graphics::PRESENT_FINISH);
|
||||
graphics.render_target_pop(KAGE::Graphics::PRESENT_FLUSH);
|
||||
}
|
||||
|
||||
// Hides the players leaving (all of them, but only the one who walked out through a door or pixelated) and renders
|
||||
// the room into the old room surface. A fade shows it going out, a forced boss or arena transition changing room at
|
||||
// once, and anything else changes room and comes in.
|
||||
void RoomTransition::old_room_capture()
|
||||
{
|
||||
KAGE::Graphics::Manager& graphics = KAGE::Graphics::manager;
|
||||
Game& game = *g_game;
|
||||
bool isWalking = animation == TRANSITION_WALK || animation == TRANSITION_PIXELATION;
|
||||
|
||||
@@ -264,14 +415,7 @@ void RoomTransition::old_room_capture()
|
||||
(!isWalking || direction == DIRECTION_NONE || player == game.playerManager.roomTransitionPlayer))
|
||||
player->isVisible = false;
|
||||
|
||||
game.room->render_lighting();
|
||||
graphics.render_target_push(oldRoomSurface.get(), KAGE::Graphics::TARGET_SCREEN_SIZE,
|
||||
KAGE::Graphics::PRESENT_FLUSH);
|
||||
graphics.Clear();
|
||||
graphics.blendMode.SetMode(KAGE::Graphics::BLEND_NORMAL);
|
||||
game.room->Render();
|
||||
graphics.Present(KAGE::Graphics::PRESENT_FINISH);
|
||||
graphics.render_target_pop(KAGE::Graphics::PRESENT_FLUSH);
|
||||
room_capture(oldRoomSurface);
|
||||
|
||||
bool isChangedAtOnce = animation == TRANSITION_BOSS_FORCED || animation == TRANSITION_ARENA;
|
||||
if (is_fade() || isChangedAtOnce)
|
||||
@@ -547,6 +691,12 @@ bool RoomTransition::is_active()
|
||||
return mode != TRANSITION_NONE;
|
||||
}
|
||||
|
||||
// 006f0070 Whether a transition shows a boss's versus screen.
|
||||
bool RoomTransition::is_versus_screen()
|
||||
{
|
||||
return mode != TRANSITION_NONE && bossIntroBossId != 0;
|
||||
}
|
||||
|
||||
// 0082eb90 Whether the players teleport out: a teleport, a womb teleport, the Glowing Hourglass or the D7.
|
||||
bool RoomTransition::is_teleport()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user