Skip to content

Commit

Permalink
phasher systems
Browse files Browse the repository at this point in the history
  • Loading branch information
ponderingdemocritus committed Nov 10, 2023
1 parent 5539ae0 commit ab22e26
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 30 deletions.
58 changes: 29 additions & 29 deletions examples/react-phaser-example/src/phaser/systems/move.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion packages/react/src/syncManager/syncFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ export function createSyncManager<S extends Schema>(
.then((modelValue) => {
console.log("ohayo", modelValue);

const convertedValue = convertValues(
modelEntry.model.schema,
modelValue
);

const entityIndex: Entity =
modelEntry.keys.length === 1
? modelEntry.keys[0].toString()
Expand All @@ -74,7 +79,7 @@ export function createSyncManager<S extends Schema>(
setComponent(
modelEntry.model,
entityIndex,
modelValue as any
convertedValue as any
);
});
}
Expand Down

0 comments on commit ab22e26

Please sign in to comment.