@screeps/engine
Version:
This is a module for Screeps standalone server. See [main repository](https://github.com/screeps/screeps) for more info.
50 lines (38 loc) • 1.44 kB
JavaScript
;
var utils = require('./../utils'),
rooms = require('./rooms'),
driver = utils.getRuntimeDriver(),
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 = 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, _data.effects);
this.id = id;
});
Source.prototype = Object.create(globals.RoomObject.prototype);
Source.prototype.constructor = Source;
utils.defineGameObjectProperties(Source.prototype, data, {
energy: o => o.energy,
energyCapacity: o => o.energyCapacity,
ticksToRegeneration: o => o.nextRegenerationTime ? o.nextRegenerationTime - runtimeData.time : undefined
});
Source.prototype.toString = register.wrapFn(function () {
return `[source #${this.id}]`;
});
Object.defineProperty(globals, 'Source', { enumerable: true, value: Source });
};
//# sourceMappingURL=../sourcemaps/game/sources.js.map