diff --git a/src/generate.js b/src/generate.js index ad4d8b2e..669e2585 100644 --- a/src/generate.js +++ b/src/generate.js @@ -2,6 +2,7 @@ const seedrandom = require("seedrandom"); const aliasNightmare = require("./projects/alias-nightmare/index.js"); const theBackrooms = require("./projects/the-backrooms/index.js"); +const theLake = require("./projects/the-lake/index.js"); (async () => { // const seed = Math.floor(Math.random() * 1e20); @@ -14,9 +15,10 @@ const theBackrooms = require("./projects/the-backrooms/index.js"); levelIdx: 1, seed, lootTable: [], + bumpFactor: 3, }; - const project = "alias-nightmare"; + const project = "the-backrooms"; switch (project) { case "the-backrooms": @@ -24,7 +26,7 @@ const theBackrooms = require("./projects/the-backrooms/index.js"); ...config, numberOfRooms: 10, roomDimensions: { width: [1, 5], depth: [1, 5], height: 2 }, - percentOfLightsOn: 60, + percentOfLightsOn: 0, lootTable: [ { name: "almondWater", @@ -47,7 +49,11 @@ const theBackrooms = require("./projects/the-backrooms/index.js"); case "alias-nightmare": await aliasNightmare({ ...config, - bumpFactor: 3, + }); + break; + case "the-lake": + await theLake({ + ...config, }); break; } diff --git a/src/projects/the-backrooms/index.js b/src/projects/the-backrooms/index.js index 6be7294f..7e236b44 100644 --- a/src/projects/the-backrooms/index.js +++ b/src/projects/the-backrooms/index.js @@ -675,8 +675,6 @@ const generate = async (config) => { const lamps = []; - let isFirstLamp = true; - for (let y = 0; y < grid.length; y++) { for (let x = 0; x < grid[y].length; x++) { if (isOccupied(x, y, grid)) { @@ -690,11 +688,6 @@ const generate = async (config) => { on: randomBetween(0, 100) < config.percentOfLightsOn, }; - if (isFirstLamp) { - isFirstLamp = false; - lampConfig.on = true; - } - const lamp = addLamp( [ left + x * UNIT - 50 + offsetX, @@ -780,7 +773,6 @@ const generate = async (config) => { }, renderGrid(grid), - setColor("#0b0c10"), addZone( diff --git a/src/projects/the-lake/index.js b/src/projects/the-lake/index.js new file mode 100644 index 00000000..d10e1a21 --- /dev/null +++ b/src/projects/the-lake/index.js @@ -0,0 +1,79 @@ +const { compose } = require("ramda"); +const { ambiences } = require("../../assets/ambiences"); +const { + items, + createItem, + moveTo, + markAsUsed, + addScript, +} = require("../../assets/items"); +const { textures } = require("../../assets/textures"); +const { + saveToDisk, + finalize, + generateBlankMapData, + movePlayerTo, + addZone, + setColor, + setTexture, +} = require("../../helpers"); +const { plain } = require("../../prefabs"); +const { disableBumping } = require("../../prefabs/plain"); +const { getInjections } = require("../../scripting"); + +const createWelcomeMarker = (pos) => (config) => { + return compose( + markAsUsed, + moveTo(pos, [0, 0, 0]), + addScript((self) => { + return ` +// component: welcomeMarker +ON INIT { + ${getInjections("init", self)} + SETCONTROLLEDZONE palette0 + ACCEPT +} + +ON CONTROLLEDZONE_ENTER { + TELEPORT -p ${self.ref} + ACCEPT +} + `; + }), + createItem + )(items.marker); +}; + +const generate = async (config) => { + const { origin } = config; + + const welcomeMarker = createWelcomeMarker([0, 0, 0])(config); + + return compose( + saveToDisk, + finalize, + + plain([0, 0, 0], [10, 10], "floor"), + setTexture(textures.gravel.ground1), + setColor("lime"), + + addZone( + [-origin[0], 0, -origin[2]], + [100, 0, 100], + "palette0", + ambiences.none, + 5000 + ), + setColor("#DBF4FF"), + + movePlayerTo([-origin[0], 0, -origin[2]]), + (mapData) => { + mapData.meta.mapName = "The Lake"; + return mapData; + }, + + generateBlankMapData + )(config); +}; + +module.exports = generate;