Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

New System Defintions #7864

Merged
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
b4128e0
WIP
speigg Mar 31, 2023
7cebb40
Cleanup
speigg Mar 31, 2023
6575eb3
Merge branch 'dev' of https://github.com/EtherealEngine/etherealengin…
HexaField Apr 5, 2023
5fe6bfe
Merge branch 'dev' of https://github.com/EtherealEngine/etherealengin…
HexaField Apr 12, 2023
35a122c
continue with mvp api
HexaField Apr 12, 2023
fffcb91
update a bunch of systems
HexaField Apr 13, 2023
0a50320
more systems
HexaField Apr 13, 2023
6ef9751
finish off systems and separate insertSystems from defineSystem
HexaField Apr 13, 2023
ca09acd
finalize pattern for insertion
HexaField Apr 14, 2023
412eaa5
Merge branch 'dev' of https://github.com/EtherealEngine/etherealengin…
HexaField Apr 14, 2023
b6b32a4
refactor defintions and actions
HexaField Apr 14, 2023
777538c
fixes
HexaField Apr 14, 2023
b035400
page sort of loads
HexaField Apr 14, 2023
7d4714a
Merge branch 'dev' of https://github.com/EtherealEngine/etherealengin…
HexaField Apr 14, 2023
8f007d4
more fixes
HexaField Apr 15, 2023
b012933
more
HexaField Apr 15, 2023
8aa3ef8
Automate removeActionQueue cleanup
speigg Apr 15, 2023
3158499
Automate removeQuery cleanup
speigg Apr 15, 2023
5aeb7a2
Cleanup unnecessary query & action queue removals
speigg Apr 15, 2023
eb3096c
Fix errors
speigg Apr 15, 2023
edc8de8
fix client modules not loading
HexaField Apr 16, 2023
a9a969b
remove sceneLoadingRegistry
HexaField Apr 16, 2023
e68ad70
remove sceneComponentRegistry
HexaField Apr 16, 2023
f0e0a72
load fix
HexaField Apr 16, 2023
aa2ccdd
simplify defineSystem
speigg Apr 16, 2023
ebe8143
Merge branch 'dev' of https://github.com/EtherealEngine/etherealengin…
HexaField Apr 17, 2023
0a1fe08
merge
HexaField Apr 17, 2023
03f39e1
editor loads
HexaField Apr 17, 2023
eb8dd72
all routes working
HexaField Apr 17, 2023
38bb8c6
fix shadow bugs
HexaField Apr 17, 2023
6b7ec6d
disable avatar context menu
HexaField Apr 17, 2023
9ece0ac
separate initializenode from createengine
HexaField Apr 18, 2023
675d5ac
Merge branch 'dev' of https://github.com/EtherealEngine/etherealengin…
HexaField Apr 18, 2023
47bd8ba
fix weird build error
HexaField Apr 18, 2023
b203c42
fix tsc errors and tests
HexaField Apr 18, 2023
122f491
tests pass
HexaField Apr 18, 2023
5fd2f85
update test
HexaField Apr 18, 2023
45bbc26
fixes
HexaField Apr 18, 2023
a017abd
more
HexaField Apr 18, 2023
6e4314b
fix debug menu
HexaField Apr 18, 2023
aabe904
fix bug with project system importing
HexaField Apr 18, 2023
86fa4bb
fix loader, make system component backwards compatible
HexaField Apr 18, 2023
64197a9
cleanup
HexaField Apr 18, 2023
f0807e3
rename createActionQueue
HexaField Apr 18, 2023
32eb9ed
refactor currentSystemUUID onto Engine
HexaField Apr 18, 2023
a869222
rename ClientSystems to startClientSystems
HexaField Apr 18, 2023
b068c64
rename useDefaultLocationSystems
HexaField Apr 18, 2023
02c09b6
rename startCaptureSystems
HexaField Apr 18, 2023
9a38d78
update i18n
HexaField Apr 18, 2023
5f58ed1
fixes
HexaField Apr 18, 2023
1fdaaeb
update warning ui system
HexaField Apr 18, 2023
9632146
fix physics, make getDAG more useful
HexaField Apr 19, 2023
8b8b7c3
fix physics system
HexaField Apr 19, 2023
1accc07
Merge branch 'dev' of https://github.com/EtherealEngine/etherealengin…
HexaField Apr 19, 2023
b5ad3a0
add back throws to addComponent
HexaField Apr 19, 2023
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: 4 additions & 0 deletions packages/client-core/i18n/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
"stats": "Stats",
"debugOptions": "Debug Options",
"debug": "Debug Helpers",
"preSystems": "Pre Systems",
"simulation": "Simulation Group",
"subSystems": "Sub System",
HexaField marked this conversation as resolved.
Show resolved Hide resolved
"postSystems": "Post Systems",
"nodeHelperDebug": "Node Helper",
"gridDebug": "Grid",
"tick": "Tick",
Expand Down
3 changes: 2 additions & 1 deletion packages/client-core/i18n/en/editor.json
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,8 @@
"systemnode": {
"description": "Attach script.",
"lbl-filePath": "Url",
"lbl-systemUpdateType": "Injection Point",
"lbl-insertUUID": "Insertion Point",
HexaField marked this conversation as resolved.
Show resolved Hide resolved
"lbl-insertOrder": "Insertion Order",
"lbl-enableClient": "Client",
"lbl-enableServer": "Server",
"lbl-args": "Args",
Expand Down
29 changes: 9 additions & 20 deletions packages/client-core/src/admin/adminRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,22 @@ import React, { lazy, Suspense, useEffect } from 'react'
import { Navigate, Route, Routes, useLocation } from 'react-router-dom'

import { EngineActions } from '@etherealengine/engine/src/ecs/classes/EngineState'
import { initSystems } from '@etherealengine/engine/src/ecs/functions/SystemFunctions'
import { SystemUpdateType } from '@etherealengine/engine/src/ecs/functions/SystemUpdateType'
import { PresentationSystemGroup } from '@etherealengine/engine/src/ecs/functions/EngineFunctions'
import { startSystems } from '@etherealengine/engine/src/ecs/functions/SystemFunctions'
import { dispatchAction } from '@etherealengine/hyperflux'
import Dashboard from '@etherealengine/ui/src/Dashboard'

import { LoadingCircle } from '../components/LoadingCircle'
import AdminSystem from '../systems/AdminSystem'
import { AdminSystem } from '../systems/AdminSystem'
import { useAuthState } from '../user/services/AuthService'
import UserUISystem from '../user/UserUISystem'
import { UserUISystem } from '../user/UserUISystem'
import Analytics from './components/Analytics'

const $allowed = lazy(() => import('@etherealengine/client-core/src/admin/allowedRoutes'))

const AdminSystemInjection = [
{
uuid: 'core.admin.AdminSystem',
type: SystemUpdateType.POST_RENDER,
systemLoader: () => Promise.resolve({ default: AdminSystem })
},
{
uuid: 'ee.client.core.UserUISystem',
type: SystemUpdateType.POST_RENDER,
systemLoader: () => Promise.resolve({ default: UserUISystem })
}
]
const AdminSystemInjection = () => {
startSystems([AdminSystem, UserUISystem], { after: PresentationSystemGroup })
}

const AdminRoutes = () => {
const location = useLocation()
Expand All @@ -53,10 +44,8 @@ const AdminRoutes = () => {
const scopes = admin?.scopes?.value || []

useEffect(() => {
initSystems(AdminSystemInjection).then(async () => {
// @ts-ignore
dispatchAction(EngineActions.initializeEngine({ initialised: true }))
})
AdminSystemInjection()
dispatchAction(EngineActions.initializeEngine({ initialised: true }))
}, [])

scopes.forEach((scope) => {
Expand Down
42 changes: 27 additions & 15 deletions packages/client-core/src/admin/components/Avatars/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import React, { useState } from 'react'
import { useTranslation } from 'react-i18next'

import ConfirmDialog from '@etherealengine/client-core/src/common/components/ConfirmDialog'
import { AvatarClientModule } from '@etherealengine/engine/src/avatar/AvatarClientModule'
import { AvatarCommonModule } from '@etherealengine/engine/src/avatar/AvatarCommonModule'
import { useSystems } from '@etherealengine/engine/src/ecs/functions/useSystems'
import { RendererModule } from '@etherealengine/engine/src/renderer/RendererModule'
import { SceneClientModule } from '@etherealengine/engine/src/scene/SceneClientModule'
import { SceneCommonModule } from '@etherealengine/engine/src/scene/SceneCommonModule'
import { TransformModule } from '@etherealengine/engine/src/transform/TransformModule'
import { AnimationSystem } from '@etherealengine/engine/src/avatar/AnimationSystem'
import { AvatarAnimationSystem } from '@etherealengine/engine/src/avatar/AvatarAnimationSystem'
import { AvatarSpawnSystem } from '@etherealengine/engine/src/avatar/AvatarSpawnSystem'
import { DebugRendererSystem } from '@etherealengine/engine/src/debug/systems/DebugRendererSystem'
import { AnimationSystemGroup, PresentationSystemGroup } from '@etherealengine/engine/src/ecs/functions/EngineFunctions'
import { useSystem, useSystems } from '@etherealengine/engine/src/ecs/functions/SystemFunctions'
import { WebGLRendererSystem } from '@etherealengine/engine/src/renderer/WebGLRendererSystem'
import { SceneSystemLoadGroup, SceneSystemUpdateGroup } from '@etherealengine/engine/src/scene/SceneClientModule'
import { SceneObjectSystem } from '@etherealengine/engine/src/scene/systems/SceneObjectSystem'
import Box from '@etherealengine/ui/src/Box'
import Button from '@etherealengine/ui/src/Button'
import Grid from '@etherealengine/ui/src/Grid'
Expand All @@ -28,14 +30,24 @@ const Avatar = () => {
const [openDeleteAvatarModal, setOpenDeleteAvatarModal] = React.useState(false)
const [selectedAvatarIds, setSelectedAvatarIds] = useState(() => new Set<string>())

useSystems([
...TransformModule(),
...RendererModule(),
...SceneCommonModule(),
...SceneClientModule(),
...AvatarCommonModule(),
...AvatarClientModule()
])
/** Avatar / Animation */
useSystems([AnimationSystem, AvatarSpawnSystem, AvatarAnimationSystem], {
with: AnimationSystemGroup
})

/** Post Transform / Pre Render */
useSystems([SceneObjectSystem, DebugRendererSystem, SceneSystemUpdateGroup], {
before: PresentationSystemGroup
})

/** Render */
useSystem(WebGLRendererSystem, {
with: PresentationSystemGroup
})

useSystem(SceneSystemLoadGroup, {
after: PresentationSystemGroup
})

const handleChange = (e: any) => {
setSearch(e.target.value)
Expand Down
11 changes: 4 additions & 7 deletions packages/client-core/src/admin/components/Project/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, { useEffect } from 'react'
import { useTranslation } from 'react-i18next'

import { initSystems } from '@etherealengine/engine/src/ecs/functions/SystemFunctions'
import { PresentationSystemGroup } from '@etherealengine/engine/src/ecs/functions/EngineFunctions'
import { useSystem } from '@etherealengine/engine/src/ecs/functions/SystemFunctions'
import { useHookstate } from '@etherealengine/hyperflux'
import Box from '@etherealengine/ui/src/Box'
import Button from '@etherealengine/ui/src/Button'
Expand All @@ -10,6 +11,7 @@ import CircularProgress from '@etherealengine/ui/src/CircularProgress'
import Grid from '@etherealengine/ui/src/Grid'

import { ProjectService, useProjectState } from '../../../common/services/ProjectService'
import { ProjectUpdateSystem } from '../../../systems/ProjectUpdateSystem'
import { useAuthState } from '../../../user/services/AuthService'
import styles from '../../styles/admin.module.scss'
import BuildStatusDrawer from './BuildStatusDrawer'
Expand All @@ -34,14 +36,9 @@ const Projects = () => {
ProjectService.refreshGithubRepoAccess()
}

const ProjectUpdateSystemInjection = {
uuid: 'core.admin.ProjectUpdateSystem',
type: 'PRE_RENDER',
systemLoader: () => import('../../../systems/ProjectUpdateSystem')
} as const
useSystem(ProjectUpdateSystem, { after: PresentationSystemGroup })

useEffect(() => {
initSystems([ProjectUpdateSystemInjection])
ProjectService.checkReloadStatus()
}, [])

Expand Down
104 changes: 70 additions & 34 deletions packages/client-core/src/components/Debug/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React, { useEffect, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import JSONTree from 'react-json-tree'

import { mapToObject } from '@etherealengine/common/src/utils/mapToObject'
import { AvatarControllerComponent } from '@etherealengine/engine/src/avatar/components/AvatarControllerComponent'
import { respawnAvatar } from '@etherealengine/engine/src/avatar/functions/respawnAvatar'
import { Engine } from '@etherealengine/engine/src/ecs/classes/Engine'
Expand All @@ -15,20 +14,63 @@ import {
getOptionalComponent,
hasComponent
} from '@etherealengine/engine/src/ecs/functions/ComponentFunctions'
import { RootSystemGroup, SimulationSystemGroup } from '@etherealengine/engine/src/ecs/functions/EngineFunctions'
import { entityExists } from '@etherealengine/engine/src/ecs/functions/EntityFunctions'
import { EntityOrObjectUUID, EntityTreeComponent } from '@etherealengine/engine/src/ecs/functions/EntityTree'
import { SystemInstance } from '@etherealengine/engine/src/ecs/functions/SystemFunctions'
import { EntityTreeComponent } from '@etherealengine/engine/src/ecs/functions/EntityTree'
import { System, SystemDefinitions, SystemUUID } from '@etherealengine/engine/src/ecs/functions/SystemFunctions'
import { NetworkState } from '@etherealengine/engine/src/networking/NetworkState'
import { RendererState } from '@etherealengine/engine/src/renderer/RendererState'
import { NameComponent } from '@etherealengine/engine/src/scene/components/NameComponent'
import { UUIDComponent } from '@etherealengine/engine/src/scene/components/UUIDComponent'
import { ObjectLayers } from '@etherealengine/engine/src/scene/constants/ObjectLayers'
import { dispatchAction, getMutableState, useHookstate } from '@etherealengine/hyperflux'
import { getMutableState, useHookstate } from '@etherealengine/hyperflux'
import Icon from '@etherealengine/ui/src/Icon'

import { StatsPanel } from './StatsPanel'
import styles from './styles.module.scss'

type DesiredType =
| {
enabled?: boolean
preSystems?: Record<SystemUUID, DesiredType>
simulation?: DesiredType
subSystems?: Record<SystemUUID, DesiredType>
postSystems?: Record<SystemUUID, DesiredType>
}
| boolean // enabled

const convertSystemTypeToDesiredType = (system: System): DesiredType => {
const { preSystems, subSystems, postSystems } = system
if (preSystems.length === 0 && subSystems.length === 0 && postSystems.length === 0) {
return Engine.instance.activeSystems.has(system.uuid)
}
const desired: DesiredType = {
enabled: Engine.instance.activeSystems.has(system.uuid)
}
if (preSystems.length > 0) {
desired.preSystems = preSystems.reduce((acc, uuid) => {
acc[uuid] = convertSystemTypeToDesiredType(SystemDefinitions.get(uuid)!)
return acc
}, {} as Record<SystemUUID, DesiredType>)
}
if (system.uuid === RootSystemGroup) {
desired.simulation = convertSystemTypeToDesiredType(SystemDefinitions.get(SimulationSystemGroup)!)
}
if (subSystems.length > 0) {
desired.subSystems = subSystems.reduce((acc, uuid) => {
acc[uuid] = convertSystemTypeToDesiredType(SystemDefinitions.get(uuid)!)
return acc
}, {} as Record<SystemUUID, DesiredType>)
}
if (postSystems.length > 0) {
desired.postSystems = postSystems.reduce((acc, uuid) => {
acc[uuid] = convertSystemTypeToDesiredType(SystemDefinitions.get(uuid)!)
return acc
}, {} as Record<SystemUUID, DesiredType>)
}
if (system.uuid === RootSystemGroup) delete desired.enabled
return desired
}

export const Debug = ({ showingStateRef }) => {
useHookstate(getMutableState(EngineState).frameTime).value
const rendererState = useHookstate(getMutableState(RendererState))
Expand Down Expand Up @@ -127,7 +169,8 @@ export const Debug = ({ showingStateRef }) => {

const namedEntities = useHookstate({})
const entityTree = useHookstate({} as any)
const pipelines = Engine.instance.pipelines

const dag = convertSystemTypeToDesiredType(SystemDefinitions.get(RootSystemGroup)!)

namedEntities.set(renderAllEntities())
entityTree.set(renderEntityTreeRoots())
Expand Down Expand Up @@ -181,41 +224,34 @@ export const Debug = ({ showingStateRef }) => {
<div className={styles.jsonPanel}>
<h1>{t('common:debug.systems')}</h1>
<JSONTree
data={pipelines}
postprocessValue={(v: SystemInstance) => {
if (!v?.name) return v
const s = new String(v.sceneSystem ? v.name : v.uuid) as any
if (v.subsystems?.length) {
s.parentSystem = v
return {
[s]: s,
subsystems: v.subsystems
}
}
s.instance = v
return s
}} // yes, all this is a hack. We probably shouldn't use JSONTree for this
valueRenderer={(raw, value: { instance: SystemInstance; parentSystem: SystemInstance }) => {
return value.parentSystem ? (
data={dag}
labelRenderer={(raw, ...keyPath) => {
const label = raw[0]
if (label === 'preSystems') return <span style={{ color: 'red' }}>{t('common:debug.preSystems')}</span>
if (label === 'simulation') return <span style={{ color: 'green' }}>{t('common:debug.simulation')}</span>
if (label === 'subSystems') return <span style={{ color: 'red' }}>{t('common:debug.subSystems')}</span>
if (label === 'postSystems') return <span style={{ color: 'red' }}>{t('common:debug.postSystems')}</span>
return <span style={{ color: 'black' }}>{label}</span>
}}
valueRenderer={(raw, value, ...keyPath) => {
const system = SystemDefinitions.get((keyPath[0] === 'enabled' ? keyPath[1] : keyPath[0]) as SystemUUID)!
return (
<>
<input
type="checkbox"
checked={value?.parentSystem?.enabled}
onChange={() => (value.parentSystem.enabled = !value.parentSystem.enabled)}
checked={value}
onChange={() => {
if (Engine.instance.activeSystems.has(system.uuid)) {
Engine.instance.activeSystems.delete(system.uuid)
} else {
Engine.instance.activeSystems.add(system.uuid)
}
}}
></input>
</>
) : (
<>
<input
type="checkbox"
checked={value?.instance?.enabled}
onChange={() => (value.instance.enabled = !value.instance.enabled)}
></input>{' '}
— {value}
</>
)
}}
shouldExpandNode={(keyPath, data, level) => level > 0}
shouldExpandNode={() => true}
/>
</div>
<div className={styles.jsonPanel}>
Expand Down
Loading