Curation round 13: grid entities, more enemies, Caves, boss helpers and five bosses, chests and costumes, curses and alt stages, the Lua API

This commit is contained in:
shweet committed 2026-11-20 16:32:45 -05:00
1 parent f8ce24fc6c
commit 8ae02a8422
160 files changed
+16231 -1689

No files matched your search

+27
View File
@@ -37,6 +37,9 @@ constexpr int DOOR_RETRIES = 20;
constexpr float DOOR_RETRY_STEP = 40;
constexpr float DEGREES_FULL_TURN = 360;
// The distance FindFreeTilePosition starts its search from, farther than any cell.
constexpr float FREE_TILE_FAR = 1e6f;
// The grid path a try accepts, by the tries left below which it does: higher as the search runs out.
struct PathBand
{
@@ -206,3 +209,27 @@ bool room_bridge_make(GridEntity* pit, GridEntity* rock)
static_cast<GridEntity_Pit*>(pit)->MakeBridge(isRock ? static_cast<GridEntity_Rock*>(rock) : nullptr, 0);
return true;
}
// 0081e520 Room::FindFreeTilePosition: the position itself on a free cell, else the center of the nearest free cell,
// taking the first one found within the distance.
Vector room_free_tile_position_find(const Vector& position, float distanceThreshold)
{
Room& room = *g_game->room;
int cell = room.GetGridIndex(position);
if (room.GetGridCollision(cell) == COLLISION_NONE) return position;
Vector best = room.GetGridPosition(cell);
float bestDistance = FREE_TILE_FAR;
for (int i = 0; i < room.gridWidth * room.gridHeight; i++)
{
if (i == cell || room.GetGridCollision(i) != COLLISION_NONE) continue;
Vector at = room.GetGridPosition(i);
float distance = (at.y - position.y) * (at.y - position.y) + (at.x - position.x) * (at.x - position.x);
if (distance >= bestDistance) continue;
best = at;
bestDistance = distance;
if (distance < distanceThreshold * distanceThreshold) break;
}
return best;
}