102 int room_id,
int selected_entrance_slot, uint8_t room_header_blockset,
104 std::span<const DungeonRenderEntranceCandidate> entrances,
111 context.
owner_index = OwnerIndexForRoom(census, room_id);
112 SetOwnerMetadata(&context, census);
113 if (project_dungeon !=
nullptr) {
119 FindCandidate(entrances, selected_entrance_slot);
120 if (selected !=
nullptr) {
133 const bool has_direct = std::any_of(
134 entrances.begin(), entrances.end(), [room_id](
const auto& entrance) {
135 return entrance.slot >= zelda3::kNumDungeonSpawnPoints &&
136 entrance.room_id == room_id;
139 std::map<uint8_t, std::vector<const DungeonRenderEntranceCandidate*>>
141 for (
const auto& candidate : entrances) {
144 const bool same_owner =
145 project_dungeon !=
nullptr
146 ? std::any_of(project_dungeon->
rooms.begin(),
147 project_dungeon->
rooms.end(),
148 [&candidate](
const auto& room) {
149 return room.id == candidate.room_id;
152 OwnerIndexForRoom(census, candidate.room_id) ==
154 if (has_direct ? candidate.room_id == room_id : same_owner) {
155 candidates_by_gfx[candidate.main_gfx].push_back(&candidate);
165 if (candidates_by_gfx.empty()) {
168 if (project_dungeon ==
nullptr &&
170 if (
const auto* entrance =
171 FindCandidate(entrances, default_entrance.
entrance_id +
173 UseEntrance(&context,
180 if (candidates_by_gfx.size() > 1) {
185 auto& agreeing = candidates_by_gfx.begin()->second;
186 const auto inferred =
187 *std::min_element(agreeing.begin(), agreeing.end(),
190 return lhs->slot < rhs->slot;
192 context.
source = has_direct
const DungeonRenderEntranceCandidate * FindCandidate(std::span< const DungeonRenderEntranceCandidate > entrances, int slot)
void UseEntrance(DungeonRenderContext *context, DungeonRenderContextSource source, const DungeonRenderEntranceCandidate &entrance)
void SetOwnerMetadata(DungeonRenderContext *context, const zelda3::RoomCensus *census)
int OwnerIndexForRoom(const zelda3::RoomCensus *census, int room_id)
DungeonRenderContext ResolveDungeonRenderContext(int room_id, int selected_entrance_slot, uint8_t room_header_blockset, const zelda3::RoomCensus *census, std::span< const DungeonRenderEntranceCandidate > entrances, zelda3::RoomDefaultEntrance default_entrance, const core::DungeonEntry *project_dungeon)
A complete dungeon entry with rooms and connections.
std::vector< DungeonRoom > rooms
DungeonRenderContextSource source
zelda3::RoomDefaultEntrance default_entrance
bool uses_entrance() const
std::vector< int > candidate_slots
uint8_t room_header_blockset
uint8_t entrance_blockset