Skip to content

Commit

Permalink
MatterPhysics - Ensures body map is removed
Browse files Browse the repository at this point in the history
`TensorFlow` - Set wasm to public root by default
`Entity` - Adds try/catch around remote event inflate
  • Loading branch information
Marak committed Mar 12, 2024
1 parent b285c59 commit cb11019
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
9 changes: 7 additions & 2 deletions mantra-game/plugins/entity/lib/inflateEntity.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,14 @@ function defaultBuild(game, entityData) {

if (supportedSerializedEvents.includes(p)) {
// this is a serialized function, create a new function from the string and assign it to the entity
//console.log('inflateEntity serialized function', entityData[p]);
// console.log('inflateEntity serialized function', entityData.type, entityData[p], entityData);
// this is a function that had .toSTring() called on it, we need to re-create the function
entityData[p] = eval('(' + entityData[p] + ')');
try {
// Remark: This try/catch is not gaurenteed to catch all eval() errors
entityData[p] = eval('(' + entityData[p] + ')');
} catch (err) {
console.log('Failed to inflate serialized function', entityData.type, entityData[p], entityData, err)
}
//console.log("after inflateENtity seralize fn", entityData[p])
}

Expand Down
2 changes: 1 addition & 1 deletion mantra-game/plugins/physics-matter/MatterPhysics.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class MatterPhysics extends PhysicsInterface {
let body = this.bodyMap[entityId];
if (body) {
Matter.World.remove(this.engine.world, body);
delete this.bodyMap[body.myEntityId];
delete this.bodyMap[body.myEntityId.toString()];
}
}

Expand Down
3 changes: 2 additions & 1 deletion mantra-game/plugins/tensorflow/TensorFlow.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class TensorFlow {

// await this.loadModel();


setWasmPaths('/');
this.game.systemsManager.addSystem('tensorflow', this);
}

Expand Down Expand Up @@ -161,6 +161,7 @@ export default class TensorFlow {
// Apply actions based on the generated random actions
Object.keys(actions).forEach(action => {
if (actions[action]) {
// console.log('applying action', action, player)
this.game.rules.emit(action, player);
}
});
Expand Down

0 comments on commit cb11019

Please sign in to comment.