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

remove queue display init from queue #9

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
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
Loading