Pārlūkot izejas kodu

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

tags/v0.14.0^2
Shaun pirms 4 mēnešiem
vecāks
revīzija
6bf5da5569
1 mainītis faili ar 15 papildinājumiem un 2 dzēšanām
  1. +15
    -2
      src/server/world/resourceSpawner.js

+ 15
- 2
src/server/world/resourceSpawner.js Parādīt failu

@@ -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;



Notiek ielāde…
Atcelt
Saglabāt