Skip to content

Commit

Permalink
add queue display after the game models because its overriding some s…
Browse files Browse the repository at this point in the history
…tuff (#8)
  • Loading branch information
gonpombo8 authored Aug 8, 2024
1 parent ab18a61 commit 4a9e248
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/queue/display/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ const frameModel = 'mini-game-assets/models/queueDisplay/workstation_display.glb
let timer = 0
let timer2 = 0
let showEnterScreen = true

let initialized = false
export function init(transform: TransformType) {
if (initialized) return
initialized = true
const {
engine,
components: { Transform, GltfContainer, Material, MeshRenderer, VisibilityComponent },
Expand Down
17 changes: 9 additions & 8 deletions src/queue/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,13 @@ let initializedQueue = false
export function startPlayersQueue() {
if (initializedQueue) return
initializedQueue = true
const { engine, players, config } = getSDK()

if (config.queueDisplay) {
queueDisplay.init(config.queueDisplay)
}

const { engine, players } = getSDK()
players.onLeaveScene((userId: string) => {
console.log('Player leave scene', userId)
removePlayer(userId)
})

engine.addSystem(internalPlayerSystem())
// TODO: TIME LIMIT PER GAME (startPlayingAt - TIME_LIMIT)
}
/**
* Add current player to the queue
Expand All @@ -44,12 +38,19 @@ export function addPlayer() {
const {
engine,
syncEntity,
components: { Player }
components: { Player },
config
} = getSDK()

const userId = getUserId()
if (!userId || isPlayerInQueue(userId)) {
return
}

if (config.queueDisplay) {
queueDisplay.init(config.queueDisplay)
}

const timestamp = Date.now()
const entity = engine.addEntity()
Player.create(entity, { address: userId, joinedAt: timestamp })
Expand Down

0 comments on commit 4a9e248

Please sign in to comment.