Curation round 20: player update, costumes and render, Missing No., the last actives and cards, familiars, Pin, the Frail, Wormwood and the Heretic, Dross to Gehenna, effects and the devil room purchase, champion colours, the quit path, save fields, shared vector helpers

This commit is contained in:
shweet committed 2026-11-22 00:33:35 -05:00
1 parent ee863e70e6
commit 8dbeb1bc4a
168 files changed
+15682 -2399

No files matched your search

+68
View File
@@ -1,4 +1,5 @@
#include "room_grid.h"
#include "capsule.h"
#include "entity_player.h"
#include "game.h"
#include "grid_entity_door.h"
@@ -8,6 +9,7 @@
#include "npc_ai.h"
#include "room.h"
#include <algorithm>
#include <utility>
#include <array>
// The partitions a query bit looks in, in the order QueryRadius goes through them.
@@ -82,6 +84,62 @@ EntityList_EL entity_query_radius(const Vector& position, float radius, uint32_t
return found;
}
// 0041ab50 (EntityList::query_player_capsule_hits) The entities a capsule touches that queries may see: those of the
// partitions asked for within its bounding box, then the players, then the effects.
EntityList_EL entity_query_capsule(const Capsule& capsule, uint32_t partitions)
{
EntityList& list = g_game->room->entityList;
EntityList_EL found;
Vector low{};
Vector high{};
capsule.get_bounding_box(low, high);
Vector center = vector_scale(vector_add(low, high), 0.5f);
Vector extent = vector_scale(vector_sub(high, low), 0.5f);
auto isTouched = [&](Entity* entity) {
return !entity->HasEntityFlags(FLAG_NO_QUERY) && Capsule::Collide(capsule, entity->GetCollisionCapsule({}));
};
for (const PartitionQuery& query : PARTITION_QUERIES)
if (partitions & query.bit) list.partitions[query.partition].query_box(found, center, extent);
if (partitions & QUERY_PLAYERS)
for (Entity_Player* player : g_game->playerManager.playerList) found.push_back(player);
std::erase_if(found, [&](Entity* entity) { return !isTouched(entity); });
if (partitions & QUERY_EFFECTS)
for (Entity* effect : list.effectEL)
if (isTouched(effect)) found.push_back(effect);
return found;
}
// 00589f90 (Room::CanSpawnObstacleAtPos) Whether an obstacle could stand on a position's cell (off the grid, as the
// room says of cell -1).
bool room_can_spawn_obstacle_at(const Vector& position, bool isForced)
{
Room& room = *g_game->room;
int column = (int)((position.x - GRID_ORIGIN_X) / GRID_CELL_SIZE + 0.5f);
int row = (int)((position.y - GRID_ORIGIN_Y) / GRID_CELL_SIZE + 0.5f);
bool isInside = column >= 0 && column < room.gridWidth && row >= 0 && row < room.gridHeight;
return room.CanSpawnObstacleAtPosition(isInside ? room.gridWidth * row + column : -1, isForced);
}
// 004cdd80 (Room::RaiseGridPathAtPos) Raises the path cost of a position's cell to a level below 951, keeping its
// thousands, false off the grid.
bool room_path_raise_at(const Vector& position, int level)
{
constexpr int PATH_LEVELS = 1000;
constexpr int PATH_LEVEL_MAX = 950;
Room& room = *g_game->room;
int column = (int)((position.x - GRID_ORIGIN_X) / GRID_CELL_SIZE + 0.5f);
int row = (int)((position.y - GRID_ORIGIN_Y) / GRID_CELL_SIZE + 0.5f);
if (column < 0 || column >= room.gridWidth || row < 0 || row >= room.gridHeight) return false;
uint32_t index = (uint32_t)(room.gridWidth * row + column);
if (index >= room.gridPaths.size() || level > PATH_LEVEL_MAX) return false;
int current = room.gridPaths[index] % PATH_LEVELS;
if (current < level) room.gridPaths[index] = room.gridPaths[index] - current + level;
return true;
}
// 00456620 The grid entity on the cell at a position, if any.
GridEntity* room_grid_entity_at(const Vector& position)
{
@@ -253,3 +311,13 @@ void Room::RemoveGridEntity(int gridIndex, int pathTrail, DecorationRemoval remo
gridPaths[gridIndex] = pathTrail;
pendingGridRemovals.insert(gridIndex);
}
// 0081e980 Removes a cell's grid entity at once, unless it is a kept decoration, leaving a path trail.
void Room::RemoveGridEntityImmediate(int gridIndex, int pathTrail, DecorationRemoval removal)
{
if ((uint32_t)gridIndex >= ROOM_GRID_CELLS || !gridEntities[gridIndex]) return;
if (gridEntities[gridIndex]->type == GRID_DECORATION && removal == DECORATION_KEPT) return;
gridPaths[gridIndex] = pathTrail;
delete std::exchange(gridEntities[gridIndex], nullptr);
}