limit the number of entities in initEntity

This commit is contained in:
Romain Beaumont 2016-03-18 13:56:05 +01:00
parent b5328463a4
commit 308fc5c8a0

View file

@ -13,6 +13,8 @@ const Vec3 = require("vec3").Vec3;
module.exports.server=function(serv,options) {
serv.initEntity = (type, entityType, world, position) => {
if(Object.keys(serv.entities).length>options["max-entities"])
throw new Error("Too many mobs !");
serv.entityMaxId++;
const entity = new Entity(serv.entityMaxId);