Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add queue display after the game models because its overriding some s… #8

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading