Skip to content

Commit e7442e7

Browse files
committed
use new event sourcing reactor API
1 parent 5f3800a commit e7442e7

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

src/BasicSystem.tsx

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { NetworkTopics } from '@etherealengine/spatial/src/networking/classes/Ne
1616
import { WorldNetworkAction } from '@etherealengine/spatial/src/networking/functions/WorldNetworkAction'
1717

1818
import { isClient } from '@etherealengine/common/src/utils/getEnvironment'
19-
import { PresentationSystemGroup, defineSystem, getComponent, setComponent } from '@etherealengine/ecs'
19+
import { SimulationSystemGroup, defineSystem, getComponent, setComponent } from '@etherealengine/ecs'
2020
import { ECSState } from '@etherealengine/ecs/src/ECSState'
2121
import { PrimitiveGeometryComponent } from '@etherealengine/engine/src/scene/components/PrimitiveGeometryComponent'
2222
import { GeometryTypeEnum } from '@etherealengine/engine/src/scene/constants/GeometryTypeEnum'
@@ -61,6 +61,21 @@ const BasicState = defineState({
6161
const state = getMutableState(BasicState)
6262
state[action.entityUUID].set(none)
6363
})
64+
},
65+
66+
/**
67+
* Observe spawn events and create a sub-reactor for each entry in the basic state
68+
*/
69+
70+
reactor: () => {
71+
const basicState = useHookstate(getMutableState(BasicState))
72+
return (
73+
<>
74+
{basicState.keys.map((entityUUID: EntityUUID) => (
75+
<BasicObject key={entityUUID} entityUUID={entityUUID} />
76+
))}
77+
</>
78+
)
6479
}
6580
})
6681

@@ -93,21 +108,6 @@ const BasicObject = ({ entityUUID }: { entityUUID: EntityUUID }) => {
93108
return null
94109
}
95110

96-
/**
97-
* Observe spawn events and create a sub-reactor for each entry in the basic state
98-
*/
99-
100-
const reactor = () => {
101-
const basicState = useHookstate(getMutableState(BasicState))
102-
return (
103-
<>
104-
{basicState.keys.map((entityUUID: EntityUUID) => (
105-
<BasicObject key={entityUUID} entityUUID={entityUUID} />
106-
))}
107-
</>
108-
)
109-
}
110-
111111
let counter = 0
112112
const spawnRate = 3
113113

@@ -136,8 +136,7 @@ const execute = () => {
136136
*/
137137

138138
export const BasicSystem = defineSystem({
139-
uuid: 'basic.system',
140-
reactor,
139+
uuid: 'ee.basic.system',
141140
execute,
142-
insert: { after: PresentationSystemGroup }
141+
insert: { with: SimulationSystemGroup }
143142
})

0 commit comments

Comments
 (0)