Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions js/sim/Simulations.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,11 @@ function Sim(config){
////////////////////////

self.STEP = 0;
self.STEP_AT_LAST_CALL = -1;

self.save = function(){
self.STEP = 0;
self.STEP_AT_LAST_CALL = -1;
self.networkConfig = self.getCurrentNetwork();
};

Expand All @@ -444,13 +446,19 @@ function Sim(config){
self.reload = function(){
var contagionLevel = self.contagion; // hack for sandbox: keep contagion the same
self.STEP = 0;
self.STEP_AT_LAST_CALL = -1;
self._canPlayBonkSound = true;
self.init();
self.contagion = contagionLevel;
};

self.nextStep = function(){

// STEP++ is time-based; nextStep() is frame-based. This check ensures
// one nextStep() per STEP to avoid duplicate animations and infections.
if(self.STEP == self.STEP_AT_LAST_CALL) return;
self.STEP_AT_LAST_CALL = self.STEP;

// SOUND! If anyone can be infected, play Contagion sound.
// Otherwise play Bonk sound ONCE
var canBeInfected = self.peeps.filter(function(peep){
Expand Down