Sim.prototype.step = function (msecs) {
var ro, q = this.queue.data;
// Calls init() on all entities only on first step
if (this.simTime === 0 ) {
this.simTime = Date.now();
this.entities.forEach(function(e){
e.init();
})
}
// Advance simulation time
this.simTime += msecs ;
while (true){
// nothing to do
if (q.length <= 0) {break;}
// check first
if (q[0].deliverAt <= this.simTime) {
ro = this.queue.remove();
// If this event is already cancelled, ignore
if (ro.cancelled) {continue;}
// execute callbacks
ro.deliver();
} else {
// done for this time
break;
}
}
}