@screeps/engine
Version:
This is a module for Screeps standalone server. See [main repository](https://github.com/screeps/screeps) for more info.
59 lines (47 loc) • 1.67 kB
JavaScript
;
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.Mineral) {
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 Mineral = register.wrapFn(function (id) {
var _data = data(id);
globals.RoomObject.call(this, _data.x, _data.y, _data.room);
this.id = id;
});
Mineral.prototype = Object.create(globals.RoomObject.prototype);
Mineral.prototype.constructor = Mineral;
utils.defineGameObjectProperties(Mineral.prototype, data, {
mineralType: function mineralType(o) {
return o.mineralType;
},
mineralAmount: function mineralAmount(o) {
return o.mineralAmount;
},
density: function density(o) {
return o.density;
},
ticksToRegeneration: function ticksToRegeneration(o) {
return o.nextRegenerationTime ? o.nextRegenerationTime - runtimeData.time : undefined;
}
});
Mineral.prototype.toString = register.wrapFn(function () {
return '[mineral (' + this.mineralType + ') #' + this.id + ']';
});
globals.Mineral = Mineral;
};
//# sourceMappingURL=../sourcemaps/game/minerals.js.map