Fix BG tile bug from switching from pink SS

If you had a pink space station background, and switched to a different
tileset, some solid tiles would be placed instead. This commit fixes
that by transforming the room into the basic autotiling tiles before
changing the tileset itself. The reason why I chose this solution is
because it will help with a future change, being unhardcoding warp zone
backgrounds (which'll help with custom autotiling, if that becomes a
thing.)
This commit is contained in:
AllyTally 2023-11-30 22:24:10 -04:00 committed by Misa Elizabeth Kai
parent 96d36f86f0
commit b23983c0b8
2 changed files with 44 additions and 0 deletions

View File

@ -4017,8 +4017,48 @@ bool editorclass::lines_can_pass(int x, int y)
return false;
}
void editorclass::make_autotiling_base(void)
{
if (cl.getroomprop(levx, levy)->directmode == 1)
{
return;
}
for (int i = 0; i < SCREEN_WIDTH_TILES * SCREEN_HEIGHT_TILES; i++)
{
int tile_x = i % SCREEN_WIDTH_TILES;
int tile_y = i / SCREEN_WIDTH_TILES;
int tile = get_tile(tile_x, tile_y);
if (tile == 0)
{
continue;
}
TileTypes type = get_tile_type(tile_x, tile_y, false);
switch (type)
{
case TileType_NONSOLID:
if (type == TileType_NONSOLID || is_warp_zone_background(tile))
{
set_tile(tile_x, tile_y, 2);
}
break;
case TileType_SOLID:
set_tile(tile_x, tile_y, 1);
break;
case TileType_SPIKE:
set_tile(tile_x, tile_y, 6);
break;
}
}
}
void editorclass::switch_tileset(const bool reversed)
{
make_autotiling_base();
int tiles = cl.getroomprop(levx, levy)->tileset;
if (reversed)
@ -4052,6 +4092,8 @@ void editorclass::switch_tileset(const bool reversed)
void editorclass::switch_tilecol(const bool reversed)
{
make_autotiling_base();
int tilecol = cl.getroomprop(levx, levy)->tilecol;
if (reversed)

View File

@ -177,6 +177,8 @@ public:
bool lines_can_pass(int x, int y);
void make_autotiling_base(void);
int get_enemy_tile(int t);
void switch_tileset(const bool reversed);