Skip to content

Commit

Permalink
remove queue display init from queue (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
gonpombo8 authored Aug 8, 2024
1 parent 4a9e248 commit 5e2c096
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IEngine, TransformType } from '@dcl/sdk/ecs'
import { IEngine } from '@dcl/sdk/ecs'
import type playersType from '@dcl/sdk/players'
import type { syncEntity as SyncEntityType } from '@dcl/sdk/network'

Expand All @@ -12,7 +12,6 @@ export type IOptions = {
environment: string
gameTimeoutMs?: number
sceneRotation?: number
queueDisplay?: TransformType
}

export let engine: IEngine
Expand Down
5 changes: 2 additions & 3 deletions src/queue/display/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ let timer = 0
let timer2 = 0
let showEnterScreen = true
let initialized = false
export function init(transform: TransformType) {

export function initQueueDisplay(transform: TransformType) {
if (initialized) return
initialized = true
const {
Expand Down Expand Up @@ -248,5 +249,3 @@ function updateListSystem(dt: number) {
VisibilityComponent.getMutable(waitingListEntity).visible = true
VisibilityComponent.getMutable(myPosEntity).visible = true
}

export default init
10 changes: 3 additions & 7 deletions src/queue/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Entity } from '@dcl/sdk/ecs'
import { initQueueDisplay } from './display'
import { getSDK } from '../sdk'
import * as queueDisplay from './display'

export type PlayerType = {
address: string
Expand All @@ -9,6 +9,7 @@ export type PlayerType = {
active: boolean
}

export { initQueueDisplay }
/**
* listeners.onActivePlayerChange = (player) => player.address
*/
Expand Down Expand Up @@ -38,19 +39,14 @@ export function addPlayer() {
const {
engine,
syncEntity,
components: { Player },
config
components: { Player }
} = 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 5e2c096

Please sign in to comment.