diff --git a/src/gameStateManager.ts b/src/gameStateManager.ts index 8258023..65218b1 100644 --- a/src/gameStateManager.ts +++ b/src/gameStateManager.ts @@ -63,10 +63,11 @@ export const createGameStateManager = (settings: Settings) => { const numberOfCollectedGames = new Variable('int', 'number_of_collected_games', 0) const playerFoundAnyGames = new Variable('bool', 'player_found_any_games', false) + const isGoblinReadyForSuicide = new Variable('bool', 'is_goblin_ready_for_suicide', false) const isGoblinDead = new Variable('bool', 'is_goblin_dead', false) const haveLittered = new Variable('bool', 'have_littered', false) - manager.script?.properties.push(numberOfCollectedGames, playerFoundAnyGames, isGoblinDead) + manager.script?.properties.push(numberOfCollectedGames, playerFoundAnyGames, isGoblinReadyForSuicide, isGoblinDead) manager.script?.subroutines.push( tutorialWelcome, @@ -123,5 +124,43 @@ export const createGameStateManager = (settings: Settings) => { ` }) + manager.script?.on('entered_at_the_game_displays_zone', () => { + return ` + if (${numberOfCollectedGames.name} < 7) { + accept + } + + if (${isGoblinDead.name} == 1) { + accept + } + + if (${isGoblinReadyForSuicide.name} == 1) { + accept + } + + set ${isGoblinReadyForSuicide.name} 1 + sendevent goblin_vanishes self nop + ` + }) + + manager.script?.on('entered_at_the_main_hall_zone', () => { + return ` + if (${numberOfCollectedGames.name} < 7) { + accept + } + + if (${isGoblinReadyForSuicide.name} == 0) { + accept + } + + if (${isGoblinDead.name} == 1) { + accept + } + + set ${isGoblinDead.name} 1 + sendevent goblin_suicide self nop + ` + }) + return manager } diff --git a/src/rooms/leftCorridor.ts b/src/rooms/leftCorridor.ts index cb3e35d..306e789 100644 --- a/src/rooms/leftCorridor.ts +++ b/src/rooms/leftCorridor.ts @@ -1,6 +1,7 @@ import { Entity, Material, Rotation, Settings, Texture, Vector3 } from 'arx-level-generator' import { createBox } from 'arx-level-generator/prefabs/mesh' -import { Scale, Shadow } from 'arx-level-generator/scripting/properties' +import { ControlZone, Scale, Shadow } from 'arx-level-generator/scripting/properties' +import { createZone } from 'arx-level-generator/tools' import { circleOfVectors } from 'arx-level-generator/utils' import { MathUtils } from 'three' import { GameDisplay } from '@/entities/GameDisplay.js' @@ -122,11 +123,42 @@ export const createLeftCorridor = async ( return `sendevent player_found_a_game ${gameStateManager.ref} ${game.variant}` }) + const atTheGameDisplaysZone = createZone({ + name: 'at_the_game_displays', + size: new Vector3(200, Infinity, 200), + position: new Vector3(-1900, 0, 0), + }) + + const atTheGameDisplaysZoneController = Entity.marker.at({ position: new Vector3(-1900, 0, 0) }).withScript() + atTheGameDisplaysZoneController.script?.properties.push(new ControlZone(atTheGameDisplaysZone)) + atTheGameDisplaysZoneController.script?.on('controlledzone_enter', () => { + return `sendevent entered_at_the_game_displays_zone ${gameStateManager.ref} nop` + }) + + const atTheMainHallZone = createZone({ + name: 'at_the_main_hall', + size: new Vector3(200, Infinity, 200), + position: new Vector3(-400, 0, 0), + }) + + const atTheMainHallZoneController = Entity.marker.at({ position: new Vector3(-1900, 0, 0) }).withScript() + atTheMainHallZoneController.script?.properties.push(new ControlZone(atTheMainHallZone)) + atTheMainHallZoneController.script?.on('controlledzone_enter', () => { + return `sendevent entered_at_the_main_hall_zone ${gameStateManager.ref} nop` + }) + return { meshes: [...bases], - entities: [rootMirror, mirror, ...Object.values(gameDisplays), game], + entities: [ + rootMirror, + mirror, + ...Object.values(gameDisplays), + game, + atTheGameDisplaysZoneController, + atTheMainHallZoneController, + ], lights: [], - zones: [], + zones: [atTheGameDisplaysZone, atTheMainHallZone], _: {}, } } diff --git a/src/rooms/mainHall.ts b/src/rooms/mainHall.ts index a57b9a2..5c1c4f1 100644 --- a/src/rooms/mainHall.ts +++ b/src/rooms/mainHall.ts @@ -53,7 +53,7 @@ export const createMainHall = async ( }) } - gameStateManager.script?.on('goblin_suicide', () => { + gameStateManager.script?.on('goblin_vanishes', () => { return `destroy ${goblin.ref}` }) diff --git a/src/rooms/pcRoom.ts b/src/rooms/pcRoom.ts index b71dee2..6b65e11 100644 --- a/src/rooms/pcRoom.ts +++ b/src/rooms/pcRoom.ts @@ -86,6 +86,8 @@ export const createPCRoom = async (settings: Settings, gameStateManager: Entity) sendevent change_to_big_rigs ${computer._.screen.ref} nop sendevent emit_dying_sound ${hangedGoblin.ref} nop + + // TODO: close the door ` })