Skip to content

Commit

Permalink
cobalt lichen: special connected tile rendering
Browse files Browse the repository at this point in the history
TODO:
- webtiles
- use different corner/edge connectors
- remove the special case for main tile background mask
- properly overlay lichen parts with randomised position

might have to extends doll code generally to do all this?
  • Loading branch information
chucksellick committed Jan 23, 2025
1 parent a00c586 commit 6e1631c
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 3 deletions.
10 changes: 9 additions & 1 deletion crawl-ref/source/rltiles/dc-mon.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1205,10 +1205,18 @@ wandering_mushroom MONS_WANDERING_MUSHROOM
deathcap MONS_DEATHCAP
sleepcap MONS_SLEEPCAP

# %rim 1
%sdir mon/fungi_plants
cobalt_lichen MONS_COBALT_LICHEN

%rim 1
cobalt_lichen MONS_COBALT_LICHEN_MASK

# %rim 0
# cobalt_lichen_corner MONS_COBALT_LICHEN_CORNER
# %rim 1
# cobalt_lichen_corner MONS_COBALT_LICHEN_CORNER_MASK

%rim 0
%start
%compose cobalt_lichen
%compose cobalt_lichen_eyestalk1
Expand Down
Binary file modified crawl-ref/source/rltiles/mon/fungi_plants/cobalt_lichen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions crawl-ref/source/tilecell.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ struct packed_cell
enum { MAX_DNGN_OVERLAY = 20 };
int num_dngn_overlay;
FixedVector<int, MAX_DNGN_OVERLAY> dngn_overlay;
FixedVector<int, 4> fg_underlay = {0,0,0,0};

tileidx_t fg;
tileidx_t bg;
Expand Down
23 changes: 23 additions & 0 deletions crawl-ref/source/tiledgnbuf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ void DungeonCellBuffer::add_glyph(const char32_t &g, const VColour &col, const V
m_buf_glyphs.get_font_wrapper().store(m_buf_glyphs, sx, sy, g, col, bg);
}

static const struct coord_def _buf_offset_coords[] = {
{0,16}, {16,16}, {16,0}, {16,-16},
};

void DungeonCellBuffer::add(const packed_cell &cell, int x, int y)
{
pack_background(x, y, cell);
Expand All @@ -63,6 +67,25 @@ void DungeonCellBuffer::add(const packed_cell &cell, int x, int y)
if (cloud_idx == TILE_CLOUD_INK && player_in_branch(BRANCH_SHOALS))
cloud_idx = 0;

for (int n=0; n < 4; n++)
{
if (cell.fg_underlay[n])
{
m_buf_doll.add(cell.fg_underlay[n], x, y, 1, false, false,
_buf_offset_coords[n].x, _buf_offset_coords[n].y);
// Mask layer at lower z-index (to add rim around the entire blob)
m_buf_doll.add(cell.fg_underlay[n] + 1, x, y, -2, false, false,
_buf_offset_coords[n].x, _buf_offset_coords[n].y);
}
}

if (fg_idx >= TILEP_MONS_COBALT_LICHEN
&& fg_idx <= TILEP_MONS_COBALT_LICHEN_SAC)
{
// Mask layer at lower z-index (to add rim around the entire blob)
m_buf_doll.add(TILEP_MONS_COBALT_LICHEN_MASK, x, y, -2);
}

if (fg_idx >= TILEP_MCACHE_START)
{
mcache_entry *entry = mcache.get(fg_idx);
Expand Down
1 change: 1 addition & 0 deletions crawl-ref/source/tiledgnbuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class DungeonCellBuffer
TileBuffer m_buf_floor;
TileBuffer m_buf_wall;
TileBuffer m_buf_feat;
TileBuffer m_buf_offset;
SubmergedTileBuffer m_buf_feat_trans;
SubmergedTileBuffer m_buf_doll;
SubmergedTileBuffer m_buf_main_trans;
Expand Down
2 changes: 1 addition & 1 deletion crawl-ref/source/tilepick.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2190,7 +2190,7 @@ tileidx_t tileidx_monster(const monster_info& mons)
ch |= TILE_FLAG_UNUSUAL;
else if (mons.type == MONS_PLAYER_GHOST)
{
// Threat is always displayed for ghosts, with different tiles,
// Threat is always displayed for ghosts, with different tiles,
// to make them more easily visible.
ch |= TILE_FLAG_GHOST;
switch (mons.threat)
Expand Down
2 changes: 1 addition & 1 deletion crawl-ref/source/tileview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ static void _tile_place_monster(const coord_def &gc, const monster_info& mon)
else if (pref != TAGPREF_ALL && !mon.is_named())
return;

if (pref != TAGPREF_NAMED && pref != TAGPREF_ALL && mon.attitude == ATT_FRIENDLY)
if (pref != TAGPREF_NAMED && pref != TAGPREF_ALL && mon.attitude == ATT_FRIENDLY)
return;

tiles.add_text_tag(TAG_NAMED_MONSTER, mon);
Expand Down
37 changes: 37 additions & 0 deletions crawl-ref/source/view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1697,6 +1697,41 @@ crawl_view_buffer view_dungeon(animation *a, bool anim_updates, view_renderer *r
return vbuf;
}

static void _pack_underlays(coord_def gc, packed_cell& cell, const monster_info& mon)
{
if (!in_bounds(gc))
return;
if (mons_species(mon.type) == MONS_COBALT_LICHEN)
{
int underlay_num = -1;
for (adjacent_iterator ri(gc, true); ri; ++ri)
{
int dx = ri->x - gc.x;
if (dx < 0)
continue;
int dy = ri->y - gc.y;
if (dy < 0 && dx < 1)
continue;
underlay_num++;
cell.fg_underlay[underlay_num] = 0;

if (!map_bounds(*ri))
continue;
const map_cell& adj_knowledge = env.map_knowledge(*ri);
if (!adj_knowledge.seen() && !adj_knowledge.mapped())
continue;
// Now we know this is a connection we *might* want to check, see if
// there's an applicable monster there first
if (!adj_knowledge.monsterinfo()
|| mons_species(adj_knowledge.monsterinfo()->type) != MONS_COBALT_LICHEN)
{
continue;
}
cell.fg_underlay[underlay_num] = TILEP_MONS_COBALT_LICHEN;
}
}
}

void draw_cell(screen_cell_t *cell, const coord_def &gc,
bool anim_updates, int flash_colour)
{
Expand Down Expand Up @@ -1725,6 +1760,8 @@ void draw_cell(screen_cell_t *cell, const coord_def &gc,
cell->tile.map_knowledge = map_bounds(gc) ? env.map_knowledge(gc) : map_cell();
cell->flash_colour = BLACK;
cell->flash_alpha = 0;
if (cell->tile.map_knowledge.monsterinfo())
_pack_underlays(gc, cell->tile, *cell->tile.map_knowledge.monsterinfo());
#endif

// Don't hide important information by recolouring monsters.
Expand Down

0 comments on commit 6e1631c

Please sign in to comment.