UNPKG

@screeps/engine

Version:

This is a module for Screeps standalone server. See [main repository](https://github.com/screeps/screeps) for more info.

56 lines (44 loc) 1.54 kB
'use strict'; var utils = require('./../utils'), rooms = require('./rooms'), driver = utils.getDriver(), C = driver.constants; var runtimeData, intents, register, globals; exports.make = function (_runtimeData, _intents, _register, _globals) { runtimeData = _runtimeData; intents = _intents; register = _register; globals = _globals; if (globals.Source) { return; } var data = function data(id) { if (!runtimeData.roomObjects[id]) { throw new Error("Could not find an object with ID " + id); } return runtimeData.roomObjects[id]; }; var Source = register.wrapFn(function (id) { var _data = data(id); globals.RoomObject.call(this, _data.x, _data.y, _data.room); this.id = id; }); Source.prototype = Object.create(globals.RoomObject.prototype); Source.prototype.constructor = Source; utils.defineGameObjectProperties(Source.prototype, data, { energy: function energy(o) { return o.energy; }, energyCapacity: function energyCapacity(o) { return o.energyCapacity; }, ticksToRegeneration: function ticksToRegeneration(o) { return o.nextRegenerationTime ? o.nextRegenerationTime - runtimeData.time : undefined; } }); Source.prototype.toString = register.wrapFn(function () { return '[source #' + this.id + ']'; }); globals.Source = Source; }; //# sourceMappingURL=../sourcemaps/game/sources.js.map