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

Commit

Permalink
Merge pull request #59 from EtherealEngine/working-behave-graph
Browse files Browse the repository at this point in the history
use exportable active behave graph
  • Loading branch information
anselm authored Nov 7, 2023
2 parents 7da5200 + 896108d commit 450010c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
2 changes: 1 addition & 1 deletion assets/graph/simpleController.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"value": "speed"
},
"value": {
"value": "2"
"value": ".8"
}
}
},
Expand Down
19 changes: 3 additions & 16 deletions examples/behaveGraph.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import React from 'react'

import { GraphJSON } from '@behave-graph/core'
import { Flow } from '@etherealengine/editor/src/components/graph/ee-flow'
import { ActiveBehaveGraph } from '@etherealengine/editor/src/components/graph/BehaveFlow'
import '@etherealengine/editor/src/components/graph/ee-flow/styles.css'
import { BehaveGraphComponent } from '@etherealengine/engine/src/behave-graph/components/BehaveGraphComponent'
import { BehaveGraphState } from '@etherealengine/engine/src/behave-graph/state/BehaveGraphState'
import { setComponent, useComponent } from '@etherealengine/engine/src/ecs/functions/ComponentFunctions'
import { setComponent } from '@etherealengine/engine/src/ecs/functions/ComponentFunctions'
import { createEntity } from '@etherealengine/engine/src/ecs/functions/EntityFunctions'
import { NO_PROXY, getMutableState, useHookstate } from '@etherealengine/hyperflux'
import isEqual from 'lodash/isEqual'
import AutoSizer from 'react-virtualized-auto-sizer'
import 'reactflow/dist/style.css'
import targetJson from '../assets/graph/simpleController.json'
Expand All @@ -18,8 +15,6 @@ const entity = createEntity()
setComponent(entity, BehaveGraphComponent, { graph: targetJson as unknown as GraphJSON })

export default function behaveGraphTest() {
const graphComponent = useComponent(entity, BehaveGraphComponent)
const behavegraphState = useHookstate(getMutableState(BehaveGraphState))

return (
<>
Expand All @@ -37,15 +32,7 @@ export default function behaveGraphTest() {
<AutoSizer>
{({ width, height }) => (
<div style={{ width, height }}>
<Flow
initialGraph={graphComponent?.value?.graph}
examples={{}}
registry={behavegraphState.registries.get(NO_PROXY)[graphComponent?.domain.value]}
onChangeGraph={(newGraph) => {
if (!graphComponent.graph || isEqual(graphComponent.graph.get(NO_PROXY), newGraph)) return
graphComponent.graph.set(JSON.parse(JSON.stringify(newGraph)))
}}
/>
<ActiveBehaveGraph entity={entity} />
</div>
)}
</AutoSizer>
Expand Down

0 comments on commit 450010c

Please sign in to comment.