瀏覽代碼

modding #2012: Added the beforeSpawnResource that allows spawned resources' positions to be set by mods

tags/v0.14.0^2
Shaun 4 月之前
父節點
當前提交
6bf5da5569
共有 1 個檔案被更改,包括 15 行新增2 行删除
  1. +15
    -2
      src/server/world/resourceSpawner.js

+ 15
- 2
src/server/world/resourceSpawner.js 查看文件

@@ -1,4 +1,5 @@
let herbs = require('../config/herbs');
const eventEmitter = require('../misc/events');

const defaultGatherChance = {
herb: 100,
@@ -122,8 +123,20 @@ module.exports = {
},

spawn: function (node) {
let blueprint = node.blueprint;
let position = this.getRandomSpawnPosition(node, blueprint);
const blueprint = node.blueprint;

const eBeforeSpawnResource = {
node,
position: undefined,
allowRandomPosition: true
};
eventEmitter.emit('beforeSpawnResource', eBeforeSpawnResource);

if (eBeforeSpawnResource.allowRandomPosition && !eBeforeSpawnResource.position)
eBeforeSpawnResource.position = this.getRandomSpawnPosition(node, blueprint);

const { position } = eBeforeSpawnResource;

if (!position)
return false;



Loading…
取消
儲存