(function() { Script.include('utils.js'); Enemy = function() { }; Enemy.prototype = { preload: function(entityID) { this.entityID = entityID; // To avoid sending extraneous messages and checking entities that we've already // seen, we keep track of which entities we've collided with previously. this.entityIDsThatHaveCollidedWithMe = []; Script.addEventHandler(entityID, "collisionWithEntity", this.onCollide.bind(this)); var userData = Entities.getEntityProperties(this.entityID, 'userData').userData; var data = utils.parseJSON(userData); if (data !== undefined && data.gameChannel !== undefined) { this.gameChannel = data.gameChannel; } else { print("enemyEntity.js | ERROR: userData does not contain a game channel and/or team number"); } }, unload: function() { Script.clearInterval(this.heartbeatTimerID); }, }; return new Enemy(); });