class CutHandler
{
constructor(room, item)
{
this.room = room;
this.item = item;
this.nextSpawnTime = 4;
this.virusRemaining = 20;
}
start()
{
this.spawnTimeout = setTimeout(this.spawn.bind(this), this.nextSpawnTime * 1000);
}
spawn()
{
const range = 1.2;
const offX = Math.random() * range - range * 0.5;
const offZ = Math.random() * range - range * 0.5;
this.room.spawnItem(this.room.getNextPlayerOwner(), 'virus', {x:this.item.details.x+offX,y:this.item.details.y,z:this.item.details.z+offZ});
console.log("Spawning virus");
this.virusRemaining--;
if (this.virusRemaining > 0)
{
this.nextSpawnTime = Math.max(1, this.nextSpawnTime - 0.1);
this.spawnTimeout = setTimeout(this.spawn.bind(this), this.nextSpawnTime * 1000);
}
}
stop()
{
clearTimeout(this.spawnTimeout);
}
itemUpdated()
{
}
}
module.exports = CutHandler;