Skip to content

Commit

Permalink
Go in game when clicking generating dungeon
Browse files Browse the repository at this point in the history
  • Loading branch information
krypciak committed Sep 2, 2023
1 parent 0812658 commit 43606b3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 37 deletions.
35 changes: 11 additions & 24 deletions src/dungeon-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { AreaInfo, AreaBuilder, ABStackEntry, IndexedBuilder } from './area/area
import DngGen from './plugin'
import { BattlePuzzleMapBuilder } from './room/dungeon-map-builder'
import { MapBuilder } from './room/map-builder'
import { SimpleSingleTunnelMapBuilder } from './room/simple-map-builder'
import { SimpleDoubleRoomMapBuilder, SimpleDoubleTunnelMapBuilder, SimpleRoomMapBuilder, SimpleSingleTunnelMapBuilder } from './room/simple-map-builder'

declare const blitzkrieg: Blitzkrieg
declare const dnggen: DngGen
Expand Down Expand Up @@ -56,17 +56,17 @@ export class DungeonBuilder {
// builders.push(builder)
// }

// SimpleRoomMapBuilder.addRandom(builders, areaInfo, 100, [SimpleRoomMapBuilder, SimpleSingleTunnelMapBuilder, SimpleDoubleTunnelMapBuilder, SimpleDoubleRoomMapBuilder])
SimpleRoomMapBuilder.addRandom(builders, areaInfo, 100, [SimpleRoomMapBuilder, SimpleSingleTunnelMapBuilder, SimpleDoubleTunnelMapBuilder, SimpleDoubleRoomMapBuilder])
// SimpleRoomMapBuilder.addRandom(builders, areaInfo, 100, [SimpleDoubleRoomMapBuilder])

SimpleSingleTunnelMapBuilder.addPreset(builders, areaInfo)
// SimpleSingleTunnelMapBuilder.addPreset(builders, areaInfo)
// SimpleDoubleRoomMapBuilder.addPreset(builders, areaInfo)

type RecReturn = undefined | { stack: Stack<ABStackEntry>, leftBuilders: Set<IndexedBuilder> }

let highestRecReturn: { stack: Stack<ABStackEntry>, leftBuilders: Set<IndexedBuilder> } = { stack: new Stack(), leftBuilders: new Set() }
const countTarget: number = Math.min(builders.length,
builders.length / 1.1
builders.length / 4
)

function recursiveTryPlaceMaps(stack: Stack<ABStackEntry>, availableBuilders: Set<IndexedBuilder>): RecReturn {
Expand Down Expand Up @@ -147,32 +147,19 @@ export class DungeonBuilder {
// dnggen.areaDrawer.drawArea(obj.stack, size)
// dnggen.areaDrawer.copyToClipboard()

// AreaBuilder.openAreaViewerGui(areaInfo.name, obj.stack.array[0].builder!.name!, 0)


const usedBuilders: IndexedBuilder[] = obj.stack.array.map(e => e.builder!)
await MapBuilder.placeBuilders(usedBuilders)

if (roomTp) {}
/*
areaBuilder.addToDatabase()
areaBuilder.finalizeBuild()
areaBuilder.saveToFile()
ig.game.varsChangedDeferred()
blitzkrieg.puzzleSelections.save()
blitzkrieg.battleSelections.save()
await Promise.all(fileWritePromises)
if (roomTp != -1) {
ig.game.teleport('map name.' + roomTp, ig.TeleportPosition.createFromJson({
marker: DungeonMapBuilder.roomEntarenceMarker,
level: 0,
baseZPos: 0,
size: {x: 0, y: 0}
}))
}
*/
ig.game.teleport(usedBuilders[0].path!, ig.TeleportPosition.createFromJson({
marker: usedBuilders[0].entarenceRoom.primaryEntarence.getTpr().name,
level: 0,
baseZPos: 0,
size: {x: 0, y: 0}
}))
// AreaBuilder.openAreaViewerGui(areaInfo.name, obj.stack.array[0].builder!.name!, 0)
}
}
24 changes: 12 additions & 12 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,20 @@ function addInjects() {
}

async function startDnggenGame(titleGuiInstance?: sc.TitleScreenButtonGui, roomTp: number = -1) {
// ig.bgm.clear('MEDIUM_OUT');
// if (titleGuiInstance) {
// ig.interact.removeEntry(titleGuiInstance.buttonInteract)
// } else {
// ig.interact.entries.forEach((e) => ig.interact.removeEntry(e))
// }
// ig.game.start(sc.START_MODE.NEW_GAME_PLUS, 1)
// ig.game.setPaused(false);

// sc.newgame.active = true
// sc.newgame.options[ngOptionName] = true
ig.bgm.clear('MEDIUM_OUT');
if (titleGuiInstance) {
ig.interact.removeEntry(titleGuiInstance.buttonInteract)
} else {
ig.interact.entries.forEach((e) => ig.interact.removeEntry(e))
}
ig.game.start(sc.START_MODE.NEW_GAME_PLUS, 1)
ig.game.setPaused(false);

sc.newgame.active = true
sc.newgame.options[ngOptionName] = true
dnggen.dungeonBuilder.build('0', roomTp)

// godlikeStats()
godlikeStats()
}

async function registerStyles() {
Expand Down
3 changes: 2 additions & 1 deletion src/room/puzzle-room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ export class PuzzleRoom extends Room {
/* prepare for super() call */
let wallSides: boolean[], roomRect: MapRect
if (puzzle.roomType == PuzzleRoomType.WholeRoom) {
wallSides = [false, false, false, false]
/* changeme later */
wallSides = [true, true, true, true]
roomRect = puzzle.usel.sel.size.to(MapRect)
} else if (puzzle.roomType == PuzzleRoomType.AddWalls) {
wallSides = [true, true, true, true]
Expand Down

0 comments on commit 43606b3

Please sign in to comment.