From ab22e269e0d5c5867e584ab871a36cdbbfc8bd26 Mon Sep 17 00:00:00 2001 From: democritus Date: Fri, 10 Nov 2023 16:44:59 +0100 Subject: [PATCH] phasher systems --- .../src/phaser/systems/move.ts | 58 +++++++++---------- .../react/src/syncManager/syncFunction.ts | 7 ++- 2 files changed, 35 insertions(+), 30 deletions(-) diff --git a/examples/react-phaser-example/src/phaser/systems/move.ts b/examples/react-phaser-example/src/phaser/systems/move.ts index 7031d26a..85a053d2 100644 --- a/examples/react-phaser-example/src/phaser/systems/move.ts +++ b/examples/react-phaser-example/src/phaser/systems/move.ts @@ -26,41 +26,41 @@ export const move = (layer: PhaserLayer) => { }, } = layer; - defineEnterSystem(world, [Has(Position)], ({ entity }: any) => { - const playerObj = objectPool.get(entity.toString(), "Sprite"); - - const type = getComponentValue(RPSType, entity.toString() as Entity); - - console.log("defineEnterSystem", type?.rps); - - let animation = Animations.RockIdle; - - switch (type?.rps) { - case RPSSprites.Rock: - animation = Animations.RockIdle; - break; - case RPSSprites.Paper: - animation = Animations.PaperIdle; - break; - case RPSSprites.Scissors: - animation = Animations.ScissorsIdle; - break; - } - - playerObj.setComponent({ - id: "animation", - once: (sprite: any) => { - sprite.play(animation); - }, - }); - }); + // defineEnterSystem(world, [Has(Position)], ({ entity }: any) => { + // const playerObj = objectPool.get(entity.toString(), "Sprite"); + + // const type = getComponentValue(RPSType, entity.toString() as Entity); + + // console.log("defineEnterSystem", type?.rps); + + // let animation = Animations.RockIdle; + + // switch (type?.rps) { + // case RPSSprites.Rock: + // animation = Animations.RockIdle; + // break; + // case RPSSprites.Paper: + // animation = Animations.PaperIdle; + // break; + // case RPSSprites.Scissors: + // animation = Animations.ScissorsIdle; + // break; + // } + + // playerObj.setComponent({ + // id: "animation", + // once: (sprite: any) => { + // sprite.play(animation); + // }, + // }); + // }); defineSystem(world, [Has(Position)], ({ entity }: any) => { const playerObj = objectPool.get(entity.toString(), "Sprite"); const type = getComponentValue(RPSType, entity.toString() as Entity); - console.log("defineSystem", type?.rps); + console.log("defineSystem", type); if (type?.rps) { let animation = Animations.RockIdle; diff --git a/packages/react/src/syncManager/syncFunction.ts b/packages/react/src/syncManager/syncFunction.ts index e83a064e..e508d9b4 100644 --- a/packages/react/src/syncManager/syncFunction.ts +++ b/packages/react/src/syncManager/syncFunction.ts @@ -66,6 +66,11 @@ export function createSyncManager( .then((modelValue) => { console.log("ohayo", modelValue); + const convertedValue = convertValues( + modelEntry.model.schema, + modelValue + ); + const entityIndex: Entity = modelEntry.keys.length === 1 ? modelEntry.keys[0].toString() @@ -74,7 +79,7 @@ export function createSyncManager( setComponent( modelEntry.model, entityIndex, - modelValue as any + convertedValue as any ); }); }