Skip to content

Commit

Permalink
feat: remove StartGameButtonCheck
Browse files Browse the repository at this point in the history
  • Loading branch information
Pejosonic committed Nov 26, 2024
1 parent 272684e commit d3f6d66
Showing 1 changed file with 1 addition and 33 deletions.
34 changes: 1 addition & 33 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import type { syncEntity as SyncEntityType, isStateSyncronized as IsStateSyncron
import { startPlayersQueue } from './queue'
import * as gameConfig from './config'
import * as progress from './progress'
import { getSDK, setSDK } from './sdk'
import { setSDK } from './sdk'
import { gameAreaCheck } from './environment/game-area-check'
import { MenuButton } from './ui'

export type IOptions = {
gameId: string
Expand Down Expand Up @@ -40,37 +39,6 @@ export function initLibrary(
}
}

export function StartGameButtonCheck(button: MenuButton) {
const {
isStateSyncronized,
engine,
components: { RealmInfo }
} = getSDK()

// Disable the start game button till the user is connected to comms.
button.disable()

// Enable start game button after we are connected to comms.
// Maybe I can create a custom component to detect when the initial state has been syncronized and await for that component.
// But for the moment I'll go this way to debug if this works.
engine.addSystem(() => {
const realmInfo = RealmInfo.getOrNull(engine.RootEntity)
if (!realmInfo) return

if (isStateSyncronized() && realmInfo.isConnectedSceneRoom && !button.enabled) {
console.log('Enable Start Game')
button.enable()
}

if ((!realmInfo.isConnectedSceneRoom || !isStateSyncronized()) && button.enabled) {
console.log(
`Disable Start Game. { isConnectedSceneRoom: ${realmInfo.isConnectedSceneRoom}, isStateSyncronized: ${isStateSyncronized()} }`
)
button.disable()
}
})
}

export * as ui from './ui'
export * as queue from './queue'
export { sceneParentEntity } from './config'
Expand Down

0 comments on commit d3f6d66

Please sign in to comment.