epfly6/RepentanceAPIIssueTracker

Add function to get current dimension for downpour mirror world and mines escape sequence

Opened this issue · 2 comments

Add function to get current dimension for downpour mirror world and mines escape sequence

This algorithm is from KingBobson:

export function getCurrentDimension(): Dimension | null {
  const game = Game();
  const level = game.GetLevel();

  const roomIndex = getRoomIndex();
  const currentRoomDesc = level.GetCurrentRoomDesc();
  const currentRoomHash = GetPtrHash(currentRoomDesc);

  for (let dimension = 0; dimension <= 2; dimension++) {
    const dimensionRoomDesc = level.GetRoomByIdx(roomIndex, dimension);
    const dimensionRoomHash = GetPtrHash(dimensionRoomDesc)
    if (dimensionRoomHash === currentRoomHash) {
      return dimension;
    }
  }

  return null;
}