Skip to content

Commit

Permalink
feat: support new schemas (#732)
Browse files Browse the repository at this point in the history
* fix: adapted trigger to new schema

* fix: adapt action to new schema

* fix: upgrade @dcl/asset-packs

* fix: installed package in wrong directory 🤦

* fix: uninstalled package in wrong dir
  • Loading branch information
cazala authored Sep 13, 2023
1 parent b6e1264 commit 761f180
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 26 deletions.
25 changes: 14 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 9 additions & 7 deletions packages/@dcl/inspector/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion packages/@dcl/inspector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"@babylonjs/inspector": "^5.48.0",
"@babylonjs/loaders": "^5.48.0",
"@babylonjs/materials": "^5.48.0",
"@dcl/asset-packs": "^0.0.0-20230911215327.commit-4ff713d",
"@dcl/asset-packs": "^0.0.0-20230913161419.commit-562cd5d",
"@dcl/ecs": "file:../ecs",
"@dcl/ecs-math": "2.0.2",
"@dcl/mini-rpc": "^1.0.7",
Expand All @@ -17,6 +17,7 @@
"@testing-library/react": "^14.0.0",
"@types/jest-environment-puppeteer": "^5.0.3",
"@types/node": "^18.11.18",
"@types/node-fetch": "^2.6.4",
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"@types/react-modal": "^3.16.0",
Expand All @@ -31,6 +32,7 @@
"jest-environment-jsdom": "^29.5.0",
"jest-puppeteer": "^9.0.0",
"mitt": "^3.0.1",
"node-fetch": "^2.7.0",
"react": "^18.2.0",
"react-contexify": "^6.0.0",
"react-dnd": "^16.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,24 @@ export default withSdk<Props>(

const hasActions = useHasComponent(entityId, Actions)

const isValidAction = useCallback((action: Action) => {
if (!action.type || !action.name) {
return false
}
switch (action.type) {
case ActionType.PLAY_ANIMATION: {
return !!action.payload.playAnimation?.animation
}
case ActionType.SET_STATE: {
return !!action.payload.setState?.state
}
default:
return false
}
}, [])

const areValidActions = useCallback(
(updatedActions: Action[]) =>
updatedActions.length > 0 &&
!updatedActions.some((action) => !action.type || !action?.animation || !action.name),
(updatedActions: Action[]) => updatedActions.length > 0 && updatedActions.every(isValidAction),
[]
)

Expand Down Expand Up @@ -89,7 +103,7 @@ export default withSdk<Props>(

const handleAddNewAction = useCallback(() => {
setActions((prev: Action[]) => {
return [...prev, { type: ActionType.PLAY_ANIMATION, name: '' }]
return [...prev, { type: ActionType.PLAY_ANIMATION, name: '', payload: {} }]
})
}, [setActions])

Expand All @@ -99,7 +113,11 @@ export default withSdk<Props>(
const data = [...prev]
data[idx] = {
...data[idx],
animation: value
payload: {
playAnimation: {
animation: value
}
}
}
return data
})
Expand Down Expand Up @@ -241,7 +259,7 @@ export default withSdk<Props>(
{ value: '', text: 'Select an Animation' },
...entityAnimations.map((animation) => ({ text: animation.name, value: animation.name }))
]}
value={action.animation}
value={action.payload.playAnimation?.animation}
onChange={(e) => handleChangeAnimation(e, idx)}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useCallback, useEffect, useMemo, useState } from 'react'
import { Entity } from '@dcl/ecs'
import { Action, Trigger, TriggerType, TriggerAction } from '@dcl/asset-packs'
import { Action, Trigger, TriggerType, TriggerAction, TriggerConditionOperation } from '@dcl/asset-packs'
import { Item } from 'react-contexify'
import { AiFillDelete as DeleteIcon, AiOutlinePlus as AddIcon } from 'react-icons/ai'
import { VscQuestion as QuestionIcon } from 'react-icons/vsc'
Expand Down Expand Up @@ -85,6 +85,8 @@ export default withSdk<Props>(
...prev,
{
type: TriggerType.ON_CLICK,
conditions: [],
operation: TriggerConditionOperation.AND,
actions: [
{
entity: undefined,
Expand Down

0 comments on commit 761f180

Please sign in to comment.