Skip to content

Commit

Permalink
remove isBot
Browse files Browse the repository at this point in the history
  • Loading branch information
HexaField committed Mar 19, 2024
1 parent 4c03c1f commit f855406
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/functions/BotHookSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ import { BotHookFunctions } from './botHookFunctions'
import { sendXRInputData, simulateXR } from './xrBotHookFunctions'
import { defineSystem } from '@etherealengine/ecs/src/SystemFunctions'
import { SimulationSystemGroup } from '@etherealengine/ecs/src/SystemGroups'
import { BotUserAgent } from '@etherealengine/common/src/constants/BotUserAgent'

const setupBotKey = 'ee.bot.setupBotKey'

const isBot = navigator.userAgent === BotUserAgent

const execute = () => {
if (getState(EngineState).isBot && getState(XRState).session) {
if (isBot && getState(XRState).session) {
sendXRInputData()
}
}
Expand Down Expand Up @@ -42,4 +45,4 @@ export const BotHookSystem = defineSystem({
insert: { with: SimulationSystemGroup },
execute,
reactor
})
})
4 changes: 2 additions & 2 deletions src/functions/botHookFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { XRState } from '@etherealengine/spatial/src/xr/XRState'
import { NetworkState } from '@etherealengine/network'
import { SceneState } from '@etherealengine/engine/src/scene/Scene'
import { AvatarComponent } from '@etherealengine/engine/src/avatar/components/AvatarComponent'
import { BotUserAgent } from '@etherealengine/common/src/constants/BotUserAgent'

export const BotHookFunctions = {
[BotHooks.IsBot]:isBot,
Expand Down Expand Up @@ -54,7 +55,7 @@ export const BotHookFunctions = {
// === ENGINE === //

export function isBot(){
return getState(EngineState).isBot
return navigator.userAgent === BotUserAgent
}

export function worldNetworkReady() {
Expand Down Expand Up @@ -100,7 +101,6 @@ export function serializeEngine() {
const engine = {
userId: Engine.instance.userID,
store: Engine.instance.store,
isBot: getState(EngineState).isBot,
publicPath: getState(EngineState).publicPath,
xrFrame: getState(XRState).xrFrame,
isEditor: getState(EngineState).isEditor
Expand Down
1 change: 0 additions & 1 deletion src/functions/xrBotHookFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,5 @@ export async function simulateXR() {
// await loadScript(getState(EngineState).publicPath + '/scripts/webxr-polyfill.js')
await overrideXR()
await xrSupported()
getMutableState(EngineState).isBot.set(true)
await startXR()
}

0 comments on commit f855406

Please sign in to comment.