Skip to content

Commit

Permalink
CrossWindow - Registers as system
Browse files Browse the repository at this point in the history
`CrossWindow` - Don’t attempt to re-inflate Sutras ( for now )
  • Loading branch information
Marak committed Mar 8, 2024
1 parent 9615731 commit 996247d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mantra-game/plugins/crosswindow/CrossWindow.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// CrossWindow.js - Mantra Plugin - Marak Squires 2024
// see: CrossWindow.js: https://github.com/yantra-core/CrossWindow.js

// import crosswindow from 'crosswindow';
// import { CrossWindow as CW, CrossWindowDebugger } from '../../../../CrossWindow.js/index.js'
import { CrossWindow as CW, CrossWindowDebugger } from 'crosswindow';

Expand All @@ -14,6 +13,8 @@ export default class CrossWindow {

init(game) {
this.game = game;
this.game.systemsManager.addSystem(CrossWindow.id, this);

//console.log('CrossWindow plugin initialized', CrossWindow);
// Initialize CrossWindow instance
this.crosswindow = new CW(window, {
Expand Down Expand Up @@ -81,6 +82,7 @@ export default class CrossWindow {
// If the best window is a different window, remove the entity and send a message
game.removeEntity(entity.id);
entityData.action = 'message'; // TODO: fix this and add 'action' and 'payload' top-level scope to CrossWindow
delete entityData.sutra; // for now
bestWindow.postMessage(entityData);
}
} else {
Expand Down Expand Up @@ -145,6 +147,8 @@ export default class CrossWindow {
entityData.frictionStatic = 0;
entityData.source = this.crosswindow.windowId;

delete entityData.sutra; // for now, we can toJSON this and re-inflate it
// console.log('sendingdata', entityData)
// Inflate or update entity in the game
let ent = this.game.inflateEntity(entityData);
if (ent.type === 'PLAYER') {
Expand Down

0 comments on commit 996247d

Please sign in to comment.