UNPKG

@screeps/engine

Version:

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

40 lines (34 loc) 1.36 kB
'use strict'; var _ = require('lodash'), utils = require('../../../utils'), driver = utils.getDriver(), C = driver.constants; module.exports = function (object, scope) { const roomObjects = scope.roomObjects, bulk = scope.bulk, roomController = scope.roomController, gameTime = scope.gameTime, eventLog = scope.eventLog; if (!object.nextDecayTime || gameTime >= object.nextDecayTime - 1) { object.hits = object.hits || 0; object.hits -= C.CONTAINER_DECAY; if (object.hits <= 0) { if (object.store) { _.forEach(object.store, (amount, resourceType) => { if (amount > 0) { require('../_create-energy')(object.x, object.y, object.room, amount, resourceType, scope); } }); } bulk.remove(object._id); delete roomObjects[object._id]; } else { object.nextDecayTime = gameTime + (roomController && roomController.level > 0 ? C.CONTAINER_DECAY_TIME_OWNED : C.CONTAINER_DECAY_TIME); bulk.update(object, { hits: object.hits, nextDecayTime: object.nextDecayTime }); } } }; //# sourceMappingURL=../../../sourcemaps/processor/intents/containers/tick.js.map