1
0
forked from sent/waves
chunglloyd_unblocker/public/assets/g/thefinalearth2/js/game_js.js
2025-04-09 17:11:14 -05:00

46395 lines
1.6 MiB

// Generated by Haxe 4.1.2
(function ($hx_exports, $global) { "use strict";
var $hxClasses = {},$estr = function() { return js_Boot.__string_rec(this,''); },$hxEnums = $hxEnums || {},$_;
function $extend(from, fields) {
var proto = Object.create(from);
for (var name in fields) proto[name] = fields[name];
if( fields.toString !== Object.prototype.toString ) proto.toString = fields.toString;
return proto;
}
var Analytics = function() { };
$hxClasses["Analytics"] = Analytics;
Analytics.__name__ = "Analytics";
Analytics.init = function() {
if(!Analytics.enabled) {
return;
}
if(window.document.location.hostname == "localhost" || window.document.location.hostname == "127.0.0.1") {
console.log("FloatingSpaceCities/Analytics.hx:18:","game is running locally");
Config.enableCheats = true;
return;
}
jsFunctions.loadJS("https://www.googletagmanager.com/gtag/js?id=UA-48290579-2",function() {
Analytics.ready = true;
jsFunctions.initGA();
Analytics.sendEvent("game","playVersion",null,"VERSION1.1",true);
Analytics.sendEvent("game","playOnSite",null,window.location.hostname,true);
var _g = 0;
var _g1 = Analytics.capturedErrors;
while(_g < _g1.length) {
var err = _g1[_g];
++_g;
jsFunctions.gaSendError(err);
}
Analytics.capturedErrors = [];
});
Analytics.useAltEarlyGame = true;
Analytics.didABTest = false;
if(Analytics.useAltEarlyGame) {
Config.earlyGameFix1 = true;
Config.earlyGameFix2 = true;
}
};
Analytics.sendErrorEvent = function(errorMessage) {
if(Analytics.errorsReported > 3) {
return;
}
Analytics.errorsReported++;
if(!Analytics.ready) {
Analytics.capturedErrors.push(errorMessage);
} else {
jsFunctions.gaSendError(errorMessage);
}
};
Analytics.sendEvent = function(category,action,value,label,nonInteraction) {
if(nonInteraction == null) {
nonInteraction = false;
}
if(label == null) {
label = "";
}
if(!Analytics.ready) {
return;
}
jsFunctions.gaSendEvent(category,action,label,value,nonInteraction);
};
Analytics.update = function(timeMod) {
Analytics.sessionTime += timeMod / 60;
if(Analytics.sessionTime > 1800. && !Analytics.reportedLongPlaytime) {
common_Storage.getItem("lptReported",function(err,res) {
if(err == null) {
if(res != "reported") {
common_Storage.setItem("lptReported","reported",function() {
Analytics.sendEvent("playtime",Analytics.didABTest ? Analytics.useAltEarlyGame ? "altEarlyGame" : "standardEarlyGame" : "noABTest");
});
}
}
});
Analytics.reportedLongPlaytime = true;
}
};
var Audio = function(game) {
this.isPaused = false;
this.playSecondMusicOnceLoaded = false;
this.music1EverFinished = false;
this.music4 = null;
this.music3 = null;
this.music2 = null;
var _gthis = this;
Audio.instance = this;
this.game = game;
this.music1 = PIXI.sound.Sound.from({ url : "audio/BTFE_BackgroundMusic_1.{ogg,mp3}", preload : true, singleInstance : true, loaded : function() {
if(Settings.musicOn) {
_gthis.music1.play($bind(_gthis,_gthis.firstMusicCompleteCallback));
if(_gthis.isPaused) {
_gthis.music1.pause();
}
}
}});
this.music2 = null;
if(Settings.musicOn) {
this.loadSecondMusic();
}
this.buildSound = PIXI.sound.Sound.from({ url : "audio/BTFE_BuildingBuild.{ogg,mp3}", preload : true});
this.buildingClickSound = PIXI.sound.Sound.from({ url : "audio/BTFE_BuildingClick.{ogg,mp3}", preload : true});
this.buildingUpgradeSound = PIXI.sound.Sound.from({ url : "audio/BTFE_BuildingUpgrade.{ogg,mp3}", preload : true});
this.buttonSound = PIXI.sound.Sound.from({ url : "audio/BTFE_Button.{ogg,mp3}", preload : true});
this.buttonFailSound = PIXI.sound.Sound.from({ url : "audio/BTFE_ButtonFail.{ogg,mp3}", preload : true});
this.music = this.music1;
};
$hxClasses["Audio"] = Audio;
Audio.__name__ = "Audio";
Audio.get = function() {
return Audio.instance;
};
Audio.prototype = {
loadSecondMusic: function() {
var _gthis = this;
this.music2 = PIXI.sound.Sound.from({ url : "audio/BTFE_BackgroundMusic_2.{ogg,mp3}", preload : true, singleInstance : false, loaded : function() {
if(Settings.musicOn && _gthis.music == _gthis.music1 && !_gthis.music.isPlaying && !_gthis.music.paused && _gthis.playSecondMusicOnceLoaded) {
_gthis.music = _gthis.music2;
_gthis.music2.play($bind(_gthis,_gthis.startNextMusic));
if(_gthis.isPaused) {
_gthis.music2.pause();
}
_gthis.playSecondMusicOnceLoaded = false;
}
}});
}
,loadThirdMusic: function() {
this.music3 = PIXI.sound.Sound.from({ url : "audio/BTFE_BackgroundMusic_3.{ogg,mp3}", preload : true, singleInstance : false});
}
,loadFourthMusic: function() {
this.music4 = PIXI.sound.Sound.from({ url : "audio/BTFE_BackgroundMusic_4.{ogg,mp3}", preload : true, singleInstance : false});
}
,startNextMusic: function() {
if(this.music2 != null && this.music2.isLoaded || this.music3 != null && this.music3.isLoaded || this.music4 != null && this.music4.isLoaded) {
var possibleOptions = [];
if(this.music2 != null && this.music2.isLoaded) {
possibleOptions.push(this.music2);
}
if(this.music3 != null && this.music3.isLoaded) {
possibleOptions.push(this.music3);
} else if(this.music3 == null) {
this.loadThirdMusic();
}
if(this.music4 != null && this.music4.isLoaded) {
possibleOptions.push(this.music4);
} else if(this.music3 != null && this.music3.isLoaded && this.music4 == null) {
this.loadFourthMusic();
}
if(possibleOptions.length > 1 && this.music != null) {
HxOverrides.remove(possibleOptions,this.music);
}
var newMusic = random_Random.fromArray(possibleOptions);
this.music = newMusic;
this.music.play($bind(this,this.startNextMusic));
if(this.isPaused) {
this.music.pause();
}
} else {
this.playSecondMusicOnceLoaded = true;
}
}
,firstMusicCompleteCallback: function(audio) {
if(!Settings.musicOn) {
return;
}
this.music1EverFinished = true;
this.startNextMusic();
}
,changeMusicEnabledness: function(musicIsOn) {
Settings.musicOn = musicIsOn;
Settings.save();
if(!Settings.musicOn) {
if(this.music.isPlaying) {
this.music.stop();
}
} else {
if(!this.music.isPlaying) {
if(this.music1EverFinished) {
this.startNextMusic();
} else if(this.music1.isLoaded) {
this.music1.play($bind(this,this.firstMusicCompleteCallback));
}
}
if(this.music2 == null) {
this.loadSecondMusic();
}
}
}
,changeSoundEnabledness: function(soundIsOn) {
Settings.soundOn = soundIsOn;
Settings.save();
}
,pauseMusic: function() {
if(this.music != null && this.music.isPlaying && !this.music.paused) {
this.music.pause();
}
this.isPaused = true;
}
,resumeMusic: function() {
if(this.music != null && this.music.paused && Settings.musicOn) {
this.music.resume();
}
this.isPaused = false;
}
,playSound: function(sound) {
if(Settings.soundOn && sound.isLoaded) {
sound.play({ });
}
}
,__class__: Audio
};
var BuilderType = $hxEnums["BuilderType"] = { __ename__ : "BuilderType", __constructs__ : ["Building","Decoration","WorldResource","MoveWorldResource"]
,Building: ($_=function(buildingType,buildingInfo) { return {_hx_index:0,buildingType:buildingType,buildingInfo:buildingInfo,__enum__:"BuilderType",toString:$estr}; },$_.__params__ = ["buildingType","buildingInfo"],$_)
,Decoration: ($_=function(decorationInfo) { return {_hx_index:1,decorationInfo:decorationInfo,__enum__:"BuilderType",toString:$estr}; },$_.__params__ = ["decorationInfo"],$_)
,WorldResource: ($_=function(resourceInfo) { return {_hx_index:2,resourceInfo:resourceInfo,__enum__:"BuilderType",toString:$estr}; },$_.__params__ = ["resourceInfo"],$_)
,MoveWorldResource: ($_=function(worldResource) { return {_hx_index:3,worldResource:worldResource,__enum__:"BuilderType",toString:$estr}; },$_.__params__ = ["worldResource"],$_)
};
var BuildPossibility = $hxEnums["BuildPossibility"] = { __ename__ : "BuildPossibility", __constructs__ : ["BuildingInWorld","BuildingPositionImpossible","BuildingOK"]
,BuildingInWorld: {_hx_index:0,__enum__:"BuildPossibility",toString:$estr}
,BuildingPositionImpossible: {_hx_index:1,__enum__:"BuildPossibility",toString:$estr}
,BuildingOK: {_hx_index:2,__enum__:"BuildPossibility",toString:$estr}
};
var Builder = function(city,stage,builderType) {
this.buildablePositionsDisplayCacheValid = false;
this.lastBuilt = -1;
this.fixedSprite = null;
this.fixedToPos = null;
this.fixedToWorld = null;
this.wasMouseHandled = true;
this.isUniqueBuilding = false;
this.city = city;
this.builderType = builderType;
switch(builderType._hx_index) {
case 0:
var buildingInfo = builderType.buildingInfo;
var buildingType = builderType.buildingType;
this.sprite = Resources.makeSprite(Reflect.field(buildingType,"spriteName"),new common_Rectangle(0,0,20,20));
this.originalCost = Materials.fromBuildingInfo(buildingInfo);
this.isUniqueBuilding = buildingInfo.specialInfo.indexOf("unique") != -1;
break;
case 1:
var decorationInfo = builderType.decorationInfo;
this.sprite = Resources.makeSprite("" + decorationInfo.textureName + "@0,0,20,20");
this.originalCost = Materials.fromDecorationInfo(decorationInfo);
break;
case 2:
var resourceInfo = builderType.resourceInfo;
this.sprite = Resources.makeSprite("" + resourceInfo.textureName);
this.originalCost = Materials.fromWorldResourceInfo(resourceInfo);
break;
case 3:
var wr = builderType.worldResource;
this.sprite = new PIXI.Sprite(wr.sprite.texture);
break;
}
this.stage = stage;
this.builderSecondaryHelpSprite = Resources.makeSprite("spr_insertbuildinghere");
stage.addChild(this.sprite);
stage.addChild(this.builderSecondaryHelpSprite);
this.sprite.alpha = 0;
this.builderSecondaryHelpSprite.alpha = 0;
this.touchAlpha = 0;
this.showContinuousTooltip();
};
$hxClasses["Builder"] = Builder;
Builder.__name__ = "Builder";
Builder.canRemoveFromLRPerspective = function(advancedMode,building,city) {
if(advancedMode) {
if(building.leftBuilding != null && pathfinder_DirectConnectionFinder.find(city,building.leftBuilding,function(bld) {
return bld.worldPosition.y == 0;
},function(bld) {
return bld == building;
}) == null) {
return false;
}
if(building.rightBuilding != null && pathfinder_DirectConnectionFinder.find(city,building.rightBuilding,function(bld) {
return bld.worldPosition.y == 0;
},function(bld) {
return bld == building;
}) == null) {
return false;
}
return true;
}
if(building.leftBuilding == null || building.leftBuilding.worldPosition.y == 0 || building.leftBuilding.bottomBuilding != null) {
if(!(building.rightBuilding == null || building.rightBuilding.worldPosition.y == 0)) {
return building.rightBuilding.bottomBuilding != null;
} else {
return true;
}
} else {
return false;
}
};
Builder.prototype = {
get_buildingToBuild: function() {
var _g = this.builderType;
if(_g._hx_index == 0) {
var _g1 = _g.buildingInfo;
var b = _g.buildingType;
return b;
} else {
return null;
}
}
,fixBuilder: function(fixedToWorld,fixedToPos) {
this.fixedToWorld = fixedToWorld;
this.fixedToPos = fixedToPos;
if(fixedToWorld == null || fixedToPos == null) {
if(this.fixedSprite != null) {
this.stage.removeChild(this.fixedSprite);
}
} else {
this.fixedSprite = Resources.makeSprite("spr_forcedbuildinglocation");
this.stage.addChild(this.fixedSprite);
this.fixedSprite.position.set(fixedToWorld.rect.x + 20 * fixedToPos - 1,fixedToWorld.rect.y - 20 - 31);
}
}
,invalidateCache: function() {
this.buildablePositionsDisplayCacheValid = false;
}
,isCacheValid: function() {
return this.buildablePositionsDisplayCacheValid;
}
,prevalidateCache: function() {
this.buildablePositionsDisplayCacheValid = true;
}
,update: function(timeMod) {
this.lastBuilt += timeMod;
if(this.city.game.isMobile && !this.buildablePositionsDisplayCacheValid) {
this.city.builderHighlightStage.removeChildren();
}
if(!this.wasMouseHandled) {
this.sprite.alpha = 0;
}
if(this.touchAlpha > 0) {
this.touchAlpha = Math.max(this.touchAlpha - timeMod / 30,0);
}
this.wasMouseHandled = false;
if(this.city.game.mouse.rightPressed) {
this.cancel();
}
this.showContinuousTooltip();
if(this.city.buildingMode != BuildingMode.Destroy && this.buildingPrerequirementsValid()) {
var prereqsvalid = this.city.game.isMobile && !this.city.game.mouse.hasSpecificClaim(this);
if(prereqsvalid && !this.buildablePositionsDisplayCacheValid) {
var higherCheckPositions = new haxe_ds_ObjectMap();
var _g = 0;
var _g1 = this.city.worlds;
while(_g < _g1.length) {
var world = _g1[_g];
++_g;
var bestY = 10000000;
var bestWorld = null;
var leftPos = world.rect.x - 20;
var leftPosOnWorld = 0;
var _g2 = 0;
var _g3 = this.city.worlds;
while(_g2 < _g3.length) {
var world2 = _g3[_g2];
++_g2;
if(world2.rect.y < bestY && world2.rect.y > world.rect.y && leftPos >= world2.rect.x && leftPos < world2.rect.get_x2()) {
bestWorld = world2;
leftPosOnWorld = (leftPos - bestWorld.rect.x) / 20 | 0;
bestY = world2.rect.y;
}
}
if(bestWorld != null) {
var worldHCPs = higherCheckPositions.h[bestWorld.__id__];
if(worldHCPs == null) {
worldHCPs = [];
higherCheckPositions.set(bestWorld,worldHCPs);
}
worldHCPs.push({ world : bestWorld, x : leftPosOnWorld, checkUntil : ((bestWorld.rect.y - world.rect.y) / 20 | 0) + world.permanents[0].length});
}
var bestY1 = 10000000;
var bestWorld1 = null;
var rightPos = world.rect.x + world.rect.width;
var rightPosOnWorld = 0;
var _g4 = 0;
var _g5 = this.city.worlds;
while(_g4 < _g5.length) {
var world21 = _g5[_g4];
++_g4;
if(world21.rect.y < bestY1 && world21.rect.y > world.rect.y && rightPos >= world21.rect.x && rightPos < world21.rect.get_x2()) {
bestWorld1 = world21;
bestY1 = world21.rect.y;
rightPosOnWorld = (rightPos - bestWorld1.rect.x) / 20 | 0;
}
}
if(bestWorld1 != null) {
var worldHCPs1 = higherCheckPositions.h[bestWorld1.__id__];
if(worldHCPs1 == null) {
worldHCPs1 = [];
higherCheckPositions.set(bestWorld1,worldHCPs1);
}
worldHCPs1.push({ world : bestWorld1, x : rightPosOnWorld, checkUntil : ((bestWorld1.rect.y - world.rect.y) / 20 | 0) + world.permanents[world.permanents.length - 1].length});
}
}
var _g = 0;
var _g1 = this.city.worlds;
while(_g < _g1.length) {
var world = _g1[_g];
++_g;
if(this.fixedToWorld != null && world != this.fixedToWorld) {
continue;
}
var _g2 = this.builderType;
switch(_g2._hx_index) {
case 0:
var buildingInfo = _g2.buildingInfo;
var buildingType = _g2.buildingType;
var _g3 = 0;
var _g4 = world.permanents.length;
while(_g3 < _g4) {
var x = [_g3++];
if(this.fixedToPos != null && x[0] != this.fixedToPos) {
continue;
}
var checkYPositionsTo = world.permanents[x[0]].length + 1;
if(x[0] >= 1) {
var val2 = world.permanents[x[0] - 1].length;
if(val2 > checkYPositionsTo) {
checkYPositionsTo = val2;
}
}
var worldPos = higherCheckPositions.h[world.__id__];
var anyHCP = worldPos == null ? null : common_ArrayExtensions.whereMax(worldPos,(function(x) {
return function(hcp) {
return x[0] == hcp.x;
};
})(x),(function() {
return function(hcp) {
return hcp.checkUntil;
};
})());
if(anyHCP != null) {
var val21 = anyHCP.checkUntil;
if(val21 > checkYPositionsTo) {
checkYPositionsTo = val21;
}
}
var _g5 = 0;
var _g6 = checkYPositionsTo;
while(_g5 < _g6) {
var y = _g5++;
if(this.canBuildBuilding(world,x[0],y,buildingInfo) == BuildPossibility.BuildingOK) {
var canBuildHereDisplay = Resources.makeSprite("spr_buildhereoutline");
canBuildHereDisplay.position.set(world.rect.x + x[0] * 20,world.rect.y - (y + 1) * 20);
this.city.builderHighlightStage.addChild(canBuildHereDisplay);
if(this.city.buildingMode == BuildingMode.Replace && world.permanents[x[0]].length > y && world.permanents[x[0]][y] != null) {
canBuildHereDisplay.tint = 16776960;
}
}
}
}
break;
case 1:
var _g7 = _g2.decorationInfo;
if(!world.canBuildOnSurface()) {
continue;
}
var _g8 = 0;
var _g9 = world.permanents.length;
while(_g8 < _g9) {
var x1 = _g8++;
if(this.fixedToPos != null && x1 != this.fixedToPos) {
continue;
}
var thesePermanents = world.permanents[x1];
if(thesePermanents.length == 0 || thesePermanents[0] == null) {
var canBuildHereDisplay1 = Resources.makeSprite("spr_buildhereoutline");
canBuildHereDisplay1.position.set(world.rect.x + x1 * 20,world.rect.y - 20);
this.city.builderHighlightStage.addChild(canBuildHereDisplay1);
}
}
break;
case 2:
var _g10 = _g2.resourceInfo;
if(!world.canBuildOnSurface()) {
continue;
}
var _g11 = 0;
var _g12 = world.permanents.length;
while(_g11 < _g12) {
var x2 = _g11++;
if(this.fixedToPos != null && x2 != this.fixedToPos) {
continue;
}
var thesePermanents1 = world.permanents[x2];
if(thesePermanents1.length == 0 || thesePermanents1[0] == null) {
var canBuildHereDisplay2 = Resources.makeSprite("spr_buildhereoutline");
canBuildHereDisplay2.position.set(world.rect.x + x2 * 20,world.rect.y - 20);
this.city.builderHighlightStage.addChild(canBuildHereDisplay2);
}
}
break;
case 3:
var _g13 = _g2.worldResource;
if(!world.canBuildOnSurface()) {
continue;
}
var _g14 = 0;
var _g15 = world.permanents.length;
while(_g14 < _g15) {
var x3 = _g14++;
if(this.fixedToPos != null && x3 != this.fixedToPos) {
continue;
}
var thesePermanents2 = world.permanents[x3];
if(thesePermanents2.length == 0 || thesePermanents2[0] == null) {
var canBuildHereDisplay3 = Resources.makeSprite("spr_buildhereoutline");
canBuildHereDisplay3.position.set(world.rect.x + x3 * 20,world.rect.y - 20);
this.city.builderHighlightStage.addChild(canBuildHereDisplay3);
}
}
break;
}
}
this.buildablePositionsDisplayCacheValid = true;
} else if(!prereqsvalid) {
this.city.builderHighlightStage.removeChildren();
this.buildablePositionsDisplayCacheValid = false;
}
} else if(this.buildablePositionsDisplayCacheValid) {
this.city.builderHighlightStage.removeChildren();
this.buildablePositionsDisplayCacheValid = false;
}
}
,showContinuousTooltip: function() {
if(this.city.game.isMobile) {
var _g = this.builderType;
switch(_g._hx_index) {
case 0:
var buildingInfo = _g.buildingInfo;
var buildingType = _g.buildingType;
this.city.gui.buildingButtons.showBuildingTooltip(buildingInfo,buildingType,this,true);
break;
case 1:
var decorationInfo = _g.decorationInfo;
this.city.gui.buildingButtons.showDecorationTooltip(decorationInfo,this,true);
break;
case 2:
var worldResourceInfo = _g.resourceInfo;
this.city.gui.buildingButtons.showWorldResourceTooltip(worldResourceInfo,this,true);
break;
default:
}
}
}
,handleMouse: function(mouse) {
if(this.city.buildingMode == BuildingMode.Destroy) {
return false;
}
this.wasMouseHandled = true;
this.sprite.alpha = 0.2;
var newX = Math.floor(mouse.get_cityX() / 20) * 20;
var newY = Math.floor(mouse.get_cityY() / 20) * 20;
this.sprite.position.set(newX,newY);
this.builderSecondaryHelpSprite.position.set(newX,newY);
this.sprite.tint = 16777215;
this.builderSecondaryHelpSprite.alpha = 0;
if(this.buildingPrerequirementsValid()) {
var cost = this.calculateCurrentCost();
var _g = 0;
var _g1 = this.city.worlds;
while(_g < _g1.length) {
var world = _g1[_g];
++_g;
if(this.fixedToWorld != null && world != this.fixedToWorld) {
continue;
}
var val = mouse.get_cityX();
var lower = world.rect.x;
var upper = world.rect.get_x2();
if(val >= lower && val < upper && mouse.get_cityY() < world.rect.y) {
var xPos = (mouse.get_cityX() - world.rect.x) / 20 | 0;
if(this.fixedToPos != null && xPos != this.fixedToPos) {
break;
}
var thesePermanents = world.permanents[xPos];
var yPos = (world.rect.y - mouse.get_cityY() - 1) / 20 | 0;
var _g2 = this.builderType;
switch(_g2._hx_index) {
case 0:
var buildingInfo = _g2.buildingInfo;
var buildingType = _g2.buildingType;
if(this.city.buildingMode == BuildingMode.Drag && mouse.hasSpecificClaim(this)) {
if(this.tryBuildingMulti(world,xPos,yPos,buildingType,buildingInfo,mouse)) {
return true;
}
} else {
var buildStatus = this.canBuildBuilding(world,xPos,yPos,buildingInfo);
if(buildStatus == BuildPossibility.BuildingOK) {
if(this.tryBuildingAt(world,xPos,yPos,buildingType,buildingInfo,mouse)) {
return true;
}
} else if(buildStatus == BuildPossibility.BuildingInWorld) {
this.sprite.tint = 16744576;
if(mouse.isTouch) {
var claim = mouse.claimMouse(this,xPos,false);
if(claim == MouseState.Active) {
this.touchAlpha = 1;
this.sprite.alpha = this.touchAlpha;
return true;
}
}
}
}
break;
case 1:
var decorationInfo = _g2.decorationInfo;
if((thesePermanents.length == 0 || thesePermanents[0] == null) && yPos == 0) {
this.sprite.alpha = 0.5;
var claim1 = mouse.claimMouse(this,"" + xPos + " " + yPos,false);
if(claim1 == MouseState.Confirmed) {
var decorationHere = world.decorations[xPos];
if(decorationInfo.textureName == "spr_removedecoration") {
world.removeDecoration(xPos);
} else if(decorationHere != null && decorationHere.textureName == decorationInfo.textureName) {
if(++decorationHere.subImage >= decorationHere.textures.length) {
decorationHere.subImage = 0;
}
decorationHere.sprite.texture = decorationHere.textures[decorationHere.subImage];
} else {
world.setDecoration(decorationInfo.textureName,xPos);
}
this.city.materials.remove(cost);
return true;
} else if(claim1 == MouseState.Active) {
this.sprite.alpha = 0.8;
return true;
}
}
break;
case 2:
var resourceInfo = _g2.resourceInfo;
if((thesePermanents.length == 0 || thesePermanents[0] == null) && yPos == 0) {
this.sprite.alpha = 0.5;
var claim2 = mouse.claimMouse(this,"" + xPos + " " + yPos,false);
if(claim2 == MouseState.Confirmed) {
var name = "worldResources." + resourceInfo.className;
var newResource = world.createWorldResource($hxClasses[name],xPos);
if(((newResource) instanceof worldResources_LimitedWorldResource)) {
var lwr = newResource;
lwr.materialsLeft = 0;
lwr.regrowProgress = resourceInfo.initialGrow;
lwr.updateTexture();
}
this.city.materials.remove(cost);
this.city.simulation.updatePathfinder(false);
return true;
} else if(claim2 == MouseState.Active) {
this.sprite.alpha = 0.8;
return true;
}
}
break;
case 3:
var thisResource = _g2.worldResource;
if((thesePermanents.length == 0 || thesePermanents[0] == null) && yPos == 0) {
this.sprite.alpha = 0.5;
var claim3 = mouse.claimMouse(this,"" + xPos + " " + yPos,false);
if(claim3 == MouseState.Confirmed) {
var _g3 = 0;
var _g4 = this.city.simulation.citizens;
while(_g3 < _g4.length) {
var citizen = _g4[_g3];
++_g3;
if(citizen.inPermanent == thisResource) {
if(citizen.inPermanent != null && citizen.inPermanent.isBuilding) {
var building = citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null;
citizen.relativeX = building.worldPosition.x * 20 + building.doorX;
} else {
citizen.relativeX += citizen.inPermanent.worldPosition.x * 20;
}
if(citizen.inPermanent != null) {
citizen.inPermanent.onCitizenLeave(citizen,null);
}
citizen.inBuildingSince = citizen.city.simulation.time.timeSinceStart;
citizen.set_drawOnStage(citizen.foregroundStage);
citizen.inPermanent = null;
citizen.relativeY = 0;
Citizen.shouldUpdateDraw = true;
}
}
if(thisResource.world.permanents[thisResource.worldPosition.x].length == 1) {
thisResource.world.permanents[thisResource.worldPosition.x].splice(0,1);
} else {
thisResource.world.permanents[thisResource.worldPosition.x][0] = null;
}
thisResource.world = world;
thisResource.worldPosition.x = xPos;
thisResource.position.x = world.rect.x + xPos * 20;
thisResource.position.y = world.rect.y - 20;
thisResource.positionSprites();
thesePermanents[0] = thisResource;
this.city.simulation.updatePathfinder(true);
return true;
} else if(claim3 == MouseState.Active) {
this.sprite.alpha = 0.8;
return true;
}
}
break;
}
}
}
} else {
this.sprite.tint = 16744576;
this.sprite.alpha = 0.6;
}
if(this.city.cityView.isDraggingView) {
this.sprite.alpha = 0;
} else if(mouse.isTouch) {
this.sprite.alpha = this.touchAlpha;
}
return false;
}
,tryBuildingMulti: function(world,xPos,yPos,buildingType,buildingInfo,mouse) {
var buildStatus = this.canBuildBuilding(world,xPos,yPos,buildingInfo);
if(buildStatus == BuildPossibility.BuildingOK) {
return this.tryBuildingAt(world,xPos,yPos,buildingType,buildingInfo,mouse);
}
return false;
}
,tryBuildingAt: function(world,xPos,yPos,buildingType,buildingInfo,mouse) {
var cost = this.calculateCurrentCost();
var thesePermanents = world.permanents[xPos];
this.sprite.alpha = 0.5;
var replaceBuilding = false;
var insertBuilding = false;
if(this.city.buildingMode == BuildingMode.Replace) {
replaceBuilding = yPos != thesePermanents.length && thesePermanents[yPos] != null;
} else {
insertBuilding = yPos != thesePermanents.length && thesePermanents[yPos] != null;
}
if(insertBuilding) {
this.builderSecondaryHelpSprite.alpha = 1;
this.sprite.tint = 12632256;
this.builderSecondaryHelpSprite.texture = Resources.getTexture("spr_insertbuildinghere");
} else if(replaceBuilding) {
this.builderSecondaryHelpSprite.alpha = 1;
this.sprite.tint = 16777215;
this.builderSecondaryHelpSprite.texture = Resources.getTexture("spr_replacebuildinghere");
}
var claim = MouseState.None;
if(this.city.buildingMode == BuildingMode.Drag) {
claim = mouse.claimMouse(this,"",true,true,true);
mouse.hasStrongClaim = true;
mouse.strongClaimOnUpdate = null;
} else {
claim = mouse.claimMouse(this,"" + xPos + " " + yPos,false);
}
if(claim == MouseState.Confirmed) {
var shouldPayCost = true;
if(replaceBuilding) {
if(yPos < thesePermanents.length && thesePermanents[yPos] != null) {
shouldPayCost = js_Boot.getClass(thesePermanents[yPos]) != this.get_buildingToBuild();
if(shouldPayCost && thesePermanents[yPos].isBuilding) {
thesePermanents[yPos].giveRecycleReward(shouldPayCost);
}
thesePermanents[yPos].destroyForReplacement();
}
} else if(insertBuilding) {
var _g = yPos;
var _g1 = thesePermanents.length;
while(_g < _g1) {
var i = _g++;
var permanent = thesePermanents[i];
if(permanent == null) {
break;
}
permanent.position.y -= 20;
permanent.worldPosition.y += 1;
}
}
var newBuilding = world.build(this.get_buildingToBuild(),xPos,yPos);
this.city.game.audio.playSound(this.city.game.audio.buildSound);
if(shouldPayCost) {
this.city.materials.remove(cost);
}
this.city.connections.updateCityConnections();
this.city.simulation.updatePathfinder(insertBuilding || replaceBuilding,newBuilding);
this.city.progress.unlocks.research(this.get_buildingToBuild());
if(insertBuilding) {
var _g = yPos + 1;
var _g1 = thesePermanents.length;
while(_g < _g1) {
var i = _g++;
var permanent = thesePermanents[i];
if(permanent != null) {
permanent.positionSprites();
}
}
}
newBuilding.postCreate();
this.fixBuilder(null,null);
if(this.lastBuilt < 0 || this.lastBuilt > 60) {
this.city.progress.unlocks.checkBuildRelatedUnlocks();
this.city.saveToBrowserStorage();
} else {
this.city.progress.unlocks.checkBuildRelatedUnlocksSoon();
}
if(this.city.windowRelatedOnBuildOrDestroy != null) {
this.city.windowRelatedOnBuildOrDestroy();
}
this.lastBuilt = 0;
return true;
} else if(claim == MouseState.Active) {
this.sprite.alpha = 0.8;
return true;
} else if(this.city.game.isMobile) {
this.builderSecondaryHelpSprite.alpha = 0;
}
return false;
}
,buildingPrerequirementsValid: function() {
var _gthis = this;
var _g = this.builderType;
if(_g._hx_index == 3) {
var _g1 = _g.worldResource;
return true;
}
if(this.get_buildingToBuild() != null && this.city.progress.unlocks.getUnlockState(this.get_buildingToBuild()) == progress_UnlockState.Researched) {
this.originalCost.knowledge = 0;
}
var noUniqueProblem = !this.isUniqueBuilding || !common_ArrayExtensions.any(this.city.permanents,function(pm) {
return pm.is(_gthis.get_buildingToBuild());
});
var currentCost = this.calculateCurrentCost();
if(this.city.materials.canAfford(currentCost)) {
return noUniqueProblem;
} else {
return false;
}
}
,calculateCurrentCost: function() {
var _g = this.builderType;
if(_g._hx_index == 0) {
var _g1 = _g.buildingType;
var buildingInfo = _g.buildingInfo;
var cost = this.city.progress.buildingCost.getBuildingCost(buildingInfo);
if(this.get_buildingToBuild() != null && this.city.progress.unlocks.getUnlockState(this.get_buildingToBuild()) == progress_UnlockState.Researched) {
cost.knowledge = 0;
}
return cost;
} else {
return this.originalCost;
}
}
,canBuildBuilding: function(world,xPos,yPos,buildingInfo) {
if(yPos == 0 && !world.canBuildOnSurface()) {
return BuildPossibility.BuildingPositionImpossible;
}
var thesePermanents = world.permanents[xPos];
var yPosTop = world.rect.y - 20 * (thesePermanents.length + 1);
var buildingXPos = world.rect.x + 20 * xPos;
var buildingYPos = world.rect.y - 20 * (yPos + 1);
var noBuildingsYet = thesePermanents.length == 0;
var topIsBuilding = !noBuildingsYet && thesePermanents[thesePermanents.length - 1].isBuilding;
var bottomIsNotNoBuilding = noBuildingsYet || (thesePermanents[0] == null || thesePermanents[0].isBuilding);
var topIsRooftopBuilding = topIsBuilding && thesePermanents[thesePermanents.length - 1].isRooftopBuilding;
var yPosTopExcludingRooftop = topIsRooftopBuilding ? yPosTop + 20 : yPosTop;
var specialAllowBridge = false;
var deleteKeyPressed = this.city.game.keyboard.down[46];
var shiftKeyPressed = this.city.game.keyboard.down[16];
var mightDoBuildingAssociatedAction = !deleteKeyPressed && !shiftKeyPressed;
var buildingCanInsertNow = this.city.buildingMode == BuildingMode.Insert && mightDoBuildingAssociatedAction;
var buildingCanReplaceNow = this.city.buildingMode == BuildingMode.Replace && mightDoBuildingAssociatedAction;
if(!buildingCanReplaceNow && yPos < thesePermanents.length && thesePermanents[yPos] != null && thesePermanents[yPos].isBuilding && thesePermanents[yPos].isRooftopBuilding) {
buildingCanInsertNow = true;
}
var isBuildingHere = yPos < thesePermanents.length && thesePermanents[yPos] != null && thesePermanents[yPos].isBuilding;
var potentialLeftPerm = null;
var potentialRightPerm = null;
var hasLeftAndRightBuilding = false;
if((yPos >= thesePermanents.length || thesePermanents[yPos] == null) && yPos > 0 && buildingInfo.specialInfo.indexOf("rooftop") == -1) {
potentialLeftPerm = this.city.getPermanentAtPos(buildingXPos - 20,buildingYPos);
potentialRightPerm = this.city.getPermanentAtPos(buildingXPos + 20,buildingYPos);
var advancedBuildingAllowed = this.city.upgrades.vars.advancedBuildingAllowed;
var buildingOnLeft = potentialLeftPerm != null && potentialLeftPerm.isBuilding;
var buildingOnRight = potentialRightPerm != null && potentialRightPerm.isBuilding;
var possiblyCanCreateBridge = false;
if(advancedBuildingAllowed) {
possiblyCanCreateBridge = buildingOnLeft || buildingOnRight;
} else {
possiblyCanCreateBridge = buildingOnLeft && buildingOnRight;
}
if(possiblyCanCreateBridge) {
hasLeftAndRightBuilding = true;
var potentialLeftBuilding = potentialLeftPerm;
var potentialRightBuilding = potentialRightPerm;
var anyHoleInLeftOrRight = false;
if(advancedBuildingAllowed) {
anyHoleInLeftOrRight = !(potentialLeftBuilding != null && !potentialLeftBuilding.isRooftopBuilding || potentialRightBuilding != null && !potentialRightBuilding.isRooftopBuilding);
} else {
anyHoleInLeftOrRight = potentialLeftBuilding.isRooftopBuilding || potentialRightBuilding.isRooftopBuilding;
}
if(!anyHoleInLeftOrRight) {
if(!common_ArrayExtensions.any(this.city.worlds,function(w) {
if(w != world && buildingXPos >= w.rect.x && buildingXPos < w.rect.get_x2() && w.rect.y - buildingYPos > 0) {
return w.rect.y - buildingYPos < world.rect.y - buildingYPos;
} else {
return false;
}
})) {
specialAllowBridge = true;
}
}
}
}
var nullInBetween = false;
if(buildingCanInsertNow) {
var _g = yPos;
var _g1 = thesePermanents.length - 1;
while(_g < _g1) {
var i = _g++;
if(thesePermanents[i] == null) {
nullInBetween = true;
break;
}
if(thesePermanents[i].isBuilding) {
var bld = thesePermanents[i];
if(bld.isRooftopBuilding && thesePermanents[i + 1] != null) {
return BuildPossibility.BuildingPositionImpossible;
}
}
}
}
var isRooftopBuilding = buildingInfo.specialInfo.indexOf("rooftop") != -1;
var isAdvancedBuildingMode = this.city.upgrades.vars.advancedBuildingAllowed;
if(buildingCanReplaceNow && isBuildingHere && !isRooftopBuilding || (noBuildingsYet || topIsBuilding || specialAllowBridge) && (yPos != 0 || bottomIsNotNoBuilding) && ((buildingCanInsertNow || yPos < thesePermanents.length && thesePermanents[yPos] == null) && (buildingYPos >= yPosTopExcludingRooftop && buildingYPos < world.rect.y) && (yPos == 0 || hasLeftAndRightBuilding || yPos > 0 && thesePermanents[yPos] != null && thesePermanents[yPos].isBuilding || yPos > 0 && thesePermanents[yPos - 1] != null && thesePermanents[yPos - 1].isBuilding && !thesePermanents[yPos - 1].isRooftopBuilding) || !buildingCanInsertNow && mightDoBuildingAssociatedAction && (buildingYPos >= yPosTopExcludingRooftop && buildingYPos < yPosTopExcludingRooftop + 20) || buildingCanReplaceNow && (buildingYPos >= yPosTopExcludingRooftop && buildingYPos < world.rect.y) && !isRooftopBuilding || specialAllowBridge) && (yPos >= thesePermanents.length || thesePermanents[yPos] == null && specialAllowBridge || yPos == 0 || thesePermanents[yPos - 1] != null || buildingCanInsertNow) && (!isRooftopBuilding || yPos == thesePermanents.length || thesePermanents[yPos] == null || yPos == thesePermanents.length - 1 && buildingCanReplaceNow && thesePermanents[yPos].isBuilding && (yPos == 0 || thesePermanents[yPos].bottomBuilding != null && !thesePermanents[yPos].bottomBuilding.isRooftopBuilding) && Builder.canRemoveFromLRPerspective(isAdvancedBuildingMode,thesePermanents[yPos],this.city))) {
var buildingYPosToUseForIntersectionCheck = specialAllowBridge || buildingCanReplaceNow ? buildingYPos : yPosTop;
if(nullInBetween) {
return BuildPossibility.BuildingOK;
}
if(yPos < thesePermanents.length && thesePermanents[yPos] == null) {
return BuildPossibility.BuildingOK;
}
if(!common_ArrayExtensions.any(this.city.worlds,function(w) {
if(w != world && w.mask != null) {
if(w.rect.intersects(new common_Rectangle(buildingXPos,buildingYPosToUseForIntersectionCheck,20,20))) {
return w.mask[(buildingXPos - w.rect.x) / 20 | 0][(buildingYPosToUseForIntersectionCheck - w.rect.y) / 20 | 0];
} else {
return false;
}
} else {
return false;
}
})) {
return BuildPossibility.BuildingOK;
} else {
return BuildPossibility.BuildingInWorld;
}
}
return BuildPossibility.BuildingPositionImpossible;
}
,cancel: function() {
this.stage.removeChild(this.sprite);
this.stage.removeChild(this.builderSecondaryHelpSprite);
if(this.fixedSprite != null) {
this.fixedSprite.destroy();
}
this.city.builder = null;
}
,__class__: Builder
};
var ICreatableCityElement = function() { };
$hxClasses["ICreatableCityElement"] = ICreatableCityElement;
ICreatableCityElement.__name__ = "ICreatableCityElement";
ICreatableCityElement.__isInterface__ = true;
var Permanent = function(game,id,city,world,position,worldPosition) {
this.destroyed = false;
this.highlightSprite = null;
this.bonusEntertainmentCapacity = 0;
this.bonusAttractiveness = 0;
this.game = game;
this.id = id;
this.city = city;
this.world = world;
this.position = position;
this.worldPosition = worldPosition;
world.city.permanentsByID.h[id] = this;
world.city.permanents.push(this);
this.isBuilding = false;
this.ancestors = [];
var currClass = js_Boot.getClass(this);
while(currClass != Permanent) {
this.ancestors.push(currClass);
currClass = currClass.__super__;
}
var c = js_Boot.getClass(this);
this.className = c.__name__;
this.classID = PermanentMetaHelper.getClassID(this.className);
if(js_Boot.__implements(this,buildings_IHousing) && this.ancestors.indexOf(buildings_House) == -1) {
this.ancestors.push(buildings_House);
}
if(this.is(buildings_Work)) {
world.city.workBuildings.push(this);
}
};
$hxClasses["Permanent"] = Permanent;
Permanent.__name__ = "Permanent";
Permanent.__interfaces__ = [ICreatableCityElement];
Permanent.prototype = {
get_name: function() {
return "";
}
,get_typeID: function() {
return 0;
}
,get_attractiveness: function() {
return this.get_baseAttractiveness() + this.bonusAttractiveness;
}
,get_baseAttractiveness: function() {
return 50;
}
,get_entertainmentCapacity: function() {
return this.get_baseEntertainmentCapacity() + this.bonusEntertainmentCapacity;
}
,get_baseEntertainmentCapacity: function() {
return 0;
}
,get_remainingCapacity: function() {
return 0;
}
,get_connectedBuildingsType: function() {
return this.className;
}
,destroyForReplacement: function() {
Permanent.destroyingForReplacement = true;
this.destroy();
Permanent.destroyingForReplacement = false;
}
,destroy: function() {
var thisPermanentStack = this.world.permanents[this.worldPosition.x];
var disableMoveDown = false;
if(Permanent.destroyingDisableMoveDown || Permanent.destroyingForReplacement) {
thisPermanentStack[this.worldPosition.y] = null;
disableMoveDown = true;
} else if(this.is(WorldResource) && thisPermanentStack.length > 1) {
thisPermanentStack[0] = null;
disableMoveDown = true;
} else {
HxOverrides.remove(thisPermanentStack,this);
}
HxOverrides.remove(this.city.permanents,this);
this.city.permanentsByID.remove(this.id);
if(this.is(buildings_Work)) {
HxOverrides.remove(this.world.city.workBuildings,this);
}
var _g = 0;
var _g1 = this.city.simulation.citizens;
while(_g < _g1.length) {
var citizen = _g1[_g];
++_g;
if(citizen.inPermanent == this) {
if(this.worldPosition.y == 0) {
if(citizen.inPermanent != null && citizen.inPermanent.isBuilding) {
var building = citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null;
citizen.relativeX = building.worldPosition.x * 20 + building.doorX;
} else {
citizen.relativeX += citizen.inPermanent.worldPosition.x * 20;
}
if(citizen.inPermanent != null) {
citizen.inPermanent.onCitizenLeave(citizen,null);
}
citizen.inBuildingSince = citizen.city.simulation.time.timeSinceStart;
citizen.set_drawOnStage(citizen.foregroundStage);
citizen.inPermanent = null;
citizen.relativeY = 0;
Citizen.shouldUpdateDraw = true;
} else {
if((citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null).bottomBuilding != null) {
citizen.inPermanent = (citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null).bottomBuilding;
citizen.onWorld = citizen.inPermanent.world;
this.onCitizenLeave(citizen,(citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null).bottomBuilding);
citizen.inBuildingSince = citizen.city.simulation.time.timeSinceStart;
} else if((citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null).leftBuilding != null) {
citizen.inPermanent = (citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null).leftBuilding;
citizen.onWorld = citizen.inPermanent.world;
this.onCitizenLeave(citizen,(citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null).leftBuilding);
citizen.inBuildingSince = citizen.city.simulation.time.timeSinceStart;
} else if((citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null).rightBuilding != null) {
citizen.inPermanent = (citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null).rightBuilding;
citizen.onWorld = citizen.inPermanent.world;
this.onCitizenLeave(citizen,(citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null).rightBuilding);
citizen.inBuildingSince = citizen.city.simulation.time.timeSinceStart;
} else if((citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null).topBuilding != null) {
citizen.inPermanent = (citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null).topBuilding;
citizen.onWorld = citizen.inPermanent.world;
this.onCitizenLeave(citizen,(citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null).topBuilding);
citizen.inBuildingSince = citizen.city.simulation.time.timeSinceStart;
} else {
if(citizen.inPermanent != null && citizen.inPermanent.isBuilding) {
var building1 = citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null;
citizen.relativeX = building1.worldPosition.x * 20 + building1.doorX;
} else {
citizen.relativeX += citizen.inPermanent.worldPosition.x * 20;
}
if(citizen.inPermanent != null) {
citizen.inPermanent.onCitizenLeave(citizen,null);
}
citizen.inBuildingSince = citizen.city.simulation.time.timeSinceStart;
citizen.set_drawOnStage(citizen.foregroundStage);
citizen.inPermanent = null;
citizen.relativeY = 0;
Citizen.shouldUpdateDraw = true;
}
citizen.setRelativeY(0);
}
if(citizen.recyclePathArray) {
pooling_Int32ArrayPool.returnToPool(citizen.path);
citizen.recyclePathArray = false;
}
citizen.path = null;
citizen.nextPathPos = -1;
citizen.pathEnd = -1;
citizen.currentPathAction = null;
if(!citizen.canViewSelfInBuilding) {
citizen.delayCanViewSelfInBuilding = true;
}
citizen.canViewSelfInBuilding = true;
citizen.verticalPathProgress = 0;
citizen.pathEndFunction = null;
citizen.requestingPathGoal = null;
citizen.pathOnlyRelatedTo = null;
citizen.pathWalkSpeed = 1;
citizen.pathCanBeReconsidered = true;
if(citizen.sprite.alpha > 0 && citizen.sprite.alpha < 1) {
citizen.sprite.alpha = 1;
}
citizen.actuallyUpdateDraw();
}
}
if(!disableMoveDown) {
var _g = this.worldPosition.y;
var _g1 = thisPermanentStack.length;
while(_g < _g1) {
var yy = _g++;
var thisPermanent = thisPermanentStack[yy];
if(thisPermanent == null) {
thisPermanentStack.splice(yy,0,null);
break;
}
thisPermanent.worldPosition.y -= 1;
thisPermanent.position.y = this.world.rect.y - (thisPermanent.worldPosition.y + 1) * 20;
if(thisPermanent.isBuilding && thisPermanent.isRooftopBuilding && yy + 1 < thisPermanentStack.length) {
thisPermanentStack.splice(yy + 1,0,null);
break;
}
}
var yy = thisPermanentStack.length - 1;
var nullsOnStackTopAmount = 0;
while(yy >= 0) {
if(thisPermanentStack[yy] == null) {
++nullsOnStackTopAmount;
} else {
break;
}
--yy;
}
if(nullsOnStackTopAmount > 0) {
thisPermanentStack.splice(thisPermanentStack.length - nullsOnStackTopAmount,nullsOnStackTopAmount);
}
}
if(!Permanent.destroyingForReplacement) {
this.city.connections.updateCityConnections();
}
if(!disableMoveDown) {
var _g = this.worldPosition.y;
var _g1 = thisPermanentStack.length;
while(_g < _g1) {
var yy = _g++;
if(thisPermanentStack[yy] != null) {
thisPermanentStack[yy].positionSprites();
}
}
}
if(!Permanent.destroyingForReplacement) {
this.city.simulation.updatePathfinder(true,this);
}
if(this.city.gui.windowRelatedTo == this) {
this.city.gui.closeWindow();
}
this.destroyed = true;
}
,postCreate: function() {
}
,onCityChange: function() {
}
,invalidatePathfindingRelatedInfo: function() {
}
,update: function(timeMod) {
}
,onClick: function() {
var hasSpecial = this.city.specialAction != null && this.city.specialAction.get_specialActionID() == "ChangeCitizenVitalBuildings";
if(hasSpecial) {
this.city.specialAction.performPermanentAction(this);
return;
}
this.showWindow();
this.city.game.audio.playSound(this.city.game.audio.buildingClickSound);
}
,onHover: function(isActive) {
}
,showWindow: function() {
gui_UpgradeWindowParts.hasMultiUpgradeModeOn = false;
this.createWindow();
}
,reloadWindow: function() {
this.city.gui.reloadWindow($bind(this,this.createWindow));
}
,createWindow: function() {
var _gthis = this;
this.city.gui.createWindow(this);
this.city.gui.setWindowReload($bind(this,this.createWindow));
this.city.gui.windowAddTitleText(this.get_name());
this.createMainWindowPart();
this.createWindowAddBottomButtons();
this.selectedSprite = Resources.makeSprite("spr_selectedbuilding");
this.selectedSprite.position.set(this.position.x - 1,this.position.y - 1);
this.city.farForegroundStage.addChild(this.selectedSprite);
this.city.gui.windowOnDestroy = function() {
_gthis.city.farForegroundStage.removeChild(_gthis.selectedSprite);
_gthis.selectedSprite = null;
};
this.city.gui.clearWindowStack();
this.city.gui.addWindowToStack(function() {
if(!_gthis.destroyed) {
_gthis.createWindow();
}
});
}
,addWindowInfoLines: function() {
}
,createMainWindowPart: function() {
this.addWindowInfoLines();
}
,createWindowAddBottomButtons: function() {
this.city.gui.windowAddBottomButtons();
}
,positionSprites: function() {
if(this.selectedSprite != null) {
this.selectedSprite.position.set(this.position.x - 1,this.position.y - 1);
}
if(this.highlightSprite != null) {
this.highlightSprite.position.set(this.position.x - 1,this.position.y - 1);
}
}
,is: function(permanentClass) {
var _g = 0;
var _g1 = this.ancestors;
while(_g < _g1.length) {
var anc = _g1[_g];
++_g;
if(permanentClass == anc) {
return true;
}
}
return false;
}
,onCitizenLeave: function(citizen,newPermanent) {
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
if(shouldSaveDefinition) {
queue.addString(Permanent.saveDefinition);
}
}
,load: function(queue,definition) {
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
}
,__class__: Permanent
};
var Building = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.isMedical = false;
this.isEntertainment = false;
this.doorX = 13;
Permanent.call(this,game,id,city,world,position,worldPosition);
this.isBuilding = true;
this.upgrades = [];
this.buildingMode = null;
this.adjecentBuildingEffects = [];
this.stage = stage;
this.bgStage = bgStage;
this.drawer = Type.createInstance(this.get_drawerType(),[this,stage,bgStage,Reflect.field(js_Boot.getClass(this),"spriteName")]);
this.info = city.progress.resources.buildingInfo.h[this.className];
this.isRooftopBuilding = this.info.specialInfo.indexOf("rooftop") != -1;
city.simulation.jobAssigner.buildingsHaveWork = true;
city.simulation.houseAssigner.shouldUpdateHouses = true;
city.simulation.schoolAssigner.schoolsShouldBeUpdated = true;
if(!Game.isLoading && this.get_possibleBuildingModes().length > 0) {
this.buildingMode = Type.createInstance(this.get_possibleBuildingModes()[0],[stage,city.cityMidStage,bgStage,this]);
}
};
$hxClasses["Building"] = Building;
Building.__name__ = "Building";
Building.__super__ = Permanent;
Building.prototype = $extend(Permanent.prototype,{
get_name: function() {
return this.info.name;
}
,get_possibleUpgrades: function() {
return [];
}
,get_possibleBuildingModes: function() {
return [];
}
,get_possibleCityUpgrades: function() {
return [];
}
,get_possiblePolicies: function() {
return [];
}
,get_walkThroughCanViewSelfInThisBuilding: function() {
return true;
}
,get_drawerType: function() {
return buildings_buildingDrawers_NormalBuildingDrawer;
}
,onBuild: function() {
}
,destroy: function() {
if(this.isRooftopBuilding && this.worldPosition.y != this.world.permanents[this.worldPosition.x].length - 1) {
Permanent.destroyingDisableMoveDown = true;
}
Permanent.prototype.destroy.call(this);
Permanent.destroyingDisableMoveDown = false;
this.drawer.destroy();
Lambda.iter(this.upgrades,function(u) {
u.destroy();
});
if(this.buildingMode != null) {
this.buildingMode.destroy();
}
if(this.city.windowRelatedOnBuildOrDestroy != null) {
this.city.windowRelatedOnBuildOrDestroy();
}
}
,tryDestroy: function(warnIfNot) {
if(warnIfNot == null) {
warnIfNot = true;
}
var failedStructuralCheck = false;
var advancedBuildingAllowed = this.city.upgrades.vars.advancedBuildingAllowed;
if(!this.isRooftopBuilding) {
var stackTopBuild = this;
while(stackTopBuild.topBuilding != null && !stackTopBuild.topBuilding.isRooftopBuilding) stackTopBuild = stackTopBuild.topBuilding;
failedStructuralCheck = !Builder.canRemoveFromLRPerspective(advancedBuildingAllowed,stackTopBuild,this.city);
if(this.topBuilding != null && (this.topBuilding.isRooftopBuilding && this.bottomBuilding == null && this.worldPosition.y != 0)) {
failedStructuralCheck = true;
}
}
if(failedStructuralCheck) {
if(warnIfNot) {
this.city.gui.showSimpleWindow("You can't destroy this building as that would result in an invalid structure.",null,true,true);
}
return false;
}
this.giveRecycleReward();
this.destroy();
return true;
}
,giveRecycleReward: function(fullCost) {
if(fullCost == null) {
fullCost = true;
}
if(this.info != null) {
var mats = fullCost ? Materials.fromBuildingInfo(this.info) : new Materials();
var _g = 0;
var _g1 = this.upgrades;
while(_g < _g1.length) {
var ug = _g1[_g];
++_g;
var ugInfo = Resources.buildingUpgradesInfo.h[ug.className];
mats.add(Materials.fromBuildingUpgradesInfo(ugInfo));
}
mats.knowledge = 0;
mats.multiply(this.city.upgrades.vars.recyclingAmount);
this.city.materials.add(mats);
}
}
,createWindowAddBottomButtons: function() {
var _gthis = this;
if(!this.city.progress.story.disableDestroy) {
var destroyButton = null;
var isConfirmButton = false;
destroyButton = this.city.gui.windowAddBottomButtons([{ text : "Destroy", action : function() {
if(isConfirmButton) {
_gthis.city.gui.closeWindow();
_gthis.tryDestroy(true);
} else {
destroyButton.setText("Really Destroy?");
isConfirmButton = true;
}
}, onHover : function() {
if(!isConfirmButton) {
_gthis.city.gui.tooltip.setText(destroyButton,_gthis.game.isMobile ? "Destroy This Building" : "Destroy This Building\nTip: you can also Delete+Click on buildings to quickly destroy them.");
}
}}])[0];
} else {
this.city.gui.windowAddBottomButtons();
}
}
,positionSprites: function() {
Permanent.prototype.positionSprites.call(this);
this.drawer.positionSprites();
Lambda.iter(this.upgrades,function(u) {
u.reposition();
});
if(this.buildingMode != null) {
this.buildingMode.reposition();
}
}
,changeMainTexture: function(textureName) {
this.drawer.changeMainTexture(textureName);
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
Permanent.prototype.save.call(this,queue,shouldSaveDefinition);
var value = this.upgrades.length;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var _g = 0;
var _g1 = this.upgrades;
while(_g < _g1.length) {
var u = _g1[_g];
++_g;
queue.addString(u.className);
u.save(queue);
}
var value = this.buildingMode != null ? 1 : 0;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
if(this.buildingMode != null) {
queue.addString(this.buildingMode.className);
this.buildingMode.save(queue);
}
}
,load: function(queue,definition) {
Permanent.prototype.load.call(this,queue,definition);
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var upgradeLen = intToRead;
var _g = 0;
var _g1 = upgradeLen;
while(_g < _g1) {
var i = _g++;
var name = queue.readString();
var upgrade = Type.createInstance($hxClasses[name],[this.stage,this.city.cityMidStage,this.bgStage,this]);
upgrade.load(queue);
this.upgrades.push(upgrade);
}
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
if(intToRead == 1) {
var name = queue.readString();
this.buildingMode = Type.createInstance($hxClasses[name],[this.stage,this.city.cityMidStage,this.bgStage,this]);
this.buildingMode.load(queue);
} else {
this.buildingMode = null;
}
}
,createMainWindowPart: function() {
Permanent.prototype.createMainWindowPart.call(this);
gui_CreateBuildingUpgrades.createMainWindowPart(this,this.city);
}
,getTotalAdjacentBuildingEffects: function(effectType) {
var total = 0.0;
var _g = 0;
var _g1 = this.adjecentBuildingEffects;
while(_g < _g1.length) {
var ae = _g1[_g];
++_g;
if(ae.name == effectType) {
total += ae.intensity;
}
}
return total;
}
,getEffectsOfAdjecentBuildings: function(effectType) {
var total = 0.0;
if(this.leftBuilding != null) {
var total1 = 0.0;
var _g = 0;
var _g1 = this.leftBuilding.adjecentBuildingEffects;
while(_g < _g1.length) {
var ae = _g1[_g];
++_g;
if(ae.name == effectType) {
total1 += ae.intensity;
}
}
total += total1;
}
if(this.rightBuilding != null) {
var total1 = 0.0;
var _g = 0;
var _g1 = this.rightBuilding.adjecentBuildingEffects;
while(_g < _g1.length) {
var ae = _g1[_g];
++_g;
if(ae.name == effectType) {
total1 += ae.intensity;
}
}
total += total1;
}
if(this.topBuilding != null) {
var total1 = 0.0;
var _g = 0;
var _g1 = this.topBuilding.adjecentBuildingEffects;
while(_g < _g1.length) {
var ae = _g1[_g];
++_g;
if(ae.name == effectType) {
total1 += ae.intensity;
}
}
total += total1;
}
if(this.bottomBuilding != null) {
var total1 = 0.0;
var _g = 0;
var _g1 = this.bottomBuilding.adjecentBuildingEffects;
while(_g < _g1.length) {
var ae = _g1[_g];
++_g;
if(ae.name == effectType) {
total1 += ae.intensity;
}
}
total += total1;
}
return total;
}
,getEffectsOfAdjecentBuildingsLR: function(effectType) {
var total = 0.0;
if(this.leftBuilding != null) {
var total1 = 0.0;
var _g = 0;
var _g1 = this.leftBuilding.adjecentBuildingEffects;
while(_g < _g1.length) {
var ae = _g1[_g];
++_g;
if(ae.name == effectType) {
total1 += ae.intensity;
}
}
total += total1;
}
if(this.rightBuilding != null) {
var total1 = 0.0;
var _g = 0;
var _g1 = this.rightBuilding.adjecentBuildingEffects;
while(_g < _g1.length) {
var ae = _g1[_g];
++_g;
if(ae.name == effectType) {
total1 += ae.intensity;
}
}
total += total1;
}
return total;
}
,onClick: function() {
var hasSpecial = this.city.specialAction != null && this.city.specialAction.get_specialActionID() == "ChangeCitizenVitalBuildings";
if(hasSpecial) {
this.city.specialAction.performPermanentAction(this);
return;
}
if(this.game.keyboard.down[46] || this.city.buildingMode == BuildingMode.Destroy) {
if(!this.city.progress.story.disableDestroy) {
if(this.city.gui.windowRelatedTo == this) {
this.city.gui.closeWindow();
}
if(this.tryDestroy(true)) {
this.city.game.audio.playSound(this.city.game.audio.buttonFailSound);
}
} else {
this.city.gui.showSimpleWindow("Your citizens don't want to destroy buildings right now!",null,true);
}
} else if(this.game.keyboard.down[16]) {
this.city.createOrRemoveBuilder(js_Boot.getClass(this),true);
} else {
this.showWindow();
this.city.game.audio.playSound(this.city.game.audio.buildingClickSound);
}
}
,onHover: function(isActive) {
Permanent.prototype.onHover.call(this,isActive);
if(this.game.keyboard.down[46] || this.city.buildingMode == BuildingMode.Destroy) {
var destroySprite = new PIXI.Sprite(Resources.getTexture("spr_destroying"));
destroySprite.position.set(this.position.x,this.position.y);
this.city.furtherForegroundTempStage.addChild(destroySprite);
destroySprite.alpha = isActive ? 1 : !this.game.isMobile ? 0.5 : 0;
}
}
,hasHolesBelowInBuildingStack: function() {
var _g = 0;
var _g1 = this.worldPosition.y;
while(_g < _g1) {
var yy = _g++;
var thisPerm = this.world.permanents[this.worldPosition.x][yy];
if(thisPerm == null || !thisPerm.isBuilding) {
return true;
}
}
return false;
}
,getGlobalGoal: function() {
return null;
}
,couldStandHere: function() {
if(this.get_drawerType() == buildings_buildingDrawers_AllDirMergingBuildingDrawer) {
if(this.bottomBuilding != null) {
return !this.bottomBuilding.is(js_Boot.getClass(this));
} else {
return true;
}
} else {
return true;
}
}
,__class__: Building
});
var BuildingMode = $hxEnums["BuildingMode"] = { __ename__ : "BuildingMode", __constructs__ : ["Normal","Insert","Replace","Drag","Destroy"]
,Normal: {_hx_index:0,__enum__:"BuildingMode",toString:$estr}
,Insert: {_hx_index:1,__enum__:"BuildingMode",toString:$estr}
,Replace: {_hx_index:2,__enum__:"BuildingMode",toString:$estr}
,Drag: {_hx_index:3,__enum__:"BuildingMode",toString:$estr}
,Destroy: {_hx_index:4,__enum__:"BuildingMode",toString:$estr}
};
var BuildingUpgrade = function(stage,building) {
this.stage = stage;
this.building = building;
var c = js_Boot.getClass(this);
this.className = c.__name__;
building.bonusAttractiveness += this.get_bonusAttractiveness();
if(stage != null) {
this.textures = Resources.getTexturesByWidth(this.get_textureName(),20);
this.spriteIndex = random_Random.getInt(this.get_availableTextures());
this.sprite = new PIXI.Sprite(this.textures[this.spriteIndex]);
this.reposition();
if(this.get_canCacheSprite()) {
stage.cacheableChildren.push(this.sprite);
stage.isInvalid = true;
} else {
stage.addChild(this.sprite);
}
} else {
this.textures = [];
}
};
$hxClasses["BuildingUpgrade"] = BuildingUpgrade;
BuildingUpgrade.__name__ = "BuildingUpgrade";
BuildingUpgrade.__interfaces__ = [ICreatableCityElement];
BuildingUpgrade.prototype = {
get_textureName: function() {
return "";
}
,get_hasChangeableAppearance: function() {
return this.textures.length > 1;
}
,get_bonusAttractiveness: function() {
return 0;
}
,get_canCacheSprite: function() {
return true;
}
,get_availableTextures: function() {
return this.textures.length;
}
,set_onUpdate: function(to) {
if(this.building.city.simulation.buildingUpgradesToUpdate.indexOf(this) == -1) {
this.building.city.simulation.buildingUpgradesToUpdate.push(this);
}
this.onUpdate = to;
return this.onUpdate;
}
,changeAppearance: function() {
if(this.textures.length <= 1) {
return;
}
if((this.spriteIndex += 1) >= this.get_availableTextures()) {
this.spriteIndex = 0;
}
this.sprite.texture = this.textures[this.spriteIndex];
if(this.get_canCacheSprite()) {
this.stage.isInvalid = true;
}
}
,reposition: function() {
if(this.stage != null) {
this.sprite.position.set(this.building.position.x,this.building.position.y);
if(this.get_canCacheSprite()) {
this.stage.isInvalid = true;
}
}
}
,postLoad: function() {
if(this.stage != null) {
this.sprite.texture = this.textures[this.spriteIndex];
if(this.get_canCacheSprite()) {
this.stage.isInvalid = true;
}
}
}
,destroy: function() {
this.building.bonusAttractiveness -= this.get_bonusAttractiveness();
if(this.stage != null) {
if(this.get_canCacheSprite()) {
var _this = this.stage;
var child = this.sprite;
HxOverrides.remove(_this.cacheableChildren,child);
_this.isInvalid = true;
if(child.parent != null) {
child.parent.removeChild(child);
}
} else {
this.stage.removeChild(this.sprite);
}
}
}
,update: function(timeMod) {
this.onUpdate(timeMod);
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
if(shouldSaveDefinition) {
queue.addString(BuildingUpgrade.saveDefinition);
}
var value = this.spriteIndex;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
,load: function(queue,definition) {
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"spriteIndex")) {
this.spriteIndex = loadMap.h["spriteIndex"];
}
this.postLoad();
}
,__class__: BuildingUpgrade
};
var LifeAction = $hxEnums["LifeAction"] = { __ename__ : "LifeAction", __constructs__ : ["Work","School","Nothing"]
,Work: {_hx_index:0,__enum__:"LifeAction",toString:$estr}
,School: {_hx_index:1,__enum__:"LifeAction",toString:$estr}
,Nothing: {_hx_index:2,__enum__:"LifeAction",toString:$estr}
};
var Citizen = function(city,simulation,foregroundStage,inBuildingStage,inBuildingStageNonParticle,adultTextures,childrenTextures,onWorld,worldX,startAge,startInPermanent) {
if(startAge == null) {
startAge = 0;
}
this.dynamicUnsavedVars = { };
this.likesNightclubs = false;
this.hasDied = false;
this.hobby = null;
this.isForcedHome = false;
this.wantsNightEntertainmentIn = 0;
this.pathCanBeReconsidered = true;
this.recyclePathArray = false;
this.pathWalkSpeed = 1;
this.pathOnlyRelatedTo = null;
this.pathEndFunction = null;
this.currentPathActionTimerXY = 0;
this.verticalPathProgress = 0;
this.delayCanViewSelfInBuilding = false;
this.canViewSelfInBuilding = true;
this.inBuildingSince = 0;
this.inPermanent = null;
this.accessorySprite = null;
this.educationLevel = 0;
this.lastInfrequentUpdateAge = 0;
this.hasWorkTools = false;
this.currentAction = LifeAction.Nothing;
this.hasBuildingInited = false;
this.city = city;
this.simulation = simulation;
this.spriteIndexActual = random_Random.getInt(childrenTextures.length);
this.nameIndex = random_Random.getInt(1,Resources.citizenNames.length == 0 ? 8000 : Resources.citizenNames.length);
this.spriteIndex = this.spriteIndexActual + (this.nameIndex << 14);
this.onWorld = onWorld;
this.relativeX = worldX;
this.relativeY = 0;
this.foregroundStage = foregroundStage;
this.inBuildingStageNonParticle = inBuildingStageNonParticle;
this.inBuildingStage = inBuildingStage;
this.adultTextures = adultTextures;
this.childrenTextures = childrenTextures;
simulation.houseAssigner.shouldUpdateHouses = true;
simulation.schoolAssigner.schoolsShouldBeUpdated = true;
this.bornOn = simulation.time.timeSinceStart - startAge * 1440;
this.lastInfrequentUpdateAge = this.get_age();
this.dieAgeModifier = random_Random.getInt(-5,5);
this.setPreferences();
this.addedToStage = null;
this.sprite = new PIXI.Sprite();
this.setCurrentTexture();
Citizen.spriteCitizens.set(this.sprite,this);
this.sprite.anchor.y = 1;
this.actuallyUpdateDraw();
if(!Game.isLoading && this.get_age() >= 16) {
this.addToWorkers();
}
if(startInPermanent != null) {
if(this.inPermanent != null) {
this.inPermanent.onCitizenLeave(this,startInPermanent);
}
this.inBuildingSince = this.city.simulation.time.timeSinceStart;
this.inPermanent = startInPermanent;
this.hasBuildingInited = false;
this.set_drawOnStage(inBuildingStage);
this.canViewSelfInBuilding = false;
} else {
this.set_drawOnStage(foregroundStage);
}
this.entertainment = new simulation_CitizenEntertainment(this);
this.wantsNightEntertainmentIn = random_Random.getInt(5);
this.pathWalkSpeed = 1;
this.inBuildingSince = city.simulation.time.timeSinceStart;
};
$hxClasses["Citizen"] = Citizen;
Citizen.__name__ = "Citizen";
Citizen.prototype = {
get_stepsInBuilding: function() {
return (this.city.simulation.time.timeSinceStart - this.inBuildingSince) / this.city.simulation.time.minutesPerTick;
}
,get_worldX: function() {
return (this.inPermanent == null ? 0 : this.inPermanent.worldPosition.x * 20) + this.relativeX;
}
,get_workTimePreference: function() {
return this.actualWorkTimePreference * (this.job == null ? 1 : this.job.workTimePreferenceMod);
}
,get_educationSpeedModifier: function() {
return 1 + this.educationLevel / 2;
}
,get_age: function() {
return (this.simulation.time.timeSinceStart - this.bornOn) / 1440;
}
,set_drawOnStage: function(val) {
var prevVal = this.drawOnStage;
this.drawOnStage = val;
if(prevVal != val) {
this.sprite.alpha = 1;
}
return this.drawOnStage;
}
,setHobby: function(hobby) {
this.hobby = hobby;
this.likesNightclubs = false;
}
,postLoad: function() {
var f = this.relativeX;
if(isNaN(f)) {
this.relativeX = 0;
}
this.entertainment.setAgeRelatedEntertainment();
}
,tryRemove: function() {
if(this.fullyBeingControlled) {
return;
}
this.city.simulation.babyMaker.onCitizenDeath();
HxOverrides.remove(this.simulation.jobAssigner.citizensWithoutJob,this);
if(this.job != null) {
HxOverrides.remove(this.job.workers,this);
this.simulation.jobAssigner.buildingsHaveWork = true;
}
if(this.home != null) {
HxOverrides.remove(this.home.residents,this);
this.simulation.houseAssigner.shouldUpdateHouses = true;
}
if(this.school != null) {
HxOverrides.remove(this.school.students,this);
this.simulation.schoolAssigner.schoolsShouldBeUpdated = true;
}
if(this.addedToStage != null) {
this.swapRemoveFromStage();
}
Citizen.spriteCitizens.remove(this.sprite);
HxOverrides.remove(this.simulation.citizens,this);
if(this.hobby != null) {
this.hobby.onDie();
}
this.hasDied = true;
if(this.isForcedHome) {
HxOverrides.remove(this.simulation.houseAssigner.citizensWithFixedHomes,this);
}
}
,setPreferences: function() {
this.actualWorkTimePreference = random_Random.getFloat(-1,1);
this.likesNightclubs = this.spriteIndex % 5 == 0 ? false : true;
}
,update: function(timeMod) {
if(!this.fullyBeingControlled) {
Citizen.shouldUpdateDraw = false;
if(this.delayCanViewSelfInBuilding) {
this.delayCanViewSelfInBuilding = false;
Citizen.shouldUpdateDraw = true;
}
this.updatePath(timeMod);
if(this.path == null && !this.isRequestingPath) {
this.updateDailyLife(timeMod);
}
if(Citizen.shouldUpdateDraw) {
this.actuallyUpdateDraw();
}
}
}
,shouldWorkNow: function() {
if(this.job != null) {
var this1 = this.simulation.time.timeSinceStart / 60 % 24;
var start = this.job.startTime + this.get_workTimePreference();
var end = (this.job.endTime + this.get_workTimePreference() + this.city.policies.vars.workTimeChange) % 24;
if(start < end) {
if(this1 >= start) {
return this1 < end;
} else {
return false;
}
} else if(!(this1 >= start)) {
return this1 < end;
} else {
return true;
}
} else {
return false;
}
}
,shouldSchoolNow: function() {
if(this.school != null) {
var this1 = this.simulation.time.timeSinceStart / 60 % 24;
var start = this.school.schoolStartTime;
var end = this.school.schoolEndTime;
if(start < end) {
if(this1 >= start) {
return this1 < end;
} else {
return false;
}
} else if(!(this1 >= start)) {
return this1 < end;
} else {
return true;
}
} else {
return false;
}
}
,updateDailyLife: function(timeMod) {
var time = this.simulation.time.timeSinceStart / 60 % 24;
if(this.currentAction == LifeAction.School) {
var start = this.school.schoolStartTime;
var end = this.school.schoolEndTime;
if(start < end ? time >= start && time < end : time >= start || time < end) {
this.school.beAtSchool(this,timeMod);
} else {
this.currentAction = LifeAction.Nothing;
}
} else if(this.currentAction == LifeAction.Work) {
var tmp = this.job;
var start = this.job.startTime + this.get_workTimePreference();
var end = this.job.endTime + this.get_workTimePreference() + this.city.policies.vars.workTimeChange;
tmp.work(this,timeMod,!(start < end ? time >= start && time < end : time >= start || time < end));
} else if(this.hobby != null && this.hobby.isActive()) {
this.hobby.update(timeMod);
} else if(this.shouldWorkNow()) {
if(this.inPermanent == this.job) {
this.currentAction = LifeAction.Work;
} else {
var _this = this.entertainment;
if(_this.citizen.inPermanent != null && _this.citizen.inPermanent.isBuilding && _this.citizen.inPermanent.isEntertainment ? _this.citizen.inPermanent.finishEntertainment(_this.citizen,timeMod) : true) {
this.simulation.pathfinder.findPath(this,this.job.get_firstBuildingToGoTo());
}
}
} else if(this.shouldSchoolNow()) {
if(this.inPermanent == this.school) {
this.currentAction = LifeAction.School;
} else {
var _this = this.entertainment;
if(_this.citizen.inPermanent != null && _this.citizen.inPermanent.isBuilding && _this.citizen.inPermanent.isEntertainment ? _this.citizen.inPermanent.finishEntertainment(_this.citizen,timeMod) : true) {
if(this.school.workers.length == 0) {
this.leaveSchool();
} else {
this.simulation.pathfinder.findPath(this,this.school);
}
}
}
} else {
var busy = this.entertainment.updateEntertainment(timeMod);
if(!busy) {
var tmp;
if(this.home != null) {
if(this.job == null) {
var start = 8 + this.get_workTimePreference();
var end = 21 + this.get_workTimePreference();
tmp = !(start < end ? time >= start && time < end : time >= start || time < end);
} else {
tmp = true;
}
} else {
tmp = false;
}
if(tmp) {
if(this.inPermanent != this.home) {
this.simulation.pathfinder.findPath(this,this.home);
} else {
var startTime;
var endTime;
if(this.job == null) {
startTime = 8;
endTime = 21;
} else {
startTime = this.job.startTime;
endTime = this.job.endTime;
}
var this1 = this.simulation.time.timeSinceStart / 60 % 24;
var this2 = startTime;
var newTime = this2;
newTime += this.get_workTimePreference() - 1;
newTime %= 24;
var start = newTime;
var this2 = endTime;
var newTime = this2;
newTime += this.get_workTimePreference() + 1;
newTime %= 24;
var end = newTime;
if((start < end ? this1 >= start && this1 < end : this1 >= start || this1 < end) || this.get_stepsInBuilding() < 240) {
this.canViewSelfInBuilding = true;
this.home.walkAround(this,this.get_stepsInBuilding());
} else {
this.canViewSelfInBuilding = false;
}
}
} else {
this.wander(timeMod);
}
}
}
}
,stopWork: function() {
this.currentAction = LifeAction.Nothing;
}
,tryFinishWork: function(timeMod) {
if(this.currentAction == LifeAction.Work) {
this.job.work(this,timeMod,true);
}
return this.currentAction != LifeAction.Work;
}
,evictFromHome: function() {
if(this.home == null) {
return;
}
HxOverrides.remove(this.home.residents,this);
this.home = null;
this.simulation.houseAssigner.shouldUpdateHouses = true;
}
,leaveSchool: function() {
if(this.school == null) {
return;
}
HxOverrides.remove(this.school.students,this);
this.school = null;
this.simulation.schoolAssigner.schoolsShouldBeUpdated = true;
if(this.currentAction == LifeAction.School) {
this.currentAction = LifeAction.Nothing;
}
}
,loseJob: function(instantReplace) {
if(instantReplace == null) {
instantReplace = false;
}
if(this.job == null) {
return;
}
HxOverrides.remove(this.job.workers,this);
this.job = null;
if(!instantReplace) {
this.simulation.jobAssigner.buildingsHaveWork = true;
this.simulation.jobAssigner.citizensWithoutJob.push(this);
}
this.hasWorkTools = false;
if(this.currentAction == LifeAction.Work) {
this.currentAction = LifeAction.Nothing;
}
}
,infrequentUpdate: function() {
this.setCurrentTexture();
if(this.lastInfrequentUpdateAge < 16 && this.get_age() >= 16) {
if(this.job == null) {
this.addToWorkers();
} else if(this.school != null) {
this.leaveSchool();
}
}
this.lastInfrequentUpdateAge = this.get_age();
if(this.get_age() >= 75 + this.dieAgeModifier && !this.city.progress.story.disableDying) {
this.tryRemove();
}
var notInFestival = true;
var _g = 0;
var _g1 = this.city.simulation.festivalManager.festivals;
while(_g < _g1.length) {
var fest = _g1[_g];
++_g;
if(fest.isInvolvedWithFestival(this)) {
notInFestival = false;
}
}
if(this.path != null && this.pathCanBeReconsidered && notInFestival) {
var shouldActuallyWorkNow = this.currentAction != LifeAction.Work && this.shouldWorkNow();
var shouldActuallySchoolNow = this.currentAction != LifeAction.School && this.shouldSchoolNow();
if(shouldActuallyWorkNow && this.pathDestination != this.job || shouldActuallySchoolNow && this.pathDestination != this.school) {
var resetCanViewSelfInBuilding = false;
if(resetCanViewSelfInBuilding == null) {
resetCanViewSelfInBuilding = true;
}
if(this.recyclePathArray) {
pooling_Int32ArrayPool.returnToPool(this.path);
this.recyclePathArray = false;
}
this.path = null;
this.nextPathPos = -1;
this.pathEnd = -1;
this.currentPathAction = null;
if(resetCanViewSelfInBuilding) {
if(!this.canViewSelfInBuilding) {
this.delayCanViewSelfInBuilding = true;
}
this.canViewSelfInBuilding = true;
}
this.verticalPathProgress = 0;
this.pathEndFunction = null;
this.requestingPathGoal = null;
this.pathOnlyRelatedTo = null;
this.pathWalkSpeed = 1;
this.pathCanBeReconsidered = true;
if(this.sprite.alpha > 0 && this.sprite.alpha < 1) {
this.sprite.alpha = 1;
}
}
}
}
,addToWorkers: function() {
this.simulation.jobAssigner.citizensWithoutJob.push(this);
this.simulation.jobAssigner.buildingsHaveWork = true;
if(this.school != null) {
this.leaveSchool();
}
}
,midDayUpdate: function() {
if(this.wantsNightEntertainmentIn > 0) {
this.wantsNightEntertainmentIn--;
}
this.dieAgeModifier += 0.2 * (this.simulation.happiness.medicalHappiness / 100.0);
if(this.city.simulation.happiness.happiness < 10 && this.home == null && this.city.materials.food < 1) {
if(this.job == null) {
this.dieAgeModifier -= 10;
}
this.dieAgeModifier -= 1;
}
if(this.home != null) {
this.dieAgeModifier += this.home.yearsToLiveLongerPerYearIfLivingHere;
}
this.dieAgeModifier += this.city.upgrades.vars.extendAgeBy;
}
,updatePath: function(timeMod) {
var _gthis = this;
if(this.path != null) {
if(this.currentPathAction == null) {
while(this.path[this.nextPathPos] == 12) {
this.pathWalkSpeed = 1 * this.path[this.nextPathPos + 1] / 100;
this.nextPathPos += 2;
}
this.currentPathAction = this.path[this.nextPathPos];
if(this.currentPathAction == 0 || this.currentPathAction == 1 || this.currentPathAction == 9) {
this.canViewSelfInBuilding = false;
Citizen.shouldUpdateDraw = true;
} else if(this.pathOnlyRelatedTo != null || this.currentPathAction != 4 && this.currentPathAction != 8) {
this.canViewSelfInBuilding = (this.inPermanent != null && this.inPermanent.isBuilding ? this.inPermanent : null) != null ? this.inPermanent.get_walkThroughCanViewSelfInThisBuilding() : true;
Citizen.shouldUpdateDraw = true;
}
if(this.currentPathAction != 4 && this.currentPathAction != 8 && this.currentPathAction != 9) {
this.relativeY = 0;
}
this.currentPathActionTimerXY = 0;
if(this.currentPathAction == 5 || this.currentPathAction == 7 || this.currentPathAction == 11 || this.currentPathAction == 13) {
this.currentPathActionPermanent = this.city.findPermanentByID(this.path[this.nextPathPos + 1]);
} else if(this.currentPathAction == 4 || this.currentPathAction == 9 || this.currentPathAction == 8) {
this.currentPathActionTimerXY = this.path[this.nextPathPos + 1];
}
}
var reachedActionGoal = false;
switch(this.currentPathAction) {
case 0:
this.verticalPathProgress += timeMod;
if(this.verticalPathProgress >= 20) {
var permanent = (this.inPermanent != null && this.inPermanent.isBuilding ? this.inPermanent : null).topBuilding;
if(this.inPermanent != null) {
this.inPermanent.onCitizenLeave(this,permanent);
}
this.inBuildingSince = this.city.simulation.time.timeSinceStart;
this.inPermanent = permanent;
this.hasBuildingInited = false;
this.verticalPathProgress -= 20;
reachedActionGoal = true;
}
break;
case 1:
this.verticalPathProgress += timeMod;
if(this.verticalPathProgress >= 20) {
var permanent = (this.inPermanent != null && this.inPermanent.isBuilding ? this.inPermanent : null).bottomBuilding;
if(this.inPermanent != null) {
this.inPermanent.onCitizenLeave(this,permanent);
}
this.inBuildingSince = this.city.simulation.time.timeSinceStart;
this.inPermanent = permanent;
this.hasBuildingInited = false;
this.verticalPathProgress -= 20;
reachedActionGoal = true;
}
break;
case 2:
this.relativeX -= timeMod * this.pathWalkSpeed;
if(this.relativeX < -2) {
var permanent = (this.inPermanent != null && this.inPermanent.isBuilding ? this.inPermanent : null).leftBuilding;
if(this.inPermanent != null) {
this.inPermanent.onCitizenLeave(this,permanent);
}
this.inBuildingSince = this.city.simulation.time.timeSinceStart;
this.inPermanent = permanent;
this.hasBuildingInited = false;
this.onWorld = this.inPermanent.world;
this.relativeX += 20;
reachedActionGoal = true;
} else {
Citizen.shouldUpdateDraw = true;
}
break;
case 3:
this.relativeX += timeMod * this.pathWalkSpeed;
if(this.relativeX > 20) {
var permanent = (this.inPermanent != null && this.inPermanent.isBuilding ? this.inPermanent : null).rightBuilding;
if(this.inPermanent != null) {
this.inPermanent.onCitizenLeave(this,permanent);
}
this.inBuildingSince = this.city.simulation.time.timeSinceStart;
this.inPermanent = permanent;
this.hasBuildingInited = false;
this.onWorld = this.inPermanent.world;
this.relativeX -= 20;
reachedActionGoal = true;
} else {
Citizen.shouldUpdateDraw = true;
}
break;
case 4:
var x = this.currentPathActionTimerXY;
var spd = this.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
if(Math.abs(x - this.relativeX) < spd) {
this.relativeX = x;
reachedActionGoal = true;
} else {
var num = x - this.relativeX;
this.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
reachedActionGoal = false;
}
break;
case 5:
if(this.inPermanent != null) {
if(this.inPermanent != null && this.inPermanent.isBuilding) {
var x = (this.inPermanent != null && this.inPermanent.isBuilding ? this.inPermanent : null).doorX;
var spd = this.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
var tmp;
if(Math.abs(x - this.relativeX) < spd) {
this.relativeX = x;
tmp = true;
} else {
var num = x - this.relativeX;
this.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
tmp = false;
}
if(tmp) {
if(this.inPermanent != null && this.inPermanent.isBuilding) {
var building = this.inPermanent != null && this.inPermanent.isBuilding ? this.inPermanent : null;
this.relativeX = building.worldPosition.x * 20 + building.doorX;
} else {
this.relativeX += this.inPermanent.worldPosition.x * 20;
}
if(this.inPermanent != null) {
this.inPermanent.onCitizenLeave(this,null);
}
this.inBuildingSince = this.city.simulation.time.timeSinceStart;
this.set_drawOnStage(this.foregroundStage);
this.inPermanent = null;
this.relativeY = 0;
Citizen.shouldUpdateDraw = true;
}
} else {
if(this.inPermanent != null && this.inPermanent.isBuilding) {
var building = this.inPermanent != null && this.inPermanent.isBuilding ? this.inPermanent : null;
this.relativeX = building.worldPosition.x * 20 + building.doorX;
} else {
this.relativeX += this.inPermanent.worldPosition.x * 20;
}
if(this.inPermanent != null) {
this.inPermanent.onCitizenLeave(this,null);
}
this.inBuildingSince = this.city.simulation.time.timeSinceStart;
this.set_drawOnStage(this.foregroundStage);
this.inPermanent = null;
this.relativeY = 0;
Citizen.shouldUpdateDraw = true;
}
} else if(this.currentPathActionPermanent.isBuilding) {
var currentPathActionBuilding = this.currentPathActionPermanent;
var x = currentPathActionBuilding.worldPosition.x * 20 + currentPathActionBuilding.doorX;
var spd = this.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
if(Math.abs(x - this.relativeX) < spd) {
this.relativeX = x;
reachedActionGoal = true;
} else {
var num = x - this.relativeX;
this.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
reachedActionGoal = false;
}
if(reachedActionGoal) {
var permanent = this.currentPathActionPermanent;
if(this.inPermanent != null) {
this.inPermanent.onCitizenLeave(this,permanent);
}
this.inBuildingSince = this.city.simulation.time.timeSinceStart;
this.inPermanent = permanent;
this.hasBuildingInited = false;
this.set_drawOnStage(this.inBuildingStage);
this.relativeX = currentPathActionBuilding.doorX;
}
} else {
var permanentX = this.currentPathActionPermanent.worldPosition.x * 20;
var num = permanentX + 10. - this.relativeX;
this.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * (timeMod * this.pathWalkSpeed);
if(this.relativeX > permanentX && this.relativeX < permanentX + 20 - 2) {
var permanent = this.currentPathActionPermanent;
if(this.inPermanent != null) {
this.inPermanent.onCitizenLeave(this,permanent);
}
this.inBuildingSince = this.city.simulation.time.timeSinceStart;
this.inPermanent = permanent;
this.hasBuildingInited = false;
this.relativeX -= this.inPermanent.worldPosition.x * 20;
reachedActionGoal = true;
}
}
Citizen.shouldUpdateDraw = true;
break;
case 7:
if(this.currentPathActionTimerXY > 0) {
this.currentPathActionTimerXY += 0.1 * timeMod;
if(this.currentPathActionTimerXY >= 1) {
this.sprite.alpha = 1;
if(this.inPermanent.is(buildings_Misdirector)) {
var resetCanViewSelfInBuilding = true;
if(resetCanViewSelfInBuilding == null) {
resetCanViewSelfInBuilding = true;
}
if(this.recyclePathArray) {
pooling_Int32ArrayPool.returnToPool(this.path);
this.recyclePathArray = false;
}
this.path = null;
this.nextPathPos = -1;
this.pathEnd = -1;
this.currentPathAction = null;
if(resetCanViewSelfInBuilding) {
if(!this.canViewSelfInBuilding) {
this.delayCanViewSelfInBuilding = true;
}
this.canViewSelfInBuilding = true;
}
this.verticalPathProgress = 0;
this.pathEndFunction = null;
this.requestingPathGoal = null;
this.pathOnlyRelatedTo = null;
this.pathWalkSpeed = 1;
this.pathCanBeReconsidered = true;
if(this.sprite.alpha > 0 && this.sprite.alpha < 1) {
this.sprite.alpha = 1;
}
this.waitAndMoveAndWaitRandom(30,45,3,16,120,180,null,false,true);
this.pathCanBeReconsidered = false;
var misdirector = this.inPermanent;
misdirector.giveReward();
} else {
reachedActionGoal = true;
}
} else {
this.sprite.alpha = this.currentPathActionTimerXY;
}
} else {
var x = this.inPermanent.teleportX;
var spd = this.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
var tmp;
if(Math.abs(x - this.relativeX) < spd) {
this.relativeX = x;
tmp = true;
} else {
var num = x - this.relativeX;
this.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
tmp = false;
}
if(tmp) {
this.inPermanent.createTeleportParticle();
this.inPermanent.timesUsed += 1;
if(this.city.misdirector != null && this.city.misdirector.get_misdirectChance() > 0 && random_Random.getFloat() < this.city.misdirector.get_misdirectChance()) {
this.currentPathActionPermanent = this.city.misdirector;
}
var permanent = this.currentPathActionPermanent;
if(this.inPermanent != null) {
this.inPermanent.onCitizenLeave(this,permanent);
}
this.inBuildingSince = this.city.simulation.time.timeSinceStart;
this.inPermanent = permanent;
this.hasBuildingInited = false;
this.inPermanent.timesUsedTo += 1;
this.onWorld = this.currentPathActionPermanent.world;
this.relativeX = this.inPermanent.teleportX;
this.currentPathActionTimerXY = 0.1 * timeMod;
this.sprite.alpha = this.currentPathActionTimerXY;
}
}
Citizen.shouldUpdateDraw = true;
break;
case 8:
var reachedActionGoal1 = this;
reachedActionGoal = (reachedActionGoal1.currentPathActionTimerXY -= timeMod) <= 0.5 * (timeMod - 0.6666666666666666666);
break;
case 9:
var spd = timeMod;
if(Math.abs(this.currentPathActionTimerXY - this.relativeY) < spd) {
this.relativeY = this.currentPathActionTimerXY;
reachedActionGoal = true;
} else {
var num = this.currentPathActionTimerXY - this.relativeY;
this.relativeY += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
}
Citizen.shouldUpdateDraw = true;
break;
case 10:
reachedActionGoal = true;
break;
case 11:
if(this.inPermanent == this.currentPathActionPermanent) {
reachedActionGoal = true;
} else {
var inLandingSite = this.inPermanent;
var destination = this.currentPathActionPermanent;
if(inLandingSite.currentlyLandedSaucer != null && (inLandingSite.currentlyLandedSaucer.destination == destination || inLandingSite.currentlyLandedSaucer.destination.estimatedFlyingDistanceTo(destination) < inLandingSite.estimatedFlyingDistanceTo(destination))) {
var fs = inLandingSite.currentlyLandedSaucer;
fs.addPassenger(this);
this.fullyBeingControlled = true;
this.canViewSelfInBuilding = false;
this.inTransportationThing = fs;
if(inLandingSite.currentlyLandedSaucer.destination != destination) {
if(inLandingSite.estimatedFlyingDistanceTo(destination) < inLandingSite.estimatedFlyingDistanceTo(inLandingSite.currentlyLandedSaucer.destination)) {
var route = this.simulation.flyingPathfinder.findRoute(inLandingSite,destination);
if(route != null) {
fs.setDestination(destination,route);
}
}
}
} else if(inLandingSite.hasFlyingSaucer) {
var route = this.simulation.flyingPathfinder.findRoute(inLandingSite,destination);
if(route != null) {
var fs = new simulation_FlyingSaucer(this.simulation,this.city.farForegroundStage,route,inLandingSite,this.currentPathActionPermanent);
this.simulation.flyingSaucers.push(fs);
fs.addPassenger(this);
this.fullyBeingControlled = true;
this.canViewSelfInBuilding = false;
this.inTransportationThing = fs;
this.inPermanent.removeFlyingSaucer();
var halfWidth = 10. | 0;
this.relativeX = random_Random.getInt(halfWidth - 3,halfWidth + 4);
} else {
if(this.recyclePathArray) {
pooling_Int32ArrayPool.returnToPool(this.path);
this.recyclePathArray = false;
}
this.path = null;
this.nextPathPos = -1;
this.pathEnd = -1;
this.currentPathAction = null;
if(!this.canViewSelfInBuilding) {
this.delayCanViewSelfInBuilding = true;
}
this.canViewSelfInBuilding = true;
this.verticalPathProgress = 0;
this.pathEndFunction = null;
this.requestingPathGoal = null;
this.pathOnlyRelatedTo = null;
this.pathWalkSpeed = 1;
this.pathCanBeReconsidered = true;
if(this.sprite.alpha > 0 && this.sprite.alpha < 1) {
this.sprite.alpha = 1;
}
return;
}
} else {
this.relativeY = -1;
}
}
Citizen.shouldUpdateDraw = true;
break;
case 12:
break;
case 13:
var diff = 20 * (this.currentPathActionPermanent.worldPosition.y - this.inPermanent.worldPosition.y);
if(this.inPermanent == this.currentPathActionPermanent) {
if(this.currentPathActionTimerXY > 3) {
if(this.nextPathPos + 2 < this.pathEnd) {
if(this.path[this.nextPathPos + 2] == 0 || this.path[this.nextPathPos + 2] == 1) {
var x = this.relativeX > 10 ? 18 : 0;
var spd = this.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
var tmp;
if(Math.abs(x - this.relativeX) < spd) {
this.relativeX = x;
tmp = true;
} else {
var num = x - this.relativeX;
this.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
tmp = false;
}
if(tmp) {
reachedActionGoal = true;
}
} else {
reachedActionGoal = true;
}
} else {
reachedActionGoal = true;
}
} else {
this.currentPathActionTimerXY += timeMod;
}
} else if(this.currentPathActionTimerXY > 0) {
if(Math.abs(this.verticalPathProgress) < Math.abs(diff)) {
this.verticalPathProgress += timeMod * 20 * (diff > 0 ? 1 : diff < 0 ? -1 : 0);
this.canViewSelfInBuilding = false;
}
if(Math.abs(this.verticalPathProgress) >= Math.abs(diff)) {
if(this.currentPathActionPermanent.openDoor()) {
var permanent = this.currentPathActionPermanent;
if(this.inPermanent != null) {
this.inPermanent.onCitizenLeave(this,permanent);
}
this.inBuildingSince = this.city.simulation.time.timeSinceStart;
this.inPermanent = permanent;
this.hasBuildingInited = false;
this.inPermanent.timesUsedTo += 1;
this.verticalPathProgress = 0;
this.canViewSelfInBuilding = true;
this.relativeX += random_Random.getInt(-2,3);
}
}
} else {
this.canViewSelfInBuilding = true;
var spd = this.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
var tmp;
if(Math.abs(9. - this.relativeX) < spd) {
this.relativeX = 9.;
tmp = true;
} else {
var num = 9. - this.relativeX;
this.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
tmp = false;
}
if(tmp) {
if(this.inPermanent.openDoor()) {
this.inPermanent.timesUsed += 1;
this.currentPathActionTimerXY = 1;
this.canViewSelfInBuilding = false;
}
}
}
Citizen.shouldUpdateDraw = true;
break;
}
if(reachedActionGoal) {
if(this.nextPathPos + 2 >= this.pathEnd) {
var pathEnd = _gthis.pathEndFunction;
var resetCanViewSelfInBuilding = true;
if(resetCanViewSelfInBuilding == null) {
resetCanViewSelfInBuilding = true;
}
if(_gthis.recyclePathArray) {
pooling_Int32ArrayPool.returnToPool(_gthis.path);
_gthis.recyclePathArray = false;
}
_gthis.path = null;
_gthis.nextPathPos = -1;
_gthis.pathEnd = -1;
_gthis.currentPathAction = null;
if(resetCanViewSelfInBuilding) {
if(!_gthis.canViewSelfInBuilding) {
_gthis.delayCanViewSelfInBuilding = true;
}
_gthis.canViewSelfInBuilding = true;
}
_gthis.verticalPathProgress = 0;
_gthis.pathEndFunction = null;
_gthis.requestingPathGoal = null;
_gthis.pathOnlyRelatedTo = null;
_gthis.pathWalkSpeed = 1;
_gthis.pathCanBeReconsidered = true;
if(_gthis.sprite.alpha > 0 && _gthis.sprite.alpha < 1) {
_gthis.sprite.alpha = 1;
}
if(pathEnd != null) {
pathEnd();
}
} else {
this.nextPathPos += 2;
this.currentPathAction = null;
if(this.path[this.nextPathPos] == 13) {
while(this.nextPathPos + 2 < this.pathEnd && this.path[this.nextPathPos + 2] == 13) this.nextPathPos += 2;
}
if(this.path[this.nextPathPos] == 10) {
if(this.nextPathPos + 2 >= this.pathEnd) {
var pathEnd = _gthis.pathEndFunction;
var resetCanViewSelfInBuilding = true;
if(resetCanViewSelfInBuilding == null) {
resetCanViewSelfInBuilding = true;
}
if(_gthis.recyclePathArray) {
pooling_Int32ArrayPool.returnToPool(_gthis.path);
_gthis.recyclePathArray = false;
}
_gthis.path = null;
_gthis.nextPathPos = -1;
_gthis.pathEnd = -1;
_gthis.currentPathAction = null;
if(resetCanViewSelfInBuilding) {
if(!_gthis.canViewSelfInBuilding) {
_gthis.delayCanViewSelfInBuilding = true;
}
_gthis.canViewSelfInBuilding = true;
}
_gthis.verticalPathProgress = 0;
_gthis.pathEndFunction = null;
_gthis.requestingPathGoal = null;
_gthis.pathOnlyRelatedTo = null;
_gthis.pathWalkSpeed = 1;
_gthis.pathCanBeReconsidered = true;
if(_gthis.sprite.alpha > 0 && _gthis.sprite.alpha < 1) {
_gthis.sprite.alpha = 1;
}
if(pathEnd != null) {
pathEnd();
}
} else {
this.canViewSelfInBuilding = true;
this.nextPathPos += 2;
}
}
}
Citizen.shouldUpdateDraw = true;
}
}
}
,leavePermanent: function(timeMod) {
if(this.inPermanent != null && this.inPermanent.isBuilding) {
var x = (this.inPermanent != null && this.inPermanent.isBuilding ? this.inPermanent : null).doorX;
var spd = this.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
var tmp;
if(Math.abs(x - this.relativeX) < spd) {
this.relativeX = x;
tmp = true;
} else {
var num = x - this.relativeX;
this.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
tmp = false;
}
if(tmp) {
if(this.inPermanent != null && this.inPermanent.isBuilding) {
var building = this.inPermanent != null && this.inPermanent.isBuilding ? this.inPermanent : null;
this.relativeX = building.worldPosition.x * 20 + building.doorX;
} else {
this.relativeX += this.inPermanent.worldPosition.x * 20;
}
if(this.inPermanent != null) {
this.inPermanent.onCitizenLeave(this,null);
}
this.inBuildingSince = this.city.simulation.time.timeSinceStart;
this.set_drawOnStage(this.foregroundStage);
this.inPermanent = null;
this.relativeY = 0;
Citizen.shouldUpdateDraw = true;
}
} else {
if(this.inPermanent != null && this.inPermanent.isBuilding) {
var building = this.inPermanent != null && this.inPermanent.isBuilding ? this.inPermanent : null;
this.relativeX = building.worldPosition.x * 20 + building.doorX;
} else {
this.relativeX += this.inPermanent.worldPosition.x * 20;
}
if(this.inPermanent != null) {
this.inPermanent.onCitizenLeave(this,null);
}
this.inBuildingSince = this.city.simulation.time.timeSinceStart;
this.set_drawOnStage(this.foregroundStage);
this.inPermanent = null;
this.relativeY = 0;
Citizen.shouldUpdateDraw = true;
}
}
,instantLeavePermanent: function() {
if(this.inPermanent != null && this.inPermanent.isBuilding) {
var building = this.inPermanent != null && this.inPermanent.isBuilding ? this.inPermanent : null;
this.relativeX = building.worldPosition.x * 20 + building.doorX;
} else {
this.relativeX += this.inPermanent.worldPosition.x * 20;
}
if(this.inPermanent != null) {
this.inPermanent.onCitizenLeave(this,null);
}
this.inBuildingSince = this.city.simulation.time.timeSinceStart;
this.set_drawOnStage(this.foregroundStage);
this.inPermanent = null;
this.relativeY = 0;
Citizen.shouldUpdateDraw = true;
}
,moveTowardsX: function(x,timeMod) {
var spd = this.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
if(Math.abs(x - this.relativeX) < spd) {
this.relativeX = x;
return true;
} else {
var num = x - this.relativeX;
this.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
return false;
}
}
,setRelativePos: function(x,y) {
if(x != this.relativeX || y != this.relativeY) {
this.relativeX = x;
this.relativeY = y;
Citizen.shouldUpdateDraw = true;
}
}
,setRelativeY: function(y) {
this.relativeY = y;
Citizen.shouldUpdateDraw = true;
}
,setRelativeX: function(x) {
this.relativeX = x;
Citizen.shouldUpdateDraw = true;
}
,wait: function(time,then) {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = time;
this.setPath(arr,0,2,true);
this.pathEndFunction = then;
this.pathOnlyRelatedTo = this.inPermanent;
}
,waitRandom: function(timeMin,timeMax,then) {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = random_Random.getInt(timeMin,timeMax);
this.setPath(arr,0,2,true);
this.pathEndFunction = then;
this.pathOnlyRelatedTo = this.inPermanent;
}
,wander: function(timeMod) {
if(this.inPermanent == null) {
var val2 = (this.relativeX | 0) - 100;
var val1 = (this.relativeX | 0) + 100;
var val21 = this.onWorld.rect.width - 2;
this.moveAndWait(random_Random.getInt(val2 > 0 ? val2 : 0,val21 < val1 ? val21 : val1),random_Random.getInt(30,60),null,false,false);
} else {
this.goDownTowardsWorldSurface(timeMod);
}
}
,goDownTowardsWorldSurface: function(timeMod) {
if(this.inPermanent.worldPosition.y == 0) {
if(this.inPermanent != null && this.inPermanent.isBuilding) {
var x = (this.inPermanent != null && this.inPermanent.isBuilding ? this.inPermanent : null).doorX;
var spd = this.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
var tmp;
if(Math.abs(x - this.relativeX) < spd) {
this.relativeX = x;
tmp = true;
} else {
var num = x - this.relativeX;
this.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
tmp = false;
}
if(tmp) {
if(this.inPermanent != null && this.inPermanent.isBuilding) {
var building = this.inPermanent != null && this.inPermanent.isBuilding ? this.inPermanent : null;
this.relativeX = building.worldPosition.x * 20 + building.doorX;
} else {
this.relativeX += this.inPermanent.worldPosition.x * 20;
}
if(this.inPermanent != null) {
this.inPermanent.onCitizenLeave(this,null);
}
this.inBuildingSince = this.city.simulation.time.timeSinceStart;
this.set_drawOnStage(this.foregroundStage);
this.inPermanent = null;
this.relativeY = 0;
Citizen.shouldUpdateDraw = true;
}
} else {
if(this.inPermanent != null && this.inPermanent.isBuilding) {
var building = this.inPermanent != null && this.inPermanent.isBuilding ? this.inPermanent : null;
this.relativeX = building.worldPosition.x * 20 + building.doorX;
} else {
this.relativeX += this.inPermanent.worldPosition.x * 20;
}
if(this.inPermanent != null) {
this.inPermanent.onCitizenLeave(this,null);
}
this.inBuildingSince = this.city.simulation.time.timeSinceStart;
this.set_drawOnStage(this.foregroundStage);
this.inPermanent = null;
this.relativeY = 0;
Citizen.shouldUpdateDraw = true;
}
} else {
var perm = this.inPermanent != null && this.inPermanent.isBuilding ? this.inPermanent : null;
var arr = [];
while(perm.worldPosition.y != 0) {
if(perm.bottomBuilding == null) {
var lb = perm.leftBuilding;
while(lb != null) lb = lb.leftBuilding;
if(lb != null) {
arr.push(2);
arr.push(0);
perm = perm.leftBuilding;
} else if(perm.rightBuilding != null) {
arr.push(3);
arr.push(0);
perm = perm.rightBuilding;
}
}
if(perm.bottomBuilding != null) {
arr.push(1);
arr.push(0);
perm = perm.bottomBuilding;
} else {
break;
}
}
if(arr.length > 0) {
this.setPath(new Int32Array(arr),0,arr.length);
}
}
}
,move: function(x,then,slowMove) {
if(slowMove == null) {
slowMove = false;
}
if(slowMove) {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[4].length > 0 ? pool[4].splice(pool[4].length - 1,1)[0] : new Int32Array(4);
arr[0] = 12;
arr[1] = 50;
arr[2] = 4;
arr[3] = x;
this.setPath(arr,0,4,true);
} else {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = x;
this.setPath(arr,0,2,true);
}
this.pathEndFunction = then;
this.pathOnlyRelatedTo = this.inPermanent;
}
,moveRandom: function(xMin,xMax,then,slowMove) {
if(slowMove == null) {
slowMove = false;
}
var moveToX = random_Random.getInt(xMin,xMax);
if(slowMove) {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[4].length > 0 ? pool[4].splice(pool[4].length - 1,1)[0] : new Int32Array(4);
arr[0] = 12;
arr[1] = 50;
arr[2] = 4;
arr[3] = moveToX;
this.setPath(arr,0,4,true);
} else {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = moveToX;
this.setPath(arr,0,2,true);
}
this.pathEndFunction = then;
this.pathOnlyRelatedTo = this.inPermanent;
}
,moveTowardsRandomInWorldCoords: function(xMin,xMax,then) {
var moveToX = random_Random.getInt(xMin,xMax);
if(this.inPermanent != null) {
var moveDiff = moveToX - this.relativeX - this.inPermanent.position.x;
if(moveDiff < -this.relativeX) {
if((this.inPermanent != null && this.inPermanent.isBuilding ? this.inPermanent : null).leftBuilding != null) {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[4].length > 0 ? pool[4].splice(pool[4].length - 1,1)[0] : new Int32Array(4);
arr[0] = 2;
arr[1] = 0;
arr[2] = 4;
arr[3] = 18;
this.setPath(arr,0,4,true);
} else {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = 0;
this.setPath(arr,0,2,true);
this.pathEndFunction = null;
this.pathOnlyRelatedTo = this.inPermanent;
}
} else if(moveDiff >= 20 - this.relativeX) {
if((this.inPermanent != null && this.inPermanent.isBuilding ? this.inPermanent : null).rightBuilding != null) {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[4].length > 0 ? pool[4].splice(pool[4].length - 1,1)[0] : new Int32Array(4);
arr[0] = 3;
arr[1] = 0;
arr[2] = 4;
arr[3] = 0;
this.setPath(arr,0,4,true);
} else {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = 18;
this.setPath(arr,0,2,true);
this.pathEndFunction = null;
this.pathOnlyRelatedTo = this.inPermanent;
}
} else {
var x = Math.floor(moveDiff + this.relativeX);
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = x;
this.setPath(arr,0,2,true);
this.pathEndFunction = null;
this.pathOnlyRelatedTo = this.inPermanent;
}
this.pathEndFunction = then;
} else {
var moveToX = random_Random.getInt(xMin - this.onWorld.rect.x,xMax - this.onWorld.rect.x);
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = moveToX;
this.setPath(arr,0,2,true);
this.pathEndFunction = then;
this.pathOnlyRelatedTo = this.inPermanent;
}
}
,moveAndWaitRandom: function(xMin,xMax,timeMin,timeMax,then,modifyWithHappiness,slowMove) {
if(slowMove == null) {
slowMove = false;
}
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
this.moveAndWait(random_Random.getInt(xMin,xMax),random_Random.getInt(timeMin,timeMax),then,modifyWithHappiness,slowMove);
}
,moveAndWait: function(x,time,then,modifyWithHappiness,slowMove) {
if(slowMove == null) {
slowMove = false;
}
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
if(modifyWithHappiness) {
time = time / this.simulation.happiness.actionSpeedModifier | 0;
}
if(slowMove) {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[6].length > 0 ? pool[6].splice(pool[6].length - 1,1)[0] : new Int32Array(6);
arr[0] = 12;
arr[1] = 50;
arr[2] = 4;
arr[3] = x;
arr[4] = 8;
arr[5] = time;
this.setPath(arr,0,6,true);
} else {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[4].length > 0 ? pool[4].splice(pool[4].length - 1,1)[0] : new Int32Array(4);
arr[0] = 4;
arr[1] = x;
arr[2] = 8;
arr[3] = time;
this.setPath(arr,0,4,true);
}
this.pathEndFunction = then;
this.pathOnlyRelatedTo = this.inPermanent;
}
,waitAndMoveAndWaitRandom: function(timeMin1,timeMin2,xMin,xMax,timeMin,timeMax,then,modifyWithHappiness,slowMove) {
if(slowMove == null) {
slowMove = false;
}
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
var time1 = random_Random.getInt(timeMin1,timeMin2);
var time2 = random_Random.getInt(timeMin,timeMax);
var x = random_Random.getInt(xMin,xMax);
if(modifyWithHappiness) {
time1 = time1 / this.simulation.happiness.actionSpeedModifier | 0;
time2 = time2 / this.simulation.happiness.actionSpeedModifier | 0;
}
if(slowMove) {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[8].length > 0 ? pool[8].splice(pool[8].length - 1,1)[0] : new Int32Array(8);
arr[0] = 8;
arr[1] = time1;
arr[2] = 12;
arr[3] = 50;
arr[4] = 4;
arr[5] = x;
arr[6] = 8;
arr[7] = time2;
this.setPath(arr,0,8,true);
} else {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[6].length > 0 ? pool[6].splice(pool[6].length - 1,1)[0] : new Int32Array(6);
arr[0] = 8;
arr[1] = time1;
arr[2] = 4;
arr[3] = x;
arr[4] = 8;
arr[5] = time2;
this.setPath(arr,0,6,true);
}
this.pathEndFunction = then;
this.pathOnlyRelatedTo = this.inPermanent;
}
,changeFloorAndMoveRandom: function(xMin,xMax,then) {
var yTo = this.isAtGroundLevel() ? 10 : 0;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[4].length > 0 ? pool[4].splice(pool[4].length - 1,1)[0] : new Int32Array(4);
arr[0] = 9;
arr[1] = yTo;
arr[2] = 4;
arr[3] = random_Random.getInt(xMin,xMax);
this.setPath(arr,0,4,true);
this.pathEndFunction = then;
this.pathOnlyRelatedTo = this.inPermanent;
}
,isAtGroundLevel: function() {
return this.relativeY < 5;
}
,isAtBottomFloor: function() {
return this.relativeY < 5;
}
,changeFloor: function(then) {
var yTo = this.isAtGroundLevel() ? 10 : 0;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 9;
arr[1] = yTo;
this.setPath(arr,0,2,true);
this.pathEndFunction = then;
this.pathOnlyRelatedTo = this.inPermanent;
}
,changeFloorAndWait: function(waitTime,then) {
var yTo = this.relativeY == 0 ? 10 : 0;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[4].length > 0 ? pool[4].splice(pool[4].length - 1,1)[0] : new Int32Array(4);
arr[0] = 9;
arr[1] = yTo;
arr[2] = 8;
arr[3] = waitTime;
this.setPath(arr,0,4,true);
this.pathEndFunction = then;
this.pathOnlyRelatedTo = this.inPermanent;
}
,changeFloorAndWaitRandom: function(minTime,maxTime,then) {
var yTo = this.relativeY == 0 ? 10 : 0;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[4].length > 0 ? pool[4].splice(pool[4].length - 1,1)[0] : new Int32Array(4);
arr[0] = 9;
arr[1] = yTo;
arr[2] = 8;
arr[3] = random_Random.getInt(minTime,maxTime);
this.setPath(arr,0,4,true);
this.pathEndFunction = then;
this.pathOnlyRelatedTo = this.inPermanent;
}
,resetPath: function(resetCanViewSelfInBuilding) {
if(resetCanViewSelfInBuilding == null) {
resetCanViewSelfInBuilding = true;
}
if(this.recyclePathArray) {
pooling_Int32ArrayPool.returnToPool(this.path);
this.recyclePathArray = false;
}
this.path = null;
this.nextPathPos = -1;
this.pathEnd = -1;
this.currentPathAction = null;
if(resetCanViewSelfInBuilding) {
if(!this.canViewSelfInBuilding) {
this.delayCanViewSelfInBuilding = true;
}
this.canViewSelfInBuilding = true;
}
this.verticalPathProgress = 0;
this.pathEndFunction = null;
this.requestingPathGoal = null;
this.pathOnlyRelatedTo = null;
this.pathWalkSpeed = 1;
this.pathCanBeReconsidered = true;
if(this.sprite.alpha > 0 && this.sprite.alpha < 1) {
this.sprite.alpha = 1;
}
}
,swapRemoveFromStage: function() {
var currentLastSprite = this.addedToStage.children[this.addedToStage.children.length - 1];
this.addedToStage.children[this.stageChildIndex] = currentLastSprite;
Citizen.spriteCitizens.h[currentLastSprite.__id__].stageChildIndex = this.stageChildIndex;
this.addedToStage.children[this.addedToStage.children.length - 1] = this.sprite;
this.addedToStage.removeChildAt(this.addedToStage.children.length - 1);
}
,actuallyUpdateDraw: function() {
if(this.inPermanent != null) {
this.sprite.position.x = this.inPermanent.position.x + this.relativeX;
if(this.inPermanent != null && this.inPermanent.isBuilding) {
if(this.sprite.alpha == 0 || this.sprite.alpha == 1) {
this.sprite.alpha = this.canViewSelfInBuilding && !this.delayCanViewSelfInBuilding ? 1 : 0;
}
this.sprite.position.y = this.inPermanent.position.y + 20 - this.relativeY - 1;
} else {
this.sprite.position.y = this.inPermanent.position.y + 20 - this.relativeY;
}
} else {
this.sprite.position.x = this.onWorld.rect.x + this.relativeX;
this.sprite.position.y = this.onWorld.rect.y - this.relativeY;
}
this.updateCull();
}
,uncull: function() {
if(this.addedToStage == null && this.drawOnStage != null) {
this.stageChildIndex = this.drawOnStage.children.length;
this.drawOnStage.addChild(this.sprite);
this.addedToStage = this.drawOnStage;
}
}
,updateCull: function() {
var newStage;
if(this.sprite.x >= this.city.cityCullX && this.sprite.y >= this.city.cityCullY && this.sprite.x < this.city.cityCullX2 && this.sprite.y < this.city.cityCullY2) {
newStage = this.drawOnStage;
} else {
newStage = null;
}
if(newStage != this.addedToStage) {
if(this.addedToStage != null) {
this.swapRemoveFromStage();
}
if(newStage != null) {
this.stageChildIndex = newStage.children.length;
newStage.addChild(this.sprite);
}
this.addedToStage = newStage;
}
}
,addToOnWorldStage: function() {
this.set_drawOnStage(this.foregroundStage);
}
,addToWithAccessoryStage: function() {
this.set_drawOnStage(this.inBuildingStageNonParticle);
}
,addToCorrectStage: function() {
this.set_drawOnStage(this.inPermanent != null && this.inPermanent.isBuilding ? this.accessorySprite != null ? this.inBuildingStageNonParticle : this.inBuildingStage : this.foregroundStage);
}
,findPath: function(goal,onFail) {
this.simulation.pathfinder.findPath(this,goal);
this.pathOnFail = onFail;
}
,setPath: function(path,pathStartPos,pathLength,recyclePathArray) {
if(recyclePathArray == null) {
recyclePathArray = false;
}
if(this.path != null) {
console.log("FloatingSpaceCities/Citizen.hx:1386:","overwriting path");
console.log("FloatingSpaceCities/Citizen.hx:1386:",this);
}
if(path[pathStartPos] == -1) {
this.isRequestingPath = false;
if(this.requestingPathGoal == this.home) {
this.evictFromHome();
} else if(this.requestingPathGoal == this.job) {
this.loseJob();
} else if(this.requestingPathGoal == this.school) {
this.leaveSchool();
}
if(this.pathOnFail != null) {
this.pathOnFail();
}
var resetCanViewSelfInBuilding = false;
if(resetCanViewSelfInBuilding == null) {
resetCanViewSelfInBuilding = true;
}
if(this.recyclePathArray) {
pooling_Int32ArrayPool.returnToPool(this.path);
this.recyclePathArray = false;
}
this.path = null;
this.nextPathPos = -1;
this.pathEnd = -1;
this.currentPathAction = null;
if(resetCanViewSelfInBuilding) {
if(!this.canViewSelfInBuilding) {
this.delayCanViewSelfInBuilding = true;
}
this.canViewSelfInBuilding = true;
}
this.verticalPathProgress = 0;
this.pathEndFunction = null;
this.requestingPathGoal = null;
this.pathOnlyRelatedTo = null;
this.pathWalkSpeed = 1;
this.pathCanBeReconsidered = true;
if(this.sprite.alpha > 0 && this.sprite.alpha < 1) {
this.sprite.alpha = 1;
}
return;
}
this.pathDestination = this.requestingPathGoal;
var resetCanViewSelfInBuilding = false;
if(resetCanViewSelfInBuilding == null) {
resetCanViewSelfInBuilding = true;
}
if(this.recyclePathArray) {
pooling_Int32ArrayPool.returnToPool(this.path);
this.recyclePathArray = false;
}
this.path = null;
this.nextPathPos = -1;
this.pathEnd = -1;
this.currentPathAction = null;
if(resetCanViewSelfInBuilding) {
if(!this.canViewSelfInBuilding) {
this.delayCanViewSelfInBuilding = true;
}
this.canViewSelfInBuilding = true;
}
this.verticalPathProgress = 0;
this.pathEndFunction = null;
this.requestingPathGoal = null;
this.pathOnlyRelatedTo = null;
this.pathWalkSpeed = 1;
this.pathCanBeReconsidered = true;
if(this.sprite.alpha > 0 && this.sprite.alpha < 1) {
this.sprite.alpha = 1;
}
if(pathLength != 0) {
this.path = path;
this.nextPathPos = pathStartPos;
this.pathEnd = pathStartPos + pathLength;
}
this.isRequestingPath = false;
this.recyclePathArray = recyclePathArray;
}
,setPathWithEnd: function(path,pathStartPos,pathLength,then,recyclePathArray) {
if(recyclePathArray == null) {
recyclePathArray = false;
}
this.setPath(path,pathStartPos,pathLength,recyclePathArray);
this.pathEndFunction = then;
}
,setCurrentTexture: function() {
var tmp = this.get_age() < 16 ? this.childrenTextures[this.spriteIndexActual] : this.adultTextures[this.spriteIndexActual];
this.sprite.texture = tmp;
this.actualSpriteHeight = this.get_age() < 16 ? 4 : this.spriteIndexActual == 6 || this.spriteIndexActual == 12 || this.spriteIndexActual == 16 || this.spriteIndexActual == 20 || this.spriteIndexActual == 26 ? 4 : 5;
}
,load: function(queue,definition) {
this.loadBasics(queue,definition);
this.nameIndex = this.spriteIndex >> 14;
this.spriteIndexActual = this.spriteIndex - (this.nameIndex << 14);
if(this.nameIndex == 0) {
this.nameIndex = random_Random.getInt(1,8000);
}
this.likesNightclubs = this.spriteIndex % 5 == 0 ? false : true;
this.setCurrentTexture();
}
,afterLoadingInPermanent: function() {
this.addToCorrectStage();
if(this.school == null && this.currentAction == LifeAction.School) {
this.currentAction = LifeAction.Nothing;
}
}
,goToPermanent: function(permanent) {
if(this.inPermanent != null) {
this.inPermanent.onCitizenLeave(this,permanent);
}
this.inBuildingSince = this.city.simulation.time.timeSinceStart;
this.inPermanent = permanent;
this.hasBuildingInited = false;
}
,goToPermanentLocal: function(permanent) {
this.inPermanent = permanent;
}
,educate: function(amount,cap) {
this.educationLevel = Math.max(Math.min(this.educationLevel + amount,cap),this.educationLevel);
}
,getCityPosition: function() {
var returnPoint = new common_FPoint(0,0);
if(this.fullyBeingControlled && this.inTransportationThing != null) {
returnPoint = new common_FPoint(this.inTransportationThing.position.x + 9,this.inTransportationThing.position.y + 16);
} else if(this.inPermanent != null) {
returnPoint.x = this.inPermanent.position.x + this.relativeX;
if((this.inPermanent != null && this.inPermanent.isBuilding ? this.inPermanent : null) != null) {
returnPoint.y = this.inPermanent.position.y + 20 - this.relativeY - 1;
} else {
returnPoint.y = this.inPermanent.position.y + 20 - this.relativeY;
}
} else {
var _this = this.onWorld.rect;
var _this_x = _this.x;
var _this_y = _this.y;
var _this_x1 = _this_x;
var _this_y1 = _this_y;
var otherPoint_x = this.relativeX;
var otherPoint_y = -this.relativeY;
returnPoint = new common_FPoint(_this_x1 + otherPoint_x,_this_y1 + otherPoint_y);
}
if(this.path != null) {
if(this.currentPathAction == 0) {
returnPoint.y -= this.verticalPathProgress;
} else if(this.currentPathAction == 1) {
returnPoint.y += this.verticalPathProgress;
}
}
return returnPoint;
}
,onClick: function() {
gui_FollowingCitizen.createWindow(this.city,this);
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
if(shouldSaveDefinition) {
queue.addString(Citizen.saveDefinition);
}
var value = this.hasBuildingInited;
if(queue.size + 1 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 1) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.b[queue.size] = value ? 1 : 0;
queue.size += 1;
var value = this.spriteIndex;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.relativeX;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.bornOn;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.actualWorkTimePreference;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var e = this.currentAction;
queue.addString($hxEnums[e.__enum__].__constructs__[e._hx_index]);
var value = this.hasWorkTools;
if(queue.size + 1 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 1) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.b[queue.size] = value ? 1 : 0;
queue.size += 1;
var value = this.lastInfrequentUpdateAge;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.dieAgeModifier;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.educationLevel;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
}
,loadBasics: function(queue,definition) {
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"hasBuildingInited")) {
this.hasBuildingInited = loadMap.h["hasBuildingInited"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"spriteIndex")) {
this.spriteIndex = loadMap.h["spriteIndex"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"relativeX")) {
this.relativeX = loadMap.h["relativeX"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"bornOn")) {
this.bornOn = loadMap.h["bornOn"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"actualWorkTimePreference")) {
this.actualWorkTimePreference = loadMap.h["actualWorkTimePreference"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"currentAction")) {
this.currentAction = loadMap.h["currentAction"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"hasWorkTools")) {
this.hasWorkTools = loadMap.h["hasWorkTools"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"lastInfrequentUpdateAge")) {
this.lastInfrequentUpdateAge = loadMap.h["lastInfrequentUpdateAge"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"dieAgeModifier")) {
this.dieAgeModifier = loadMap.h["dieAgeModifier"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"educationLevel")) {
this.educationLevel = loadMap.h["educationLevel"];
}
this.postLoad();
}
,__class__: Citizen
};
var GameState = function() { };
$hxClasses["GameState"] = GameState;
GameState.__name__ = "GameState";
GameState.__isInterface__ = true;
GameState.prototype = {
__class__: GameState
};
var City = function(game,stage,storyName,displayOnly,cityFile) {
if(cityFile == null) {
cityFile = "fpc_save";
}
if(displayOnly == null) {
displayOnly = false;
}
this.cityName = "";
this.previousCullRectangle = null;
this.permanentNumberCached = null;
this.updateConnectedBuildingSprites = false;
this.isLoserState = false;
this.skyColor = 0;
this.saveRawDataToReuse = null;
this.currentlySaving = false;
this.secondsSinceAutoSave = 0.0;
this.simulationSpeed = 1.0;
this.windowRelatedOnBuildOrDestroy = null;
this.zoomScale = 2;
this.fixViewBottomYOn = null;
this.specialAction = null;
this.postCreateBuilder = null;
this.misdirector = null;
this.maxPermanentID = 0;
this.worlds = [];
this.hoverHighlightSetThisStep = false;
this.cityCullX = 0;
this.cityCullY = 0;
this.cityCullX2 = 1;
this.cityCullY2 = 1;
this.zoomScale = Math.max(game.scaling,this.zoomScale);
this.game = game;
this.outerStage = stage;
this.displayOnly = displayOnly;
this.cityFile = cityFile;
this.buildingMode = BuildingMode.Normal;
this.materials = new Materials();
this.permanentsByID = new haxe_ds_IntMap();
this.permanents = [];
this.workBuildings = [];
this.upgrades = new cityUpgrades_CityUpgrades(this);
this.policies = new policies_Policies(this);
this.teleporters = [];
this.landingSites = [];
this.connections = new simulation_CityConnections(this);
this.progress = new progress_GameProgress(this,storyName);
this.progress.init();
this.viewPos = new common_FPoint(225,150);
this.cityView = new CityView(this);
this.sky = new PIXI.Graphics();
this.updateSky(0);
this.outerStage.addChild(this.sky);
this.starStage = new PIXI.Container();
this.outerStage.addChild(this.starStage);
this.stars = new graphics_Stars(this.starStage,this);
this.movingViewStage = new PIXI.Container();
this.outerStage.addChild(this.movingViewStage);
this.movingViewStage.position.set(game.addX,game.addY);
this.mainMovingViewStage = new PIXI.Container();
this.movingViewStage.addChild(this.mainMovingViewStage);
this.cityBgStage = new graphics_CachingContainer(new common_Rectangle(-1024,-1024,2048,2048));
this.mainMovingViewStage.addChild(this.cityBgStage);
if(this.get_usingParticleContainers()) {
this.citizenInBuildingStage = new PIXI.Container();
} else {
this.citizenInBuildingStage = new PIXI.particles.ParticleContainer(10000,{ position : true, alpha : true, uvs : true, scale : false});
}
this.mainMovingViewStage.addChild(this.citizenInBuildingStage);
this.citizenInBuildingStageNonParticle = new PIXI.Container();
this.mainMovingViewStage.addChild(this.citizenInBuildingStageNonParticle);
this.aboveCitizensInBuildingStage = new PIXI.Container();
this.mainMovingViewStage.addChild(this.aboveCitizensInBuildingStage);
var particleStage = new PIXI.Container();
this.mainMovingViewStage.addChild(particleStage);
this.particles = new graphics_Particles(particleStage);
this.cityMidStage = new graphics_CachingContainer(new common_Rectangle(-1024,-1024,2048,2048));
this.mainMovingViewStage.addChild(this.cityMidStage);
this.cityStage = new graphics_CachingContainer(new common_Rectangle(-1024,-1024,2048,2048));
this.mainMovingViewStage.addChild(this.cityStage);
this.justAboveCityStage = new PIXI.Container();
this.mainMovingViewStage.addChild(this.justAboveCityStage);
this.builderStage = new PIXI.Container();
this.mainMovingViewStage.addChild(this.builderStage);
if(this.get_usingParticleContainers()) {
this.citizenForegroundStage = new PIXI.Container();
} else {
this.citizenForegroundStage = new PIXI.particles.ParticleContainer(5000,{ position : true, uvs : true, scale : false});
}
this.mainMovingViewStage.addChild(this.citizenForegroundStage);
this.farForegroundStage = new PIXI.Container();
this.mainMovingViewStage.addChild(this.farForegroundStage);
this.furtherForegroundStage = new PIXI.Container();
this.mainMovingViewStage.addChild(this.furtherForegroundStage);
this.builderHighlightStage = new PIXI.Container();
this.furtherForegroundStage.addChild(this.builderHighlightStage);
this.hoverHighlightStage = new PIXI.Container();
this.furtherForegroundStage.addChild(this.hoverHighlightStage);
this.hoverHighlightStage2 = new PIXI.Container();
this.furtherForegroundStage.addChild(this.hoverHighlightStage2);
this.furtherForegroundTempStage = new PIXI.Container();
this.furtherForegroundStage.addChild(this.furtherForegroundTempStage);
this.simulation = new CitySimulation(this,this.citizenForegroundStage,this.citizenInBuildingStage,this.citizenInBuildingStageNonParticle);
this.guiStage = new PIXI.Container();
if(displayOnly) {
this.guiStage.visible = false;
}
this.outerStage.addChild(this.guiStage);
this.gui = new gui_CityGUI(game,this.guiStage,this);
this.set_pauseGame(false);
if(!Game.isLoading) {
this.progress.story.makeWorlds(game,this.cityStage,this.cityMidStage,this.cityBgStage);
this.createBottomWorld();
this.progress.story.start();
this.updateDrawCachingRectSize();
}
if(!Game.isLoading) {
this.connections.updateCityConnections();
this.simulation.pathfinder.sendPathfindingInfo();
}
worldResources_AlienRuins.alreadyFoundBonuses = [];
this.simulation.time.updateSky();
this.secondsSinceAutoSave = 0;
this.resize();
if(Config.enableCheats) {
window.cheatMaterials = $bind(this,this.cheatMaterials);
window.cheatPeople = $bind(this,this.cheatPeople);
window.cheatUnlocks = $bind(this,this.cheatUnlocks);
window.cheatSpeed = function() {
Config.cheatSpeedEnabled = true;
};
window.cheatMaterialsZero = $bind(this,this.cheatMaterialsZero);
window.cheatFood = $bind(this,this.cheatFood);
window.cheatWood = $bind(this,this.cheatWood);
}
this.viewActions = new cityActions_ViewActions(this);
};
$hxClasses["City"] = City;
City.__name__ = "City";
City.__interfaces__ = [GameState];
City.prototype = {
get_publicGUI: function() {
return this.gui;
}
,get_displayWidth: function() {
return Math.floor(this.game.rect.width * this.game.scaling / this.zoomScale);
}
,get_displayHeight: function() {
return Math.floor(this.game.rect.height * this.game.scaling / this.zoomScale);
}
,set_pauseGame: function(val) {
this.pauseGame = val;
this.gui.pausedForWindow = false;
return this.pauseGame;
}
,get_usingParticleContainers: function() {
return !this.game.isMobile;
}
,enableDisplayOnly: function() {
this.displayOnly = true;
}
,disableDisplayOnlyMode: function(newSaveFile) {
this.displayOnly = false;
this.guiStage.visible = true;
if(newSaveFile != null) {
this.cityFile = newSaveFile;
}
}
,setHoverHightlight: function(forThesePermanents,outlineColor) {
var ind = 0;
var ind2 = 0;
if(this.hoverHighlightSetThisStep) {
ind = this.hoverHighlightStage.children.length;
ind2 = this.hoverHighlightStage2.children.length;
}
var _g = 0;
var _g1 = this.permanents;
while(_g < _g1.length) {
var pm = _g1[_g];
++_g;
var desiredTexture = forThesePermanents(pm);
if(desiredTexture != null) {
if(ind >= this.hoverHighlightStage.children.length) {
this.hoverHighlightStage.addChild(new PIXI.Sprite());
}
var thisSprite = this.hoverHighlightStage.children[ind];
thisSprite.position.set(pm.position.x - 1,pm.position.y - 1);
thisSprite.texture = desiredTexture;
thisSprite.alpha = 0.5 + (Math.sin(this.gui.guiTimer / 10) + 1) / 4;
++ind;
if(ind2 >= this.hoverHighlightStage2.children.length) {
this.hoverHighlightStage2.addChild(new PIXI.Sprite());
}
var thisSprite1 = this.hoverHighlightStage2.children[ind2];
thisSprite1.position.set(pm.position.x - 1,pm.position.y - 1);
thisSprite1.texture = Resources.getTexture("spr_whiteoutline");
thisSprite1.tint = outlineColor;
thisSprite1.alpha = 1;
++ind2;
}
}
if(ind < this.hoverHighlightStage.children.length) {
this.hoverHighlightStage.removeChildren(ind);
}
if(ind2 < this.hoverHighlightStage2.children.length) {
this.hoverHighlightStage2.removeChildren(ind2);
}
this.hoverHighlightSetThisStep = true;
}
,updateDrawCachingRectSize: function() {
var cacheRect = new common_Rectangle(0,0,1024,1024);
if(this.worlds.length > 0) {
cacheRect = new common_Rectangle(common_ArrayExtensions.min(this.worlds,function(w) {
return w.rect.x;
}).rect.x,common_ArrayExtensions.max(this.worlds,function(w) {
return w.rect.get_y2();
}).rect.get_y2() - 2040,2046,2046);
}
this.cityStage.cacheWithinRect = cacheRect;
this.cityBgStage.cacheWithinRect = cacheRect;
this.cityMidStage.cacheWithinRect = cacheRect;
}
,stop: function() {
if(!this.displayOnly) {
this.saveToBrowserStorage();
}
this.simulation.stop();
var _g = 0;
var _g1 = this.worlds;
while(_g < _g1.length) {
var w = _g1[_g];
++_g;
w.cleanup();
}
this.cityStage.removeCache();
this.cityBgStage.removeCache();
this.cityMidStage.removeCache();
}
,pause: function() {
if(!this.pauseGame) {
this.pausedForUnfocused = true;
this.set_pauseGame(true);
}
}
,resume: function() {
if(this.pauseGame && this.pausedForUnfocused) {
this.pausedForUnfocused = false;
this.set_pauseGame(false);
}
}
,handleMouse: function(mouse) {
if(this.progress.handleMouse(mouse)) {
return true;
}
if(this.displayOnly || this.pauseGame && this.pausedForUnfocused) {
return false;
}
if((!this.pauseGame || this.gui.pausedForWindow) && !this.displayOnly && this.gui.windowStackMeta.indexOf("GameMenu") == -1 && mouse.pressed) {
common_PokiHelpers.reportStartGameplay();
}
var scrollbarZoomHandled = false;
if(!this.cityView.isDraggingView) {
if(this.gui.handleMouse(mouse)) {
return true;
}
this.cityView.handleScrollbarZoom(mouse);
scrollbarZoomHandled = true;
if(this.cityView.handleEarlyMouse(mouse)) {
return true;
}
if(!this.isLoserState) {
if(this.simulation.handleMouse(mouse)) {
return true;
}
if(this.builder != null) {
if(this.builder.handleMouse(mouse)) {
return true;
}
}
var _g = 0;
var _g1 = this.worlds;
while(_g < _g1.length) {
var world = _g1[_g];
++_g;
if(world.handleMouse(mouse)) {
return true;
}
}
}
if(mouse.pressed && mouse.disableCityMovement) {
mouse.disableCityMovement = false;
}
if(this.cityView.handleMouse(mouse)) {
return true;
}
}
if(!scrollbarZoomHandled) {
this.cityView.handleScrollbarZoom(mouse);
}
mouse.releaseAllClaims();
return false;
}
,update: function(timeMod) {
if(this.game.mouse.rightPressed && this.buildingMode == BuildingMode.Destroy) {
this.buildingMode = BuildingMode.Normal;
}
if(!(this.pauseGame && this.pausedForUnfocused) && !this.displayOnly && (this.game.keyboard.pressed[32] || this.game.keyboard.pressed[Keyboard.getLetterCode("P")])) {
this.set_pauseGame(!this.pauseGame);
if(this.pauseGame) {
common_PokiHelpers.reportStopGameplay();
}
}
if((!this.pauseGame || this.gui.pausedForWindow) && !this.displayOnly && this.gui.windowStackMeta.indexOf("GameMenu") == -1 && this.game.keyboard.anyKey()) {
common_PokiHelpers.reportStartGameplay();
}
var usedSimulationSpeed = this.pauseGame ? 0 : this.simulationSpeed * 0.6666666666666666666;
var _g = 0;
var _g1 = this.worlds;
while(_g < _g1.length) {
var world = _g1[_g];
++_g;
world.update(timeMod * usedSimulationSpeed);
}
this.particles.update(timeMod * usedSimulationSpeed);
if(this.builder != null) {
this.builder.update(timeMod);
} else if(this.game.isMobile) {
this.builderHighlightStage.removeChildren();
}
if(!this.displayOnly) {
this.gui.update(timeMod);
}
var nextWholeSimulationSpeed = Math.ceil(usedSimulationSpeed / 1.67);
this.cityCullX = this.viewPos.x - this.get_displayWidth() / 2 - 5;
this.cityCullY = this.viewPos.y - this.get_displayHeight() / 2 + 5;
this.cityCullX2 = this.cityCullX + this.get_displayWidth() + 10;
this.cityCullY2 = this.cityCullY + this.get_displayHeight() + 10;
var _g = 0;
var _g1 = nextWholeSimulationSpeed;
while(_g < _g1) {
var i = _g++;
this.simulation.update(timeMod * (usedSimulationSpeed / nextWholeSimulationSpeed));
}
this.simulation.prevTimeMod = timeMod * usedSimulationSpeed;
if(nextWholeSimulationSpeed == 0) {
this.simulation.updateWhilePaused();
}
this.stars.update();
this.progress.update(timeMod);
if(!this.displayOnly) {
common_AdHelper.cityUpdate(this,this.game.mouse);
}
if(!this.displayOnly) {
this.cityView.handleMouseMovement(timeMod);
this.cityView.handleKeyboardMove(timeMod);
}
if(!this.displayOnly) {
this.handleAutoSave(timeMod);
}
if(!this.displayOnly) {
this.gui.lateUpdate();
}
if(this.updateConnectedBuildingSprites) {
var _g = 0;
var _g1 = this.permanents;
while(_g < _g1.length) {
var pm = _g1[_g];
++_g;
if(pm.isBuilding) {
var bl = pm;
var ambd = bl.drawer;
ambd.positionSpritesMerging();
}
}
this.updateConnectedBuildingSprites = false;
}
var cullRectangle = new common_FRectangle(this.viewPos.x - this.get_displayWidth() / 2 - 1,this.viewPos.y - this.get_displayHeight() / 2 - 1,this.get_displayWidth() + 2,this.get_displayHeight() + 2);
if(this.previousCullRectangle == null || this.previousCullRectangle.x != cullRectangle.x || this.previousCullRectangle.y != cullRectangle.y || this.previousCullRectangle.width != cullRectangle.width || this.previousCullRectangle.height != cullRectangle.height) {
this.simulation.recomputeCull();
this.previousCullRectangle = cullRectangle.clone();
}
this.cityBgStage.preDraw(cullRectangle);
this.cityStage.preDraw(cullRectangle);
this.cityMidStage.preDraw(cullRectangle);
}
,uncull: function() {
this.cityBgStage.uncull();
this.cityStage.uncull();
this.cityMidStage.uncull();
this.simulation.uncull();
}
,postDraw: function() {
this.simulation.lateUpdate();
this.furtherForegroundTempStage.removeChildren();
if(!this.hoverHighlightSetThisStep) {
this.hoverHighlightStage.removeChildren();
this.hoverHighlightStage2.removeChildren();
} else {
this.hoverHighlightSetThisStep = false;
}
}
,resize: function() {
if(this.displayOnly) {
this.zoomScale = this.game.scaling;
}
var filterless = false;
var usedScale = this.zoomScale;
if(this.zoomScale % 1 < 0.001 || this.zoomScale % 1 > 0.999) {
filterless = true;
usedScale = Math.round(this.zoomScale);
} else {
usedScale = this.zoomScale;
}
this.sky.scale.x = this.sky.scale.y = usedScale;
this.starStage.scale.x = this.starStage.scale.y = usedScale;
this.starStage.position.set(usedScale * (this.get_displayWidth() - this.stars.maxStarX) / 2,usedScale * (this.get_displayHeight() - this.stars.maxStarY) / 2);
this.movingViewStage.scale.x = this.movingViewStage.scale.y = usedScale;
this.cityView.updateMovingView();
this.gui.resize();
this.stars.resize();
this.simulation.time.updateSky();
}
,refocus: function() {
if(this.game.isMobile) {
this.cityStage.isInvalid = true;
this.cityMidStage.isInvalid = true;
this.cityBgStage.isInvalid = true;
}
}
,updateSky: function(color) {
this.sky.clear();
this.skyColor = color;
this.sky.beginFill(color);
this.sky.drawRect(0,0,this.get_displayWidth() + 1,this.get_displayHeight() + 1);
this.sky.endFill();
}
,getCityEdges: function() {
var minX = 0;
var maxX = 0;
var minY = 0;
var maxY = 1;
var _g = 0;
var _g1 = this.worlds;
while(_g < _g1.length) {
var w = _g1[_g];
++_g;
if(w.rect.height == 0) {
continue;
}
var val2 = w.rect.x;
if(val2 < minX) {
minX = val2;
}
var val21 = w.rect.get_x2();
if(val21 > maxX) {
maxX = val21;
}
var val22 = w.rect.y - 20 * common_ArrayExtensions.max(w.permanents,function(permanents) {
return permanents.length;
}).length;
if(val22 < minY) {
minY = val22;
}
var val23 = w.rect.get_y2();
if(val23 > maxY) {
maxY = val23;
}
}
return { minX : minX, maxX : maxX, minY : minY, maxY : maxY};
}
,getPermanentAtPos: function(xx,yy) {
var _g = 0;
var _g1 = this.worlds;
while(_g < _g1.length) {
var thisWorld = _g1[_g];
++_g;
var perms = thisWorld.permanents;
var preRelY = thisWorld.rect.y - (yy + 1);
var relX = (xx - thisWorld.rect.x) / 20 | 0;
var relY = preRelY < 0 ? -1 : preRelY / 20 | 0;
if(relX >= 0 && relX < perms.length) {
var thesePerms = thisWorld.permanents[relX];
if(relY >= 0 && relY < thesePerms.length) {
return thesePerms[relY];
}
}
}
return null;
}
,fixViewBottom: function(onY) {
this.fixViewBottomYOn = onY;
}
,createOrRemoveBuilder: function(buildingType,neverRemove) {
if(neverRemove == null) {
neverRemove = false;
}
var canPrevalidatePossibly = false;
if(this.builder != null && this.builder.get_buildingToBuild() == buildingType) {
if(!neverRemove) {
this.builder.cancel();
}
return;
}
if(this.builder != null) {
canPrevalidatePossibly = this.builder.isCacheValid();
}
var this1 = this.progress.resources.buildingInfo;
var key = buildingType.__name__;
var newBuildingInfo = this1.h[key];
var canPrevalidateCache = false;
if(this.builder != null) {
var _g = this.builder.builderType;
if(_g._hx_index == 0) {
var _g1 = _g.buildingType;
var info = _g.buildingInfo;
canPrevalidateCache = newBuildingInfo.specialInfo.indexOf("rooftop") != -1 == (info.specialInfo.indexOf("rooftop") != -1);
}
this.builder.cancel();
}
if(this.specialAction != null) {
this.specialAction.deactivate();
}
this.builder = new Builder(this,this.builderStage,BuilderType.Building(buildingType,newBuildingInfo));
if(canPrevalidateCache && canPrevalidatePossibly) {
this.builder.prevalidateCache();
}
if(this.postCreateBuilder != null) {
this.postCreateBuilder();
}
}
,createOrRemoveDecorationBuilder: function(decorationInfo) {
var tmp;
if(this.builder != null) {
var _g = this.builder.builderType;
var tmp1;
if(_g._hx_index == 1) {
var d = _g.decorationInfo;
tmp1 = d.name;
} else {
tmp1 = "";
}
tmp = tmp1 == decorationInfo.name;
} else {
tmp = false;
}
if(tmp) {
this.builder.cancel();
return;
}
if(this.builder != null) {
this.builder.cancel();
}
if(this.specialAction != null) {
this.specialAction.deactivate();
}
this.builder = new Builder(this,this.builderStage,BuilderType.Decoration(decorationInfo));
if(this.postCreateBuilder != null) {
this.postCreateBuilder();
}
}
,createOrRemoveWorldResourceBuilder: function(resourceInfo) {
var tmp;
if(this.builder != null) {
var _g = this.builder.builderType;
var tmp1;
if(_g._hx_index == 2) {
var w = _g.resourceInfo;
tmp1 = w;
} else {
tmp1 = null;
}
tmp = tmp1 == resourceInfo;
} else {
tmp = false;
}
if(tmp) {
this.builder.cancel();
return;
}
if(this.builder != null) {
this.builder.cancel();
}
if(this.specialAction != null) {
this.specialAction.deactivate();
}
this.builder = new Builder(this,this.builderStage,BuilderType.WorldResource(resourceInfo));
if(this.postCreateBuilder != null) {
this.postCreateBuilder();
}
}
,createWorldResourceBuilderMove: function(worldResource) {
if(this.builder != null) {
this.builder.cancel();
}
if(this.specialAction != null) {
this.specialAction.deactivate();
}
this.builder = new Builder(this,this.builderStage,BuilderType.MoveWorldResource(worldResource));
if(this.postCreateBuilder != null) {
this.postCreateBuilder();
}
}
,activateSpecialCityAction: function(newSpecialAction) {
if(this.builder != null) {
this.builder.cancel();
}
if(this.specialAction != null) {
this.specialAction.deactivate();
}
this.specialAction = newSpecialAction;
this.specialAction.activate();
}
,findPermanentByID: function(id) {
return this.permanentsByID.h[id];
}
,handleAutoSave: function(timeMod) {
this.secondsSinceAutoSave += timeMod / 60;
if(this.secondsSinceAutoSave > 1.95 && !this.currentlySaving && !this.isLoserState) {
this.saveToBrowserStorage(this.cityFile);
}
}
,saveToBrowserStorage: function(fileName) {
var _gthis = this;
if(fileName == null) {
fileName = this.cityFile;
}
var saveFile = this.saveToUIntArray();
this.currentlySaving = true;
common_Storage.setItem(fileName,saveFile,function() {
_gthis.secondsSinceAutoSave = 0;
_gthis.currentlySaving = false;
});
gamesave_SaveMetaData.saveMetaData(fileName,this);
}
,saveToString: function() {
return this.save().toBase64();
}
,saveToUIntArray: function() {
return this.save().getData();
}
,save: function() {
var queue = new gamesave_ResizingBytesQueue(this.saveRawDataToReuse);
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
var tmp = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes = tmp;
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,-1234);
queue.size += 4;
queue.addString(this.progress.story.storyName);
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
var tmp = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes = tmp;
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,36);
queue.size += 4;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
var tmp = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes = tmp;
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,0);
queue.size += 4;
Settings.saveToCitySave(queue);
var value = this.worlds.length;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
var tmp = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes = tmp;
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
Lambda.iter(this.worlds,function(w) {
w.save(queue);
});
this.progress.save(queue);
this.simulation.save(queue);
this.saveBasics(queue);
this.materials.save(queue);
this.upgrades.save(queue);
this.policies.save(queue);
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
var tmp = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes = tmp;
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,0);
queue.size += 4;
this.saveRawDataToReuse = queue.bytes;
return queue;
}
,createBottomWorld: function() {
var boundaries = this.getCityEdges();
this.worlds.push(new World(this.game,this,this.cityStage,this.cityMidStage,this.cityBgStage,new common_Rectangle(boundaries.minX - 20,boundaries.maxY + 40,boundaries.maxX - boundaries.minX,0),0));
}
,activateLoserState: function() {
if(this.builder != null) {
this.builder.cancel();
}
this.set_pauseGame(true);
this.gui.activateLoserState();
this.isLoserState = true;
}
,load: function(queue) {
if(queue.bytes.getInt32(queue.readStart) == -1234) {
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
queue.readString();
}
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
queue.version = intToRead;
if(queue.version >= 36) {
modding_ModTools._performOnLoadEarly(this,queue);
}
if(queue.version >= 14) {
Settings.loadFromCitySave(queue);
}
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var num = intToRead;
var _g = 0;
var _g1 = num;
while(_g < _g1) {
var i = _g++;
this.worlds.push(World.fromLoad(queue,this.game,this,this.cityStage,this.cityMidStage,this.cityBgStage));
}
if(queue.version < 24) {
this.createBottomWorld();
}
this.updateDrawCachingRectSize();
this.progress.load(queue);
this.simulation.load(queue);
this.loadBasics(queue);
this.materials.load(queue);
if(queue.version >= 4) {
this.upgrades.load(queue);
}
if(queue.version >= 34) {
this.policies.load(queue);
}
if(queue.version >= 35) {
modding_ModTools._performOnLoad(this,queue);
}
this.cityView.updateMovingViewStagePosition();
this.connections.updateCityConnections();
this.simulation.updatePathfinder(false);
this.resize();
var _g = 0;
var _g1 = this.permanents;
while(_g < _g1.length) {
var pm = _g1[_g];
++_g;
pm.postCreate();
}
this.simulation.afterLoad();
}
,getAmountOfPermanentsPerType: function() {
if(this.permanentNumberCached != null) {
return this.permanentNumberCached;
}
var permanentNumber = new haxe_ds_StringMap();
var _g = 0;
var _g1 = this.permanents;
while(_g < _g1.length) {
var b = _g1[_g];
++_g;
var c = js_Boot.getClass(b);
var t = c.__name__;
if(Object.prototype.hasOwnProperty.call(permanentNumber.h,t)) {
var tmp = t;
var v = permanentNumber.h[tmp] + 1;
permanentNumber.h[tmp] = v;
} else {
permanentNumber.h[t] = 1;
}
}
this.permanentNumberCached = permanentNumber;
return permanentNumber;
}
,cheatMaterials: function() {
this.materials.add(new Materials(10000,10000,10000,10000,10000,10000,10000));
}
,cheatMaterialsZero: function() {
this.materials.remove(this.materials);
}
,cheatFood: function(food) {
this.materials.set_food(food);
}
,cheatWood: function(wood) {
this.materials.wood = wood;
}
,cheatPeople: function() {
var _gthis = this;
var _g = 0;
while(_g < 100) {
var i = _g++;
var tmp = this.simulation;
var _g1 = [];
var _g2 = 0;
var _g3 = this.worlds;
while(_g2 < _g3.length) {
var v = _g3[_g2];
++_g2;
if(common_ArrayExtensions.any(_gthis.simulation.citizens,(function(w) {
return function(ct) {
return ct.onWorld == w[0];
};
})([v]))) {
_g1.push(v);
}
}
tmp.createCitizen(_g1[0],20,null,0);
}
}
,cheatUnlocks: function() {
var building = haxe_ds_StringMap.valueIterator(Resources.buildingInfo.h);
while(building.hasNext()) {
var building1 = building.next();
var name = "buildings." + building1.className;
this.progress.unlocks.unlock($hxClasses[name]);
var name1 = "buildings." + building1.className;
this.progress.unlocks.fullyUnlock($hxClasses[name1]);
}
}
,onContextRestored: function() {
this.cityStage.isInvalid = true;
this.cityMidStage.isInvalid = true;
this.cityBgStage.isInvalid = true;
if(this.get_usingParticleContainers()) {
graphics_ParticleContainerHelper.recreateContainer(this.citizenInBuildingStage);
graphics_ParticleContainerHelper.recreateContainer(this.citizenForegroundStage);
}
}
,saveBasics: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
if(shouldSaveDefinition) {
queue.addString(City.saveDefinition);
}
var value = this.maxPermanentID;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
queue.addFPoint(this.viewPos);
var value = this.zoomScale;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
queue.addString(this.cityName);
}
,loadBasics: function(queue,definition) {
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"maxPermanentID")) {
this.maxPermanentID = loadMap.h["maxPermanentID"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"viewPos")) {
this.viewPos = loadMap.h["viewPos"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"zoomScale")) {
this.zoomScale = loadMap.h["zoomScale"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"cityName")) {
this.cityName = loadMap.h["cityName"];
}
}
,__class__: City
};
var CitySimulation = function(city,foregroundStage,inBuildingStage,inBuildingStageNonParticle) {
this.infrequentUpdateStart = 0;
this.adultTextures = [];
this.childrenTextures = [];
this.citizens = [];
this.city = city;
this.foregroundStage = foregroundStage;
this.inBuildingStageNonParticle = inBuildingStageNonParticle;
this.inBuildingStage = inBuildingStage;
this.time = new CityTime(city,this);
this.childrenTextures = Resources.getTexturesByWidth("spr_children",2);
this.adultTextures = Resources.getTexturesByWidth("spr_humans",2);
this.jobAssigner = new simulation_JobAssigner(city,this);
this.houseAssigner = new simulation_HouseAssigner(city,this);
this.schoolAssigner = new simulation_SchoolAssigner(city,this);
this.pathfinder = new pathfinder_PathfinderManager(city);
this.permanentFinder = new pathfinder_PermanentFinder(city);
this.flyingPathfinder = new pathfinder_FlyingPathfinder(city);
this.happiness = new simulation_Happiness(city,this);
this.babyMaker = new simulation_BabyMaker(city,this);
this.stats = new simulation_Stats(city,this);
this.bonuses = new simulation_BonusResults();
this.flyingSaucers = [];
this.citizenSpawners = [];
this.eating = new simulation_Eating(this);
this.resourcePriorityManager = new simulation_ResourcePriorityManager(city);
this.fishes = new simulation_FishManager(this);
this.buildingUpgradesToUpdate = [];
if(!Game.isLoading) {
this.initPossibleHobbies();
} else {
this.possibleCitizenHobbies = [];
}
this.boostManager = new simulation_BoostManager(this);
this.festivalManager = new simulation_festival_FestivalManager(city,this);
this.citizenUpdater = new simulation_CitizenUpdater(this);
};
$hxClasses["CitySimulation"] = CitySimulation;
CitySimulation.__name__ = "CitySimulation";
CitySimulation.prototype = {
stop: function() {
this.pathfinder.terminate();
}
,initPossibleHobbies: function() {
this.possibleCitizenHobbies = [{ hobbyClass : simulation_citizenSpecialActions_ClimbIntoTree, minimumCitizenAmount : 1},{ hobbyClass : simulation_citizenSpecialActions_MoveToEdge, minimumCitizenAmount : 2},{ hobbyClass : simulation_citizenSpecialActions_WatchStars, minimumCitizenAmount : 5},{ hobbyClass : simulation_citizenSpecialActions_Protester, minimumCitizenAmount : 6},{ hobbyClass : simulation_citizenSpecialActions_DanceOnBall, minimumCitizenAmount : 35},{ hobbyClass : simulation_citizenSpecialActions_ClimbOntoRuins, minimumCitizenAmount : 80}];
}
,update: function(timeMod) {
var previousHour = ((this.time.timeSinceStart | 0) / 60 | 0) % 24;
this.time.update(timeMod);
if(previousHour >= 23 && ((this.time.timeSinceStart | 0) / 60 | 0) % 24 < 1) {
this.stats.midnightUpdate();
}
this.stats.update(timeMod);
this.permanentFinder.preUpdate();
this.pathfinder.distributePaths();
var i = this.flyingSaucers.length;
while(--i >= 0) this.flyingSaucers[i].update(timeMod);
var i = this.citizenSpawners.length;
while(--i >= 0) this.citizenSpawners[i].update(timeMod);
this.festivalManager.update(timeMod);
if(this.citizens.length > 0) {
if(this.festivalManager.hasFestival()) {
this.festivalManager.updateFestivalCitizens(timeMod);
} else {
this.citizenUpdater.update(timeMod);
}
if(previousHour < 12 && ((this.time.timeSinceStart | 0) / 60 | 0) % 24 >= 12) {
var _g = 0;
var _g1 = this.citizens;
while(_g < _g1.length) {
var citizen = _g1[_g];
++_g;
citizen.midDayUpdate();
}
}
var val1 = this.citizens.length;
var val2 = Math.ceil(this.infrequentUpdateStart + this.citizens.length / 60);
var i = val2 < val1 ? val2 : val1;
var minNumber = Math.ceil(this.infrequentUpdateStart);
while(--i >= minNumber) this.citizens[i].infrequentUpdate();
this.infrequentUpdateStart += this.citizens.length / 60;
if(this.infrequentUpdateStart >= this.citizens.length) {
this.infrequentUpdateStart = 0;
}
}
this.fishes.update(timeMod);
this.babyMaker.update(timeMod);
this.pathfinder.requestAllPaths();
var _g = 0;
var _g1 = this.city.permanents;
while(_g < _g1.length) {
var permanent = _g1[_g];
++_g;
permanent.update(timeMod);
}
var _g = 0;
var _g1 = this.buildingUpgradesToUpdate;
while(_g < _g1.length) {
var bu = _g1[_g];
++_g;
bu.update(timeMod);
}
this.boostManager.update(timeMod);
}
,lateUpdate: function() {
var timeMod = this.prevTimeMod;
this.jobAssigner.assignJobs();
this.schoolAssigner.assignSchools();
this.houseAssigner.assignHouses();
this.happiness.update(timeMod);
this.eating.update(timeMod);
}
,updateWhilePaused: function() {
this.stats.update(0);
this.boostManager.update(0);
this.prevTimeMod = 0;
var _g = 0;
var _g1 = this.citizens;
while(_g < _g1.length) {
var citizen = _g1[_g];
++_g;
citizen.actuallyUpdateDraw();
}
}
,recomputeCull: function() {
var _g = 0;
var _g1 = this.citizens;
while(_g < _g1.length) {
var citizen = _g1[_g];
++_g;
citizen.updateCull();
}
}
,createCitizen: function(onWorld,age,startInPermanent,startX) {
if(age == null) {
age = 0;
}
var _gthis = this;
if(startX == null) {
startX = startInPermanent == null ? random_Random.getInt(onWorld.rect.width - 2) : random_Random.getInt(20);
}
var newCitizen = new Citizen(this.city,this,this.foregroundStage,this.inBuildingStage,this.inBuildingStageNonParticle,this.adultTextures,this.childrenTextures,onWorld,startX,age,startInPermanent);
this.citizens.push(newCitizen);
var isPossibleHobby = function(hobby) {
return _gthis.citizens.length >= hobby.minimumCitizenAmount;
};
if(this.possibleCitizenHobbies.length > 0 && common_ArrayExtensions.any(this.possibleCitizenHobbies,isPossibleHobby)) {
var _g = [];
var _g1 = 0;
var _g2 = this.possibleCitizenHobbies;
while(_g1 < _g2.length) {
var v = _g2[_g1];
++_g1;
if(isPossibleHobby(v)) {
_g.push(v);
}
}
var hobby = random_Random.fromArray(_g);
newCitizen.setHobby(Type.createInstance(hobby.hobbyClass,[newCitizen]));
HxOverrides.remove(this.possibleCitizenHobbies,hobby);
}
return newCitizen;
}
,updatePathfinder: function(invalidate,invalidateRelatedTo) {
if(invalidate) {
this.pathfinder.invalidateAllPaths();
var _g = 0;
var _g1 = this.citizens;
while(_g < _g1.length) {
var citizen = _g1[_g];
++_g;
if(citizen.path != null && (citizen.pathOnlyRelatedTo == null || invalidateRelatedTo == null || invalidateRelatedTo == citizen.pathOnlyRelatedTo)) {
var resetCanViewSelfInBuilding = false;
if(resetCanViewSelfInBuilding == null) {
resetCanViewSelfInBuilding = true;
}
if(citizen.recyclePathArray) {
pooling_Int32ArrayPool.returnToPool(citizen.path);
citizen.recyclePathArray = false;
}
citizen.path = null;
citizen.nextPathPos = -1;
citizen.pathEnd = -1;
citizen.currentPathAction = null;
if(resetCanViewSelfInBuilding) {
if(!citizen.canViewSelfInBuilding) {
citizen.delayCanViewSelfInBuilding = true;
}
citizen.canViewSelfInBuilding = true;
}
citizen.verticalPathProgress = 0;
citizen.pathEndFunction = null;
citizen.requestingPathGoal = null;
citizen.pathOnlyRelatedTo = null;
citizen.pathWalkSpeed = 1;
citizen.pathCanBeReconsidered = true;
if(citizen.sprite.alpha > 0 && citizen.sprite.alpha < 1) {
citizen.sprite.alpha = 1;
}
citizen.actuallyUpdateDraw();
}
}
var _g = 0;
var _g1 = this.city.permanents;
while(_g < _g1.length) {
var permanent = _g1[_g];
++_g;
permanent.invalidatePathfindingRelatedInfo();
}
this.permanentFinder.invalidatePathfindingRelatedInfo();
this.permanentFinder.requestQueryLimiting(true);
}
var _g = 0;
var _g1 = this.city.permanents;
while(_g < _g1.length) {
var permanent = _g1[_g];
++_g;
permanent.onCityChange();
}
var _g = 0;
var _g1 = this.city.worlds;
while(_g < _g1.length) {
var world = _g1[_g];
++_g;
world.onCityChange();
}
var _g = 0;
var _g1 = this.fishes.fishes;
while(_g < _g1.length) {
var fish = _g1[_g];
++_g;
if(fish.inPermanent != invalidateRelatedTo) {
fish.pushBackIntoPermanent();
}
}
this.city.permanentNumberCached = null;
this.pathfinder.sendPathfindingInfo();
}
,handleMouse: function(mouse) {
var hasSpecial = this.city.specialAction != null && this.city.specialAction.get_specialActionID() == "FollowCitizenAction";
if(this.city.game.keyboard.down[17] || hasSpecial) {
switch(mouse.claimMouse(this,null,false)._hx_index) {
case 0:
return true;
case 1:
var nearestCitizen = null;
var currentDist = 10.0;
if(this.city.game.isMobile) {
currentDist = 25.0;
}
var _g = 0;
var _g1 = this.citizens;
while(_g < _g1.length) {
var citizen = _g1[_g];
++_g;
var cityPos = citizen.getCityPosition();
var xDist = cityPos.x + 1 - mouse.get_cityX();
var yDist = cityPos.y - 3 - mouse.get_cityY();
var distanceToMouse = Math.sqrt(xDist * xDist + yDist * yDist);
if(distanceToMouse < currentDist) {
currentDist = distanceToMouse;
nearestCitizen = citizen;
}
}
if(nearestCitizen != null) {
nearestCitizen.onClick();
if(this.city.specialAction != null) {
this.city.specialAction.deactivate();
}
}
return true;
case 2:
return hasSpecial;
}
}
return false;
}
,save: function(queue) {
this.time.save(queue);
var value = this.citizenSpawners.length;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
var tmp = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes = tmp;
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
Lambda.iter(this.citizenSpawners,function(s) {
s.save(queue);
});
queue.addString(Citizen.saveDefinition);
var value = this.citizens.length;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
var tmp = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes = tmp;
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var _g = 0;
var _g1 = this.citizens;
while(_g < _g1.length) {
var c = _g1[_g];
++_g;
var value = this.city.worlds.indexOf(c.onWorld);
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
var tmp = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes = tmp;
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
c.save(queue,false);
var value1 = c.inPermanent != null ? c.inPermanent.id : -1;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes1 = queue.bytes;
var tmp1 = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes = tmp1;
queue.bytes.blit(0,oldBytes1,0,queue.size);
}
queue.bytes.setInt32(queue.size,value1);
queue.size += 4;
var value2 = c.job == null ? -1 : c.job.id;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes2 = queue.bytes;
var tmp2 = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes = tmp2;
queue.bytes.blit(0,oldBytes2,0,queue.size);
}
queue.bytes.setInt32(queue.size,value2);
queue.size += 4;
var value3 = c.home == null ? -1 : c.home.id;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes3 = queue.bytes;
var tmp3 = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes = tmp3;
queue.bytes.blit(0,oldBytes3,0,queue.size);
}
queue.bytes.setInt32(queue.size,value3);
queue.size += 4;
var value4 = c.school == null ? -1 : c.school.id;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes4 = queue.bytes;
var tmp4 = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes = tmp4;
queue.bytes.blit(0,oldBytes4,0,queue.size);
}
queue.bytes.setInt32(queue.size,value4);
queue.size += 4;
}
this.happiness.save(queue);
this.bonuses.save(queue);
this.jobAssigner.save(queue);
this.eating.save(queue);
this.stats.save(queue);
var _g = 0;
var _g1 = this.citizens.length;
while(_g < _g1) {
var i = _g++;
var citizen = this.citizens[i];
if(citizen.hobby != null) {
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
var tmp = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes = tmp;
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,i);
queue.size += 4;
var c = js_Boot.getClass(citizen.hobby);
queue.addString(c.__name__);
}
}
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
var tmp = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes = tmp;
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,-1);
queue.size += 4;
this.babyMaker.save(queue);
this.resourcePriorityManager.save(queue);
this.boostManager.save(queue);
this.houseAssigner.save(queue);
this.fishes.save(queue);
this.festivalManager.save(queue);
}
,load: function(queue) {
this.time.load(queue);
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var spawnerNumber = intToRead;
var _g = 0;
var _g1 = spawnerNumber;
while(_g < _g1) {
var i = _g++;
this.citizenSpawners.push(simulation_SpawnFlyingSaucer.fromLoad(queue,this.city.simulation,this.city.farForegroundStage));
}
var citizenDefinition = queue.readString();
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var num = intToRead;
var _g = 0;
var _g1 = num;
while(_g < _g1) {
var i = _g++;
var c = this.city.worlds;
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var c1 = this.createCitizen(c[intToRead]);
c1.load(queue,citizenDefinition);
var intToRead1 = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var inPermanentInt = intToRead1;
if(inPermanentInt != -1) {
c1.inPermanent = this.city.findPermanentByID(inPermanentInt);
}
var intToRead2 = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var jobInt = intToRead2;
if(jobInt != -1) {
c1.job = this.city.findPermanentByID(jobInt);
if(c1.job != null && c1.job.is(buildings_Work)) {
c1.job.workers.push(c1);
} else {
c1.job = null;
if(c1.get_age() > 16) {
this.jobAssigner.citizensWithoutJob.push(c1);
}
}
} else if(c1.get_age() > 16) {
this.jobAssigner.citizensWithoutJob.push(c1);
}
var intToRead3 = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var homeInt = intToRead3;
if(homeInt != -1) {
c1.home = this.city.findPermanentByID(homeInt);
if(c1.home != null && c1.home.is(buildings_House)) {
c1.home.residents.push(c1);
} else {
c1.home = null;
}
}
var intToRead4 = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var schoolInt = intToRead4;
if(schoolInt != -1) {
c1.school = this.city.findPermanentByID(schoolInt);
if(c1.school != null && c1.school.is(buildings_School)) {
c1.school.students.push(c1);
} else {
c1.school = null;
}
}
c1.afterLoadingInPermanent();
}
this.jobAssigner.buildingsHaveWork = true;
this.houseAssigner.shouldUpdateHouses = true;
this.schoolAssigner.schoolsShouldBeUpdated = true;
this.happiness.load(queue);
this.bonuses.load(queue);
this.jobAssigner.load(queue);
this.eating.load(queue);
if(queue.version >= 2) {
this.stats.load(queue);
}
if(queue.version >= 3) {
this.initPossibleHobbies();
var i;
while(true) {
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
i = intToRead;
if(!(i != -1)) {
break;
}
var name = queue.readString();
var cls = [$hxClasses[name]];
this.citizens[i].setHobby(Type.createInstance(cls[0],[this.citizens[i]]));
HxOverrides.remove(this.possibleCitizenHobbies,Lambda.find(this.possibleCitizenHobbies,(function(cls) {
return function(h) {
return h.hobbyClass == cls[0];
};
})(cls)));
}
}
if(queue.version >= 9) {
this.babyMaker.load(queue);
}
if(queue.version >= 10) {
this.resourcePriorityManager.load(queue);
}
if(queue.version >= 16) {
this.boostManager.load(queue);
}
if(queue.version >= 17) {
this.houseAssigner.load(queue);
}
if(queue.version >= 19) {
this.fishes.load(queue);
}
if(queue.version >= 21) {
this.festivalManager.load(queue);
}
}
,afterLoad: function() {
this.festivalManager.afterLoad();
}
,uncull: function() {
var _g = 0;
var _g1 = this.citizens;
while(_g < _g1.length) {
var citizen = _g1[_g];
++_g;
citizen.uncull();
}
}
,__class__: CitySimulation
};
var CityTime = function(city,simulation) {
this.skyColors = [{ color : 2626656, time : 0},{ color : 2626656, time : 4},{ color : 12541833, time : 6},{ color : 12541833, time : 6.5},{ color : 11389183, time : 8.5},{ color : 11389183, time : 11},{ color : 12247804, time : 13},{ color : 12247804, time : 17},{ color : 8872356, time : 20.5},{ color : 8872356, time : 21},{ color : 2626656, time : 23},{ color : 2626656, time : 24}];
this.minutesPerTick = 0.5;
this.city = city;
this.simulation = simulation;
this.timeSinceStart = 120;
};
$hxClasses["CityTime"] = CityTime;
CityTime.__name__ = "CityTime";
CityTime.getBasicTimeString = function(time) {
if(time > 2880) {
return "" + Math.floor(time / 1440) + " days";
}
if(time > 1440) {
return "one day";
}
if(time > 60) {
return "" + Math.floor(time / 60) + " hours";
}
return "one hour";
};
CityTime.prototype = {
update: function(timeMod) {
this.timeSinceStart += timeMod * this.minutesPerTick;
this.updateSky();
if((this.timeSinceStart / 60 % 24 > 23 || this.timeSinceStart / 60 % 24 < 4) && this.city.progress.story.get_speedUpStartNights()) {
if(1 + ((this.timeSinceStart | 0) / 1440 | 0) == 1 || 1 + ((this.timeSinceStart | 0) / 1440 | 0) == 2 || 1 + ((this.timeSinceStart | 0) / 1440 | 0) == 3 && this.timeSinceStart / 60 % 24 < 4) {
this.timeSinceStart += timeMod * this.minutesPerTick * 2.75;
} else if(1 + ((this.timeSinceStart | 0) / 1440 | 0) == 3) {
this.timeSinceStart += timeMod * this.minutesPerTick;
} else if(1 + ((this.timeSinceStart | 0) / 1440 | 0) == 4) {
this.timeSinceStart += timeMod * this.minutesPerTick * 0.5;
}
}
}
,updateSky: function() {
var currentColor = this.getCurrentColor(this.skyColors);
if(currentColor != null) {
this.city.updateSky(currentColor);
}
}
,getCurrentColor: function(colors) {
var rgb = function(col) {
return { r : col / 65536 | 0, g : (col / 256 | 0) % 256, b : col % 256};
};
var _g = 0;
var _g1 = colors.length;
while(_g < _g1) {
var i = _g++;
var thisCol = colors[i];
var nextCol = colors[i + 1];
if(this.timeSinceStart / 60 % 24 < nextCol.time) {
var thisColColor = rgb(thisCol.color);
var nextColColor = rgb(nextCol.color);
var lerpVal = (this.timeSinceStart / 60 % 24 - thisCol.time) / (nextCol.time - thisCol.time);
var val1 = thisColColor.r;
var val11 = thisColColor.g;
var val12 = thisColColor.b;
return (val1 + lerpVal * (nextColColor.r - val1) | 0) * 256 * 256 + (val11 + lerpVal * (nextColColor.g - val11) | 0) * 256 + (val12 + lerpVal * (nextColColor.b - val12) | 0);
}
}
return null;
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
if(shouldSaveDefinition) {
queue.addString(CityTime.saveDefinition);
}
var value = this.timeSinceStart;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
}
,load: function(queue,definition) {
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"timeSinceStart")) {
this.timeSinceStart = loadMap.h["timeSinceStart"];
}
}
,__class__: CityTime
};
var CityView = function(city) {
this.remZoomScrollBarMovement = 0;
this.isDraggingViewTwoPointer = false;
this.isDraggingView = false;
this.city = city;
this.dragPreviousMousePos = new common_FPoint(0,0);
this.dragDir = new common_FPoint(0,0);
this.dragDirRemaining = new common_FPoint(0,0);
this.dragPointerIdentifiers = [0,1];
this.dragPreviousCityPointerPositions = [null,null];
this.dragInitialPointerPositions = [null,null];
};
$hxClasses["CityView"] = CityView;
CityView.__name__ = "CityView";
CityView.prototype = {
get_game: function() {
return this.city.game;
}
,handleEarlyMouse: function(mouse) {
if(mouse.weakClaimForScroll("doCityViewScroll")) {
if(!mouse.disableCityMovement) {
this.startViewDrag();
return true;
}
}
return false;
}
,handleMouse: function(mouse) {
if(!this.isDraggingView && !mouse.disableCityMovement) {
if(mouse.down) {
this.startViewDrag();
return true;
} else if(mouse.pointerDown.length >= 2) {
this.startViewDrag();
return true;
}
}
return false;
}
,handleKeyboardMove: function(timeMod) {
var keyboardXMove = 0.0;
var keyboardYMove = 0.0;
var keyboardMoveSpeed = 2.0 + 12.0 / this.city.zoomScale;
if(this.get_game().keyboard.down[37]) {
keyboardXMove -= keyboardMoveSpeed * timeMod;
}
if(this.get_game().keyboard.down[39]) {
keyboardXMove += keyboardMoveSpeed * timeMod;
}
if(this.get_game().keyboard.down[38]) {
keyboardYMove -= keyboardMoveSpeed * timeMod;
}
if(this.get_game().keyboard.down[40]) {
keyboardYMove += keyboardMoveSpeed * timeMod;
}
if(keyboardXMove != 0 || keyboardYMove != 0) {
this.city.viewPos.x += keyboardXMove;
this.city.viewPos.y += keyboardYMove;
this.updateMovingView();
}
if(this.get_game().keyboard.pressed[187] || this.get_game().keyboard.pressed[61]) {
this.zoomIn();
}
if(this.get_game().keyboard.pressed[189] || this.get_game().keyboard.pressed[173]) {
this.zoomOut();
}
}
,updateMovingView: function() {
var edges = this.city.getCityEdges();
var minX = edges.minX;
var maxX = edges.maxX;
var minY = edges.minY;
var maxY = edges.maxY;
var val = this.city.viewPos.x - this.get_game().addX;
this.city.viewPos.x = (val < minX ? minX : val > maxX ? maxX : val) + this.get_game().addX;
var tmp;
if(this.city.fixViewBottomYOn == null) {
var val = this.city.viewPos.y - this.get_game().addY;
tmp = (val < minY ? minY : val > maxY ? maxY : val) + this.get_game().addY;
} else {
tmp = this.city.fixViewBottomYOn - (this.get_game().rect.height / 2 | 0) + this.get_game().addY;
}
this.city.viewPos.y = tmp;
this.updateMovingViewStagePosition();
}
,updateMovingViewStagePosition: function() {
if(this.city.viewIsControlled) {
this.city.movingViewStage.position.set((-this.city.viewPos.x + this.get_game().addX) * this.city.zoomScale + (this.get_game().rect.width / 2 | 0) * this.get_game().scaling,(-this.city.viewPos.y + this.get_game().addY) * this.city.zoomScale + this.get_game().scaling * (this.get_game().rect.height / 2 | 0));
} else {
this.city.movingViewStage.position.set(Math.floor((-this.city.viewPos.x + this.get_game().addX) * this.city.zoomScale + (this.get_game().rect.width / 2 | 0) * this.get_game().scaling),Math.floor((-this.city.viewPos.y + this.get_game().addY) * this.city.zoomScale + this.get_game().scaling * (this.get_game().rect.height / 2 | 0)));
}
}
,handleMouseMovement: function(timeMod) {
var _gthis = this;
var mouse = this.get_game().mouse;
if(!this.city.viewIsControlled || mouse.pointerDown.length >= 2) {
if(mouse.middlePressed) {
if(!this.city.viewIsControlled) {
this.startViewDrag();
}
} else if(this.isDraggingView) {
var shouldBeTwoPointerDrag = mouse.pointerDown.length >= 2;
if(mouse.pointerDown.length == 0 && !mouse.middleDown && !mouse.down) {
this.isDraggingView = false;
this.isDraggingViewTwoPointer = false;
} else if(shouldBeTwoPointerDrag != this.isDraggingViewTwoPointer) {
this.startViewDrag();
} else if(this.isDraggingViewTwoPointer) {
if(common_ArrayExtensions.any(mouse.pointerDown,function(d) {
return _gthis.dragPointerIdentifiers.indexOf(d) == -1;
}) || common_ArrayExtensions.any(this.dragPointerIdentifiers,function(d) {
return mouse.pointerDown.indexOf(d) == -1;
})) {
this.startViewDrag();
} else {
var _g = [];
var _g1 = 0;
var _g2 = this.dragPointerIdentifiers.length;
while(_g1 < _g2) {
var i = _g1++;
_g.push(null);
}
var currentPointerCityPositions = _g;
var _g = [];
var _g1 = 0;
var _g2 = this.dragPointerIdentifiers.length;
while(_g1 < _g2) {
var i = _g1++;
_g.push(null);
}
var currentPointerPositions = _g;
var _g = 0;
var _g1 = this.dragPointerIdentifiers.length;
while(_g < _g1) {
var i = _g++;
currentPointerCityPositions[i] = mouse.pointerCityPosition.h[this.dragPointerIdentifiers[i]];
currentPointerPositions[i] = mouse.pointerPosition.h[this.dragPointerIdentifiers[i]];
}
if(currentPointerCityPositions.indexOf(null) != -1) {
this.startViewDrag();
} else {
var _this = common_ArrayExtensions.sumFPoint(currentPointerPositions);
var withFloat = 1 / currentPointerCityPositions.length;
var newCenterPointerPos = new common_FPoint(_this.x * withFloat,_this.y * withFloat);
var _this = common_ArrayExtensions.sumFPoint(this.dragInitialPointerPositions);
var withFloat = 1 / this.dragInitialPointerPositions.length;
var initialCenterPointerPos = new common_FPoint(_this.x * withFloat,_this.y * withFloat);
var newPointerDistance = Math.max(1,common_ArrayExtensions.sum(currentPointerPositions,function(pnt) {
return common_FPoint.distance(newCenterPointerPos,new common_FPoint(pnt.x,pnt.y));
}));
var initialPointerDistance = Math.max(1,common_ArrayExtensions.sum(this.dragInitialPointerPositions,function(pnt) {
return common_FPoint.distance(initialCenterPointerPos,new common_FPoint(pnt.x,pnt.y));
}));
var val = newPointerDistance / initialPointerDistance * this.originalTwoFingerDragZoom;
var val1 = this.get_game().scaling / 2;
var minVal = Math.floor(val1 < 1 ? 1 : val1 > 2 ? 2 : val1);
var maxVal = 7 * (this.get_game().scaling / 2);
this.setZoom(val < minVal ? minVal : val > maxVal ? maxVal : val,mouse);
if(!this.city.viewIsControlled) {
var _g = 0;
var _g1 = this.dragPointerIdentifiers.length;
while(_g < _g1) {
var i = _g++;
currentPointerCityPositions[i] = mouse.pointerCityPosition.h[this.dragPointerIdentifiers[i]];
}
var _this = common_ArrayExtensions.sumFPoint(currentPointerCityPositions);
var withFloat = 1 / currentPointerCityPositions.length;
var newCenterPosition_x = _this.x * withFloat;
var newCenterPosition_y = _this.y * withFloat;
var _this = common_ArrayExtensions.sumFPoint(this.dragPreviousCityPointerPositions);
var withFloat = 1 / this.dragPreviousCityPointerPositions.length;
var oldCenterPosition_x = _this.x * withFloat;
var oldCenterPosition_y = _this.y * withFloat;
var thisDragDir_x = oldCenterPosition_x - newCenterPosition_x;
var thisDragDir_y = oldCenterPosition_y - newCenterPosition_y;
this.dragDir.x = this.dragDir.x * 0.4 + 0.6 * thisDragDir_x;
this.dragDir.y = this.dragDir.y * 0.4 + 0.6 * thisDragDir_y;
var _this = this.city.viewPos;
var val = new common_FPoint(_this.x + thisDragDir_x,_this.y + thisDragDir_y);
this.city.viewPos = val;
this.updateMovingView();
}
var _g = 0;
var _g1 = this.dragPointerIdentifiers.length;
while(_g < _g1) {
var i = _g++;
this.dragPreviousCityPointerPositions[i] = mouse.calcCityFPositionForPointer(this.get_game(),this.city,this.dragPointerIdentifiers[i]);
}
}
}
} else {
var scaledCityPos;
if(!mouse.down && mouse.pointerDown.length > 0) {
scaledCityPos = mouse.pointerCityScaledPosition.h[mouse.pointerDown[0]];
} else {
scaledCityPos = mouse.cityScaledPosition;
}
var _this = this.dragPreviousMousePos;
var thisDragDir_x = _this.x - scaledCityPos.x;
var thisDragDir_y = _this.y - scaledCityPos.y;
this.dragDir.x = this.dragDir.x * 0.4 + 0.6 * thisDragDir_x;
this.dragDir.y = this.dragDir.y * 0.4 + 0.6 * thisDragDir_y;
var _this = this.city.viewPos;
var val = new common_FPoint(_this.x + thisDragDir_x,_this.y + thisDragDir_y);
this.city.viewPos = val;
this.dragPreviousMousePos = scaledCityPos;
this.updateMovingView();
}
}
if(!this.isDraggingView) {
if(mouse.pressed || this.dragDir.get_length() < 0.5) {
this.dragDir.x = 0;
this.dragDir.y = 0;
this.dragDirRemaining.x = 0;
this.dragDirRemaining.y = 0;
} else {
var dragSpeedTimeout = mouse.isTouch ? 0.933 : 0.8;
this.dragDir.x *= dragSpeedTimeout;
this.dragDir.y *= dragSpeedTimeout;
var stepDragDir_x = this.dragDir.x + this.dragDirRemaining.x;
var stepDragDir_y = this.dragDir.y + this.dragDirRemaining.y;
this.dragDirRemaining.x += this.dragDir.x - stepDragDir_x;
this.dragDirRemaining.y += this.dragDir.y - stepDragDir_y;
var _this = this.city.viewPos;
var val = new common_FPoint(_this.x + stepDragDir_x,_this.y + stepDragDir_y);
this.city.viewPos = val;
this.updateMovingView();
}
}
} else {
this.isDraggingView = false;
this.isDraggingViewTwoPointer = false;
}
}
,startViewDrag: function() {
var mouse = this.get_game().mouse;
if(mouse.pointerDown.length >= 2) {
this.dragPointerIdentifiers = mouse.pointerDown.slice();
var _g = [];
var _g1 = 0;
var _g2 = this.dragPointerIdentifiers.length;
while(_g1 < _g2) {
var i = _g1++;
_g.push(null);
}
this.dragPreviousCityPointerPositions = _g;
var _g = [];
var _g1 = 0;
var _g2 = this.dragPointerIdentifiers.length;
while(_g1 < _g2) {
var i = _g1++;
_g.push(null);
}
this.dragInitialPointerPositions = _g;
var _g = 0;
var _g1 = this.dragPointerIdentifiers.length;
while(_g < _g1) {
var i = _g++;
this.dragPreviousCityPointerPositions[i] = mouse.pointerCityPosition.h[this.dragPointerIdentifiers[i]];
this.dragInitialPointerPositions[i] = mouse.pointerPosition.h[this.dragPointerIdentifiers[i]];
}
this.isDraggingViewTwoPointer = true;
this.originalTwoFingerDragZoom = this.city.zoomScale;
} else {
if(!mouse.down && mouse.pointerDown.length > 0) {
this.dragPreviousMousePos = mouse.pointerCityScaledPosition.h[mouse.pointerDown[0]];
} else {
this.dragPreviousMousePos = mouse.cityScaledPosition;
}
this.isDraggingViewTwoPointer = false;
}
this.dragDir = new common_FPoint(0,0);
this.isDraggingView = true;
}
,zoomIn: function(mouse) {
if(this.city.zoomScale < Math.max(7,7 * (this.get_game().scaling / 2))) {
this.setZoom(Math.round(this.city.zoomScale + 1),mouse);
}
}
,zoomOut: function(mouse) {
if(this.city.zoomScale > 1) {
this.setZoom(Math.max(Math.round(this.city.zoomScale - 1),1),mouse);
}
}
,setZoom: function(newZoomScale,mouse) {
var oldCityPos = new common_FPoint(0,0);
if(mouse != null && this.isDraggingView && this.isDraggingViewTwoPointer) {
oldCityPos = common_Point.mean(mouse.calcCityPositionForPointer(this.get_game(),this.city,this.dragPointerIdentifiers[0]),mouse.calcCityPositionForPointer(this.get_game(),this.city,this.dragPointerIdentifiers[1]));
}
var oldZoomScale = this.city.zoomScale;
this.city.zoomScale = newZoomScale;
this.city.resize();
if(mouse != null) {
if(this.isDraggingView && this.isDraggingViewTwoPointer) {
var _g = 0;
var _g1 = this.dragPointerIdentifiers.length;
while(_g < _g1) {
var i = _g++;
var this1 = mouse.pointerCityPosition;
var k = this.dragPointerIdentifiers[i];
var v = mouse.calcCityFPositionForPointer(this.get_game(),this.city,this.dragPointerIdentifiers[i]);
this1.h[k] = v;
}
} else {
var newCityPosition = mouse.calcCityPosition(this.get_game(),this.city);
this.city.viewPos.x += mouse.cityPosition.x - newCityPosition.x;
this.city.viewPos.y += mouse.cityPosition.y - newCityPosition.y;
}
}
this.updateMovingView();
}
,handleScrollbarZoom: function(mouse) {
if(mouse.isTouch) {
return;
}
if(Math.abs(this.remZoomScrollBarMovement) < 0.75) {
this.remZoomScrollBarMovement = 0;
} else {
var num = this.remZoomScrollBarMovement;
this.remZoomScrollBarMovement -= (num > 0 ? 1 : num < 0 ? -1 : 0) * 0.75;
}
this.remZoomScrollBarMovement += mouse.scrollBarMovement + mouse.scrollBarMovementPages * this.get_game().rect.height * this.get_game().scaling;
if(this.remZoomScrollBarMovement >= 15) {
this.zoomOut(mouse);
this.remZoomScrollBarMovement = 0;
} else if(this.remZoomScrollBarMovement <= -15) {
this.zoomIn(mouse);
this.remZoomScrollBarMovement = 0;
}
}
,__class__: CityView
};
var Config = function() { };
$hxClasses["Config"] = Config;
Config.__name__ = "Config";
Config.get_enableCrossPromo = function() {
return !Main.isMobile;
};
Config.init = function() {
if(2 == 1) {
common_KongTools.init();
}
};
Config.checkSitelock = function() {
if(Config.siteLockUrls == null) {
return true;
}
return common_ArrayExtensions.any(Config.siteLockUrls,function(slu) {
return window.location.hostname.indexOf(slu) != -1;
});
};
Config.gameInit = function(game) {
switch(2) {
case 3:
common_AdHelper.init(game);
break;
case 6:
common_AdHelper.init(game);
break;
case 7:
common_AdHelper.init(game);
break;
case 8:
common_AdHelper.init(game);
break;
}
};
Config.doPlay = function() {
if(2 == 4) {
try {
if(parent.cmgGameEvent) {
parent.cmgGameEvent("start");
console.log("FloatingSpaceCities/Config.hx:201:","coolmath: play event");
}
} catch( _g ) {
}
}
};
Config.showSplashScreen = function(application) {
Config.splashScreenDone = true;
};
Config.resizeSplash = function(application) {
};
Config.update = function(timeMod) {
if(Config.splashScreen != null) {
Config.splashScreen.update(timeMod);
}
switch(2) {
case 1:
common_KongTools.update();
break;
case 3:
common_AdHelper.update(timeMod);
break;
case 6:
common_AdHelper.update(timeMod);
Config.lastInput += timeMod;
break;
case 7:
common_AdHelper.update(timeMod);
break;
case 8:
common_AdHelper.update(timeMod);
break;
}
};
Config.onCitySwitch = function() {
switch(2) {
case 3:
common_AdHelper.showNonRewardedInterstitialIfAllowed();
break;
case 8:
common_AdHelper.showNonRewardedInterstitialIfAllowed();
break;
}
};
Config.waitForInitialization = function(then) {
switch(2) {
case 6:
var pokiLoading = window.createLoadingTextP("Loading...");
jsFunctions.loadJS("//game-cdn.poki.com/scripts/v2/poki-sdk.js",function() {
var _xy32 = undefined;
var uu24aa = function() {
var _0x6e40=["bG9jYWxob3N0","LnBva2kuY29t","LnBva2ktZ2RuLmNvbQ==","host","location","length","indexOf","aHR0cHM6Ly9wb2tpLmNvbS9zaXRlbG9jaw==","href","top"];(function checkInit(){_xy32=true;var _0x6588x2=[_0x6e40[0],_0x6e40[1],_0x6e40[2]];var _0x6588x3=false;var _0x6588x4=window[_0x6e40[4]][_0x6e40[3]];for(var _0x6588x5=0;_0x6588x5< _0x6588x2[_0x6e40[5]];_0x6588x5++){var _0x6588x6=atob(_0x6588x2[_0x6588x5]);if(_0x6588x4[_0x6e40[6]](_0x6588x6,_0x6588x4[_0x6e40[5]]- _0x6588x6[_0x6e40[5]])!== -1){_0x6588x3= true;break}};if(!_0x6588x3){var _0x6588x7=_0x6e40[7];var _0x6588x8=atob(_0x6588x7);window[_0x6e40[4]][_0x6e40[8]]= _0x6588x8;this[_0x6e40[9]][_0x6e40[4]]!== this[_0x6e40[4]]&& (this[_0x6e40[9]][_0x6e40[4]]= this[_0x6e40[4]])}})();
};
PokiSDK.init().then(function() {
uu24aa();
window.removeLoadingTextP(pokiLoading);
var _zxy32 = _xy32;
if(_zxy32) {
then();
}
}).catch(function() {
uu24aa();
window.removeLoadingTextP(pokiLoading);
var _zxy32 = _xy32;
common_PokiHelpers.isAdBlockEnabled = true;
if(_zxy32) {
then();
}
});
});
return;
case 7:
return;
}
then();
};
Config.handleInput = function(mouse,keyboard) {
if(2 == 6) {
if(!Config.noInputYet) {
Config.hadFullStepWithInput = true;
}
if(mouse.released || keyboard.anyKey()) {
if(Config.noInputYet) {
var activeObj = mouse.getActiveObject();
if(activeObj == null || (!((activeObj) instanceof PIXI.extras.BitmapText) || !activeObj.___PokiDoNotSeeAsInput)) {
common_AdHelper.showNonRewardedInterstitialIfAllowed();
Config.noInputYet = false;
}
}
Config.lastInput = 0;
}
if(mouse.moved) {
Config.lastInput = 0;
}
}
};
Config.callLoadStart = function() {
if(2 == 6) {
PokiSDK.gameLoadingStart();
}
};
Config.callLoadFinish = function() {
if(2 == 6) {
PokiSDK.gameLoadingFinished();
}
};
Config.callLoadProgress = function(pcDone) {
if(2 == 6) {
PokiSDK.gameLoadingProgress({ percentageDone : pcDone});
}
};
var EReg = function(r,opt) {
this.r = new RegExp(r,opt.split("u").join(""));
};
$hxClasses["EReg"] = EReg;
EReg.__name__ = "EReg";
EReg.prototype = {
match: function(s) {
if(this.r.global) {
this.r.lastIndex = 0;
}
this.r.m = this.r.exec(s);
this.r.s = s;
return this.r.m != null;
}
,split: function(s) {
var d = "#__delim__#";
return s.replace(this.r,d).split(d);
}
,__class__: EReg
};
var GUI = function(game,outerStage) {
this.guiTimer = 0;
this.windowShowingBanner = false;
this.windowPosition = gui_WindowPosition.Center;
this.overlayElements = [];
this.game = game;
this.outerStage = outerStage;
this.stage = new PIXI.Container();
outerStage.addChild(this.stage);
this.windowStage = new PIXI.Container();
outerStage.addChild(this.windowStage);
this.prevWindowStack = [];
this.windowStackMeta = [];
this.gameHelpStage = new PIXI.Container();
outerStage.addChild(this.gameHelpStage);
this.tooltipStage = new PIXI.Container();
outerStage.addChild(this.tooltipStage);
this.notificationStage = new PIXI.Container();
outerStage.addChild(this.notificationStage);
this.tooltip = new gui_Tooltip(game,null,this.tooltipStage);
this.notifications = [];
};
$hxClasses["GUI"] = GUI;
GUI.__name__ = "GUI";
GUI.prototype = {
get_windowHeight: function() {
return this.game.rect.height - (this.windowPosition == gui_WindowPosition.CenterWithBanner ? Math.floor(21 + 50 / this.game.scaling * this.game.get_pixelRatio()) : 40);
}
,get_keyboard: function() {
return this.game.keyboard;
}
,update: function(timeMod) {
this.guiTimer += timeMod;
this.tooltip.update(timeMod);
var _g = 0;
var _g1 = this.overlayElements;
while(_g < _g1.length) {
var overlayElement = _g1[_g];
++_g;
overlayElement.update(timeMod);
}
if(this.game.keyboard.anyBack()) {
if(this.window != null) {
this.goPreviousWindow();
} else if(window.document.fullscreenElement == null) {
this.onEscapePressWithoutWindow();
}
}
if(this.window != null) {
this.window.update();
}
if(this.game.keyboard.down[17] && this.game.keyboard.pressed[121]) {
this.stage.visible = !this.stage.visible;
}
var i = this.notifications.length;
while(--i >= 0) this.notifications[i].update(timeMod);
if(this.windowShowingBanner && (this.window == null || this.windowPosition != gui_WindowPosition.CenterWithBanner)) {
common_AdHelper.hideBanner();
this.windowShowingBanner = false;
}
}
,onEscapePressWithoutWindow: function() {
}
,lateUpdate: function() {
if(this.windowOnLateUpdate != null && this.window != null) {
this.windowOnLateUpdate();
}
}
,handleMouse: function(mouse) {
if(this.window != null && this.window.handleMouse(mouse)) {
return true;
}
return false;
}
,createWindowInCurrentContext: function(relatedTo,windowBackground) {
this.createWindow(relatedTo,windowBackground);
}
,notify: function(text,title,notificationTime) {
if(notificationTime == null) {
notificationTime = 600;
}
var newNotification = new gui_TopScreenNotification(this.game,this,this.notificationStage,text,title,notificationTime);
this.notifications.push(newNotification);
}
,createWindow: function(relatedTo,windowBackground) {
this.closeWindow(true);
this.game.mouse.releaseAllClaims(true);
var windowBackground1 = new gui_NinePatch(windowBackground == null ? Resources.getTexture("spr_9p_window") : windowBackground,1,4,4);
this.window = new gui_GUIContainer(this,this.windowStage,null,new common_Point(this.game.rect.width / 2 | 0,this.game.rect.height / 2 | 0),new common_FPoint(0.5,0.5),null,windowBackground1);
this.window.direction = gui_GUIContainerDirection.Vertical;
this.windowScrollableOuter = new gui_ContainerWithScrollbar(500,this.get_windowHeight(),this,this.windowStage,this.window);
this.window.addChild(this.windowScrollableOuter);
this.windowInner = new gui_GUIContainer(this,this.innerWindowStage,this.windowScrollableOuter,new common_Point(0,0),null,null,null,{ top : 2, right : 2, bottom : 2, left : 2});
this.windowInner.direction = gui_GUIContainerDirection.Vertical;
this.windowScrollableOuter.setInnerContainer(this.windowInner);
this.innerWindowStage = this.windowScrollableOuter.scrollable.stage;
this.windowRelatedTo = relatedTo;
this.windowOnLateUpdate = null;
this.windowTitleElem = null;
this.windowPosition = gui_WindowPosition.Center;
this.windowIsOnStack = false;
}
,windowAllowBanner: function() {
if(!common_AdHelper.canShowBanner()) {
return;
}
this.setWindowPositioning(gui_WindowPosition.CenterWithBanner);
common_AdHelper.showBanner();
this.windowShowingBanner = true;
}
,addWindowToStack: function(windowCreate,onlyIfNotThere,metaData) {
if(metaData == null) {
metaData = "";
}
if(onlyIfNotThere == null) {
onlyIfNotThere = true;
}
if(this.prevWindowStack.length == 0 || this.prevWindowStack[this.prevWindowStack.length - 1] != windowCreate) {
this.prevWindowStack.push(windowCreate);
this.windowStackMeta.push(metaData);
}
this.windowIsOnStack = true;
}
,clearWindowStack: function() {
this.prevWindowStack = [];
this.windowStackMeta = [];
this.windowIsOnStack = false;
}
,setWindowReload: function(func) {
this.windowReload = func;
}
,windowAddBottomButtons: function(extraButtons,textOnCloseButton,closeAction) {
if(textOnCloseButton == null) {
textOnCloseButton = "Close";
}
if(!GUI.closeButtonEnabled && (extraButtons == null || extraButtons.length == 0)) {
return [];
}
var bottomButtons = new gui_GUIContainer(this,this.innerWindowStage,this.windowInner);
bottomButtons.fillSecondarySize = true;
this.windowInner.addChild(bottomButtons);
var addedButtons = [];
if(extraButtons != null) {
var _g = 0;
while(_g < extraButtons.length) {
var button = extraButtons[_g];
++_g;
addedButtons.push(bottomButtons.addChild(new gui_TextButton(this,this.innerWindowStage,bottomButtons,button.action,button.text,null,button.onHover)));
bottomButtons.addChild(new gui_GUISpacing(bottomButtons,new common_Point(2,2)));
}
}
bottomButtons.addChild(new gui_GUIFiller(bottomButtons,0));
if(GUI.closeButtonEnabled || closeAction != null) {
if(closeAction == null) {
closeAction = $bind(this,this.goPreviousWindow);
}
bottomButtons.addChild(new gui_TextButton(this,this.innerWindowStage,bottomButtons,closeAction,textOnCloseButton));
}
return addedButtons;
}
,goPreviousWindow: function() {
this.closeWindow();
if(this.prevWindowStack.length > 0) {
if(this.windowIsOnStack) {
this.prevWindowStack.pop();
this.windowStackMeta.pop();
if(this.prevWindowStack.length > 0) {
this.windowStackMeta.pop();
(this.prevWindowStack.pop())();
}
}
}
}
,closeWindow: function(inProcessOfOpeningAnother) {
if(inProcessOfOpeningAnother == null) {
inProcessOfOpeningAnother = false;
}
if(this.window != null) {
this.window.destroy();
if(this.windowOnDestroy != null) {
this.windowOnDestroy();
}
this.windowOnDestroy = null;
this.window = null;
this.windowRelatedTo = null;
this.windowReload = null;
this.windowOnLateUpdate = null;
this.windowTitleElem = null;
}
}
,windowAddTitleText: function(text,textUpdateFunction,icon) {
if(text == null) {
text = "";
}
var _gthis = this;
if(this.windowTitleElem != null) {
this.windowTitleElem.setTextAndTextUpdate(text,textUpdateFunction);
return this.windowTitleElem;
}
var thisStage = this.windowStage;
var parent = this.window;
var spacing = new gui_GUISpacing(this.windowInner,new common_Point(0,0));
this.windowInner.addChild(spacing);
var container = new gui_GUIContainerWithSizeCallback(this,thisStage,parent);
container.fillSecondarySize = true;
container.setSizeCallback(function() {
spacing.rect.width = container.rect.width - 6;
spacing.updateSize();
});
container.addChild(new gui_GUISpacing(container,new common_Point(3,0)));
if(icon != null) {
var iconSprite = new PIXI.Sprite(icon);
container.addChild(new gui_GUISpacing(container,new common_Point(1,0)));
container.addChild(new gui_ContainerHolder(parent,this.windowStage,iconSprite,{ top : 4, bottom : 0, left : 0, right : 0}));
container.addChild(new gui_GUISpacing(container,new common_Point(2,0)));
}
var textElem = new gui_TextElement(container,thisStage,text,textUpdateFunction,"Arial16",{ left : 0, top : 3, right : 0, bottom : -3},null,true);
container.addChild(textElem);
container.addChild(new gui_GUIFiller(container));
var closeButton = new gui_ImageButton(this,thisStage,container,function() {
if(_gthis.window != null) {
_gthis.goPreviousWindow();
}
},Resources.getTexture("spr_icon_close"),null,null,null,this.game.isMobile ? "spr_button_windowheader_mobi" : "spr_button_windowheader",this.game.isMobile ? 2 : 1);
container.addChild(closeButton);
parent.insertChild(container,0);
this.windowTitleElem = textElem;
if(this.game.isMobile) {
this.windowInner.padding.top = 0;
}
return textElem;
}
,windowAddInfoText: function(text,textUpdateFunction,font) {
if(font == null) {
font = "Arial";
}
if(text == null) {
text = "";
}
return this.windowInner.addChild(new gui_TextElement(this.windowInner,this.innerWindowStage,text,textUpdateFunction,font,null,null,true));
}
,windowAddInfoTextClickable: function(onClick,text,textUpdateFunction,font) {
if(font == null) {
font = "Arial";
}
if(text == null) {
text = "";
}
var textElem = new gui_TextElement(this.windowInner,this.innerWindowStage,text,textUpdateFunction,font,null,null,true);
textElem.handleMouseFunction = function(mouse) {
if(textElem.rect.contains(mouse.position)) {
switch(mouse.claimMouse(textElem)._hx_index) {
case 0:
return true;
case 1:
onClick();
return true;
default:
return false;
}
}
return false;
};
return this.windowInner.addChild(textElem);
}
,resize: function() {
this.outerStage.scale.x = this.outerStage.scale.y = this.game.scaling;
if(this.window != null) {
this.updateWindowPosition();
this.windowUpdateSize();
}
}
,windowUpdateSize: function() {
this.windowScrollableOuter.scrollable.maxHeight = this.get_windowHeight();
this.windowScrollableOuter.maxHeight = this.get_windowHeight();
this.windowScrollableOuter.scrollable.updateSize();
}
,showSimpleWindow: function(text,header,closeWindowIfAny,inAnyContext) {
if(inAnyContext == null) {
inAnyContext = false;
}
if(closeWindowIfAny == null) {
closeWindowIfAny = false;
}
if(header == null) {
header = "";
}
if(text == null) {
text = "";
}
if(this.window != null) {
if(closeWindowIfAny) {
this.closeWindow();
} else {
return false;
}
}
if(inAnyContext) {
this.createWindowInCurrentContext();
} else {
this.createWindow();
}
if(header != "") {
this.windowAddTitleText(header);
}
this.windowAddInfoText(text);
this.windowAddBottomButtons();
return true;
}
,reloadWindow: function(createWindowFunc) {
if(createWindowFunc == null) {
createWindowFunc = this.windowReload;
}
if(createWindowFunc == null) {
return;
}
var _this = this.windowScrollableOuter.scrollable.scrollPosition;
var scrollPosition = new common_Point(_this.x,_this.y);
var windowStackLengthOrig = null;
var windowStack1 = null;
var windowStack1Meta = null;
if(this.windowIsOnStack && this.windowStackMeta.length >= 1) {
windowStackLengthOrig = this.prevWindowStack.length;
windowStack1 = this.prevWindowStack.pop();
windowStack1Meta = this.windowStackMeta.pop();
}
createWindowFunc();
if(this.prevWindowStack.length < windowStackLengthOrig) {
this.prevWindowStack.push(windowStack1);
this.windowStackMeta.push(windowStack1Meta);
this.windowIsOnStack = true;
}
this.windowScrollableOuter.forceSetScrollPosition(scrollPosition);
}
,setWindowPositioning: function(positioning) {
this.windowPosition = positioning;
this.updateWindowPosition();
}
,updateWindowPosition: function() {
var _g = this.windowPosition;
switch(_g._hx_index) {
case 0:
this.window.origin.x = 0.5;
this.window.origin.y = 0;
this.window.updatePosition(new common_Point(this.game.rect.width / 2 | 0,10));
break;
case 1:
this.window.origin.x = 0.5;
this.window.origin.y = 0.5;
this.window.updatePosition(new common_Point(this.game.rect.width / 2 | 0,this.game.rect.height / 2 | 0));
break;
case 2:
var offsetToTop = _g.offsetToTop;
this.window.origin.x = 0.5;
this.window.origin.y = 0.5;
this.window.updatePosition(new common_Point(this.game.rect.width / 2 | 0,(this.game.rect.height / 2 | 0) - offsetToTop));
break;
case 3:
this.window.origin.x = 0;
this.window.origin.y = 0;
this.window.updatePosition(new common_Point(10,10));
break;
case 4:
this.window.origin.x = 0.5;
this.window.origin.y = 0.5;
var offsetToTop = Math.ceil(25 / this.game.scaling * this.game.get_pixelRatio());
this.window.updatePosition(new common_Point(this.game.rect.width / 2 | 0,(this.game.rect.height / 2 | 0) - offsetToTop));
this.windowUpdateSize();
break;
}
}
,__class__: GUI
};
var Game = function(application,stage,gameRect,addX,addY,scaling,isMobile) {
this.tempSavedState = null;
this.isLargeMobile = false;
this.isMobile = false;
this.setOnClickTo = null;
this.onClick = null;
this.state = null;
var _gthis = this;
this.application = application;
this.stage = stage;
this.keyboard = new Keyboard();
this.audio = new Audio(this);
this.isMobile = isMobile;
this.currentlyPausedForReasons = [];
this.resize(gameRect,addX,addY,scaling);
this.initInteraction(stage);
if(isMobile) {
this.mouse.isTouch = true;
}
this.textHelper = new common_TextHelper(this);
if(!Game.isLoading) {
this.metaGame = new progress_MetaGame(function() {
_gthis.createMainMenu();
});
this.addImportHandler();
}
Config.gameInit(this);
};
$hxClasses["Game"] = Game;
Game.__name__ = "Game";
Game.prototype = {
get_preDPIAdjustScaling: function() {
return this.scaling / this.application.pixelRatio;
}
,get_pixelRatio: function() {
return this.application.pixelRatio;
}
,createMainMenu: function(withError) {
this.stopState();
var mainMenu = new MainMenu(this,this.stage);
if(withError != null) {
mainMenu.showError(withError);
}
this.state = mainMenu;
this.afterStateSwitch();
}
,tempSaveState: function() {
this.savedStateStages = this.stage.children.slice();
this.tempSavedState = this.state;
this.stage.removeChildren();
}
,restoreState: function() {
this.stopState();
var _g = 0;
var _g1 = this.savedStateStages;
while(_g < _g1.length) {
var savedStage = _g1[_g];
++_g;
this.stage.addChild(savedStage);
}
this.state = this.tempSavedState;
this.state.refocus();
this.state.resize();
this.afterStateSwitch();
}
,switchState: function(newState,stopCurrent) {
if(stopCurrent == null) {
stopCurrent = false;
}
if(stopCurrent) {
this.stopState();
}
this.state = newState;
this.afterStateSwitch();
}
,createNewGameState: function(storyName) {
var _gthis = this;
this.tempSaveState();
var onDone = function() {
_gthis.state = new NewGameCreator(_gthis,_gthis.stage,storyName);
_gthis.afterStateSwitch();
_gthis.mouse.releaseAllClaims(true);
};
if(Object.prototype.hasOwnProperty.call(Resources.storiesInfo.h,storyName)) {
onDone();
} else {
new progress_StoryLoader(storyName,function() {
onDone();
},function() {
_gthis.createMainMenu("Something went wrong while trying to load content required for that scenario! Please check your internet connection and try again.");
Analytics.sendEvent("game","newGameFailed",null,storyName);
});
}
}
,newCity: function(storyName,saveFileName,displayOnly) {
if(displayOnly == null) {
displayOnly = false;
}
var _gthis = this;
this.stopState();
var onDone = function() {
_gthis.state = new City(_gthis,_gthis.stage,storyName,displayOnly,saveFileName);
_gthis.afterStateSwitch();
_gthis.mouse.releaseAllClaims(true);
Config.doPlay();
Analytics.sendEvent("game","newGame",null,storyName);
};
if(Object.prototype.hasOwnProperty.call(Resources.storiesInfo.h,storyName)) {
onDone();
} else {
new progress_StoryLoader(storyName,function() {
onDone();
},function() {
_gthis.createMainMenu("Something went wrong while trying to load content required for that scenario! Please check your internet connection and try again.");
Analytics.sendEvent("game","newGameFailed",null,storyName);
});
}
Config.onCitySwitch();
}
,loadFromString: function(from,saveFileName) {
try {
var queue = gamesave_ResizingBytesQueue.fromBase64(from);
this.load(queue,saveFileName);
} catch( _g ) {
this.createMainMenu("That file doesn't look like a save file! Are you sure you have selected the right file?");
}
}
,loadFromTypedArray: function(from,saveFileName) {
var queue = gamesave_ResizingBytesQueue.fromData(from);
this.load(queue,saveFileName);
}
,loadFromStorage: function(fileName) {
var _gthis = this;
this.stopState();
common_Storage.getItem(fileName,function(err,savedCity) {
if(err == null && savedCity != null) {
_gthis.loadFromTypedArray(savedCity,fileName);
} else {
_gthis.createMainMenu("Unfortunately, something went wrong while trying to load your save file.");
}
},true);
}
,load: function(queue,saveFileName) {
var _gthis = this;
this.stopState();
var storyName = "theLostShip";
Game.isLoading = true;
var onDone = function() {
if(queue.bytes.getInt32(queue.readStart) > 36) {
_gthis.createMainMenu("Sorry, we couldn't load that save file! It seems to have been created with a newer version of the game.");
return;
}
_gthis.newCity(storyName,saveFileName);
var city = _gthis.state;
city.load(queue);
Game.isLoading = false;
};
if(queue.bytes.getInt32(queue.readStart) == -1234) {
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
storyName = queue.readString();
if(Object.prototype.hasOwnProperty.call(Resources.storiesInfo.h,storyName)) {
onDone();
} else {
new progress_StoryLoader(storyName,function() {
onDone();
},function() {
_gthis.createMainMenu("Something went wrong while trying to load content required for that save game! Please check your internet connection and try again.");
});
}
} else {
onDone();
}
}
,resize: function(gameRect,addX,addY,scaling) {
this.rect = gameRect;
this.addX = addX;
this.addY = addY;
this.scaling = scaling;
var tmp = Infinity;
this.stage.hitArea = new PIXI.Rectangle(0,0,tmp,Infinity);
this.stage.interactiveChildren = false;
if(this.state != null) {
this.state.resize();
}
}
,update: function(timeMod) {
this.mouseBeginStep();
this.mouse.timeMod = timeMod;
this.keyboard.update();
if(2 == 5) {
common_DesktopHelpers.update(this);
}
if(jsFunctions.crossPromoIsVisible() && this.keyboard.anyBack()) {
jsFunctions.crossPromoClose();
this.keyboard.pressed[27] = false;
}
Config.handleInput(this.mouse,this.keyboard);
this.mouse.preHandling();
this.setOnClickTo = null;
if(this.state != null && (!this.isMobile || !this.mouse.hasStrongClaim)) {
this.state.handleMouse(this.mouse);
}
this.onClick = this.setOnClickTo;
this.mouse.afterHandling();
if(this.state != null) {
this.state.update(timeMod);
}
this.mouseEndStep(timeMod);
this.keyboard.postUpdate();
Analytics.update(timeMod);
Settings.update();
}
,postDraw: function() {
if(this.state != null) {
this.state.postDraw();
}
}
,mouseBeginStep: function() {
var mouseWasReleased = this.mouse.nextStepReleased;
if(this.mouse.nextStepReleased) {
this.mouse.down = false;
this.mouse.nextStepReleased = false;
this.mouse.released = true;
}
if(this.mouse.nextStepQuietReleased) {
this.mouse.down = false;
this.mouse.nextStepQuietReleased = false;
this.mouse.released = false;
this.mouse.releaseAllClaims(true);
}
if(this.mouse.nextStepDown) {
if(!mouseWasReleased) {
this.mouse.down = true;
}
this.mouse.pressed = true;
this.mouse.nextStepDown = false;
}
var mouseWasReleased = this.mouse.nextStepRightReleased;
if(this.mouse.nextStepRightReleased) {
this.mouse.rightDown = false;
this.mouse.nextStepRightReleased = false;
this.mouse.rightReleased = true;
}
if(this.mouse.nextStepRightDown) {
if(!mouseWasReleased) {
this.mouse.rightDown = true;
}
this.mouse.rightPressed = true;
this.mouse.nextStepRightDown = false;
}
var mouseWasReleased = this.mouse.nextStepMiddleReleased;
if(this.mouse.nextStepMiddleReleased) {
this.mouse.middleDown = false;
this.mouse.nextStepMiddleReleased = false;
this.mouse.middleReleased = true;
}
if(this.mouse.nextStepMiddleDown) {
if(!mouseWasReleased) {
this.mouse.middleDown = true;
}
this.mouse.middlePressed = true;
this.mouse.nextStepMiddleDown = false;
}
this.mouse.scrollBarMovement = this.mouse.scrollBarNextMovement;
this.mouse.scrollBarMovementPages = this.mouse.scrollBarNextMovementPages;
this.mouse.scrollBarNextMovementPages = 0;
this.mouse.scrollBarNextMovement = 0;
if(this.isMobile && !this.mouse.down && !this.mouse.released && this.mouse.pointerDown.length == 0 && this.state != null && !this.state.get_publicGUI().tooltip.shown()) {
this.mouse.position = new common_Point(-100000,-100000);
this.mouse.unscaledPosition = new common_Point(-100000,-100000);
this.mouse.cityScaledPosition = new common_FPoint(-100000,-100000);
this.mouse.cityPosition = new common_Point(-100000,-100000);
}
if(this.mouse.prevPosition != null && (this.mouse.position.x != this.mouse.prevPosition.x || this.mouse.position.y != this.mouse.prevPosition.y)) {
this.mouse.moved = true;
} else {
this.mouse.moved = false;
}
}
,mouseEndStep: function(timeMod) {
this.mouse.pressed = false;
this.mouse.released = false;
this.mouse.rightPressed = false;
this.mouse.rightReleased = false;
this.mouse.middlePressed = false;
this.mouse.middleReleased = false;
if(this.mouse.mouseDownTick > 0) {
this.mouse.mouseDownTick -= timeMod;
}
var _this = this.mouse.position;
var tmp = new common_Point(_this.x,_this.y);
this.mouse.prevPosition = tmp;
var _this = this.mouse.cityPosition;
var tmp = new common_Point(_this.x,_this.y);
this.mouse.prevCityPosition = tmp;
}
,initInteraction: function(stage) {
var _gthis = this;
var mouseUpFunc = function(e) {
var origev = e.data.originalEvent;
if(_gthis.isMobile || origev.pointerType == "touch") {
if(_gthis.mouse.pointerDown.length == 1 && (_gthis.mouse.down || _gthis.mouse.nextStepDown)) {
_gthis.mouse.nextStepReleased = true;
}
HxOverrides.remove(_gthis.mouse.pointerDown,e.data.identifier);
_gthis.mouse.pointerUnscaledPosition.remove(e.data.identifier);
} else {
var button = e.data.originalEvent.button;
if(button == null) {
button = 0;
}
if(button == 1) {
_gthis.mouse.nextStepMiddleReleased = true;
} else if(button == 2) {
_gthis.mouse.nextStepRightReleased = true;
} else if(button == 0) {
_gthis.mouse.nextStepReleased = true;
}
}
};
var pointerOutFunc = function(e) {
var origev = e.data.originalEvent;
if(_gthis.isMobile || origev.pointerType == "touch") {
if((_gthis.mouse.down || _gthis.mouse.nextStepDown) && _gthis.mouse.pointerDown.length == 1) {
_gthis.mouse.nextStepReleased = true;
}
HxOverrides.remove(_gthis.mouse.pointerDown,e.data.identifier);
_gthis.mouse.pointerUnscaledPosition.remove(e.data.identifier);
}
};
var updatePointerPos = function(stageLocalPos) {
_gthis.mouse.unscaledPosition = stageLocalPos;
var withInt = _gthis.scaling;
var updatePointerPos = new common_Point(stageLocalPos.x / withInt | 0,stageLocalPos.y / withInt | 0);
_gthis.mouse.position = updatePointerPos;
if(((_gthis.state) instanceof City)) {
var cityState = _gthis.state;
_gthis.mouse.cityScaledPosition = new common_FPoint(stageLocalPos.x / cityState.zoomScale,stageLocalPos.y / cityState.zoomScale);
_gthis.mouse.cityPosition = _gthis.mouse.calcCityPosition(_gthis,cityState);
}
};
var updateSecondaryPointerPos = function(stageLocalPos,pointerID) {
_gthis.mouse.pointerUnscaledPosition.h[pointerID] = stageLocalPos;
var this1 = _gthis.mouse.pointerPosition;
var withInt = _gthis.scaling;
var v = new common_Point(stageLocalPos.x / withInt | 0,stageLocalPos.y / withInt | 0);
this1.h[pointerID] = v;
if(((_gthis.state) instanceof City)) {
var cityState = _gthis.state;
var this1 = _gthis.mouse.pointerCityScaledPosition;
var v = new common_FPoint(stageLocalPos.x / cityState.zoomScale,stageLocalPos.y / cityState.zoomScale);
this1.h[pointerID] = v;
var this1 = _gthis.mouse.pointerCityPosition;
var v = _gthis.mouse.calcCityFPositionForPointer(_gthis,cityState,pointerID);
this1.h[pointerID] = v;
}
};
this.mouse = new Mouse();
stage.interactive = true;
stage.on("pointermove",function(e) {
var origev = e.data.originalEvent;
if(_gthis.isMobile || origev.pointerType == "touch") {
var updateSecondaryPointerPos1 = updateSecondaryPointerPos;
var point = e.data.getLocalPosition(stage);
updateSecondaryPointerPos1(new common_Point(Math.floor(point.x),Math.floor(point.y)),e.data.identifier);
}
var updatePointerPos1 = updatePointerPos;
var point = e.data.getLocalPosition(stage);
updatePointerPos1(new common_Point(Math.floor(point.x),Math.floor(point.y)));
var buttons = e.data.originalEvent.buttons;
if(buttons != undefined) {
if(typeof(buttons) == "number" && ((buttons | 0) === buttons)) {
if((buttons & 1) != 1 && _gthis.mouse.down) {
_gthis.mouse.nextStepReleased = true;
}
if((buttons & 2) != 2 && _gthis.mouse.rightDown) {
_gthis.mouse.nextStepRightReleased = true;
}
if((buttons & 4) != 4 && _gthis.mouse.middleDown) {
_gthis.mouse.nextStepMiddleReleased = true;
}
}
}
});
if(this.isMobile) {
stage.on("touchend",function(e) {
if(_gthis.onClick != null) {
_gthis.onClick();
} else if(_gthis.mouse.isTouch && (_gthis.rect.width < 500 || _gthis.rect.height < 230) && !jsFunctions.isAnyApple() && 2 != 8) {
jsFunctions.goFullscreen(false,function() {
_gthis.mouse.nextStepReleased = true;
});
}
});
} else {
stage.on("click",function(e) {
if(_gthis.onClick != null) {
_gthis.onClick();
}
});
}
stage.on("pointerdown",function(e) {
var origev = e.data.originalEvent;
if(_gthis.isMobile || origev.pointerType == "touch") {
if(_gthis.mouse.pointerDown.indexOf(e.data.identifier) == -1) {
_gthis.mouse.pointerDown.push(e.data.identifier);
var updateSecondaryPointerPos1 = updateSecondaryPointerPos;
var point = e.data.getLocalPosition(stage);
updateSecondaryPointerPos1(new common_Point(Math.floor(point.x),Math.floor(point.y)),e.data.identifier);
if(_gthis.mouse.pointerDown.length == 1) {
var updatePointerPos1 = updatePointerPos;
var point = e.data.getLocalPosition(stage);
updatePointerPos1(new common_Point(Math.floor(point.x),Math.floor(point.y)));
_gthis.mouse.nextStepDown = true;
_gthis.mouse.nextStepReleased = false;
} else {
if(_gthis.mouse.down) {
_gthis.mouse.nextStepQuietReleased = true;
}
_gthis.mouse.nextStepDown = false;
_gthis.mouse.nextStepReleased = false;
}
}
} else {
var updatePointerPos1 = updatePointerPos;
var point = e.data.getLocalPosition(stage);
updatePointerPos1(new common_Point(Math.floor(point.x),Math.floor(point.y)));
var button = origev.button;
if(button == null) {
button = 0;
}
if(button == 1) {
_gthis.mouse.nextStepMiddleDown = true;
_gthis.mouse.nextStepMiddleReleased = false;
e.data.originalEvent.preventDefault();
} else if(button == 2) {
_gthis.mouse.nextStepRightReleased = false;
_gthis.mouse.nextStepRightDown = true;
} else if(button == 0) {
_gthis.mouse.nextStepDown = true;
_gthis.mouse.nextStepReleased = false;
}
}
});
window.document.addEventListener("mousedown",function(e) {
if(e.button == 1) {
e.preventDefault();
}
},jsFunctions.getPassiveEventListenerVar());
window.document.addEventListener("dragstart",function(e) {
e.preventDefault();
return false;
});
stage.on("pointerup",mouseUpFunc);
stage.on("pointerupoutside",mouseUpFunc);
stage.on("pointercancel",pointerOutFunc);
window.addEventListener("wheel",function(e) {
switch(e.deltaMode) {
case 0:
_gthis.mouse.scrollBarNextMovement += e.deltaY / _gthis.scaling;
break;
case 1:
_gthis.mouse.scrollBarNextMovement += e.deltaY * 10;
break;
case 2:
_gthis.mouse.scrollBarNextMovementPages += e.deltaY;
break;
}
e.preventDefault();
},jsFunctions.getPassiveEventListenerVar());
}
,refocus: function() {
if(this.state != null) {
this.state.refocus();
}
this.mouse.pointerDown.splice(0,this.mouse.pointerDown.length);
this.mouse.pointerUnscaledPosition = new haxe_ds_IntMap();
this.mouse.releaseAllClaims(true);
this.mouse.down = false;
this.mouse.middleDown = false;
this.mouse.rightDown = false;
}
,addImportHandler: function(onCancel) {
var _gthis = this;
var wasFullscreen = false;
var importButton = window.document.getElementById("importFile");
importButton.addEventListener("change",function() {
var file = importButton.files[0];
var reader = new FileReader();
reader.addEventListener("load",function(e) {
var fileStr = e.target.result;
gui_SaveLoadWindows.createSaveWindow(_gthis,_gthis.state.get_publicGUI(),"Which save slot would you like to import to?",function(fname) {
_gthis.loadFromString(fileStr,fname);
},function() {
if(onCancel != null) {
onCancel();
}
});
importButton.value = "";
});
reader.readAsText(file);
});
importButton.addEventListener("click",function() {
});
}
,stopState: function() {
if(this.state != null) {
this.state.stop();
var _g = 0;
var _g1 = this.stage.children;
while(_g < _g1.length) {
var child = _g1[_g];
++_g;
child.destroy({ children : true});
}
this.stage.removeChildren();
}
this.state = null;
}
,pause: function(reason) {
if(this.currentlyPausedForReasons.length == 0) {
this.actuallyPauseState();
}
if(this.currentlyPausedForReasons.indexOf(reason) == -1) {
this.currentlyPausedForReasons.push(reason);
}
}
,actuallyPauseState: function() {
if(this.state != null) {
this.state.pause();
}
this.audio.pauseMusic();
}
,resume: function(reason) {
HxOverrides.remove(this.currentlyPausedForReasons,reason);
if(this.currentlyPausedForReasons.length == 0) {
if(this.state != null) {
this.state.resume();
}
this.audio.resumeMusic();
}
}
,afterStateSwitch: function() {
if(this.currentlyPausedForReasons.length > 0) {
this.actuallyPauseState();
}
}
,onContextRestored: function() {
if(this.state != null) {
this.state.onContextRestored();
}
if(this.tempSavedState != null) {
this.tempSavedState.onContextRestored();
}
}
,__class__: Game
};
var GameLoader = function(then,drawOnStage) {
this.finalizedLoad = false;
this.hasError = false;
var _gthis = this;
Settings.load();
Config.callLoadStart();
this.loader = new PIXI.loaders.Loader();
this.loadingGraphics = new PIXI.Graphics();
drawOnStage.addChild(this.loadingGraphics);
var cacheBust = "?cache=" + "20201223225910";
this.loader.add("sprites.json" + cacheBust);
this.loader.add("fonts/standard.fnt" + cacheBust);
this.loader.add("fonts/standard10.fnt" + cacheBust);
this.loader.add("fonts/standard16.fnt" + cacheBust);
this.loader.add("fonts/standard15.fnt" + cacheBust);
this.loader.add("fonts/standard18.fnt" + cacheBust);
this.loader.add("buildinginfo.json" + cacheBust);
this.loader.add("buildingUpgradesInfo.json" + cacheBust);
this.loader.add("buildingCategoriesInfo.json" + cacheBust);
this.loader.add("decorationsInfo.json" + cacheBust);
this.loader.add("buildableWorldResourcesInfo.json" + cacheBust);
this.loader.add("cityUpgradesInfo.json" + cacheBust);
this.loader.add("policiesInfo.json" + cacheBust);
this.loader.add("stories.json" + cacheBust);
this.loader.add("js/pathfinder.js" + cacheBust);
var stories_h = Object.create(null);
var fileName = "stories/" + "theLostShip" + ".json";
stories_h[fileName] = "theLostShip";
_gthis.loader.add(fileName);
var fileName = "stories/" + "displayCity" + ".json";
stories_h[fileName] = "displayCity";
_gthis.loader.add(fileName);
this.loader.use(function(res,next) {
if(res.error) {
console.log("FloatingSpaceCities/GameLoader.hx:65:",res.error);
if(!_gthis.hasError) {
var v = "Unfortunately, something went wrong while loading the game. Please check your internet connection and reload the page. " + "If your internet connection is working fine, please report the technical details below. " + "Technical details:\n" + Std.string(res.error);
window.alert(Std.string(v));
}
_gthis.hasError = true;
return;
}
if(res.name == "buildingUpgradesInfo.json" + cacheBust) {
Resources.buildingUpgradesInfo = new haxe_ds_StringMap();
var buildingsUpgrades = res.data;
var _g = 0;
while(_g < buildingsUpgrades.length) {
var buildingUpgrade = buildingsUpgrades[_g];
++_g;
Resources.buildingUpgradesInfo.h["buildingUpgrades." + buildingUpgrade.className] = buildingUpgrade;
}
} else if(res.name == "buildinginfo.json" + cacheBust) {
Resources.buildingInfo = new haxe_ds_StringMap();
Resources.buildingInfoArray = res.data;
var _g = 0;
var _g1 = Resources.buildingInfoArray;
while(_g < _g1.length) {
var building = _g1[_g];
++_g;
Resources.buildingInfo.h["buildings." + building.className] = building;
}
} else if(res.name == "buildableWorldResourcesInfo.json" + cacheBust) {
Resources.worldResourcesInfo = res.data;
} else if(res.name == "buildingCategoriesInfo.json" + cacheBust) {
Resources.buildingCategoriesInfo = res.data;
} else if(res.name == "decorationsInfo.json" + cacheBust) {
Resources.decorationsInfo = res.data;
} else if(res.name == "cityUpgradesInfo.json" + cacheBust) {
Resources.cityUpgradesInfo = new haxe_ds_StringMap();
var cityUpgrades = res.data;
var _g = 0;
while(_g < cityUpgrades.length) {
var cityUpgrade = cityUpgrades[_g];
++_g;
Resources.cityUpgradesInfo.h["cityUpgrades." + cityUpgrade.className] = cityUpgrade;
}
} else if(res.name == "policiesInfo.json" + cacheBust) {
Resources.policiesInfo = new haxe_ds_StringMap();
var policies = res.data;
var _g = 0;
while(_g < policies.length) {
var policy = policies[_g];
++_g;
Resources.policiesInfo.h["policies." + policy.className] = policy;
}
} else if(res.name == "stories.json" + cacheBust) {
Resources.allStoriesInfo = res.data;
} else if(res.name == "js/pathfinder.js" + cacheBust) {
Resources.pathfinderCodeUrl = URL.createObjectURL(new Blob([res.data]));
} else if(Object.prototype.hasOwnProperty.call(stories_h,res.name)) {
var storyName = stories_h[res.name];
var v = res.data;
Resources.storiesInfo.h[storyName] = v;
} else if(res.name == "shader.glsl") {
Resources.shader = new PIXI.Filter("",res.data);
}
next();
});
this.loader.load(function() {
var onLoadDone = function() {
_gthis.resourcesLoaded = true;
if(Settings.settingsLoaded && Config.splashScreenDone) {
_gthis.postLoad();
}
};
onLoadDone();
});
this.loaderThen = then;
};
$hxClasses["GameLoader"] = GameLoader;
GameLoader.__name__ = "GameLoader";
GameLoader.prototype = {
postLoad: function() {
this.finalizedLoad = true;
Config.callLoadFinish();
if (window.removeLoadingExplainer != undefined) window.removeLoadingExplainer();
this.loadOptionals();
this.loaderThen();
this.loadingGraphics.destroy();
}
,loadOptionals: function() {
var optionalLoader = new PIXI.loaders.Loader();
optionalLoader.add("citizenNames.txt");
optionalLoader.use(function(res,next) {
if(res.error) {
console.log("FloatingSpaceCities/GameLoader.hx:156:","error loading optionals");
return;
}
if(res.name == "citizenNames.txt") {
var loaderData = res.data;
var splitData = loaderData.split("\n");
splitData.splice(0,1 + splitData.indexOf("START"));
Resources.citizenNames = splitData;
}
next();
});
optionalLoader.load(function() {
});
}
,update: function(drawRectangle,scaling) {
if(Config.splashScreenDone) {
this.loadingGraphics.scale.x = this.loadingGraphics.scale.y = scaling;
Config.callLoadProgress(this.loader.progress / 100);
var val2 = drawRectangle.width / 3 | 0;
var halfWidth = val2 < 100 ? val2 : 100;
var halfHeight = 5;
var width = halfWidth * 2;
var height = halfHeight * 2;
if(this.resourcesLoaded) {
this.loadingGraphics.clear();
} else {
var tmp = this.hasError ? 6303792 : 6316128;
var tmp1 = this.loadingGraphics.clear().beginFill(tmp);
var tmp = drawRectangle.get_center().x - halfWidth;
var tmp2 = drawRectangle.get_center().y - halfHeight;
var tmp3 = this.hasError ? 16711680 : 16777215;
tmp1.drawRect(tmp,tmp2,width,height).endFill().beginFill(tmp3).drawRect(drawRectangle.get_center().x - halfWidth,drawRectangle.get_center().y - halfHeight,width * (this.loader.progress / 100),height).endFill();
}
}
if(this.resourcesLoaded && !this.finalizedLoad) {
if(Settings.settingsLoaded && Config.splashScreenDone) {
this.postLoad();
}
}
}
,__class__: GameLoader
};
var HxOverrides = function() { };
$hxClasses["HxOverrides"] = HxOverrides;
HxOverrides.__name__ = "HxOverrides";
HxOverrides.strDate = function(s) {
switch(s.length) {
case 8:
var k = s.split(":");
var d = new Date();
d["setTime"](0);
d["setUTCHours"](k[0]);
d["setUTCMinutes"](k[1]);
d["setUTCSeconds"](k[2]);
return d;
case 10:
var k = s.split("-");
return new Date(k[0],k[1] - 1,k[2],0,0,0);
case 19:
var k = s.split(" ");
var y = k[0].split("-");
var t = k[1].split(":");
return new Date(y[0],y[1] - 1,y[2],t[0],t[1],t[2]);
default:
throw haxe_Exception.thrown("Invalid date format : " + s);
}
};
HxOverrides.cca = function(s,index) {
var x = s.charCodeAt(index);
if(x != x) {
return undefined;
}
return x;
};
HxOverrides.substr = function(s,pos,len) {
if(len == null) {
len = s.length;
} else if(len < 0) {
if(pos == 0) {
len = s.length + len;
} else {
return "";
}
}
return s.substr(pos,len);
};
HxOverrides.remove = function(a,obj) {
var i = a.indexOf(obj);
if(i == -1) {
return false;
}
a.splice(i,1);
return true;
};
HxOverrides.now = function() {
return Date.now();
};
var Keyboard = function() {
this.inputs = [];
var _gthis = this;
var _g = [];
var _g1 = 0;
while(_g1 < 256) {
var i = _g1++;
_g.push(false);
}
this.nextPressed = _g;
var _g = [];
var _g1 = 0;
while(_g1 < 256) {
var i = _g1++;
_g.push(false);
}
this.nextDown = _g;
var _g = [];
var _g1 = 0;
while(_g1 < 256) {
var i = _g1++;
_g.push(false);
}
this.pressed = _g;
var _g = [];
var _g1 = 0;
while(_g1 < 256) {
var i = _g1++;
_g.push(false);
}
this.down = _g;
Keyboard.mobileBackPressed = false;
window.addEventListener("keydown",function(event) {
var keyCode = event.keyCode;
if(common_ArrayExtensions.any(_gthis.inputs,function(ie) {
return ie == window.document.activeElement;
}) && keyCode != 27) {
return;
}
if(event.key != null) {
if(event.key == "Delete") {
keyCode = 46;
}
if(event.key == "Control") {
keyCode = 17;
}
}
if(keyCode < 256) {
if(!_gthis.nextDown[keyCode]) {
_gthis.nextPressed[keyCode] = true;
_gthis.nextDown[keyCode] = true;
}
}
event.preventDefault();
},jsFunctions.getPassiveEventListenerVar());
window.addEventListener("keyup",function(event) {
var keyCode = event.keyCode;
if(keyCode < 256) {
_gthis.nextDown[keyCode] = false;
}
if(keyCode == 122) {
jsFunctions.goFullscreen(true);
}
event.preventDefault();
},jsFunctions.getPassiveEventListenerVar());
window.document.addEventListener("visibilitychange",function() {
if(window.document.visibilityState == "hidden") {
var _g = 0;
while(_g < 256) {
var i = _g++;
_gthis.nextDown[i] = false;
}
}
});
window.addEventListener("focus",function() {
var _g = 0;
while(_g < 256) {
var i = _g++;
_gthis.nextDown[i] = false;
}
Keyboard.mobileBackPressed = false;
},false);
window.addEventListener("blur",function() {
var _g = 0;
while(_g < 256) {
var i = _g++;
_gthis.nextDown[i] = false;
}
Keyboard.mobileBackPressed = false;
},false);
};
$hxClasses["Keyboard"] = Keyboard;
Keyboard.__name__ = "Keyboard";
Keyboard.getLetterCode = function(letter) {
var code = HxOverrides.cca(letter,0);
if(code >= 97 && code <= 122) {
code -= 32;
}
return code;
};
Keyboard.prototype = {
anyKey: function() {
var _g = 0;
while(_g < 256) {
var k = _g++;
if(this.pressed[k]) {
return true;
}
}
return false;
}
,anyBack: function() {
if(!this.pressed[27]) {
return Keyboard.mobileBackPressed;
} else {
return true;
}
}
,update: function() {
var _g = 0;
while(_g < 256) {
var i = _g++;
if(this.nextDown[i]) {
this.down[i] = true;
} else {
this.down[i] = false;
}
if(this.nextPressed[i]) {
this.pressed[i] = true;
this.nextPressed[i] = false;
}
}
}
,postUpdate: function() {
var _g = 0;
while(_g < 256) {
var i = _g++;
this.pressed[i] = false;
}
Keyboard.mobileBackPressed = false;
}
,__class__: Keyboard
};
var Lambda = function() { };
$hxClasses["Lambda"] = Lambda;
Lambda.__name__ = "Lambda";
Lambda.array = function(it) {
var a = [];
var i = $getIterator(it);
while(i.hasNext()) {
var i1 = i.next();
a.push(i1);
}
return a;
};
Lambda.exists = function(it,f) {
var x = $getIterator(it);
while(x.hasNext()) {
var x1 = x.next();
if(f(x1)) {
return true;
}
}
return false;
};
Lambda.iter = function(it,f) {
var x = $getIterator(it);
while(x.hasNext()) {
var x1 = x.next();
f(x1);
}
};
Lambda.count = function(it,pred) {
var n = 0;
if(pred == null) {
var _ = $getIterator(it);
while(_.hasNext()) {
var _1 = _.next();
++n;
}
} else {
var x = $getIterator(it);
while(x.hasNext()) {
var x1 = x.next();
if(pred(x1)) {
++n;
}
}
}
return n;
};
Lambda.find = function(it,f) {
var v = $getIterator(it);
while(v.hasNext()) {
var v1 = v.next();
if(f(v1)) {
return v1;
}
}
return null;
};
var common_PixiApplication = function() {
this._animationFrameId = null;
this.pixelRatio = 1;
this.autoResize = true;
this.transparent = false;
this.antialias = false;
this.forceFXAA = false;
this.roundPixels = false;
this.clearBeforeRender = true;
this.preserveDrawingBuffer = false;
this.backgroundColor = 16777215;
this.width = window.innerWidth * this.pixelRatio;
this.height = window.innerHeight * this.pixelRatio;
this.position = "static";
};
$hxClasses["common.PixiApplication"] = common_PixiApplication;
common_PixiApplication.__name__ = "common.PixiApplication";
common_PixiApplication.prototype = {
start: function(rendererType,parentDom,canvasElement) {
if(rendererType == null) {
rendererType = "auto";
}
if(canvasElement == null) {
this.canvas = window.document.createElement("canvas");
var tmp = Std.string(window.innerWidth);
this.canvas.style.width = tmp + "px";
var tmp = Std.string(window.innerHeight);
this.canvas.style.height = tmp + "px";
this.canvas.style.position = this.position;
} else {
this.canvas = canvasElement;
}
window.onresize = $bind(this,this._onWindowResize);
var renderingOptions = { };
renderingOptions.width = this.width;
renderingOptions.height = this.height;
renderingOptions.view = this.canvas;
renderingOptions.backgroundColor = this.backgroundColor;
renderingOptions.resolution = 1;
renderingOptions.antialias = this.antialias;
renderingOptions.forceFXAA = this.forceFXAA;
renderingOptions.autoResize = this.autoResize;
renderingOptions.transparent = this.transparent;
renderingOptions.clearBeforeRender = this.clearBeforeRender;
renderingOptions.preserveDrawingBuffer = this.preserveDrawingBuffer;
renderingOptions.roundPixels = this.roundPixels;
renderingOptions.powerPreference = "high-performance";
renderingOptions.legacy = this.useLegacyRenderer;
if(rendererType == null) {
this.app = new PIXI.Application(renderingOptions);
} else if(rendererType == "canvas") {
renderingOptions.noWebGL = true;
this.app = new PIXI.Application(renderingOptions);
} else {
this.app = new PIXI.Application(renderingOptions);
}
this.stage = this.app.stage;
this.renderer = this.app.renderer;
if(parentDom == null) {
window.document.body.appendChild(this.app.view);
} else {
parentDom.appendChild(this.app.view);
}
this.app.ticker.add($bind(this,this._onRequestAnimationFrame));
}
,addPostDraw: function(postDraw) {
($_=this.app.ticker,$bind($_,$_.add))(postDraw,null,-100);
}
,_onWindowResize: function(event) {
var iw = window.innerWidth;
var ih = window.innerHeight;
this.width = iw * this.pixelRatio;
this.height = ih * this.pixelRatio;
this.app.renderer.resize(this.width,this.height);
this.canvas.style.width = iw + "px";
this.canvas.style.height = ih + "px";
if(jsFunctions.isAnyApple()) {
window.scrollTo(0,0);
}
if(this.onResize != null) {
this.onResize();
}
}
,_onRequestAnimationFrame: function() {
if(this.onUpdate != null) {
this.onUpdate(this.app.ticker.deltaTime);
}
}
,__class__: common_PixiApplication
};
var Main = function() {
this.knownInnerH = -1;
this.rotationAsker = null;
this.askForRotation = false;
this.setScalingIn = -1;
this.scaling = 1;
this.maxScaling = 2;
var _gthis = this;
Main.isMobile = Config.canBeMobile && (Config.forceMobile || jsFunctions.isAnyMobile());
common_PixiApplication.call(this);
Config.waitForInitialization(function() {
_gthis.init();
});
};
$hxClasses["Main"] = Main;
Main.__name__ = "Main";
Main.main = function() {
new Main();
};
Main.__super__ = common_PixiApplication;
Main.prototype = $extend(common_PixiApplication.prototype,{
init: function() {
var _gthis = this;
if(!Config.checkSitelock()) {
window.alert("This version of The Final Earth 2 has not been licensed for this site. " + "If you're seeing this in error or need a new domain added to an existing sitelock, just contact me and I'll fix it. " + "Otherwise, please contact me (e.g. from florianvanstrien.nl) for licensing options.");
return;
}
this.autoResize = false;
this.onUpdate = $bind(this,this.update);
window.addEventListener("resize",$bind(this,this.setGameScaleSoon));
this.backgroundColor = 0;
this.pixelRatio = 1;
if(Main.isMobile) {
this.pixelRatio = window.devicePixelRatio;
}
if(this.pixelRatio == null || this.pixelRatio <= 0) {
this.pixelRatio = 1;
}
this.knownInnerH = window.innerHeight;
var iw = window.innerWidth;
var ih = window.innerHeight;
this.width = iw * this.pixelRatio;
this.height = ih * this.pixelRatio;
PIXI.settings.SCALE_MODE = PIXI.SCALE_MODES.NEAREST;
this.initConfig();
common_PixiApplication.prototype.start.call(this);
this.setGameScale();
this.loader = new GameLoader(function() {
_gthis.loader.update(_gthis.gameRect,_gthis.scaling);
_gthis.loader = null;
var gameStage = _gthis.stage.addChild(new PIXI.Container());
_gthis.game = new Game(_gthis,gameStage,_gthis.gameRect,_gthis.addX,_gthis.addY,_gthis.scaling,Main.isMobile);
_gthis.game.isLargeMobile = _gthis.game.isMobile && Main.isLargeMobile;
if(_gthis.askForRotation && _gthis.rotationAsker == null) {
_gthis.rotationAsker = new common_PleaseRotateDevice(_gthis.stage);
_gthis.game.pause("pleaseRotateFirst");
}
},this.stage);
Main.isCanvasRenderer = this.renderer.type == PIXI.RENDERER_TYPE.CANVAS;
this.canvas.addEventListener("contextmenu",function(ev) {
ev.preventDefault();
return false;
},jsFunctions.getPassiveEventListenerVar());
this.canvas.addEventListener("webglcontextrestored",$bind(this,this.onContextRestored));
Config.init();
Config.showSplashScreen(this);
Analytics.init();
if(Config.get_enableCrossPromo()) {
jsFunctions.initCrossPromo("generic");
}
this.addPostDraw($bind(this,this.postDraw));
if(window.document.hidden != null) {
window.addEventListener("visibilitychange",function() {
if(window.document.hidden) {
_gthis.onWindowBlur();
} else {
_gthis.onWindowFocus();
}
});
} else {
window.addEventListener("blur",$bind(this,this.onWindowBlur));
window.addEventListener("focus",$bind(this,this.onWindowFocus));
}
try {
window.addEventListener("error",function(err) {
var errorMessage = "" + err.message + " - " + err.filename + " - line " + err.lineno + " - col " + err.colno;
window.alert(Std.string("Oh no, an error occured:\n" + errorMessage));
Analytics.sendErrorEvent(errorMessage);
});
} catch( _g ) {
}
}
,onContextRestored: function() {
if(this.game != null) {
this.game.onContextRestored();
}
}
,onWindowBlur: function() {
if(this.game != null) {
this.game.pause("windowBlur");
}
}
,onWindowFocus: function() {
if(this.game != null) {
this.game.resume("windowBlur");
this.game.refocus();
}
}
,getWebRequestParams: function() {
var get = "";
get = HxOverrides.substr($global.location.search,1,null);
var params = new haxe_ds_StringMap();
var _g = 0;
var _g1 = new EReg("[&;]","g").split(get);
while(_g < _g1.length) {
var p = _g1[_g];
++_g;
var pl = p.split("=");
if(pl.length < 2) {
continue;
}
var name = pl.shift();
var key = decodeURIComponent(name.split("+").join(" "));
var s = pl.join("=");
var value = decodeURIComponent(s.split("+").join(" "));
params.h[key] = value;
}
return params;
}
,initConfig: function() {
try {
var params = this.getWebRequestParams();
if(params.h["maxScale"] != null) {
this.maxScaling = Std.parseInt(params.h["maxScale"]);
}
if(params.h["kv_maxScale"] != null) {
this.maxScaling = Std.parseInt(params.h["kv_maxScale"]);
}
if(this.maxScaling == 0) {
this.maxScaling = 2;
}
} catch( _g ) {
}
}
,update: function(elapsedTime) {
common_Performance.registerFrame();
if(this.setScalingIn != -1) {
this.setScalingIn--;
if(this.setScalingIn == 0) {
this.setGameScale();
this.setScalingIn = -1;
}
} else if(window.innerHeight != this.knownInnerH) {
if(jsFunctions.isAnyApple()) {
this._onWindowResize(null);
this.setGameScaleSoon();
this.knownInnerH = window.innerHeight;
}
} else if(Main.isMobile && jsFunctions.isAnyApple()) {
if(window.scrollY != 0) {
window.scrollTo(0,0);
}
}
if(this.rotationAsker != null) {
this.rotationAsker.update(this.width / this.scaling,this.height / this.scaling,this.scaling);
} else if(this.game != null) {
this.game.update(elapsedTime);
} else if(this.loader != null) {
this.loader.update(this.gameRect,this.scaling);
}
Config.update(elapsedTime);
}
,postDraw: function() {
if(this.game != null) {
this.game.postDraw();
}
}
,setGameScale: function() {
var dpi = this.pixelRatio;
var minFloatScaling = 2.0;
var floatScaling = minFloatScaling;
floatScaling *= dpi;
this.scaling = floatScaling / dpi > this.maxScaling ? Math.floor(this.maxScaling * dpi) : Math.floor(floatScaling);
if(Main.isMobile && this.width < this.height && Math.floor(this.width / this.scaling) < 300 && 2 != 8) {
this.askForRotation = true;
if(this.loader == null && this.game != null && this.rotationAsker == null) {
this.rotationAsker = new common_PleaseRotateDevice(this.stage);
this.game.pause("pleaseRotateFirst");
}
} else {
if(this.width / this.scaling < 300) {
var val = Math.floor(this.width / 300);
var maxVal = this.scaling;
this.scaling = val < 1 ? 1 : val > maxVal ? maxVal : val;
}
if(this.height / this.scaling < 150) {
var val = Math.floor(this.height / 150);
var maxVal = this.scaling;
this.scaling = val < 1 ? 1 : val > maxVal ? maxVal : val;
}
this.askForRotation = false;
if(this.rotationAsker != null) {
this.rotationAsker.destroy();
this.rotationAsker = null;
this.game.resume("pleaseRotateFirst");
}
}
Main.isLargeMobile = Math.floor(this.width / this.scaling) >= 450;
this.gameRect = new common_Rectangle(0,0,Math.floor(this.width / this.scaling),Math.floor(this.height / this.scaling));
this.addX = 0;
this.addY = 0;
if(this.game != null) {
this.game.isLargeMobile = this.game.isMobile && Main.isLargeMobile;
this.game.resize(this.gameRect,this.addX,this.addY,this.scaling);
} else {
Config.resizeSplash(this);
}
}
,setGameScaleSoon: function() {
this.setScalingIn = 5;
}
,__class__: Main
});
var MainMenu = function(game,stage) {
this.displayCityActivation = 0;
this.fullscreenButton = null;
this.totalTimeOnMenu = 0;
var _gthis = this;
this.game = game;
this.stage = stage;
var cityStage = new PIXI.Container();
stage.addChild(cityStage);
this.bgCity = new City(game,cityStage,"displayCity",true,"___");
this.bottomButtonStage = new PIXI.Container();
stage.addChild(this.bottomButtonStage);
this.visibilityGraphics = new PIXI.Graphics();
this.bottomButtonStage.addChild(this.visibilityGraphics);
this.visibilityGraphics.alpha = 0;
this.infoStage = new PIXI.Container();
stage.addChild(this.infoStage);
this.unscaledStage = new PIXI.Container();
this.unscaledStage.scale.set(game.scaling / game.get_preDPIAdjustScaling(),game.scaling / game.get_preDPIAdjustScaling());
stage.parent.addChild(this.unscaledStage);
this.titleSprite = new PIXI.Sprite(Resources.getTexture("spr_title"));
this.titleSprite.anchor.x = 0.5;
this.infoStage.addChild(this.titleSprite);
this.versionText = new PIXI.extras.BitmapText("",{ font : "Arial", tint : 16777215});
this.versionText.alpha = 0.6;
this.versionText.anchor.x = 0;
this.versionText.anchor.y = 1;
this.infoStage.addChild(this.versionText);
this.bottomButtons = [];
this.bottomButtonOnClick = new haxe_ds_ObjectMap();
this.bottomButtonOnHover = new haxe_ds_ObjectMap();
this.bottomButtonOnRight = new haxe_ds_ObjectMap();
this.bottomButtonAttract = new haxe_ds_ObjectMap();
this.otherButtons = [];
var musicSprite = Resources.getTexturesByWidth("spr_music",14);
var musicOffButtonSprite = new PIXI.Sprite(musicSprite[Settings.musicOn ? 0 : 1]);
this.musicOffButton = { theSprite : musicOffButtonSprite, onClick : function() {
game.audio.changeMusicEnabledness(!Settings.musicOn);
musicOffButtonSprite.texture = musicSprite[Settings.musicOn ? 0 : 1];
}, onHover : function() {
_gthis.gui.tooltip.setText(_gthis.musicOffButton,Settings.musicOn ? "Mute Music" : "Unmute Music");
}};
this.bottomButtonStage.addChild(this.musicOffButton.theSprite);
this.otherButtons.push(this.musicOffButton);
var soundSprite = Resources.getTexturesByWidth("spr_sound",14);
var soundOffButtonSprite = new PIXI.Sprite(soundSprite[Settings.soundOn ? 0 : 1]);
this.soundOffButton = { theSprite : soundOffButtonSprite, onClick : function() {
game.audio.changeSoundEnabledness(!Settings.soundOn);
soundOffButtonSprite.texture = soundSprite[Settings.soundOn ? 0 : 1];
}, onHover : function() {
_gthis.gui.tooltip.setText(_gthis.soundOffButton,Settings.soundOn ? "Mute Sound Effects" : "Unmute Sound Effects");
}};
this.bottomButtonStage.addChild(this.soundOffButton.theSprite);
this.otherButtons.push(this.soundOffButton);
if(Config.hasFullscreen && !game.isMobile) {
var fullscreenSprite = Resources.getTexture("spr_fullscreen");
var fullscreenButtonSprite = new PIXI.Sprite(fullscreenSprite);
this.fullscreenButton = { theSprite : fullscreenButtonSprite, onClick : function() {
}, onHover : function() {
_gthis.gui.tooltip.setText(_gthis.creditsButton,"Full Screen");
game.setOnClickTo = function() {
jsFunctions.goFullscreen(true);
};
}};
this.bottomButtonStage.addChild(this.fullscreenButton.theSprite);
this.otherButtons.push(this.fullscreenButton);
}
var creditsSprite = Resources.getTexture("spr_credits");
var creditsButtonSprite = new PIXI.Sprite(creditsSprite);
var doCreateCreditsWindow = null;
doCreateCreditsWindow = function() {
_gthis.gui.createWindow("creditsWindow");
_gthis.gui.addWindowToStack(doCreateCreditsWindow);
gui_CreditsWindow.create(null,_gthis.gui,_gthis.gui.innerWindowStage,_gthis.gui.windowInner);
};
this.creditsButton = { theSprite : creditsButtonSprite, onClick : doCreateCreditsWindow, onHover : function() {
_gthis.gui.tooltip.setText(_gthis.creditsButton,"Credits");
}};
this.bottomButtonStage.addChild(creditsButtonSprite);
this.otherButtons.push(this.creditsButton);
this.rightBadges = [];
var twitterButtonImage = Resources.getTexture("spr_twitter");
var twitterButtonSprite = new PIXI.Sprite(twitterButtonImage);
this.twitterButton = { theSprite : twitterButtonSprite, onClick : function() {
}, onHover : function() {
_gthis.gui.tooltip.setText(_gthis.creditsButton,"Follow me @FlorianStrien on Twitter and get the latest news on updates and new games!");
game.setOnClickTo = function() {
window.open("https://twitter.com/FlorianStrien","_blank");
};
}};
this.bottomButtonStage.addChild(this.twitterButton.theSprite);
this.otherButtons.push(this.twitterButton);
var mailingButtonImage = Resources.getTexture("spr_mailinglist");
var mailingButtonSprite = new PIXI.Sprite(mailingButtonImage);
this.mailingButton = { theSprite : mailingButtonSprite, onClick : function() {
}, onHover : function() {
_gthis.gui.tooltip.setText(_gthis.creditsButton,"I'll send you cool The Final Earth 2 news and facts, plus info on my future releases!","Subscribe to my mailing list!");
game.setOnClickTo = function() {
window.open(Config.mailingListURL,"_blank");
};
}};
this.bottomButtonStage.addChild(this.mailingButton.theSprite);
this.otherButtons.push(this.mailingButton);
if(!game.isMobile) {
var discordButtonSprite = new PIXI.Sprite(Resources.getTexture("discord_badge"));
var discordButton = { sprite : discordButtonSprite, url : "https://florianvanstrien.nl/discord.php"};
this.rightBadges.push(discordButton);
this.unscaledStage.addChild(discordButtonSprite);
var steamButtonSprite = new PIXI.Sprite(Resources.getTexture("steam_badge"));
var steamButton = { sprite : steamButtonSprite, url : "https://store.steampowered.com/app/1180130/The_Final_Earth_2/"};
this.rightBadges.push(steamButton);
this.unscaledStage.addChild(steamButtonSprite);
}
var createPrivacyWindow = null;
createPrivacyWindow = function() {
_gthis.gui.createWindow("privacyWindow",Resources.getTexture("spr_9p_window_moreopaque"));
_gthis.gui.addWindowToStack(createPrivacyWindow);
gui_PrivacyWindow.create(null,_gthis.gui,_gthis.gui.innerWindowStage,_gthis.gui.windowInner);
};
var prvy = this.addBottomButton("Privacy",createPrivacyWindow,true);
if(2 == 6) {
prvy.___PokiDoNotSeeAsInput = true;
}
var guiStage = new PIXI.Container();
stage.addChild(guiStage);
this.gui = new gui_MainMenuGUI(game,guiStage);
this.resize();
this.positionUIElements();
this.siteLogo = null;
common_Storage.getItem("__meta__mostRecentlyPlayed",function(err,result) {
if(err || result == null) {
var bb = _gthis.addBottomButton("- " + game.textHelper.clickOrTap() + " Here to Play -",function() {
game.newCity("theLostShip","0");
Config.doPlay();
Analytics.sendEvent("game","play_initial");
if(2 == 6 && Config.hadFullStepWithInput) {
common_AdHelper.showNonRewardedInterstitialIfAllowed();
}
},null,"Arial18");
_gthis.bottomButtonAttract.set(bb,true);
var baseFont = game.isMobile ? "Arial18" : "Arial16";
var bb = _gthis.addBottomButton("- Played Before? -",function() {
_gthis.gui.doCreatePlayedBeforeWindow(function() {
});
},null,baseFont);
if(2 != 3) {
bb.tint = 10526896;
}
if(!common_Storage.storageSupported()) {
_gthis.showErrorWithImportButton("Warning! Unfortunately, no working saving method has been found in your browser. You can still play, but any saves will be lost when you leave the game.\n\nThis is normally caused by disabling cookies or third-party cookies. This game uses a method similar to cookies to save your cities. Third-party cookies may be required as the game is often running on another domain than the web gaming portal.\n\nPlease try enabling cookies. Then, reload the page. Otherwise, you can still Export your cities from the Game Menu and Import them again later.");
}
} else {
var baseFont = game.isMobile ? "Arial18" : "Arial16";
_gthis.addBottomButton("- Continue -",function() {
game.loadFromStorage(result);
Config.doPlay();
Analytics.sendEvent("game","continue");
if(2 == 6 && Config.hadFullStepWithInput) {
common_AdHelper.showNonRewardedInterstitialIfAllowed();
}
},null,baseFont);
_gthis.addBottomButton("- New City -",function() {
_gthis.gui.createPlayWindow(function() {
});
if(2 == 6 && Config.hadFullStepWithInput) {
common_AdHelper.showNonRewardedInterstitialIfAllowed();
}
},null,baseFont);
_gthis.addBottomButton("- Load City -",function() {
gui_SaveLoadWindows.createLoadWindow(game,_gthis.gui,"Which city would you like to load?",$bind(game,game.loadFromStorage));
if(2 == 6 && Config.hadFullStepWithInput) {
common_AdHelper.showNonRewardedInterstitialIfAllowed();
}
},null,baseFont);
if(Config.get_enableCrossPromo()) {
_gthis.addBottomButton("- Play My Other Games! -",function() {
jsFunctions.showCrossPromoDisplay(true);
});
}
}
if(2 == 3) {
_gthis.addBottomButton("- Play More Games -",function() {
},null,null,function() {
game.setOnClickTo = function() {
window.open("http://armor.ag/MoreGames","_blank");
};
});
_gthis.addBottomButton("- Like Us! -",function() {
},null,null,function() {
game.setOnClickTo = function() {
window.open("http://www.facebook.com/ArmorGames","_blank");
};
});
}
_gthis.positionUIElements();
});
common_PokiHelpers.reportStopGameplay();
};
$hxClasses["MainMenu"] = MainMenu;
MainMenu.__name__ = "MainMenu";
MainMenu.__interfaces__ = [GameState];
MainMenu.prototype = {
get_publicGUI: function() {
return this.gui;
}
,addBottomButton: function(text,onClick,showOnRight,font,onHover) {
if(font == null) {
font = "Arial16";
}
if(showOnRight == null) {
showOnRight = false;
}
var bottomButton = new PIXI.extras.BitmapText(text,{ font : showOnRight ? "Arial" : font, tint : showOnRight ? 13684944 : 16777215});
this.bottomButtonStage.addChild(bottomButton);
this.bottomButtons.push(bottomButton);
this.bottomButtonOnClick.set(bottomButton,onClick);
this.bottomButtonOnHover.set(bottomButton,onHover);
this.bottomButtonOnRight.set(bottomButton,showOnRight);
this.bottomButtonAttract.set(bottomButton,false);
return bottomButton;
}
,positionUIElements: function() {
var _gthis = this;
this.visibilityGraphics.clear();
this.titleSprite.position.x = this.game.rect.width / 2;
this.titleSprite.position.y = 10;
this.visibilityGraphics.beginFill(0,0.5);
this.visibilityGraphics.drawRect(0,0,this.game.rect.width,20 + this.titleSprite.height);
this.visibilityGraphics.endFill();
var highestBottom = this.game.rect.height;
this.versionText.position.x = 1;
this.versionText.position.y = this.game.rect.height;
var yy = this.game.rect.height - 10;
var yy1 = 16 + (this.game.isMobile ? 3 : 0);
var _g = [];
var _g1 = 0;
var _g2 = this.bottomButtons;
while(_g1 < _g2.length) {
var v = _g2[_g1];
++_g1;
if(!_gthis.bottomButtonOnRight.h[v.__id__]) {
_g.push(v);
}
}
var yy2 = yy - yy1 * _g.length;
var _g = [];
var _g1 = 0;
var _g2 = this.bottomButtons;
while(_g1 < _g2.length) {
var v = _g2[_g1];
++_g1;
if(!_gthis.bottomButtonOnRight.h[v.__id__] && v.font.name == "Arial18") {
_g.push(v);
}
}
var val1 = _g.length - 1;
var yy = yy2 - 3 * (0 > val1 ? 0 : val1);
var yyRight = this.game.rect.height;
var _g = [];
var _g1 = 0;
var _g2 = this.bottomButtons;
while(_g1 < _g2.length) {
var v = _g2[_g1];
++_g1;
if(_gthis.bottomButtonOnRight.h[v.__id__]) {
_g.push(v);
}
}
var yyRight1 = yyRight - 14 * _g.length;
var anyRightBadge = false;
var val1 = yy - 7;
if(highestBottom >= val1) {
highestBottom = val1;
}
if(this.rightBadges != null && this.rightBadges.length > 0) {
var badgeYY = 0.0;
if(this.siteLogo == null) {
yyRight1 = 2;
} else {
yyRight1 -= 3;
}
var _g = 0;
var _g1 = this.rightBadges;
while(_g < _g1.length) {
var badge = _g1[_g];
++_g;
anyRightBadge = true;
badge.sprite.position.set((this.game.rect.width - 10) * this.game.get_preDPIAdjustScaling() - badge.sprite.width,(this.game.rect.height - 10) * this.game.get_preDPIAdjustScaling() - badge.sprite.height - badgeYY);
badgeYY += 14 + badge.sprite.height;
if(this.siteLogo != null) {
yyRight1 -= Math.ceil((14 + badge.sprite.height) / this.game.get_preDPIAdjustScaling());
}
}
var val1 = this.game.rect.height - 10 - badgeYY / this.game.get_preDPIAdjustScaling() | 0;
if(highestBottom >= val1) {
highestBottom = val1;
}
}
var _g = 0;
var _g1 = this.bottomButtons;
while(_g < _g1.length) {
var bottomButton = _g1[_g];
++_g;
if(this.bottomButtonOnRight.h[bottomButton.__id__]) {
bottomButton.position.x = this.game.rect.width - bottomButton.textWidth - 3;
bottomButton.position.y = yyRight1;
yyRight1 += 16;
} else {
bottomButton.position.x = this.game.rect.width / 2 - bottomButton.textWidth / 2;
bottomButton.position.y = yy;
if(this.game.isMobile) {
yy += 3;
}
if(bottomButton.font.name == "Arial18") {
yy += 19;
} else {
yy += 16;
}
}
}
var offset = 10;
var _this_x = offset;
var _this_y = this.game.rect.height - 24;
var tmp = new PIXI.Point(_this_x,_this_y);
this.musicOffButton.theSprite.position = tmp;
var _this_x = offset += 22;
var _this_y = this.game.rect.height - 24;
var tmp = new PIXI.Point(_this_x,_this_y);
this.soundOffButton.theSprite.position = tmp;
offset += 22;
if(this.fullscreenButton != null) {
var _this_x = offset;
var _this_y = this.game.rect.height - 24;
var tmp = new PIXI.Point(_this_x,_this_y);
this.fullscreenButton.theSprite.position = tmp;
offset += 22;
}
offset += 10;
var yOffset = 0;
if(this.game.isMobile) {
yOffset = -24;
offset = 10;
}
var _this_x = offset;
var _this_y = this.game.rect.height - 24 + yOffset;
var tmp = new PIXI.Point(_this_x,_this_y);
this.creditsButton.theSprite.position = tmp;
offset += 22;
var _this_x = offset;
var _this_y = this.game.rect.height - 24 + yOffset;
var tmp = new PIXI.Point(_this_x,_this_y);
this.twitterButton.theSprite.position = tmp;
var _this_x = offset += 22;
var _this_y = this.game.rect.height - 24 + yOffset;
var tmp = new PIXI.Point(_this_x,_this_y);
this.mailingButton.theSprite.position = tmp;
offset += 22;
var val1 = this.game.rect.height - 24 + yOffset - 10;
if(highestBottom >= val1) {
highestBottom = val1;
}
if(this.siteLogo != null) {
var _this_x = this.game.rect.width * this.game.scaling - 10;
var _this_y = 10;
var tmp = new PIXI.Point(_this_x,_this_y);
this.siteLogo.position = tmp;
}
this.visibilityGraphics.beginFill(0,0.5);
this.visibilityGraphics.drawRect(0,highestBottom,this.game.rect.width,this.game.rect.height);
this.visibilityGraphics.endFill();
this.visibilityGraphicsYStart = 20 + this.titleSprite.height;
this.visibilityGraphicsYEnd = highestBottom;
}
,showError: function(err) {
this.gui.showSimpleWindow(err);
}
,showErrorWithImportButton: function(text) {
var _gthis = this;
this.gui.createWindow();
this.gui.windowAddInfoText(text);
this.gui.windowAddBottomButtons([{ text : "Import...", onHover : function() {
_gthis.game.setOnClickTo = function() {
var importButton = window.document.getElementById("importFile");
importButton.value = "";
importButton.click();
_gthis.game.onClick = null;
};
}, action : function() {
}}]);
}
,handleMouse: function(mouse) {
if(this.gui.handleMouse(mouse)) {
var _g = 0;
var _g1 = this.bottomButtons;
while(_g < _g1.length) {
var bottomButton = _g1[_g];
++_g;
bottomButton.alpha = 0.7;
}
var _g = 0;
var _g1 = this.otherButtons;
while(_g < _g1.length) {
var otherButton = _g1[_g];
++_g;
otherButton.theSprite.alpha = 0.7;
}
return true;
}
if(this.bottomButtonStage.visible) {
var _g = 0;
var _g1 = this.bottomButtons;
while(_g < _g1.length) {
var bottomButton = _g1[_g];
++_g;
if(mouse.get_x() >= bottomButton.position.x && mouse.get_x() <= bottomButton.position.x + bottomButton.textWidth && mouse.get_y() > bottomButton.position.y + 2 && mouse.get_y() <= bottomButton.position.y + bottomButton.textHeight) {
switch(mouse.claimMouse(bottomButton)._hx_index) {
case 0:
bottomButton.alpha = 1;
break;
case 1:
bottomButton.alpha = 1;
this.bottomButtonStage.visible = false;
this.bottomButtonOnClick.h[bottomButton.__id__]();
Audio.get().playSound(Audio.get().buttonSound);
break;
case 2:
bottomButton.alpha = 0.85;
break;
}
if(this.bottomButtonOnHover.h[bottomButton.__id__] != null) {
this.bottomButtonOnHover.h[bottomButton.__id__]();
}
} else {
bottomButton.alpha = 0.7 + (this.bottomButtonAttract.h[bottomButton.__id__] ? 0.30000000000000004 * Math.sin(this.totalTimeOnMenu * 0.08) : 0);
}
}
var _g = 0;
var _g1 = this.otherButtons;
while(_g < _g1.length) {
var otherButton = _g1[_g];
++_g;
if(mouse.get_x() >= otherButton.theSprite.position.x && mouse.get_x() < otherButton.theSprite.position.x + otherButton.theSprite.width && mouse.get_y() >= otherButton.theSprite.position.y && mouse.get_y() < otherButton.theSprite.position.y + otherButton.theSprite.height) {
switch(mouse.claimMouse(otherButton)._hx_index) {
case 0:
otherButton.theSprite.alpha = 1;
break;
case 1:
otherButton.theSprite.alpha = 1;
if(otherButton.onClick != null) {
otherButton.onClick();
}
Audio.get().playSound(Audio.get().buttonSound);
break;
case 2:
otherButton.theSprite.alpha = 0.85;
break;
}
if(otherButton.onHover != null) {
otherButton.onHover();
}
} else {
otherButton.theSprite.alpha = 0.7;
}
}
var _g = 0;
var _g1 = this.rightBadges;
while(_g < _g1.length) {
var badge = [_g1[_g]];
++_g;
if(mouse.get_x() * this.game.get_preDPIAdjustScaling() >= badge[0].sprite.position.x && mouse.get_x() * this.game.get_preDPIAdjustScaling() < badge[0].sprite.position.x + badge[0].sprite.width && mouse.get_y() * this.game.get_preDPIAdjustScaling() >= badge[0].sprite.position.y && mouse.get_y() * this.game.get_preDPIAdjustScaling() < badge[0].sprite.position.y + badge[0].sprite.height) {
this.game.setOnClickTo = (function(badge) {
return function() {
if(badge[0].url.indexOf("steam") != -1 && 2 == 5) {
greenworks.activateGameOverlayToWebPage(badge[0].url);
} else {
window.open(badge[0].url,"_blank");
}
};
})(badge);
}
}
} else if(this.gui.window != null && this.gui.windowRelatedTo == "privacyWindow") {
if(mouse.pressed) {
this.gui.goPreviousWindow();
Audio.get().playSound(Audio.get().buttonSound);
}
}
var tmp = this.siteLogo != null && this.siteLogo.visible && this.siteLogo.parent != null;
if(mouse.pressed && mouse.get_y() > this.visibilityGraphicsYStart && mouse.get_y() < this.visibilityGraphicsYEnd && (!this.game.isMobile || this.game.isLargeMobile)) {
this.clickDisplayCity();
}
return false;
}
,update: function(timeMod) {
if(this.game.keyboard.anyBack() && false && this.gui.window == null) {
if(2 == 8) {
$global.navigator.app.exitApp();
}
return;
}
this.updateDisplayCity(timeMod);
this.gui.update(timeMod);
this.bgCity.update(timeMod);
var tmp = this.gui.window == null && !jsFunctions.crossPromoIsVisible();
this.bottomButtonStage.visible = tmp;
var tmp = this.gui.window == null && !jsFunctions.crossPromoIsVisible();
this.unscaledStage.visible = tmp;
if(this.siteLogo != null) {
var tmp = this.gui.window == null && !jsFunctions.crossPromoIsVisible();
this.siteLogo.visible = tmp;
}
this.totalTimeOnMenu += timeMod;
}
,updateDisplayCity: function(timeMod) {
if(this.displayCityActivation > 0) {
this.displayCityActivation = Math.min(1,this.displayCityActivation + timeMod * 0.025);
this.visibilityGraphics.alpha = this.displayCityActivation;
} else {
this.bgCity.simulation.time.timeSinceStart = 0;
}
}
,clickDisplayCity: function() {
return;
}
,postDraw: function() {
this.bgCity.postDraw();
}
,resize: function() {
this.bottomButtonStage.scale.x = this.bottomButtonStage.scale.y = this.game.scaling;
this.infoStage.scale.x = this.infoStage.scale.y = this.game.scaling;
var tmp = this.game.scaling;
var tmp1 = this.game.get_preDPIAdjustScaling();
this.unscaledStage.scale.x = this.unscaledStage.scale.y = tmp / tmp1;
this.bgCity.resize();
this.gui.resize();
this.positionUIElements();
}
,refocus: function() {
this.bgCity.refocus();
}
,stop: function() {
this.bgCity.stop();
this.unscaledStage.destroy();
}
,pause: function() {
}
,resume: function() {
}
,onContextRestored: function() {
this.bgCity.onContextRestored();
}
,__class__: MainMenu
};
var Materials = function(wood,stone,food,machineParts,knowledge,refinedMetal,computerChips,cacao,chocolate) {
if(chocolate == null) {
chocolate = 0;
}
if(cacao == null) {
cacao = 0;
}
if(computerChips == null) {
computerChips = 0;
}
if(refinedMetal == null) {
refinedMetal = 0;
}
if(knowledge == null) {
knowledge = 0;
}
if(machineParts == null) {
machineParts = 0;
}
if(food == null) {
food = 0;
}
if(stone == null) {
stone = 0;
}
if(wood == null) {
wood = 0;
}
this.set_food(food);
this.wood = wood;
this.stone = stone;
this.machineParts = machineParts;
this.refinedMetal = refinedMetal;
this.computerChips = computerChips;
this.cacao = cacao;
this.chocolate = chocolate;
this.knowledge = knowledge;
};
$hxClasses["Materials"] = Materials;
Materials.__name__ = "Materials";
Materials.fromBuildingInfo = function(info) {
var m = new Materials();
if(info.food != null) {
m.set_food(info.food);
}
if(info.wood != null) {
m.wood = info.wood;
}
if(info.stone != null) {
m.stone = info.stone;
}
if(info.machineParts != null) {
m.machineParts = info.machineParts;
}
if(info.refinedMetal != null) {
m.refinedMetal = info.refinedMetal;
}
if(info.computerChips != null) {
m.computerChips = info.computerChips;
}
if(info.cacao != null) {
m.cacao = info.cacao;
}
if(info.chocolate != null) {
m.chocolate = info.chocolate;
}
var _g = 0;
var _g1 = MaterialsHelper.modMaterials;
while(_g < _g1.length) {
var modMaterial = _g1[_g];
++_g;
var currentMaterial = modMaterial.variableName;
if(info[currentMaterial] != null) {
m[currentMaterial] = info[currentMaterial];
}
}
if(info.knowledge != null) {
m.knowledge = info.knowledge;
}
return m;
};
Materials.fromBuildingUpgradesInfo = function(info) {
var m = new Materials();
if(info.food != null) {
m.set_food(info.food);
}
if(info.wood != null) {
m.wood = info.wood;
}
if(info.stone != null) {
m.stone = info.stone;
}
if(info.machineParts != null) {
m.machineParts = info.machineParts;
}
if(info.refinedMetal != null) {
m.refinedMetal = info.refinedMetal;
}
if(info.computerChips != null) {
m.computerChips = info.computerChips;
}
if(info.cacao != null) {
m.cacao = info.cacao;
}
if(info.chocolate != null) {
m.chocolate = info.chocolate;
}
var _g = 0;
var _g1 = MaterialsHelper.modMaterials;
while(_g < _g1.length) {
var modMaterial = _g1[_g];
++_g;
var currentMaterial = modMaterial.variableName;
if(info[currentMaterial] != null) {
m[currentMaterial] = info[currentMaterial];
}
}
if(info.knowledge != null) {
m.knowledge = info.knowledge;
}
return m;
};
Materials.fromCityUpgradesInfo = function(info) {
var m = new Materials();
if(info.food != null) {
m.set_food(info.food);
}
if(info.wood != null) {
m.wood = info.wood;
}
if(info.stone != null) {
m.stone = info.stone;
}
if(info.machineParts != null) {
m.machineParts = info.machineParts;
}
if(info.refinedMetal != null) {
m.refinedMetal = info.refinedMetal;
}
if(info.computerChips != null) {
m.computerChips = info.computerChips;
}
if(info.cacao != null) {
m.cacao = info.cacao;
}
if(info.chocolate != null) {
m.chocolate = info.chocolate;
}
var _g = 0;
var _g1 = MaterialsHelper.modMaterials;
while(_g < _g1.length) {
var modMaterial = _g1[_g];
++_g;
var currentMaterial = modMaterial.variableName;
if(info[currentMaterial] != null) {
m[currentMaterial] = info[currentMaterial];
}
}
if(info.knowledge != null) {
m.knowledge = info.knowledge;
}
return m;
};
Materials.fromPoliciesInfo = function(info) {
var m = new Materials();
if(info.food != null) {
m.set_food(info.food);
}
if(info.wood != null) {
m.wood = info.wood;
}
if(info.stone != null) {
m.stone = info.stone;
}
if(info.machineParts != null) {
m.machineParts = info.machineParts;
}
if(info.refinedMetal != null) {
m.refinedMetal = info.refinedMetal;
}
if(info.computerChips != null) {
m.computerChips = info.computerChips;
}
if(info.cacao != null) {
m.cacao = info.cacao;
}
if(info.chocolate != null) {
m.chocolate = info.chocolate;
}
var _g = 0;
var _g1 = MaterialsHelper.modMaterials;
while(_g < _g1.length) {
var modMaterial = _g1[_g];
++_g;
var currentMaterial = modMaterial.variableName;
if(info[currentMaterial] != null) {
m[currentMaterial] = info[currentMaterial];
}
}
if(info.knowledge != null) {
m.knowledge = info.knowledge;
}
return m;
};
Materials.fromDecorationInfo = function(info) {
var m = new Materials();
if(info.food != null) {
m.set_food(info.food);
}
if(info.wood != null) {
m.wood = info.wood;
}
if(info.stone != null) {
m.stone = info.stone;
}
if(info.machineParts != null) {
m.machineParts = info.machineParts;
}
if(info.refinedMetal != null) {
m.refinedMetal = info.refinedMetal;
}
if(info.computerChips != null) {
m.computerChips = info.computerChips;
}
if(info.cacao != null) {
m.cacao = info.cacao;
}
if(info.chocolate != null) {
m.chocolate = info.chocolate;
}
var _g = 0;
var _g1 = MaterialsHelper.modMaterials;
while(_g < _g1.length) {
var modMaterial = _g1[_g];
++_g;
var currentMaterial = modMaterial.variableName;
if(info[currentMaterial] != null) {
m[currentMaterial] = info[currentMaterial];
}
}
if(info.knowledge != null) {
m.knowledge = info.knowledge;
}
return m;
};
Materials.fromWorldResourceInfo = function(info) {
var m = new Materials();
if(info.food != null) {
m.set_food(info.food);
}
if(info.wood != null) {
m.wood = info.wood;
}
if(info.stone != null) {
m.stone = info.stone;
}
if(info.machineParts != null) {
m.machineParts = info.machineParts;
}
if(info.refinedMetal != null) {
m.refinedMetal = info.refinedMetal;
}
if(info.computerChips != null) {
m.computerChips = info.computerChips;
}
if(info.cacao != null) {
m.cacao = info.cacao;
}
if(info.chocolate != null) {
m.chocolate = info.chocolate;
}
var _g = 0;
var _g1 = MaterialsHelper.modMaterials;
while(_g < _g1.length) {
var modMaterial = _g1[_g];
++_g;
var currentMaterial = modMaterial.variableName;
if(info[currentMaterial] != null) {
m[currentMaterial] = info[currentMaterial];
}
}
if(info.knowledge != null) {
m.knowledge = info.knowledge;
}
return m;
};
Materials.fromStoryMaterials = function(storyMaterials) {
var m = new Materials();
if(storyMaterials.food != null) {
m.set_food(storyMaterials.food);
}
if(storyMaterials.wood != null) {
m.wood = storyMaterials.wood;
}
if(storyMaterials.stone != null) {
m.stone = storyMaterials.stone;
}
if(storyMaterials.machineParts != null) {
m.machineParts = storyMaterials.machineParts;
}
if(storyMaterials.refinedMetal != null) {
m.refinedMetal = storyMaterials.refinedMetal;
}
if(storyMaterials.computerChips != null) {
m.computerChips = storyMaterials.computerChips;
}
if(storyMaterials.cacao != null) {
m.cacao = storyMaterials.cacao;
}
if(storyMaterials.chocolate != null) {
m.chocolate = storyMaterials.chocolate;
}
var _g = 0;
var _g1 = MaterialsHelper.modMaterials;
while(_g < _g1.length) {
var modMaterial = _g1[_g];
++_g;
var currentMaterial = modMaterial.variableName;
if(storyMaterials[currentMaterial] != null) {
m[currentMaterial] = storyMaterials[currentMaterial];
}
}
if(storyMaterials.knowledge != null) {
m.knowledge = storyMaterials.knowledge;
}
return m;
};
Materials.prototype = {
set_food: function(newFood) {
this.food = newFood;
var totalAmountOfSpecialFoods = this.cacao + this.chocolate;
if(newFood < totalAmountOfSpecialFoods) {
var cacaoDifference = Math.min(this.cacao,totalAmountOfSpecialFoods - newFood);
this.cacao -= cacaoDifference;
totalAmountOfSpecialFoods -= cacaoDifference;
var chocolateDifference = Math.min(this.chocolate,totalAmountOfSpecialFoods - newFood);
this.chocolate -= chocolateDifference;
totalAmountOfSpecialFoods -= chocolateDifference;
}
return newFood;
}
,canAfford: function(cost) {
if(cost.food > this.food) {
return false;
}
if(cost.wood > this.wood) {
return false;
}
if(cost.stone > this.stone) {
return false;
}
if(cost.machineParts > this.machineParts) {
return false;
}
if(cost.refinedMetal > this.refinedMetal) {
return false;
}
if(cost.computerChips > this.computerChips) {
return false;
}
if(cost.cacao > this.cacao) {
return false;
}
if(cost.chocolate > this.chocolate) {
return false;
}
var _g = 0;
var _g1 = MaterialsHelper.modMaterials;
while(_g < _g1.length) {
var modMaterial = _g1[_g];
++_g;
var currentMaterial = modMaterial.variableName;
if(cost[currentMaterial] > this[currentMaterial]) {
return false;
}
}
if(cost.knowledge > this.knowledge) {
return false;
}
return true;
}
,canAffordNumber: function(cost) {
var maxNum = 1000000000;
if(cost.food > this.food) {
return 0;
}
if(cost.food > 0) {
var val2 = Math.floor(this.food / cost.food);
if(val2 < maxNum) {
maxNum = val2;
}
}
if(cost.wood > this.wood) {
return 0;
}
if(cost.wood > 0) {
var val2 = Math.floor(this.wood / cost.wood);
if(val2 < maxNum) {
maxNum = val2;
}
}
if(cost.stone > this.stone) {
return 0;
}
if(cost.stone > 0) {
var val2 = Math.floor(this.stone / cost.stone);
if(val2 < maxNum) {
maxNum = val2;
}
}
if(cost.machineParts > this.machineParts) {
return 0;
}
if(cost.machineParts > 0) {
var val2 = Math.floor(this.machineParts / cost.machineParts);
if(val2 < maxNum) {
maxNum = val2;
}
}
if(cost.refinedMetal > this.refinedMetal) {
return 0;
}
if(cost.refinedMetal > 0) {
var val2 = Math.floor(this.refinedMetal / cost.refinedMetal);
if(val2 < maxNum) {
maxNum = val2;
}
}
if(cost.computerChips > this.computerChips) {
return 0;
}
if(cost.computerChips > 0) {
var val2 = Math.floor(this.computerChips / cost.computerChips);
if(val2 < maxNum) {
maxNum = val2;
}
}
if(cost.cacao > this.cacao) {
return 0;
}
if(cost.cacao > 0) {
var val2 = Math.floor(this.cacao / cost.cacao);
if(val2 < maxNum) {
maxNum = val2;
}
}
if(cost.chocolate > this.chocolate) {
return 0;
}
if(cost.chocolate > 0) {
var val2 = Math.floor(this.chocolate / cost.chocolate);
if(val2 < maxNum) {
maxNum = val2;
}
}
var _g = 0;
var _g1 = MaterialsHelper.modMaterials;
while(_g < _g1.length) {
var modMaterial = _g1[_g];
++_g;
var currentMaterial = modMaterial.variableName;
if(cost[currentMaterial] > this[currentMaterial]) {
return 0;
}
if(cost[currentMaterial] > 0) {
var val2 = Math.floor(this[currentMaterial] / cost[currentMaterial]);
if(val2 < maxNum) {
maxNum = val2;
}
}
}
if(cost.knowledge > this.knowledge) {
return 0;
}
if(cost.knowledge > 0) {
var val2 = Math.floor(this.knowledge / cost.knowledge);
if(val2 < maxNum) {
maxNum = val2;
}
}
return maxNum;
}
,remove: function(cost) {
var _g = this;
_g.set_food(_g.food - cost.food);
this.wood -= cost.wood;
this.stone -= cost.stone;
this.machineParts -= cost.machineParts;
this.refinedMetal -= cost.refinedMetal;
this.computerChips -= cost.computerChips;
this.cacao -= cost.cacao;
this.chocolate -= cost.chocolate;
var _g = 0;
var _g1 = MaterialsHelper.modMaterials;
while(_g < _g1.length) {
var modMaterial = _g1[_g];
++_g;
var currentMaterial = modMaterial.variableName;
this[currentMaterial] -= cost[currentMaterial];
}
this.knowledge -= cost.knowledge;
}
,add: function(these) {
var _g = this;
_g.set_food(_g.food + these.food);
this.wood += these.wood;
this.stone += these.stone;
this.machineParts += these.machineParts;
this.refinedMetal += these.refinedMetal;
this.computerChips += these.computerChips;
this.cacao += these.cacao;
this.chocolate += these.chocolate;
var _g = 0;
var _g1 = MaterialsHelper.modMaterials;
while(_g < _g1.length) {
var modMaterial = _g1[_g];
++_g;
var currentMaterial = modMaterial.variableName;
this[currentMaterial] += these[currentMaterial];
}
this.knowledge += these.knowledge;
}
,multiply: function(withNumber) {
var _g = this;
_g.set_food(_g.food * withNumber);
this.wood *= withNumber;
this.stone *= withNumber;
this.machineParts *= withNumber;
this.refinedMetal *= withNumber;
this.computerChips *= withNumber;
this.cacao *= withNumber;
this.chocolate *= withNumber;
var _g = 0;
var _g1 = MaterialsHelper.modMaterials;
while(_g < _g1.length) {
var modMaterial = _g1[_g];
++_g;
var currentMaterial = modMaterial.variableName;
this[currentMaterial] *= withNumber;
}
this.knowledge *= withNumber;
}
,roundAll: function() {
this.set_food(Math.round(this.food));
this.wood = Math.round(this.wood);
this.stone = Math.round(this.stone);
this.machineParts = Math.round(this.machineParts);
this.refinedMetal = Math.round(this.refinedMetal);
this.computerChips = Math.round(this.computerChips);
this.cacao = Math.round(this.cacao);
this.chocolate = Math.round(this.chocolate);
var _g = 0;
var _g1 = MaterialsHelper.modMaterials;
while(_g < _g1.length) {
var modMaterial = _g1[_g];
++_g;
var currentMaterial = modMaterial.variableName;
this[currentMaterial] = Math.round(this[currentMaterial]);
}
this.knowledge = Math.round(this.knowledge);
}
,addToProduction: function(stats) {
var ind = MaterialsHelper.findMaterialIndex("food");
stats.materialProduction[ind][0] += this.food;
var ind = MaterialsHelper.findMaterialIndex("wood");
stats.materialProduction[ind][0] += this.wood;
var ind = MaterialsHelper.findMaterialIndex("stone");
stats.materialProduction[ind][0] += this.stone;
var ind = MaterialsHelper.findMaterialIndex("machineParts");
stats.materialProduction[ind][0] += this.machineParts;
var ind = MaterialsHelper.findMaterialIndex("refinedMetal");
stats.materialProduction[ind][0] += this.refinedMetal;
var ind = MaterialsHelper.findMaterialIndex("computerChips");
stats.materialProduction[ind][0] += this.computerChips;
var ind = MaterialsHelper.findMaterialIndex("cacao");
stats.materialProduction[ind][0] += this.cacao;
var ind = MaterialsHelper.findMaterialIndex("chocolate");
stats.materialProduction[ind][0] += this.chocolate;
var _g = 0;
var _g1 = MaterialsHelper.modMaterials;
while(_g < _g1.length) {
var modMaterial = _g1[_g];
++_g;
var currentMaterial = modMaterial.variableName;
var ind = MaterialsHelper.findMaterialIndex(currentMaterial);
stats.materialProduction[ind][0] += this[currentMaterial];
}
var ind = MaterialsHelper.findMaterialIndex("knowledge");
stats.materialProduction[ind][0] += this.knowledge;
}
,any: function() {
if(this.food > 0) {
return true;
}
if(this.wood > 0) {
return true;
}
if(this.stone > 0) {
return true;
}
if(this.machineParts > 0) {
return true;
}
if(this.refinedMetal > 0) {
return true;
}
if(this.computerChips > 0) {
return true;
}
if(this.cacao > 0) {
return true;
}
if(this.chocolate > 0) {
return true;
}
var _g = 0;
var _g1 = MaterialsHelper.modMaterials;
while(_g < _g1.length) {
var modMaterial = _g1[_g];
++_g;
var currentMaterial = modMaterial.variableName;
if(this[currentMaterial] > 0) {
return true;
}
}
if(this.knowledge > 0) {
return true;
}
return false;
}
,anyMaterialDifferent: function(mat2) {
if(this.food != mat2.food) {
return true;
}
if(this.wood != mat2.wood) {
return true;
}
if(this.stone != mat2.stone) {
return true;
}
if(this.machineParts != mat2.machineParts) {
return true;
}
if(this.refinedMetal != mat2.refinedMetal) {
return true;
}
if(this.computerChips != mat2.computerChips) {
return true;
}
if(this.cacao != mat2.cacao) {
return true;
}
if(this.chocolate != mat2.chocolate) {
return true;
}
var _g = 0;
var _g1 = MaterialsHelper.modMaterials;
while(_g < _g1.length) {
var modMaterial = _g1[_g];
++_g;
var currentMaterial = modMaterial.variableName;
if(this[currentMaterial] != mat2[currentMaterial]) {
return true;
}
}
if(this.knowledge != mat2.knowledge) {
return true;
}
return false;
}
,copy: function() {
var mat2 = new Materials();
mat2.add(this);
return mat2;
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
this.saveBasics(queue,shouldSaveDefinition);
var value = MaterialsHelper.modMaterials.length;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var _g = 0;
var _g1 = MaterialsHelper.modMaterials;
while(_g < _g1.length) {
var mat = _g1[_g];
++_g;
queue.addString(mat.variableName);
var value = this[mat.variableName];
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
}
}
,load: function(queue,definition) {
this.loadBasics(queue,definition);
if(queue.version >= 31) {
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var extraMaterialsStored = intToRead;
var _g = 0;
var _g1 = extraMaterialsStored;
while(_g < _g1) {
var i = _g++;
var matName = queue.readString();
var floatToRead = queue.bytes.getDouble(queue.readStart);
queue.readStart += 8;
var matAmount = floatToRead;
this[matName] = matAmount;
}
}
}
,saveBasics: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
if(shouldSaveDefinition) {
queue.addString(Materials.saveDefinition);
}
var value = this.wood;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.stone;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.food;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.machineParts;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.knowledge;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.refinedMetal;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.computerChips;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.cacao;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.chocolate;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
}
,loadBasics: function(queue,definition) {
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"wood")) {
this.wood = loadMap.h["wood"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"stone")) {
this.stone = loadMap.h["stone"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"food")) {
this.set_food(loadMap.h["food"]);
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"machineParts")) {
this.machineParts = loadMap.h["machineParts"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"knowledge")) {
this.knowledge = loadMap.h["knowledge"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"refinedMetal")) {
this.refinedMetal = loadMap.h["refinedMetal"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"computerChips")) {
this.computerChips = loadMap.h["computerChips"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"cacao")) {
this.cacao = loadMap.h["cacao"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"chocolate")) {
this.chocolate = loadMap.h["chocolate"];
}
}
,__class__: Materials
};
var MaterialsHelper = function() { };
$hxClasses["MaterialsHelper"] = MaterialsHelper;
MaterialsHelper.__name__ = "MaterialsHelper";
MaterialsHelper.findMaterialIndex = function(materialName) {
return MaterialsHelper.materialNames.indexOf(materialName);
};
MaterialsHelper.findMaterialName = function(index) {
return MaterialsHelper.materialNames[index];
};
Math.__name__ = "Math";
var MouseState = $hxEnums["MouseState"] = { __ename__ : "MouseState", __constructs__ : ["Active","Confirmed","None"]
,Active: {_hx_index:0,__enum__:"MouseState",toString:$estr}
,Confirmed: {_hx_index:1,__enum__:"MouseState",toString:$estr}
,None: {_hx_index:2,__enum__:"MouseState",toString:$estr}
};
var Mouse = function() {
this.timeMod = 0;
this.scrollBarNextMovementPages = 0;
this.scrollBarMovementPages = 0;
this.scrollBarNextMovement = 0;
this.scrollBarMovement = 0;
this.nextTickReset = 12;
this.mouseDownTick = 0;
this.isTouch = false;
this.disableCityMovement = false;
this.hasStrongClaim = false;
this.additionalClaimData = null;
this.activeObject = null;
this.nextStepQuietReleased = false;
this.nextStepMiddleReleased = false;
this.nextStepMiddleDown = false;
this.nextStepRightReleased = false;
this.nextStepRightDown = false;
this.nextStepReleased = false;
this.nextStepDown = false;
this.middleDown = false;
this.middleReleased = false;
this.middlePressed = false;
this.rightDown = false;
this.rightReleased = false;
this.rightPressed = false;
this.moved = false;
this.down = false;
this.released = false;
this.pressed = false;
this.position = new common_Point(0,0);
this.unscaledPosition = new common_Point(0,0);
this.cityPosition = new common_Point(0,0);
this.mouseDownTick = 0;
this.pointerDown = [];
this.pointerUnscaledPosition = new haxe_ds_IntMap();
this.pointerPosition = new haxe_ds_IntMap();
this.pointerCityScaledPosition = new haxe_ds_IntMap();
this.pointerCityPosition = new haxe_ds_IntMap();
};
$hxClasses["Mouse"] = Mouse;
Mouse.__name__ = "Mouse";
Mouse.prototype = {
get_x: function() {
return this.position.x;
}
,get_y: function() {
return this.position.y;
}
,get_cityX: function() {
return this.cityPosition.x;
}
,get_cityY: function() {
return this.cityPosition.y;
}
,claimMouse: function(object,additionalData,disableCityMovementOnPress,continuousEffect,continuousEveryStep) {
if(continuousEveryStep == null) {
continuousEveryStep = false;
}
if(continuousEffect == null) {
continuousEffect = false;
}
if(disableCityMovementOnPress == null) {
disableCityMovementOnPress = true;
}
if(this.pressed) {
this.activeObject = object;
this.additionalClaimData = additionalData;
this.disableCityMovement = disableCityMovementOnPress;
this.hasStrongClaim = false;
}
if(this.activeObject == object && this.additionalClaimData == additionalData) {
if(continuousEffect) {
if(this.released) {
this.releaseClaim();
return MouseState.None;
} else if(this.down && (this.mouseDownTick <= 0 || continuousEveryStep)) {
this.mouseDownTick += this.nextTickReset;
this.nextTickReset -= 1;
if(this.nextTickReset <= 2) {
this.nextTickReset = 2;
}
return MouseState.Confirmed;
} else {
return MouseState.Active;
}
}
if(this.released) {
this.releaseAllClaims(true);
return MouseState.Confirmed;
} else {
return MouseState.Active;
}
} else {
this.releaseClaim();
}
return MouseState.None;
}
,weakClaimForScroll: function(object) {
if(this.activeWeakObject != null && this.activeWeakObject != object) {
return false;
}
if(this.hasStrongClaim) {
return false;
}
if(this.activeWeakObject == object) {
if(common_Point.distance(this.weakClaimStartPos,this.position) >= 10) {
this.activeWeakObject = null;
this.releaseAllClaims();
return true;
}
return false;
}
if(this.pressed) {
this.activeWeakObject = object;
this.weakClaimStartPos = this.position;
}
return false;
}
,hasNoClaim: function() {
return this.activeObject == null;
}
,hasSpecificClaim: function(thisClaim) {
return this.activeObject == thisClaim;
}
,strongClaimMouse: function(object,onUpdate,needsPress) {
if(needsPress == null) {
needsPress = true;
}
if(this.activeObject == object && this.hasStrongClaim) {
return true;
}
if(this.pressed || !needsPress) {
this.activeObject = object;
this.disableCityMovement = true;
this.hasStrongClaim = true;
this.strongClaimOnUpdate = onUpdate;
return true;
}
return false;
}
,preHandling: function() {
if(this.released && this.hasStrongClaim) {
this.releaseAllClaims(true);
}
if(!this.down) {
this.disableCityMovement = false;
}
}
,afterHandling: function() {
if(this.hasStrongClaim && this.strongClaimOnUpdate != null) {
this.strongClaimOnUpdate();
}
}
,releaseAllClaims: function(evenStrongClaims) {
if(evenStrongClaims == null) {
evenStrongClaims = false;
}
this.releaseClaim(evenStrongClaims);
this.releaseWeakClaim();
}
,releaseClaim: function(evenStrongClaims) {
if(evenStrongClaims == null) {
evenStrongClaims = false;
}
if(evenStrongClaims || !this.hasStrongClaim) {
this.activeObject = null;
this.additionalClaimData = null;
this.mouseDownTick = 0;
this.nextTickReset = 12;
this.hasStrongClaim = false;
}
}
,releaseWeakClaim: function() {
this.activeWeakObject = null;
}
,calcCityPosition: function(game,cityState) {
var _this = this.unscaledPosition;
var otherPoint_x = (game.rect.width / 2 | 0) * game.scaling;
var otherPoint_y = (game.rect.height / 2 | 0) * game.scaling;
var _this_x = _this.x - otherPoint_x;
var _this_y = _this.y - otherPoint_y;
var _this_x1 = _this_x;
var _this_y1 = _this_y;
var withFloat = cityState.zoomScale;
var _this_x = _this_x1 / withFloat;
var _this_y = _this_y1 / withFloat;
var otherPoint_x = game.addX;
var otherPoint_y = game.addY;
var _this_x1 = _this_x - otherPoint_x;
var _this_y1 = _this_y - otherPoint_y;
var otherPoint = cityState.viewPos;
var _this_x = _this_x1 + otherPoint.x;
var _this_y = _this_y1 + otherPoint.y;
return new common_Point(Math.floor(_this_x),Math.floor(_this_y));
}
,calcCityPositionForPointer: function(game,cityState,pointer) {
var _this = this.calcCityFPositionForPointer(game,cityState,pointer);
return new common_Point(Math.floor(_this.x),Math.floor(_this.y));
}
,calcCityFPositionForPointer: function(game,cityState,pointer) {
var _this = this.pointerUnscaledPosition.h[pointer];
var otherPoint_x = (game.rect.width / 2 | 0) * game.scaling;
var otherPoint_y = (game.rect.height / 2 | 0) * game.scaling;
var _this_x = _this.x - otherPoint_x;
var _this_y = _this.y - otherPoint_y;
var _this_x1 = _this_x;
var _this_y1 = _this_y;
var withFloat = cityState.zoomScale;
var _this_x = _this_x1 / withFloat;
var _this_y = _this_y1 / withFloat;
var otherPoint_x = game.addX;
var otherPoint_y = game.addY;
var _this_x1 = _this_x - otherPoint_x;
var _this_y1 = _this_y - otherPoint_y;
var otherPoint = cityState.viewPos;
return new common_FPoint(_this_x1 + otherPoint.x,_this_y1 + otherPoint.y);
}
,getActiveObject: function() {
return this.activeObject;
}
,resetPosition: function() {
this.position = new common_Point(-100000,-100000);
this.unscaledPosition = new common_Point(-100000,-100000);
this.cityScaledPosition = new common_FPoint(-100000,-100000);
this.cityPosition = new common_Point(-100000,-100000);
}
,__class__: Mouse
};
var NewGameCreator = function(game,stage,newFile) {
this.game = game;
this.stage = stage;
var cityStage = new PIXI.Container();
stage.addChild(cityStage);
this.bgCity = new City(game,cityStage,newFile,true,"___");
this.guiStage = new PIXI.Container();
stage.addChild(this.guiStage);
this.gui = new GUI(game,this.guiStage);
this.resize();
this.startUI(newFile);
this.resize();
};
$hxClasses["NewGameCreator"] = NewGameCreator;
NewGameCreator.__name__ = "NewGameCreator";
NewGameCreator.__interfaces__ = [GameState];
NewGameCreator.prototype = {
get_publicGUI: function() {
return this.gui;
}
,startUI: function(newFile) {
var isFreePlay = Lambda.find(Resources.allStoriesInfo,function(st) {
return st.link == newFile;
}).freePlay;
if(isFreePlay != null && isFreePlay) {
var _g = $bind(this,this.createSaveWindow);
var storyName = newFile;
var restoreStateOnCancel = false;
var tmp = function() {
_g(storyName,restoreStateOnCancel);
};
gui_FreePlayConfigureWindow.createWindow(this.bgCity,this.gui,tmp,($_=this.game,$bind($_,$_.restoreState)));
} else {
this.createSaveWindow(newFile);
}
}
,createSaveWindow: function(storyName,restoreStateOnCancel) {
if(restoreStateOnCancel == null) {
restoreStateOnCancel = true;
}
var _gthis = this;
this.gui.windowOnDestroy = null;
gui_SaveLoadWindows.createSaveWindow(this.game,this.gui,"Which save slot would you like to use?",function(fileName) {
_gthis.bgCity.disableDisplayOnlyMode(fileName);
_gthis.bgCity.progress.unlocks.postInitialCreate();
Config.doPlay();
Analytics.sendEvent("game","newGame",null,storyName);
_gthis.game.switchState(_gthis.bgCity);
Config.onCitySwitch();
_gthis.guiStage.destroy();
},function() {
if(restoreStateOnCancel) {
_gthis.game.restoreState();
}
});
}
,handleMouse: function(mouse) {
if(this.gui.handleMouse(mouse)) {
return true;
}
return false;
}
,update: function(timeMod) {
this.bgCity.update(timeMod);
this.gui.update(timeMod);
}
,postDraw: function() {
this.bgCity.postDraw();
}
,resize: function() {
this.bgCity.resize();
this.gui.resize();
}
,refocus: function() {
this.bgCity.refocus();
}
,stop: function() {
this.bgCity.stop();
}
,pause: function() {
}
,resume: function() {
}
,onContextRestored: function() {
this.bgCity.onContextRestored();
}
,__class__: NewGameCreator
};
var Perf = $hx_exports["Perf"] = function(pos,offset) {
if(offset == null) {
offset = 0;
}
if(pos == null) {
pos = "TR";
}
this._perfObj = window.performance;
if(Reflect.field(this._perfObj,"memory") != null) {
this._memoryObj = Reflect.field(this._perfObj,"memory");
}
this._memCheck = this._perfObj != null && this._memoryObj != null && this._memoryObj.totalJSHeapSize > 0;
this._pos = pos;
this._offset = offset;
this.currentFps = 60;
this.currentMs = 0;
this.currentMem = "0";
this.lowFps = 60;
this.avgFps = 60;
this._measureCount = 0;
this._totalFps = 0;
this._time = 0;
this._ticks = 0;
this._fpsMin = 60;
this._fpsMax = 60;
this._startTime = this._perfObj != null && this._perfObj.now != null ? this._perfObj.now() : new Date().getTime();
this._prevTime = -Perf.MEASUREMENT_INTERVAL;
this._createFpsDom();
this._createMsDom();
if(this._memCheck) {
this._createMemoryDom();
}
if(window.requestAnimationFrame != null) {
this.RAF = ($_=window,$bind($_,$_.requestAnimationFrame));
} else if(window.mozRequestAnimationFrame != null) {
this.RAF = window.mozRequestAnimationFrame;
} else if(window.webkitRequestAnimationFrame != null) {
this.RAF = window.webkitRequestAnimationFrame;
} else if(window.msRequestAnimationFrame != null) {
this.RAF = window.msRequestAnimationFrame;
}
if(window.cancelAnimationFrame != null) {
this.CAF = ($_=window,$bind($_,$_.cancelAnimationFrame));
} else if(window.mozCancelAnimationFrame != null) {
this.CAF = window.mozCancelAnimationFrame;
} else if(window.webkitCancelAnimationFrame != null) {
this.CAF = window.webkitCancelAnimationFrame;
} else if(window.msCancelAnimationFrame != null) {
this.CAF = window.msCancelAnimationFrame;
}
if(this.RAF != null) {
var o = window;
this._raf = this.RAF.apply(o,[$bind(this,this._tick)]);
}
};
$hxClasses["Perf"] = Perf;
Perf.__name__ = "Perf";
Perf.prototype = {
_init: function() {
this.currentFps = 60;
this.currentMs = 0;
this.currentMem = "0";
this.lowFps = 60;
this.avgFps = 60;
this._measureCount = 0;
this._totalFps = 0;
this._time = 0;
this._ticks = 0;
this._fpsMin = 60;
this._fpsMax = 60;
this._startTime = this._perfObj != null && this._perfObj.now != null ? this._perfObj.now() : new Date().getTime();
this._prevTime = -Perf.MEASUREMENT_INTERVAL;
}
,_now: function() {
if(this._perfObj != null && this._perfObj.now != null) {
return this._perfObj.now();
} else {
return new Date().getTime();
}
}
,_tick: function(val) {
var time = this._perfObj != null && this._perfObj.now != null ? this._perfObj.now() : new Date().getTime();
this._ticks++;
if(this._raf != null && time > this._prevTime + Perf.MEASUREMENT_INTERVAL) {
this.currentMs = Math.round(time - this._startTime);
this.ms.innerHTML = "MS: " + this.currentMs;
this.currentFps = Math.round(this._ticks * 1000 / (time - this._prevTime));
if(this.currentFps > 0 && val > Perf.DELAY_TIME) {
this._measureCount++;
this._totalFps += this.currentFps;
this.lowFps = this._fpsMin = Math.min(this._fpsMin,this.currentFps);
this._fpsMax = Math.max(this._fpsMax,this.currentFps);
this.avgFps = Math.round(this._totalFps / this._measureCount);
}
this.fps.innerHTML = "FPS: " + this.currentFps + " (" + this._fpsMin + "-" + this._fpsMax + ")";
if(this.currentFps >= 30) {
this.fps.style.backgroundColor = Perf.FPS_BG_CLR;
} else if(this.currentFps >= 15) {
this.fps.style.backgroundColor = Perf.FPS_WARN_BG_CLR;
} else {
this.fps.style.backgroundColor = Perf.FPS_PROB_BG_CLR;
}
this._prevTime = time;
this._ticks = 0;
if(this._memCheck) {
this.currentMem = this._getFormattedSize(this._memoryObj.usedJSHeapSize,2);
this.memory.innerHTML = "MEM: " + this.currentMem;
}
}
this._startTime = time;
if(this._raf != null) {
var o = window;
this._raf = this.RAF.apply(o,[$bind(this,this._tick)]);
}
}
,_createDiv: function(id,top) {
if(top == null) {
top = 0;
}
var div = window.document.createElement("div");
div.id = id;
div.className = id;
div.style.position = "absolute";
switch(this._pos) {
case "BL":
div.style.left = this._offset + "px";
div.style.bottom = (this._memCheck ? 48 : 32) - top + "px";
break;
case "BR":
div.style.right = this._offset + "px";
div.style.bottom = (this._memCheck ? 48 : 32) - top + "px";
break;
case "TL":
div.style.left = this._offset + "px";
div.style.top = top + "px";
break;
case "TR":
div.style.right = this._offset + "px";
div.style.top = top + "px";
break;
}
div.style.width = "80px";
div.style.height = "12px";
div.style.lineHeight = "12px";
div.style.padding = "2px";
div.style.fontFamily = Perf.FONT_FAMILY;
div.style.fontSize = "9px";
div.style.fontWeight = "bold";
div.style.textAlign = "center";
window.document.body.appendChild(div);
return div;
}
,_createFpsDom: function() {
this.fps = this._createDiv("fps");
this.fps.style.backgroundColor = Perf.FPS_BG_CLR;
this.fps.style.zIndex = "995";
this.fps.style.color = Perf.FPS_TXT_CLR;
this.fps.innerHTML = "FPS: 0";
}
,_createMsDom: function() {
this.ms = this._createDiv("ms",16);
this.ms.style.backgroundColor = Perf.MS_BG_CLR;
this.ms.style.zIndex = "996";
this.ms.style.color = Perf.MS_TXT_CLR;
this.ms.innerHTML = "MS: 0";
}
,_createMemoryDom: function() {
this.memory = this._createDiv("memory",32);
this.memory.style.backgroundColor = Perf.MEM_BG_CLR;
this.memory.style.color = Perf.MEM_TXT_CLR;
this.memory.style.zIndex = "997";
this.memory.innerHTML = "MEM: 0";
}
,_getFormattedSize: function(bytes,frac) {
if(frac == null) {
frac = 0;
}
var sizes = ["Bytes","KB","MB","GB","TB"];
if(bytes == 0) {
return "0";
}
var precision = Math.pow(10,frac);
var i = Math.floor(Math.log(bytes) / Math.log(1024));
return Math.round(bytes * precision / Math.pow(1024,i)) / precision + " " + sizes[i];
}
,addInfo: function(val) {
this.info = this._createDiv("info",this._memCheck ? 48 : 32);
this.info.style.backgroundColor = Perf.INFO_BG_CLR;
this.info.style.color = Perf.INFO_TXT_CLR;
this.info.style.zIndex = "998";
this.info.innerHTML = val;
}
,clearInfo: function() {
if(this.info != null) {
window.document.body.removeChild(this.info);
this.info = null;
}
}
,destroy: function() {
var o = window;
this.CAF.apply(o,[this._raf]);
this._raf = null;
this._perfObj = null;
this._memoryObj = null;
if(this.fps != null) {
window.document.body.removeChild(this.fps);
this.fps = null;
}
if(this.ms != null) {
window.document.body.removeChild(this.ms);
this.ms = null;
}
if(this.memory != null) {
window.document.body.removeChild(this.memory);
this.memory = null;
}
this.clearInfo();
this.currentFps = 60;
this.currentMs = 0;
this.currentMem = "0";
this.lowFps = 60;
this.avgFps = 60;
this._measureCount = 0;
this._totalFps = 0;
this._time = 0;
this._ticks = 0;
this._fpsMin = 60;
this._fpsMax = 60;
this._startTime = this._perfObj != null && this._perfObj.now != null ? this._perfObj.now() : new Date().getTime();
this._prevTime = -Perf.MEASUREMENT_INTERVAL;
}
,_cancelRAF: function() {
var o = window;
this.CAF.apply(o,[this._raf]);
this._raf = null;
}
,__class__: Perf
};
var PermanentMetaHelper = function() { };
$hxClasses["PermanentMetaHelper"] = PermanentMetaHelper;
PermanentMetaHelper.__name__ = "PermanentMetaHelper";
PermanentMetaHelper.getClassIDLength = function() {
return PermanentMetaHelper.buildingClassesNumber;
};
PermanentMetaHelper.getClassID = function(className) {
var registeredClassName = PermanentMetaHelper.registeredClassNames.h[className];
if(registeredClassName != null) {
return registeredClassName;
}
var v = PermanentMetaHelper.buildingClassesNumber;
PermanentMetaHelper.registeredClassNames.h[className] = v;
PermanentMetaHelper.buildingClassesNumber++;
return PermanentMetaHelper.buildingClassesNumber - 1;
};
var Reflect = function() { };
$hxClasses["Reflect"] = Reflect;
Reflect.__name__ = "Reflect";
Reflect.field = function(o,field) {
try {
return o[field];
} catch( _g ) {
return null;
}
};
Reflect.fields = function(o) {
var a = [];
if(o != null) {
var hasOwnProperty = Object.prototype.hasOwnProperty;
for( var f in o ) {
if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) {
a.push(f);
}
}
}
return a;
};
Reflect.isFunction = function(f) {
if(typeof(f) == "function") {
return !(f.__name__ || f.__ename__);
} else {
return false;
}
};
Reflect.deleteField = function(o,field) {
if(!Object.prototype.hasOwnProperty.call(o,field)) {
return false;
}
delete(o[field]);
return true;
};
Reflect.copy = function(o) {
if(o == null) {
return null;
}
var o2 = { };
var _g = 0;
var _g1 = Reflect.fields(o);
while(_g < _g1.length) {
var f = _g1[_g];
++_g;
o2[f] = Reflect.field(o,f);
}
return o2;
};
var Resources = function() { };
$hxClasses["Resources"] = Resources;
Resources.__name__ = "Resources";
Resources.getTextures = function(name,number,striped) {
if(striped == null) {
striped = false;
}
var cacheName = name + "%num%" + number;
if(striped) {
cacheName += "%s%";
}
if(Object.prototype.hasOwnProperty.call(Resources.multiTextureCache.h,cacheName)) {
return Resources.multiTextureCache.h[cacheName];
}
var textures = [];
var _g = 0;
var _g1 = number;
while(_g < _g1) {
var i = _g++;
var tex = PIXI.Texture.fromFrame("" + name + ".png").clone();
var w = ((tex.frame.width + 2 | 0) / number | 0) - (striped ? 1 : 2);
tex.frame = new PIXI.Rectangle(tex.frame.x + (w + (striped ? 1 : 2)) * i - (striped && i % 2 == 1 ? 1 : 0),tex.frame.y,w,tex.frame.height);
textures.push(tex);
}
Resources.multiTextureCache.h[cacheName] = textures;
return textures;
};
Resources.getTexturesByWidth = function(name,width,striped) {
if(striped == null) {
striped = false;
}
var cacheName = name + "%width%" + width;
if(striped) {
cacheName += "%s%";
}
if(Object.prototype.hasOwnProperty.call(Resources.multiTextureCache.h,cacheName)) {
return Resources.multiTextureCache.h[cacheName];
}
var textures = Resources.getTextures(name,(PIXI.Texture.fromFrame("" + name + ".png").width + 2) / (width + (striped ? 1 : 2)) | 0,striped);
Resources.multiTextureCache.h[cacheName] = textures;
return textures;
};
Resources.getTexturesAsGrid = function(name,numberW,numberH,marginX,striped) {
if(striped == null) {
striped = false;
}
if(marginX == null) {
marginX = 0;
}
var cacheName = name + "%numW%" + numberW + "%numH%" + numberH;
if(striped) {
cacheName += "%s%";
}
if(Object.prototype.hasOwnProperty.call(Resources.multiTextureCache2.h,cacheName)) {
return Resources.multiTextureCache2.h[cacheName];
}
var textures = [];
var _g = 0;
var _g1 = numberW;
while(_g < _g1) {
var i = _g++;
textures[i] = [];
var _g2 = 0;
var _g3 = numberH;
while(_g2 < _g3) {
var j = _g2++;
var tex = PIXI.Texture.fromFrame("" + name + ".png").clone();
var w = ((tex.frame.width + 2 | 0) / numberW | 0) - (striped ? 1 : marginX);
var h = (tex.frame.height | 0) / numberH | 0;
tex.frame = new PIXI.Rectangle(tex.frame.x + (w + (striped ? 1 : marginX)) * i - (striped && i % 2 == 1 ? 1 : 0),tex.frame.y + h * j,w,h);
textures[i].push(tex);
}
}
Resources.multiTextureCache2.h[cacheName] = textures;
return textures;
};
Resources.getTexturesBySize = function(name,width,height,marginX,striped) {
if(striped == null) {
striped = false;
}
if(marginX == null) {
marginX = 0;
}
var cacheName = name + "%width%" + width + "%height%" + height;
if(striped) {
cacheName += "%s%";
}
if(Object.prototype.hasOwnProperty.call(Resources.multiTextureCache2.h,cacheName)) {
return Resources.multiTextureCache2.h[cacheName];
}
var textures = Resources.getTexturesAsGrid(name,(PIXI.Texture.fromFrame("" + name + ".png").width + marginX) / (width + (striped ? 1 : marginX)) | 0,PIXI.Texture.fromFrame("" + name + ".png").height / height | 0,null,striped);
Resources.multiTextureCache2.h[cacheName] = textures;
return textures;
};
Resources.getTexture = function(name,part) {
var cacheName = part != null ? "" + name + "@" + part.x + "," + part.y + "," + part.width + "," + part.height : name;
if(Object.prototype.hasOwnProperty.call(Resources.singleTextureCache.h,cacheName)) {
return Resources.singleTextureCache.h[cacheName];
}
if(part == null && name.indexOf("@") != -1) {
var splitName = name.split("@");
name = splitName[0];
var partString = splitName[1];
var _this = partString.split(",");
var result = new Array(_this.length);
var _g = 0;
var _g1 = _this.length;
while(_g < _g1) {
var i = _g++;
result[i] = Std.parseInt(_this[i]);
}
var splitParts = result;
part = new common_Rectangle(splitParts[0],splitParts[1],splitParts[2],splitParts[3]);
}
var tex = PIXI.Texture.fromFrame("" + name + ".png").clone();
if(part != null) {
tex.frame = new PIXI.Rectangle(tex.frame.x + part.x,tex.frame.y + part.y,part.width,part.height);
}
Resources.singleTextureCache.h[cacheName] = tex;
return tex;
};
Resources.makeSprite = function(textureName,part) {
return new PIXI.Sprite(Resources.getTexture(textureName,part));
};
Resources.initializeCityResources = function(cr) {
cr.buildingInfoArray = [];
var _g = 0;
var _g1 = Resources.buildingInfoArray;
while(_g < _g1.length) {
var bi = _g1[_g];
++_g;
cr.buildingInfoArray.push(Reflect.copy(bi));
}
cr.buildingInfo = new haxe_ds_StringMap();
var _g = 0;
var _g1 = cr.buildingInfoArray;
while(_g < _g1.length) {
var building = _g1[_g];
++_g;
cr.buildingInfo.h["buildings." + building.className] = building;
}
};
var Settings = function() { };
$hxClasses["Settings"] = Settings;
Settings.__name__ = "Settings";
Settings.load = function() {
if(common_Storage.getItem("tfe2_settings",function(err,theSave) {
if(err == null && theSave != null) {
Settings.musicOn = theSave.musicOn;
Settings.soundOn = theSave.soundOn;
if(theSave.pathfindingWorkers != null) {
Settings.pathfindingWorkers = theSave.pathfindingWorkers;
}
if(theSave.secretCodesEnabled != null) {
Settings.secretCodesEnabled = theSave.secretCodesEnabled;
}
Settings.fullscreen = theSave.isFullScreen;
}
Settings.settingsLoaded = true;
}) == null) {
Settings.settingsLoaded = true;
}
if(Settings.pathfindingWorkers <= 0) {
Settings.resetPathfindingWorkers();
}
};
Settings.resetPathfindingWorkers = function() {
Settings.pathfindingWorkers = 1;
if($global.navigator != null && $global.navigator.hardwareConcurrency != null) {
try {
var val = ($global.navigator.hardwareConcurrency / 2 | 0) - 1;
Settings.pathfindingWorkers = val < 1 ? 1 : val > 7 ? 7 : val;
} catch( _g ) {
Settings.pathfindingWorkers = 1;
}
}
return Settings.pathfindingWorkers;
};
Settings.save = function() {
var theSave = { };
theSave.musicOn = Settings.musicOn;
theSave.soundOn = Settings.soundOn;
theSave.pathfindingWorkers = Settings.pathfindingWorkers;
theSave.secretCodesEnabled = Settings.secretCodesEnabled;
common_Storage.setItem("tfe2_settings",theSave,function() {
});
};
Settings.hasSecretCode = function(code) {
return Settings.secretCodesEnabled.indexOf(code) != -1;
};
Settings.unlockSecretCode = function(code) {
if(Settings.hasSecretCode(code)) {
return;
}
Settings.secretCodesEnabled.push(code);
Settings.save();
};
Settings.loadFromCitySave = function(queue) {
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var numberOfSecretCodesStored = intToRead;
var _g = 0;
var _g1 = numberOfSecretCodesStored;
while(_g < _g1) {
var i = _g++;
Settings.unlockSecretCode(queue.readString());
}
};
Settings.saveToCitySave = function(queue) {
var value = Settings.secretCodesEnabled.length;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var _g = 0;
var _g1 = Settings.secretCodesEnabled;
while(_g < _g1.length) {
var sc = _g1[_g];
++_g;
queue.addString(sc);
}
};
Settings.update = function() {
};
var Std = function() { };
$hxClasses["Std"] = Std;
Std.__name__ = "Std";
Std.string = function(s) {
return js_Boot.__string_rec(s,"");
};
Std.parseInt = function(x) {
if(x != null) {
var _g = 0;
var _g1 = x.length;
while(_g < _g1) {
var i = _g++;
var c = x.charCodeAt(i);
if(c <= 8 || c >= 14 && c != 32 && c != 45) {
var nc = x.charCodeAt(i + 1);
var v = parseInt(x,nc == 120 || nc == 88 ? 16 : 10);
if(isNaN(v)) {
return null;
} else {
return v;
}
}
}
}
return null;
};
Std.random = function(x) {
if(x <= 0) {
return 0;
} else {
return Math.floor(Math.random() * x);
}
};
var StringBuf = function() {
this.b = "";
};
$hxClasses["StringBuf"] = StringBuf;
StringBuf.__name__ = "StringBuf";
StringBuf.prototype = {
__class__: StringBuf
};
var StringTools = function() { };
$hxClasses["StringTools"] = StringTools;
StringTools.__name__ = "StringTools";
StringTools.startsWith = function(s,start) {
if(s.length >= start.length) {
return s.lastIndexOf(start,0) == 0;
} else {
return false;
}
};
StringTools.replace = function(s,sub,by) {
return s.split(sub).join(by);
};
var ValueType = $hxEnums["ValueType"] = { __ename__ : "ValueType", __constructs__ : ["TNull","TInt","TFloat","TBool","TObject","TFunction","TClass","TEnum","TUnknown"]
,TNull: {_hx_index:0,__enum__:"ValueType",toString:$estr}
,TInt: {_hx_index:1,__enum__:"ValueType",toString:$estr}
,TFloat: {_hx_index:2,__enum__:"ValueType",toString:$estr}
,TBool: {_hx_index:3,__enum__:"ValueType",toString:$estr}
,TObject: {_hx_index:4,__enum__:"ValueType",toString:$estr}
,TFunction: {_hx_index:5,__enum__:"ValueType",toString:$estr}
,TClass: ($_=function(c) { return {_hx_index:6,c:c,__enum__:"ValueType",toString:$estr}; },$_.__params__ = ["c"],$_)
,TEnum: ($_=function(e) { return {_hx_index:7,e:e,__enum__:"ValueType",toString:$estr}; },$_.__params__ = ["e"],$_)
,TUnknown: {_hx_index:8,__enum__:"ValueType",toString:$estr}
};
var Type = function() { };
$hxClasses["Type"] = Type;
Type.__name__ = "Type";
Type.createInstance = function(cl,args) {
var ctor = Function.prototype.bind.apply(cl,[null].concat(args));
return new (ctor);
};
Type.createEnum = function(e,constr,params) {
var f = Reflect.field(e,constr);
if(f == null) {
throw haxe_Exception.thrown("No such constructor " + constr);
}
if(Reflect.isFunction(f)) {
if(params == null) {
throw haxe_Exception.thrown("Constructor " + constr + " need parameters");
}
return f.apply(e,params);
}
if(params != null && params.length != 0) {
throw haxe_Exception.thrown("Constructor " + constr + " does not need parameters");
}
return f;
};
Type.typeof = function(v) {
switch(typeof(v)) {
case "boolean":
return ValueType.TBool;
case "function":
if(v.__name__ || v.__ename__) {
return ValueType.TObject;
}
return ValueType.TFunction;
case "number":
if(Math.ceil(v) == v % 2147483648.0) {
return ValueType.TInt;
}
return ValueType.TFloat;
case "object":
if(v == null) {
return ValueType.TNull;
}
var e = v.__enum__;
if(e != null) {
return ValueType.TEnum($hxEnums[e]);
}
var c = js_Boot.getClass(v);
if(c != null) {
return ValueType.TClass(c);
}
return ValueType.TObject;
case "string":
return ValueType.TClass(String);
case "undefined":
return ValueType.TNull;
default:
return ValueType.TUnknown;
}
};
Type.enumParameters = function(e) {
var enm = $hxEnums[e.__enum__];
var ctorName = enm.__constructs__[e._hx_index];
var params = enm[ctorName].__params__;
if(params != null) {
var _g = [];
var _g1 = 0;
while(_g1 < params.length) {
var p = params[_g1];
++_g1;
_g.push(e[p]);
}
return _g;
} else {
return [];
}
};
var World = function(game,city,stage,midStage,bgStage,rect,seed) {
this.isUnbuildableFromAliens = false;
this.hasTeleporterOnGroup = false;
this.stresstest = false;
this.knownResourceInavailabilityLastResetDay = 0;
this.relevantWorldsForDirectCityConnectionsCache = null;
this.worldGroup = null;
this.game = game;
this.city = city;
this.rect = rect;
this.stage = stage;
this.midStage = midStage;
this.bgStage = bgStage;
this.seed = seed;
this.worldGlow = null;
var random = new random_SeedeableRandom(seed);
if(seed == null) {
this.seed = random.seed;
}
if(rect.height != 0) {
var worldSpriteAndMask = graphics_WorldImage.makeWorldSprite(random,rect.width,rect.height);
this.worldSprite = worldSpriteAndMask.sprite;
this.mask = worldSpriteAndMask.mask;
this.worldSprite.position.set(rect.x,rect.y);
stage.cacheableChildren.push(this.worldSprite);
stage.isInvalid = true;
} else {
this.worldSprite = null;
}
var numberOfHCells = Math.ceil(rect.width / 20);
var _g = [];
var _g1 = 0;
var _g2 = numberOfHCells;
while(_g1 < _g2) {
var _ = _g1++;
_g.push([]);
}
this.permanents = _g;
var _g = [];
var _g1 = 0;
var _g2 = numberOfHCells;
while(_g1 < _g2) {
var _ = _g1++;
_g.push(null);
}
this.decorations = _g;
if(!Game.isLoading && rect.height != 0) {
var _g = 0;
var _g1 = numberOfHCells;
while(_g < _g1) {
var x = _g++;
this.setDecoration("spr_grass",x);
}
}
this.reachableWorlds = [];
this.knownResourceInavailability = new haxe_ds_StringMap();
};
$hxClasses["World"] = World;
World.__name__ = "World";
World.fromLoad = function(queue,game,city,stage,midStage,bgStage) {
var rect = queue.readRectangle();
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var seed = intToRead;
var thisWorld = new World(game,city,stage,midStage,bgStage,rect,seed);
var xPos = 0;
var _g = 0;
var _g1 = thisWorld.permanents;
while(_g < _g1.length) {
var permanentStack = _g1[_g];
++_g;
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var stackSize = intToRead;
var _g2 = 0;
var _g3 = stackSize;
while(_g2 < _g3) {
var i = _g2++;
var intToRead1 = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var firstInt = intToRead1;
if(firstInt == 2) {
permanentStack.push(null);
} else {
var isBuilding = firstInt == 1;
var intToRead2 = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var permanentID = intToRead2;
var typeString = queue.readString();
var typeClass = $hxClasses[typeString];
var worldPos = new common_Point(xPos,i);
var pos = new common_Point(rect.x + 20 * xPos,rect.y - 20 * (1 + i));
var inst = typeClass == null ? new buildings_UnknownBuilding(game,stage,bgStage,city,thisWorld,pos,worldPos,permanentID) : isBuilding ? Type.createInstance(typeClass,[game,stage,bgStage,city,thisWorld,pos,worldPos,permanentID]) : Type.createInstance(typeClass,[game,permanentID,city,thisWorld,pos,worldPos,stage]);
permanentStack.push(inst);
inst.load(queue);
}
}
if(stackSize == 0) {
var decorationName = queue.readString();
if(decorationName != "") {
var intToRead3 = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var subImage = intToRead3;
thisWorld.setDecoration(decorationName,xPos,subImage);
}
}
++xPos;
}
if(queue.version >= 27) {
var byteToRead = queue.bytes.b[queue.readStart];
queue.readStart += 1;
thisWorld.isUnbuildableFromAliens = byteToRead == 1;
if(thisWorld.isUnbuildableFromAliens) {
thisWorld.setUnbuildableAliens();
}
}
return thisWorld;
};
World.prototype = {
update: function(timeMod) {
if(this.knownResourceInavailabilityLastResetDay != 1 + ((this.city.simulation.time.timeSinceStart | 0) / 1440 | 0)) {
this.knownResourceInavailability = new haxe_ds_StringMap();
this.knownResourceInavailabilityLastResetDay = 1 + ((this.city.simulation.time.timeSinceStart | 0) / 1440 | 0);
}
if(!this.isUnbuildableFromAliens && this.worldGlow != null) {
this.worldGlow.alpha -= 0.1 * timeMod;
if(this.worldGlow.alpha <= 0) {
this.worldGlow.destroy();
this.worldGlow = null;
}
}
}
,canBuildOnSurface: function() {
if(this.rect.height != 0) {
return !this.isUnbuildableFromAliens;
} else {
return false;
}
}
,onCityChange: function() {
this.knownResourceInavailability = new haxe_ds_StringMap();
}
,build: function(buildingType,xPos,insertAt) {
if(insertAt == null || insertAt == 0) {
this.removeDecoration(xPos);
}
var currLen = this.permanents[xPos].length;
var yPos = insertAt == null ? currLen : insertAt;
if(yPos > currLen) {
var _g = 0;
var _g1 = yPos - currLen;
while(_g < _g1) {
var i = _g++;
this.permanents[xPos].push(null);
}
}
var newBuilding = Type.createInstance(buildingType,[this.game,this.stage,this.bgStage,this.city,this,new common_Point(this.rect.x + 20 * xPos,this.rect.y - 20 * (1 + yPos)),new common_Point(xPos,yPos),this.city.maxPermanentID++]);
if(yPos < this.permanents[xPos].length && this.permanents[xPos][yPos] == null) {
this.permanents[xPos][yPos] = newBuilding;
} else if(insertAt == null) {
this.permanents[xPos].push(newBuilding);
} else {
this.permanents[xPos].splice(insertAt,0,newBuilding);
var _g = yPos + 1;
var _g1 = currLen + 1;
while(_g < _g1) {
var i = _g++;
if(this.permanents[xPos][i] == null) {
this.permanents[xPos].splice(i,1);
break;
}
}
}
newBuilding.onBuild();
return newBuilding;
}
,createWorldResource: function(resourceType,xPos) {
this.removeDecoration(xPos);
var newResource = Type.createInstance(resourceType,[this.game,this.city.maxPermanentID++,this.city,this,new common_Point(this.rect.x + 20 * xPos,this.rect.y - 20),new common_Point(xPos,0),this.stage]);
this.permanents[xPos][0] = newResource;
return newResource;
}
,setDecoration: function(textureName,xPos,image) {
this.removeDecoration(xPos);
if(this.permanents[xPos].length > 0 && this.permanents[xPos][0] != null) {
return;
}
this.decorations[xPos] = new graphics_GroundDecoration(this.stage,new common_Point(this.rect.x + 20 * xPos,this.rect.y - 20),textureName,image);
}
,removeDecoration: function(xPos) {
if(this.decorations[xPos] != null) {
this.decorations[xPos].destroy();
this.decorations[xPos] = null;
}
}
,handleMouse: function(mouse) {
var tmp;
if(this.stresstest) {
var _this = this.rect;
var inlPoint_x = _this.x;
var inlPoint_y = _this.y;
tmp = inlPoint_x == 0;
} else {
tmp = false;
}
if(tmp) {
this.stresstest = false;
var _g = 0;
while(_g < 1250) {
var i = _g++;
var i0 = random_Random.getInt(this.permanents.length);
if(this.permanents[i0].length == 0 || this.permanents[i0][this.permanents[i0].length - 1].isBuilding) {
this.build(buildings_NormalHouse,i0);
}
var i1 = random_Random.getInt(this.permanents.length);
if(this.permanents[i1].length == 0 || this.permanents[i1][this.permanents[i1].length - 1].isBuilding) {
this.build(buildings_IndoorFarm,i1);
}
}
this.city.connections.updateCityConnections();
this.city.simulation.updatePathfinder(false);
}
if(mouse.get_cityX() >= this.rect.x && mouse.get_cityX() < this.rect.x + this.rect.width && mouse.get_cityY() < this.rect.y) {
var pressedStack = this.permanents[(mouse.get_cityX() - this.rect.x) / 20 | 0];
var permanentNumber = (this.rect.y - (mouse.get_cityY() + 1)) / 20 | 0;
if(permanentNumber < pressedStack.length) {
if(pressedStack[permanentNumber] != null) {
switch(mouse.claimMouse(pressedStack[permanentNumber],null,false)._hx_index) {
case 0:
pressedStack[permanentNumber].onHover(true);
return true;
case 1:
pressedStack[permanentNumber].onClick();
return true;
case 2:
pressedStack[permanentNumber].onHover(false);
return false;
}
}
}
}
return false;
}
,save: function(queue) {
queue.addRectangle(this.rect);
var value = this.seed;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var _g = 0;
var _g1 = this.permanents.length;
while(_g < _g1) {
var i = _g++;
var permanentStack = this.permanents[i];
var value = permanentStack.length;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var _g2 = 0;
while(_g2 < permanentStack.length) {
var permanent = permanentStack[_g2];
++_g2;
if(permanent == null) {
if(queue.size + 4 > queue.bytes.length) {
var oldBytes1 = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes1,0,queue.size);
}
queue.bytes.setInt32(queue.size,2);
queue.size += 4;
} else {
var value1 = permanent.isBuilding ? 1 : 0;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes2 = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes2,0,queue.size);
}
queue.bytes.setInt32(queue.size,value1);
queue.size += 4;
var value2 = permanent.id;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes3 = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes3,0,queue.size);
}
queue.bytes.setInt32(queue.size,value2);
queue.size += 4;
queue.addString(permanent.className);
permanent.save(queue);
}
}
if(permanentStack.length == 0) {
if(this.decorations[i] != null) {
queue.addString(this.decorations[i].textureName);
var value3 = this.decorations[i].subImage;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes4 = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes4,0,queue.size);
}
queue.bytes.setInt32(queue.size,value3);
queue.size += 4;
} else {
queue.addString("");
}
}
}
var value = this.isUnbuildableFromAliens ? 1 : 0;
if(queue.size + 1 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 1) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.b[queue.size] = value;
queue.size += 1;
}
,setUnbuildableAliens: function() {
if(this.worldGlow == null) {
this.worldGlow = new PIXI.Sprite(Resources.getTexture("spr_blueworldglow"));
this.worldGlow.width = this.rect.width;
this.worldGlow.position.set(this.rect.x,this.rect.y - 4);
this.stage.addChild(this.worldGlow);
this.isUnbuildableFromAliens = true;
}
}
,makeBuildableAliens: function() {
this.isUnbuildableFromAliens = false;
}
,cleanup: function() {
if(this.worldSprite != null) {
var _this = this.stage;
var child = this.worldSprite;
HxOverrides.remove(_this.cacheableChildren,child);
_this.isInvalid = true;
if(child.parent != null) {
child.parent.removeChild(child);
}
this.worldSprite.texture.destroy(true);
this.worldSprite.destroy();
}
}
,__class__: World
};
var WorldResource = function(game,id,city,world,position,worldPosition,stage,texture) {
this.stage = stage;
this.sprite = new PIXI.Sprite(texture);
stage.addChild(this.sprite);
Permanent.call(this,game,id,city,world,position,worldPosition);
this.positionSprites();
};
$hxClasses["WorldResource"] = WorldResource;
WorldResource.__name__ = "WorldResource";
WorldResource.__super__ = Permanent;
WorldResource.prototype = $extend(Permanent.prototype,{
destroy: function() {
Permanent.prototype.destroy.call(this);
this.stage.removeChild(this.sprite);
this.city.simulation.resourcePriorityManager.deprioritize(this);
}
,positionSprites: function() {
Permanent.prototype.positionSprites.call(this);
this.sprite.position.set(this.position.x,this.position.y);
}
,__class__: WorldResource
});
var buildingUpgrades_AIAssistedDiagnosis = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,bgStage,building);
building.extraQuality += 25;
building.extraCapacity += 50;
};
$hxClasses["buildingUpgrades.AIAssistedDiagnosis"] = buildingUpgrades_AIAssistedDiagnosis;
buildingUpgrades_AIAssistedDiagnosis.__name__ = "buildingUpgrades.AIAssistedDiagnosis";
buildingUpgrades_AIAssistedDiagnosis.__super__ = BuildingUpgrade;
buildingUpgrades_AIAssistedDiagnosis.prototype = $extend(BuildingUpgrade.prototype,{
get_textureName: function() {
return "spr_smartdiagnose";
}
,destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
var ccf = this.building;
ccf.extraQuality -= 25;
ccf.extraCapacity -= 50;
}
,__class__: buildingUpgrades_AIAssistedDiagnosis
});
var buildingUpgrades_AIMining = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,bgStage,building);
building.stoneMinedPerActionBoost += 0.3;
};
$hxClasses["buildingUpgrades.AIMining"] = buildingUpgrades_AIMining;
buildingUpgrades_AIMining.__name__ = "buildingUpgrades.AIMining";
buildingUpgrades_AIMining.__super__ = BuildingUpgrade;
buildingUpgrades_AIMining.prototype = $extend(BuildingUpgrade.prototype,{
get_textureName: function() {
return "spr_aiMining";
}
,destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
this.building.stoneMinedPerActionBoost -= 0.3;
}
,__class__: buildingUpgrades_AIMining
});
var buildingUpgrades_AutomaticWaterManagement = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,null,building);
building.regrowSpeedBoost += 2;
};
$hxClasses["buildingUpgrades.AutomaticWaterManagement"] = buildingUpgrades_AutomaticWaterManagement;
buildingUpgrades_AutomaticWaterManagement.__name__ = "buildingUpgrades.AutomaticWaterManagement";
buildingUpgrades_AutomaticWaterManagement.__super__ = BuildingUpgrade;
buildingUpgrades_AutomaticWaterManagement.prototype = $extend(BuildingUpgrade.prototype,{
destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
this.building.regrowSpeedBoost -= 2;
}
,__class__: buildingUpgrades_AutomaticWaterManagement
});
var buildingUpgrades_BetterLightShow = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,null,building);
building.nightClubEntertainmentQuantity += 40;
this.addedLasers = [];
this.addedLasers.push({ start : new common_FPoint(7,4), end : new common_FPoint(6,18), hue : 90, speed : 0.5, targetLaserHue : -1, laserSprite : null});
this.addedLasers.push({ start : new common_FPoint(12,4), end : new common_FPoint(6,18), hue : 270, speed : -0.5, targetLaserHue : -1, laserSprite : null});
Lambda.iter(this.addedLasers,function(l) {
building.lasers.push(l);
});
};
$hxClasses["buildingUpgrades.BetterLightShow"] = buildingUpgrades_BetterLightShow;
buildingUpgrades_BetterLightShow.__name__ = "buildingUpgrades.BetterLightShow";
buildingUpgrades_BetterLightShow.__super__ = BuildingUpgrade;
buildingUpgrades_BetterLightShow.prototype = $extend(BuildingUpgrade.prototype,{
destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
var nightClub = this.building;
nightClub.nightClubEntertainmentQuantity -= 40;
Lambda.iter(this.addedLasers,function(l) {
if(l.laserSprite != null) {
l.laserSprite.destroy();
}
HxOverrides.remove(nightClub.lasers,l);
});
}
,__class__: buildingUpgrades_BetterLightShow
});
var buildingUpgrades_BetterPickaxes = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,bgStage,building);
building.stoneMinedPerActionBoost += 0.2;
};
$hxClasses["buildingUpgrades.BetterPickaxes"] = buildingUpgrades_BetterPickaxes;
buildingUpgrades_BetterPickaxes.__name__ = "buildingUpgrades.BetterPickaxes";
buildingUpgrades_BetterPickaxes.__super__ = BuildingUpgrade;
buildingUpgrades_BetterPickaxes.prototype = $extend(BuildingUpgrade.prototype,{
get_textureName: function() {
return "spr_improvedpickaxes";
}
,destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
this.building.stoneMinedPerActionBoost -= 0.2;
}
,__class__: buildingUpgrades_BetterPickaxes
});
var buildingUpgrades_BetterTools = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,bgStage,building);
};
$hxClasses["buildingUpgrades.BetterTools"] = buildingUpgrades_BetterTools;
buildingUpgrades_BetterTools.__name__ = "buildingUpgrades.BetterTools";
buildingUpgrades_BetterTools.__super__ = BuildingUpgrade;
buildingUpgrades_BetterTools.prototype = $extend(BuildingUpgrade.prototype,{
get_textureName: function() {
return "spr_tinkerershouse_bettertools";
}
,get_bonusAttractiveness: function() {
return 20;
}
,__class__: buildingUpgrades_BetterTools
});
var buildingUpgrades_BiggerTV = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,bgStage,building);
building.extraCapacity += 1;
};
$hxClasses["buildingUpgrades.BiggerTV"] = buildingUpgrades_BiggerTV;
buildingUpgrades_BiggerTV.__name__ = "buildingUpgrades.BiggerTV";
buildingUpgrades_BiggerTV.__super__ = BuildingUpgrade;
buildingUpgrades_BiggerTV.prototype = $extend(BuildingUpgrade.prototype,{
get_textureName: function() {
return "spr_biggertv";
}
,get_bonusAttractiveness: function() {
return 5;
}
,destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
this.building.extraCapacity -= 1;
}
,__class__: buildingUpgrades_BiggerTV
});
var buildingUpgrades_CHProduceFood = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,null,building);
var currentMatType = building.materialType;
if(currentMatType != 2) {
building.resetProgress();
}
building.setMaterialType(2);
};
$hxClasses["buildingUpgrades.CHProduceFood"] = buildingUpgrades_CHProduceFood;
buildingUpgrades_CHProduceFood.__name__ = "buildingUpgrades.CHProduceFood";
buildingUpgrades_CHProduceFood.__super__ = BuildingUpgrade;
buildingUpgrades_CHProduceFood.prototype = $extend(BuildingUpgrade.prototype,{
destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
}
,__class__: buildingUpgrades_CHProduceFood
});
var buildingUpgrades_CHProduceStone = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,null,building);
var currentMatType = building.materialType;
if(currentMatType != 0) {
building.resetProgress();
}
building.setMaterialType(0);
};
$hxClasses["buildingUpgrades.CHProduceStone"] = buildingUpgrades_CHProduceStone;
buildingUpgrades_CHProduceStone.__name__ = "buildingUpgrades.CHProduceStone";
buildingUpgrades_CHProduceStone.__super__ = BuildingUpgrade;
buildingUpgrades_CHProduceStone.prototype = $extend(BuildingUpgrade.prototype,{
destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
}
,__class__: buildingUpgrades_CHProduceStone
});
var buildingUpgrades_CHProduceWood = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,null,building);
var currentMatType = building.materialType;
if(currentMatType != 1) {
building.resetProgress();
}
building.setMaterialType(1);
};
$hxClasses["buildingUpgrades.CHProduceWood"] = buildingUpgrades_CHProduceWood;
buildingUpgrades_CHProduceWood.__name__ = "buildingUpgrades.CHProduceWood";
buildingUpgrades_CHProduceWood.__super__ = BuildingUpgrade;
buildingUpgrades_CHProduceWood.prototype = $extend(BuildingUpgrade.prototype,{
destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
}
,__class__: buildingUpgrades_CHProduceWood
});
var buildingUpgrades_CulinaryHerbs = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,null,building);
building.adjecentBuildingEffects.push({ name : "restaurantCapBoost", intensity : 10});
building.drawer.changeMainTexture("spr_herbgarden");
building.drawer.changeTextureGroup("spr_restaurant");
building.changePlantsTexture(random_Random.getInt(building.herbTextures.length / 2 | 0) * 2);
};
$hxClasses["buildingUpgrades.CulinaryHerbs"] = buildingUpgrades_CulinaryHerbs;
buildingUpgrades_CulinaryHerbs.__name__ = "buildingUpgrades.CulinaryHerbs";
buildingUpgrades_CulinaryHerbs.__super__ = BuildingUpgrade;
buildingUpgrades_CulinaryHerbs.prototype = $extend(BuildingUpgrade.prototype,{
destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
var rcb = Lambda.find(this.building.adjecentBuildingEffects,function(abe) {
return abe.name == "restaurantCapBoost";
});
HxOverrides.remove(this.building.adjecentBuildingEffects,rcb);
}
,__class__: buildingUpgrades_CulinaryHerbs
});
var buildingUpgrades_DieShrink = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,midStage,building);
building.efficiency -= 2;
building.materialsMadePerStepPerWorker += 0.00005;
};
$hxClasses["buildingUpgrades.DieShrink"] = buildingUpgrades_DieShrink;
buildingUpgrades_DieShrink.__name__ = "buildingUpgrades.DieShrink";
buildingUpgrades_DieShrink.__super__ = BuildingUpgrade;
buildingUpgrades_DieShrink.prototype = $extend(BuildingUpgrade.prototype,{
get_textureName: function() {
return "spr_dieshrink";
}
,destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
var ccf = this.building;
ccf.efficiency += 2;
ccf.materialsMadePerStepPerWorker -= 0.00005;
}
,__class__: buildingUpgrades_DieShrink
});
var buildingUpgrades_FactoryDisabled = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,null,building);
building.buildingEnabled = false;
};
$hxClasses["buildingUpgrades.FactoryDisabled"] = buildingUpgrades_FactoryDisabled;
buildingUpgrades_FactoryDisabled.__name__ = "buildingUpgrades.FactoryDisabled";
buildingUpgrades_FactoryDisabled.__super__ = BuildingUpgrade;
buildingUpgrades_FactoryDisabled.prototype = $extend(BuildingUpgrade.prototype,{
destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
this.building.buildingEnabled = true;
}
,__class__: buildingUpgrades_FactoryDisabled
});
var buildingUpgrades_FactoryWorking = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,null,building);
building.buildingEnabled = true;
};
$hxClasses["buildingUpgrades.FactoryWorking"] = buildingUpgrades_FactoryWorking;
buildingUpgrades_FactoryWorking.__name__ = "buildingUpgrades.FactoryWorking";
buildingUpgrades_FactoryWorking.__super__ = BuildingUpgrade;
buildingUpgrades_FactoryWorking.prototype = $extend(BuildingUpgrade.prototype,{
__class__: buildingUpgrades_FactoryWorking
});
var buildingUpgrades_FarmingResearch = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,midStage,building);
this.myEffect = { name : "increaseCropNumber", intensity : 10};
building.adjecentBuildingEffects.push(this.myEffect);
};
$hxClasses["buildingUpgrades.FarmingResearch"] = buildingUpgrades_FarmingResearch;
buildingUpgrades_FarmingResearch.__name__ = "buildingUpgrades.FarmingResearch";
buildingUpgrades_FarmingResearch.__super__ = BuildingUpgrade;
buildingUpgrades_FarmingResearch.prototype = $extend(BuildingUpgrade.prototype,{
get_textureName: function() {
return "spr_upgrade_farmboost";
}
,destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
HxOverrides.remove(this.building.adjecentBuildingEffects,this.myEffect);
}
,__class__: buildingUpgrades_FarmingResearch
});
var buildingUpgrades_Flowers = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,midStage,building);
};
$hxClasses["buildingUpgrades.Flowers"] = buildingUpgrades_Flowers;
buildingUpgrades_Flowers.__name__ = "buildingUpgrades.Flowers";
buildingUpgrades_Flowers.__super__ = BuildingUpgrade;
buildingUpgrades_Flowers.prototype = $extend(BuildingUpgrade.prototype,{
get_textureName: function() {
return "spr_upgrade_flowers";
}
,get_bonusAttractiveness: function() {
return 5;
}
,__class__: buildingUpgrades_Flowers
});
var buildingUpgrades_FossilScanner = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,bgStage,building);
building.city.upgrades.vars.stoneResearchCenterWithFossils = building;
};
$hxClasses["buildingUpgrades.FossilScanner"] = buildingUpgrades_FossilScanner;
buildingUpgrades_FossilScanner.__name__ = "buildingUpgrades.FossilScanner";
buildingUpgrades_FossilScanner.__super__ = BuildingUpgrade;
buildingUpgrades_FossilScanner.prototype = $extend(BuildingUpgrade.prototype,{
get_textureName: function() {
return "spr_stoneresearchcentre_computer";
}
,destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
this.building.city.upgrades.vars.stoneResearchCenterWithFossils = null;
}
,__class__: buildingUpgrades_FossilScanner
});
var buildingUpgrades_HeatedBed = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,null,building);
building.hasHeatedBed = true;
building.onCityChange();
};
$hxClasses["buildingUpgrades.HeatedBed"] = buildingUpgrades_HeatedBed;
buildingUpgrades_HeatedBed.__name__ = "buildingUpgrades.HeatedBed";
buildingUpgrades_HeatedBed.__super__ = BuildingUpgrade;
buildingUpgrades_HeatedBed.prototype = $extend(BuildingUpgrade.prototype,{
get_bonusAttractiveness: function() {
return 20;
}
,destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
this.building.hasHeatedBed = false;
}
,__class__: buildingUpgrades_HeatedBed
});
var buildingUpgrades_IndoorPond = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,bgStage,building);
};
$hxClasses["buildingUpgrades.IndoorPond"] = buildingUpgrades_IndoorPond;
buildingUpgrades_IndoorPond.__name__ = "buildingUpgrades.IndoorPond";
buildingUpgrades_IndoorPond.__super__ = BuildingUpgrade;
buildingUpgrades_IndoorPond.prototype = $extend(BuildingUpgrade.prototype,{
get_textureName: function() {
return "spr_communityhouse_indoorpond";
}
,get_bonusAttractiveness: function() {
return 15;
}
,__class__: buildingUpgrades_IndoorPond
});
var buildingUpgrades_LabDisabled = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,null,building);
building.buildingEnabled = false;
};
$hxClasses["buildingUpgrades.LabDisabled"] = buildingUpgrades_LabDisabled;
buildingUpgrades_LabDisabled.__name__ = "buildingUpgrades.LabDisabled";
buildingUpgrades_LabDisabled.__super__ = BuildingUpgrade;
buildingUpgrades_LabDisabled.prototype = $extend(BuildingUpgrade.prototype,{
destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
this.building.buildingEnabled = true;
}
,__class__: buildingUpgrades_LabDisabled
});
var buildingUpgrades_LabWorking = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,null,building);
building.buildingEnabled = true;
};
$hxClasses["buildingUpgrades.LabWorking"] = buildingUpgrades_LabWorking;
buildingUpgrades_LabWorking.__name__ = "buildingUpgrades.LabWorking";
buildingUpgrades_LabWorking.__super__ = BuildingUpgrade;
buildingUpgrades_LabWorking.prototype = $extend(BuildingUpgrade.prototype,{
__class__: buildingUpgrades_LabWorking
});
var buildingUpgrades_LivingComputer = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,bgStage,building);
};
$hxClasses["buildingUpgrades.LivingComputer"] = buildingUpgrades_LivingComputer;
buildingUpgrades_LivingComputer.__name__ = "buildingUpgrades.LivingComputer";
buildingUpgrades_LivingComputer.__super__ = BuildingUpgrade;
buildingUpgrades_LivingComputer.prototype = $extend(BuildingUpgrade.prototype,{
get_textureName: function() {
return "spr_alienhouse_livingcomputer";
}
,get_bonusAttractiveness: function() {
return 20;
}
,__class__: buildingUpgrades_LivingComputer
});
var buildingUpgrades_MachinePartsFactoryEfficiency = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,null,building);
building.efficiency -= 1;
};
$hxClasses["buildingUpgrades.MachinePartsFactoryEfficiency"] = buildingUpgrades_MachinePartsFactoryEfficiency;
buildingUpgrades_MachinePartsFactoryEfficiency.__name__ = "buildingUpgrades.MachinePartsFactoryEfficiency";
buildingUpgrades_MachinePartsFactoryEfficiency.__super__ = BuildingUpgrade;
buildingUpgrades_MachinePartsFactoryEfficiency.prototype = $extend(BuildingUpgrade.prototype,{
destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
this.building.efficiency += 1;
}
,__class__: buildingUpgrades_MachinePartsFactoryEfficiency
});
var buildingUpgrades_MachinePartsFactoryTurbo = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,null,building);
building.buildingEnabled = true;
building.efficiency += 2;
building.materialsMadePerStepPerWorker += 0.0015;
};
$hxClasses["buildingUpgrades.MachinePartsFactoryTurbo"] = buildingUpgrades_MachinePartsFactoryTurbo;
buildingUpgrades_MachinePartsFactoryTurbo.__name__ = "buildingUpgrades.MachinePartsFactoryTurbo";
buildingUpgrades_MachinePartsFactoryTurbo.__super__ = BuildingUpgrade;
buildingUpgrades_MachinePartsFactoryTurbo.prototype = $extend(BuildingUpgrade.prototype,{
destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
var mpf = this.building;
mpf.efficiency -= 2;
mpf.materialsMadePerStepPerWorker -= 0.0015;
}
,__class__: buildingUpgrades_MachinePartsFactoryTurbo
});
var buildingUpgrades_MedicalEducation = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,null,building);
building.medicalEducationPart = 1;
};
$hxClasses["buildingUpgrades.MedicalEducation"] = buildingUpgrades_MedicalEducation;
buildingUpgrades_MedicalEducation.__name__ = "buildingUpgrades.MedicalEducation";
buildingUpgrades_MedicalEducation.__super__ = BuildingUpgrade;
buildingUpgrades_MedicalEducation.prototype = $extend(BuildingUpgrade.prototype,{
destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
var ccf = this.building;
ccf.medicalEducationPart = 0;
}
,__class__: buildingUpgrades_MedicalEducation
});
var buildingUpgrades_MedicalHerbs = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,null,building);
building.drawer.changeMainTexture("spr_herbgarden_medic");
building.drawer.changeTextureGroup("spr_botanicalgardens");
building.isMedical = true;
building.changePlantsTexture(random_Random.getInt(building.herbTextures.length / 2 | 0) * 2 + 1);
};
$hxClasses["buildingUpgrades.MedicalHerbs"] = buildingUpgrades_MedicalHerbs;
buildingUpgrades_MedicalHerbs.__name__ = "buildingUpgrades.MedicalHerbs";
buildingUpgrades_MedicalHerbs.__super__ = BuildingUpgrade;
buildingUpgrades_MedicalHerbs.prototype = $extend(BuildingUpgrade.prototype,{
destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
this.building.isMedical = false;
}
,__class__: buildingUpgrades_MedicalHerbs
});
var buildingUpgrades_MisdirectorAlways = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,null,building);
building.mode = buildings_MisdirectorMode.Always;
};
$hxClasses["buildingUpgrades.MisdirectorAlways"] = buildingUpgrades_MisdirectorAlways;
buildingUpgrades_MisdirectorAlways.__name__ = "buildingUpgrades.MisdirectorAlways";
buildingUpgrades_MisdirectorAlways.__super__ = BuildingUpgrade;
buildingUpgrades_MisdirectorAlways.prototype = $extend(BuildingUpgrade.prototype,{
destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
var misdirector = this.building;
misdirector.mode = buildings_MisdirectorMode.Always;
}
,__class__: buildingUpgrades_MisdirectorAlways
});
var buildingUpgrades_MisdirectorDisabled = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,null,building);
building.mode = buildings_MisdirectorMode.Disabled;
};
$hxClasses["buildingUpgrades.MisdirectorDisabled"] = buildingUpgrades_MisdirectorDisabled;
buildingUpgrades_MisdirectorDisabled.__name__ = "buildingUpgrades.MisdirectorDisabled";
buildingUpgrades_MisdirectorDisabled.__super__ = BuildingUpgrade;
buildingUpgrades_MisdirectorDisabled.prototype = $extend(BuildingUpgrade.prototype,{
destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
var misdirector = this.building;
misdirector.mode = buildings_MisdirectorMode.Disabled;
}
,__class__: buildingUpgrades_MisdirectorDisabled
});
var buildingUpgrades_MisdirectorMostlyDisabled = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,null,building);
building.mode = buildings_MisdirectorMode.MostlyDisabled;
};
$hxClasses["buildingUpgrades.MisdirectorMostlyDisabled"] = buildingUpgrades_MisdirectorMostlyDisabled;
buildingUpgrades_MisdirectorMostlyDisabled.__name__ = "buildingUpgrades.MisdirectorMostlyDisabled";
buildingUpgrades_MisdirectorMostlyDisabled.__super__ = BuildingUpgrade;
buildingUpgrades_MisdirectorMostlyDisabled.prototype = $extend(BuildingUpgrade.prototype,{
destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
var misdirector = this.building;
misdirector.mode = buildings_MisdirectorMode.Normal;
}
,__class__: buildingUpgrades_MisdirectorMostlyDisabled
});
var buildingUpgrades_MisdirectorNormal = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,null,building);
building.mode = buildings_MisdirectorMode.Normal;
};
$hxClasses["buildingUpgrades.MisdirectorNormal"] = buildingUpgrades_MisdirectorNormal;
buildingUpgrades_MisdirectorNormal.__name__ = "buildingUpgrades.MisdirectorNormal";
buildingUpgrades_MisdirectorNormal.__super__ = BuildingUpgrade;
buildingUpgrades_MisdirectorNormal.prototype = $extend(BuildingUpgrade.prototype,{
destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
var misdirector = this.building;
misdirector.mode = buildings_MisdirectorMode.Normal;
}
,__class__: buildingUpgrades_MisdirectorNormal
});
var buildingUpgrades_ModernConveniences = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,bgStage,building);
};
$hxClasses["buildingUpgrades.ModernConveniences"] = buildingUpgrades_ModernConveniences;
buildingUpgrades_ModernConveniences.__name__ = "buildingUpgrades.ModernConveniences";
buildingUpgrades_ModernConveniences.__super__ = BuildingUpgrade;
buildingUpgrades_ModernConveniences.prototype = $extend(BuildingUpgrade.prototype,{
get_textureName: function() {
return "spr_modernconveniences";
}
,get_bonusAttractiveness: function() {
return 15;
}
,__class__: buildingUpgrades_ModernConveniences
});
var buildingUpgrades_ModernHomePlant = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,bgStage,building);
building.yearsToLiveLongerPerYearIfLivingHere += 0.05;
};
$hxClasses["buildingUpgrades.ModernHomePlant"] = buildingUpgrades_ModernHomePlant;
buildingUpgrades_ModernHomePlant.__name__ = "buildingUpgrades.ModernHomePlant";
buildingUpgrades_ModernHomePlant.__super__ = BuildingUpgrade;
buildingUpgrades_ModernHomePlant.prototype = $extend(BuildingUpgrade.prototype,{
get_textureName: function() {
return "spr_modernhomeplant";
}
,get_bonusAttractiveness: function() {
return 10;
}
,get_availableTextures: function() {
return this.textures.length - (Settings.hasSecretCode("orchid") ? 0 : 3);
}
,destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
var ccf = this.building;
ccf.yearsToLiveLongerPerYearIfLivingHere -= 0.05;
}
,__class__: buildingUpgrades_ModernHomePlant
});
var buildingUpgrades_PickaxeTech = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,bgStage,building);
building.hasPickaxeTech = true;
};
$hxClasses["buildingUpgrades.PickaxeTech"] = buildingUpgrades_PickaxeTech;
buildingUpgrades_PickaxeTech.__name__ = "buildingUpgrades.PickaxeTech";
buildingUpgrades_PickaxeTech.__super__ = BuildingUpgrade;
buildingUpgrades_PickaxeTech.prototype = $extend(BuildingUpgrade.prototype,{
get_textureName: function() {
return "spr_stoneresearchcentre_pickaxetech";
}
,destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
this.building.hasPickaxeTech = false;
}
,__class__: buildingUpgrades_PickaxeTech
});
var buildingUpgrades_RefinedMetalsFactoryHack = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,null,building);
building.buildingEnabled = true;
building.efficiency += 1;
building.materialsMadePerStepPerWorker += 0.0005;
};
$hxClasses["buildingUpgrades.RefinedMetalsFactoryHack"] = buildingUpgrades_RefinedMetalsFactoryHack;
buildingUpgrades_RefinedMetalsFactoryHack.__name__ = "buildingUpgrades.RefinedMetalsFactoryHack";
buildingUpgrades_RefinedMetalsFactoryHack.__super__ = BuildingUpgrade;
buildingUpgrades_RefinedMetalsFactoryHack.prototype = $extend(BuildingUpgrade.prototype,{
destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
var mpf = this.building;
mpf.efficiency -= 1;
mpf.materialsMadePerStepPerWorker -= 0.0005;
}
,__class__: buildingUpgrades_RefinedMetalsFactoryHack
});
var buildingUpgrades_RefinedStoneUsingFactoryDisabled = function(stage,midStage,bgStage,building) {
buildingUpgrades_FactoryDisabled.call(this,stage,midStage,bgStage,building);
};
$hxClasses["buildingUpgrades.RefinedStoneUsingFactoryDisabled"] = buildingUpgrades_RefinedStoneUsingFactoryDisabled;
buildingUpgrades_RefinedStoneUsingFactoryDisabled.__name__ = "buildingUpgrades.RefinedStoneUsingFactoryDisabled";
buildingUpgrades_RefinedStoneUsingFactoryDisabled.__super__ = buildingUpgrades_FactoryDisabled;
buildingUpgrades_RefinedStoneUsingFactoryDisabled.prototype = $extend(buildingUpgrades_FactoryDisabled.prototype,{
__class__: buildingUpgrades_RefinedStoneUsingFactoryDisabled
});
var buildingUpgrades_SmartChairs = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,bgStage,building);
};
$hxClasses["buildingUpgrades.SmartChairs"] = buildingUpgrades_SmartChairs;
buildingUpgrades_SmartChairs.__name__ = "buildingUpgrades.SmartChairs";
buildingUpgrades_SmartChairs.__super__ = BuildingUpgrade;
buildingUpgrades_SmartChairs.prototype = $extend(BuildingUpgrade.prototype,{
get_textureName: function() {
return "spr_smartchairs";
}
,get_bonusAttractiveness: function() {
return 10;
}
,__class__: buildingUpgrades_SmartChairs
});
var buildingUpgrades_SmartLights = function(stage,midStage,bgStage,building) {
this.lightColor = [{ color : 14680064, time : 0.0},{ color : 14680064, time : 4},{ color : 16777215, time : 6},{ color : 16777215, time : 19},{ color : 16766023, time : 21},{ color : 16766023, time : 23},{ color : 14680064, time : 24}];
var _gthis = this;
BuildingUpgrade.call(this,bgStage,building);
this.set_onUpdate(function(timeMod) {
_gthis.sprite.tint = building.city.simulation.time.getCurrentColor(_gthis.lightColor);
});
};
$hxClasses["buildingUpgrades.SmartLights"] = buildingUpgrades_SmartLights;
buildingUpgrades_SmartLights.__name__ = "buildingUpgrades.SmartLights";
buildingUpgrades_SmartLights.__super__ = BuildingUpgrade;
buildingUpgrades_SmartLights.prototype = $extend(BuildingUpgrade.prototype,{
get_textureName: function() {
return "spr_smartlights";
}
,get_bonusAttractiveness: function() {
return 15;
}
,get_canCacheSprite: function() {
return false;
}
,__class__: buildingUpgrades_SmartLights
});
var buildingUpgrades_SofterBeds = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,bgStage,building);
};
$hxClasses["buildingUpgrades.SofterBeds"] = buildingUpgrades_SofterBeds;
buildingUpgrades_SofterBeds.__name__ = "buildingUpgrades.SofterBeds";
buildingUpgrades_SofterBeds.__super__ = BuildingUpgrade;
buildingUpgrades_SofterBeds.prototype = $extend(BuildingUpgrade.prototype,{
get_textureName: function() {
return "spr_softerbeds";
}
,get_bonusAttractiveness: function() {
return 10;
}
,__class__: buildingUpgrades_SofterBeds
});
var buildingUpgrades_StarDatabase = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,bgStage,building);
building.hasStarDatabase = true;
};
$hxClasses["buildingUpgrades.StarDatabase"] = buildingUpgrades_StarDatabase;
buildingUpgrades_StarDatabase.__name__ = "buildingUpgrades.StarDatabase";
buildingUpgrades_StarDatabase.__super__ = BuildingUpgrade;
buildingUpgrades_StarDatabase.prototype = $extend(BuildingUpgrade.prototype,{
get_textureName: function() {
return "spr_computer_observatory";
}
,destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
var obs = this.building;
obs.hasStarDatabase = false;
}
,__class__: buildingUpgrades_StarDatabase
});
var buildingUpgrades_StoneTeleporterRemote = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,bgStage,building);
building.hasRemoteControl = true;
};
$hxClasses["buildingUpgrades.StoneTeleporterRemote"] = buildingUpgrades_StoneTeleporterRemote;
buildingUpgrades_StoneTeleporterRemote.__name__ = "buildingUpgrades.StoneTeleporterRemote";
buildingUpgrades_StoneTeleporterRemote.__super__ = BuildingUpgrade;
buildingUpgrades_StoneTeleporterRemote.prototype = $extend(BuildingUpgrade.prototype,{
get_textureName: function() {
return "spr_stoneteleporter_remote";
}
,destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
var tp = this.building;
tp.hasRemoteControl = false;
}
,__class__: buildingUpgrades_StoneTeleporterRemote
});
var buildingUpgrades_StoneUsingFactoryDisabled = function(stage,midStage,bgStage,building) {
buildingUpgrades_FactoryDisabled.call(this,stage,midStage,bgStage,building);
};
$hxClasses["buildingUpgrades.StoneUsingFactoryDisabled"] = buildingUpgrades_StoneUsingFactoryDisabled;
buildingUpgrades_StoneUsingFactoryDisabled.__name__ = "buildingUpgrades.StoneUsingFactoryDisabled";
buildingUpgrades_StoneUsingFactoryDisabled.__super__ = buildingUpgrades_FactoryDisabled;
buildingUpgrades_StoneUsingFactoryDisabled.prototype = $extend(buildingUpgrades_FactoryDisabled.prototype,{
__class__: buildingUpgrades_StoneUsingFactoryDisabled
});
var buildingUpgrades_TreePlantationResearch = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,stage,building);
this.myEffect = { name : "increaseTreeGrowth", intensity : 0.2};
building.adjecentBuildingEffects.push(this.myEffect);
};
$hxClasses["buildingUpgrades.TreePlantationResearch"] = buildingUpgrades_TreePlantationResearch;
buildingUpgrades_TreePlantationResearch.__name__ = "buildingUpgrades.TreePlantationResearch";
buildingUpgrades_TreePlantationResearch.__super__ = BuildingUpgrade;
buildingUpgrades_TreePlantationResearch.prototype = $extend(BuildingUpgrade.prototype,{
get_textureName: function() {
return "spr_treegrowthboost";
}
,destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
HxOverrides.remove(this.building.adjecentBuildingEffects,this.myEffect);
}
,__class__: buildingUpgrades_TreePlantationResearch
});
var buildingUpgrades_UltimateScrewdriver = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,bgStage,building);
building.efficiency -= 0.058;
};
$hxClasses["buildingUpgrades.UltimateScrewdriver"] = buildingUpgrades_UltimateScrewdriver;
buildingUpgrades_UltimateScrewdriver.__name__ = "buildingUpgrades.UltimateScrewdriver";
buildingUpgrades_UltimateScrewdriver.__super__ = BuildingUpgrade;
buildingUpgrades_UltimateScrewdriver.prototype = $extend(BuildingUpgrade.prototype,{
get_textureName: function() {
return "spr_experimentationlab_screwdriver";
}
,get_canCacheSprite: function() {
return false;
}
,destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
var etl = this.building;
etl.efficiency += 0.058;
}
,__class__: buildingUpgrades_UltimateScrewdriver
});
var buildingUpgrades_WorkshopKnowledge = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,bgStage,building);
building.isProducingKnowledge = true;
};
$hxClasses["buildingUpgrades.WorkshopKnowledge"] = buildingUpgrades_WorkshopKnowledge;
buildingUpgrades_WorkshopKnowledge.__name__ = "buildingUpgrades.WorkshopKnowledge";
buildingUpgrades_WorkshopKnowledge.__super__ = BuildingUpgrade;
buildingUpgrades_WorkshopKnowledge.prototype = $extend(BuildingUpgrade.prototype,{
get_textureName: function() {
return "spr_workshop_petprojects";
}
,destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
}
,__class__: buildingUpgrades_WorkshopKnowledge
});
var buildingUpgrades_WorkshopMachineParts = function(stage,midStage,bgStage,building) {
BuildingUpgrade.call(this,bgStage,building);
building.isProducingKnowledge = false;
};
$hxClasses["buildingUpgrades.WorkshopMachineParts"] = buildingUpgrades_WorkshopMachineParts;
buildingUpgrades_WorkshopMachineParts.__name__ = "buildingUpgrades.WorkshopMachineParts";
buildingUpgrades_WorkshopMachineParts.__super__ = BuildingUpgrade;
buildingUpgrades_WorkshopMachineParts.prototype = $extend(BuildingUpgrade.prototype,{
get_textureName: function() {
return "spr_workshop_makemachineparts";
}
,destroy: function() {
BuildingUpgrade.prototype.destroy.call(this);
}
,__class__: buildingUpgrades_WorkshopMachineParts
});
var buildings_AlienDecryptor = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.timeWorking = 0;
Building.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
};
$hxClasses["buildings.AlienDecryptor"] = buildings_AlienDecryptor;
buildings_AlienDecryptor.__name__ = "buildings.AlienDecryptor";
buildings_AlienDecryptor.__super__ = Building;
buildings_AlienDecryptor.prototype = $extend(Building.prototype,{
update: function(timeMod) {
this.timeWorking += timeMod * this.city.simulation.time.minutesPerTick;
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
Building.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_AlienDecryptor.saveDefinition);
}
var value = this.timeWorking;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
}
,load: function(queue,definition) {
Building.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"timeWorking")) {
this.timeWorking = loadMap.h["timeWorking"];
}
}
,__class__: buildings_AlienDecryptor
});
var buildings_IHousing = function() { };
$hxClasses["buildings.IHousing"] = buildings_IHousing;
buildings_IHousing.__name__ = "buildings.IHousing";
buildings_IHousing.__isInterface__ = true;
buildings_IHousing.prototype = {
__class__: buildings_IHousing
};
var buildings_House = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.yearsToLiveLongerPerYearIfLivingHere = 0.0;
this.residents = [];
this.extraCapacity = 0;
Building.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
};
$hxClasses["buildings.House"] = buildings_House;
buildings_House.__name__ = "buildings.House";
buildings_House.__interfaces__ = [buildings_IHousing];
buildings_House.__super__ = Building;
buildings_House.prototype = $extend(Building.prototype,{
get_residentCapacity: function() {
if(this.info.residents == null) {
return 0;
} else {
return this.info.residents + this.extraCapacity;
}
}
,get_baseAttractiveness: function() {
return this.info.quality;
}
,get_possibleUpgrades: function() {
return [];
}
,get_remainingCapacity: function() {
return this.get_residentCapacity() - this.residents.length;
}
,get_fixedCapacityForWorkers: function() {
return 0;
}
,get_hasPrivateTeleporter: function() {
return false;
}
,destroy: function() {
Building.prototype.destroy.call(this);
while(this.residents.length != 0) this.residents[this.residents.length - 1].evictFromHome();
}
,addWindowInfoLines: function() {
var _gthis = this;
Building.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
return "Quality: " + (_gthis.get_baseAttractiveness() + _gthis.bonusAttractiveness);
});
var tmp = this.city.gui;
var city = this.city;
var citizens = this.residents;
var topText = "Residents of " + this.get_name();
var relatedBuilding = this;
var nothingFoundText = "No residents";
tmp.windowAddInfoTextClickable(function() {
gui_MultiFollowWindow.createWindow(city,citizens,topText,relatedBuilding,nothingFoundText);
},null,function() {
return "" + _gthis.residents.length + "/" + _gthis.get_residentCapacity() + " residents";
});
}
,walkAround: function(citizen,stepsInBuilding) {
var r = random_Random.getInt(4);
if(r == 0 && stepsInBuilding > 120) {
citizen.changeFloorAndWaitRandom(30,60);
} else if(r == 1) {
citizen.moveAndWait(random_Random.getInt(3,7),random_Random.getInt(30,60),null,false,false);
} else if(r == 2) {
citizen.moveAndWait(random_Random.getInt(12,16),random_Random.getInt(30,60),null,false,false);
} else {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = random_Random.getInt(90,120);
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
}
,__class__: buildings_House
});
var buildings_AlienHouse = function(game,stage,bgStage,city,world,position,worldPosition,id) {
buildings_House.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
};
$hxClasses["buildings.AlienHouse"] = buildings_AlienHouse;
buildings_AlienHouse.__name__ = "buildings.AlienHouse";
buildings_AlienHouse.__super__ = buildings_House;
buildings_AlienHouse.prototype = $extend(buildings_House.prototype,{
get_possibleUpgrades: function() {
return [buildingUpgrades_LivingComputer];
}
,__class__: buildings_AlienHouse
});
var buildings_IWaterFilled = function() { };
$hxClasses["buildings.IWaterFilled"] = buildings_IWaterFilled;
buildings_IWaterFilled.__name__ = "buildings.IWaterFilled";
buildings_IWaterFilled.__isInterface__ = true;
buildings_IWaterFilled.prototype = {
__class__: buildings_IWaterFilled
};
var buildings_IEntertainmentBuilding = function() { };
$hxClasses["buildings.IEntertainmentBuilding"] = buildings_IEntertainmentBuilding;
buildings_IEntertainmentBuilding.__name__ = "buildings.IEntertainmentBuilding";
buildings_IEntertainmentBuilding.__isInterface__ = true;
buildings_IEntertainmentBuilding.prototype = {
__class__: buildings_IEntertainmentBuilding
};
var buildings_Aquarium = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.justBuilt = false;
this.currentTexture = 0;
Building.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.isEntertainment = true;
this.currentTexture = 0;
this.adjecentBuildingEffects.push({ name : "modernRusticHomeCommunityFeeling", intensity : 1});
this.leftIsWaterFilled = false;
this.rightIsWaterFilled = false;
this.topIsWaterFilled = false;
this.bottomIsWaterFilled = false;
};
$hxClasses["buildings.Aquarium"] = buildings_Aquarium;
buildings_Aquarium.__name__ = "buildings.Aquarium";
buildings_Aquarium.__interfaces__ = [buildings_IWaterFilled,buildings_IEntertainmentBuilding];
buildings_Aquarium.__super__ = Building;
buildings_Aquarium.prototype = $extend(Building.prototype,{
get_baseEntertainmentCapacity: function() {
return 50;
}
,get_isOpen: function() {
return false;
}
,get_entertainmentType: function() {
return 3;
}
,get_minimumNormalTimeToSpend: function() {
return 3;
}
,get_maximumNormalTimeToSpend: function() {
return 4;
}
,get_minimumEntertainmentGroupSatisfy: function() {
return 1;
}
,get_maximumEntertainmentGroupSatisfy: function() {
return 1.5;
}
,get_entertainmentQuality: function() {
return 100;
}
,get_drawerType: function() {
return buildings_buildingDrawers_AllDirMergingBuildingDrawer;
}
,get_mergingDrawer: function() {
return this.drawer;
}
,get_walkThroughCanViewSelfInThisBuilding: function() {
return false;
}
,get_isOpenForExistingVisitors: function() {
return this.get_isOpen();
}
,finishEntertainment: function(citizen,timeMod) {
return true;
}
,postCreate: function() {
Building.prototype.postCreate.call(this);
this.updateGardenTexture();
if(this.justBuilt) {
var buildingToTakeTextureFrom = null;
if(this.bottomBuilding != null && this.bottomBuilding.is(buildings_Aquarium)) {
buildingToTakeTextureFrom = this.bottomBuilding;
}
if(this.topBuilding != null && this.topBuilding.is(buildings_Aquarium)) {
buildingToTakeTextureFrom = this.topBuilding;
}
if(buildingToTakeTextureFrom != null) {
this.get_mergingDrawer().setGroupOfSecondaryTextureForThisBuilding(this.get_mergingDrawer().getSecondaryTextureGroup(buildingToTakeTextureFrom.currentTexture));
} else {
this.currentTexture = random_Random.getInt(common_ArrayExtensions.isum(buildings_Aquarium.gardenTextureSets));
}
this.justBuilt = false;
this.city.simulation.fishes.fishes.push(new simulation_Fish(this.city,this.city.aboveCitizensInBuildingStage,this,10,10));
this.city.simulation.fishes.fishes.push(new simulation_Fish(this.city,this.city.aboveCitizensInBuildingStage,this,10,14));
this.city.simulation.fishes.fishes.push(new simulation_Fish(this.city,this.city.aboveCitizensInBuildingStage,this,10,6));
this.updateGardenTexture();
}
this.positionSprites();
}
,destroy: function() {
Building.prototype.destroy.call(this);
var fishes = this.city.simulation.fishes.fishes;
var i = fishes.length;
while(--i >= 0) if(fishes[i].inPermanent == this) {
fishes[i].destroy();
}
}
,onCityChange: function() {
this.leftIsWaterFilled = this.leftBuilding != null && js_Boot.__implements(this.leftBuilding,buildings_IWaterFilled);
this.rightIsWaterFilled = this.rightBuilding != null && js_Boot.__implements(this.rightBuilding,buildings_IWaterFilled);
this.topIsWaterFilled = this.topBuilding != null && js_Boot.__implements(this.topBuilding,buildings_IWaterFilled);
this.bottomIsWaterFilled = this.bottomBuilding != null && js_Boot.__implements(this.bottomBuilding,buildings_IWaterFilled);
if(this.leftIsWaterFilled) {
this.leftAsWaterFilled = this.leftBuilding;
} else {
this.leftAsWaterFilled = null;
}
if(this.rightIsWaterFilled) {
this.rightAsWaterFilled = this.rightBuilding;
} else {
this.rightAsWaterFilled = null;
}
if(this.topIsWaterFilled) {
this.topAsWaterFilled = this.topBuilding;
} else {
this.topAsWaterFilled = null;
}
if(this.bottomIsWaterFilled) {
this.bottomAsWaterFilled = this.bottomBuilding;
} else {
this.bottomAsWaterFilled = null;
}
}
,postLoad: function() {
this.updateGardenTexture();
}
,onBuild: function() {
Building.prototype.onBuild.call(this);
this.justBuilt = true;
}
,updateGardenTexture: function() {
var _gthis = this;
this.get_mergingDrawer().setSecondaryBackgroundImages("spr_aquarium_plants",buildings_Aquarium.gardenTextureSets,this.currentTexture,function(n) {
_gthis.currentTexture = n;
});
}
,beEntertained: function(citizen,timeMod) {
}
,createWindowAddBottomButtons: function() {
var _gthis = this;
gui_windowParts_CycleValueButton.create(this.city.gui,function() {
return _gthis.get_mergingDrawer().getCurrentSecondaryTextureGroup();
},($_=this.get_mergingDrawer(),$bind($_,$_.setGroupOfSecondaryTexture)),function() {
return buildings_Aquarium.gardenTextureSets.length;
},"Change Plants");
gui_windowParts_CycleValueButton.create(this.city.gui,function() {
return _gthis.currentTexture - _gthis.get_mergingDrawer().getFirstSecondaryTextureOfGroup(_gthis.get_mergingDrawer().getCurrentSecondaryTextureGroup());
},($_=this.get_mergingDrawer(),$bind($_,$_.setSecondaryTextureWithinGroup)),function() {
return buildings_Aquarium.gardenTextureSets[_gthis.get_mergingDrawer().getCurrentSecondaryTextureGroup()];
},"Change Plants Variant");
Building.prototype.createWindowAddBottomButtons.call(this);
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
Building.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_Aquarium.saveDefinition);
}
var value = this.currentTexture;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
,load: function(queue,definition) {
Building.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"currentTexture")) {
this.currentTexture = loadMap.h["currentTexture"];
}
this.postLoad();
}
,__class__: buildings_Aquarium
});
var buildings_Work = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.workTimePreferenceMod = 1;
this.endTime = 19;
this.startTime = 6;
this.workers = [];
Building.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
};
$hxClasses["buildings.Work"] = buildings_Work;
buildings_Work.__name__ = "buildings.Work";
buildings_Work.__super__ = Building;
buildings_Work.prototype = $extend(Building.prototype,{
get_jobs: function() {
if(this.info.jobs == null) {
return 0;
} else {
return this.info.jobs;
}
}
,get_remainingCapacity: function() {
return this.get_jobs() - this.workers.length;
}
,get_firstBuildingToGoTo: function() {
return this;
}
,destroy: function() {
Building.prototype.destroy.call(this);
while(this.workers.length != 0) this.workers[this.workers.length - 1].loseJob();
}
,work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking) {
citizen.currentAction = LifeAction.Nothing;
}
}
,addWindowInfoLines: function() {
var _gthis = this;
Building.prototype.addWindowInfoLines.call(this);
var tmp = this.city.gui;
var city = this.city;
var citizens = this.workers;
var topText = "Workers of " + this.get_name();
var relatedBuilding = this;
var nothingFoundText = "No workers";
tmp.windowAddInfoTextClickable(function() {
gui_MultiFollowWindow.createWindow(city,citizens,topText,relatedBuilding,nothingFoundText);
},null,function() {
return "" + _gthis.workers.length + "/" + _gthis.get_jobs() + " workers";
});
}
,afterGiveJob: function(citizen) {
}
,__class__: buildings_Work
});
var buildings_Arcade = function(game,stage,bgStage,city,world,position,worldPosition,id) {
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.startTime = 12;
this.endTime = 23.5;
this.workTimePreferenceMod = 0.1;
this.isEntertainment = true;
};
$hxClasses["buildings.Arcade"] = buildings_Arcade;
buildings_Arcade.__name__ = "buildings.Arcade";
buildings_Arcade.__interfaces__ = [buildings_IEntertainmentBuilding];
buildings_Arcade.__super__ = buildings_Work;
buildings_Arcade.prototype = $extend(buildings_Work.prototype,{
get_baseEntertainmentCapacity: function() {
return this.workers.length * 120;
}
,get_isOpen: function() {
if(this.workers.length == 1 && this.workers[0].currentAction == LifeAction.Work) {
return this.city.simulation.time.timeSinceStart / 60 % 24 < 23;
} else {
return false;
}
}
,get_entertainmentType: function() {
return 4;
}
,get_minimumNormalTimeToSpend: function() {
return 2.5;
}
,get_maximumNormalTimeToSpend: function() {
return 3;
}
,get_minimumEntertainmentGroupSatisfy: function() {
return 4;
}
,get_maximumEntertainmentGroupSatisfy: function() {
return 7;
}
,get_entertainmentQuality: function() {
return 100;
}
,get_isOpenForExistingVisitors: function() {
return this.get_isOpen();
}
,finishEntertainment: function(citizen,timeMod) {
return true;
}
,beEntertained: function(citizen,timeMod) {
var moveFunction = function() {
var xx = citizen.relativeY < 5 ? 5 + 4 * random_Random.getInt(3) : 5 + 8 * random_Random.getInt(2);
citizen.moveAndWait(random_Random.getInt(xx,xx + 1),random_Random.getInt(100,120),null,false,false);
};
if(random_Random.getInt(3) == 1) {
citizen.changeFloor(moveFunction);
} else {
moveFunction();
}
}
,work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking) {
citizen.currentAction = LifeAction.Nothing;
} else {
var spd = citizen.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
if(Math.abs(6 - citizen.relativeX) < spd) {
citizen.relativeX = 6;
} else {
var num = 6 - citizen.relativeX;
citizen.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
}
}
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Work.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_Arcade.saveDefinition);
}
}
,load: function(queue,definition) {
buildings_Work.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
}
,__class__: buildings_Arcade
});
var buildings_WorkWithHome = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.yearsToLiveLongerPerYearIfLivingHere = 0.0;
this.residents = [];
this.extraCapacity = 0;
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
};
$hxClasses["buildings.WorkWithHome"] = buildings_WorkWithHome;
buildings_WorkWithHome.__name__ = "buildings.WorkWithHome";
buildings_WorkWithHome.__interfaces__ = [buildings_IHousing];
buildings_WorkWithHome.__super__ = buildings_Work;
buildings_WorkWithHome.prototype = $extend(buildings_Work.prototype,{
get_residentCapacity: function() {
if(this.info.residents == null) {
return 0;
} else {
return this.info.residents + this.extraCapacity;
}
}
,get_baseAttractiveness: function() {
return this.info.quality;
}
,get_possibleUpgrades: function() {
return [];
}
,get_remainingCapacity: function() {
return this.get_residentCapacity() - this.residents.length;
}
,get_fixedCapacityForWorkers: function() {
return this.get_residentCapacity();
}
,get_hasPrivateTeleporter: function() {
return false;
}
,destroy: function() {
buildings_Work.prototype.destroy.call(this);
while(this.residents.length != 0) this.residents[this.residents.length - 1].evictFromHome();
}
,addWindowInfoLines: function() {
var _gthis = this;
this.city.gui.windowAddInfoText(null,function() {
return "Quality: " + (_gthis.get_baseAttractiveness() + _gthis.bonusAttractiveness);
});
var tmp = this.city.gui;
var city = this.city;
var citizens = this.residents;
var topText = "Residents of " + this.get_name();
var relatedBuilding = this;
var nothingFoundText = "No residents";
tmp.windowAddInfoTextClickable(function() {
gui_MultiFollowWindow.createWindow(city,citizens,topText,relatedBuilding,nothingFoundText);
},null,function() {
return "" + _gthis.residents.length + "/" + _gthis.get_residentCapacity() + " residents";
});
buildings_Work.prototype.addWindowInfoLines.call(this);
}
,walkAround: function(citizen,stepsInBuilding) {
var r = random_Random.getInt(4);
if(r == 0 && stepsInBuilding > 120) {
citizen.changeFloorAndWaitRandom(30,60);
} else if(r == 1) {
citizen.moveAndWait(random_Random.getInt(3,7),random_Random.getInt(30,60),null,false,false);
} else if(r == 2) {
citizen.moveAndWait(random_Random.getInt(12,16),random_Random.getInt(30,60),null,false,false);
} else {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = random_Random.getInt(90,120);
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
}
,__class__: buildings_WorkWithHome
});
var buildings_ArtColony = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.artSprite = null;
this.currentWorkProgress = 0;
this.currentTexture = 0;
buildings_WorkWithHome.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.startTime = 10;
this.endTime = 22;
this.workTimePreferenceMod = 0.3;
this.isEntertainment = true;
this.artTextures = Resources.getTexturesByWidth("spr_artcolonywork",20);
this.currentTexture = 0;
this.artSprite = new PIXI.Sprite(this.artTextures[this.currentTexture]);
this.artSprite.position.set(position.x,position.y);
bgStage.addChild(this.artSprite);
};
$hxClasses["buildings.ArtColony"] = buildings_ArtColony;
buildings_ArtColony.__name__ = "buildings.ArtColony";
buildings_ArtColony.__interfaces__ = [buildings_IEntertainmentBuilding];
buildings_ArtColony.__super__ = buildings_WorkWithHome;
buildings_ArtColony.prototype = $extend(buildings_WorkWithHome.prototype,{
get_baseEntertainmentCapacity: function() {
return this.workers.length * 50;
}
,get_isOpen: function() {
if(this.workers.length > 0 && this.workers[0].currentAction == LifeAction.Work && (1 + ((this.city.simulation.time.timeSinceStart | 0) / 1440 | 0)) % 3 == 0 && this.city.simulation.time.timeSinceStart / 60 % 24 < 21.5) {
return this.city.simulation.time.timeSinceStart / 60 % 24 > 15.0;
} else {
return false;
}
}
,get_entertainmentType: function() {
return 2;
}
,get_minimumNormalTimeToSpend: function() {
return 1;
}
,get_maximumNormalTimeToSpend: function() {
return 2;
}
,get_minimumEntertainmentGroupSatisfy: function() {
return 2;
}
,get_maximumEntertainmentGroupSatisfy: function() {
return 3;
}
,get_entertainmentQuality: function() {
return 100;
}
,get_isOpenForExistingVisitors: function() {
return this.get_isOpen();
}
,finishEntertainment: function(citizen,timeMod) {
return true;
}
,postLoad: function() {
this.artSprite.texture = this.artTextures[this.currentTexture];
}
,positionSprites: function() {
buildings_WorkWithHome.prototype.positionSprites.call(this);
if(this.artSprite != null) {
this.artSprite.position.set(this.position.x,this.position.y);
}
}
,destroy: function() {
buildings_WorkWithHome.prototype.destroy.call(this);
this.bgStage.removeChild(this.artSprite);
}
,beEntertained: function(citizen,timeMod) {
var moveFunction = function() {
var modifyWithHappiness = false;
var slowMove = true;
if(slowMove == null) {
slowMove = false;
}
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
citizen.moveAndWait(random_Random.getInt(3,16),random_Random.getInt(50,100),null,modifyWithHappiness,slowMove);
};
if(citizen.relativeY < 5) {
citizen.changeFloor(moveFunction);
} else {
moveFunction();
}
}
,get_possibleUpgrades: function() {
return [];
}
,addWindowInfoLines: function() {
var _gthis = this;
this.city.gui.windowAddInfoText(null,function() {
return "Quality: " + (_gthis.get_baseAttractiveness() + _gthis.bonusAttractiveness);
});
var tmp = this.city.gui;
var city = this.city;
var citizens = this.residents;
var topText = "Resident workers of " + this.get_name();
var relatedBuilding = this;
var nothingFoundText = "None";
tmp.windowAddInfoTextClickable(function() {
gui_MultiFollowWindow.createWindow(city,citizens,topText,relatedBuilding,nothingFoundText);
},null,function() {
return "" + _gthis.residents.length + "/" + _gthis.get_residentCapacity() + " resident workers";
});
}
,walkAround: function(citizen,stepsInBuilding) {
var r = random_Random.getInt(3);
if(r == 0 && stepsInBuilding > 120) {
citizen.changeFloorAndWaitRandom(30,60);
} else if(r == 1) {
if(citizen.relativeY < 5) {
citizen.moveAndWait(random_Random.getInt(3,15),random_Random.getInt(30,60),null,false,false);
} else {
citizen.moveAndWait(random_Random.getInt(3,15),random_Random.getInt(30,60),null,false,false);
}
} else {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = random_Random.getInt(90,120);
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
}
,work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking) {
citizen.currentAction = LifeAction.Nothing;
}
var workerIndex = this.workers.indexOf(citizen);
var myPlace = (workerIndex + (1 + ((this.city.simulation.time.timeSinceStart | 0) / 1440 | 0))) % 5;
if(myPlace == 0 || myPlace == 3) {
if(citizen.relativeY > 5) {
citizen.changeFloor();
} else if(myPlace == 0) {
if(citizen.relativeX < 3 || citizen.relativeX > 6 || random_Random.getFloat() < 0.015 * timeMod) {
citizen.moveAndWait(random_Random.getInt(3,7),random_Random.getInt(5,10),null,false,false);
}
} else if(myPlace == 3) {
if(citizen.relativeX < 12 || citizen.relativeX > 15 || random_Random.getFloat() < 0.015 * timeMod) {
citizen.moveAndWait(random_Random.getInt(12,16),random_Random.getInt(5,10),null,false,false);
}
}
} else if(citizen.relativeY < 5) {
citizen.changeFloor();
} else if(myPlace == 1) {
if(citizen.relativeX < 3 || citizen.relativeX > 6 || random_Random.getFloat() < 0.015 * timeMod) {
citizen.moveAndWait(random_Random.getInt(3,7),random_Random.getInt(5,10),null,false,false);
}
} else if(myPlace == 2) {
if(citizen.relativeX < 12 || citizen.relativeX > 15 || random_Random.getFloat() < 0.015 * timeMod) {
citizen.moveAndWait(random_Random.getInt(12,16),random_Random.getInt(5,10),null,false,false);
}
} else if(myPlace == 4) {
if(citizen.relativeX < 8 || citizen.relativeX > 10 || random_Random.getFloat() < 0.015 * timeMod) {
citizen.moveAndWait(random_Random.getInt(8,11),random_Random.getInt(5,10),null,false,false);
}
}
if(this.currentWorkProgress >= 1.0) {
this.currentTexture += 1;
var totalNewWorksUnlocked = 0;
var _g = 0;
var _g1 = buildings_ArtColony.unlockNewWorkAfter;
while(_g < _g1.length) {
var newWorkAfter = _g1[_g];
++_g;
if(this.currentTexture > newWorkAfter) {
++totalNewWorksUnlocked;
}
}
var val1 = this.city.progress.unlocks.numberOfModernArtMuseumArtworksUnlocked;
var val2 = 4 + totalNewWorksUnlocked;
this.city.progress.unlocks.numberOfModernArtMuseumArtworksUnlocked = val2 > val1 ? val2 : val1;
this.currentTexture %= this.artTextures.length;
this.artSprite.texture = this.artTextures[this.currentTexture];
this.currentWorkProgress = 0;
}
this.currentWorkProgress += timeMod * citizen.get_educationSpeedModifier() * this.city.simulation.happiness.actionSpeedModifier * 0.00002;
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_WorkWithHome.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_ArtColony.saveDefinition);
}
var value = this.currentTexture;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.currentWorkProgress;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
}
,load: function(queue,definition) {
buildings_WorkWithHome.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"currentTexture")) {
this.currentTexture = loadMap.h["currentTexture"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"currentWorkProgress")) {
this.currentWorkProgress = loadMap.h["currentWorkProgress"];
}
this.postLoad();
}
,__class__: buildings_ArtColony
});
var buildings_Beacon = function(game,stage,bgStage,city,world,position,worldPosition,id) {
Building.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.lightSpr = new PIXI.Sprite(Resources.getTexture("spr_beacon_light"));
stage.addChild(this.lightSpr);
this.positionSprites();
};
$hxClasses["buildings.Beacon"] = buildings_Beacon;
buildings_Beacon.__name__ = "buildings.Beacon";
buildings_Beacon.__interfaces__ = [buildings_IEntertainmentBuilding];
buildings_Beacon.__super__ = Building;
buildings_Beacon.prototype = $extend(Building.prototype,{
get_isOpen: function() {
return true;
}
,get_entertainmentType: function() {
return 2;
}
,get_minimumNormalTimeToSpend: function() {
return 1.5;
}
,get_maximumNormalTimeToSpend: function() {
return 3;
}
,get_minimumEntertainmentGroupSatisfy: function() {
return 2;
}
,get_maximumEntertainmentGroupSatisfy: function() {
return 3;
}
,get_entertainmentQuality: function() {
return 100;
}
,get_baseEntertainmentCapacity: function() {
return 50;
}
,get_isOpenForExistingVisitors: function() {
return true;
}
,finishEntertainment: function(citizen,timeMod) {
return true;
}
,destroy: function() {
Building.prototype.destroy.call(this);
if(this.lightSpr != null) {
this.lightSpr.destroy();
}
}
,positionSprites: function() {
Building.prototype.positionSprites.call(this);
this.lightSpr.position.set(this.position.x + 8,this.position.y + 1);
this.lightSpr.alpha = 0;
}
,update: function(timeMod) {
Building.prototype.update.call(this,timeMod);
if(((this.city.simulation.time.timeSinceStart | 0) / 60 | 0) % 24 < 6 || ((this.city.simulation.time.timeSinceStart | 0) / 60 | 0) % 24 > 20.5) {
this.lightSpr.alpha = 1;
} else if(((this.city.simulation.time.timeSinceStart | 0) / 60 | 0) % 24 < 6.5) {
this.lightSpr.alpha = (6.5 - this.city.simulation.time.timeSinceStart / 60 % 24) * 2;
} else if(((this.city.simulation.time.timeSinceStart | 0) / 60 | 0) % 24 > 20) {
this.lightSpr.alpha = (this.city.simulation.time.timeSinceStart / 60 % 24 - 20) * 2;
} else {
this.lightSpr.alpha = 0;
}
}
,beEntertained: function(citizen,timeMod) {
if(random_Random.getFloat() < 0.5) {
citizen.moveAndWait(random_Random.getInt(4,8),random_Random.getInt(60,90),null,false,false);
} else {
citizen.moveAndWait(random_Random.getInt(11,15),random_Random.getInt(60,90),null,false,false);
}
}
,addWindowInfoLines: function() {
Building.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText("The Beacon has been designed together with Hydra, who won the first building contest in the Discord!");
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
Building.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_Beacon.saveDefinition);
}
}
,load: function(queue,definition) {
Building.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
}
,__class__: buildings_Beacon
});
var buildings_BlossomHippieHQ = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.canLeaveForBG = 0;
this.eventBotanicalGardens = null;
this.timeToCheckBuildings = 0;
this.currentMission = 0;
this.eventPhase = 0;
this.doingEvent = -1;
this.lastEventDoneOnDay = 0;
buildings_WorkWithHome.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.startTime = 11;
this.endTime = 23;
this.workTimePreferenceMod = 0.3;
};
$hxClasses["buildings.BlossomHippieHQ"] = buildings_BlossomHippieHQ;
buildings_BlossomHippieHQ.__name__ = "buildings.BlossomHippieHQ";
buildings_BlossomHippieHQ.__super__ = buildings_WorkWithHome;
buildings_BlossomHippieHQ.prototype = $extend(buildings_WorkWithHome.prototype,{
positionSprites: function() {
buildings_WorkWithHome.prototype.positionSprites.call(this);
}
,destroy: function() {
buildings_WorkWithHome.prototype.destroy.call(this);
}
,addWindowInfoLines: function() {
var _gthis = this;
buildings_WorkWithHome.prototype.addWindowInfoLines.call(this);
this.city.gui.windowInner.addChild(new gui_GUISpacing(this.city.gui.window,new common_Point(4,4)));
this.city.gui.windowAddInfoText(null,function() {
return _gthis.missionGetTitle();
},"Arial15");
this.city.gui.windowAddInfoText(null,function() {
return _gthis.missionGetText();
});
}
,createMainWindowPart: function() {
var _gthis = this;
buildings_WorkWithHome.prototype.createMainWindowPart.call(this);
var skipButtonExists = false;
var skipButton = null;
var guiSpacing = null;
var buttonContainer = new gui_GUIContainer(this.city.gui,this.city.gui.innerWindowStage,this.city.gui.windowInner);
buttonContainer.direction = gui_GUIContainerDirection.Vertical;
this.city.gui.windowInner.addChild(buttonContainer);
buttonContainer.onUpdate = function() {
if(_gthis.currentMission == 2) {
if(!skipButtonExists) {
skipButtonExists = true;
skipButton = new gui_TextButton(_gthis.city.gui,_gthis.city.gui.innerWindowStage,buttonContainer,function() {
if(_gthis.currentMission == 2 && _gthis.city.materials.canAfford(new Materials(0,0,10000))) {
_gthis.currentMission = 3;
var _g = _gthis.city.materials;
_g.set_food(_g.food - 10000);
} else {
var showWarningWindow = function() {
_gthis.city.gui.showSimpleWindow("You can't afford bribing the Hippies right now!",null,true);
};
showWarningWindow();
_gthis.city.gui.addWindowToStack(showWarningWindow);
}
},"... or bribe the Hippies and skip this\ntask for 10,000 food");
buttonContainer.addChild(skipButton);
guiSpacing = buttonContainer.addChild(new gui_GUISpacing(buttonContainer,new common_Point(4,4)));
}
} else if(skipButtonExists) {
skipButton.destroy();
buttonContainer.removeChild(skipButton);
skipButtonExists = false;
guiSpacing.destroy();
buttonContainer.removeChild(guiSpacing);
}
};
}
,missionGetTitle: function() {
if(this.currentMission == 8) {
return "Thank You";
}
return "Current Task";
}
,missionGetText: function() {
if(this.currentMission == 8) {
return "Peace out!";
}
if(this.workers.length != this.get_jobs()) {
return "Open the Flower Buds:\nMake sure all 6 jobs are filled.";
}
switch(this.currentMission) {
case 0:
return "Flower Link:\nBuild at least two teleporters each surrounded by Botanical Gardens.";
case 1:
return "Flowery Dining:\nBuild three Blossom Restaurants.";
case 2:
return "Actual Nature:\nHave at least one protected forest.";
case 3:
return "Together in Harmony:\nBuild twenty Community Houses.";
case 4:
return "Organicize:\nBuild thirty Eco Farms.";
case 5:
return "Don't Waste:\nBuild nine Farm By-Product Processors.";
case 6:
return "Peaceful Society:\nResearch Societal Living in the Living Research Center.";
case 7:
return "Make the City Sing:\nBuild the Festival HQ.";
default:
return "";
}
}
,checkMissionCompletions: function() {
var missionComplete = false;
while(true) {
missionComplete = false;
switch(this.currentMission) {
case 0:
var timesComplete = 0;
var _g = 0;
var _g1 = this.city.permanents;
while(_g < _g1.length) {
var bld = _g1[_g];
++_g;
if(bld.is(buildings_Teleporter)) {
var bld1 = bld;
if(bld1.leftBuilding != null && bld1.rightBuilding != null && bld1.topBuilding != null && bld1.bottomBuilding != null && bld1.leftBuilding.is(buildings_BotanicalGardens) && bld1.rightBuilding.is(buildings_BotanicalGardens) && bld1.bottomBuilding.is(buildings_BotanicalGardens) && bld1.topBuilding.is(buildings_BotanicalGardens)) {
++timesComplete;
}
}
}
if(timesComplete >= 2) {
missionComplete = true;
this.city.progress.unlocks.unlock(buildings_BlossomRestaurant);
}
break;
case 2:
var _g2 = 0;
var _g3 = this.city.permanents;
while(_g2 < _g3.length) {
var bld2 = _g3[_g2];
++_g2;
if(bld2.is(worldResources_Forest)) {
var thisForest = bld2;
if(thisForest.managementMode == worldResources_ForestManagementMode.Protect) {
missionComplete = true;
this.city.progress.unlocks.unlock(buildings_FarmHouse);
}
}
}
break;
case 6:
missionComplete = common_ArrayExtensions.any(this.city.upgrades.upgrades,function(cu) {
return ((cu) instanceof cityUpgrades_SuperSpaciousLiving);
});
if(missionComplete) {
this.city.progress.unlocks.unlock(buildings_FestivalHQ);
}
break;
default:
}
if(this.timeToCheckBuildings <= 0 && this.currentMission != 0 && this.currentMission != 2 && this.currentMission != 6 && this.currentMission != 8) {
var buildingsByType = this.city.getAmountOfPermanentsPerType();
switch(this.currentMission) {
case 1:
missionComplete = buildingsByType.h["buildings.BlossomRestaurant"] >= 3;
break;
case 3:
missionComplete = buildingsByType.h["buildings.FarmHouse"] >= 20;
break;
case 4:
missionComplete = buildingsByType.h["buildings.EcoFarm"] >= 30;
if(missionComplete) {
this.city.progress.unlocks.unlock(buildings_FarmByProductProcessor);
}
break;
case 5:
missionComplete = buildingsByType.h["buildings.FarmByProductProcessor"] >= 9;
if(missionComplete) {
this.city.progress.unlocks.unlock(cityUpgrades_SuperSpaciousLiving);
}
break;
case 7:
missionComplete = buildingsByType.h["buildings.FestivalHQ"] >= 1;
break;
default:
}
this.timeToCheckBuildings = 30;
}
if(missionComplete) {
this.currentMission += 1;
this.timeToCheckBuildings = 0;
this.city.progress.goalHelp.updateHasBuildingGoal();
}
if(!missionComplete) {
break;
}
}
}
,update: function(timeMod) {
buildings_WorkWithHome.prototype.update.call(this,timeMod);
this.checkMissionCompletions();
this.timeToCheckBuildings -= timeMod;
this.canLeaveForBG -= timeMod;
}
,work: function(citizen,timeMod,shouldStopWorking) {
var _gthis = this;
if(citizen.inPermanent != null && citizen.inPermanent.is(buildings_BotanicalGardens) && citizen.inPermanent.isTree()) {
if(this.eventPhase != 0) {
citizen.setRelativeY(citizen.relativeY - 0.4 * timeMod);
if(citizen.relativeY <= 0) {
if((citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null).bottomBuilding != null && (citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null).bottomBuilding.is(buildings_BotanicalGardens)) {
citizen.setRelativeY(citizen.relativeY + 20);
citizen.inPermanent = (citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null).bottomBuilding;
return;
} else {
citizen.setRelativeY(0);
this.doingEvent = -1;
}
} else {
return;
}
} else {
var spd = citizen.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
var tmp;
if(Math.abs(9 - citizen.relativeX) < spd) {
citizen.relativeX = 9;
tmp = true;
} else {
var num = 9 - citizen.relativeX;
citizen.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
tmp = false;
}
if(tmp) {
citizen.setRelativeY(citizen.relativeY + 0.4 * timeMod);
if(citizen.relativeY >= 10) {
if((citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null).topBuilding != null && (citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null).topBuilding.is(buildings_BotanicalGardens)) {
citizen.setRelativeY(citizen.relativeY - 20);
citizen.inPermanent = (citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null).topBuilding;
} else {
this.eventPhase = 1;
}
}
}
return;
}
} else if(this.doingEvent != -1) {
citizen.setRelativeY(0);
if(this.eventBotanicalGardens == null) {
this.eventBotanicalGardens = this.city.simulation.permanentFinder.query(this,function(pm) {
if(pm.is(buildings_BotanicalGardens)) {
var bg = pm;
if(bg.bottomBuilding == null || !bg.bottomBuilding.is(buildings_BotanicalGardens)) {
return bg.isTree();
} else {
return false;
}
}
return false;
});
}
if(this.eventBotanicalGardens != null) {
if(this.canLeaveForBG <= 0) {
citizen.simulation.pathfinder.findPath(citizen,this.eventBotanicalGardens);
citizen.pathOnFail = function() {
_gthis.doingEvent = -1;
};
this.canLeaveForBG = 20;
}
return;
} else {
this.doingEvent = -1;
}
}
if(shouldStopWorking) {
citizen.currentAction = LifeAction.Nothing;
return;
}
if(citizen.inPermanent != this) {
citizen.setRelativeY(0);
citizen.simulation.pathfinder.findPath(citizen,this);
citizen.pathOnFail = null;
return;
}
this.doWalkAround(citizen);
if(((this.city.simulation.time.timeSinceStart | 0) / 60 | 0) % 24 > 10) {
if(1 + ((this.city.simulation.time.timeSinceStart | 0) / 1440 | 0) > this.lastEventDoneOnDay) {
this.doingEvent = 1;
this.eventPhase = 0;
this.lastEventDoneOnDay = 1 + ((this.city.simulation.time.timeSinceStart | 0) / 1440 | 0);
}
}
}
,walkAround: function(citizen,stepsInBuilding) {
this.doWalkAround(citizen);
}
,doWalkAround: function(citizen) {
if(citizen.relativeX < 7 && random_Random.getFloat() < 0.3) {
citizen.changeFloorAndWaitRandom(10,30);
} else if(citizen.relativeY > 5 || random_Random.getFloat() > 0.5) {
citizen.moveAndWait(random_Random.getInt(3,7),random_Random.getInt(60,180),null,false,false);
} else {
citizen.moveAndWait(random_Random.getInt(12,16),random_Random.getInt(60,180),null,false,false);
}
}
,getGlobalGoal: function() {
if(this.currentMission == 8) {
return null;
}
return { category : "Hippie Mission", text : this.missionGetText()};
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_WorkWithHome.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_BlossomHippieHQ.saveDefinition);
}
var value = this.lastEventDoneOnDay;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.doingEvent;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.eventPhase;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.currentMission;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
,load: function(queue,definition) {
buildings_WorkWithHome.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"lastEventDoneOnDay")) {
this.lastEventDoneOnDay = loadMap.h["lastEventDoneOnDay"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"doingEvent")) {
this.doingEvent = loadMap.h["doingEvent"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"eventPhase")) {
this.eventPhase = loadMap.h["eventPhase"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"currentMission")) {
this.currentMission = loadMap.h["currentMission"];
}
}
,__class__: buildings_BlossomHippieHQ
});
var buildings_BlossomHut = function(game,stage,bgStage,city,world,position,worldPosition,id) {
buildings_House.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.get_mergingDrawer().setBackgroundTextures("spr_bloomhouse");
};
$hxClasses["buildings.BlossomHut"] = buildings_BlossomHut;
buildings_BlossomHut.__name__ = "buildings.BlossomHut";
buildings_BlossomHut.__super__ = buildings_House;
buildings_BlossomHut.prototype = $extend(buildings_House.prototype,{
get_drawerType: function() {
return buildings_buildingDrawers_AllDirMergingBuildingDrawer;
}
,get_mergingDrawer: function() {
return this.drawer;
}
,postCreate: function() {
buildings_House.prototype.postCreate.call(this);
this.positionSprites();
}
,positionSprites: function() {
buildings_House.prototype.positionSprites.call(this);
}
,walkAround: function(citizen,stepsInBuilding) {
if(citizen.relativeX == 9) {
citizen.canViewSelfInBuilding = false;
} else {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = 9;
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
}
,__class__: buildings_BlossomHut
});
var buildings_BlossomRestaurant = function(game,stage,bgStage,city,world,position,worldPosition,id) {
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.startTime = 16;
this.endTime = 1;
this.workTimePreferenceMod = 0.5;
this.isEntertainment = true;
this.get_mergingDrawer().setForegroundTextures("spr_bloomrestaurant_foreground");
};
$hxClasses["buildings.BlossomRestaurant"] = buildings_BlossomRestaurant;
buildings_BlossomRestaurant.__name__ = "buildings.BlossomRestaurant";
buildings_BlossomRestaurant.__interfaces__ = [buildings_IEntertainmentBuilding];
buildings_BlossomRestaurant.__super__ = buildings_Work;
buildings_BlossomRestaurant.prototype = $extend(buildings_Work.prototype,{
get_baseEntertainmentCapacity: function() {
var bec = 50;
bec += this.getEffectsOfAdjecentBuildingsLR("restaurantCapBoost");
return this.workers.length * bec | 0;
}
,get_isOpen: function() {
if(this.workers.length >= 1 && this.workers[0].currentAction == LifeAction.Work) {
var this1 = this.city.simulation.time.timeSinceStart / 60 % 24;
var start = this.startTime - this.workTimePreferenceMod;
if(start < 0.5) {
if(this1 >= start) {
return this1 < 0.5;
} else {
return false;
}
} else if(!(this1 >= start)) {
return this1 < 0.5;
} else {
return true;
}
} else {
return false;
}
}
,get_entertainmentType: function() {
return 1;
}
,get_minimumNormalTimeToSpend: function() {
return 1;
}
,get_maximumNormalTimeToSpend: function() {
return 2;
}
,get_minimumEntertainmentGroupSatisfy: function() {
return 1;
}
,get_maximumEntertainmentGroupSatisfy: function() {
return 3;
}
,get_entertainmentQuality: function() {
return 100;
}
,get_isOpenForExistingVisitors: function() {
return this.get_isOpen();
}
,finishEntertainment: function(citizen,timeMod) {
return true;
}
,get_drawerType: function() {
return buildings_buildingDrawers_AllDirMergingBuildingDrawer;
}
,get_mergingDrawer: function() {
return this.drawer;
}
,beEntertained: function(citizen,timeMod) {
if(!citizen.hasBuildingInited) {
if(this.bottomBuilding == null || !this.bottomBuilding.is(buildings_BlossomRestaurant)) {
var i = random_Random.getInt(6);
switch(i) {
case 0:
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = 1;
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
break;
case 1:
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = 2;
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
break;
case 2:
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = 5;
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
break;
case 3:
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = 13;
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
break;
case 4:
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = 14;
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
break;
case 5:
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = 17;
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
break;
}
} else {
var i = random_Random.getInt(4);
switch(i) {
case 0:
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = 1;
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
break;
case 1:
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = 4;
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
break;
case 2:
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = 12;
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
break;
case 3:
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = 17;
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
break;
}
}
citizen.hasBuildingInited = true;
} else {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = random_Random.getInt(30,60);
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
}
,work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking && this.city.simulation.time.timeSinceStart / 60 % 24 > 0.5) {
citizen.currentAction = LifeAction.Nothing;
} else {
var modifyWithHappiness = false;
var slowMove = true;
if(slowMove == null) {
slowMove = false;
}
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
citizen.moveAndWait(random_Random.getInt(3,18),random_Random.getInt(60,120),null,modifyWithHappiness,slowMove);
}
}
,__class__: buildings_BlossomRestaurant
});
var buildings_BlueCollarWork = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.hasNotSearchedForResourceGatherPlaceThisStep = true;
this.nearestResourceGatherPlace = null;
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
};
$hxClasses["buildings.BlueCollarWork"] = buildings_BlueCollarWork;
buildings_BlueCollarWork.__name__ = "buildings.BlueCollarWork";
buildings_BlueCollarWork.__super__ = buildings_Work;
buildings_BlueCollarWork.prototype = $extend(buildings_Work.prototype,{
doBlueCollarJob: function(citizen,timeMod,shouldStopWorking,resourceOptions,getResource,minChopTime,maxChopTime) {
var _gthis = this;
if(shouldStopWorking) {
if(!citizen.hasWorkTools) {
citizen.currentAction = LifeAction.Nothing;
} else if(citizen.inPermanent == this) {
citizen.moveAndWait(4,20,function() {
citizen.hasWorkTools = false;
});
} else {
citizen.simulation.pathfinder.findPath(citizen,this);
citizen.pathOnFail = null;
}
} else if(citizen.hasWorkTools) {
var citizenInResource = false;
var _g = 0;
while(_g < resourceOptions.length) {
var o = resourceOptions[_g];
++_g;
if(js_Boot.__instanceof(citizen.inPermanent,o)) {
citizenInResource = true;
break;
}
}
if(citizenInResource && (citizen.inPermanent.materialsLeft > 0 || citizen.inPermanent.get_stayIfEmpty()) && !citizen.inPermanent.get_doNotGather()) {
var resourceGatherPlace = citizen.inPermanent;
if(resourceGatherPlace.materialsLeft > 0) {
var modifyWithHappiness = true;
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
citizen.moveAndWait(random_Random.getInt(resourceGatherPlace.minCitizenX,resourceGatherPlace.maxCitizenX),random_Random.getInt(minChopTime,maxChopTime),function() {
if(resourceGatherPlace.get_doNotGather()) {
_gthis.nearestResourceGatherPlace = null;
return;
}
getResource(resourceGatherPlace);
if(resourceGatherPlace.materialsLeft <= 0 && !resourceGatherPlace.get_stayIfEmpty()) {
_gthis.nearestResourceGatherPlace = null;
if(resourceGatherPlace.get_destroyedOnEmpty()) {
resourceGatherPlace.destroy();
}
} else {
resourceGatherPlace.updateTexture();
}
},modifyWithHappiness,false);
}
} else {
var performCitizenAction = true;
if(this.nearestResourceGatherPlace == null || this.nearestResourceGatherPlace.materialsLeft <= 0 && !this.nearestResourceGatherPlace.get_stayIfEmpty() || this.nearestResourceGatherPlace.get_doNotGather()) {
this.nearestResourceGatherPlace = null;
var notRateLimited = this.city.simulation.permanentFinder.canPerformQuery();
if(!notRateLimited) {
performCitizenAction = false;
}
var tmp;
if(notRateLimited && this.hasNotSearchedForResourceGatherPlaceThisStep) {
var this1 = this.world.knownResourceInavailability;
var key = resourceOptions[0].__name__;
tmp = !Object.prototype.hasOwnProperty.call(this1.h,key);
} else {
tmp = false;
}
if(tmp) {
if(this.city.simulation.resourcePriorityManager.hasResourcePrioritiesFor(resourceOptions[0])) {
var findFunc = resourceOptions.length == 0 ? function(pm) {
if(pm.is(resourceOptions[0]) && pm.materialsLeft > 0 && !pm.get_doNotGather()) {
return _gthis.city.simulation.resourcePriorityManager.isPrioritized(pm);
} else {
return false;
}
} : function(pm) {
if(common_ArrayExtensions.any(resourceOptions,function(ro) {
return pm.is(ro);
}) && pm.materialsLeft > 0 && !pm.get_doNotGather()) {
return _gthis.city.simulation.resourcePriorityManager.isPrioritized(pm);
} else {
return false;
}
};
this.nearestResourceGatherPlace = this.city.simulation.permanentFinder.query(this,findFunc);
}
if(this.nearestResourceGatherPlace == null) {
var findFunc = resourceOptions.length == 0 ? function(pm) {
if(pm.is(resourceOptions[0]) && pm.materialsLeft > 0) {
return !pm.get_doNotGather();
} else {
return false;
}
} : function(pm) {
if(common_ArrayExtensions.any(resourceOptions,function(ro) {
return pm.is(ro);
}) && pm.materialsLeft > 0) {
return !pm.get_doNotGather();
} else {
return false;
}
};
this.nearestResourceGatherPlace = this.city.simulation.permanentFinder.query(this,findFunc);
}
if(this.nearestResourceGatherPlace == null) {
var this1 = this.world.knownResourceInavailability;
var k = resourceOptions[0].__name__;
this1.h[k] = true;
}
this.hasNotSearchedForResourceGatherPlaceThisStep = false;
}
}
if(performCitizenAction) {
if(this.nearestResourceGatherPlace != null) {
citizen.simulation.pathfinder.findPath(citizen,this.nearestResourceGatherPlace);
citizen.pathOnFail = null;
} else {
citizen.wander(timeMod);
}
}
}
} else if(citizen.inPermanent == this) {
citizen.moveAndWait(4,20,function() {
citizen.hasWorkTools = true;
});
} else {
citizen.simulation.pathfinder.findPath(citizen,this);
citizen.pathOnFail = null;
}
}
,update: function(timeMod) {
buildings_Work.prototype.update.call(this,timeMod);
this.hasNotSearchedForResourceGatherPlaceThisStep = true;
}
,invalidatePathfindingRelatedInfo: function() {
buildings_Work.prototype.invalidatePathfindingRelatedInfo.call(this);
this.nearestResourceGatherPlace = null;
}
,__class__: buildings_BlueCollarWork
});
var buildings_BoardGameStore = function(game,stage,bgStage,city,world,position,worldPosition,id) {
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.startTime = 11;
this.endTime = 23.5;
this.workTimePreferenceMod = 0.1;
this.isEntertainment = true;
};
$hxClasses["buildings.BoardGameStore"] = buildings_BoardGameStore;
buildings_BoardGameStore.__name__ = "buildings.BoardGameStore";
buildings_BoardGameStore.__interfaces__ = [buildings_IEntertainmentBuilding];
buildings_BoardGameStore.__super__ = buildings_Work;
buildings_BoardGameStore.prototype = $extend(buildings_Work.prototype,{
get_baseEntertainmentCapacity: function() {
return this.workers.length * 90;
}
,get_isOpen: function() {
if(this.workers.length == 1 && this.workers[0].currentAction == LifeAction.Work) {
return this.city.simulation.time.timeSinceStart / 60 % 24 < 23;
} else {
return false;
}
}
,get_entertainmentType: function() {
return 4;
}
,get_minimumNormalTimeToSpend: function() {
return 3;
}
,get_maximumNormalTimeToSpend: function() {
return 3.5;
}
,get_minimumEntertainmentGroupSatisfy: function() {
return 4;
}
,get_maximumEntertainmentGroupSatisfy: function() {
return 8;
}
,get_entertainmentQuality: function() {
return 100;
}
,get_isOpenForExistingVisitors: function() {
return this.get_isOpen();
}
,finishEntertainment: function(citizen,timeMod) {
return true;
}
,beEntertained: function(citizen,timeMod) {
var moveFunction = function() {
var xx = citizen.relativeY < 5 ? random_Random.getInt(8,16) : random_Random.getInt(2) == 0 ? random_Random.fromArray(buildings_BoardGameStore.firstFloorChairs) : random_Random.getInt(3,14);
var modifyWithHappiness = false;
var slowMove = true;
if(slowMove == null) {
slowMove = false;
}
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
citizen.moveAndWait(random_Random.getInt(xx,xx + 1),random_Random.getInt(100,120),null,modifyWithHappiness,slowMove);
};
if(random_Random.getInt(3 - citizen.relativeY < 10 ? 1 : 0) == 0) {
citizen.changeFloor(moveFunction);
} else {
moveFunction();
}
}
,work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking) {
citizen.currentAction = LifeAction.Nothing;
} else {
var spd = citizen.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
if(Math.abs(4 - citizen.relativeX) < spd) {
citizen.relativeX = 4;
} else {
var num = 4 - citizen.relativeX;
citizen.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
}
citizen.setRelativeY(1);
}
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Work.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_BoardGameStore.saveDefinition);
}
}
,load: function(queue,definition) {
buildings_Work.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
}
,__class__: buildings_BoardGameStore
});
var buildings_IBuildingWithFestivalSpecials = function() { };
$hxClasses["buildings.IBuildingWithFestivalSpecials"] = buildings_IBuildingWithFestivalSpecials;
buildings_IBuildingWithFestivalSpecials.__name__ = "buildings.IBuildingWithFestivalSpecials";
buildings_IBuildingWithFestivalSpecials.__isInterface__ = true;
buildings_IBuildingWithFestivalSpecials.prototype = {
__class__: buildings_IBuildingWithFestivalSpecials
};
var buildings_BotanicalGardens = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.justBuilt = false;
this.festivalJobs = 2;
this.currentTexture = 0;
this.currentMainTexture = 0;
Building.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.isEntertainment = true;
this.currentTexture = 0;
this.adjecentBuildingEffects.push({ name : "modernRusticHomeCommunityFeeling", intensity : 1});
};
$hxClasses["buildings.BotanicalGardens"] = buildings_BotanicalGardens;
buildings_BotanicalGardens.__name__ = "buildings.BotanicalGardens";
buildings_BotanicalGardens.__interfaces__ = [buildings_IBuildingWithFestivalSpecials,buildings_IEntertainmentBuilding];
buildings_BotanicalGardens.__super__ = Building;
buildings_BotanicalGardens.prototype = $extend(Building.prototype,{
get_baseEntertainmentCapacity: function() {
return 40;
}
,get_isOpen: function() {
if(this.bottomBuilding == null || !this.bottomBuilding.is(buildings_BotanicalGardens)) {
var this1 = this.city.simulation.time.timeSinceStart / 60 % 24;
if(this1 >= 6.0) {
return this1 < 22;
} else {
return false;
}
} else {
return false;
}
}
,get_entertainmentType: function() {
return 3;
}
,get_minimumNormalTimeToSpend: function() {
return 2.5;
}
,get_maximumNormalTimeToSpend: function() {
return 4;
}
,get_minimumEntertainmentGroupSatisfy: function() {
return 1;
}
,get_maximumEntertainmentGroupSatisfy: function() {
return 1.5;
}
,get_entertainmentQuality: function() {
return 100;
}
,get_drawerType: function() {
return buildings_buildingDrawers_AllDirMergingBuildingDrawer;
}
,get_mergingDrawer: function() {
return this.drawer;
}
,get_walkThroughCanViewSelfInThisBuilding: function() {
if(this.bottomBuilding != null) {
return !this.bottomBuilding.is(buildings_BotanicalGardens);
} else {
return true;
}
}
,get_isOpenForExistingVisitors: function() {
return this.get_isOpen();
}
,finishEntertainment: function(citizen,timeMod) {
return true;
}
,postCreate: function() {
Building.prototype.postCreate.call(this);
this.updateGardenTexture();
if(this.justBuilt) {
var buildingToTakeTextureFrom = null;
if(this.bottomBuilding != null && this.bottomBuilding.is(buildings_BotanicalGardens)) {
buildingToTakeTextureFrom = this.bottomBuilding;
}
if(this.topBuilding != null && this.topBuilding.is(buildings_BotanicalGardens)) {
buildingToTakeTextureFrom = this.topBuilding;
}
if(buildingToTakeTextureFrom != null) {
this.get_mergingDrawer().setGroupOfSecondaryTextureForThisBuilding(this.get_mergingDrawer().getSecondaryTextureGroup(buildingToTakeTextureFrom.currentTexture));
} else {
this.currentTexture = random_Random.getInt(common_ArrayExtensions.isum(buildings_BotanicalGardens.gardenTextureSets));
}
this.justBuilt = false;
this.updateGardenTexture();
}
this.positionSprites();
}
,postLoad: function() {
this.updateGardenTexture();
this.changeMainTexture(buildings_BotanicalGardens.mainTextures[this.currentMainTexture]);
}
,onBuild: function() {
Building.prototype.onBuild.call(this);
this.justBuilt = true;
}
,updateGardenTexture: function() {
var _gthis = this;
this.get_mergingDrawer().setSecondaryBackgroundImages("spr_botanicalgardens_plants",buildings_BotanicalGardens.gardenTextureSets,this.currentTexture,function(n) {
_gthis.currentTexture = n;
});
}
,beEntertained: function(citizen,timeMod) {
buildings_buildingBehaviours_ParkWalk.beEntertainedPark(this.leftBuilding,this.rightBuilding,citizen);
}
,createWindowAddBottomButtons: function() {
var _gthis = this;
gui_windowParts_CycleValueButton.create(this.city.gui,function() {
return _gthis.currentMainTexture;
},function(t) {
_gthis.currentMainTexture = t;
_gthis.changeMainTexture(buildings_BotanicalGardens.mainTextures[_gthis.currentMainTexture]);
},function() {
return buildings_BotanicalGardens.mainTextures.length;
},"Change Building Color");
gui_windowParts_CycleValueButton.create(this.city.gui,function() {
return _gthis.get_mergingDrawer().getCurrentSecondaryTextureGroup();
},($_=this.get_mergingDrawer(),$bind($_,$_.setGroupOfSecondaryTexture)),function() {
return buildings_BotanicalGardens.gardenTextureSets.length;
},"Change Plants");
gui_windowParts_CycleValueButton.create(this.city.gui,function() {
return _gthis.currentTexture - _gthis.get_mergingDrawer().getFirstSecondaryTextureOfGroup(_gthis.get_mergingDrawer().getCurrentSecondaryTextureGroup());
},($_=this.get_mergingDrawer(),$bind($_,$_.setSecondaryTextureWithinGroup)),function() {
return buildings_BotanicalGardens.gardenTextureSets[_gthis.get_mergingDrawer().getCurrentSecondaryTextureGroup()];
},"Change Plants Variant");
Building.prototype.createWindowAddBottomButtons.call(this);
}
,destroy: function() {
Building.prototype.destroy.call(this);
if(this.festivalEntertainment != null) {
this.festivalEntertainment.destroy();
}
}
,initFestival: function() {
if(this.festivalEntertainment == null) {
this.festivalEntertainment = new buildings_buildingBehaviours_ParkFestivalEntertainment(this,this.bgStage);
}
}
,stopFestival: function() {
if(this.festivalEntertainment != null) {
this.festivalEntertainment.stop();
this.festivalEntertainment.destroy();
this.festivalEntertainment = null;
}
}
,doFestivalWork: function(festival,citizen,timeMod,citizenID) {
this.festivalEntertainment.doFestivalWork(festival,citizen,timeMod,0,citizenID);
}
,beEntertainedFestival: function(festival,citizen,timeMod) {
this.festivalEntertainment.beEntertainedFestival(festival,citizen,timeMod);
}
,endFestivalWork: function(festival,citizen) {
citizen.setRelativeY(0);
}
,isTree: function() {
if(this.currentTexture >= 7) {
return this.currentTexture <= 10;
} else {
return false;
}
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
Building.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_BotanicalGardens.saveDefinition);
}
var value = this.currentMainTexture;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.currentTexture;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
,load: function(queue,definition) {
Building.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"currentMainTexture")) {
this.currentMainTexture = loadMap.h["currentMainTexture"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"currentTexture")) {
this.currentTexture = loadMap.h["currentTexture"];
}
this.postLoad();
}
,__class__: buildings_BotanicalGardens
});
var buildings_CacaoFarmStage = $hxEnums["buildings.CacaoFarmStage"] = { __ename__ : "buildings.CacaoFarmStage", __constructs__ : ["Growing","Harvesting"]
,Growing: {_hx_index:0,__enum__:"buildings.CacaoFarmStage",toString:$estr}
,Harvesting: {_hx_index:1,__enum__:"buildings.CacaoFarmStage",toString:$estr}
};
var buildings_CacaoFarm = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.percentCleaned = 0;
this.foodLeft = 0;
this.percentGrown = 0;
this.farmStage = buildings_CacaoFarmStage.Growing;
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.textures = Resources.getTexturesByWidth("spr_cacaofarm_trees",20);
this.growthSprite = new PIXI.Sprite();
bgStage.addChild(this.growthSprite);
this.updateTexture();
this.positionSprites();
this.doorX = 12;
this.adjecentBuildingEffects.push({ name : "farm", intensity : 1});
};
$hxClasses["buildings.CacaoFarm"] = buildings_CacaoFarm;
buildings_CacaoFarm.__name__ = "buildings.CacaoFarm";
buildings_CacaoFarm.__super__ = buildings_Work;
buildings_CacaoFarm.prototype = $extend(buildings_Work.prototype,{
postLoad: function() {
this.updateTexture();
}
,work: function(citizen,timeMod,shouldStopWorking) {
var _gthis = this;
if(shouldStopWorking) {
citizen.currentAction = LifeAction.Nothing;
} else if(this.farmStage == buildings_CacaoFarmStage.Growing) {
citizen.setRelativeY(0);
var modifyWithHappiness = this.city.materials.food > 1 || this.city.simulation.happiness.actionSpeedModifier > 1;
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
citizen.moveAndWait(random_Random.getInt(5,13),random_Random.getInt(50,100),function() {
_gthis.percentGrown += 0.75;
if(_gthis.percentGrown >= 100) {
_gthis.farmStage = buildings_CacaoFarmStage.Harvesting;
var tmp = 35 + _gthis.city.simulation.bonuses.extraFoodFromFarms;
var tmp1 = _gthis.getEffectsOfAdjecentBuildings("increaseCropNumber");
_gthis.foodLeft = tmp + tmp1;
}
_gthis.updateTexture();
},modifyWithHappiness,false);
} else {
var firstTreeX = 6;
var secondTreeX = 12;
var firstTreeY = 7;
var secondTreeY = 5;
if(citizen.relativeY <= 1) {
if(this.workers.indexOf(citizen) == 0) {
citizen.setPath(new Int32Array([4,firstTreeX,9,firstTreeY]),0,4,true);
} else {
citizen.setPath(new Int32Array([4,secondTreeX,9,secondTreeY]),0,4,true);
}
} else {
var thisHarvestAmount = this.city.simulation.boostManager.currentGlobalBoostAmount * 0.025 / this.city.simulation.happiness.actionSpeedModifier;
this.foodLeft -= thisHarvestAmount;
var _g = this.city.materials;
_g.set_food(_g.food + thisHarvestAmount);
this.city.simulation.stats.materialProduction[0][0] += thisHarvestAmount;
this.city.materials.cacao += thisHarvestAmount;
this.city.simulation.stats.materialProduction[6][0] += thisHarvestAmount;
if(this.foodLeft <= 0) {
this.farmStage = buildings_CacaoFarmStage.Growing;
this.percentGrown = 0;
}
this.updateTexture();
}
}
}
,destroy: function() {
buildings_Work.prototype.destroy.call(this);
this.bgStage.removeChild(this.growthSprite);
}
,update: function(timeMod) {
if(this.farmStage == buildings_CacaoFarmStage.Growing) {
var this1 = this.city.simulation.time.timeSinceStart / 60 % 24;
var start = 7;
var end = 20;
if(start < end ? this1 >= start && this1 < end : this1 >= start || this1 < end) {
this.percentGrown += timeMod * 0.012;
if(this.percentGrown >= 100) {
this.farmStage = buildings_CacaoFarmStage.Harvesting;
this.foodLeft = 35 + this.city.simulation.bonuses.extraFoodFromFarms + this.getEffectsOfAdjecentBuildings("increaseCropNumber");
}
this.updateTexture();
} else {
var this1 = this.city.simulation.time.timeSinceStart / 60 % 24;
var start = 7 - 1;
var end = 20 + 1;
if(start < end ? this1 >= start && this1 < end : this1 >= start || this1 < end) {
this.percentGrown += timeMod * 0.006;
if(this.percentGrown >= 100) {
this.farmStage = buildings_CacaoFarmStage.Harvesting;
this.foodLeft = 35 + this.city.simulation.bonuses.extraFoodFromFarms + this.getEffectsOfAdjecentBuildings("increaseCropNumber");
}
this.updateTexture();
}
}
}
}
,grow: function(percent) {
this.percentGrown += percent;
if(this.percentGrown >= 100) {
this.farmStage = buildings_CacaoFarmStage.Harvesting;
this.foodLeft = 35 + this.city.simulation.bonuses.extraFoodFromFarms + this.getEffectsOfAdjecentBuildings("increaseCropNumber");
}
this.updateTexture();
}
,updateTexture: function() {
var tmp;
switch(this.farmStage._hx_index) {
case 0:
tmp = this.textures[Math.floor(this.percentGrown / 100 * (this.textures.length - 1))];
break;
case 1:
tmp = this.textures[this.textures.length - 1];
break;
}
this.growthSprite.texture = tmp;
}
,positionSprites: function() {
buildings_Work.prototype.positionSprites.call(this);
if(this.growthSprite != null) {
this.growthSprite.position.set(this.position.x,this.position.y);
}
}
,addWindowInfoLines: function() {
var _gthis = this;
buildings_Work.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
switch(_gthis.farmStage._hx_index) {
case 0:
return "Beans " + Math.floor(_gthis.percentGrown) + "% grown.";
case 1:
return "" + Math.floor(_gthis.foodLeft) + " cacao left to harvest.";
}
});
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Work.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_CacaoFarm.saveDefinition);
}
var e = this.farmStage;
queue.addString($hxEnums[e.__enum__].__constructs__[e._hx_index]);
var value = this.percentGrown;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.foodLeft;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.percentCleaned;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
}
,load: function(queue,definition) {
buildings_Work.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"farmStage")) {
this.farmStage = loadMap.h["farmStage"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"percentGrown")) {
this.percentGrown = loadMap.h["percentGrown"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"foodLeft")) {
this.foodLeft = loadMap.h["foodLeft"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"percentCleaned")) {
this.percentCleaned = loadMap.h["percentCleaned"];
}
this.postLoad();
}
,__class__: buildings_CacaoFarm
});
var buildings_Factory = function(game,stage,bgStage,city,world,position,worldPosition,id,animation,idleAnimation) {
this.activeWorkersTotalEducation = 0;
this.activeWorkers = 0;
this.buildingEnabled = true;
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.activeBgTextures = Resources.getTexturesByWidth(animation,20);
this.idleBgTextures = Resources.getTexturesByWidth(idleAnimation,20);
this.bgTexture = 0;
this.backSprite = new PIXI.Sprite(this.idleBgTextures[0]);
this.backSprite.position.set(position.x,position.y);
bgStage.addChild(this.backSprite);
};
$hxClasses["buildings.Factory"] = buildings_Factory;
buildings_Factory.__name__ = "buildings.Factory";
buildings_Factory.__super__ = buildings_Work;
buildings_Factory.prototype = $extend(buildings_Work.prototype,{
work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking) {
citizen.currentAction = LifeAction.Nothing;
} else {
this.workAnimation(citizen,timeMod);
this.activeWorkers += 1;
this.activeWorkersTotalEducation += citizen.get_educationSpeedModifier();
}
}
,workAnimation: function(citizen,timeMod) {
}
,update: function(timeMod) {
var active = false;
if(this.activeWorkers > 0 && this.buildingEnabled) {
active = this.possiblyBeActive(timeMod);
}
var bgTextures = active && this.canShowActiveTextures() ? this.activeBgTextures : this.idleBgTextures;
this.bgTexture += timeMod / 4;
if(this.bgTexture >= bgTextures.length) {
this.bgTexture = 0;
}
this.backSprite.texture = bgTextures[this.bgTexture | 0];
this.activeWorkers = 0;
this.activeWorkersTotalEducation = 0;
}
,positionSprites: function() {
buildings_Work.prototype.positionSprites.call(this);
if(this.backSprite != null) {
this.backSprite.position.set(this.position.x,this.position.y);
}
}
,destroy: function() {
buildings_Work.prototype.destroy.call(this);
if(this.backSprite != null) {
this.bgStage.removeChild(this.backSprite);
}
}
,possiblyBeActive: function(timeMod) {
return false;
}
,canShowActiveTextures: function() {
return false;
}
,__class__: buildings_Factory
});
var buildings_MaterialConvertingFactory = function(game,stage,bgStage,city,world,position,worldPosition,id,animation,idleAnimation) {
this.materialMade = 0;
this.totalMaterialUsed = 0;
this.efficiency = this.get_normalEfficiency();
buildings_Factory.call(this,game,stage,bgStage,city,world,position,worldPosition,id,animation,idleAnimation);
};
$hxClasses["buildings.MaterialConvertingFactory"] = buildings_MaterialConvertingFactory;
buildings_MaterialConvertingFactory.__name__ = "buildings.MaterialConvertingFactory";
buildings_MaterialConvertingFactory.__super__ = buildings_Factory;
buildings_MaterialConvertingFactory.prototype = $extend(buildings_Factory.prototype,{
get_normalEfficiency: function() {
return 3;
}
,get_materialFrom: function() {
return 0.0;
}
,set_materialFrom: function(value) {
return value;
}
,get_materialTo: function() {
return 0.0;
}
,set_materialTo: function(value) {
return value;
}
,get_bonusSpeed: function() {
return 1.0;
}
,get_walkThroughCanViewSelfInThisBuilding: function() {
return false;
}
,possiblyBeActive: function(timeMod) {
if(this.get_materialFrom() >= 1) {
var convertedInto = timeMod * this.materialsMadePerStepPerWorker * this.activeWorkers * this.city.simulation.happiness.actionSpeedModifier * this.get_bonusSpeed() * this.city.simulation.boostManager.currentGlobalBoostAmount;
var _g = this;
_g.set_materialTo(_g.get_materialTo() + convertedInto);
this.materialMade += convertedInto;
var materialsUsed = convertedInto * this.efficiency;
var _g = this;
_g.set_materialFrom(_g.get_materialFrom() - materialsUsed);
this.totalMaterialUsed += materialsUsed;
return true;
}
return false;
}
,canShowActiveTextures: function() {
return this.get_materialFrom() >= 3;
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Factory.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_MaterialConvertingFactory.saveDefinition);
}
var value = this.totalMaterialUsed;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.materialMade;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
}
,load: function(queue,definition) {
buildings_Factory.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"totalMaterialUsed")) {
this.totalMaterialUsed = loadMap.h["totalMaterialUsed"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"materialMade")) {
this.materialMade = loadMap.h["materialMade"];
}
}
,__class__: buildings_MaterialConvertingFactory
});
var buildings_ChocolateFactory = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.materialsMadePerStepPerWorker = 0.0008;
buildings_MaterialConvertingFactory.call(this,game,stage,bgStage,city,world,position,worldPosition,id,"spr_chocolatefactory_frames","spr_chocolatefactory_idle");
};
$hxClasses["buildings.ChocolateFactory"] = buildings_ChocolateFactory;
buildings_ChocolateFactory.__name__ = "buildings.ChocolateFactory";
buildings_ChocolateFactory.__super__ = buildings_MaterialConvertingFactory;
buildings_ChocolateFactory.prototype = $extend(buildings_MaterialConvertingFactory.prototype,{
get_normalEfficiency: function() {
return 1;
}
,get_walkThroughCanViewSelfInThisBuilding: function() {
return false;
}
,get_possibleUpgrades: function() {
return [];
}
,get_possibleBuildingModes: function() {
return [buildingUpgrades_FactoryWorking,buildingUpgrades_FactoryDisabled];
}
,get_materialFrom: function() {
return this.city.materials.cacao;
}
,set_materialFrom: function(value) {
return this.city.materials.cacao = value;
}
,get_materialTo: function() {
return this.city.materials.chocolate;
}
,set_materialTo: function(value) {
var productionAmount = value - this.city.materials.chocolate;
this.city.materials.chocolate += productionAmount;
this.city.simulation.stats.materialProduction[7][0] += productionAmount;
return this.city.materials.chocolate;
}
,workAnimation: function(citizen,timeMod) {
if(this.workers.indexOf(citizen) == 1) {
var spd = citizen.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
if(Math.abs(3 - citizen.relativeX) < spd) {
citizen.relativeX = 3;
} else {
var num = 3 - citizen.relativeX;
citizen.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
}
} else {
var spd = citizen.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
if(Math.abs(7 - citizen.relativeX) < spd) {
citizen.relativeX = 7;
} else {
var num = 7 - citizen.relativeX;
citizen.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
}
}
}
,addWindowInfoLines: function() {
var _gthis = this;
buildings_MaterialConvertingFactory.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
return "" + (_gthis.totalMaterialUsed | 0) + " cacao beans used to make " + (_gthis.materialMade | 0) + " chocolate bars.";
});
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_MaterialConvertingFactory.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_ChocolateFactory.saveDefinition);
}
}
,load: function(queue,definition) {
buildings_MaterialConvertingFactory.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
}
,__class__: buildings_ChocolateFactory
});
var buildings_CityHall = function(game,stage,bgStage,city,world,position,worldPosition,id) {
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
};
$hxClasses["buildings.CityHall"] = buildings_CityHall;
buildings_CityHall.__name__ = "buildings.CityHall";
buildings_CityHall.sanitizeCityName = function(origName) {
return HxOverrides.substr(origName,0,1000);
};
buildings_CityHall.__super__ = buildings_Work;
buildings_CityHall.prototype = $extend(buildings_Work.prototype,{
get_possiblePolicies: function() {
return [policies_FoodRationing,policies_SmallerClasses,policies_MandatoryOvertime];
}
,update: function(timeMod) {
}
,work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking) {
citizen.currentAction = LifeAction.Nothing;
}
var rnd = random_Random.getInt(7);
if(citizen.relativeY < 5) {
if(rnd < 3) {
citizen.changeFloorAndWaitRandom(20,30);
} else if(rnd < 5) {
citizen.moveAndWait(random_Random.getInt(3,7),random_Random.getInt(90,180),null,false,false);
} else {
citizen.moveAndWait(random_Random.getInt(12,15),random_Random.getInt(90,180),null,false,false);
}
} else if(rnd < 1) {
citizen.changeFloorAndWaitRandom(20,30);
} else if(rnd < 3) {
citizen.moveAndWait(random_Random.getInt(3,4),random_Random.getInt(90,180),null,false,false);
} else if(rnd < 5) {
citizen.moveAndWait(random_Random.getInt(9,10),random_Random.getInt(90,180),null,false,false);
} else {
citizen.moveAndWait(random_Random.getInt(15,16),random_Random.getInt(90,180),null,false,false);
}
}
,createWindowAddBottomButtons: function() {
var _gthis = this;
gui_UpgradeWindowParts.createHeader(this.city.gui,"City Name:");
this.city.gui.windowInner.addChild(new gui_TextElementAlt(this.city.gui.windowInner,this.city.gui.innerWindowStage,null,function() {
if(_gthis.city.cityName == "") {
return "Unnamed City";
}
return _gthis.city.cityName;
},"Arial, sans-serif",null,300,null,15));
var button = gui_windowParts_FullSizeTextButton.create(this.city.gui,function() {
if(2 == 8 || _gthis.game.isMobile) {
var inp = window.prompt("Give your city a name!",_gthis.city.cityName);
if(inp != null) {
_gthis.city.cityName = buildings_CityHall.sanitizeCityName(inp);
}
} else {
gui_ChangeCityNameWindow.createWindow(_gthis.city);
}
},this.city.gui.windowInner,function() {
return "Change City Name";
},this.city.gui.innerWindowStage);
this.city.gui.windowInner.addChild(new gui_GUISpacing(this.city.gui.windowInner,new common_Point(2,4)));
buildings_Work.prototype.createWindowAddBottomButtons.call(this);
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Work.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_CityHall.saveDefinition);
}
}
,load: function(queue,definition) {
buildings_Work.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
}
,__class__: buildings_CityHall
});
var buildings_ComputerChipFactory = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.materialsMadePerStepPerWorker = 0.0001;
buildings_MaterialConvertingFactory.call(this,game,stage,bgStage,city,world,position,worldPosition,id,"spr_computerchipfactory_frames","spr_computerchipfactory_idle");
};
$hxClasses["buildings.ComputerChipFactory"] = buildings_ComputerChipFactory;
buildings_ComputerChipFactory.__name__ = "buildings.ComputerChipFactory";
buildings_ComputerChipFactory.__super__ = buildings_MaterialConvertingFactory;
buildings_ComputerChipFactory.prototype = $extend(buildings_MaterialConvertingFactory.prototype,{
get_normalEfficiency: function() {
return 7;
}
,get_walkThroughCanViewSelfInThisBuilding: function() {
return false;
}
,get_possibleUpgrades: function() {
return [buildingUpgrades_DieShrink];
}
,get_possibleBuildingModes: function() {
return [buildingUpgrades_FactoryWorking,buildingUpgrades_RefinedStoneUsingFactoryDisabled];
}
,get_materialFrom: function() {
return this.city.materials.refinedMetal;
}
,set_materialFrom: function(value) {
var productionAmount = this.city.materials.refinedMetal - value;
this.city.materials.refinedMetal -= productionAmount;
this.city.simulation.stats.materialUsed[4][0] += productionAmount;
return this.city.materials.refinedMetal;
}
,get_materialTo: function() {
return this.city.materials.computerChips;
}
,set_materialTo: function(value) {
var productionAmount = value - this.city.materials.computerChips;
this.city.materials.computerChips += productionAmount;
this.city.simulation.stats.materialProduction[5][0] += productionAmount;
return this.city.materials.computerChips;
}
,get_bonusSpeed: function() {
return (this.workers.length == 0 ? 1 : this.activeWorkersTotalEducation / this.activeWorkers) * this.city.upgrades.vars.computerChipFactorySpeed;
}
,onBuild: function() {
this.city.progress.unlocks.unlock(buildingUpgrades_AIMining);
this.city.progress.unlocks.unlock(buildingUpgrades_HeatedBed);
this.city.progress.unlocks.unlock(buildings_Supercomputer);
this.city.progress.unlocks.unlock(buildings_LivingResearchCenter);
this.city.progress.unlocks.unlock(buildings_Teleporter);
this.city.progress.unlocks.unlock(buildings_CuttingEdgeHome);
this.city.progress.unlocks.fullyUnlock(buildings_Arcade);
this.city.progress.unlocks.unlock(cityUpgrades_ChipBinning);
this.city.progress.unlocks.unlock(buildingUpgrades_PickaxeTech);
this.city.progress.unlocks.unlock(buildingUpgrades_FossilScanner);
}
,workAnimation: function(citizen,timeMod) {
if(citizen.relativeY != 10) {
if(this.workers.indexOf(citizen) == 1) {
citizen.setRelativePos(3,10);
} else if(this.workers.indexOf(citizen) == 0) {
var spd = citizen.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
if(Math.abs(3 - citizen.relativeX) < spd) {
citizen.relativeX = 3;
} else {
var num = 3 - citizen.relativeX;
citizen.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
}
citizen.setRelativeY(0);
} else {
var spd = citizen.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
if(Math.abs(13 - citizen.relativeX) < spd) {
citizen.relativeX = 13;
} else {
var num = 13 - citizen.relativeX;
citizen.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
}
citizen.setRelativeY(0);
}
}
}
,addWindowInfoLines: function() {
var _gthis = this;
buildings_MaterialConvertingFactory.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
return "" + (_gthis.totalMaterialUsed | 0) + " units of refined metals used to make " + (_gthis.materialMade | 0) + " computer chips.";
});
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_MaterialConvertingFactory.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_ComputerChipFactory.saveDefinition);
}
}
,load: function(queue,definition) {
buildings_MaterialConvertingFactory.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
}
,__class__: buildings_ComputerChipFactory
});
var buildings_ComputerResearchCenter = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.totalKnowledgeGenerated = 0;
buildings_Factory.call(this,game,stage,bgStage,city,world,position,worldPosition,id,"spr_computerresearchcenter_frames","spr_computerresearchcenter_idle");
};
$hxClasses["buildings.ComputerResearchCenter"] = buildings_ComputerResearchCenter;
buildings_ComputerResearchCenter.__name__ = "buildings.ComputerResearchCenter";
buildings_ComputerResearchCenter.__super__ = buildings_Factory;
buildings_ComputerResearchCenter.prototype = $extend(buildings_Factory.prototype,{
get_possibleCityUpgrades: function() {
return [cityUpgrades_ChipBinning];
}
,get_walkThroughCanViewSelfInThisBuilding: function() {
return false;
}
,workAnimation: function(citizen,timeMod) {
switch(this.workers.indexOf(citizen)) {
case 0:
citizen.setRelativePos(13,10);
break;
case 1:
citizen.setRelativePos(6,0);
break;
case 2:
citizen.setRelativePos(6,10);
break;
case 3:
citizen.setRelativePos(15,0);
break;
case 4:
citizen.setRelativePos(8,0);
break;
}
}
,possiblyBeActive: function(timeMod) {
var newKnowledge = 0.0014 * timeMod * this.city.simulation.happiness.actionSpeedModifier * this.activeWorkersTotalEducation * this.city.simulation.boostManager.currentGlobalBoostAmount;
this.city.materials.knowledge += newKnowledge;
this.city.simulation.stats.materialProduction[8][0] += newKnowledge;
this.totalKnowledgeGenerated += newKnowledge;
return true;
}
,canShowActiveTextures: function() {
return true;
}
,addWindowInfoLines: function() {
var _gthis = this;
buildings_Factory.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
return "" + (_gthis.totalKnowledgeGenerated | 0) + " knowledge gathered.";
});
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Factory.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_ComputerResearchCenter.saveDefinition);
}
var value = this.totalKnowledgeGenerated;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
}
,load: function(queue,definition) {
buildings_Factory.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"totalKnowledgeGenerated")) {
this.totalKnowledgeGenerated = loadMap.h["totalKnowledgeGenerated"];
}
}
,__class__: buildings_ComputerResearchCenter
});
var buildings_CuttingEdgeHome = function(game,stage,bgStage,city,world,position,worldPosition,id) {
buildings_House.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
};
$hxClasses["buildings.CuttingEdgeHome"] = buildings_CuttingEdgeHome;
buildings_CuttingEdgeHome.__name__ = "buildings.CuttingEdgeHome";
buildings_CuttingEdgeHome.__super__ = buildings_House;
buildings_CuttingEdgeHome.prototype = $extend(buildings_House.prototype,{
get_possibleUpgrades: function() {
return [buildingUpgrades_BiggerTV,buildingUpgrades_ModernHomePlant,buildingUpgrades_SmartChairs];
}
,walkAround: function(citizen,stepsInBuilding) {
var r = random_Random.getInt(3);
if(r == 0 && stepsInBuilding > 120) {
citizen.changeFloorAndWaitRandom(30,60);
} else if(r == 1) {
if(citizen.relativeY < 5) {
citizen.moveAndWait(random_Random.getInt(3,15),random_Random.getInt(30,60),null,false,false);
} else {
citizen.moveAndWait(random_Random.getInt(5,15),random_Random.getInt(30,60),null,false,false);
}
} else {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = random_Random.getInt(90,120);
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
}
,__class__: buildings_CuttingEdgeHome
});
var buildings_EcoFarm = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.crop3Sprite = 0;
this.crop2Sprite = 0;
this.openDay = 0;
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.crop2Sprite = random_Random.getInt(buildings_EcoFarm.crop2Sprites.length);
this.crop3Sprite = random_Random.getInt(buildings_EcoFarm.crop3Sprites.length);
this.growthAreas = [new buildings_FarmGrowArea(bgStage,this,new common_Point(3,3),city,"spr_ecofarm_crop1",6,15,0.7,0,6),new buildings_FarmGrowArea(bgStage,this,new common_Point(9,3),city,buildings_EcoFarm.crop2Sprites[this.crop2Sprite],8,7,1.4,10),new buildings_FarmGrowArea(bgStage,this,new common_Point(9,12),city,buildings_EcoFarm.crop3Sprites[this.crop3Sprite],8,8,0.6,7)];
this.isEntertainment = true;
this.openDay = random_Random.getInt(7);
this.positionSprites();
this.adjecentBuildingEffects.push({ name : "farm", intensity : 1});
};
$hxClasses["buildings.EcoFarm"] = buildings_EcoFarm;
buildings_EcoFarm.__name__ = "buildings.EcoFarm";
buildings_EcoFarm.__interfaces__ = [buildings_IEntertainmentBuilding];
buildings_EcoFarm.__super__ = buildings_Work;
buildings_EcoFarm.prototype = $extend(buildings_Work.prototype,{
get_baseEntertainmentCapacity: function() {
return this.workers.length * 5;
}
,get_isOpen: function() {
if(this.workers.length > 0 && this.workers[0].currentAction == LifeAction.Work && (1 + ((this.city.simulation.time.timeSinceStart | 0) / 1440 | 0)) % 7 == this.openDay && this.city.simulation.time.timeSinceStart / 60 % 24 < 20.5) {
return this.city.simulation.time.timeSinceStart / 60 % 24 > 12.0;
} else {
return false;
}
}
,get_entertainmentType: function() {
return 3;
}
,get_minimumNormalTimeToSpend: function() {
return 2;
}
,get_maximumNormalTimeToSpend: function() {
return 3;
}
,get_minimumEntertainmentGroupSatisfy: function() {
return 1;
}
,get_maximumEntertainmentGroupSatisfy: function() {
return 1.5;
}
,get_entertainmentQuality: function() {
return 100;
}
,get_isOpenForExistingVisitors: function() {
return this.get_isOpen();
}
,finishEntertainment: function(citizen,timeMod) {
return true;
}
,beEntertained: function(citizen,timeMod) {
var modifyWithHappiness = false;
var slowMove = true;
if(slowMove == null) {
slowMove = false;
}
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
citizen.moveAndWait(random_Random.getInt(3,16),random_Random.getInt(50,100),null,modifyWithHappiness,slowMove);
}
,postLoad: function() {
this.growthAreas[1].setTexture(buildings_EcoFarm.crop2Sprites[this.crop2Sprite],8);
this.growthAreas[2].setTexture(buildings_EcoFarm.crop3Sprites[this.crop3Sprite],8);
var _g = 0;
var _g1 = this.growthAreas;
while(_g < _g1.length) {
var growthArea = _g1[_g];
++_g;
growthArea.updateTexture();
}
}
,update: function(timeMod) {
if((1 + ((this.city.simulation.time.timeSinceStart | 0) / 1440 | 0)) % 7 == this.openDay) {
this.endTime = 21.0;
} else {
this.endTime = 19.0;
}
buildings_Work.prototype.update.call(this,timeMod);
var _g = 0;
var _g1 = this.growthAreas;
while(_g < _g1.length) {
var growthArea = _g1[_g];
++_g;
growthArea.update(timeMod);
}
}
,work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking) {
citizen.currentAction = LifeAction.Nothing;
} else {
var citizenIndex = this.workers.indexOf(citizen);
if(citizenIndex == 1) {
if(citizen.relativeY < 5) {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = 18;
citizen1.setPath(arr,0,2,true);
citizen.pathEndFunction = function() {
citizen.changeFloor();
};
citizen.pathOnlyRelatedTo = citizen.inPermanent;
} else {
this.growthAreas[citizenIndex].doCitizenWork(citizen);
}
} else if(citizenIndex == 0 && this.growthAreas[0].farmStage == buildings_FarmStage.Harvesting) {
if(citizen.relativeY <= 1 || (citizen.relativeX < 4 || citizen.relativeX > 6)) {
citizen.setPath(new Int32Array([4,5,9,8]),0,4,true);
} else {
this.growthAreas[citizenIndex].doCitizenWorkNoMove(citizen);
}
} else if(citizen.relativeY > 5) {
citizen.changeFloor();
} else {
this.growthAreas[citizenIndex].doCitizenWork(citizen);
}
}
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Work.prototype.save.call(this,queue,shouldSaveDefinition);
this.saveBasics(queue);
var _g = 0;
var _g1 = this.growthAreas;
while(_g < _g1.length) {
var growthArea = _g1[_g];
++_g;
growthArea.save(queue);
}
}
,load: function(queue,definition) {
buildings_Work.prototype.load.call(this,queue,definition);
this.loadBasics(queue,definition);
var _g = 0;
var _g1 = this.growthAreas;
while(_g < _g1.length) {
var growthArea = _g1[_g];
++_g;
growthArea.load(queue);
}
this.postLoad();
}
,destroy: function() {
buildings_Work.prototype.destroy.call(this);
var _g = 0;
var _g1 = this.growthAreas;
while(_g < _g1.length) {
var growthArea = _g1[_g];
++_g;
growthArea.destroy();
}
}
,positionSprites: function() {
buildings_Work.prototype.positionSprites.call(this);
var _g = 0;
var _g1 = this.growthAreas;
while(_g < _g1.length) {
var growthArea = _g1[_g];
++_g;
growthArea.positionSprites();
}
}
,addWindowInfoLines: function() {
buildings_Work.prototype.addWindowInfoLines.call(this);
this.growthAreas[0].showInfoText("Left plot: ");
this.growthAreas[1].showInfoText("Top right plot: ");
this.growthAreas[2].showInfoText("Bottom right plot: ");
}
,saveBasics: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
if(shouldSaveDefinition) {
queue.addString(buildings_EcoFarm.saveDefinition);
}
var value = this.openDay;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.crop2Sprite;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.crop3Sprite;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
,loadBasics: function(queue,definition) {
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"openDay")) {
this.openDay = loadMap.h["openDay"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"crop2Sprite")) {
this.crop2Sprite = loadMap.h["crop2Sprite"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"crop3Sprite")) {
this.crop3Sprite = loadMap.h["crop3Sprite"];
}
this.postLoad();
}
,__class__: buildings_EcoFarm
});
var buildings_EscapeRoomPhase = $hxEnums["buildings.EscapeRoomPhase"] = { __ename__ : "buildings.EscapeRoomPhase", __constructs__ : ["Start","First","Second","Third","Lasers","Last","Done"]
,Start: {_hx_index:0,__enum__:"buildings.EscapeRoomPhase",toString:$estr}
,First: {_hx_index:1,__enum__:"buildings.EscapeRoomPhase",toString:$estr}
,Second: {_hx_index:2,__enum__:"buildings.EscapeRoomPhase",toString:$estr}
,Third: {_hx_index:3,__enum__:"buildings.EscapeRoomPhase",toString:$estr}
,Lasers: {_hx_index:4,__enum__:"buildings.EscapeRoomPhase",toString:$estr}
,Last: {_hx_index:5,__enum__:"buildings.EscapeRoomPhase",toString:$estr}
,Done: {_hx_index:6,__enum__:"buildings.EscapeRoomPhase",toString:$estr}
};
var buildings_EscapeRoom = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.graphicsDrawn = false;
this.escapeRoomPhaseProgress = 0;
this.escapeRoomPhase = buildings_EscapeRoomPhase.Start;
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.startTime = 13;
this.endTime = 3;
this.workTimePreferenceMod = 0.1;
this.isEntertainment = true;
this.registeredCitizens = [];
this.graphics = new PIXI.Graphics();
bgStage.addChild(this.graphics);
this.graphics.position.set(position.x,position.y);
};
$hxClasses["buildings.EscapeRoom"] = buildings_EscapeRoom;
buildings_EscapeRoom.__name__ = "buildings.EscapeRoom";
buildings_EscapeRoom.__interfaces__ = [buildings_IEntertainmentBuilding];
buildings_EscapeRoom.__super__ = buildings_Work;
buildings_EscapeRoom.prototype = $extend(buildings_Work.prototype,{
get_baseEntertainmentCapacity: function() {
return this.workers.length * 120;
}
,get_isOpen: function() {
if(this.workers.length == 1 && this.workers[0].currentAction == LifeAction.Work && this.city.simulation.time.timeSinceStart / 60 % 24 < 23.99) {
return this.registeredCitizens.length < 10;
} else {
return false;
}
}
,get_entertainmentType: function() {
return 4;
}
,get_minimumNormalTimeToSpend: function() {
return 2.5;
}
,get_maximumNormalTimeToSpend: function() {
return 3.5;
}
,get_minimumEntertainmentGroupSatisfy: function() {
return 4;
}
,get_maximumEntertainmentGroupSatisfy: function() {
return 7;
}
,get_entertainmentQuality: function() {
return 100;
}
,get_isOpenForExistingVisitors: function() {
if(this.workers.length == 1) {
return this.workers[0].currentAction == LifeAction.Work;
} else {
return false;
}
}
,finishEntertainment: function(citizen,timeMod) {
if(!(this.registeredCitizens.length < 5 || this.registeredCitizens.indexOf(citizen) == -1 || this.escapeRoomPhase == buildings_EscapeRoomPhase.Done)) {
return !this.get_isOpenForExistingVisitors();
} else {
return true;
}
}
,beEntertained: function(citizen,timeMod) {
if(!citizen.hasBuildingInited || citizen.dynamicUnsavedVars.buildingInited == null) {
if(this.registeredCitizens.indexOf(citizen) == -1) {
if(this.registeredCitizens.length > 10) {
citizen.entertainment.stop();
return;
}
this.registeredCitizens.push(citizen);
}
citizen.hasBuildingInited = true;
citizen.dynamicUnsavedVars.buildingInited = true;
}
if(this.escapeRoomPhase == buildings_EscapeRoomPhase.Done) {
citizen.entertainment.stop();
return;
}
if(this.registeredCitizens.length < 5) {
if(citizen.relativeY > 5) {
citizen.changeFloor();
} else {
citizen.moveAndWait(random_Random.getInt(7,16),random_Random.getInt(50,70),null,false,false);
}
} else if(this.escapeRoomPhase == buildings_EscapeRoomPhase.Start) {
if(citizen.relativeY > 5) {
citizen.changeFloor();
} else {
citizen.moveAndWait(random_Random.getInt(7,16),random_Random.getInt(50,70),null,false,false);
}
if(this.registeredCitizens.length < 8 && this.escapeRoomPhaseProgress < 1) {
this.escapeRoomPhaseProgress += 0.02 * timeMod;
} else {
this.escapeRoomPhase = buildings_EscapeRoomPhase.First;
this.escapeRoomPhaseProgress = 0;
}
return;
} else if(this.escapeRoomPhase == buildings_EscapeRoomPhase.First) {
if(citizen.relativeY < 5 && citizen.relativeX > 2 && citizen.relativeX < 7) {
citizen.changeFloor();
} else {
citizen.moveAndWait(random_Random.getInt(3,6),random_Random.getInt(30,60),null,false,false);
if(random_Random.getFloat(1) < 0.2) {
this.escapeRoomPhaseProgress += 0.2;
if(this.escapeRoomPhaseProgress > 1) {
this.escapeRoomPhase = buildings_EscapeRoomPhase.Second;
this.escapeRoomPhaseProgress = 0;
}
}
}
} else if(this.escapeRoomPhase == buildings_EscapeRoomPhase.Second) {
var ind = this.registeredCitizens.indexOf(citizen);
if(ind % 2 == 0) {
if(citizen.relativeY > 5) {
citizen.changeFloor();
} else {
citizen.moveAndWait(random_Random.getInt(3,16),random_Random.getInt(50,120),null,false,false);
if(random_Random.getFloat(1) < 0.3) {
this.escapeRoomPhaseProgress += 0.34;
if(this.escapeRoomPhaseProgress > 1) {
this.escapeRoomPhase = buildings_EscapeRoomPhase.Third;
this.escapeRoomPhaseProgress = 0;
}
}
}
} else if(citizen.relativeY < 5 && citizen.relativeX > 2 && citizen.relativeX < 7) {
citizen.changeFloor();
} else {
citizen.moveAndWait(random_Random.getInt(3,6),random_Random.getInt(30,60),null,false,false);
}
} else if(this.escapeRoomPhase == buildings_EscapeRoomPhase.Third) {
if(citizen.relativeY > 5) {
citizen.changeFloor();
} else if(citizen.relativeX > 4) {
var moveToX = random_Random.getInt(3,5);
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = moveToX;
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
} else if(this.escapeRoomPhase == buildings_EscapeRoomPhase.Last) {
if(citizen.relativeY < 5 && citizen.relativeX > 11 && citizen.relativeX < 16) {
citizen.changeFloor();
} else {
citizen.moveAndWait(random_Random.getInt(11,16),random_Random.getInt(20,60),null,false,false);
}
}
}
,update: function(timeMod) {
var i = this.registeredCitizens.length;
while(--i > 0) {
var thisCitizen = this.registeredCitizens[i];
if(thisCitizen.hasDied || (thisCitizen.inPermanent != null && thisCitizen.inPermanent.isBuilding ? thisCitizen.inPermanent : null) != this) {
this.registeredCitizens.splice(i,1);
}
}
if(this.escapeRoomPhase == buildings_EscapeRoomPhase.Done) {
this.escapeRoomPhaseProgress += 0.02 * timeMod;
if(this.escapeRoomPhaseProgress >= 1) {
this.resetEscapeRoom();
}
} else if(this.escapeRoomPhase == buildings_EscapeRoomPhase.Third) {
if(common_ArrayExtensions.all(this.registeredCitizens,function(c) {
if(c.relativeY < 5) {
return c.relativeX < 5;
} else {
return false;
}
})) {
this.escapeRoomPhase = buildings_EscapeRoomPhase.Lasers;
this.escapeRoomPhaseProgress = 0;
}
} else if(this.escapeRoomPhase == buildings_EscapeRoomPhase.Last) {
if(common_ArrayExtensions.all(this.registeredCitizens,function(c) {
if(c.relativeY > 5) {
return c.relativeX > 11;
} else {
return false;
}
})) {
this.escapeRoomPhase = buildings_EscapeRoomPhase.Done;
this.escapeRoomPhaseProgress = 0;
}
}
if(this.escapeRoomPhase == buildings_EscapeRoomPhase.Lasers) {
this.graphics.clear();
this.graphics.beginFill(16711680,0.7);
var y = 13;
this.graphics.drawRect(7,y,1,1);
var y = 13;
this.graphics.drawRect(8,y,1,1);
var y = 13;
this.graphics.drawRect(9,y,1,1);
var y = 13;
this.graphics.drawRect(10,y,1,1);
var y = 13;
this.graphics.drawRect(11,y,1,1);
var y = 13;
this.graphics.drawRect(12,y,1,1);
var y = 13;
this.graphics.drawRect(13,y,1,1);
var y = 13;
this.graphics.drawRect(14,y,1,1);
var y = 13;
this.graphics.drawRect(15,y,1,1);
var y = 13;
this.graphics.drawRect(16,y,1,1);
this.graphics.endFill();
this.graphicsDrawn = true;
this.escapeRoomPhaseProgress += 0.01 * timeMod;
if(this.escapeRoomPhaseProgress >= 1) {
this.escapeRoomPhaseProgress = 0;
this.escapeRoomPhase = buildings_EscapeRoomPhase.Last;
}
} else if(this.graphicsDrawn) {
this.graphics.clear();
this.graphicsDrawn = false;
}
}
,postLoad: function() {
this.graphics.position.set(this.position.x,this.position.y);
}
,positionSprites: function() {
buildings_Work.prototype.positionSprites.call(this);
this.graphics.position.set(this.position.x,this.position.y);
}
,onCitizenLeave: function(citizen,newPermanent) {
HxOverrides.remove(this.registeredCitizens,citizen);
}
,work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking) {
citizen.currentAction = LifeAction.Nothing;
this.resetEscapeRoom();
} else {
var spd = citizen.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
if(Math.abs(3 - citizen.relativeX) < spd) {
citizen.relativeX = 3;
} else {
var num = 3 - citizen.relativeX;
citizen.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
}
}
}
,resetEscapeRoom: function() {
this.escapeRoomPhase = buildings_EscapeRoomPhase.Start;
this.escapeRoomPhaseProgress = 0;
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Work.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_EscapeRoom.saveDefinition);
}
}
,load: function(queue,definition) {
buildings_Work.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
this.postLoad();
}
,__class__: buildings_EscapeRoom
});
var buildings_ExperimentalFarm = function(game,stage,bgStage,city,world,position,worldPosition,id) {
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.growthAreas = [new buildings_FarmGrowArea(bgStage,this,new common_Point(3,3),city,"spr_experimentalfarm_crop1",5,12,1,5),new buildings_FarmGrowArea(bgStage,this,new common_Point(12,3),city,"spr_experimentalfarm_crop2",5,10,1.2,10),new buildings_FarmGrowArea(bgStage,this,new common_Point(12,12),city,"spr_experimentalfarm_crop3",5,6,1.5,10)];
this.positionSprites();
this.adjecentBuildingEffects.push({ name : "farm", intensity : 1});
};
$hxClasses["buildings.ExperimentalFarm"] = buildings_ExperimentalFarm;
buildings_ExperimentalFarm.__name__ = "buildings.ExperimentalFarm";
buildings_ExperimentalFarm.__super__ = buildings_Work;
buildings_ExperimentalFarm.prototype = $extend(buildings_Work.prototype,{
onBuild: function() {
this.city.simulation.bonuses.indoorFarmSpeed += 0.1;
}
,postLoad: function() {
var _g = 0;
var _g1 = this.growthAreas;
while(_g < _g1.length) {
var growthArea = _g1[_g];
++_g;
growthArea.updateTexture();
}
}
,update: function(timeMod) {
buildings_Work.prototype.update.call(this,timeMod);
var _g = 0;
var _g1 = this.growthAreas;
while(_g < _g1.length) {
var growthArea = _g1[_g];
++_g;
growthArea.update(timeMod);
}
}
,work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking) {
citizen.currentAction = LifeAction.Nothing;
} else {
var citizenIndex = this.workers.indexOf(citizen);
if(citizenIndex == 1) {
if(citizen.relativeY < 5) {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = 18;
citizen1.setPath(arr,0,2,true);
citizen.pathEndFunction = function() {
citizen.changeFloor();
};
citizen.pathOnlyRelatedTo = citizen.inPermanent;
} else {
this.growthAreas[citizenIndex].doCitizenWork(citizen);
}
} else if(citizen.relativeY > 5) {
citizen.changeFloor();
} else {
this.growthAreas[citizenIndex].doCitizenWork(citizen);
}
}
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Work.prototype.save.call(this,queue,shouldSaveDefinition);
this.saveBasics(queue);
var _g = 0;
var _g1 = this.growthAreas;
while(_g < _g1.length) {
var growthArea = _g1[_g];
++_g;
growthArea.save(queue);
}
}
,load: function(queue,definition) {
buildings_Work.prototype.load.call(this,queue,definition);
this.loadBasics(queue,definition);
var _g = 0;
var _g1 = this.growthAreas;
while(_g < _g1.length) {
var growthArea = _g1[_g];
++_g;
growthArea.load(queue);
}
this.postLoad();
}
,destroy: function() {
buildings_Work.prototype.destroy.call(this);
var _g = 0;
var _g1 = this.growthAreas;
while(_g < _g1.length) {
var growthArea = _g1[_g];
++_g;
growthArea.destroy();
}
this.city.simulation.bonuses.indoorFarmSpeed -= 0.1;
}
,positionSprites: function() {
buildings_Work.prototype.positionSprites.call(this);
var _g = 0;
var _g1 = this.growthAreas;
while(_g < _g1.length) {
var growthArea = _g1[_g];
++_g;
growthArea.positionSprites();
}
}
,addWindowInfoLines: function() {
buildings_Work.prototype.addWindowInfoLines.call(this);
this.growthAreas[0].showInfoText("Left plot: ");
this.growthAreas[1].showInfoText("Top right plot: ");
this.growthAreas[2].showInfoText("Bottom right plot: ");
}
,saveBasics: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
if(shouldSaveDefinition) {
queue.addString(buildings_ExperimentalFarm.saveDefinition);
}
}
,loadBasics: function(queue,definition) {
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
this.postLoad();
}
,__class__: buildings_ExperimentalFarm
});
var buildings_ExperimentationLab = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.bottomPipeSprite = null;
this.topPipeSprite = null;
this.materialsMadePerStepPerWorker = 0.0023;
buildings_MaterialConvertingFactory.call(this,game,stage,bgStage,city,world,position,worldPosition,id,this.get_idleFrames(),this.get_idleFrames());
};
$hxClasses["buildings.ExperimentationLab"] = buildings_ExperimentationLab;
buildings_ExperimentationLab.__name__ = "buildings.ExperimentationLab";
buildings_ExperimentationLab.__super__ = buildings_MaterialConvertingFactory;
buildings_ExperimentationLab.prototype = $extend(buildings_MaterialConvertingFactory.prototype,{
get_normalEfficiency: function() {
return 0.2;
}
,get_walkThroughCanViewSelfInThisBuilding: function() {
return false;
}
,get_possibleUpgrades: function() {
return [buildingUpgrades_UltimateScrewdriver];
}
,get_possibleBuildingModes: function() {
return [buildingUpgrades_LabWorking,buildingUpgrades_LabDisabled];
}
,get_materialFrom: function() {
return this.city.materials.machineParts;
}
,set_materialFrom: function(value) {
var productionAmount = this.city.materials.machineParts - value;
this.city.materials.machineParts -= productionAmount;
this.city.simulation.stats.materialUsed[3][0] += productionAmount;
return this.city.materials.machineParts;
}
,get_materialTo: function() {
return this.city.materials.knowledge;
}
,set_materialTo: function(value) {
var productionAmount = value - this.city.materials.knowledge;
this.city.materials.knowledge += productionAmount;
this.city.simulation.stats.materialProduction[8][0] += productionAmount;
return this.city.materials.knowledge;
}
,get_idleFrames: function() {
return "spr_experimentationlab_idle";
}
,get_bonusSpeed: function() {
if(this.workers.length == 0) {
return 1;
} else {
return this.activeWorkersTotalEducation / this.activeWorkers;
}
}
,destroy: function() {
buildings_MaterialConvertingFactory.prototype.destroy.call(this);
if(this.topPipeSprite != null) {
this.topPipeSprite.destroy();
}
if(this.bottomPipeSprite != null) {
this.bottomPipeSprite.destroy();
}
}
,workAnimation: function(citizen,timeMod) {
if(citizen.relativeY != 10) {
if(this.workers.indexOf(citizen) == 0) {
citizen.setRelativePos(4,10);
} else {
citizen.setRelativePos(3,0);
}
}
}
,addWindowInfoLines: function() {
var _gthis = this;
buildings_MaterialConvertingFactory.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
return "" + (_gthis.totalMaterialUsed | 0) + " machine parts used to gain " + (_gthis.materialMade | 0) + " knowledge.";
});
}
,canShowActiveTextures: function() {
return false;
}
,onCityChange: function() {
if(this.bottomBuilding != null && this.bottomBuilding.is(buildings_RefinedMetalFactory) && !this.bottomBuilding.is(buildings_FactoryPub)) {
if(this.bottomPipeSprite == null) {
this.bottomPipeSprite = new PIXI.Sprite(Resources.getTexture("spr_experimentationlab_pipe_bottom"));
this.city.justAboveCityStage.addChild(this.bottomPipeSprite);
}
this.bottomPipeSprite.position.set(this.position.x + 7,this.position.y + 17);
} else if(this.bottomPipeSprite != null) {
this.bottomPipeSprite.destroy();
this.bottomPipeSprite = null;
}
if(this.topBuilding != null && this.topBuilding.is(buildings_RefinedMetalFactory) && !this.topBuilding.is(buildings_FactoryPub)) {
if(this.topPipeSprite == null) {
this.topPipeSprite = new PIXI.Sprite(Resources.getTexture("spr_experimentationlab_pipe_top"));
this.city.justAboveCityStage.addChild(this.topPipeSprite);
}
this.topPipeSprite.position.set(this.position.x + 10,this.position.y - 11);
} else if(this.topPipeSprite != null) {
this.topPipeSprite.destroy();
this.topPipeSprite = null;
}
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_MaterialConvertingFactory.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_ExperimentationLab.saveDefinition);
}
}
,load: function(queue,definition) {
buildings_MaterialConvertingFactory.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
}
,__class__: buildings_ExperimentationLab
});
var buildings_CurrentExplorationCentreAction = $hxEnums["buildings.CurrentExplorationCentreAction"] = { __ename__ : "buildings.CurrentExplorationCentreAction", __constructs__ : ["Unknown","Exploring","Investigating"]
,Unknown: {_hx_index:0,__enum__:"buildings.CurrentExplorationCentreAction",toString:$estr}
,Exploring: {_hx_index:1,__enum__:"buildings.CurrentExplorationCentreAction",toString:$estr}
,Investigating: {_hx_index:2,__enum__:"buildings.CurrentExplorationCentreAction",toString:$estr}
};
var buildings_ExplorationCentre = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.hasSearchedForRuinsThisStep = false;
this.currentAction = buildings_CurrentExplorationCentreAction.Unknown;
this.nearestRuins = null;
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
};
$hxClasses["buildings.ExplorationCentre"] = buildings_ExplorationCentre;
buildings_ExplorationCentre.__name__ = "buildings.ExplorationCentre";
buildings_ExplorationCentre.__super__ = buildings_Work;
buildings_ExplorationCentre.prototype = $extend(buildings_Work.prototype,{
addWindowInfoLines: function() {
var _gthis = this;
buildings_Work.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
switch(_gthis.currentAction._hx_index) {
case 0:
return "Current task: looking for ruins.";
case 1:
return "Current task: exploring ruins.";
case 2:
return "Current task: investigating findings.";
}
});
}
,work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking) {
citizen.currentAction = LifeAction.Nothing;
citizen.hasWorkTools = false;
} else if(citizen.hasWorkTools) {
if(((citizen.inPermanent) instanceof worldResources_AlienRuins)) {
this.exploreTheseRuins(citizen);
} else {
if(this.nearestRuins == null && !this.hasSearchedForRuinsThisStep && !Object.prototype.hasOwnProperty.call(this.world.knownResourceInavailability.h,"AlienRuins")) {
if(!this.city.simulation.permanentFinder.canPerformQuery()) {
return;
}
this.nearestRuins = this.city.simulation.permanentFinder.query(this,function(pm) {
if(pm.is(worldResources_AlienRuins)) {
return pm.explored < 100;
} else {
return false;
}
});
this.hasSearchedForRuinsThisStep = true;
if(this.nearestRuins == null) {
this.world.knownResourceInavailability.h["AlienRuins"] = true;
}
}
this.exploreOrInvestigate(citizen,timeMod);
}
} else if(citizen.inPermanent == this) {
citizen.moveAndWait(4,30,function() {
citizen.hasWorkTools = true;
},true);
} else {
citizen.simulation.pathfinder.findPath(citizen,this);
citizen.pathOnFail = null;
}
}
,exploreTheseRuins: function(citizen) {
var _gthis = this;
var theseRuins = citizen.inPermanent;
var moveX = theseRuins.standingPlaces.length == 0 ? random_Random.getInt(1,17) : random_Random.fromArray(theseRuins.standingPlaces);
citizen.moveAndWait(moveX,random_Random.getInt(90,180),function() {
if(theseRuins.explored < 100) {
theseRuins.explored += 0.25;
var _this = _gthis.city.simulation;
var productionAmount = 0.25 * (Config.earlyGameFix1 && _this.citizens.length < 30 ? 1.3 - 0.3 * (_this.citizens.length / 60) : 1) * _gthis.city.simulation.boostManager.currentGlobalBoostAmount;
_gthis.city.materials.knowledge += productionAmount;
_gthis.city.simulation.stats.materialProduction[8][0] += productionAmount;
theseRuins.awardAnyBonuses();
if(theseRuins.explored >= 100) {
theseRuins.explored = 100;
if(citizen.inPermanent != null && citizen.inPermanent.isBuilding) {
var building = citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null;
citizen.relativeX = building.worldPosition.x * 20 + building.doorX;
} else {
citizen.relativeX += citizen.inPermanent.worldPosition.x * 20;
}
if(citizen.inPermanent != null) {
citizen.inPermanent.onCitizenLeave(citizen,null);
}
citizen.inBuildingSince = citizen.city.simulation.time.timeSinceStart;
citizen.set_drawOnStage(citizen.foregroundStage);
citizen.inPermanent = null;
citizen.relativeY = 0;
Citizen.shouldUpdateDraw = true;
_gthis.nearestRuins = null;
}
} else {
if(citizen.inPermanent != null && citizen.inPermanent.isBuilding) {
var building = citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null;
citizen.relativeX = building.worldPosition.x * 20 + building.doorX;
} else {
citizen.relativeX += citizen.inPermanent.worldPosition.x * 20;
}
if(citizen.inPermanent != null) {
citizen.inPermanent.onCitizenLeave(citizen,null);
}
citizen.inBuildingSince = citizen.city.simulation.time.timeSinceStart;
citizen.set_drawOnStage(citizen.foregroundStage);
citizen.inPermanent = null;
citizen.relativeY = 0;
Citizen.shouldUpdateDraw = true;
_gthis.nearestRuins = null;
}
},true);
}
,exploreOrInvestigate: function(citizen,timeMod) {
if(this.nearestRuins != null) {
citizen.simulation.pathfinder.findPath(citizen,this.nearestRuins);
citizen.pathOnFail = null;
this.currentAction = buildings_CurrentExplorationCentreAction.Exploring;
} else {
this.currentAction = buildings_CurrentExplorationCentreAction.Investigating;
if(citizen.inPermanent == this) {
var positionInArray = this.workers.indexOf(citizen);
if((positionInArray == 1 || positionInArray == 2) && citizen.isAtGroundLevel()) {
citizen.changeFloor();
} else {
var correctXMin = positionInArray == 2 ? 12 : 3;
var correctXMax = positionInArray == 2 ? 16 : 7;
if(citizen.relativeX >= correctXMin && citizen.relativeX < correctXMax) {
var productionAmount = 0.001 * timeMod * this.city.simulation.happiness.actionSpeedModifier * citizen.get_educationSpeedModifier() * this.city.simulation.boostManager.currentGlobalBoostAmount;
this.city.materials.knowledge += productionAmount;
this.city.simulation.stats.materialProduction[8][0] += productionAmount;
} else {
var moveToX = random_Random.getInt(correctXMin,correctXMax);
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = moveToX;
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
}
} else {
citizen.simulation.pathfinder.findPath(citizen,this);
citizen.pathOnFail = null;
}
}
}
,update: function(timeMod) {
buildings_Work.prototype.update.call(this,timeMod);
this.hasSearchedForRuinsThisStep = false;
}
,invalidatePathfindingRelatedInfo: function() {
buildings_Work.prototype.invalidatePathfindingRelatedInfo.call(this);
this.nearestRuins = null;
}
,__class__: buildings_ExplorationCentre
});
var buildings_RefinedMetalFactory = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.materialsMadePerStepPerWorker = 0.001;
buildings_MaterialConvertingFactory.call(this,game,stage,bgStage,city,world,position,worldPosition,id,this.get_animationFrames(),this.get_idleFrames());
};
$hxClasses["buildings.RefinedMetalFactory"] = buildings_RefinedMetalFactory;
buildings_RefinedMetalFactory.__name__ = "buildings.RefinedMetalFactory";
buildings_RefinedMetalFactory.__super__ = buildings_MaterialConvertingFactory;
buildings_RefinedMetalFactory.prototype = $extend(buildings_MaterialConvertingFactory.prototype,{
get_normalEfficiency: function() {
return 5.0;
}
,get_walkThroughCanViewSelfInThisBuilding: function() {
return false;
}
,get_possibleUpgrades: function() {
return [];
}
,get_possibleBuildingModes: function() {
return [buildingUpgrades_FactoryWorking,buildingUpgrades_RefinedMetalsFactoryHack,buildingUpgrades_StoneUsingFactoryDisabled];
}
,get_materialFrom: function() {
return this.city.materials.stone;
}
,set_materialFrom: function(value) {
var productionAmount = this.city.materials.stone - value;
this.city.materials.stone -= productionAmount;
this.city.simulation.stats.materialUsed[2][0] += productionAmount;
return this.city.materials.stone;
}
,get_materialTo: function() {
return this.city.materials.refinedMetal;
}
,set_materialTo: function(value) {
var productionAmount = value - this.city.materials.refinedMetal;
this.city.materials.refinedMetal += productionAmount;
this.city.simulation.stats.materialProduction[4][0] += productionAmount;
return this.city.materials.refinedMetal;
}
,get_animationFrames: function() {
return "spr_refinedmetalfactory_frames";
}
,get_idleFrames: function() {
return "spr_refinedmetalfactory_idle";
}
,onBuild: function() {
this.city.progress.unlocks.unlock(buildings_HyperElevator);
this.city.progress.unlocks.unlock(buildings_ComputerResearchCenter);
this.city.progress.unlocks.fullyUnlock(buildings_MedicalClinic);
this.city.progress.unlocks.fullyUnlock(buildings_ModernArtMuseum);
this.city.progress.unlocks.unlock(buildings_SpaciousHouse);
this.city.progress.unlocks.unlock(buildings_StoneResearchCenter);
}
,workAnimation: function(citizen,timeMod) {
if(citizen.relativeY != 10) {
if(this.workers.indexOf(citizen) == 0) {
citizen.setRelativePos(3,10);
} else {
var spd = citizen.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
if(Math.abs(3 - citizen.relativeX) < spd) {
citizen.relativeX = 3;
} else {
var num = 3 - citizen.relativeX;
citizen.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
}
citizen.setRelativeY(0);
}
}
}
,addWindowInfoLines: function() {
var _gthis = this;
buildings_MaterialConvertingFactory.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
return "" + (_gthis.totalMaterialUsed | 0) + " stone used to make " + (_gthis.materialMade | 0) + " units of refined metals.";
});
}
,onCityChange: function() {
this.efficiency = 5.0;
this.materialsMadePerStepPerWorker = 0.001;
if(this.bottomBuilding != null && this.bottomBuilding.is(buildings_ExperimentationLab)) {
this.efficiency -= 0.5;
this.materialsMadePerStepPerWorker += 0.0001;
}
if(this.topBuilding != null && this.topBuilding.is(buildings_ExperimentationLab)) {
this.efficiency -= 0.5;
this.materialsMadePerStepPerWorker += 0.0001;
}
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_MaterialConvertingFactory.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_RefinedMetalFactory.saveDefinition);
}
}
,load: function(queue,definition) {
buildings_MaterialConvertingFactory.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
}
,__class__: buildings_RefinedMetalFactory
});
var buildings_FactoryPub = function(game,stage,bgStage,city,world,position,worldPosition,id) {
buildings_RefinedMetalFactory.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.materialsMadePerStepPerWorker = 0.00075;
this.startTime = 16.5;
this.endTime = 5.5;
this.workTimePreferenceMod = 0.5;
this.isEntertainment = true;
};
$hxClasses["buildings.FactoryPub"] = buildings_FactoryPub;
buildings_FactoryPub.__name__ = "buildings.FactoryPub";
buildings_FactoryPub.__interfaces__ = [buildings_IEntertainmentBuilding];
buildings_FactoryPub.__super__ = buildings_RefinedMetalFactory;
buildings_FactoryPub.prototype = $extend(buildings_RefinedMetalFactory.prototype,{
get_baseEntertainmentCapacity: function() {
return this.workers.length * 25;
}
,get_isOpen: function() {
if(this.workers.length >= 1 && this.workers[0].currentAction == LifeAction.Work) {
var this1 = this.city.simulation.time.timeSinceStart / 60 % 24;
var start = this.startTime - this.workTimePreferenceMod;
if(start < 4.5) {
if(this1 >= start) {
return this1 < 4.5;
} else {
return false;
}
} else if(!(this1 >= start)) {
return this1 < 4.5;
} else {
return true;
}
} else {
return false;
}
}
,get_entertainmentType: function() {
return 1;
}
,get_minimumNormalTimeToSpend: function() {
return 2;
}
,get_maximumNormalTimeToSpend: function() {
return 5;
}
,get_minimumEntertainmentGroupSatisfy: function() {
return 1;
}
,get_maximumEntertainmentGroupSatisfy: function() {
return 3;
}
,get_entertainmentQuality: function() {
return 100;
}
,get_isOpenForExistingVisitors: function() {
return this.get_isOpen();
}
,finishEntertainment: function(citizen,timeMod) {
return true;
}
,get_animationFrames: function() {
return "spr_refinedmetalfactorypub_frames";
}
,get_idleFrames: function() {
return "spr_refinedmetalfactorypub_idle";
}
,get_drawerType: function() {
return buildings_buildingDrawers_AutoMergingBuildingDrawer;
}
,destroy: function() {
buildings_RefinedMetalFactory.prototype.destroy.call(this);
}
,positionSprites: function() {
buildings_RefinedMetalFactory.prototype.positionSprites.call(this);
}
,beEntertained: function(citizen,timeMod) {
var moveFunction = function() {
var moveToX = random_Random.getInt(8,16);
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = moveToX;
citizen1.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
};
if(citizen.relativeY < 5) {
citizen.changeFloor(moveFunction);
} else {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[4].length > 0 ? pool[4].splice(pool[4].length - 1,1)[0] : new Int32Array(4);
arr[0] = 4;
arr[1] = random_Random.getInt(8,this.rightBuilding != null && this.rightBuilding.is(buildings_FactoryPub) ? 19 : 16);
arr[2] = 8;
arr[3] = random_Random.getInt(60,120);
citizen1.setPath(arr,0,4,true);
}
if(!citizen.hasBuildingInited) {
citizen.wantsNightEntertainmentIn = random_Random.getInt(1,5);
citizen.hasBuildingInited = true;
}
}
,workAnimation: function(citizen,timeMod) {
if(citizen.relativeY != 10) {
if(this.workers.indexOf(citizen) == 0) {
citizen.setRelativePos(8,10);
} else {
citizen.setRelativePos(3,1);
}
}
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_RefinedMetalFactory.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_FactoryPub.saveDefinition);
}
}
,load: function(queue,definition) {
buildings_RefinedMetalFactory.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
}
,__class__: buildings_FactoryPub
});
var buildings_FarmByProductProcessor = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.cachedAdjacencyExpiration = 0.0;
this.cachedAdjacencyValue = 0.0;
this.woodMade = 0;
buildings_Factory.call(this,game,stage,bgStage,city,world,position,worldPosition,id,"spr_farmbyproductprocessor_frames","spr_farmbyproductprocessor_idle");
};
$hxClasses["buildings.FarmByProductProcessor"] = buildings_FarmByProductProcessor;
buildings_FarmByProductProcessor.__name__ = "buildings.FarmByProductProcessor";
buildings_FarmByProductProcessor.__super__ = buildings_Factory;
buildings_FarmByProductProcessor.prototype = $extend(buildings_Factory.prototype,{
get_walkThroughCanViewSelfInThisBuilding: function() {
return false;
}
,possiblyBeActive: function(timeMod) {
this.cachedAdjacencyExpiration--;
var adjacentFarmNumberToUse = this.cachedAdjacencyValue;
if(this.cachedAdjacencyExpiration <= 0) {
adjacentFarmNumberToUse = this.adjacentFarmNumber(true);
this.cachedAdjacencyValue = adjacentFarmNumberToUse;
this.cachedAdjacencyExpiration = 72;
}
var woodProduction = 0.0014 * this.activeWorkersTotalEducation * this.city.simulation.happiness.actionSpeedModifier * this.city.simulation.boostManager.currentGlobalBoostAmount * timeMod * adjacentFarmNumberToUse;
this.city.materials.wood += woodProduction;
this.city.simulation.stats.materialProduction[1][0] += woodProduction;
this.woodMade += woodProduction;
return woodProduction > 0;
}
,adjacentFarmNumber: function(trueValue) {
var effectType = "farm";
var total = 0.0;
if(this.leftBuilding != null) {
var total1 = 0.0;
var _g = 0;
var _g1 = this.leftBuilding.adjecentBuildingEffects;
while(_g < _g1.length) {
var ae = _g1[_g];
++_g;
if(ae.name == effectType) {
total1 += ae.intensity;
}
}
var thisVal = total1;
if(thisVal > 0.5) {
if(trueValue) {
if(this.leftBuilding.is(buildings_Work)) {
var workBuilding = this.leftBuilding;
total += workBuilding.workers.length / workBuilding.get_jobs();
} else {
var houseBuilding = this.leftBuilding;
total += houseBuilding.residents.length / houseBuilding.get_residentCapacity();
}
} else {
++total;
}
}
}
if(this.rightBuilding != null && (this.rightBuilding.rightBuilding == null || !this.rightBuilding.rightBuilding.is(buildings_FarmByProductProcessor))) {
var total1 = 0.0;
var _g = 0;
var _g1 = this.rightBuilding.adjecentBuildingEffects;
while(_g < _g1.length) {
var ae = _g1[_g];
++_g;
if(ae.name == effectType) {
total1 += ae.intensity;
}
}
var thisVal = total1;
if(thisVal > 0.5) {
if(trueValue) {
if(this.rightBuilding.is(buildings_Work)) {
var workBuilding = this.rightBuilding;
total += workBuilding.workers.length / workBuilding.get_jobs();
} else {
var houseBuilding = this.rightBuilding;
total += houseBuilding.residents.length / houseBuilding.get_residentCapacity();
}
} else {
++total;
}
}
}
if(this.topBuilding != null && (this.topBuilding.leftBuilding == null || !this.topBuilding.leftBuilding.is(buildings_FarmByProductProcessor)) && (this.topBuilding.rightBuilding == null || !this.topBuilding.rightBuilding.is(buildings_FarmByProductProcessor))) {
var total1 = 0.0;
var _g = 0;
var _g1 = this.topBuilding.adjecentBuildingEffects;
while(_g < _g1.length) {
var ae = _g1[_g];
++_g;
if(ae.name == effectType) {
total1 += ae.intensity;
}
}
var thisVal = total1;
if(thisVal > 0.5) {
if(trueValue) {
if(this.topBuilding.is(buildings_Work)) {
var workBuilding = this.topBuilding;
total += workBuilding.workers.length / workBuilding.get_jobs();
} else {
var houseBuilding = this.topBuilding;
total += houseBuilding.residents.length / houseBuilding.get_residentCapacity();
}
} else {
++total;
}
}
}
if(this.bottomBuilding != null && (this.bottomBuilding.leftBuilding == null || !this.bottomBuilding.leftBuilding.is(buildings_FarmByProductProcessor)) && (this.bottomBuilding.rightBuilding == null || !this.bottomBuilding.rightBuilding.is(buildings_FarmByProductProcessor)) && (this.bottomBuilding.bottomBuilding == null || !this.bottomBuilding.bottomBuilding.is(buildings_FarmByProductProcessor))) {
var total1 = 0.0;
var _g = 0;
var _g1 = this.bottomBuilding.adjecentBuildingEffects;
while(_g < _g1.length) {
var ae = _g1[_g];
++_g;
if(ae.name == effectType) {
total1 += ae.intensity;
}
}
var thisVal = total1;
if(thisVal > 0.5) {
if(trueValue) {
if(this.bottomBuilding.is(buildings_Work)) {
var workBuilding = this.bottomBuilding;
total += workBuilding.workers.length / workBuilding.get_jobs();
} else {
var houseBuilding = this.bottomBuilding;
total += houseBuilding.residents.length / houseBuilding.get_residentCapacity();
}
} else {
++total;
}
}
}
return total;
}
,workAnimation: function(citizen,timeMod) {
if(citizen.relativeY != 10) {
if(this.workers.indexOf(citizen) == 0) {
citizen.setRelativePos(12,10);
} else {
citizen.setRelativePos(15,10);
}
}
}
,canShowActiveTextures: function() {
return true;
}
,addWindowInfoLines: function() {
var _gthis = this;
buildings_Factory.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
return "Processing by-products for " + (_gthis.adjacentFarmNumber(false) | 0) + " farm" + ((_gthis.adjacentFarmNumber(false) | 0) == 1 ? "" : "s") + ".";
});
this.city.gui.windowAddInfoText(null,function() {
return "" + (_gthis.woodMade | 0) + " wood produced.";
});
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Factory.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_FarmByProductProcessor.saveDefinition);
}
var value = this.woodMade;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
}
,load: function(queue,definition) {
buildings_Factory.prototype.load.call(this,queue);
if(queue.version < 22) {
return;
}
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"woodMade")) {
this.woodMade = loadMap.h["woodMade"];
}
}
,__class__: buildings_FarmByProductProcessor
});
var buildings_FarmGrowArea = function(stage,partOf,relativePosition,city,textureName,textureWidth,foodPerHarvest,growSpeedMultiplier,cleanSpeed,harvestSpritePart) {
if(harvestSpritePart == null) {
harvestSpritePart = 1;
}
this.percentCleaned = 0;
this.originalFoodLeft = 1;
this.foodLeft = 0;
this.percentGrown = 0;
this.farmStage = buildings_FarmStage.Growing;
this.harvestSpritePart = 1;
this.passiveGrowSpeedBadLight = 0.006;
this.passiveGrowSpeed = 0.012;
this.cleanSpeed = 5;
this.harvestAmount = 0.25;
this.growSpeed = 0.85;
this.foodPerHarvest = 25;
this.partOf = partOf;
this.city = city;
this.relativePosition = relativePosition;
this.stage = stage;
this.foodPerHarvest = foodPerHarvest;
this.growSpeed *= growSpeedMultiplier;
this.passiveGrowSpeed *= growSpeedMultiplier;
this.passiveGrowSpeedBadLight *= growSpeedMultiplier;
this.cleanSpeed = cleanSpeed;
this.harvestSpritePart = harvestSpritePart;
this.textures = Resources.getTexturesByWidth(textureName,textureWidth);
this.growthSprite = new PIXI.Sprite();
stage.addChild(this.growthSprite);
this.positionSprites();
this.updateTexture();
};
$hxClasses["buildings.FarmGrowArea"] = buildings_FarmGrowArea;
buildings_FarmGrowArea.__name__ = "buildings.FarmGrowArea";
buildings_FarmGrowArea.prototype = {
destroy: function() {
this.stage.removeChild(this.growthSprite);
}
,update: function(timeMod) {
if(this.farmStage == buildings_FarmStage.Growing) {
var this1 = this.city.simulation.time.timeSinceStart / 60 % 24;
var start = 7;
var end = 20;
if(start < end ? this1 >= start && this1 < end : this1 >= start || this1 < end) {
this.percentGrown += timeMod * this.passiveGrowSpeed;
if(this.percentGrown >= 100) {
this.farmStage = buildings_FarmStage.Harvesting;
this.foodLeft = this.foodPerHarvest + this.city.simulation.bonuses.extraFoodFromFarms + this.partOf.getEffectsOfAdjecentBuildings("increaseCropNumber");
this.originalFoodLeft = this.foodLeft;
}
this.updateTexture();
} else {
var this1 = this.city.simulation.time.timeSinceStart / 60 % 24;
var start = 7 - 1;
var end = 20 + 1;
if(start < end ? this1 >= start && this1 < end : this1 >= start || this1 < end) {
this.percentGrown += timeMod * this.passiveGrowSpeedBadLight;
if(this.percentGrown >= 100) {
this.farmStage = buildings_FarmStage.Harvesting;
this.foodLeft = this.foodPerHarvest + this.city.simulation.bonuses.extraFoodFromFarms + this.partOf.getEffectsOfAdjecentBuildings("increaseCropNumber");
this.originalFoodLeft = this.foodLeft;
}
this.updateTexture();
}
}
}
}
,doCitizenWork: function(citizen) {
var _gthis = this;
var timeMin = (this.farmStage == buildings_FarmStage.Harvesting ? 15 : 30) / this.city.simulation.happiness.actionSpeedModifierWithoutPenalties | 0;
var timeMax = (this.farmStage == buildings_FarmStage.Harvesting ? 30 : 60) / this.city.simulation.happiness.actionSpeedModifierWithoutPenalties | 0;
var modifyWithHappiness = false;
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
citizen.moveAndWait(random_Random.getInt(this.relativePosition.x,this.relativePosition.x + (this.growthSprite.texture.width | 0) - 2 + 1),random_Random.getInt(timeMin,timeMax),function() {
_gthis.onCitizenWork(citizen);
},modifyWithHappiness,false);
}
,doCitizenWorkNoMove: function(citizen) {
var _gthis = this;
var timeMin = this.farmStage == buildings_FarmStage.Harvesting ? 15 : 30;
var timeMax = this.farmStage == buildings_FarmStage.Harvesting ? 30 : 60;
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = random_Random.getInt(timeMin,timeMax);
citizen1.setPath(arr,0,2,true);
citizen.pathEndFunction = function() {
_gthis.onCitizenWork(citizen);
};
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
,onCitizenWork: function(citizen) {
switch(this.farmStage._hx_index) {
case 0:
this.percentGrown += this.growSpeed;
if(this.percentGrown >= 100) {
this.farmStage = buildings_FarmStage.Harvesting;
this.foodLeft = this.foodPerHarvest + this.city.simulation.bonuses.extraFoodFromFarms + this.partOf.getEffectsOfAdjecentBuildings("increaseCropNumber");
this.originalFoodLeft = this.foodLeft;
}
this.updateTexture();
break;
case 1:
var currentHarvestAmount = this.harvestAmount * this.city.simulation.boostManager.currentGlobalBoostAmount;
this.foodLeft -= currentHarvestAmount;
var _g = this.city.materials;
_g.set_food(_g.food + currentHarvestAmount);
this.city.simulation.stats.materialProduction[0][0] += currentHarvestAmount;
if(this.foodLeft <= 0) {
if(this.cleanSpeed <= 0) {
this.farmStage = buildings_FarmStage.Growing;
this.percentGrown = 0;
} else {
this.percentCleaned = 0;
this.farmStage = buildings_FarmStage.Cleaning;
}
}
this.updateTexture();
break;
case 2:
this.percentCleaned += this.cleanSpeed;
if(this.percentCleaned >= 100) {
this.farmStage = buildings_FarmStage.Growing;
this.percentGrown = 0;
}
this.updateTexture();
break;
}
}
,setTexture: function(textureName,textureWidth) {
this.textures = Resources.getTexturesByWidth(textureName,textureWidth);
}
,updateTexture: function() {
var tmp;
switch(this.farmStage._hx_index) {
case 0:
tmp = this.textures[Math.floor(this.percentGrown / 100 * (this.textures.length - 1 - this.harvestSpritePart))];
break;
case 1:
var val = this.textures.length - 1 - Math.ceil(this.foodLeft / this.originalFoodLeft * 0.9999 * this.harvestSpritePart);
var maxVal = this.textures.length - 2;
tmp = this.textures[val < 1 ? 1 : val > maxVal ? maxVal : val];
break;
case 2:
tmp = this.textures[this.textures.length - 1];
break;
}
this.growthSprite.texture = tmp;
}
,positionSprites: function() {
if(this.growthSprite != null) {
this.growthSprite.position.set(this.partOf.position.x + this.relativePosition.x,this.partOf.position.y + this.relativePosition.y);
}
}
,showInfoText: function(extraText) {
var _gthis = this;
this.city.gui.windowAddInfoText(null,function() {
switch(_gthis.farmStage._hx_index) {
case 0:
return "" + extraText + "Crops " + Math.floor(_gthis.percentGrown) + "% grown.";
case 1:
return "" + extraText + Math.floor(_gthis.foodLeft) + " food left to harvest.";
case 2:
return "" + extraText + "Old crops " + Math.floor(_gthis.percentCleaned) + "% cleaned.";
}
});
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
if(shouldSaveDefinition) {
queue.addString(buildings_FarmGrowArea.saveDefinition);
}
var e = this.farmStage;
queue.addString($hxEnums[e.__enum__].__constructs__[e._hx_index]);
var value = this.percentGrown;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.foodLeft;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.originalFoodLeft;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.percentCleaned;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
}
,load: function(queue,definition) {
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"farmStage")) {
this.farmStage = loadMap.h["farmStage"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"percentGrown")) {
this.percentGrown = loadMap.h["percentGrown"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"foodLeft")) {
this.foodLeft = loadMap.h["foodLeft"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"originalFoodLeft")) {
this.originalFoodLeft = loadMap.h["originalFoodLeft"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"percentCleaned")) {
this.percentCleaned = loadMap.h["percentCleaned"];
}
}
,__class__: buildings_FarmGrowArea
};
var buildings_FarmHouse = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.totalMaterialsProduced = 0;
this.materialPhase = 0;
this.stageProgress = 0;
this.resourceSprite = null;
this.resourceSprite = new PIXI.Sprite();
buildings_House.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.buildingMode = Type.createInstance(this.get_possibleBuildingModes()[random_Random.getInt(3)],[stage,city.cityMidStage,bgStage,this]);
this.currentMaterialTextures = this.get_materialTextures();
this.resourceSprite.position.set(position.x + 3,position.y + 3);
bgStage.addChild(this.resourceSprite);
};
$hxClasses["buildings.FarmHouse"] = buildings_FarmHouse;
buildings_FarmHouse.__name__ = "buildings.FarmHouse";
buildings_FarmHouse.__super__ = buildings_House;
buildings_FarmHouse.prototype = $extend(buildings_House.prototype,{
get_originalMaterials: function() {
switch(this.materialType) {
case 0:
return 20;
case 1:
return 25;
case 2:
return 10;
default:
return 10;
}
}
,get_materialTextures: function() {
var tmp;
switch(this.materialType) {
case 0:
tmp = "spr_communityhouse_rock";
break;
case 1:
tmp = "spr_communityhouse_tree";
break;
case 2:
tmp = "spr_communityhouse_crop";
break;
default:
tmp = "";
}
return Resources.getTexturesByWidth(tmp,5);
}
,get_possibleUpgrades: function() {
return [buildingUpgrades_IndoorPond];
}
,get_possibleBuildingModes: function() {
return [buildingUpgrades_CHProduceFood,buildingUpgrades_CHProduceStone,buildingUpgrades_CHProduceWood];
}
,destroy: function() {
buildings_House.prototype.destroy.call(this);
this.resourceSprite.destroy();
}
,postLoad: function() {
this.resourceSprite.alpha = 1;
this.setResourceSpriteTexture();
}
,positionSprites: function() {
buildings_House.prototype.positionSprites.call(this);
if(this.resourceSprite != null) {
this.resourceSprite.position.set(this.position.x + 3,this.position.y + 3);
}
}
,update: function(timeMod) {
if(this.materialPhase == 0) {
switch(this.materialType) {
case 0:
this.stageProgress += timeMod * 0.05;
if(this.stageProgress >= 1) {
this.materialPhase = 1;
this.stageProgress = this.get_originalMaterials();
this.resourceSprite.alpha = 1;
}
this.setResourceSpriteTexture();
break;
case 1:
var this1 = this.city.simulation.time.timeSinceStart / 60 % 24;
var start = 7;
var end = 20;
if(start < end ? this1 >= start && this1 < end : this1 >= start || this1 < end) {
this.stageProgress += 0.00018 * timeMod;
if(this.stageProgress >= 1) {
this.materialPhase = 1;
this.stageProgress = this.get_originalMaterials();
}
this.setResourceSpriteTexture();
}
break;
case 2:
var this1 = this.city.simulation.time.timeSinceStart / 60 % 24;
var start = 7;
var end = 20;
if(start < end ? this1 >= start && this1 < end : this1 >= start || this1 < end) {
this.stageProgress += 0.00008 * timeMod;
if(this.stageProgress >= 1) {
this.materialPhase = 1;
this.stageProgress = this.get_originalMaterials();
}
this.setResourceSpriteTexture();
}
break;
}
}
}
,walkAround: function(citizen,stepsInBuilding) {
var _gthis = this;
if(stepsInBuilding < 180) {
if(citizen.relativeY > 5) {
citizen.changeFloor();
} else {
var timeMin = this.materialPhase == 2 ? 20 : 50;
var timeMax = this.materialPhase == 2 ? 30 : 80;
var modifyWithHappiness = true;
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
citizen.moveAndWait(random_Random.getInt(3,7),random_Random.getInt(timeMin,timeMax),function() {
switch(_gthis.materialType) {
case 0:
if(_gthis.materialPhase == 1) {
var harvestAmount = 0.1;
var currentHarvestAmount = harvestAmount * _gthis.city.simulation.boostManager.currentGlobalBoostAmount;
_gthis.stageProgress -= currentHarvestAmount;
_gthis.city.materials.stone += currentHarvestAmount;
_gthis.city.simulation.stats.materialProduction[2][0] += currentHarvestAmount;
_gthis.totalMaterialsProduced += currentHarvestAmount;
if(_gthis.stageProgress <= 0) {
_gthis.stageProgress = 0;
_gthis.materialPhase = 0;
}
}
break;
case 1:
if(_gthis.materialPhase == 0) {
_gthis.stageProgress += 0.005;
if(_gthis.stageProgress >= 1) {
_gthis.stageProgress = _gthis.get_originalMaterials();
_gthis.materialPhase += 1;
}
} else {
var harvestAmount = 0.2;
var currentHarvestAmount = harvestAmount * _gthis.city.simulation.boostManager.currentGlobalBoostAmount;
_gthis.stageProgress -= currentHarvestAmount;
_gthis.city.materials.wood += currentHarvestAmount;
_gthis.city.simulation.stats.materialProduction[1][0] += currentHarvestAmount;
_gthis.totalMaterialsProduced += currentHarvestAmount;
if(_gthis.stageProgress <= 0) {
_gthis.stageProgress = 0;
_gthis.materialPhase = 0;
}
}
break;
case 2:
if(_gthis.materialPhase == 1) {
var harvestAmount = 0.25;
var currentHarvestAmount = harvestAmount * _gthis.city.simulation.boostManager.currentGlobalBoostAmount;
_gthis.stageProgress -= currentHarvestAmount;
var _g = _gthis.city.materials;
_g.set_food(_g.food + currentHarvestAmount);
_gthis.city.simulation.stats.materialProduction[0][0] += currentHarvestAmount;
_gthis.totalMaterialsProduced += currentHarvestAmount;
if(_gthis.stageProgress <= 0) {
_gthis.stageProgress = 0;
_gthis.materialPhase = 2;
}
} else if(_gthis.materialPhase == 0) {
_gthis.stageProgress += 0.01;
if(_gthis.stageProgress >= 1) {
_gthis.stageProgress = _gthis.get_originalMaterials();
_gthis.materialPhase += 1;
}
} else if(_gthis.materialPhase == 2) {
_gthis.stageProgress += 0.1;
if(_gthis.stageProgress >= 1) {
_gthis.stageProgress = 0;
_gthis.materialPhase = 0;
}
}
break;
}
_gthis.setResourceSpriteTexture();
},modifyWithHappiness,false);
}
} else if(citizen.relativeX > 11 && random_Random.getInt(3) == 1) {
citizen.changeFloorAndWaitRandom(60,90);
} else {
citizen.moveAndWait(random_Random.getInt(12,16),random_Random.getInt(60,90),null,false,false);
}
}
,setMaterialType: function(type) {
this.materialType = type;
this.currentMaterialTextures = this.get_materialTextures();
buildings_FarmHouse.treeGrowTextures = Resources.getTexturesByWidth("spr_communityhouse_tree_grow",5);
if(this.materialType == 2) {
this.adjecentBuildingEffects.push({ name : "farm", intensity : 1});
} else {
var farmEffect = Lambda.find(this.adjecentBuildingEffects,function(ae) {
return ae.name == "farm";
});
HxOverrides.remove(this.adjecentBuildingEffects,farmEffect);
}
this.resourceSprite.alpha = 1;
this.setResourceSpriteTexture();
}
,resetProgress: function() {
this.materialPhase = 0;
this.stageProgress = 0;
}
,setResourceSpriteTexture: function() {
if((this.materialType == 0 || this.materialType == 1) && this.materialPhase == 1) {
var tmp = this.currentMaterialTextures;
var tmp1 = 1 - this.stageProgress / this.get_originalMaterials();
this.resourceSprite.texture = tmp[Math.ceil(tmp1 * (this.currentMaterialTextures.length - 1))];
} else if(this.materialType == 0) {
this.resourceSprite.texture = this.currentMaterialTextures[0];
this.resourceSprite.alpha = this.stageProgress;
} else if(this.materialType == 2 && this.materialPhase == 0) {
this.resourceSprite.texture = this.currentMaterialTextures[this.stageProgress * (this.currentMaterialTextures.length - 2) | 0];
} else if(this.materialType == 1 && this.materialPhase == 0) {
this.resourceSprite.texture = buildings_FarmHouse.treeGrowTextures[this.stageProgress * buildings_FarmHouse.treeGrowTextures.length | 0];
} else if(this.materialType == 2) {
if(this.materialPhase == 1) {
this.resourceSprite.texture = this.currentMaterialTextures[this.currentMaterialTextures.length - 2];
} else if(this.materialPhase == 2) {
this.resourceSprite.texture = this.currentMaterialTextures[this.currentMaterialTextures.length - 1];
}
}
}
,addWindowInfoLines: function() {
var _gthis = this;
buildings_House.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
return "" + (_gthis.totalMaterialsProduced | 0) + " resources produced.";
});
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_House.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_FarmHouse.saveDefinition);
}
var value = this.stageProgress;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.materialPhase;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.totalMaterialsProduced;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
}
,load: function(queue,definition) {
buildings_House.prototype.load.call(this,queue);
if(queue.version < 23) {
return;
}
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"stageProgress")) {
this.stageProgress = loadMap.h["stageProgress"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"materialPhase")) {
this.materialPhase = loadMap.h["materialPhase"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"totalMaterialsProduced")) {
this.totalMaterialsProduced = loadMap.h["totalMaterialsProduced"];
}
this.postLoad();
}
,__class__: buildings_FarmHouse
});
var buildings_FarmStage = $hxEnums["buildings.FarmStage"] = { __ename__ : "buildings.FarmStage", __constructs__ : ["Growing","Harvesting","Cleaning"]
,Growing: {_hx_index:0,__enum__:"buildings.FarmStage",toString:$estr}
,Harvesting: {_hx_index:1,__enum__:"buildings.FarmStage",toString:$estr}
,Cleaning: {_hx_index:2,__enum__:"buildings.FarmStage",toString:$estr}
};
var buildings_FestivalHQ = function(game,stage,bgStage,city,world,position,worldPosition,id) {
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.doorX = 14;
this.festivalCoolDown = 0;
};
$hxClasses["buildings.FestivalHQ"] = buildings_FestivalHQ;
buildings_FestivalHQ.__name__ = "buildings.FestivalHQ";
buildings_FestivalHQ.__super__ = buildings_Work;
buildings_FestivalHQ.prototype = $extend(buildings_Work.prototype,{
work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking) {
citizen.currentAction = LifeAction.Nothing;
return;
}
if(citizen.relativeY > 5) {
if(random_Random.getFloat(1) < 0.5) {
citizen.changeFloor(function() {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = random_Random.getInt(50,100);
citizen1.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
});
} else {
citizen.moveAndWait(random_Random.fromArray([3,4,5,6,12,13,14,15]),random_Random.getInt(50,100));
}
} else if(random_Random.getFloat(1) < 0.3) {
citizen.changeFloor(function() {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = random_Random.getInt(50,100);
citizen1.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
});
} else {
citizen.moveAndWait(random_Random.fromArray([3,8,13,14]),random_Random.getInt(50,100));
}
}
,update: function(timeMod) {
if(this.festivalCoolDown > -1) {
this.festivalCoolDown -= timeMod * (this.workers.length / this.get_jobs()) * this.city.simulation.time.minutesPerTick;
}
}
,getMusicFestivalMTP: function() {
return new Materials(this.city.simulation.citizens.length,0,this.city.simulation.citizens.length * 3);
}
,getHundredFestivalMTP: function() {
return new Materials(0,0,this.city.simulation.citizens.length * 2);
}
,addWindowInfoLines: function() {
var _gthis = this;
var shouldShowCreationOptions = function() {
if(_gthis.city.simulation.festivalManager.hasNoPlannedFestival() && _gthis.festivalCoolDown < 0) {
return _gthis.city.simulation.festivalManager.festivalCoolDown < 0;
} else {
return false;
}
};
buildings_Work.prototype.addWindowInfoLines.call(this);
var gui = this.city.gui;
var windowDisplayType = 0;
var festivalContainer = new gui_GUIContainer(gui,gui.innerWindowStage,gui.windowInner);
festivalContainer.fillSecondarySize = true;
festivalContainer.direction = gui_GUIContainerDirection.Vertical;
gui.windowInner.addChild(festivalContainer);
var showFestivalCreationOptions;
var showCurrentFestivalInfo = function() {
festivalContainer.clear();
festivalContainer.addChild(new gui_GUISpacing(festivalContainer,new common_Point(0,3)));
festivalContainer.addChild(new gui_TextElement(festivalContainer,gui.innerWindowStage,null,function() {
var fm = _gthis.city.simulation.festivalManager;
if(fm.hasFestival()) {
return "Current Festival";
}
if(fm.plannedFestival() != null) {
return "Planned Festival";
}
return "Preparing...";
},"Arial15"));
festivalContainer.addChild(new gui_TextElement(festivalContainer,gui.innerWindowStage,null,function() {
var fm = _gthis.city.simulation.festivalManager;
if(fm.hasFestival()) {
return fm.currentFestival().getText();
}
if(fm.plannedFestival() != null) {
return fm.plannedFestival().getText();
}
if(_gthis.workers.length == 0) {
return "Assign workers to prepare for a new festival!";
}
var hireMoreText = "";
if(_gthis.workers.length < _gthis.get_jobs()) {
hireMoreText = " Assign more workers to speed this up!";
}
return common_StringExtensions.firstToUpper(CityTime.getBasicTimeString(Math.max(_gthis.festivalCoolDown,_gthis.city.simulation.festivalManager.festivalCoolDown) * (_gthis.get_jobs() / _gthis.workers.length))) + " of preparation left." + hireMoreText;
}));
gui.window.onUpdate = function() {
if(shouldShowCreationOptions()) {
showFestivalCreationOptions();
}
};
};
showFestivalCreationOptions = function() {
festivalContainer.clear();
var headerContainer = gui_UpgradeWindowParts.createHeader(gui,"Organize a Festival",festivalContainer);
var infoContainerInfo = gui_UpgradeWindowParts.createActivatableButton(_gthis.city.gui,false,function() {
var mtp = _gthis.getMusicFestivalMTP();
if(_gthis.city.materials.canAfford(mtp) && _gthis.city.simulation.festivalManager.hasNoPlannedFestival() && simulation_festival_MusicFestival.canDo(_gthis.city,_gthis.city.simulation,_gthis)) {
_gthis.city.materials.remove(mtp);
var musicFestival = new simulation_festival_MusicFestival(_gthis.city,_gthis.city.simulation,_gthis.city.simulation.festivalManager,_gthis);
musicFestival.plan();
_gthis.city.simulation.festivalManager.addFestival(musicFestival);
_gthis.festivalCoolDown += 8783.9999999999982;
_gthis.city.simulation.festivalManager.festivalCoolDown = _gthis.festivalCoolDown;
showCurrentFestivalInfo();
} else {
var createWarningWindow = function() {
_gthis.city.gui.showSimpleWindow("You can't organize a Music Festival right now!",null,true);
};
createWarningWindow();
_gthis.city.gui.addWindowToStack(createWarningWindow);
}
},"Music Festival","A huge, awesome party that lasts for one day. Boosts the happiness of your citizens for a week. This can even make it go over 100.",festivalContainer);
var materialsToPay = _gthis.getMusicFestivalMTP();
var infoContainer = infoContainerInfo.container;
var mcdContainer = new gui_GUIContainer(gui,gui.innerWindowStage,infoContainer);
var mcd = new gui_MaterialsCostDisplay(_gthis.city,materialsToPay,"");
mcdContainer.addChild(new gui_ContainerHolder(mcdContainer,gui.innerWindowStage,mcd,{ left : 0, right : 0, top : 0, bottom : gui_UpgradeWindowParts.hasMultiUpgradeModeOn ? materialsToPay.knowledge == 0 ? 0 : 1 : 2},$bind(mcd,mcd.updateCostDisplay)));
gui.window.onUpdate = function() {
var materialsToPay = _gthis.getMusicFestivalMTP();
mcd.setCost(materialsToPay);
};
infoContainer.addChild(mcdContainer);
festivalContainer.addChild(new gui_GUISpacing(festivalContainer,new common_Point(0,3)));
};
if(shouldShowCreationOptions()) {
showFestivalCreationOptions();
} else {
showCurrentFestivalInfo();
}
}
,destroy: function() {
buildings_Work.prototype.destroy.call(this);
var _g = 0;
var _g1 = this.city.simulation.festivalManager.festivals;
while(_g < _g1.length) {
var fes = _g1[_g];
++_g;
this.city.simulation.festivalManager.endFestival(fes);
}
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Work.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_FestivalHQ.saveDefinition);
}
var value = this.festivalCoolDown;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
}
,load: function(queue,definition) {
buildings_Work.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"festivalCoolDown")) {
this.festivalCoolDown = loadMap.h["festivalCoolDown"];
}
}
,__class__: buildings_FestivalHQ
});
var buildings_FlowerPenthouse = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.mirrored = false;
this.teleportX = 15;
this.topFlower = null;
buildings_House.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.doorX = 14;
this.yearsToLiveLongerPerYearIfLivingHere = 0.05;
this.updateTopFlower();
};
$hxClasses["buildings.FlowerPenthouse"] = buildings_FlowerPenthouse;
buildings_FlowerPenthouse.__name__ = "buildings.FlowerPenthouse";
buildings_FlowerPenthouse.__super__ = buildings_House;
buildings_FlowerPenthouse.prototype = $extend(buildings_House.prototype,{
get_possibleUpgrades: function() {
return [];
}
,get_baseAttractiveness: function() {
return 100;
}
,get_hasPrivateTeleporter: function() {
return true;
}
,postLoad: function() {
if(this.mirrored) {
this.mirror();
this.mirrored = true;
}
}
,mirror: function() {
this.mirrored = !this.mirrored;
this.updateTopFlower();
this.teleportX = 19 - this.teleportX;
this.drawer.mirror();
}
,updateTopFlower: function() {
if(this.world.permanents[this.worldPosition.x].length == this.worldPosition.y + 1 || this.world.permanents[this.worldPosition.x][this.worldPosition.y + 1] == null) {
if(this.topFlower == null) {
this.topFlower = new PIXI.Sprite(Resources.getTexture("spr_flower_up"));
this.stage.addChild(this.topFlower);
this.topFlower.anchor.y = 1;
}
if(this.mirrored) {
this.topFlower.position.set(this.position.x + 20,this.position.y);
this.topFlower.scale.x = -1;
} else {
this.topFlower.position.set(this.position.x,this.position.y);
this.topFlower.scale.x = 1;
}
} else if(this.topFlower != null) {
this.topFlower.destroy();
this.topFlower = null;
}
}
,onCityChange: function() {
buildings_House.prototype.onCityChange.call(this);
this.updateTopFlower();
}
,destroy: function() {
buildings_House.prototype.destroy.call(this);
if(this.topFlower != null) {
this.topFlower.destroy();
}
}
,walkAround: function(citizen,stepsInBuilding) {
if(this.mirrored) {
if(citizen.relativeY < 5) {
if(citizen.relativeX >= 5 || random_Random.getFloat() < 0.5) {
citizen.moveAndWait(random_Random.getInt(3,16),random_Random.getInt(60,90),null,false,false);
} else {
citizen.changeFloorAndWait(60);
}
} else if(citizen.relativeX >= 5 || random_Random.getFloat() < 0.8) {
var rnd = random_Random.getFloat();
if(rnd < 0.5) {
citizen.moveAndWait(random_Random.getInt(15,18),random_Random.getInt(40,60),null,false,false);
} else if(rnd < 0.8) {
citizen.moveAndWait(random_Random.getInt(10,12),random_Random.getInt(60,90),null,false,false);
} else {
citizen.moveAndWait(random_Random.getInt(3,5),random_Random.getInt(60,90),null,false,false);
}
} else {
citizen.changeFloorAndWait(60);
}
} else if(citizen.relativeY < 5) {
if(citizen.relativeX < 14 || random_Random.getFloat() < 0.5) {
citizen.moveAndWait(random_Random.getInt(3,16),random_Random.getInt(60,90),null,false,false);
} else {
citizen.changeFloorAndWait(60);
}
} else if(citizen.relativeX < 14 || random_Random.getFloat() < 0.8) {
var rnd = random_Random.getFloat();
if(rnd < 0.5) {
citizen.moveAndWait(random_Random.getInt(1,4),random_Random.getInt(40,60),null,false,false);
} else if(rnd < 0.8) {
citizen.moveAndWait(random_Random.getInt(7,9),random_Random.getInt(60,90),null,false,false);
} else {
citizen.moveAndWait(random_Random.getInt(14,16),random_Random.getInt(60,90),null,false,false);
}
} else {
citizen.changeFloorAndWait(60);
}
}
,createWindowAddBottomButtons: function() {
gui_windowParts_FullSizeTextButton.create(this.city.gui,$bind(this,this.mirror),this.city.gui.windowInner,function() {
return "Mirror";
},this.city.gui.innerWindowStage);
this.city.gui.windowInner.addChild(new gui_GUISpacing(this.city.gui.windowInner,new common_Point(2,6)));
buildings_House.prototype.createWindowAddBottomButtons.call(this);
}
,createTeleportParticle: function(rayTexture) {
if(rayTexture == null) {
rayTexture = "unused";
}
this.city.particles.addParticle(Resources.getTexturesByWidth(this.mirrored ? "spr_smallteleporter_ray_penthouse_mirror" : "spr_smallteleporter_ray_penthouse",3),new common_Point(this.position.x + (this.mirrored ? 3 : 14),this.position.y + 12));
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_House.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_FlowerPenthouse.saveDefinition);
}
var value = this.mirrored;
if(queue.size + 1 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 1) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.b[queue.size] = value ? 1 : 0;
queue.size += 1;
}
,load: function(queue,definition) {
buildings_House.prototype.load.call(this,queue);
if(queue.version < 26) {
return;
}
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"mirrored")) {
this.mirrored = loadMap.h["mirrored"];
}
this.postLoad();
}
,__class__: buildings_FlowerPenthouse
});
var buildings_FossilMuseum = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.totalKnowledgeGenerated = 0;
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.startTime = 14;
this.endTime = 23;
this.workTimePreferenceMod = 0.5;
this.isEntertainment = true;
};
$hxClasses["buildings.FossilMuseum"] = buildings_FossilMuseum;
buildings_FossilMuseum.__name__ = "buildings.FossilMuseum";
buildings_FossilMuseum.__interfaces__ = [buildings_IEntertainmentBuilding];
buildings_FossilMuseum.__super__ = buildings_Work;
buildings_FossilMuseum.prototype = $extend(buildings_Work.prototype,{
get_baseEntertainmentCapacity: function() {
return this.workers.length * 50;
}
,get_isOpen: function() {
if(this.workers.length >= 1 && common_ArrayExtensions.any(this.workers,function(w) {
return w.currentAction == LifeAction.Work;
})) {
var this1 = this.city.simulation.time.timeSinceStart / 60 % 24;
var start = this.startTime - this.workTimePreferenceMod;
if(start < 23) {
if(this1 >= start) {
return this1 < 23;
} else {
return false;
}
} else if(!(this1 >= start)) {
return this1 < 23;
} else {
return true;
}
} else {
return false;
}
}
,get_entertainmentType: function() {
return 5;
}
,get_minimumNormalTimeToSpend: function() {
return 2;
}
,get_maximumNormalTimeToSpend: function() {
return 5;
}
,get_minimumEntertainmentGroupSatisfy: function() {
return 1;
}
,get_maximumEntertainmentGroupSatisfy: function() {
return 3;
}
,get_entertainmentQuality: function() {
return 100;
}
,get_isOpenForExistingVisitors: function() {
return this.get_isOpen();
}
,finishEntertainment: function(citizen,timeMod) {
return true;
}
,positionSprites: function() {
buildings_Work.prototype.positionSprites.call(this);
}
,beEntertained: function(citizen,timeMod) {
var moveFunction = function() {
if(citizen.relativeY < 5) {
if(random_Random.getFloat() < 1) {
var slowMove = true;
if(slowMove == null) {
slowMove = false;
}
var moveToX = random_Random.getInt(12,16);
if(slowMove) {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[4].length > 0 ? pool[4].splice(pool[4].length - 1,1)[0] : new Int32Array(4);
arr[0] = 12;
arr[1] = 50;
arr[2] = 4;
arr[3] = moveToX;
citizen1.setPath(arr,0,4,true);
} else {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = moveToX;
citizen1.setPath(arr,0,2,true);
}
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
} else {
var slowMove = true;
if(slowMove == null) {
slowMove = false;
}
if(slowMove) {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[4].length > 0 ? pool[4].splice(pool[4].length - 1,1)[0] : new Int32Array(4);
arr[0] = 12;
arr[1] = 50;
arr[2] = 4;
arr[3] = 6;
citizen1.setPath(arr,0,4,true);
} else {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = 6;
citizen1.setPath(arr,0,2,true);
}
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
} else {
var slowMove = true;
if(slowMove == null) {
slowMove = false;
}
var moveToX = random_Random.getInt(4,15);
if(slowMove) {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[4].length > 0 ? pool[4].splice(pool[4].length - 1,1)[0] : new Int32Array(4);
arr[0] = 12;
arr[1] = 50;
arr[2] = 4;
arr[3] = moveToX;
citizen1.setPath(arr,0,4,true);
} else {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = moveToX;
citizen1.setPath(arr,0,2,true);
}
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
};
if(random_Random.getInt(2) == 1) {
citizen.changeFloor(moveFunction);
} else {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = random_Random.getInt(120,180);
citizen1.setPath(arr,0,2,true);
citizen.pathEndFunction = moveFunction;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
if(!citizen.hasBuildingInited) {
citizen.educationLevel = Math.max(Math.min(citizen.educationLevel + 0.035,1.61),citizen.educationLevel);
citizen.hasBuildingInited = true;
}
}
,work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking) {
citizen.currentAction = LifeAction.Nothing;
} else {
switch(this.workers.indexOf(citizen)) {
case 0:
var spd = citizen.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
if(Math.abs(6 - citizen.relativeX) < spd) {
citizen.relativeX = 6;
} else {
var num = 6 - citizen.relativeX;
citizen.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
}
var newKnowledge = 0.001 * this.city.simulation.bonuses.fossilsCollected * timeMod * this.city.simulation.happiness.actionSpeedModifier * citizen.get_educationSpeedModifier() * this.city.simulation.boostManager.currentGlobalBoostAmount * this.workers.length;
this.city.materials.knowledge += newKnowledge;
this.city.simulation.stats.materialProduction[8][0] += newKnowledge;
this.totalKnowledgeGenerated += newKnowledge;
break;
case 1:
citizen.moveAndWait(random_Random.getInt(12,16),random_Random.getInt(120,180),null,false,false);
break;
case 2:
if(citizen.relativeY < 5) {
citizen.changeFloor();
} else {
citizen.moveAndWait(random_Random.getInt(4,16),random_Random.getInt(120,180),null,false,false);
}
break;
}
}
}
,addWindowInfoLines: function() {
var _gthis = this;
buildings_Work.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
return "" + (_gthis.totalKnowledgeGenerated | 0) + " knowledge gathered.";
});
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Work.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_FossilMuseum.saveDefinition);
}
var value = this.totalKnowledgeGenerated;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
}
,load: function(queue,definition) {
buildings_Work.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"totalKnowledgeGenerated")) {
this.totalKnowledgeGenerated = loadMap.h["totalKnowledgeGenerated"];
}
}
,__class__: buildings_FossilMuseum
});
var buildings_HackerHQ = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.timeToCheckBuildings = 0;
this.currentMission = 0;
this.manyTeleportAlpha = 0;
this.eventPhase = 0;
this.doingEvent = -1;
this.lastEventDoneOnDay = 0;
buildings_WorkWithHome.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.startTime = 14;
this.endTime = 3;
this.workTimePreferenceMod = 0.3;
this.boltSprite = new PIXI.Sprite(Resources.getTexture("spr_hackers_bolt"));
this.boltSprite.position.set(position.x + 12,position.y + 11);
stage.addChild(this.boltSprite);
if(worldPosition.y == 0) {
this.boltSprite.visible = false;
}
};
$hxClasses["buildings.HackerHQ"] = buildings_HackerHQ;
buildings_HackerHQ.__name__ = "buildings.HackerHQ";
buildings_HackerHQ.__super__ = buildings_WorkWithHome;
buildings_HackerHQ.prototype = $extend(buildings_WorkWithHome.prototype,{
positionSprites: function() {
buildings_WorkWithHome.prototype.positionSprites.call(this);
this.boltSprite.position.set(this.position.x + 12,this.position.y + 11);
if(this.worldPosition.y == 0) {
this.boltSprite.visible = false;
}
}
,destroy: function() {
this.boltSprite.destroy();
buildings_WorkWithHome.prototype.destroy.call(this);
}
,addWindowInfoLines: function() {
var _gthis = this;
buildings_WorkWithHome.prototype.addWindowInfoLines.call(this);
this.city.gui.windowInner.addChild(new gui_GUISpacing(this.city.gui.window,new common_Point(4,4)));
this.city.gui.windowAddInfoText(null,function() {
return _gthis.missionGetTitle();
},"Arial15");
this.city.gui.windowAddInfoText(null,function() {
return _gthis.missionGetText();
});
}
,missionGetTitle: function() {
if(this.currentMission == 11) {
return "Thank You";
}
return "Current Task";
}
,missionGetText: function() {
if(this.currentMission == 11) {
return "We'll keep on hacking!";
}
if(this.workers.length != this.get_jobs()) {
return "Gather the Hackers:\nMake sure all 6 jobs are filled.";
}
switch(this.currentMission) {
case 0:
return "Collect the Knowledge:\nBuild twenty Labs.";
case 1:
return "Spread the Knowledge:\nBuild three Libraries.";
case 2:
return "House the Smart:\nBuild five Tinkerers' Houses.";
case 3:
return "Factory Hack:\nResearch the Firmware Modding upgrade at a Refined Metals Factory.";
case 4:
return "Try our latest invention:\nBuild a Factory Pub.";
case 5:
return "More of the basics:\nProduce at least 20 computer chips in a day.";
case 6:
return "Mechanical Party:\nBuild seven Scrapyard Nightclubs.";
case 7:
return "Let's have even more fun!\nBuild the Lab Escape Room.";
case 8:
return "Watering Cans Are Overrated:\nResearch Automatic Water Management in a Tree Plantation.";
case 9:
return "Change the Game:\nBuild two Holo Game Halls.";
case 10:
return "Build our Ultimate Invention:\nBuild the Misdirector.";
default:
return "";
}
}
,checkMissionCompletions: function() {
var missionComplete = false;
while(true) {
missionComplete = false;
switch(this.currentMission) {
case 3:
missionComplete = this.city.progress.unlocks.getUnlockState(buildingUpgrades_RefinedMetalsFactoryHack) == progress_UnlockState.Researched;
if(missionComplete) {
this.city.progress.unlocks.unlock(buildings_FactoryPub);
}
break;
case 5:
missionComplete = common_ArrayExtensions.any(this.city.simulation.stats.materialProduction[MaterialsHelper.findMaterialIndex("computerChips")],function(mt) {
return mt >= 20;
});
if(missionComplete) {
this.city.progress.unlocks.unlock(buildings_ScrapyardNightClub);
}
break;
case 8:
missionComplete = this.city.progress.unlocks.getUnlockState(buildingUpgrades_AutomaticWaterManagement) == progress_UnlockState.Researched;
if(missionComplete) {
this.city.progress.unlocks.unlock(buildings_HoloGameHall);
}
break;
default:
}
if(this.timeToCheckBuildings <= 0 && this.currentMission != 3 && this.currentMission != 5 && this.currentMission != 8 && this.currentMission != 11) {
var buildingsByType = this.city.getAmountOfPermanentsPerType();
switch(this.currentMission) {
case 0:
if(buildingsByType.h["buildings.ExperimentationLab"] == null) {
buildingsByType.h["buildings.ExperimentationLab"] = 0;
}
missionComplete = buildingsByType.h["buildings.Laboratory"] + buildingsByType.h["buildings.ExperimentationLab"] >= 20;
if(missionComplete) {
this.city.progress.unlocks.unlock(buildings_Library);
}
break;
case 1:
missionComplete = buildingsByType.h["buildings.Library"] >= 3;
if(missionComplete) {
this.city.progress.unlocks.unlock(buildings_TinkerersHome);
}
break;
case 2:
missionComplete = buildingsByType.h["buildings.TinkerersHome"] >= 5;
if(missionComplete) {
this.city.progress.unlocks.unlock(buildingUpgrades_RefinedMetalsFactoryHack);
}
break;
case 4:
missionComplete = buildingsByType.h["buildings.FactoryPub"] >= 1;
break;
case 6:
missionComplete = buildingsByType.h["buildings.ScrapyardNightClub"] >= 7;
if(missionComplete) {
this.city.progress.unlocks.unlock(buildings_EscapeRoom);
}
break;
case 7:
missionComplete = buildingsByType.h["buildings.EscapeRoom"] >= 1;
if(missionComplete) {
this.city.progress.unlocks.unlock(buildingUpgrades_AutomaticWaterManagement);
}
break;
case 9:
missionComplete = buildingsByType.h["buildings.HoloGameHall"] >= 2;
if(missionComplete) {
this.city.progress.unlocks.unlock(buildings_Misdirector);
}
break;
case 10:
missionComplete = buildingsByType.h["buildings.Misdirector"] >= 1;
break;
}
this.timeToCheckBuildings = 30;
}
if(missionComplete) {
this.currentMission += 1;
this.timeToCheckBuildings = 0;
this.city.progress.goalHelp.updateHasBuildingGoal();
}
if(!missionComplete) {
break;
}
}
}
,update: function(timeMod) {
buildings_WorkWithHome.prototype.update.call(this,timeMod);
this.checkMissionCompletions();
this.timeToCheckBuildings -= timeMod;
if(((this.city.simulation.time.timeSinceStart | 0) / 60 | 0) % 24 >= 0 && ((this.city.simulation.time.timeSinceStart | 0) / 60 | 0) % 24 < 4) {
var val = 4.0 - 4.0 * Math.abs(1.0 - this.city.simulation.time.timeSinceStart / 60 % 24 / 2.0);
this.boltSprite.alpha = val < 0 ? 0 : val > 1 ? 1 : val;
} else {
this.boltSprite.alpha = 0;
}
}
,work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking) {
citizen.currentAction = LifeAction.Nothing;
return;
}
this.doWalkAround(citizen);
}
,walkAround: function(citizen,stepsInBuilding) {
this.doWalkAround(citizen);
}
,doWalkAround: function(citizen) {
if(citizen.relativeY > 5) {
if(random_Random.getInt(4) == 1 && citizen.relativeX > 5) {
citizen.changeFloor();
} else {
citizen.moveAndWait(random_Random.fromArray(buildings_HackerHQ.walkAroundPositions),random_Random.getInt(60,120));
}
} else if(random_Random.getInt(4) == 1) {
citizen.changeFloor();
} else if(random_Random.getInt(3) == 1) {
citizen.moveAndWait(random_Random.getInt(5,7),random_Random.getInt(90,150),null,false,false);
} else {
citizen.moveAndWait(random_Random.getInt(9,15),random_Random.getInt(60,150),null,false,false);
}
}
,getGlobalGoal: function() {
if(this.currentMission == 11) {
return null;
}
return { category : "Hackers Mission", text : this.missionGetText()};
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_WorkWithHome.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_HackerHQ.saveDefinition);
}
var value = this.lastEventDoneOnDay;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.doingEvent;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.eventPhase;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.currentMission;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
,load: function(queue,definition) {
buildings_WorkWithHome.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"lastEventDoneOnDay")) {
this.lastEventDoneOnDay = loadMap.h["lastEventDoneOnDay"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"doingEvent")) {
this.doingEvent = loadMap.h["doingEvent"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"eventPhase")) {
this.eventPhase = loadMap.h["eventPhase"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"currentMission")) {
this.currentMission = loadMap.h["currentMission"];
}
}
,__class__: buildings_HackerHQ
});
var buildings_IMedicalBuilding = function() { };
$hxClasses["buildings.IMedicalBuilding"] = buildings_IMedicalBuilding;
buildings_IMedicalBuilding.__name__ = "buildings.IMedicalBuilding";
buildings_IMedicalBuilding.__isInterface__ = true;
buildings_IMedicalBuilding.prototype = {
__class__: buildings_IMedicalBuilding
};
var buildings_HerbGarden = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.herbSprite = null;
this.currentTexture = 0;
this.herbCapPerWorker = 50;
this.herbTextures = Resources.getTexturesByWidth(this.get_myHerbTextures(),20);
this.currentTexture = random_Random.getInt(this.herbTextures.length / 2 | 0) * 2;
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.drawer.changeTextureGroup("spr_restaurant");
this.herbSprite = new PIXI.Sprite(this.herbTextures[this.currentTexture]);
this.herbSprite.position.set(position.x,position.y);
bgStage.cacheableChildren.push(this.herbSprite);
bgStage.isInvalid = true;
};
$hxClasses["buildings.HerbGarden"] = buildings_HerbGarden;
buildings_HerbGarden.__name__ = "buildings.HerbGarden";
buildings_HerbGarden.__interfaces__ = [buildings_IMedicalBuilding];
buildings_HerbGarden.__super__ = buildings_Work;
buildings_HerbGarden.prototype = $extend(buildings_Work.prototype,{
get_drawerType: function() {
return buildings_buildingDrawers_AutoMergingBuildingDrawerDifferentForType;
}
,get_possibleBuildingModes: function() {
return [buildingUpgrades_CulinaryHerbs,buildingUpgrades_MedicalHerbs];
}
,get_medicalQuality: function() {
return 100;
}
,get_medicalCapacity: function() {
if(((this.buildingMode) instanceof buildingUpgrades_MedicalHerbs)) {
return 100;
} else {
return 0;
}
}
,get_medicalTypeLimit: function() {
return 0.2;
}
,get_medicalTypeID: function() {
return 1;
}
,get_myHerbTextures: function() {
return "spr_herbgarden_plants";
}
,postLoad: function() {
this.herbSprite.texture = this.herbTextures[this.currentTexture];
this.bgStage.isInvalid = true;
}
,work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking) {
citizen.currentAction = LifeAction.Nothing;
return;
}
if(citizen.relativeY < 5 && this.workers.indexOf(citizen) == 1) {
citizen.changeFloor();
return;
}
var modifyWithHappiness = false;
var slowMove = true;
if(slowMove == null) {
slowMove = false;
}
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
citizen.moveAndWait(random_Random.getInt(3,16),random_Random.getInt(30,60),null,modifyWithHappiness,slowMove);
}
,getHerbCapacity: function() {
return this.herbCapPerWorker * this.workers.length;
}
,positionSprites: function() {
buildings_Work.prototype.positionSprites.call(this);
if(this.herbSprite != null) {
this.herbSprite.position.set(this.position.x,this.position.y);
this.bgStage.isInvalid = true;
}
}
,changePlantsTexture: function(tex) {
this.currentTexture = tex;
if(this.herbSprite != null) {
this.herbSprite.texture = this.herbTextures[this.currentTexture];
this.bgStage.isInvalid = true;
}
}
,destroy: function() {
buildings_Work.prototype.destroy.call(this);
var _this = this.bgStage;
var child = this.herbSprite;
HxOverrides.remove(_this.cacheableChildren,child);
_this.isInvalid = true;
if(child.parent != null) {
child.parent.removeChild(child);
}
}
,addWindowInfoLines: function() {
var _gthis = this;
buildings_Work.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
return "Herbs reduce your citizens' food consumption by " + Math.round(_gthis.city.simulation.eating.currentFoodSaveByHerbsPct * 0.2 * 100) + "/" + 20 + "%" + "\n" + ("Total medical happiness from herb gardens: " + Math.round(100 * (_gthis.city.simulation.happiness.healthCapacityByType[1] / _gthis.city.simulation.citizens.length)) + "/20%");
});
}
,createWindowAddBottomButtons: function() {
var _gthis = this;
gui_windowParts_CycleValueButton.create(this.city.gui,function() {
return _gthis.currentTexture;
},$bind(this,this.changePlantsTexture),function() {
return _gthis.herbTextures.length;
},"Change Herb Plants",null,2);
buildings_Work.prototype.createWindowAddBottomButtons.call(this);
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Work.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_HerbGarden.saveDefinition);
}
var value = this.currentTexture;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
,load: function(queue,definition) {
buildings_Work.prototype.load.call(this,queue);
if(queue.version < 32) {
return;
}
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"currentTexture")) {
this.currentTexture = loadMap.h["currentTexture"];
}
this.postLoad();
}
,__class__: buildings_HerbGarden
});
var buildings_HighTechNightClub = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.lowestNightClub = null;
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.positionSprites();
this.startTime = 20;
this.endTime = 7.5;
this.workTimePreferenceMod = 0.5;
this.isEntertainment = true;
if(buildings_HighTechNightClub.citizenClothesTexture == null) {
buildings_HighTechNightClub.citizenClothesTexture = Resources.getTexture("spr_tech_nightclub_hoverer");
}
this.lowestNightClub = this;
};
$hxClasses["buildings.HighTechNightClub"] = buildings_HighTechNightClub;
buildings_HighTechNightClub.__name__ = "buildings.HighTechNightClub";
buildings_HighTechNightClub.__interfaces__ = [buildings_IEntertainmentBuilding];
buildings_HighTechNightClub.__super__ = buildings_Work;
buildings_HighTechNightClub.prototype = $extend(buildings_Work.prototype,{
get_baseEntertainmentCapacity: function() {
return this.workers.length * 100;
}
,get_isOpen: function() {
if((this.bottomBuilding == null || !this.bottomBuilding.is(buildings_HighTechNightClub)) && this.workers.length == 1 && this.workers[0].currentAction == LifeAction.Work) {
var this1 = this.city.simulation.time.timeSinceStart / 60 % 24;
var start = this.startTime - this.workTimePreferenceMod;
if(start < 6) {
if(this1 >= start) {
return this1 < 6;
} else {
return false;
}
} else if(!(this1 >= start)) {
return this1 < 6;
} else {
return true;
}
} else {
return false;
}
}
,get_entertainmentType: function() {
return 0;
}
,get_minimumNormalTimeToSpend: function() {
return 5;
}
,get_maximumNormalTimeToSpend: function() {
return 7;
}
,get_minimumEntertainmentGroupSatisfy: function() {
return 1;
}
,get_maximumEntertainmentGroupSatisfy: function() {
return 3;
}
,get_entertainmentQuality: function() {
return 100;
}
,get_isOpenForExistingVisitors: function() {
var this1 = this.city.simulation.time.timeSinceStart / 60 % 24;
var start = this.startTime - this.workTimePreferenceMod;
if(start < 6) {
if(this1 >= start) {
return this1 < 6;
} else {
return false;
}
} else if(!(this1 >= start)) {
return this1 < 6;
} else {
return true;
}
}
,get_drawerType: function() {
return buildings_buildingDrawers_AllDirMergingBuildingDrawer;
}
,get_mergingDrawer: function() {
return this.drawer;
}
,get_walkThroughCanViewSelfInThisBuilding: function() {
if(this.bottomBuilding != null) {
return !this.bottomBuilding.is(buildings_HighTechNightClub);
} else {
return true;
}
}
,get_hasLeftNightClub: function() {
if(this.leftBuilding != null) {
return this.leftBuilding.is(buildings_HighTechNightClub);
} else {
return false;
}
}
,get_hasRightNightClub: function() {
if(this.rightBuilding != null) {
return this.rightBuilding.is(buildings_HighTechNightClub);
} else {
return false;
}
}
,get_hasTopNightClub: function() {
if(this.topBuilding != null) {
return this.topBuilding.is(buildings_HighTechNightClub);
} else {
return false;
}
}
,get_hasBottomNightClub: function() {
if(this.bottomBuilding != null) {
return this.bottomBuilding.is(buildings_HighTechNightClub);
} else {
return false;
}
}
,get_firstBuildingToGoTo: function() {
return this.lowestNightClub;
}
,postCreate: function() {
buildings_Work.prototype.postCreate.call(this);
this.updateLowestNightClub();
}
,onCityChange: function() {
this.updateLowestNightClub();
}
,updateLowestNightClub: function() {
this.lowestNightClub = this;
while(this.lowestNightClub.get_hasBottomNightClub()) this.lowestNightClub = this.lowestNightClub.bottomBuilding;
}
,onCitizenLeave: function(citizen,newPermanent) {
if(newPermanent != null && !newPermanent.is(buildings_HighTechNightClub)) {
if(citizen.accessorySprite != null) {
citizen.accessorySprite.destroy();
citizen.accessorySprite = null;
}
}
}
,beEntertained: function(citizen,timeMod) {
if(citizen.accessorySprite == null) {
var spd = citizen.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
var tmp;
if(Math.abs(9 - citizen.relativeX) < spd) {
citizen.relativeX = 9;
tmp = true;
} else {
var num = 9 - citizen.relativeX;
citizen.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
tmp = false;
}
if(tmp) {
citizen.setRelativeY(citizen.relativeY + timeMod / 2);
if(citizen.relativeY >= 4) {
citizen.accessorySprite = new PIXI.Sprite(buildings_HighTechNightClub.citizenClothesTexture);
citizen.accessorySprite.anchor.set(0,0);
citizen.accessorySprite.position.set(-1,-1);
citizen.sprite.addChild(citizen.accessorySprite);
citizen.setRelativeY(4);
citizen.addToWithAccessoryStage();
}
} else {
citizen.setRelativeY(0);
}
citizen.dynamicUnsavedVars.xMoveLeft = 0.0;
citizen.dynamicUnsavedVars.yMoveLeft = 0.0;
citizen.dynamicUnsavedVars.waitTime = 0.0;
return;
}
var hasLeftBuildingOfSameType = this.get_hasLeftNightClub();
var leftBuilding = this.leftBuilding;
var hasRightBuildingOfSameType = this.get_hasRightNightClub();
var rightBuilding = this.rightBuilding;
var hasTopBuildingOfSameType = this.get_hasTopNightClub();
var topBuilding = this.topBuilding;
var hasBottomBuildingOfSameType = this.get_hasBottomNightClub();
var bottomBuilding = this.bottomBuilding;
if(Math.abs(citizen.dynamicUnsavedVars.xMoveLeft) > 0) {
var num = citizen.dynamicUnsavedVars.xMoveLeft;
var xMoveNowSign = num > 0 ? 1 : num < 0 ? -1 : 0;
var xMoveNow = timeMod * xMoveNowSign;
if(xMoveNowSign * xMoveNow > xMoveNowSign * citizen.dynamicUnsavedVars.xMoveLeft) {
citizen.setRelativeX(citizen.relativeX + citizen.dynamicUnsavedVars.xMoveLeft);
citizen.dynamicUnsavedVars.xMoveLeft = 0;
} else {
citizen.setRelativeX(citizen.relativeX + xMoveNow);
citizen.dynamicUnsavedVars.xMoveLeft -= xMoveNow;
}
if(xMoveNowSign > 0 && citizen.relativeX > 20) {
if(hasRightBuildingOfSameType) {
citizen.inPermanent = rightBuilding;
citizen.setRelativeX(citizen.relativeX - 20);
} else {
citizen.dynamicUnsavedVars.xMoveLeft = 0;
}
}
if(xMoveNowSign < 0 && citizen.relativeX < 0) {
if(hasLeftBuildingOfSameType) {
citizen.setRelativeX(citizen.relativeX + 20);
citizen.inPermanent = leftBuilding;
} else {
citizen.dynamicUnsavedVars.xMoveLeft = 0;
}
}
}
if(Math.abs(citizen.dynamicUnsavedVars.yMoveLeft) > 0) {
var num = citizen.dynamicUnsavedVars.yMoveLeft;
var yMoveNowSign = num > 0 ? 1 : num < 0 ? -1 : 0;
var yMoveNow = timeMod * yMoveNowSign;
if(yMoveNowSign * yMoveNow > yMoveNowSign * citizen.dynamicUnsavedVars.yMoveLeft) {
citizen.setRelativeY(citizen.relativeY + citizen.dynamicUnsavedVars.yMoveLeft);
citizen.dynamicUnsavedVars.yMoveLeft = 0;
} else {
citizen.setRelativeY(citizen.relativeY + yMoveNow);
citizen.dynamicUnsavedVars.yMoveLeft -= yMoveNow;
}
if(yMoveNowSign > 0 && citizen.relativeY > 20) {
if(hasTopBuildingOfSameType) {
citizen.inPermanent = topBuilding;
citizen.setRelativeY(citizen.relativeY - 20);
} else {
citizen.dynamicUnsavedVars.yMoveLeft = 0;
}
}
if(yMoveNowSign < 0 && citizen.relativeY < 0) {
if(hasBottomBuildingOfSameType) {
citizen.setRelativeY(citizen.relativeY + 20);
citizen.inPermanent = bottomBuilding;
} else {
citizen.dynamicUnsavedVars.yMoveLeft = 0;
}
}
}
if(citizen.dynamicUnsavedVars.yMoveLeft == 0 && citizen.dynamicUnsavedVars.xMoveLeft == 0) {
if(citizen.dynamicUnsavedVars.waitTime < 1) {
citizen.dynamicUnsavedVars.waitTime += timeMod;
return;
}
citizen.dynamicUnsavedVars.waitTime = 0.0;
var r = random_Random.getInt(2);
if(r == 0) {
var remainingTop = 20 - citizen.relativeY - citizen.actualSpriteHeight - 4;
if(this.get_hasTopNightClub() && (this.topBuilding.get_hasLeftNightClub() || citizen.relativeX >= 4) && (this.topBuilding.get_hasRightNightClub() || citizen.relativeX <= 14)) {
remainingTop += 20;
}
var remainingBottom = 0.0;
if(remainingTop < 10 || random_Random.getInt(2) == 0) {
remainingBottom = citizen.relativeY - 4;
if(this.get_hasBottomNightClub() && (this.bottomBuilding.get_hasLeftNightClub() || citizen.relativeX >= 4) && (this.bottomBuilding.get_hasRightNightClub() || citizen.relativeX <= 14)) {
remainingBottom += 20;
}
}
citizen.dynamicUnsavedVars.yMoveLeft = random_Random.getFloat(-remainingBottom,remainingTop);
} else if(r == 1) {
var remainingRight = 20 - citizen.relativeX - 2 - 4;
if(this.get_hasRightNightClub() && (this.rightBuilding.get_hasBottomNightClub() || citizen.relativeY > 2) && (this.rightBuilding.get_hasTopNightClub() || citizen.relativeY < 20 - citizen.actualSpriteHeight - 4)) {
remainingRight += 20;
}
var remainingLeft = citizen.relativeX - 4;
if(this.get_hasLeftNightClub() && (this.leftBuilding.get_hasBottomNightClub() || citizen.relativeY > 2) && (this.leftBuilding.get_hasTopNightClub() || citizen.relativeY < 20 - citizen.actualSpriteHeight - 4)) {
remainingLeft += 20;
}
citizen.dynamicUnsavedVars.xMoveLeft = random_Random.getFloat(-remainingLeft,remainingRight);
}
}
}
,work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking && this.city.simulation.time.timeSinceStart / 60 % 24 > 6) {
if(!citizen.inPermanent.is(buildings_HighTechNightClub)) {
citizen.setRelativeY(0);
if(citizen.accessorySprite != null) {
citizen.accessorySprite.destroy();
citizen.accessorySprite = null;
}
citizen.currentAction = LifeAction.Nothing;
return;
}
if(citizen.inPermanent.exitBuilding(citizen,timeMod)) {
citizen.currentAction = LifeAction.Nothing;
}
return;
}
if(citizen.inPermanent != this) {
if(!citizen.inPermanent.is(buildings_HighTechNightClub) || !citizen.inPermanent.get_hasTopNightClub()) {
return;
}
}
}
,createWindowAddBottomButtons: function() {
buildings_Work.prototype.createWindowAddBottomButtons.call(this);
}
,exitBuilding: function(citizen,timeMod) {
if(citizen.accessorySprite == null && citizen.relativeY <= 0) {
return true;
}
var tmp;
if(citizen.relativeX < 3) {
var spd = citizen.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
var tmp1;
if(Math.abs(3 - citizen.relativeX) < spd) {
citizen.relativeX = 3;
tmp1 = true;
} else {
var num = 3 - citizen.relativeX;
citizen.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
tmp1 = false;
}
tmp = !tmp1;
} else {
tmp = false;
}
if(tmp) {
return false;
}
var tmp;
if(citizen.relativeX > 16) {
var spd = citizen.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
var tmp1;
if(Math.abs(16 - citizen.relativeX) < spd) {
citizen.relativeX = 16;
tmp1 = true;
} else {
var num = 16 - citizen.relativeX;
citizen.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
tmp1 = false;
}
tmp = !tmp1;
} else {
tmp = false;
}
if(tmp) {
return false;
}
var hasLeftBuildingOfSameType = this.get_hasLeftNightClub();
var leftBuilding = this.leftBuilding;
var hasRightBuildingOfSameType = this.get_hasRightNightClub();
var rightBuilding = this.rightBuilding;
var hasTopBuildingOfSameType = this.get_hasTopNightClub();
var topBuilding = this.topBuilding;
var hasBottomBuildingOfSameType = this.get_hasBottomNightClub();
var bottomBuilding = this.bottomBuilding;
if(Math.abs(citizen.dynamicUnsavedVars.xMoveLeft) > 0) {
var num = citizen.dynamicUnsavedVars.xMoveLeft;
var xMoveNowSign = num > 0 ? 1 : num < 0 ? -1 : 0;
var xMoveNow = timeMod * xMoveNowSign;
if(xMoveNowSign * xMoveNow > xMoveNowSign * citizen.dynamicUnsavedVars.xMoveLeft) {
citizen.setRelativeX(citizen.relativeX + citizen.dynamicUnsavedVars.xMoveLeft);
citizen.dynamicUnsavedVars.xMoveLeft = 0;
} else {
citizen.setRelativeX(citizen.relativeX + xMoveNow);
citizen.dynamicUnsavedVars.xMoveLeft -= xMoveNow;
}
if(xMoveNowSign > 0 && citizen.relativeX > 20) {
if(hasRightBuildingOfSameType) {
citizen.inPermanent = rightBuilding;
citizen.setRelativeX(citizen.relativeX - 20);
} else {
citizen.dynamicUnsavedVars.xMoveLeft = 0;
}
}
if(xMoveNowSign < 0 && citizen.relativeX < 0) {
if(hasLeftBuildingOfSameType) {
citizen.setRelativeX(citizen.relativeX + 20);
citizen.inPermanent = leftBuilding;
} else {
citizen.dynamicUnsavedVars.xMoveLeft = 0;
}
}
}
if(Math.abs(citizen.dynamicUnsavedVars.yMoveLeft) > 0) {
var num = citizen.dynamicUnsavedVars.yMoveLeft;
var yMoveNowSign = num > 0 ? 1 : num < 0 ? -1 : 0;
var yMoveNow = timeMod * yMoveNowSign;
if(yMoveNowSign * yMoveNow > yMoveNowSign * citizen.dynamicUnsavedVars.yMoveLeft) {
citizen.setRelativeY(citizen.relativeY + citizen.dynamicUnsavedVars.yMoveLeft);
citizen.dynamicUnsavedVars.yMoveLeft = 0;
} else {
citizen.setRelativeY(citizen.relativeY + yMoveNow);
citizen.dynamicUnsavedVars.yMoveLeft -= yMoveNow;
}
if(yMoveNowSign > 0 && citizen.relativeY > 20) {
if(hasTopBuildingOfSameType) {
citizen.inPermanent = topBuilding;
citizen.setRelativeY(citizen.relativeY - 20);
} else {
citizen.dynamicUnsavedVars.yMoveLeft = 0;
}
}
if(yMoveNowSign < 0 && citizen.relativeY < 0) {
if(hasBottomBuildingOfSameType) {
citizen.setRelativeY(citizen.relativeY + 20);
citizen.inPermanent = bottomBuilding;
} else {
citizen.dynamicUnsavedVars.yMoveLeft = 0;
}
}
}
if(this.get_hasBottomNightClub()) {
citizen.dynamicUnsavedVars.yMoveLeft = -citizen.relativeY - 15;
return false;
} else if(citizen.relativeY > 4) {
citizen.dynamicUnsavedVars.yMoveLeft = -citizen.relativeY + 4;
return false;
}
citizen.dynamicUnsavedVars.yMoveLeft = 0;
citizen.dynamicUnsavedVars.xMoveLeft = 0;
var spd = citizen.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
var tmp;
if(Math.abs(9 - citizen.relativeX) < spd) {
citizen.relativeX = 9;
tmp = true;
} else {
var num = 9 - citizen.relativeX;
citizen.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
tmp = false;
}
if(!tmp) {
return false;
}
if(citizen.accessorySprite != null) {
citizen.accessorySprite.destroy();
citizen.accessorySprite = null;
}
if(citizen.relativeY > 0) {
citizen.setRelativeY(Math.max(citizen.relativeY - timeMod * 0.5,0));
return false;
}
return true;
}
,finishEntertainment: function(citizen,timeMod) {
return this.exitBuilding(citizen,timeMod);
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Work.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_HighTechNightClub.saveDefinition);
}
}
,load: function(queue,definition) {
buildings_Work.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
}
,__class__: buildings_HighTechNightClub
});
var buildings_HoloGameHall = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.boostTeam2 = 0;
this.boostTeam1 = 0;
this.progressTeam2 = 0;
this.progressTeam1 = 0;
this.hasAtLeastOneVisitor = false;
this.totalWidth = 18;
this.coordinatorBuilding = null;
this.gameInited = false;
this.boosters = [];
this.monsterSpriteTeam2 = null;
this.monsterSpriteTeam1 = null;
this.currentGameType = null;
Building.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.isEntertainment = true;
this.currentGameType = 0;
if(buildings_HoloGameHall.citizenClothesTexture == null) {
buildings_HoloGameHall.citizenClothesTexture = Resources.getTexture("spr_hgh_citizenclothes_1");
}
var _g = [];
_g.push([]);
_g.push([]);
_g.push([]);
_g.push([]);
_g.push([]);
this.blocks = _g;
};
$hxClasses["buildings.HoloGameHall"] = buildings_HoloGameHall;
buildings_HoloGameHall.__name__ = "buildings.HoloGameHall";
buildings_HoloGameHall.__interfaces__ = [buildings_IEntertainmentBuilding];
buildings_HoloGameHall.__super__ = Building;
buildings_HoloGameHall.prototype = $extend(Building.prototype,{
get_baseEntertainmentCapacity: function() {
return 75;
}
,get_isOpen: function() {
var this1 = this.city.simulation.time.timeSinceStart / 60 % 24;
if(!(this1 >= 12)) {
return this1 < 2;
} else {
return true;
}
}
,get_entertainmentType: function() {
return 4;
}
,get_minimumNormalTimeToSpend: function() {
return 4;
}
,get_maximumNormalTimeToSpend: function() {
return 5;
}
,get_minimumEntertainmentGroupSatisfy: function() {
return 2;
}
,get_maximumEntertainmentGroupSatisfy: function() {
return 5;
}
,get_entertainmentQuality: function() {
return 100;
}
,get_isOpenForExistingVisitors: function() {
return this.get_isOpen();
}
,finishEntertainment: function(citizen,timeMod) {
return true;
}
,get_drawerType: function() {
return buildings_buildingDrawers_AutoMergingBuildingDrawer;
}
,get_hasLeftHoloGameHall: function() {
if(this.leftBuilding != null) {
return this.leftBuilding.is(buildings_HoloGameHall);
} else {
return false;
}
}
,get_hasRightHoloGameHall: function() {
if(this.rightBuilding != null) {
return this.rightBuilding.is(buildings_HoloGameHall);
} else {
return false;
}
}
,postCreate: function() {
Building.prototype.postCreate.call(this);
this.positionSprites();
this.calculateCoordinatorBuilding();
this.setGameType();
}
,onCityChange: function() {
this.calculateCoordinatorBuilding();
if(!this.get_hasRightHoloGameHall()) {
var _g = 0;
var _g1 = this.blocks[4];
while(_g < _g1.length) {
var block = _g1[_g];
++_g;
block.sprite.destroy();
}
this.blocks[4] = [];
}
}
,calculateCoordinatorBuilding: function() {
var prevCoordinatorBuilding = this.coordinatorBuilding;
this.coordinatorBuilding = this;
while(this.coordinatorBuilding.get_hasLeftHoloGameHall()) this.coordinatorBuilding = this.coordinatorBuilding.leftBuilding;
if(this.coordinatorBuilding == this) {
this.totalWidth = 18;
var currentlyHandling = this;
while(currentlyHandling.get_hasRightHoloGameHall()) {
this.totalWidth += 20;
currentlyHandling = currentlyHandling.rightBuilding;
}
if(prevCoordinatorBuilding != this) {
this.resetSpaceShipGame();
}
}
if(!this.get_hasLeftHoloGameHall() && !this.get_hasRightHoloGameHall() && this.currentGameType == 0) {
this.currentGameType = 1;
this.destroyHGHSprites();
this.boosters = [];
}
if(this.currentGameType != this.coordinatorBuilding.currentGameType) {
this.destroyHGHSprites();
this.currentGameType = this.coordinatorBuilding.currentGameType;
} else if(prevCoordinatorBuilding != this.coordinatorBuilding && this.coordinatorBuilding != this && this.currentGameType == 0) {
this.destroyHGHSprites();
}
}
,destroy: function() {
Building.prototype.destroy.call(this);
this.destroyHGHSprites();
}
,destroyHGHSprites: function() {
if(this.monsterSpriteTeam1 != null) {
this.monsterSpriteTeam1.destroy();
this.monsterSpriteTeam1 = null;
}
if(this.monsterSpriteTeam2 != null) {
this.monsterSpriteTeam2.destroy();
this.monsterSpriteTeam2 = null;
}
var _g = 0;
var _g1 = this.boosters;
while(_g < _g1.length) {
var booster = _g1[_g];
++_g;
if(booster.sprite != null) {
booster.sprite.destroy();
}
}
this.boosters = [];
var _g = 0;
var _g1 = this.blocks;
while(_g < _g1.length) {
var theseBlocks = _g1[_g];
++_g;
var _g2 = 0;
while(_g2 < theseBlocks.length) {
var block = theseBlocks[_g2];
++_g2;
block.sprite.destroy();
}
}
var _g = [];
_g.push([]);
_g.push([]);
_g.push([]);
_g.push([]);
_g.push([]);
this.blocks = _g;
}
,beEntertained: function(citizen,timeMod) {
switch(this.coordinatorBuilding.currentGameType) {
case 0:
this.beEntertainedSpaceShipBattle(citizen,timeMod);
break;
case 1:
this.beEntertainedBlockGame(citizen,timeMod);
break;
}
this.currentGameType = this.coordinatorBuilding.currentGameType;
}
,beEntertainedBlockGame: function(citizen,timeMod) {
var _gthis = this;
var xToGo = random_Random.getInt(4 + (this.get_hasRightHoloGameHall() ? 1 : 0));
var r = random_Random.getInt(6);
if(this.get_hasLeftHoloGameHall() && r == 0) {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[4].length > 0 ? pool[4].splice(pool[4].length - 1,1)[0] : new Int32Array(4);
arr[0] = 2;
arr[1] = 0;
arr[2] = 4;
arr[3] = 19;
citizen1.setPathWithEnd(arr,0,4,function() {
citizen.hasBuildingInited = true;
},true);
} else if(this.get_hasRightHoloGameHall() && r == 1) {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[4].length > 0 ? pool[4].splice(pool[4].length - 1,1)[0] : new Int32Array(4);
arr[0] = 3;
arr[1] = 0;
arr[2] = 4;
arr[3] = 0;
citizen1.setPathWithEnd(arr,0,4,function() {
citizen.hasBuildingInited = true;
},true);
} else {
citizen.moveAndWait(3 + xToGo * 4,random_Random.getInt(45,90),function() {
if(_gthis.coordinatorBuilding.currentGameType != 1 || xToGo == 4 && !_gthis.get_hasRightHoloGameHall()) {
return;
}
if(_gthis.blocks[xToGo].length == 0 || _gthis.blocks[xToGo][_gthis.blocks[xToGo].length - 1].sprite.alpha >= 1) {
if(_gthis.blocks[xToGo].length < 4) {
_gthis.gameInited = true;
var newBlockSprite = new PIXI.Sprite(Resources.getTexture("spr_hgh_block"));
_gthis.bgStage.addChild(newBlockSprite);
var this1 = [random_Random.getFloat(360),1,1];
var col = this1;
_gthis.blocks[xToGo].push({ sprite : newBlockSprite, color : col});
newBlockSprite.alpha = 0.1;
newBlockSprite.tint = common_ColorExtensions.toHexInt(thx_color_Hsv.toRgb(col));
newBlockSprite.position.set(_gthis.position.x + 2 + xToGo * 4,_gthis.position.y + 20 - 1 - 4 * _gthis.blocks[xToGo].length);
} else {
var blockToChange = random_Random.fromArray(_gthis.blocks[xToGo]);
var this1 = [(blockToChange.color[0] + 5) % 360,1,1];
blockToChange.color = this1;
var tmp = thx_color_Hsv.toRgb(blockToChange.color);
blockToChange.sprite.tint = common_ColorExtensions.toHexInt(tmp);
}
} else {
var lastBlock = _gthis.blocks[xToGo][_gthis.blocks[xToGo].length - 1].sprite;
lastBlock.alpha = Math.min(lastBlock.alpha + 0.1,1);
}
});
}
}
,beEntertainedSpaceShipBattle: function(citizen,timeMod) {
if(!citizen.hasBuildingInited || citizen.dynamicUnsavedVars.buildingInited == null) {
citizen.dynamicUnsavedVars.hghTeam = random_Random.getInt(2);
citizen.dynamicUnsavedVars.hghStarted = false;
citizen.hasBuildingInited = true;
citizen.dynamicUnsavedVars.focussingOnBoosters = random_Random.fromArray([false,false,true]);
citizen.dynamicUnsavedVars.focussingOnBooster = random_Random.getInt(2);
citizen.dynamicUnsavedVars.buildingInited = true;
}
if(!citizen.dynamicUnsavedVars.hghStarted) {
var pleaseInit = false;
if(citizen.dynamicUnsavedVars.hghTeam == 0) {
if(this.get_hasLeftHoloGameHall()) {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[4].length > 0 ? pool[4].splice(pool[4].length - 1,1)[0] : new Int32Array(4);
arr[0] = 2;
arr[1] = 0;
arr[2] = 4;
arr[3] = random_Random.getInt(1,19);
citizen1.setPathWithEnd(arr,0,4,function() {
citizen.hasBuildingInited = true;
},true);
} else if(citizen.relativeX > 1) {
citizen.setRelativeX(Math.max(1,citizen.relativeX - timeMod));
} else {
citizen.setRelativeX(1);
pleaseInit = true;
}
} else if(this.get_hasRightHoloGameHall()) {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[4].length > 0 ? pool[4].splice(pool[4].length - 1,1)[0] : new Int32Array(4);
arr[0] = 3;
arr[1] = 0;
arr[2] = 4;
arr[3] = random_Random.getInt(0,17);
citizen1.setPathWithEnd(arr,0,4,function() {
citizen.hasBuildingInited = true;
},true);
} else if(citizen.relativeX < 17) {
citizen.setRelativeX(Math.min(17,citizen.relativeX + timeMod));
} else {
citizen.setRelativeX(17);
pleaseInit = true;
}
if(pleaseInit) {
citizen.dynamicUnsavedVars.hghStarted = true;
this.coordinatorBuilding.hasAtLeastOneVisitor = true;
if(citizen.accessorySprite == null) {
citizen.accessorySprite = new PIXI.Sprite(buildings_HoloGameHall.citizenClothesTexture);
citizen.accessorySprite.anchor.set(0,1);
citizen.accessorySprite.alpha = 0.5;
if(citizen.actualSpriteHeight == 4) {
citizen.accessorySprite.position.set(0,1);
}
citizen.sprite.addChild(citizen.accessorySprite);
citizen.addToWithAccessoryStage();
if(citizen.dynamicUnsavedVars.hghTeam == 0) {
citizen.accessorySprite.tint = 16711680;
} else {
citizen.accessorySprite.tint = 255;
}
}
}
} else {
var totalRemWidth = this.coordinatorBuilding.totalWidth - buildings_HoloGameHall.monsterSize * 2;
var theBoosters = this.coordinatorBuilding.boosters;
if(!citizen.dynamicUnsavedVars.focussingOnBoosters && theBoosters.length > 0 && random_Random.getFloat(90) < timeMod) {
citizen.dynamicUnsavedVars.focussingOnBoosters = true;
citizen.dynamicUnsavedVars.focussingOnBooster = random_Random.getInt(theBoosters.length);
}
if(citizen.dynamicUnsavedVars.focussingOnBoosters) {
if(theBoosters.length <= citizen.dynamicUnsavedVars.focussingOnBooster) {
citizen.dynamicUnsavedVars.focussingOnBoosters = false;
} else {
var thisBooster = theBoosters[citizen.dynamicUnsavedVars.focussingOnBooster];
var thisBoosterPos = this.coordinatorBuilding.position.x + thisBooster.xPos;
if((citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null).position.x + citizen.relativeX > thisBoosterPos && (citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null).position.x + citizen.relativeX < thisBoosterPos + buildings_HoloGameHall.boosterSpriteSize) {
if(citizen.dynamicUnsavedVars.hghTeam == 0) {
thisBooster.team1Ownership++;
} else {
thisBooster.team2Ownership++;
}
if(random_Random.getFloat(40) < timeMod) {
citizen.dynamicUnsavedVars.focussingOnBoosters = false;
}
} else {
citizen.moveTowardsRandomInWorldCoords(thisBoosterPos,thisBoosterPos + buildings_HoloGameHall.boosterSpriteSize - 1,function() {
citizen.hasBuildingInited = true;
});
}
}
}
if(!citizen.dynamicUnsavedVars.focussingOnBoosters) {
if(citizen.dynamicUnsavedVars.hghTeam == 0) {
var currentTeam1Pos = this.coordinatorBuilding.position.x + 1 + Math.floor(this.coordinatorBuilding.progressTeam1 * totalRemWidth);
if((citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null).position.x + citizen.relativeX > currentTeam1Pos && (citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null).position.x + citizen.relativeX < currentTeam1Pos + buildings_HoloGameHall.monsterSize - 1 && random_Random.getFloat(30) > timeMod) {
this.coordinatorBuilding.progressTeam1 = Math.min(this.coordinatorBuilding.progressTeam1 + timeMod / (totalRemWidth * (10 + (20 - this.boostTeam1) * this.coordinatorBuilding.progressTeam1)),1);
if(this.coordinatorBuilding.progressTeam1 + this.coordinatorBuilding.progressTeam2 > 1) {
this.coordinatorBuilding.progressTeam2 = 1 - this.coordinatorBuilding.progressTeam1;
}
} else {
citizen.moveTowardsRandomInWorldCoords(currentTeam1Pos,currentTeam1Pos + buildings_HoloGameHall.monsterSize - 1,function() {
citizen.hasBuildingInited = true;
});
}
} else {
var currentTeam2Pos = this.coordinatorBuilding.position.x + this.coordinatorBuilding.totalWidth - buildings_HoloGameHall.monsterSize + 1 - Math.floor(this.coordinatorBuilding.progressTeam2 * totalRemWidth);
if((citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null).position.x + citizen.relativeX > currentTeam2Pos && (citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null).position.x + citizen.relativeX < currentTeam2Pos + buildings_HoloGameHall.monsterSize - 1 && random_Random.getFloat(30) > timeMod) {
this.coordinatorBuilding.progressTeam2 = Math.min(this.coordinatorBuilding.progressTeam2 + timeMod / (totalRemWidth * (10 + (20 - this.boostTeam2) * this.coordinatorBuilding.progressTeam2)),1);
if(this.coordinatorBuilding.progressTeam1 + this.coordinatorBuilding.progressTeam2 > 1) {
this.coordinatorBuilding.progressTeam1 = 1 - this.coordinatorBuilding.progressTeam2;
}
} else {
citizen.moveTowardsRandomInWorldCoords(currentTeam2Pos,currentTeam2Pos + buildings_HoloGameHall.monsterSize - 1,function() {
citizen.hasBuildingInited = true;
});
}
}
}
}
}
,onCitizenLeave: function(citizen,newPermanent) {
if(newPermanent == null || !newPermanent.is(buildings_HoloGameHall)) {
if(citizen.accessorySprite != null) {
citizen.accessorySprite.destroy();
citizen.accessorySprite = null;
citizen.addToCorrectStage();
}
}
}
,positionSprites: function() {
Building.prototype.positionSprites.call(this);
if(this.coordinatorBuilding == this) {
this.positionHGHSprites();
}
}
,createWindowAddBottomButtons: function() {
Building.prototype.createWindowAddBottomButtons.call(this);
}
,update: function(timeMod) {
Building.prototype.update.call(this,timeMod);
switch(this.currentGameType) {
case 0:
this.updateSpaceShipGame(timeMod);
break;
case 1:
this.updateBlockGame(timeMod);
break;
}
}
,updateBlockGame: function(timeMod) {
if(!this.get_isOpen()) {
if(this.gameInited && this.city.simulation.time.timeSinceStart / 60 % 24 > 4) {
this.destroyHGHSprites();
this.gameInited = false;
if(this.coordinatorBuilding == this) {
this.setGameType();
}
}
}
}
,updateSpaceShipGame: function(timeMod) {
if(this.coordinatorBuilding == this) {
if(!this.get_isOpen()) {
if(this.gameInited) {
this.stopSpaceShipGame();
}
} else if(this.hasAtLeastOneVisitor) {
this.gameInited = true;
this.boostTeam1 = 0;
this.boostTeam2 = 0;
if(this.monsterSpriteTeam1 == null) {
this.monsterSpriteTeam1 = new PIXI.Sprite(Resources.getTexture("spr_hgh_monster_1"));
this.monsterSpriteTeam1.tint = 16711680;
this.bgStage.addChild(this.monsterSpriteTeam1);
}
if(this.monsterSpriteTeam2 == null) {
this.monsterSpriteTeam2 = new PIXI.Sprite(Resources.getTexture("spr_hgh_monster_1"));
this.monsterSpriteTeam2.scale.set(-1,1);
this.monsterSpriteTeam2.tint = 255;
this.bgStage.addChild(this.monsterSpriteTeam2);
}
var i = this.boosters.length;
while(--i >= 0) {
var booster = this.boosters[i];
if(booster.xPos > this.totalWidth - buildings_HoloGameHall.boosterSpriteSize) {
booster.sprite.destroy();
this.boosters.splice(i,1);
continue;
}
booster.age += timeMod;
if(booster.team1Ownership > booster.team2Ownership) {
booster.sprite.tint = 16711680;
this.boostTeam1 += 11;
} else if(booster.team2Ownership > booster.team1Ownership) {
booster.sprite.tint = 255;
this.boostTeam2 += 11;
}
booster.team1Ownership = 0;
booster.team2Ownership = 0;
if(booster.isFadingOut) {
booster.sprite.alpha -= 0.1 * timeMod;
if(booster.sprite.alpha < 0) {
booster.sprite.destroy();
this.boosters.splice(i,1);
}
} else if(booster.age >= 200 && random_Random.getFloat(50) < timeMod && i == this.boosters.length - 1) {
booster.isFadingOut = true;
} else if(booster.sprite.alpha < 1) {
booster.sprite.alpha = Math.min(1,booster.sprite.alpha + 0.1 * timeMod);
}
}
if(this.boosters.length < 2 && random_Random.getFloat(100) < timeMod) {
var xPos = -1;
var tries = 0;
while(tries < 10) {
xPos = random_Random.getInt(this.totalWidth - buildings_HoloGameHall.boosterSpriteSize);
var failed = false;
var _g = 0;
var _g1 = this.boosters;
while(_g < _g1.length) {
var booster = _g1[_g];
++_g;
if(xPos > booster.xPos - buildings_HoloGameHall.boosterSpriteSize && xPos < booster.xPos + buildings_HoloGameHall.boosterSpriteSize) {
failed = true;
}
}
if(!failed) {
break;
}
++tries;
}
if(tries < 10) {
var spr = new PIXI.Sprite(Resources.getTexture("spr_hgh_booster"));
spr.alpha = 0;
this.bgStage.addChild(spr);
this.boosters.push({ xPos : xPos, team2Ownership : 0, team1Ownership : 0, sprite : spr, isFadingOut : false, age : 0});
}
}
this.positionHGHSprites();
}
}
}
,resetSpaceShipGame: function() {
this.progressTeam1 = 0;
this.progressTeam2 = 0;
this.gameInited = false;
this.destroyHGHSprites();
this.hasAtLeastOneVisitor = false;
this.boosters = [];
}
,stopSpaceShipGame: function() {
this.resetSpaceShipGame();
this.setGameType();
}
,setGameType: function() {
var tmp;
switch(random_Random.getInt(1 + (this.get_hasRightHoloGameHall() || this.get_hasLeftHoloGameHall() ? 1 : 0))) {
case 0:
tmp = 1;
break;
case 1:
tmp = 0;
break;
default:
tmp = 1;
}
this.currentGameType = tmp;
}
,positionHGHSprites: function() {
var totalRemWidth = this.totalWidth - buildings_HoloGameHall.monsterSize * 2;
if(this.monsterSpriteTeam1 != null) {
this.monsterSpriteTeam1.position.set(this.position.x + 1 + Math.floor(this.progressTeam1 * totalRemWidth),this.position.y + 2);
}
if(this.monsterSpriteTeam2 != null) {
this.monsterSpriteTeam2.position.set(this.position.x + this.totalWidth + 1 - Math.ceil(this.progressTeam2 * totalRemWidth),this.position.y + 2);
}
var _g = 0;
var _g1 = this.boosters;
while(_g < _g1.length) {
var booster = _g1[_g];
++_g;
booster.sprite.position.set(this.position.x + booster.xPos,this.position.y + 20 - 9);
}
var _g = 0;
var _g1 = this.blocks.length;
while(_g < _g1) {
var i = _g++;
var theseBlocks = this.blocks[i];
var _g2 = 0;
var _g3 = theseBlocks.length;
while(_g2 < _g3) {
var j = _g2++;
theseBlocks[j].sprite.position.set(this.position.x + 2 + i * 4,this.position.y + 20 - 5 - 4 * j);
}
}
}
,__class__: buildings_HoloGameHall
});
var buildings_HyperElevator = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.timesUsedTo = 0;
this.timesUsed = 0;
Building.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.doorX = 8;
this.doorTextures = Resources.getTexturesByWidth("spr_hyperelevator_door",10);
this.doorSprite = new PIXI.Sprite(this.doorTextures[0]);
bgStage.addChild(this.doorSprite);
this.doorSprite.position.set(position.x + 5,position.y + 10);
this.doorFullyOpenFor = 0;
this.currentDoorTexture = 0;
this.relocateSprite();
};
$hxClasses["buildings.HyperElevator"] = buildings_HyperElevator;
buildings_HyperElevator.__name__ = "buildings.HyperElevator";
buildings_HyperElevator.__super__ = Building;
buildings_HyperElevator.prototype = $extend(Building.prototype,{
get_typeID: function() {
return 4;
}
,positionSprites: function() {
Building.prototype.positionSprites.call(this);
this.relocateSprite();
}
,relocateSprite: function() {
this.doorSprite.parent.removeChild(this.doorSprite);
if(this.worldPosition.y == 0) {
this.stage.addChild(this.doorSprite);
} else {
this.bgStage.addChild(this.doorSprite);
}
this.doorSprite.position.set(this.position.x + 5,this.position.y + 10);
}
,update: function(timeMod) {
Building.prototype.update.call(this,timeMod);
if(this.doorFullyOpenFor > 0) {
this.doorFullyOpenFor -= timeMod;
var val = this.currentDoorTexture + 0.5 * timeMod;
var maxVal = this.doorTextures.length - 1;
this.currentDoorTexture = val < 0 ? 0 : val > maxVal ? maxVal : val;
this.updateCurrentDoorTexture();
} else {
var val = this.currentDoorTexture - 0.5 * timeMod;
var maxVal = this.doorTextures.length - 1;
this.currentDoorTexture = val < 0 ? 0 : val > maxVal ? maxVal : val;
this.updateCurrentDoorTexture();
}
}
,openDoor: function() {
this.doorFullyOpenFor = 45;
return this.currentDoorTexture >= this.doorTextures.length - 1.01;
}
,updateCurrentDoorTexture: function() {
this.doorSprite.texture = this.doorTextures[Math.floor(this.currentDoorTexture)];
}
,destroy: function() {
Building.prototype.destroy.call(this);
this.doorSprite.destroy();
}
,addWindowInfoLines: function() {
var _gthis = this;
Building.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
return "Elevator entered here " + _gthis.timesUsed + " times.";
});
this.city.gui.windowAddInfoText(null,function() {
return "Elevator left here " + _gthis.timesUsedTo + " times.";
});
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
Building.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_HyperElevator.saveDefinition);
}
var value = this.timesUsed;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.timesUsedTo;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
,load: function(queue,definition) {
Building.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"timesUsed")) {
this.timesUsed = loadMap.h["timesUsed"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"timesUsedTo")) {
this.timesUsedTo = loadMap.h["timesUsedTo"];
}
}
,__class__: buildings_HyperElevator
});
var buildings_IndoorFarm = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.percentCleaned = 0;
this.foodLeft = 0;
this.percentGrown = 0;
this.farmStage = buildings_FarmStage.Growing;
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.textures = Resources.getTexturesByWidth("spr_indoorfarm_crops",20);
this.growthSprite = new PIXI.Sprite();
bgStage.addChild(this.growthSprite);
this.updateTexture();
this.positionSprites();
this.doorX = 12;
this.adjecentBuildingEffects.push({ name : "farm", intensity : 1});
};
$hxClasses["buildings.IndoorFarm"] = buildings_IndoorFarm;
buildings_IndoorFarm.__name__ = "buildings.IndoorFarm";
buildings_IndoorFarm.__super__ = buildings_Work;
buildings_IndoorFarm.prototype = $extend(buildings_Work.prototype,{
postLoad: function() {
this.updateTexture();
}
,work: function(citizen,timeMod,shouldStopWorking) {
var _gthis = this;
if(shouldStopWorking) {
citizen.currentAction = LifeAction.Nothing;
} else {
var timeMin = (this.farmStage == buildings_FarmStage.Harvesting ? 15 : 30) / this.city.simulation.happiness.actionSpeedModifierWithoutPenalties | 0;
var timeMax = (this.farmStage == buildings_FarmStage.Harvesting ? 30 : 60) / this.city.simulation.happiness.actionSpeedModifierWithoutPenalties | 0;
var modifyWithHappiness = false;
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
citizen.moveAndWait(random_Random.getInt(3,15),random_Random.getInt(timeMin,timeMax),function() {
switch(_gthis.farmStage._hx_index) {
case 0:
_gthis.percentGrown += 1.15 * _gthis.city.simulation.bonuses.indoorFarmSpeed;
if(_gthis.percentGrown >= 100) {
_gthis.farmStage = buildings_FarmStage.Harvesting;
var tmp = 25 + _gthis.city.simulation.bonuses.extraFoodFromFarms;
var tmp1 = _gthis.getEffectsOfAdjecentBuildings("increaseCropNumber");
_gthis.foodLeft = tmp + tmp1;
}
_gthis.updateTexture();
break;
case 1:
var currentHarvestAmount = 0.25 * _gthis.city.simulation.boostManager.currentGlobalBoostAmount;
_gthis.foodLeft -= currentHarvestAmount;
var _g = _gthis.city.materials;
_g.set_food(_g.food + currentHarvestAmount);
_gthis.city.simulation.stats.materialProduction[0][0] += currentHarvestAmount;
if(_gthis.foodLeft <= 0) {
_gthis.percentCleaned = 0;
_gthis.farmStage = buildings_FarmStage.Cleaning;
}
_gthis.updateTexture();
break;
case 2:
_gthis.percentCleaned += 5;
if(_gthis.percentCleaned >= 100) {
_gthis.farmStage = buildings_FarmStage.Growing;
_gthis.percentGrown = 0;
}
_gthis.updateTexture();
break;
}
},modifyWithHappiness,false);
}
}
,destroy: function() {
buildings_Work.prototype.destroy.call(this);
this.bgStage.removeChild(this.growthSprite);
}
,update: function(timeMod) {
if(this.farmStage == buildings_FarmStage.Growing) {
var this1 = this.city.simulation.time.timeSinceStart / 60 % 24;
var start = 7;
var end = 20;
if(start < end ? this1 >= start && this1 < end : this1 >= start || this1 < end) {
this.percentGrown += timeMod * 0.018 * this.city.simulation.bonuses.indoorFarmSpeed;
if(this.percentGrown >= 100) {
this.farmStage = buildings_FarmStage.Harvesting;
this.foodLeft = 25 + this.city.simulation.bonuses.extraFoodFromFarms + this.getEffectsOfAdjecentBuildings("increaseCropNumber");
}
this.updateTexture();
} else {
var this1 = this.city.simulation.time.timeSinceStart / 60 % 24;
var start = 7 - 1;
var end = 20 + 1;
if(start < end ? this1 >= start && this1 < end : this1 >= start || this1 < end) {
this.percentGrown += timeMod * 0.009 * this.city.simulation.bonuses.indoorFarmSpeed;
if(this.percentGrown >= 100) {
this.farmStage = buildings_FarmStage.Harvesting;
this.foodLeft = 25 + this.city.simulation.bonuses.extraFoodFromFarms + this.getEffectsOfAdjecentBuildings("increaseCropNumber");
}
this.updateTexture();
}
}
}
}
,grow: function(percent) {
this.percentGrown += percent;
if(this.percentGrown >= 100) {
this.farmStage = buildings_FarmStage.Harvesting;
this.foodLeft = 25 + this.city.simulation.bonuses.extraFoodFromFarms + this.getEffectsOfAdjecentBuildings("increaseCropNumber");
}
this.updateTexture();
}
,updateTexture: function() {
var tmp;
switch(this.farmStage._hx_index) {
case 0:
tmp = this.textures[Math.floor(this.percentGrown / 100 * (this.textures.length - 2))];
break;
case 1:
tmp = this.textures[this.textures.length - 2];
break;
case 2:
tmp = this.textures[this.textures.length - 1];
break;
}
this.growthSprite.texture = tmp;
}
,positionSprites: function() {
buildings_Work.prototype.positionSprites.call(this);
if(this.growthSprite != null) {
this.growthSprite.position.set(this.position.x,this.position.y);
}
}
,addWindowInfoLines: function() {
var _gthis = this;
buildings_Work.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
switch(_gthis.farmStage._hx_index) {
case 0:
return "Crops " + Math.floor(_gthis.percentGrown) + "% grown.";
case 1:
return "" + Math.floor(_gthis.foodLeft) + " food left to harvest.";
case 2:
return "Old crops " + Math.floor(_gthis.percentCleaned) + "% cleaned.";
}
});
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Work.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_IndoorFarm.saveDefinition);
}
var e = this.farmStage;
queue.addString($hxEnums[e.__enum__].__constructs__[e._hx_index]);
var value = this.percentGrown;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.foodLeft;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.percentCleaned;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
}
,load: function(queue,definition) {
buildings_Work.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"farmStage")) {
this.farmStage = loadMap.h["farmStage"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"percentGrown")) {
this.percentGrown = loadMap.h["percentGrown"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"foodLeft")) {
this.foodLeft = loadMap.h["foodLeft"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"percentCleaned")) {
this.percentCleaned = loadMap.h["percentCleaned"];
}
this.postLoad();
}
,__class__: buildings_IndoorFarm
});
var buildings_Laboratory = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.anyoneHasWorkedHere = false;
this.totalKnowledgeGenerated = 0;
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.normalDrawer = this.drawer;
this.originalBackTexture = Resources.getTexturesByWidth("spr_laboratory",20)[2];
this.noLightBackTexture = Resources.getTexture("spr_laboratory_lightsoff");
this.backSprite = new PIXI.Sprite(this.originalBackTexture);
this.backSprite.position.set(position.x,position.y);
bgStage.addChild(this.backSprite);
};
$hxClasses["buildings.Laboratory"] = buildings_Laboratory;
buildings_Laboratory.__name__ = "buildings.Laboratory";
buildings_Laboratory.__super__ = buildings_Work;
buildings_Laboratory.prototype = $extend(buildings_Work.prototype,{
get_possibleUpgrades: function() {
return [buildingUpgrades_FarmingResearch,buildingUpgrades_TreePlantationResearch];
}
,positionSprites: function() {
buildings_Work.prototype.positionSprites.call(this);
if(this.backSprite != null) {
this.backSprite.position.set(this.position.x,this.position.y);
}
}
,destroy: function() {
buildings_Work.prototype.destroy.call(this);
if(this.backSprite != null) {
this.bgStage.removeChild(this.backSprite);
}
}
,work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking) {
citizen.currentAction = LifeAction.Nothing;
} else {
this.anyoneHasWorkedHere = true;
if(citizen.isAtGroundLevel()) {
var positionInArray = this.workers.indexOf(citizen);
citizen.setRelativePos(positionInArray == 0 ? 5 : 13,9);
} else {
var newKnowledge = 0.00125 * timeMod * this.city.simulation.happiness.actionSpeedModifier * this.city.simulation.bonuses.labSpeed * citizen.get_educationSpeedModifier() * this.city.simulation.boostManager.currentGlobalBoostAmount;
this.city.materials.knowledge += newKnowledge;
this.city.simulation.stats.materialProduction[8][0] += newKnowledge;
this.totalKnowledgeGenerated += newKnowledge;
}
}
}
,update: function(timeMod) {
this.backSprite.texture = this.anyoneHasWorkedHere ? this.originalBackTexture : this.noLightBackTexture;
this.anyoneHasWorkedHere = false;
}
,addWindowInfoLines: function() {
var _gthis = this;
buildings_Work.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
return "" + (_gthis.totalKnowledgeGenerated | 0) + " knowledge gathered.";
});
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Work.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_Laboratory.saveDefinition);
}
var value = this.totalKnowledgeGenerated;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
}
,load: function(queue,definition) {
buildings_Work.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"totalKnowledgeGenerated")) {
this.totalKnowledgeGenerated = loadMap.h["totalKnowledgeGenerated"];
}
}
,__class__: buildings_Laboratory
});
var buildings_LandedExplorationShip = function(game,stage,bgStage,city,world,position,worldPosition,id) {
buildings_House.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.doorX = 4;
};
$hxClasses["buildings.LandedExplorationShip"] = buildings_LandedExplorationShip;
buildings_LandedExplorationShip.__name__ = "buildings.LandedExplorationShip";
buildings_LandedExplorationShip.__super__ = buildings_House;
buildings_LandedExplorationShip.prototype = $extend(buildings_House.prototype,{
get_possibleUpgrades: function() {
return [];
}
,get_baseAttractiveness: function() {
return 50;
}
,walkAround: function(citizen,stepsInBuilding) {
var r = random_Random.getInt(3);
if(citizen.relativeX > 11) {
citizen.setRelativeX(11);
}
if(citizen.relativeX <= 1) {
citizen.setRelativeX(2);
}
if(r == 1) {
citizen.moveAndWait(random_Random.getInt(4,5),random_Random.getInt(30,60),null,false,false);
} else if(r == 2) {
citizen.moveAndWait(random_Random.getInt(9,12),random_Random.getInt(30,60),null,false,false);
} else {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = random_Random.getInt(90,120);
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
}
,addWindowInfoLines: function() {
this.city.gui.windowAddInfoText(null,function() {
return "Used as a house.";
});
buildings_House.prototype.addWindowInfoLines.call(this);
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_House.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_LandedExplorationShip.saveDefinition);
}
}
,load: function(queue,definition) {
buildings_House.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
}
,__class__: buildings_LandedExplorationShip
});
var buildings_LandingSite = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.saucerType = 0;
this.timesUsedStopOver = 0;
this.timesUsedTo = 0;
this.timesUsed = 0;
this.landingSiteGroup = 0;
this.currentlyLandedSaucer = null;
this.hasFlyingSaucer = true;
Building.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
city.landingSites.push(this);
this.doorX = 15;
this.connectedWaypoint = null;
this.flyingSaucerSprite = Resources.makeSprite("spr_flyingsaucer");
this.flyingSaucerSprite.position.set(position.x,position.y);
stage.addChild(this.flyingSaucerSprite);
};
$hxClasses["buildings.LandingSite"] = buildings_LandingSite;
buildings_LandingSite.__name__ = "buildings.LandingSite";
buildings_LandingSite.__super__ = Building;
buildings_LandingSite.prototype = $extend(Building.prototype,{
get_typeID: function() {
return 2;
}
,get_saucherTexture: function() {
switch(this.saucerType) {
case 0:
return "spr_flyingsaucer";
case 1:
return "spr_flyingsaucer_alt";
case 2:
return "spr_flowercraft";
case 3:
return "spr_flyingsaucer_cube";
case 4:
return "spr_flyingsaucer_deepblue";
case 5:
return "spr_flyingsaucer_shade";
default:
return "spr_flyingsaucer";
}
}
,get_mainTexture: function() {
switch(this.saucerType) {
case 0:
return buildings_LandingSite.spriteName;
case 1:
return "spr_landingplace_alt";
case 4:
return "spr_landingplace_deepblue";
default:
return buildings_LandingSite.spriteName;
}
}
,postLoad: function() {
var tmp = this.get_saucherTexture();
this.flyingSaucerSprite.texture = Resources.getTexture(tmp);
this.drawer.changeMainTexture(this.get_mainTexture());
}
,positionSprites: function() {
Building.prototype.positionSprites.call(this);
if(this.flyingSaucerSprite != null) {
this.flyingSaucerSprite.position.set(this.position.x,this.position.y);
}
}
,update: function(timeMod) {
Building.prototype.update.call(this,timeMod);
if(this.timeUntilCanGetNewFlyingSaucer > 0) {
this.timeUntilCanGetNewFlyingSaucer -= timeMod;
} else if(this.gettingNewFlyingSaucerStage > 0) {
this.gettingNewFlyingSaucerStage -= timeMod;
this.flyingSaucerSprite.position.set(this.position.x,this.position.y - Math.max(0,this.gettingNewFlyingSaucerStage * 0.25));
this.flyingSaucerSprite.alpha = 1 - this.gettingNewFlyingSaucerStage / 16;
if(this.gettingNewFlyingSaucerStage <= 0) {
this.hasFlyingSaucer = true;
}
}
}
,destroy: function() {
HxOverrides.remove(this.city.landingSites,this);
this.stage.removeChild(this.flyingSaucerSprite);
var i = this.city.simulation.flyingSaucers.length;
while(--i >= 0) if(this.city.simulation.flyingSaucers[i].destination == this) {
this.city.simulation.flyingSaucers[i].cancel();
}
Building.prototype.destroy.call(this);
}
,addFlyingSaucer: function() {
if(!this.hasFlyingSaucer) {
this.hasFlyingSaucer = true;
this.flyingSaucerSprite.alpha = 1;
this.flyingSaucerSprite.position.set(this.position.x,this.position.y);
}
}
,removeFlyingSaucer: function() {
if(this.hasFlyingSaucer) {
this.hasFlyingSaucer = false;
this.flyingSaucerSprite.alpha = 0;
this.gettingNewFlyingSaucerStage = 16;
this.timeUntilCanGetNewFlyingSaucer = 30;
}
}
,estimatedFlyingDistanceTo: function(site) {
return (Math.abs(site.position.x - this.position.x) + Math.abs(site.position.y - this.position.y)) / 3;
}
,addWindowInfoLines: function() {
var _gthis = this;
Building.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
var val2 = _gthis.timesUsed - _gthis.timesUsedStopOver;
return "Transported from " + (val2 > 0 ? val2 : 0) + " times.";
});
this.city.gui.windowAddInfoText(null,function() {
return "Transported to " + _gthis.timesUsedTo + " times.";
});
this.city.gui.windowAddInfoText(null,function() {
return "Used as stopover " + _gthis.timesUsedStopOver + " times.";
});
}
,createWindowAddBottomButtons: function() {
var _gthis = this;
if(Settings.hasSecretCode("hangar")) {
gui_windowParts_CycleValueButton.create(this.city.gui,function() {
return _gthis.saucerType;
},function(t) {
_gthis.saucerType = t;
var tmp = _gthis.get_saucherTexture();
_gthis.flyingSaucerSprite.texture = Resources.getTexture(tmp);
_gthis.drawer.changeMainTexture(_gthis.get_mainTexture());
},function() {
return 6;
},"Change Space Ship");
}
Building.prototype.createWindowAddBottomButtons.call(this);
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
Building.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_LandingSite.saveDefinition);
}
var value = this.timesUsed;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.timesUsedTo;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.timesUsedStopOver;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.saucerType;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
,load: function(queue,definition) {
Building.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"timesUsed")) {
this.timesUsed = loadMap.h["timesUsed"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"timesUsedTo")) {
this.timesUsedTo = loadMap.h["timesUsedTo"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"timesUsedStopOver")) {
this.timesUsedStopOver = loadMap.h["timesUsedStopOver"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"saucerType")) {
this.saucerType = loadMap.h["saucerType"];
}
this.postLoad();
}
,__class__: buildings_LandingSite
});
var buildings_Library = function(game,stage,bgStage,city,world,position,worldPosition,id) {
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.startTime = 14;
this.endTime = 22;
this.workTimePreferenceMod = 0.5;
this.isEntertainment = true;
};
$hxClasses["buildings.Library"] = buildings_Library;
buildings_Library.__name__ = "buildings.Library";
buildings_Library.__interfaces__ = [buildings_IEntertainmentBuilding];
buildings_Library.__super__ = buildings_Work;
buildings_Library.prototype = $extend(buildings_Work.prototype,{
get_baseEntertainmentCapacity: function() {
return this.workers.length * 50;
}
,get_isOpen: function() {
if(this.workers.length == 1 && this.workers[0].currentAction == LifeAction.Work) {
var this1 = this.city.simulation.time.timeSinceStart / 60 % 24;
var start = this.startTime - this.workTimePreferenceMod;
if(start < 22) {
if(this1 >= start) {
return this1 < 22;
} else {
return false;
}
} else if(!(this1 >= start)) {
return this1 < 22;
} else {
return true;
}
} else {
return false;
}
}
,get_entertainmentType: function() {
return 5;
}
,get_minimumNormalTimeToSpend: function() {
return 2;
}
,get_maximumNormalTimeToSpend: function() {
return 5;
}
,get_minimumEntertainmentGroupSatisfy: function() {
return 1;
}
,get_maximumEntertainmentGroupSatisfy: function() {
return 3;
}
,get_entertainmentQuality: function() {
return 100;
}
,get_isOpenForExistingVisitors: function() {
return this.get_isOpen();
}
,finishEntertainment: function(citizen,timeMod) {
return true;
}
,positionSprites: function() {
buildings_Work.prototype.positionSprites.call(this);
}
,beEntertained: function(citizen,timeMod) {
var moveFunction = function() {
if(citizen.relativeY < 5) {
var moveToX = random_Random.getInt(3,7);
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = moveToX;
citizen1.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
} else {
var moveToX = random_Random.getInt(3,16);
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = moveToX;
citizen1.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
};
if(random_Random.getInt(2) == 1) {
citizen.changeFloor(moveFunction);
} else {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = random_Random.getInt(120,180);
citizen1.setPath(arr,0,2,true);
citizen.pathEndFunction = moveFunction;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
if(!citizen.hasBuildingInited) {
citizen.educationLevel = Math.max(Math.min(citizen.educationLevel + 0.025,1.5),citizen.educationLevel);
citizen.hasBuildingInited = true;
}
}
,work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking && this.city.simulation.time.timeSinceStart / 60 % 24 > 22) {
citizen.currentAction = LifeAction.Nothing;
} else {
var spd = citizen.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
if(Math.abs(12 - citizen.relativeX) < spd) {
citizen.relativeX = 12;
} else {
var num = 12 - citizen.relativeX;
citizen.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
}
}
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Work.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_Library.saveDefinition);
}
}
,load: function(queue,definition) {
buildings_Work.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
}
,__class__: buildings_Library
});
var buildings_LivingResearchCenter = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.totalKnowledgeGenerated = 0;
buildings_WorkWithHome.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
};
$hxClasses["buildings.LivingResearchCenter"] = buildings_LivingResearchCenter;
buildings_LivingResearchCenter.__name__ = "buildings.LivingResearchCenter";
buildings_LivingResearchCenter.__super__ = buildings_WorkWithHome;
buildings_LivingResearchCenter.prototype = $extend(buildings_WorkWithHome.prototype,{
get_possibleCityUpgrades: function() {
return [cityUpgrades_SpaciousLiving,cityUpgrades_SlimyLiving,cityUpgrades_SecretiveLiving,cityUpgrades_MechanicalLiving,cityUpgrades_SuperSpaciousLiving];
}
,walkAround: function(citizen,stepsInBuilding) {
var r = random_Random.getInt(3);
if(citizen.relativeY < 5) {
citizen.changeFloorAndWaitRandom(30,60);
} else if(r == 1) {
if(random_Random.getInt(2) == 0) {
citizen.moveAndWait(random_Random.getInt(3,7),random_Random.getInt(30,60),null,false,false);
} else {
citizen.moveAndWait(random_Random.getInt(12,16),random_Random.getInt(30,60),null,false,false);
}
} else {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = random_Random.getInt(90,120);
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
}
,work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking) {
citizen.currentAction = LifeAction.Nothing;
return;
}
if(citizen.relativeY < 2) {
if(random_Random.getInt(2) == 0) {
var modifyWithHappiness = false;
var slowMove = true;
if(slowMove == null) {
slowMove = false;
}
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
citizen.moveAndWait(random_Random.getInt(3,6),random_Random.getInt(60,120),null,modifyWithHappiness,slowMove);
} else {
var modifyWithHappiness = false;
var slowMove = true;
if(slowMove == null) {
slowMove = false;
}
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
citizen.moveAndWait(random_Random.getInt(13,14),random_Random.getInt(60,120),null,modifyWithHappiness,slowMove);
}
} else if(random_Random.getInt(2) == 0) {
var modifyWithHappiness = false;
var slowMove = true;
if(slowMove == null) {
slowMove = false;
}
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
citizen.moveAndWait(random_Random.getInt(3,15),random_Random.getInt(60,120),null,modifyWithHappiness,slowMove);
}
var newKnowledge = 0.10799999999999998 * citizen.get_educationSpeedModifier() * this.city.simulation.boostManager.currentGlobalBoostAmount;
this.city.materials.knowledge += newKnowledge;
this.city.simulation.stats.materialProduction[8][0] += newKnowledge;
this.totalKnowledgeGenerated += newKnowledge;
}
,addWindowInfoLines: function() {
var _gthis = this;
buildings_WorkWithHome.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
return "" + (_gthis.totalKnowledgeGenerated | 0) + " knowledge gathered.";
});
}
,createMainWindowPart: function() {
var _gthis = this;
buildings_WorkWithHome.prototype.createMainWindowPart.call(this);
var createUpgradeAllHousesWindow = null;
createUpgradeAllHousesWindow = function() {
_gthis.city.gui.createWindow(_gthis);
gui_ReplaceAllHousesWindow.create(_gthis.city,_gthis.city.gui,_gthis.city.gui.innerWindowStage,_gthis.city.gui.windowInner);
_gthis.city.gui.addWindowToStack(createUpgradeAllHousesWindow);
};
var tb = new gui_ContainerButton(this.city.gui,this.city.gui.innerWindowStage,this.city.gui.windowInner,createUpgradeAllHousesWindow);
var extraSpacing = this.city.game.isMobile ? 3 : 0;
tb.container.padding.top = 3 + extraSpacing;
tb.container.padding.left = 3;
tb.container.padding.right = 3;
tb.container.padding.bottom = extraSpacing;
tb.container.fillSecondarySize = true;
tb.container.addChild(new gui_TextElement(tb,this.city.gui.innerWindowStage,"Upgrade Basic Houses"));
this.city.gui.windowInner.addChild(tb);
this.city.gui.windowInner.addChild(new gui_GUISpacing(this.city.gui.windowInner,new common_Point(2,6)));
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_WorkWithHome.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_LivingResearchCenter.saveDefinition);
}
var value = this.totalKnowledgeGenerated;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
}
,load: function(queue,definition) {
buildings_WorkWithHome.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"totalKnowledgeGenerated")) {
this.totalKnowledgeGenerated = loadMap.h["totalKnowledgeGenerated"];
}
}
,__class__: buildings_LivingResearchCenter
});
var buildings_MachinePartsFactory = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.materialsMadePerStepPerWorker = 0.0015;
buildings_MaterialConvertingFactory.call(this,game,stage,bgStage,city,world,position,worldPosition,id,"spr_machinepartsfactory_frames","spr_machinepartsfactory_idle");
};
$hxClasses["buildings.MachinePartsFactory"] = buildings_MachinePartsFactory;
buildings_MachinePartsFactory.__name__ = "buildings.MachinePartsFactory";
buildings_MachinePartsFactory.__super__ = buildings_MaterialConvertingFactory;
buildings_MachinePartsFactory.prototype = $extend(buildings_MaterialConvertingFactory.prototype,{
get_normalEfficiency: function() {
return 3;
}
,get_walkThroughCanViewSelfInThisBuilding: function() {
return false;
}
,get_possibleUpgrades: function() {
return [buildingUpgrades_MachinePartsFactoryEfficiency];
}
,get_possibleBuildingModes: function() {
return [buildingUpgrades_FactoryWorking,buildingUpgrades_MachinePartsFactoryTurbo,buildingUpgrades_StoneUsingFactoryDisabled];
}
,get_materialFrom: function() {
return this.city.materials.stone;
}
,set_materialFrom: function(value) {
var productionAmount = this.city.materials.stone - value;
this.city.materials.stone -= productionAmount;
this.city.simulation.stats.materialUsed[2][0] += productionAmount;
return this.city.materials.stone;
}
,get_materialTo: function() {
return this.city.materials.machineParts;
}
,set_materialTo: function(value) {
var productionAmount = value - this.city.materials.machineParts;
this.city.materials.machineParts += productionAmount;
this.city.simulation.stats.materialProduction[3][0] += productionAmount;
return this.city.materials.machineParts;
}
,get_bonusSpeed: function() {
return this.city.simulation.bonuses.machinePartsFactorySpeed;
}
,onBuild: function() {
buildings_MaterialConvertingFactory.prototype.onBuild.call(this);
this.city.progress.unlocks.unlock(buildings_MechanicalHouse);
}
,workAnimation: function(citizen,timeMod) {
if(citizen.relativeY != 10) {
if(this.workers.indexOf(citizen) == 0) {
citizen.setRelativePos(12,10);
} else {
citizen.setRelativePos(15,10);
}
}
}
,addWindowInfoLines: function() {
var _gthis = this;
buildings_MaterialConvertingFactory.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
return "" + (_gthis.totalMaterialUsed | 0) + " stone used to make " + (_gthis.materialMade | 0) + " machine parts.";
});
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_MaterialConvertingFactory.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_MachinePartsFactory.saveDefinition);
}
}
,load: function(queue,definition) {
buildings_MaterialConvertingFactory.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
}
,__class__: buildings_MachinePartsFactory
});
var buildings_MechanicalHouse = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.hasHeatedBed = false;
this.movementType = 0;
this.bgSprite2 = null;
this.currentAdjBonus = 0;
buildings_House.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
};
$hxClasses["buildings.MechanicalHouse"] = buildings_MechanicalHouse;
buildings_MechanicalHouse.__name__ = "buildings.MechanicalHouse";
buildings_MechanicalHouse.__super__ = buildings_House;
buildings_MechanicalHouse.prototype = $extend(buildings_House.prototype,{
get_possibleUpgrades: function() {
return [buildingUpgrades_HeatedBed];
}
,destroy: function() {
buildings_House.prototype.destroy.call(this);
if(this.spriteOverMachinePartsFactory != null) {
this.spriteOverMachinePartsFactory.destroy();
}
if(this.bgSprite != null) {
this.bgSprite.destroy();
}
if(this.bgSprite2 != null) {
this.bgSprite2.destroy();
}
this.spriteOverMachinePartsFactory = null;
this.bgSprite = null;
}
,update: function(timeMod) {
if(this.bgSprite != null) {
this.bgTexture += timeMod * 0.25;
if(this.bgTexture >= this.bgTextures.length) {
this.bgTexture = 0;
}
this.bgSprite.texture = this.bgTextures[this.bgTexture | 0];
}
}
,walkAround: function(citizen,stepsInBuilding) {
if(this.movementType == 0) {
buildings_House.prototype.walkAround.call(this,citizen,stepsInBuilding);
} else if(this.movementType == 1) {
var r = random_Random.getInt(4);
if(r == 0 && stepsInBuilding > 120 && citizen.relativeX < 11) {
citizen.changeFloorAndWaitRandom(30,60);
} else if(r == 1) {
citizen.moveAndWait(random_Random.getInt(3,7),random_Random.getInt(30,60),null,false,false);
} else if(r == 2 && citizen.relativeY < 5) {
citizen.moveAndWait(random_Random.getInt(12,16),random_Random.getInt(30,60),null,false,false);
} else {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = random_Random.getInt(90,120);
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
} else if(this.movementType == 2) {
var r = random_Random.getInt(4);
if(r == 0 && stepsInBuilding > 120 && citizen.relativeX > 11) {
citizen.changeFloorAndWaitRandom(30,60);
} else if(r <= 2 && citizen.relativeY < 5) {
citizen.moveAndWait(random_Random.getInt(7,16),random_Random.getInt(30,60),null,false,false);
} else if(r <= 2) {
citizen.moveAndWait(random_Random.getInt(12,16),random_Random.getInt(30,60),null,false,false);
} else {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = random_Random.getInt(90,120);
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
} else if(this.movementType == 3) {
var r = random_Random.getInt(4);
if(r == 0 && stepsInBuilding > 120 && citizen.relativeX > 11) {
citizen.changeFloorAndWaitRandom(30,60);
} else if((r == 1 || r == 2) && citizen.relativeY < 5) {
citizen.moveAndWait(random_Random.getInt(7,16),random_Random.getInt(30,60),null,false,false);
} else if(r == 2) {
citizen.moveAndWait(random_Random.getInt(12,16),random_Random.getInt(30,60),null,false,false);
} else {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = random_Random.getInt(90,120);
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
}
}
,onCityChange: function() {
var _gthis = this;
var newAdjBonus = 0;
this.movementType = 0;
if(this.rightBuilding != null && this.rightBuilding.is(buildings_MachinePartsFactory)) {
if(this.leftBuilding != null && this.leftBuilding.is(buildings_MachinePartsFactory)) {
newAdjBonus = 50;
this.drawer.changeMainTexture("spr_mechanicalhouse_leftright");
if(_gthis.spriteOverMachinePartsFactory == null) {
_gthis.spriteOverMachinePartsFactory = new PIXI.Sprite();
_gthis.city.justAboveCityStage.addChild(_gthis.spriteOverMachinePartsFactory);
}
if(_gthis.bgSprite == null) {
_gthis.bgSprite = new PIXI.Sprite();
_gthis.bgStage.addChild(_gthis.bgSprite);
}
if(_gthis.bgSprite2 != null) {
_gthis.bgSprite2.destroy();
}
if(_gthis.hasHeatedBed) {
_gthis.bgSprite2 = new PIXI.Sprite(Resources.getTexture("spr_mechanicalhouse_heatedbed"));
_gthis.bgStage.addChild(_gthis.bgSprite2);
}
_gthis.bgSprite.position.set(_gthis.position.x,_gthis.position.y);
this.bgTextures = Resources.getTexturesByWidth("spr_mechanicalhouse_leftright_bganim",20);
this.spriteOverMachinePartsFactory.texture = Resources.getTexture(this.leftBuilding.bottomBuilding == null ? "spr_mechanicalhouse_pipe_h3_bf" : "spr_mechanicalhouse_pipe_h3");
this.spriteOverMachinePartsFactory.position.set(this.position.x - 3,this.position.y);
this.bgTexture = this.rightBuilding.bgTexture % this.bgTextures.length;
} else {
newAdjBonus = 50;
this.drawer.changeMainTexture("spr_mechanicalhouse_left");
if(_gthis.spriteOverMachinePartsFactory == null) {
_gthis.spriteOverMachinePartsFactory = new PIXI.Sprite();
_gthis.city.justAboveCityStage.addChild(_gthis.spriteOverMachinePartsFactory);
}
if(_gthis.bgSprite == null) {
_gthis.bgSprite = new PIXI.Sprite();
_gthis.bgStage.addChild(_gthis.bgSprite);
}
if(_gthis.bgSprite2 != null) {
_gthis.bgSprite2.destroy();
}
if(_gthis.hasHeatedBed) {
_gthis.bgSprite2 = new PIXI.Sprite(Resources.getTexture("spr_mechanicalhouse_heatedbed"));
_gthis.bgStage.addChild(_gthis.bgSprite2);
}
_gthis.bgSprite.position.set(_gthis.position.x,_gthis.position.y);
this.bgTextures = Resources.getTexturesByWidth("spr_mechanicalhouse_left_bganim",20);
this.spriteOverMachinePartsFactory.texture = Resources.getTexture("spr_mechanicalhouse_pipe_h");
this.spriteOverMachinePartsFactory.position.set(this.position.x + 20,this.position.y + 4);
this.bgTexture = this.rightBuilding.bgTexture % this.bgTextures.length;
}
this.movementType = 1;
} else if(this.bottomBuilding != null && this.bottomBuilding.is(buildings_MachinePartsFactory)) {
newAdjBonus = 50;
this.drawer.changeMainTexture("spr_mechanicalhouse_top");
if(_gthis.spriteOverMachinePartsFactory == null) {
_gthis.spriteOverMachinePartsFactory = new PIXI.Sprite();
_gthis.city.justAboveCityStage.addChild(_gthis.spriteOverMachinePartsFactory);
}
if(_gthis.bgSprite == null) {
_gthis.bgSprite = new PIXI.Sprite();
_gthis.bgStage.addChild(_gthis.bgSprite);
}
if(_gthis.bgSprite2 != null) {
_gthis.bgSprite2.destroy();
}
if(_gthis.hasHeatedBed) {
_gthis.bgSprite2 = new PIXI.Sprite(Resources.getTexture("spr_mechanicalhouse_heatedbed"));
_gthis.bgStage.addChild(_gthis.bgSprite2);
}
_gthis.bgSprite.position.set(_gthis.position.x,_gthis.position.y);
this.bgTextures = Resources.getTexturesByWidth("spr_mechanicalhouse_top_bganim",20);
if(this.topBuilding != null && this.topBuilding.is(buildings_MachinePartsFactory)) {
this.spriteOverMachinePartsFactory.texture = Resources.getTexture("spr_mechanicalhouse_pipe_v3");
this.spriteOverMachinePartsFactory.position.set(this.position.x + 1,this.position.y - 3);
} else {
this.spriteOverMachinePartsFactory.texture = Resources.getTexture("spr_mechanicalhouse_pipe_v1");
this.spriteOverMachinePartsFactory.position.set(this.position.x + 1,this.position.y + 20);
}
this.bgTexture = this.bottomBuilding.bgTexture % this.bgTextures.length;
this.movementType = 2;
} else if(this.leftBuilding != null && this.leftBuilding.is(buildings_MachinePartsFactory)) {
newAdjBonus = 50;
this.drawer.changeMainTexture("spr_mechanicalhouse_right");
if(_gthis.spriteOverMachinePartsFactory == null) {
_gthis.spriteOverMachinePartsFactory = new PIXI.Sprite();
_gthis.city.justAboveCityStage.addChild(_gthis.spriteOverMachinePartsFactory);
}
if(_gthis.bgSprite == null) {
_gthis.bgSprite = new PIXI.Sprite();
_gthis.bgStage.addChild(_gthis.bgSprite);
}
if(_gthis.bgSprite2 != null) {
_gthis.bgSprite2.destroy();
}
if(_gthis.hasHeatedBed) {
_gthis.bgSprite2 = new PIXI.Sprite(Resources.getTexture("spr_mechanicalhouse_heatedbed"));
_gthis.bgStage.addChild(_gthis.bgSprite2);
}
_gthis.bgSprite.position.set(_gthis.position.x,_gthis.position.y);
this.bgTextures = Resources.getTexturesByWidth("spr_mechanicalhouse_right_bganim",20);
this.spriteOverMachinePartsFactory.texture = Resources.getTexture(this.leftBuilding.bottomBuilding == null ? "spr_mechanicalhouse_pipe_h2_bf" : "spr_mechanicalhouse_pipe_h2");
this.spriteOverMachinePartsFactory.position.set(this.position.x - 3,this.position.y + 11 - (this.leftBuilding.bottomBuilding == null ? 6 : 0));
this.bgTexture = this.leftBuilding.bgTexture % this.bgTextures.length;
} else if(this.topBuilding != null && this.topBuilding.is(buildings_MachinePartsFactory)) {
newAdjBonus = 50;
this.drawer.changeMainTexture("spr_mechanicalhouse_bottom");
if(_gthis.spriteOverMachinePartsFactory == null) {
_gthis.spriteOverMachinePartsFactory = new PIXI.Sprite();
_gthis.city.justAboveCityStage.addChild(_gthis.spriteOverMachinePartsFactory);
}
if(_gthis.bgSprite == null) {
_gthis.bgSprite = new PIXI.Sprite();
_gthis.bgStage.addChild(_gthis.bgSprite);
}
if(_gthis.bgSprite2 != null) {
_gthis.bgSprite2.destroy();
}
if(_gthis.hasHeatedBed) {
_gthis.bgSprite2 = new PIXI.Sprite(Resources.getTexture("spr_mechanicalhouse_heatedbed"));
_gthis.bgStage.addChild(_gthis.bgSprite2);
}
_gthis.bgSprite.position.set(_gthis.position.x,_gthis.position.y);
this.bgTextures = Resources.getTexturesByWidth("spr_mechanicalhouse_bottom_bganim",20);
this.spriteOverMachinePartsFactory.texture = Resources.getTexture("spr_mechanicalhouse_pipe_v2");
this.spriteOverMachinePartsFactory.position.set(this.position.x + 3,this.position.y - 3);
this.bgTexture = this.topBuilding.bgTexture % this.bgTextures.length;
this.movementType = 3;
} else {
this.drawer.changeMainTexture("spr_mechanicalhouse");
if(this.spriteOverMachinePartsFactory != null) {
this.spriteOverMachinePartsFactory.destroy();
this.spriteOverMachinePartsFactory = null;
}
if(this.bgSprite != null) {
this.bgSprite.destroy();
this.bgSprite = null;
}
if(this.hasHeatedBed) {
if(this.bgSprite2 == null) {
this.bgSprite2 = new PIXI.Sprite(Resources.getTexture("spr_mechanicalhouse_heatedbed"));
this.bgStage.addChild(this.bgSprite2);
}
}
}
if(this.bgSprite2 != null) {
this.bgSprite2.position.set(this.position.x,this.position.y);
}
if(this.bgSprite != null) {
this.bgSprite.texture = this.bgTextures[this.bgTexture | 0];
}
this.bonusAttractiveness += newAdjBonus - this.currentAdjBonus;
if(newAdjBonus != (this.currentAdjBonus | 0)) {
this.city.simulation.houseAssigner.shouldUpdateHouses = true;
}
this.currentAdjBonus = newAdjBonus | 0;
}
,__class__: buildings_MechanicalHouse
});
var buildings_MedicalClinic = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.extraCapacity = 0;
this.extraQuality = 0;
this.medicalEducationPart = 0;
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.isMedical = true;
};
$hxClasses["buildings.MedicalClinic"] = buildings_MedicalClinic;
buildings_MedicalClinic.__name__ = "buildings.MedicalClinic";
buildings_MedicalClinic.__interfaces__ = [buildings_IMedicalBuilding];
buildings_MedicalClinic.__super__ = buildings_Work;
buildings_MedicalClinic.prototype = $extend(buildings_Work.prototype,{
get_medicalQuality: function() {
return 50 + 0.25 * this.city.simulation.happiness.schoolHappiness * this.medicalEducationPart + this.extraQuality;
}
,get_medicalCapacity: function() {
return (50 + this.extraCapacity) * (this.workers.length == 0 ? 0 : common_ArrayExtensions.sum(this.workers,function(w) {
return w.get_educationSpeedModifier();
}));
}
,get_possibleUpgrades: function() {
return [buildingUpgrades_MedicalEducation,buildingUpgrades_AIAssistedDiagnosis];
}
,get_possibleCityUpgrades: function() {
return [cityUpgrades_BirthControl];
}
,get_medicalTypeLimit: function() {
return 1;
}
,get_medicalTypeID: function() {
return 0;
}
,work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking) {
citizen.currentAction = LifeAction.Nothing;
return;
}
if(citizen.relativeY < 5 && this.workers.indexOf(citizen) == 1) {
citizen.changeFloor();
} else {
var x = citizen.relativeY < 5 ? 5 : 3;
var spd = citizen.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
if(Math.abs(x - citizen.relativeX) < spd) {
citizen.relativeX = x;
} else {
var num = x - citizen.relativeX;
citizen.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
}
}
}
,addWindowInfoLines: function() {
var _gthis = this;
buildings_Work.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
return "Quality: " + Math.floor(_gthis.get_medicalQuality());
});
this.city.gui.windowAddInfoText(null,function() {
return "Capacity: " + Math.floor(_gthis.get_medicalCapacity());
});
}
,createMainWindowPart: function() {
var _gthis = this;
buildings_Work.prototype.createMainWindowPart.call(this);
var birthControlOptionContainer = new gui_GUIContainer(this.city.gui,this.city.gui.innerWindowStage,this.city.gui.windowInner);
this.city.gui.windowInner.addChild(birthControlOptionContainer);
var createBirthControlOption = function() {
birthControlOptionContainer.padding.bottom = 6;
var createBirthControlWindow = null;
createBirthControlWindow = function() {
_gthis.city.gui.createWindow("birthControlWindow");
_gthis.city.gui.addWindowToStack(createBirthControlWindow);
gui_BirthControlWindow.create(_gthis.city,_gthis.city.gui,_gthis.city.gui.innerWindowStage,_gthis.city.gui.windowInner);
_gthis.city.gui.setWindowReload(createBirthControlWindow);
};
birthControlOptionContainer.addChild(new gui_TextButton(_gthis.city.gui,_gthis.city.gui.innerWindowStage,birthControlOptionContainer,createBirthControlWindow,"Manage Birth Control"));
};
if(this.city.upgrades.vars.hasBirthControl) {
createBirthControlOption();
} else {
var stillNeedsToAddBirthControlOption = true;
birthControlOptionContainer.onUpdate = function() {
if(stillNeedsToAddBirthControlOption && _gthis.city.upgrades.vars.hasBirthControl) {
stillNeedsToAddBirthControlOption = false;
createBirthControlOption();
}
};
}
}
,__class__: buildings_MedicalClinic
});
var buildings_MisdirectorMode = $hxEnums["buildings.MisdirectorMode"] = { __ename__ : "buildings.MisdirectorMode", __constructs__ : ["Normal","Disabled","Always","MostlyDisabled"]
,Normal: {_hx_index:0,__enum__:"buildings.MisdirectorMode",toString:$estr}
,Disabled: {_hx_index:1,__enum__:"buildings.MisdirectorMode",toString:$estr}
,Always: {_hx_index:2,__enum__:"buildings.MisdirectorMode",toString:$estr}
,MostlyDisabled: {_hx_index:3,__enum__:"buildings.MisdirectorMode",toString:$estr}
};
var buildings_Misdirector = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.mode = buildings_MisdirectorMode.Normal;
this.teleportX = 9.;
this.timesUsedTo = 0;
this.knowledgeGenerated = 0;
Building.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.doorX = 12;
city.misdirector = this;
};
$hxClasses["buildings.Misdirector"] = buildings_Misdirector;
buildings_Misdirector.__name__ = "buildings.Misdirector";
buildings_Misdirector.__super__ = Building;
buildings_Misdirector.prototype = $extend(Building.prototype,{
get_misdirectChance: function() {
switch(this.mode._hx_index) {
case 0:
return 0.025;
case 1:
return 0;
case 2:
return 1;
case 3:
return 0.001;
}
}
,get_possibleBuildingModes: function() {
return [buildingUpgrades_MisdirectorNormal,buildingUpgrades_MisdirectorAlways,buildingUpgrades_MisdirectorMostlyDisabled,buildingUpgrades_MisdirectorDisabled];
}
,giveReward: function() {
var newKnowledge = this.mode == buildings_MisdirectorMode.Always ? 0.05 : 0.5;
this.city.materials.knowledge += newKnowledge;
this.city.simulation.stats.materialProduction[8][0] += newKnowledge;
this.knowledgeGenerated += newKnowledge;
}
,destroy: function() {
Building.prototype.destroy.call(this);
this.city.misdirector = null;
}
,addWindowInfoLines: function() {
var _gthis = this;
Building.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
return "Misdirected " + _gthis.timesUsedTo + " times.";
});
this.city.gui.windowAddInfoText(null,function() {
return "Generated " + Math.floor(_gthis.knowledgeGenerated) + " knowledge.";
});
}
,createTeleportParticle: function(rayTexture) {
if(rayTexture == null) {
rayTexture = "spr_teleporter_ray_misdirect";
}
this.city.particles.addParticle(Resources.getTexturesByWidth(rayTexture,4),new common_Point(this.position.x + 8,this.position.y + 4));
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
Building.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_Misdirector.saveDefinition);
}
var value = this.knowledgeGenerated;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.timesUsedTo;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
,load: function(queue,definition) {
Building.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"knowledgeGenerated")) {
this.knowledgeGenerated = loadMap.h["knowledgeGenerated"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"timesUsedTo")) {
this.timesUsedTo = loadMap.h["timesUsedTo"];
}
}
,__class__: buildings_Misdirector
});
var buildings_ModernArtMuseum = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.artSprite = null;
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.startTime = 9;
this.endTime = 22;
this.workTimePreferenceMod = 0.1;
this.isEntertainment = true;
this.artTextures = Resources.getTexturesByWidth("spr_modernart",20);
this.currentTexture = random_Random.getInt(city.progress.unlocks.numberOfModernArtMuseumArtworksUnlocked);
this.artSprite = new PIXI.Sprite(this.artTextures[this.currentTexture]);
this.artSprite.position.set(position.x,position.y);
bgStage.addChild(this.artSprite);
};
$hxClasses["buildings.ModernArtMuseum"] = buildings_ModernArtMuseum;
buildings_ModernArtMuseum.__name__ = "buildings.ModernArtMuseum";
buildings_ModernArtMuseum.__interfaces__ = [buildings_IEntertainmentBuilding];
buildings_ModernArtMuseum.__super__ = buildings_Work;
buildings_ModernArtMuseum.prototype = $extend(buildings_Work.prototype,{
get_baseEntertainmentCapacity: function() {
return this.workers.length * 100;
}
,get_isOpen: function() {
if(this.workers.length == 1 && this.workers[0].currentAction == LifeAction.Work) {
return this.city.simulation.time.timeSinceStart / 60 % 24 < 21.5;
} else {
return false;
}
}
,get_entertainmentType: function() {
return 2;
}
,get_minimumNormalTimeToSpend: function() {
return 2;
}
,get_maximumNormalTimeToSpend: function() {
return 3;
}
,get_minimumEntertainmentGroupSatisfy: function() {
return 2;
}
,get_maximumEntertainmentGroupSatisfy: function() {
return 3;
}
,get_entertainmentQuality: function() {
return 100;
}
,get_isOpenForExistingVisitors: function() {
return this.get_isOpen();
}
,finishEntertainment: function(citizen,timeMod) {
return true;
}
,onBuild: function() {
this.city.progress.unlocks.unlock(buildings_ArtColony);
}
,postLoad: function() {
this.artSprite.texture = this.artTextures[this.currentTexture];
}
,positionSprites: function() {
buildings_Work.prototype.positionSprites.call(this);
if(this.artSprite != null) {
this.artSprite.position.set(this.position.x,this.position.y);
}
}
,destroy: function() {
buildings_Work.prototype.destroy.call(this);
this.bgStage.removeChild(this.artSprite);
}
,beEntertained: function(citizen,timeMod) {
var moveFunction = function() {
var modifyWithHappiness = false;
var slowMove = true;
if(slowMove == null) {
slowMove = false;
}
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
citizen.moveAndWait(random_Random.getInt(3,16),random_Random.getInt(100,120),null,modifyWithHappiness,slowMove);
};
if(citizen.relativeY < 5) {
citizen.changeFloor(moveFunction);
} else {
moveFunction();
}
}
,createWindowAddBottomButtons: function() {
var _gthis = this;
gui_windowParts_CycleValueButton.create(this.city.gui,function() {
return _gthis.currentTexture;
},function(t) {
_gthis.currentTexture = t;
_gthis.artSprite.texture = _gthis.artTextures[_gthis.currentTexture];
},function() {
return _gthis.city.progress.unlocks.numberOfModernArtMuseumArtworksUnlocked;
},"Change Exhibition");
buildings_Work.prototype.createWindowAddBottomButtons.call(this);
}
,work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking) {
citizen.currentAction = LifeAction.Nothing;
} else if(citizen.relativeX >= 4 && citizen.relativeX < 6) {
if(random_Random.getInt(10) == 0) {
citizen.changeFloorAndWaitRandom(30,60,function() {
var slowMove = true;
if(slowMove == null) {
slowMove = false;
}
var moveToX = random_Random.getInt(14,15);
if(slowMove) {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[4].length > 0 ? pool[4].splice(pool[4].length - 1,1)[0] : new Int32Array(4);
arr[0] = 12;
arr[1] = 50;
arr[2] = 4;
arr[3] = moveToX;
citizen1.setPath(arr,0,4,true);
} else {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = moveToX;
citizen1.setPath(arr,0,2,true);
}
citizen.pathEndFunction = function() {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = random_Random.getInt(30,60);
citizen1.setPath(arr,0,2,true);
citizen.pathEndFunction = function() {
var slowMove = true;
if(slowMove == null) {
slowMove = false;
}
var moveToX = random_Random.getInt(4,6);
if(slowMove) {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[4].length > 0 ? pool[4].splice(pool[4].length - 1,1)[0] : new Int32Array(4);
arr[0] = 12;
arr[1] = 50;
arr[2] = 4;
arr[3] = moveToX;
citizen1.setPath(arr,0,4,true);
} else {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = moveToX;
citizen1.setPath(arr,0,2,true);
}
citizen.pathEndFunction = function() {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = random_Random.getInt(30,60);
citizen1.setPath(arr,0,2,true);
citizen.pathEndFunction = function() {
citizen.changeFloor();
};
citizen.pathOnlyRelatedTo = citizen.inPermanent;
};
citizen.pathOnlyRelatedTo = citizen.inPermanent;
};
citizen.pathOnlyRelatedTo = citizen.inPermanent;
};
citizen.pathOnlyRelatedTo = citizen.inPermanent;
});
} else {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = random_Random.getInt(30,60);
citizen1.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
} else {
var moveToX = random_Random.getInt(4,6);
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = moveToX;
citizen1.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Work.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_ModernArtMuseum.saveDefinition);
}
var value = this.currentTexture;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
,load: function(queue,definition) {
buildings_Work.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"currentTexture")) {
this.currentTexture = loadMap.h["currentTexture"];
}
this.postLoad();
}
,__class__: buildings_ModernArtMuseum
});
var buildings_ModernRusticHome = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.currentAdjBonus = 0;
buildings_House.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.adjecentBuildingEffects.push({ name : "modernRusticHomeCommunityFeeling", intensity : 1});
};
$hxClasses["buildings.ModernRusticHome"] = buildings_ModernRusticHome;
buildings_ModernRusticHome.__name__ = "buildings.ModernRusticHome";
buildings_ModernRusticHome.__super__ = buildings_House;
buildings_ModernRusticHome.prototype = $extend(buildings_House.prototype,{
get_possibleUpgrades: function() {
return [buildingUpgrades_ModernConveniences];
}
,onCityChange: function() {
var newAdjBonus = 0;
if(this.getEffectsOfAdjecentBuildings("modernRusticHomeCommunityFeeling") >= 3) {
newAdjBonus = 15;
}
this.bonusAttractiveness += newAdjBonus - this.currentAdjBonus;
if(newAdjBonus != (this.currentAdjBonus | 0)) {
this.city.simulation.houseAssigner.shouldUpdateHouses = true;
}
this.currentAdjBonus = newAdjBonus | 0;
}
,__class__: buildings_ModernRusticHome
});
var buildings_NightClub = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.knownEntertainedCitizenSet = 0;
this.knownEntertainedCitizen = null;
this.nightClubColor = 0;
this.nightClubEntertainmentQuantity = 0;
this.laserImages = Resources.getTexturesByWidth("spr_nightclub_laser",18);
this.lights = [];
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
var light = new PIXI.Sprite(Resources.getTexture("spr_nightclub_light"));
bgStage.addChild(light);
this.lights.push({ sprite : light, color : 0, alpha : 0, waiting : 1, alphaDir : 1});
light.alpha = 0.8;
var this1 = [150,1,0.5];
light.tint = thx_color_Rgb.toInt(thx_color_Hsl.toRgb(this1));
var light = new PIXI.Sprite(Resources.getTexture("spr_nightclub_light"));
bgStage.addChild(light);
this.lights.push({ sprite : light, color : 0, alpha : 0, waiting : 1, alphaDir : 1});
light.alpha = 0.8;
var this1 = [150,1,0.5];
light.tint = thx_color_Rgb.toInt(thx_color_Hsl.toRgb(this1));
this.laserStage = new PIXI.Container();
bgStage.addChild(this.laserStage);
this.laserStage.position.set(position.x,position.y);
this.lasers = [];
this.lasers.push({ start : new common_FPoint(2,3), end : new common_FPoint(6,18), hue : 180, speed : 1, targetLaserHue : -1, laserSprite : null});
this.lasers.push({ start : new common_FPoint(17,3), end : new common_FPoint(6,18), hue : 0, speed : -1, targetLaserHue : -1, laserSprite : null});
this.positionSprites();
this.startTime = 20;
this.endTime = 5.5;
this.workTimePreferenceMod = 0.5;
this.isEntertainment = true;
this.lightsAreOn = -1;
};
$hxClasses["buildings.NightClub"] = buildings_NightClub;
buildings_NightClub.__name__ = "buildings.NightClub";
buildings_NightClub.__interfaces__ = [buildings_IEntertainmentBuilding];
buildings_NightClub.__super__ = buildings_Work;
buildings_NightClub.prototype = $extend(buildings_Work.prototype,{
get_baseEntertainmentCapacity: function() {
return this.workers.length * (40 + this.nightClubEntertainmentQuantity);
}
,get_isOpen: function() {
if(this.workers.length == 1 && this.workers[0].currentAction == LifeAction.Work) {
var this1 = this.city.simulation.time.timeSinceStart / 60 % 24;
var start = this.startTime - this.workTimePreferenceMod;
if(start < 6) {
if(this1 >= start) {
return this1 < 6;
} else {
return false;
}
} else if(!(this1 >= start)) {
return this1 < 6;
} else {
return true;
}
} else {
return false;
}
}
,get_entertainmentType: function() {
return 0;
}
,get_minimumNormalTimeToSpend: function() {
return 5;
}
,get_maximumNormalTimeToSpend: function() {
return 7;
}
,get_minimumEntertainmentGroupSatisfy: function() {
return 1;
}
,get_maximumEntertainmentGroupSatisfy: function() {
return 3;
}
,get_entertainmentQuality: function() {
return 100;
}
,get_isOpenForExistingVisitors: function() {
return this.get_isOpen();
}
,finishEntertainment: function(citizen,timeMod) {
return true;
}
,get_possibleUpgrades: function() {
return [buildingUpgrades_BetterLightShow];
}
,get_drawerType: function() {
return buildings_buildingDrawers_AutoMergingBuildingDrawer;
}
,get_hasLeftNightClub: function() {
if(this.leftBuilding != null) {
return this.leftBuilding.is(buildings_NightClub);
} else {
return false;
}
}
,get_hasRightNightClub: function() {
if(this.rightBuilding != null) {
return this.rightBuilding.is(buildings_NightClub);
} else {
return false;
}
}
,postLoad: function() {
var _g = 0;
var _g1 = this.lights;
while(_g < _g1.length) {
var light = _g1[_g];
++_g;
if(this.nightClubColor == 3) {
light.sprite.texture = Resources.getTexture("spr_nightclub_light_rainbow");
}
}
}
,postCreate: function() {
buildings_Work.prototype.postCreate.call(this);
this.positionSprites();
}
,destroy: function() {
var _g = 0;
var _g1 = this.lights;
while(_g < _g1.length) {
var light = _g1[_g];
++_g;
this.bgStage.removeChild(light.sprite);
}
this.laserStage.destroy();
buildings_Work.prototype.destroy.call(this);
}
,work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking && this.city.simulation.time.timeSinceStart / 60 % 24 > 6) {
citizen.currentAction = LifeAction.Nothing;
} else if(this.get_hasLeftNightClub()) {
citizen.moveAndWait(random_Random.getInt(0,this.get_hasRightNightClub() ? 19 : 17),random_Random.getInt(20,50),null,false,false);
this.lightsAreOn = 60;
} else {
var spd = citizen.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
if(Math.abs(1 - citizen.relativeX) < spd) {
citizen.relativeX = 1;
} else {
var num = 1 - citizen.relativeX;
citizen.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
}
this.lightsAreOn = 3;
}
}
,beEntertained: function(citizen,timeMod) {
if(this.knownEntertainedCitizen == null) {
this.knownEntertainedCitizen = citizen;
this.knownEntertainedCitizenSet = 60;
} else if(this.knownEntertainedCitizen == citizen) {
this.knownEntertainedCitizenSet = 60;
}
var waitTimeMod;
switch(this.nightClubColor) {
case 1:
waitTimeMod = -3;
break;
case 2:
waitTimeMod = 3;
break;
case 4:
waitTimeMod = 3;
break;
default:
waitTimeMod = 0;
}
var goTo = random_Random.getInt(2 + (this.get_hasLeftNightClub() ? 1 : 0) + (this.get_hasRightNightClub() ? 1 : 0));
var canGoLR = this.nightClubColor != 4 || this.knownEntertainedCitizen != citizen;
if(this.get_hasLeftNightClub() && canGoLR && goTo == 0 && this.leftBuilding.get_isOpen()) {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[6].length > 0 ? pool[6].splice(pool[6].length - 1,1)[0] : new Int32Array(6);
arr[0] = 2;
arr[1] = 0;
arr[2] = 4;
arr[3] = random_Random.getInt(5,19);
arr[4] = 8;
arr[5] = random_Random.getInt(5,6);
citizen.setPath(arr,0,6,true);
} else if(this.get_hasRightNightClub() && canGoLR && goTo == 1 && this.rightBuilding.get_isOpen()) {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[6].length > 0 ? pool[6].splice(pool[6].length - 1,1)[0] : new Int32Array(6);
arr[0] = 3;
arr[1] = 0;
arr[2] = 4;
arr[3] = random_Random.getInt(0,17);
arr[4] = 8;
arr[5] = random_Random.getInt(5,6);
citizen.setPath(arr,0,6,true);
} else {
var xMin = this.get_hasLeftNightClub() ? 0 : 5;
var xMax = this.get_hasRightNightClub() ? 19 : 17;
var modifyWithHappiness = false;
var slowMove = this.nightClubColor == 2 || this.nightClubColor == 4;
if(slowMove == null) {
slowMove = false;
}
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
citizen.moveAndWait(random_Random.getInt(xMin,xMax),random_Random.getInt(5 + waitTimeMod,6 + waitTimeMod),null,modifyWithHappiness,slowMove);
}
if(!citizen.hasBuildingInited) {
citizen.wantsNightEntertainmentIn = random_Random.getInt(1,5);
citizen.hasBuildingInited = true;
}
}
,positionSprites: function() {
buildings_Work.prototype.positionSprites.call(this);
if(this.lights.length >= 2) {
this.lights[0].sprite.position.set(this.position.x + 5,this.position.y + 4);
this.lights[1].sprite.position.set(this.position.x + 10,this.position.y + 4);
}
this.laserStage.position.set(this.position.x,this.position.y);
}
,createWindowAddBottomButtons: function() {
var _gthis = this;
if(Settings.hasSecretCode("nightClubColors")) {
var cycleButton = gui_windowParts_CycleValueButton.create(this.city.gui,function() {
return _gthis.nightClubColor;
},function(t) {
_gthis.nightClubColor = t;
if(_gthis.nightClubColor == 0) {
_gthis.lasers[0].hue = 0;
_gthis.lasers[1].hue = 180;
if(_gthis.lasers.length >= 4) {
_gthis.lasers[2].hue = 90;
_gthis.lasers[3].hue = 270;
}
}
var _g = 0;
var _g1 = _gthis.lasers;
while(_g < _g1.length) {
var laser = _g1[_g];
++_g;
laser.targetLaserHue = -1;
}
var _g = 0;
var _g1 = _gthis.lights;
while(_g < _g1.length) {
var light = _g1[_g];
++_g;
if(_gthis.nightClubColor == 3) {
light.sprite.texture = Resources.getTexture("spr_nightclub_light_rainbow");
} else {
light.sprite.texture = Resources.getTexture("spr_nightclub_light");
}
}
},function() {
return 5;
},null,function() {
var cycleButton;
switch(_gthis.nightClubColor) {
case 0:
cycleButton = "Colorful";
break;
case 1:
cycleButton = "Fast & Red";
break;
case 2:
cycleButton = "Slow & Blue";
break;
case 3:
cycleButton = "Rainbow Light";
break;
case 4:
cycleButton = "Romantic & Pink";
break;
default:
cycleButton = "";
}
return "Change Light Show (" + cycleButton + ")";
});
}
buildings_Work.prototype.createWindowAddBottomButtons.call(this);
}
,update: function(timeMod) {
buildings_Work.prototype.update.call(this,timeMod);
this.lightsAreOn -= Math.min(1,timeMod);
if(this.lightsAreOn <= 0 && !(this.workers.length >= 1 && this.workers[0].inPermanent == this && this.workers[0].currentAction == LifeAction.Work)) {
var _g = 0;
var _g1 = this.lights;
while(_g < _g1.length) {
var l = _g1[_g];
++_g;
l.sprite.alpha = 0;
}
var _g = 0;
var _g1 = this.lasers;
while(_g < _g1.length) {
var l = _g1[_g];
++_g;
if(l.laserSprite != null) {
l.laserSprite.destroy();
l.laserSprite = null;
}
}
return;
}
var _g = 0;
var _g1 = this.lasers;
while(_g < _g1.length) {
var laser = _g1[_g];
++_g;
if(this.nightClubColor == 4 && this.workers.length > 0 && this.workers[0].inPermanent == this && this.get_hasLeftNightClub()) {
if(this.knownEntertainedCitizenSet >= 0) {
if(this.knownEntertainedCitizen != null && this.knownEntertainedCitizen.inPermanent == this && !this.knownEntertainedCitizen.hasDied) {
laser.end.x = this.knownEntertainedCitizen.relativeX;
}
} else {
laser.end.x = this.workers[0].relativeX;
}
} else {
laser.end.x += timeMod * laser.speed;
if(laser.speed > 0) {
if(laser.end.x > 18) {
laser.end.x = 18;
laser.speed = -laser.speed;
}
} else if(laser.end.x < (this.get_hasLeftNightClub() ? 1 : 6)) {
var tmp = this.get_hasLeftNightClub() ? 1 : 6;
laser.end.x = tmp;
laser.speed = -laser.speed;
}
}
switch(this.nightClubColor) {
case 0:
laser.hue += timeMod;
if(laser.hue > 360) {
laser.hue -= 360;
}
break;
case 1:
laser.hue = 0;
break;
case 2:
if(laser.targetLaserHue == -1 || Math.abs(laser.hue - laser.targetLaserHue) < timeMod / 2) {
laser.targetLaserHue = random_Random.getInt(170,245);
}
var spd = 1;
if(laser.hue > 245 || laser.hue < 170) {
spd = 12;
}
var num = laser.targetLaserHue - laser.hue;
laser.hue += (num > 0 ? 1 : num < 0 ? -1 : 0) * 0.5 * timeMod * spd;
break;
case 3:
if(laser.targetLaserHue == -1 || Math.abs(laser.hue - laser.targetLaserHue) < timeMod) {
laser.targetLaserHue = random_Random.getInt(360);
}
var num1 = laser.targetLaserHue - laser.hue;
laser.hue += (num1 > 0 ? 1 : num1 < 0 ? -1 : 0) * timeMod;
break;
case 4:
if(laser.targetLaserHue == -1 || Math.abs(laser.hue - laser.targetLaserHue) < timeMod / 2) {
laser.targetLaserHue = random_Random.getInt(270,330);
}
var spd1 = 1;
if(laser.hue > 330 || laser.hue < 270) {
spd1 = 12;
}
var num2 = laser.targetLaserHue - laser.hue;
laser.hue += (num2 > 0 ? 1 : num2 < 0 ? -1 : 0) * 0.5 * timeMod * spd1;
break;
}
if(random_Random.getInt(20) == 0) {
switch(this.nightClubColor) {
case 1:
var num3 = laser.speed;
laser.speed = (num3 > 0 ? 1 : num3 < 0 ? -1 : 0) * random_Random.getFloat(1,2);
break;
case 2:
var num4 = laser.speed;
laser.speed = (num4 > 0 ? 1 : num4 < 0 ? -1 : 0) * random_Random.getFloat(0.5,0.8);
break;
case 4:
var num5 = laser.speed;
laser.speed = (num5 > 0 ? 1 : num5 < 0 ? -1 : 0) * random_Random.getFloat(0.5,0.8);
break;
default:
var num6 = laser.speed;
laser.speed = (num6 > 0 ? 1 : num6 < 0 ? -1 : 0) * random_Random.getFloat(0.5,1.5);
}
}
if(laser.laserSprite == null) {
laser.laserSprite = new PIXI.Sprite();
this.laserStage.addChild(laser.laserSprite);
}
var val = Math.floor(Math.abs(laser.end.x - laser.start.x));
laser.laserSprite.texture = this.laserImages[val < 0 ? 0 : val > 17 ? 17 : val];
laser.laserSprite.position.y = laser.start.y;
var this1 = [laser.hue,0.7,1];
var tmp1 = thx_color_Hsv.toRgb(this1);
laser.laserSprite.tint = common_ColorExtensions.toHexInt(tmp1);
if(laser.end.x < laser.start.x) {
laser.laserSprite.position.set(laser.start.x + 1,laser.start.y);
laser.laserSprite.scale.x = -1;
} else {
laser.laserSprite.position.set(laser.start.x,laser.start.y);
laser.laserSprite.scale.x = 1;
}
}
var _g = 0;
var _g1 = this.lights;
while(_g < _g1.length) {
var light = _g1[_g];
++_g;
if(light.alpha > 0) {
light.alpha += light.alphaDir * 0.1 * (this.nightClubColor == 4 ? 0.25 : 1);
if(light.alpha > 1) {
light.alpha = 1;
light.alphaDir = -1;
} else if(light.alpha <= 0) {
light.alpha = 0;
if(this.nightClubColor == 1 || this.nightClubColor == 3) {
light.waiting = random_Random.getInt(30);
} else {
light.waiting = random_Random.getInt(60);
}
}
light.sprite.alpha = light.alpha;
} else if(light.waiting > 0) {
light.waiting -= timeMod;
} else {
light.waiting = 0;
light.alpha = 0.01;
light.alphaDir = 1;
switch(this.nightClubColor) {
case 0:
var this1 = [random_Random.getInt(360),0.8,0.5];
var tmp = thx_color_Hsl.toRgb(this1);
light.sprite.tint = thx_color_Rgb.toInt(tmp);
break;
case 1:
var this2 = [random_Random.getInt(60),0.8,0.6];
var tmp1 = thx_color_Hsl.toRgb(this2);
light.sprite.tint = thx_color_Rgb.toInt(tmp1);
break;
case 2:
var this3 = [random_Random.getInt(170,245),0.8,0.7];
var tmp2 = thx_color_Hsl.toRgb(this3);
light.sprite.tint = thx_color_Rgb.toInt(tmp2);
break;
case 3:
light.sprite.tint = 16777215;
break;
case 4:
var this4 = [random_Random.getInt(270,330),0.8,0.7];
var tmp3 = thx_color_Hsl.toRgb(this4);
light.sprite.tint = thx_color_Rgb.toInt(tmp3);
break;
}
}
}
if(this.knownEntertainedCitizenSet >= 0) {
this.knownEntertainedCitizenSet -= timeMod;
if(this.knownEntertainedCitizenSet < 0) {
this.knownEntertainedCitizen = null;
}
}
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Work.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_NightClub.saveDefinition);
}
var value = this.nightClubColor;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
,load: function(queue,definition) {
buildings_Work.prototype.load.call(this,queue);
if(queue.version < 15) {
return;
}
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"nightClubColor")) {
this.nightClubColor = loadMap.h["nightClubColor"];
}
this.postLoad();
}
,__class__: buildings_NightClub
});
var buildings_NormalHouse = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.doorMainTexture = 0;
buildings_House.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.doorTextures = Resources.getTexturesByWidth("spr_coloreddoors",20);
this.makeDoorSpriteIfNeeded();
};
$hxClasses["buildings.NormalHouse"] = buildings_NormalHouse;
buildings_NormalHouse.__name__ = "buildings.NormalHouse";
buildings_NormalHouse.__super__ = buildings_House;
buildings_NormalHouse.prototype = $extend(buildings_House.prototype,{
get_possibleUpgrades: function() {
return [buildingUpgrades_Flowers];
}
,positionSprites: function() {
buildings_House.prototype.positionSprites.call(this);
if(this.doorSprite != null) {
this.doorSprite.position.set(this.position.x,this.position.y);
if(this.worldPosition.y != 0) {
this.stage.removeChild(this.doorSprite);
this.doorSprite = null;
}
} else {
this.makeDoorSpriteIfNeeded();
}
}
,postLoad: function() {
if(this.doorSprite != null) {
this.doorSprite.texture = this.doorTextures[this.doorMainTexture];
}
}
,makeDoorSpriteIfNeeded: function() {
if(this.doorSprite == null) {
if(this.worldPosition.y == 0) {
this.doorSprite = new PIXI.Sprite(this.doorTextures[this.doorMainTexture]);
this.doorSprite.position.set(this.position.x,this.position.y);
this.stage.addChild(this.doorSprite);
}
}
}
,createWindowAddBottomButtons: function() {
var _gthis = this;
if(this.doorSprite != null) {
var cycleButton = gui_windowParts_CycleValueButton.create(this.city.gui,function() {
return _gthis.doorMainTexture;
},function(t) {
if(_gthis.doorSprite != null) {
_gthis.doorMainTexture = t;
_gthis.doorSprite.texture = _gthis.doorTextures[_gthis.doorMainTexture];
}
},function() {
return _gthis.doorTextures.length;
},"Change Door Color");
cycleButton.onUpdate = function() {
if(_gthis.doorSprite == null) {
_gthis.city.gui.windowInner.removeChild(cycleButton);
}
};
}
buildings_House.prototype.createWindowAddBottomButtons.call(this);
}
,destroy: function() {
if(this.doorSprite != null) {
this.stage.removeChild(this.doorSprite);
}
buildings_House.prototype.destroy.call(this);
}
,addWindowInfoLines: function() {
buildings_House.prototype.addWindowInfoLines.call(this);
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_House.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_NormalHouse.saveDefinition);
}
var value = this.doorMainTexture;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
,load: function(queue,definition) {
buildings_House.prototype.load.call(this,queue);
if(queue.version < 18) {
return;
}
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"doorMainTexture")) {
this.doorMainTexture = loadMap.h["doorMainTexture"];
}
this.postLoad();
}
,__class__: buildings_NormalHouse
});
var buildings_Observatory = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.hasStarDatabase = false;
this.totalKnowledgeGenerated = 0;
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.startTime = 21;
this.endTime = 4;
};
$hxClasses["buildings.Observatory"] = buildings_Observatory;
buildings_Observatory.__name__ = "buildings.Observatory";
buildings_Observatory.__super__ = buildings_Work;
buildings_Observatory.prototype = $extend(buildings_Work.prototype,{
get_possibleUpgrades: function() {
return [buildingUpgrades_StarDatabase];
}
,work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking) {
citizen.currentAction = LifeAction.Nothing;
} else {
switch(this.workers.indexOf(citizen)) {
case 0:
var spd = citizen.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
if(Math.abs(5 - citizen.relativeX) < spd) {
citizen.relativeX = 5;
} else {
var num = 5 - citizen.relativeX;
citizen.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
}
break;
case 1:
var spd = citizen.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
if(Math.abs(13 - citizen.relativeX) < spd) {
citizen.relativeX = 13;
} else {
var num = 13 - citizen.relativeX;
citizen.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
}
break;
case 2:
var spd = citizen.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
if(Math.abs(9 - citizen.relativeX) < spd) {
citizen.relativeX = 9;
} else {
var num = 9 - citizen.relativeX;
citizen.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
}
break;
}
var currentKnowledgePerStep = 0.002 * (this.hasStarDatabase ? this.city.upgrades.vars.starDatabaseIsMoreEffective ? 6 : 1.5 : 1);
var newKnowledge = currentKnowledgePerStep * timeMod * this.city.simulation.happiness.actionSpeedModifier * this.city.simulation.bonuses.labSpeed * citizen.get_educationSpeedModifier() * this.city.simulation.boostManager.currentGlobalBoostAmount;
this.city.materials.knowledge += newKnowledge;
this.city.simulation.stats.materialProduction[8][0] += newKnowledge;
this.totalKnowledgeGenerated += newKnowledge;
}
}
,addWindowInfoLines: function() {
var _gthis = this;
buildings_Work.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
return "" + (_gthis.totalKnowledgeGenerated | 0) + " knowledge gathered.";
});
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Work.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_Observatory.saveDefinition);
}
var value = this.totalKnowledgeGenerated;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
}
,load: function(queue,definition) {
buildings_Work.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"totalKnowledgeGenerated")) {
this.totalKnowledgeGenerated = loadMap.h["totalKnowledgeGenerated"];
}
}
,__class__: buildings_Observatory
});
var buildings_OutpostHouse = function(game,stage,bgStage,city,world,position,worldPosition,id) {
buildings_House.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
};
$hxClasses["buildings.OutpostHouse"] = buildings_OutpostHouse;
buildings_OutpostHouse.__name__ = "buildings.OutpostHouse";
buildings_OutpostHouse.__super__ = buildings_House;
buildings_OutpostHouse.prototype = $extend(buildings_House.prototype,{
destroy: function() {
buildings_House.prototype.destroy.call(this);
}
,addWindowInfoLines: function() {
buildings_House.prototype.addWindowInfoLines.call(this);
}
,__class__: buildings_OutpostHouse
});
var buildings_Park = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.festivalJobs = 2;
this.parkSprite = null;
this.currentMainTexture = 0;
Building.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.isEntertainment = true;
this.parkTextures = Resources.getTexturesByWidth(this.get_myParkTextures(),20);
this.currentTexture = random_Random.getInt(this.parkTextures.length - this.get_numberOfLockedParkTextures());
this.parkSprite = new PIXI.Sprite(this.parkTextures[this.currentTexture]);
this.parkSprite.position.set(position.x,position.y);
bgStage.cacheableChildren.push(this.parkSprite);
bgStage.isInvalid = true;
this.adjecentBuildingEffects.push({ name : "modernRusticHomeCommunityFeeling", intensity : 1});
this.festivalEntertainment = null;
};
$hxClasses["buildings.Park"] = buildings_Park;
buildings_Park.__name__ = "buildings.Park";
buildings_Park.__interfaces__ = [buildings_IBuildingWithFestivalSpecials,buildings_IEntertainmentBuilding];
buildings_Park.__super__ = Building;
buildings_Park.prototype = $extend(Building.prototype,{
get_myParkTextures: function() {
return "spr_park_plants";
}
,get_changePlantsText: function() {
return "Change Plants";
}
,get_baseEntertainmentCapacity: function() {
return 30;
}
,get_isOpen: function() {
var this1 = this.city.simulation.time.timeSinceStart / 60 % 24;
if(this1 >= 6.0) {
return this1 < 22;
} else {
return false;
}
}
,get_entertainmentType: function() {
return 3;
}
,get_minimumNormalTimeToSpend: function() {
return 1.5;
}
,get_maximumNormalTimeToSpend: function() {
return 2.5;
}
,get_minimumEntertainmentGroupSatisfy: function() {
return 1;
}
,get_maximumEntertainmentGroupSatisfy: function() {
return 1.75;
}
,get_entertainmentQuality: function() {
return 100;
}
,get_isOpenForExistingVisitors: function() {
return this.get_isOpen();
}
,finishEntertainment: function(citizen,timeMod) {
return true;
}
,get_drawerType: function() {
return buildings_buildingDrawers_AutoMergingBuildingDrawer;
}
,get_numberOfLockedParkTextures: function() {
if(Settings.hasSecretCode("orchid")) {
return 0;
} else {
return 3;
}
}
,postLoad: function() {
this.parkSprite.texture = this.parkTextures[this.currentTexture];
this.bgStage.isInvalid = true;
this.changeMainTexture(buildings_Park.mainTextures[this.currentMainTexture]);
}
,postCreate: function() {
Building.prototype.postCreate.call(this);
this.positionSprites();
}
,positionSprites: function() {
Building.prototype.positionSprites.call(this);
if(this.parkSprite != null) {
this.parkSprite.position.set(this.position.x,this.position.y);
this.bgStage.isInvalid = true;
}
}
,beEntertained: function(citizen,timeMod) {
buildings_buildingBehaviours_ParkWalk.beEntertainedPark(this.leftBuilding,this.rightBuilding,citizen);
}
,createWindowAddBottomButtons: function() {
var _gthis = this;
gui_windowParts_CycleValueButton.create(this.city.gui,function() {
return _gthis.currentMainTexture;
},function(t) {
_gthis.currentMainTexture = t;
_gthis.changeMainTexture(buildings_Park.mainTextures[_gthis.currentMainTexture]);
},function() {
return buildings_Park.mainTextures.length;
},"Change Building Color");
gui_windowParts_CycleValueButton.create(this.city.gui,function() {
return _gthis.currentTexture;
},function(t) {
_gthis.currentTexture = t;
_gthis.parkSprite.texture = _gthis.parkTextures[_gthis.currentTexture];
_gthis.bgStage.isInvalid = true;
},function() {
return _gthis.parkTextures.length - _gthis.get_numberOfLockedParkTextures();
},this.get_changePlantsText());
Building.prototype.createWindowAddBottomButtons.call(this);
}
,destroy: function() {
Building.prototype.destroy.call(this);
if(this.festivalEntertainment != null) {
this.festivalEntertainment.destroy();
}
var _this = this.bgStage;
var child = this.parkSprite;
HxOverrides.remove(_this.cacheableChildren,child);
_this.isInvalid = true;
if(child.parent != null) {
child.parent.removeChild(child);
}
}
,initFestival: function() {
if(this.festivalEntertainment == null) {
this.festivalEntertainment = new buildings_buildingBehaviours_ParkFestivalEntertainment(this,this.bgStage);
}
}
,stopFestival: function() {
if(this.festivalEntertainment != null) {
this.festivalEntertainment.stop();
this.festivalEntertainment.destroy();
this.festivalEntertainment = null;
}
}
,doFestivalWork: function(festival,citizen,timeMod,citizenID) {
this.festivalEntertainment.doFestivalWork(festival,citizen,timeMod,this.currentMainTexture,citizenID);
}
,beEntertainedFestival: function(festival,citizen,timeMod) {
this.festivalEntertainment.beEntertainedFestival(festival,citizen,timeMod);
}
,endFestivalWork: function(festival,citizen) {
citizen.setRelativeY(0);
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
Building.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_Park.saveDefinition);
}
var value = this.currentTexture;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.currentMainTexture;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
,load: function(queue,definition) {
Building.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"currentTexture")) {
this.currentTexture = loadMap.h["currentTexture"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"currentMainTexture")) {
this.currentMainTexture = loadMap.h["currentMainTexture"];
}
this.postLoad();
}
,__class__: buildings_Park
});
var buildings_ParkPod = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.parkSprite = null;
this.currentMainTexture = 0;
buildings_House.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.parkTextures = Resources.getTexturesByWidth("spr_parkpod",20);
this.currentTexture = random_Random.getInt(this.parkTextures.length);
this.parkSprite = new PIXI.Sprite(this.parkTextures[this.currentTexture]);
this.parkSprite.position.set(position.x,position.y);
bgStage.addChild(this.parkSprite);
this.adjecentBuildingEffects.push({ name : "modernRusticHomeCommunityFeeling", intensity : 1});
};
$hxClasses["buildings.ParkPod"] = buildings_ParkPod;
buildings_ParkPod.__name__ = "buildings.ParkPod";
buildings_ParkPod.__super__ = buildings_House;
buildings_ParkPod.prototype = $extend(buildings_House.prototype,{
get_drawerType: function() {
return buildings_buildingDrawers_AutoMergingBuildingDrawer;
}
,postLoad: function() {
this.parkSprite.texture = this.parkTextures[this.currentTexture];
this.changeMainTexture(buildings_ParkPod.mainTextures[this.currentMainTexture]);
}
,postCreate: function() {
buildings_House.prototype.postCreate.call(this);
this.positionSprites();
}
,positionSprites: function() {
buildings_House.prototype.positionSprites.call(this);
if(this.parkSprite != null) {
this.parkSprite.position.set(this.position.x,this.position.y);
}
}
,beEntertained: function(citizen,timeMod) {
var leftPark = this.leftBuilding != null && this.leftBuilding.is(buildings_Park);
var rightPark = this.rightBuilding != null && this.rightBuilding.is(buildings_Park);
var goTo = random_Random.getInt(1 + (leftPark ? 1 : 0) + (rightPark ? 1 : 0));
if(leftPark && goTo == 0) {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[8].length > 0 ? pool[8].splice(pool[8].length - 1,1)[0] : new Int32Array(8);
arr[0] = 12;
arr[1] = 50;
arr[2] = 2;
arr[3] = 0;
arr[4] = 4;
arr[5] = random_Random.getInt(0,18);
arr[6] = 8;
arr[7] = random_Random.getInt(100,180);
citizen.setPath(arr,0,8,true);
} else if(rightPark && goTo == 1) {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[8].length > 0 ? pool[8].splice(pool[8].length - 1,1)[0] : new Int32Array(8);
arr[0] = 12;
arr[1] = 50;
arr[2] = 3;
arr[3] = 0;
arr[4] = 4;
arr[5] = random_Random.getInt(0,18);
arr[6] = 8;
arr[7] = random_Random.getInt(100,180);
citizen.setPath(arr,0,8,true);
} else {
var modifyWithHappiness = false;
var slowMove = true;
if(slowMove == null) {
slowMove = false;
}
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
citizen.moveAndWait(random_Random.getInt(leftPark ? 0 : 3,rightPark ? 18 : 15),random_Random.getInt(100,180),null,modifyWithHappiness,slowMove);
}
}
,createWindowAddBottomButtons: function() {
var _gthis = this;
gui_windowParts_CycleValueButton.create(this.city.gui,function() {
return _gthis.currentMainTexture;
},function(t) {
_gthis.currentMainTexture = t;
_gthis.changeMainTexture(buildings_ParkPod.mainTextures[_gthis.currentMainTexture]);
},function() {
return buildings_ParkPod.mainTextures.length;
},"Change Building Color");
gui_windowParts_CycleValueButton.create(this.city.gui,function() {
return _gthis.currentTexture;
},function(t) {
_gthis.currentTexture = t;
_gthis.parkSprite.texture = _gthis.parkTextures[_gthis.currentTexture];
},function() {
return _gthis.parkTextures.length;
},"Change Variant");
buildings_House.prototype.createWindowAddBottomButtons.call(this);
}
,destroy: function() {
buildings_House.prototype.destroy.call(this);
this.bgStage.removeChild(this.parkSprite);
}
,walkAround: function(citizen,stepsInBuilding) {
if(citizen.relativeX == 9) {
citizen.canViewSelfInBuilding = false;
} else {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = 9;
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_House.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_ParkPod.saveDefinition);
}
var value = this.currentTexture;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.currentMainTexture;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
,load: function(queue,definition) {
buildings_House.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"currentTexture")) {
this.currentTexture = loadMap.h["currentTexture"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"currentMainTexture")) {
this.currentMainTexture = loadMap.h["currentMainTexture"];
}
this.postLoad();
}
,__class__: buildings_ParkPod
});
var buildings_Pub = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.markingTexture = "";
this.marking = null;
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.startTime = 20;
this.endTime = 5.5;
this.workTimePreferenceMod = 0.5;
this.isEntertainment = true;
};
$hxClasses["buildings.Pub"] = buildings_Pub;
buildings_Pub.__name__ = "buildings.Pub";
buildings_Pub.__interfaces__ = [buildings_IEntertainmentBuilding];
buildings_Pub.__super__ = buildings_Work;
buildings_Pub.prototype = $extend(buildings_Work.prototype,{
get_baseEntertainmentCapacity: function() {
return this.workers.length * 50;
}
,get_isOpen: function() {
var tmp;
if(this.workers.length == 1 && this.workers[0].currentAction == LifeAction.Work) {
var this1 = this.city.simulation.time.timeSinceStart / 60 % 24;
var start = this.startTime - this.workTimePreferenceMod;
tmp = start < 4.5 ? this1 >= start && this1 < 4.5 : this1 >= start || this1 < 4.5;
} else {
tmp = false;
}
if(tmp) {
return this.marking == null;
} else {
return false;
}
}
,get_entertainmentType: function() {
return 1;
}
,get_minimumNormalTimeToSpend: function() {
return 2;
}
,get_maximumNormalTimeToSpend: function() {
return 6;
}
,get_minimumEntertainmentGroupSatisfy: function() {
return 1;
}
,get_maximumEntertainmentGroupSatisfy: function() {
return 3;
}
,get_entertainmentQuality: function() {
return 100;
}
,get_isOpenForExistingVisitors: function() {
return this.get_isOpen();
}
,finishEntertainment: function(citizen,timeMod) {
return true;
}
,postLoad: function() {
if(this.markingTexture != "") {
this.setMarking(this.markingTexture);
}
}
,destroy: function() {
buildings_Work.prototype.destroy.call(this);
if(this.marking != null) {
this.stage.removeChild(this.marking);
}
}
,positionSprites: function() {
buildings_Work.prototype.positionSprites.call(this);
if(this.marking != null) {
this.marking.position.set(this.position.x + 2,this.position.y + 10);
}
}
,setMarking: function(markingTexture) {
this.markingTexture = markingTexture;
if(this.marking == null) {
this.marking = new PIXI.Sprite(Resources.getTexture(markingTexture));
}
this.marking.texture = Resources.getTexture(markingTexture);
this.marking.position.set(this.position.x + 2,this.position.y + 10);
this.stage.addChild(this.marking);
}
,beEntertained: function(citizen,timeMod) {
var moveFunction = function() {
var moveToX = random_Random.getInt(7,16);
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = moveToX;
citizen1.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
};
if(citizen.relativeY < 5) {
citizen.changeFloor(moveFunction);
} else {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = random_Random.getInt(120,180);
citizen1.setPath(arr,0,2,true);
citizen.pathEndFunction = moveFunction;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
if(!citizen.hasBuildingInited) {
citizen.wantsNightEntertainmentIn = random_Random.getInt(1,5);
citizen.hasBuildingInited = true;
}
}
,work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking && this.city.simulation.time.timeSinceStart / 60 % 24 > 4.5) {
citizen.currentAction = LifeAction.Nothing;
} else if(citizen.relativeY < 5) {
citizen.changeFloor();
} else {
var spd = citizen.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
if(Math.abs(3 - citizen.relativeX) < spd) {
citizen.relativeX = 3;
} else {
var num = 3 - citizen.relativeX;
citizen.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
}
}
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Work.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_Pub.saveDefinition);
}
queue.addString(this.markingTexture);
}
,load: function(queue,definition) {
buildings_Work.prototype.load.call(this,queue);
if(queue.version < 7) {
return;
}
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"markingTexture")) {
this.markingTexture = loadMap.h["markingTexture"];
}
this.postLoad();
}
,__class__: buildings_Pub
});
var buildings_Restaurant = function(game,stage,bgStage,city,world,position,worldPosition,id) {
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.startTime = 16;
this.endTime = 1;
this.workTimePreferenceMod = 0.5;
this.isEntertainment = true;
};
$hxClasses["buildings.Restaurant"] = buildings_Restaurant;
buildings_Restaurant.__name__ = "buildings.Restaurant";
buildings_Restaurant.__interfaces__ = [buildings_IEntertainmentBuilding];
buildings_Restaurant.__super__ = buildings_Work;
buildings_Restaurant.prototype = $extend(buildings_Work.prototype,{
get_baseEntertainmentCapacity: function() {
var bec = 45;
bec += this.getEffectsOfAdjecentBuildingsLR("restaurantCapBoost");
return this.workers.length * bec | 0;
}
,get_isOpen: function() {
if(this.workers.length >= 1 && this.workers[0].currentAction == LifeAction.Work) {
var this1 = this.city.simulation.time.timeSinceStart / 60 % 24;
var start = this.startTime - this.workTimePreferenceMod;
if(start < 0.5) {
if(this1 >= start) {
return this1 < 0.5;
} else {
return false;
}
} else if(!(this1 >= start)) {
return this1 < 0.5;
} else {
return true;
}
} else {
return false;
}
}
,get_entertainmentType: function() {
return 1;
}
,get_minimumNormalTimeToSpend: function() {
return 1;
}
,get_maximumNormalTimeToSpend: function() {
return 3;
}
,get_minimumEntertainmentGroupSatisfy: function() {
return 1;
}
,get_maximumEntertainmentGroupSatisfy: function() {
return 3;
}
,get_entertainmentQuality: function() {
return 100;
}
,get_isOpenForExistingVisitors: function() {
return this.get_isOpen();
}
,finishEntertainment: function(citizen,timeMod) {
return true;
}
,get_drawerType: function() {
return buildings_buildingDrawers_AutoMergingBuildingDrawer;
}
,beEntertained: function(citizen,timeMod) {
if(!citizen.hasBuildingInited) {
var hasLeftRestaurant = this.leftBuilding != null && this.leftBuilding.is(buildings_Restaurant);
var hasRightRestaurant = this.rightBuilding != null && this.rightBuilding.is(buildings_Restaurant);
var getTopTable = function() {
var i = random_Random.getInt(3 + (hasRightRestaurant ? 1 : 0));
switch(i) {
case 0:
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = 4;
citizen1.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
break;
case 1:
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = 7;
citizen1.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
break;
case 2:
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = 14;
citizen1.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
break;
case 3:
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = 17;
citizen1.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
break;
}
};
citizen.wantsNightEntertainmentIn = random_Random.getInt(1,5);
citizen.hasBuildingInited = true;
if(citizen.relativeY <= 5) {
if(random_Random.getInt(3) <= 1) {
citizen.changeFloor(getTopTable);
} else if(hasLeftRestaurant) {
if(random_Random.getInt(2) == 0) {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = 1;
citizen1.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
} else {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = 6;
citizen1.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
} else if(random_Random.getInt(2) == 0) {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = 3;
citizen1.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
} else {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = 6;
citizen1.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
} else {
getTopTable();
}
} else {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = random_Random.getInt(30,60);
citizen1.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
}
,work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking && this.city.simulation.time.timeSinceStart / 60 % 24 > 0.5) {
citizen.currentAction = LifeAction.Nothing;
} else {
switch(this.workers.indexOf(citizen)) {
case 0:
if(citizen.relativeY > 5) {
citizen.changeFloor();
} else {
var spd = citizen.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
if(Math.abs(12 - citizen.relativeX) < spd) {
citizen.relativeX = 12;
} else {
var num = 12 - citizen.relativeX;
citizen.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
}
}
break;
case 1:
if(citizen.relativeY < 5) {
citizen.changeFloor();
} else {
var hasLeftRestaurant = this.leftBuilding != null && this.leftBuilding.is(buildings_Restaurant);
var hasRightRestaurant = this.rightBuilding != null && this.rightBuilding.is(buildings_Restaurant);
citizen.moveAndWait(random_Random.getInt(hasLeftRestaurant ? 0 : 3,hasRightRestaurant ? 19 : 16),random_Random.getInt(60,90),null,false,false);
}
break;
}
}
}
,__class__: buildings_Restaurant
});
var buildings_School = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.schoolEndTime = 16;
this.schoolStartTime = 7;
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.students = [];
};
$hxClasses["buildings.School"] = buildings_School;
buildings_School.__name__ = "buildings.School";
buildings_School.__super__ = buildings_Work;
buildings_School.prototype = $extend(buildings_Work.prototype,{
get_studentCapacity: function() {
return Math.round(this.city.policies.vars.schoolClassSizeMod * 30);
}
,get_educationPerDay: function() {
return 0.07 * this.city.policies.vars.schoolMaxEdu;
}
,get_educationCap: function() {
return this.city.policies.vars.schoolMaxEdu;
}
,work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking) {
citizen.currentAction = LifeAction.Nothing;
return;
}
var spd = citizen.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
if(Math.abs(3 - citizen.relativeX) < spd) {
citizen.relativeX = 3;
} else {
var num = 3 - citizen.relativeX;
citizen.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
}
}
,addWindowInfoLines: function() {
var _gthis = this;
buildings_Work.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
return "" + _gthis.students.length + "/" + _gthis.get_studentCapacity() + " students";
});
}
,destroy: function() {
buildings_Work.prototype.destroy.call(this);
var i = this.students.length;
while(--i >= 0) {
var student = this.students[i];
student.leaveSchool();
}
}
,afterGiveJob: function(citizen) {
this.city.simulation.schoolAssigner.schoolsShouldBeUpdated = true;
}
,beAtSchool: function(citizen,timeMod) {
if(!citizen.hasBuildingInited) {
var i = this.students.indexOf(citizen);
switch(i % 3) {
case 0:
var moveToX = random_Random.getInt(6,7);
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = moveToX;
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
break;
case 1:
citizen.changeFloorAndMoveRandom(3,7);
break;
case 2:
var moveToX = random_Random.getInt(12,16);
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = moveToX;
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
break;
}
var amount = this.get_educationPerDay();
var cap = this.get_educationCap();
citizen.educationLevel = Math.max(Math.min(citizen.educationLevel + amount,cap),citizen.educationLevel);
citizen.hasBuildingInited = true;
}
}
,__class__: buildings_School
});
var buildings_ScrapyardNightClub = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.isCurrentlyActive = false;
this.mainTextureOther = 0;
this.mainTextureLeft = 0;
this.lightsAreOn = -1;
this.knownEntertainedCitizenSet = 0;
this.knownEntertainedCitizen = null;
this.hadLeftNightClub = false;
this.nightClubEntertainmentQuantity = 0;
this.mainTexturesLeft = Resources.getTexturesByWidth("spr_synightclub_lefttextures",20);
this.mainTextures = Resources.getTexturesByWidth("spr_synightclub_maintextures",20);
this.secondaryBackgroundSprites = [];
this.mainTextureLeft = random_Random.getInt(this.mainTexturesLeft.length);
this.mainTextureOther = random_Random.getInt(this.mainTextures.length);
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.mainSprite = new PIXI.Sprite(this.mainTextures[this.mainTextureOther]);
this.mainSprite.position.set(position.x,position.y);
bgStage.addChild(this.mainSprite);
this.positionSprites();
this.startTime = 20;
this.endTime = 5.5;
this.workTimePreferenceMod = 0.5;
this.isEntertainment = true;
};
$hxClasses["buildings.ScrapyardNightClub"] = buildings_ScrapyardNightClub;
buildings_ScrapyardNightClub.__name__ = "buildings.ScrapyardNightClub";
buildings_ScrapyardNightClub.__interfaces__ = [buildings_IEntertainmentBuilding];
buildings_ScrapyardNightClub.__super__ = buildings_Work;
buildings_ScrapyardNightClub.prototype = $extend(buildings_Work.prototype,{
get_baseEntertainmentCapacity: function() {
return this.workers.length * 120;
}
,get_isOpen: function() {
if(this.workers.length == 1 && this.workers[0].currentAction == LifeAction.Work) {
var this1 = this.city.simulation.time.timeSinceStart / 60 % 24;
var start = this.startTime - this.workTimePreferenceMod;
if(start < 6) {
if(this1 >= start) {
return this1 < 6;
} else {
return false;
}
} else if(!(this1 >= start)) {
return this1 < 6;
} else {
return true;
}
} else {
return false;
}
}
,get_entertainmentType: function() {
return 0;
}
,get_minimumNormalTimeToSpend: function() {
return 5;
}
,get_maximumNormalTimeToSpend: function() {
return 7;
}
,get_minimumEntertainmentGroupSatisfy: function() {
return 1;
}
,get_maximumEntertainmentGroupSatisfy: function() {
return 3;
}
,get_entertainmentQuality: function() {
return 100;
}
,get_isOpenForExistingVisitors: function() {
return this.get_isOpen();
}
,finishEntertainment: function(citizen,timeMod) {
return true;
}
,get_drawerType: function() {
return buildings_buildingDrawers_AutoMergingBuildingDrawer;
}
,get_hasLeftNightClub: function() {
if(this.leftBuilding != null) {
return this.leftBuilding.is(buildings_ScrapyardNightClub);
} else {
return false;
}
}
,get_hasRightNightClub: function() {
if(this.rightBuilding != null) {
return this.rightBuilding.is(buildings_ScrapyardNightClub);
} else {
return false;
}
}
,reRegisterSecondaryImages: function() {
var _g = 0;
var _g1 = this.secondaryBackgroundSprites;
while(_g < _g1.length) {
var spr = _g1[_g];
++_g;
spr.destroy();
}
this.secondaryBackgroundSprites.splice(0,this.secondaryBackgroundSprites.length);
if(!this.get_hasLeftNightClub()) {
switch(this.mainTextureLeft) {
case 0:
var sprite0 = new PIXI.Sprite(Resources.getTexture("spr_synightclub_lights"));
sprite0.scale.y = 0.8;
this.secondaryBackgroundSprites.push(sprite0);
this.bgStage.addChild(sprite0);
var sprite1 = new PIXI.Sprite(Resources.getTexture("spr_synightclub_lights"));
sprite1.scale.y = 0.4;
this.secondaryBackgroundSprites.push(sprite1);
this.bgStage.addChild(sprite1);
var sprite2 = new PIXI.Sprite(Resources.getTexture("spr_synightclub_lights"));
sprite2.scale.y = 0.8;
this.secondaryBackgroundSprites.push(sprite2);
this.bgStage.addChild(sprite2);
var sprite3 = new PIXI.Sprite(Resources.getTexture("spr_synightclub_lights"));
sprite3.scale.y = 0.5;
this.secondaryBackgroundSprites.push(sprite3);
this.bgStage.addChild(sprite3);
var _g = [];
_g.push({ sprite : this.secondaryBackgroundSprites[0], blend : 0});
_g.push({ sprite : this.secondaryBackgroundSprites[1], blend : 72});
_g.push({ sprite : this.secondaryBackgroundSprites[2], blend : 144});
_g.push({ sprite : this.secondaryBackgroundSprites[3], blend : 216});
this.lightColumnData = _g;
break;
case 1:
this.waterfallBaseHue = (this.position.x * 60 + this.position.y * 75) % 360;
var spr = new PIXI.Sprite(Resources.getTexture("spr_synightclub_waterfalllight"));
this.secondaryBackgroundSprites.push(spr);
this.bgStage.addChild(spr);
var spr = new PIXI.Sprite(Resources.getTexture("spr_synightclub_waterfalllight"));
this.secondaryBackgroundSprites.push(spr);
this.bgStage.addChild(spr);
var spr = new PIXI.Sprite(Resources.getTexture("spr_synightclub_waterfalllight"));
this.secondaryBackgroundSprites.push(spr);
this.bgStage.addChild(spr);
var spr2 = new PIXI.Sprite(Resources.getTexture("spr_synightclub_waterfalllight_last"));
this.secondaryBackgroundSprites.push(spr2);
this.bgStage.addChild(spr2);
break;
case 2:
this.lightColumnDataH = [];
var spr = new PIXI.Sprite(Resources.getTexture("spr_synightclub_lights_h"));
spr.alpha = 0;
this.bgStage.addChild(spr);
this.secondaryBackgroundSprites.push(spr);
this.lightColumnDataH.push({ sprite : spr, blend : 0, targetBlend : random_Random.getFloat(360)});
var spr = new PIXI.Sprite(Resources.getTexture("spr_synightclub_lights_h"));
spr.alpha = 0;
this.bgStage.addChild(spr);
this.secondaryBackgroundSprites.push(spr);
this.lightColumnDataH.push({ sprite : spr, blend : 120, targetBlend : random_Random.getFloat(360)});
var spr = new PIXI.Sprite(Resources.getTexture("spr_synightclub_lights_h"));
spr.alpha = 0;
this.bgStage.addChild(spr);
this.secondaryBackgroundSprites.push(spr);
this.lightColumnDataH.push({ sprite : spr, blend : 240, targetBlend : random_Random.getFloat(360)});
this.secondaryBackgroundSprites[0].scale.x = 1.4;
this.secondaryBackgroundSprites[1].scale.x = 1.5;
this.secondaryBackgroundSprites[2].scale.x = 1.2;
break;
}
} else {
switch(this.mainTextureOther) {
case 0:
var sprite0 = new PIXI.Sprite(Resources.getTexture("spr_synightclub_lights"));
sprite0.scale.y = 1.1;
this.secondaryBackgroundSprites.push(sprite0);
this.bgStage.addChild(sprite0);
var sprite1 = new PIXI.Sprite(Resources.getTexture("spr_synightclub_lights"));
sprite1.scale.y = 1;
this.secondaryBackgroundSprites.push(sprite1);
this.bgStage.addChild(sprite1);
var sprite2 = new PIXI.Sprite(Resources.getTexture("spr_synightclub_lights"));
sprite2.scale.y = 1.1;
this.secondaryBackgroundSprites.push(sprite2);
this.bgStage.addChild(sprite2);
var sprite3 = new PIXI.Sprite(Resources.getTexture("spr_synightclub_lights"));
sprite3.scale.y = 1.3;
this.secondaryBackgroundSprites.push(sprite3);
this.bgStage.addChild(sprite3);
var sprite4 = new PIXI.Sprite(Resources.getTexture("spr_synightclub_lights"));
sprite4.scale.y = 1;
this.secondaryBackgroundSprites.push(sprite4);
this.bgStage.addChild(sprite4);
var _g = [];
_g.push({ sprite : this.secondaryBackgroundSprites[0], blend : 0});
_g.push({ sprite : this.secondaryBackgroundSprites[1], blend : 60});
_g.push({ sprite : this.secondaryBackgroundSprites[2], blend : 120});
_g.push({ sprite : this.secondaryBackgroundSprites[3], blend : 180});
_g.push({ sprite : this.secondaryBackgroundSprites[4], blend : 240});
this.lightColumnData = _g;
break;
case 1:
this.miniLightData = [];
var _g = 0;
while(_g < 9) {
var i = _g++;
var spr = new PIXI.Sprite(Resources.getTexture("spr_synightclub_minilight"));
spr.alpha = 0;
this.bgStage.addChild(spr);
this.secondaryBackgroundSprites.push(spr);
this.miniLightData.push({ waitTime : random_Random.getInt(50), stage : 0, sprite : spr, alpha : 0});
}
break;
case 2:
this.lightColumnData = [];
var _g = 0;
while(_g < 6) {
var i = _g++;
var spr = new PIXI.Sprite(Resources.getTexture("spr_synightclub_lights"));
if(i < 2) {
spr.scale.y = 1.2;
} else if(i < 4) {
spr.scale.y = 0.7;
}
spr.alpha = 0;
this.bgStage.addChild(spr);
this.secondaryBackgroundSprites.push(spr);
this.lightColumnData.push({ sprite : spr, blend : i * 120});
}
break;
}
}
this.positionSprites();
this.activateOrDeactivateSprites(this.lightsAreOn >= 0);
}
,positionSprites: function() {
buildings_Work.prototype.positionSprites.call(this);
if(this.mainSprite != null) {
this.mainSprite.position.set(this.position.x,this.position.y);
}
if(!this.get_hasLeftNightClub()) {
switch(this.mainTextureLeft) {
case 0:
if(this.secondaryBackgroundSprites != null && this.secondaryBackgroundSprites.length >= 4) {
this.secondaryBackgroundSprites[0].position.set(this.position.x + 3,this.position.y + 2);
this.secondaryBackgroundSprites[1].position.set(this.position.x + 7,this.position.y + 4);
this.secondaryBackgroundSprites[2].position.set(this.position.x + 12,this.position.y + 3);
this.secondaryBackgroundSprites[3].position.set(this.position.x + 16,this.position.y + 4);
}
break;
case 1:
if(this.secondaryBackgroundSprites != null && this.secondaryBackgroundSprites.length >= 4) {
this.secondaryBackgroundSprites[0].position.set(this.position.x + 2,this.position.y + 1);
this.secondaryBackgroundSprites[1].position.set(this.position.x + 6,this.position.y + 5);
this.secondaryBackgroundSprites[2].position.set(this.position.x + 10,this.position.y + 9);
this.secondaryBackgroundSprites[3].position.set(this.position.x + 15,this.position.y + 13);
}
break;
case 2:
if(this.secondaryBackgroundSprites != null && this.secondaryBackgroundSprites.length >= 3) {
this.secondaryBackgroundSprites[0].position.set(this.position.x + 4,this.position.y + 3);
this.secondaryBackgroundSprites[1].position.set(this.position.x + 3,this.position.y + 7);
this.secondaryBackgroundSprites[2].position.set(this.position.x + 6,this.position.y + 11);
}
break;
}
} else {
switch(this.mainTextureOther) {
case 0:
if(this.secondaryBackgroundSprites != null && this.secondaryBackgroundSprites.length >= 5) {
this.secondaryBackgroundSprites[0].position.set(this.position.x + 2,this.position.y + 3);
this.secondaryBackgroundSprites[1].position.set(this.position.x + 6,this.position.y + 2);
this.secondaryBackgroundSprites[2].position.set(this.position.x + 10,this.position.y + 3);
this.secondaryBackgroundSprites[3].position.set(this.position.x + 14,this.position.y + 4);
this.secondaryBackgroundSprites[4].position.set(this.position.x + 17,this.position.y + 2);
}
break;
case 1:
if(this.secondaryBackgroundSprites != null && this.secondaryBackgroundSprites.length >= 9) {
this.secondaryBackgroundSprites[0].position.set(this.position.x - 1 + 3,this.position.y - 1 + 3);
this.secondaryBackgroundSprites[1].position.set(this.position.x - 1 + 2,this.position.y - 1 + 8);
this.secondaryBackgroundSprites[2].position.set(this.position.x - 1 + 3,this.position.y - 1 + 14);
this.secondaryBackgroundSprites[3].position.set(this.position.x - 1 + 9,this.position.y - 1 + 4);
this.secondaryBackgroundSprites[4].position.set(this.position.x - 1 + 7,this.position.y - 1 + 9);
this.secondaryBackgroundSprites[5].position.set(this.position.x - 1 + 9,this.position.y - 1 + 14);
this.secondaryBackgroundSprites[6].position.set(this.position.x - 1 + 14,this.position.y - 1 + 4);
this.secondaryBackgroundSprites[7].position.set(this.position.x - 1 + 14,this.position.y - 1 + 9);
this.secondaryBackgroundSprites[8].position.set(this.position.x - 1 + 13,this.position.y - 1 + 14);
}
break;
case 2:
if(this.secondaryBackgroundSprites != null && this.secondaryBackgroundSprites.length >= 6) {
this.secondaryBackgroundSprites[0].position.set(this.position.x + 3,this.position.y + 3);
this.secondaryBackgroundSprites[1].position.set(this.position.x + 4,this.position.y + 3);
this.secondaryBackgroundSprites[2].position.set(this.position.x + 9,this.position.y + 8);
this.secondaryBackgroundSprites[3].position.set(this.position.x + 10,this.position.y + 8);
this.secondaryBackgroundSprites[4].position.set(this.position.x + 15,this.position.y + 5);
this.secondaryBackgroundSprites[5].position.set(this.position.x + 16,this.position.y + 5);
}
break;
}
}
}
,updateSecondaryImages: function(timeMod) {
if(!this.get_hasLeftNightClub()) {
switch(this.mainTextureLeft) {
case 0:
var _g = 0;
var _g1 = this.lightColumnData;
while(_g < _g1.length) {
var lc = _g1[_g];
++_g;
var this1 = [lc.blend,0.65,1];
var tmp = thx_color_Hsv.toRgb(this1);
lc.sprite.tint = common_ColorExtensions.toHexInt(tmp);
lc.blend = (lc.blend + timeMod) % 360.0;
}
break;
case 1:
this.waterfallBaseHue += 0.5 * timeMod;
var offset = 0;
var _g = 0;
var _g1 = this.secondaryBackgroundSprites;
while(_g < _g1.length) {
var spr = _g1[_g];
++_g;
var this1 = [(this.waterfallBaseHue + offset) % 360,0.7,1];
spr.tint = common_ColorExtensions.toHexInt(thx_color_Hsv.toRgb(this1));
offset += 25;
}
break;
case 2:
var _g = 0;
var _g1 = this.lightColumnDataH;
while(_g < _g1.length) {
var lc = _g1[_g];
++_g;
var this1 = [lc.blend,0.65,1];
var tmp = thx_color_Hsv.toRgb(this1);
lc.sprite.tint = common_ColorExtensions.toHexInt(tmp);
var diff = lc.targetBlend - lc.blend;
var sgn = diff > 0 ? 1 : diff < 0 ? -1 : 0;
lc.blend = (lc.blend + (Math.abs(diff) > 180.0 ? -sgn : sgn) * timeMod + 360.0) % 360.0;
if(Math.abs(diff) < 2) {
lc.targetBlend = random_Random.getFloat(360);
}
}
break;
}
} else {
switch(this.mainTextureOther) {
case 0:
var _g = 0;
var _g1 = this.lightColumnData;
while(_g < _g1.length) {
var lc = _g1[_g];
++_g;
var this1 = [lc.blend,0.65,1];
var tmp = thx_color_Hsv.toRgb(this1);
lc.sprite.tint = common_ColorExtensions.toHexInt(tmp);
lc.blend = (lc.blend + timeMod) % 360.0;
}
break;
case 1:
var _g = 0;
var _g1 = this.miniLightData;
while(_g < _g1.length) {
var ml = _g1[_g];
++_g;
switch(ml.stage) {
case 0:
ml.waitTime -= timeMod;
if(ml.waitTime <= 0) {
ml.waitTime = 0;
var this1 = [random_Random.getInt(360),random_Random.getFloat(0.6,0.9),1];
var tmp = thx_color_Hsv.toRgb(this1);
ml.sprite.tint = common_ColorExtensions.toHexInt(tmp);
ml.stage = 1;
}
break;
case 1:
ml.alpha += 0.1 * timeMod;
if(ml.alpha >= 1.0) {
ml.alpha = 1.0;
ml.stage = 2;
ml.waitTime = random_Random.getFloat(20,90);
}
ml.sprite.alpha = ml.alpha;
break;
case 2:
ml.waitTime -= timeMod;
if(ml.waitTime <= 0) {
ml.waitTime = 0;
ml.stage = 3;
}
break;
case 3:
ml.alpha -= 0.1 * timeMod;
if(ml.alpha <= 0.0) {
ml.alpha = 0.0;
ml.stage = 0;
ml.waitTime = random_Random.getFloat(5);
}
ml.sprite.alpha = ml.alpha;
break;
}
}
break;
case 2:
var _g = 0;
while(_g < 6) {
var i = _g++;
var lc = this.lightColumnData[i];
var this1 = [lc.blend,0.75 - i * 0.01,1];
var tmp = thx_color_Hsv.toRgb(this1);
lc.sprite.tint = common_ColorExtensions.toHexInt(tmp);
lc.blend = (lc.blend + timeMod * (i % 2 == 0 ? 1.5 : -1.5) + 360.0) % 360.0;
}
break;
}
}
}
,activateOrDeactivateSprites: function(activate) {
if(!this.get_hasLeftNightClub() && this.mainTextureLeft == 0 || !this.get_hasLeftNightClub() && this.mainTextureLeft == 1 || !this.get_hasLeftNightClub() && this.mainTextureLeft == 2 || this.get_hasLeftNightClub() && this.mainTextureOther == 0 || this.get_hasLeftNightClub() && this.mainTextureOther == 2) {
var _g = 0;
var _g1 = this.secondaryBackgroundSprites;
while(_g < _g1.length) {
var spr = _g1[_g];
++_g;
spr.alpha = activate ? 1 : 0;
}
} else if(this.get_hasLeftNightClub() && this.mainTextureOther == 1) {
var _g = 0;
var _g1 = this.miniLightData;
while(_g < _g1.length) {
var miniImg = _g1[_g];
++_g;
miniImg.sprite.alpha = activate ? 1 : 0;
if(!activate) {
miniImg.alpha = 0;
miniImg.stage = 0;
}
}
}
}
,onCityChange: function() {
if(this.hadLeftNightClub != this.get_hasLeftNightClub()) {
var tmp = this.get_hasLeftNightClub() ? this.mainTextures[this.mainTextureOther] : this.mainTexturesLeft[this.mainTextureLeft];
this.mainSprite.texture = tmp;
this.hadLeftNightClub = this.get_hasLeftNightClub();
this.reRegisterSecondaryImages();
}
}
,postCreate: function() {
buildings_Work.prototype.postCreate.call(this);
var tmp = this.get_hasLeftNightClub() ? this.mainTextures[this.mainTextureOther] : this.mainTexturesLeft[this.mainTextureLeft];
this.mainSprite.texture = tmp;
this.hadLeftNightClub = this.get_hasLeftNightClub();
this.reRegisterSecondaryImages();
this.positionSprites();
}
,destroy: function() {
buildings_Work.prototype.destroy.call(this);
this.bgStage.removeChild(this.mainSprite);
if(this.secondaryBackgroundSprites != null) {
var _g = 0;
var _g1 = this.secondaryBackgroundSprites;
while(_g < _g1.length) {
var extraSprite = _g1[_g];
++_g;
extraSprite.destroy();
}
}
}
,work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking && this.city.simulation.time.timeSinceStart / 60 % 24 > 6) {
citizen.currentAction = LifeAction.Nothing;
} else if(this.get_hasLeftNightClub()) {
citizen.moveAndWait(random_Random.getInt(0,this.get_hasRightNightClub() ? 19 : 17),random_Random.getInt(20,50),null,false,false);
this.lightsAreOn = 60;
} else {
var spd = citizen.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
if(Math.abs(1 - citizen.relativeX) < spd) {
citizen.relativeX = 1;
} else {
var num = 1 - citizen.relativeX;
citizen.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
}
this.lightsAreOn = 3;
}
}
,beEntertained: function(citizen,timeMod) {
if(this.knownEntertainedCitizen == null) {
this.knownEntertainedCitizen = citizen;
this.knownEntertainedCitizenSet = 60;
} else if(this.knownEntertainedCitizen == citizen) {
this.knownEntertainedCitizenSet = 60;
}
var waitTimeMod = 3;
var goTo = random_Random.getInt(2 + (this.get_hasLeftNightClub() ? 1 : 0) + (this.get_hasRightNightClub() ? 1 : 0));
var canGoLR = true;
if(this.get_hasLeftNightClub() && canGoLR && goTo == 0 && this.leftBuilding.get_isOpen()) {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[6].length > 0 ? pool[6].splice(pool[6].length - 1,1)[0] : new Int32Array(6);
arr[0] = 2;
arr[1] = 0;
arr[2] = 4;
arr[3] = random_Random.getInt(5,19);
arr[4] = 8;
arr[5] = random_Random.getInt(5,6);
citizen.setPath(arr,0,6,true);
} else if(this.get_hasRightNightClub() && canGoLR && goTo == 1 && this.rightBuilding.get_isOpen()) {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[6].length > 0 ? pool[6].splice(pool[6].length - 1,1)[0] : new Int32Array(6);
arr[0] = 3;
arr[1] = 0;
arr[2] = 4;
arr[3] = random_Random.getInt(0,17);
arr[4] = 8;
arr[5] = random_Random.getInt(5,6);
citizen.setPath(arr,0,6,true);
} else {
var xMin = this.get_hasLeftNightClub() ? 0 : 5;
var xMax = this.get_hasRightNightClub() ? 19 : 17;
var modifyWithHappiness = false;
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
citizen.moveAndWait(random_Random.getInt(xMin,xMax),random_Random.getInt(5 + waitTimeMod,6 + waitTimeMod),null,modifyWithHappiness,false);
}
if(!citizen.hasBuildingInited) {
citizen.wantsNightEntertainmentIn = random_Random.getInt(1,5);
citizen.hasBuildingInited = true;
}
}
,createWindowAddBottomButtons: function() {
var _gthis = this;
gui_windowParts_CycleValueButton.create(this.city.gui,function() {
if(!_gthis.get_hasLeftNightClub()) {
return _gthis.mainTextureLeft;
} else {
return _gthis.mainTextureOther;
}
},function(t) {
var tmp;
if(_gthis.get_hasLeftNightClub()) {
_gthis.mainTextureOther = t;
tmp = _gthis.mainTextures[_gthis.mainTextureOther];
} else {
_gthis.mainTextureLeft = t;
tmp = _gthis.mainTexturesLeft[_gthis.mainTextureLeft];
}
_gthis.mainSprite.texture = tmp;
_gthis.reRegisterSecondaryImages();
},function() {
if(!_gthis.get_hasLeftNightClub()) {
return _gthis.mainTexturesLeft.length;
} else {
return _gthis.mainTextures.length;
}
},"Change Machines");
buildings_Work.prototype.createWindowAddBottomButtons.call(this);
}
,update: function(timeMod) {
buildings_Work.prototype.update.call(this,timeMod);
this.lightsAreOn -= Math.min(1,timeMod);
var shouldBeActive = this.lightsAreOn > 0 || this.workers.length >= 1 && this.workers[0].inPermanent == this && this.workers[0].currentAction == LifeAction.Work;
if(shouldBeActive != this.isCurrentlyActive) {
this.isCurrentlyActive = shouldBeActive;
this.activateOrDeactivateSprites(this.isCurrentlyActive);
}
if(this.isCurrentlyActive) {
this.updateSecondaryImages(timeMod);
}
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Work.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_ScrapyardNightClub.saveDefinition);
}
var value = this.mainTextureLeft;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.mainTextureOther;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
,load: function(queue,definition) {
buildings_Work.prototype.load.call(this,queue);
if(queue.version < 15) {
return;
}
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"mainTextureLeft")) {
this.mainTextureLeft = loadMap.h["mainTextureLeft"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"mainTextureOther")) {
this.mainTextureOther = loadMap.h["mainTextureOther"];
}
}
,__class__: buildings_ScrapyardNightClub
});
var buildings_SecretSocietyHouse = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.givenStatueReward = false;
this.timeToCheckBuildings = 0;
this.currentMission = 0;
this.ownPub = null;
this.manyTeleportAlpha = 0;
this.eventPhase = 0;
this.doingEvent = -1;
this.lastEventDoneOnDay = 0;
buildings_WorkWithHome.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.startTime = 12;
this.endTime = 2;
this.workTimePreferenceMod = 0.3;
};
$hxClasses["buildings.SecretSocietyHouse"] = buildings_SecretSocietyHouse;
buildings_SecretSocietyHouse.__name__ = "buildings.SecretSocietyHouse";
buildings_SecretSocietyHouse.__super__ = buildings_WorkWithHome;
buildings_SecretSocietyHouse.prototype = $extend(buildings_WorkWithHome.prototype,{
onBuild: function() {
this.city.progress.unlocks.unlock(cityUpgrades_SecretiveLiving);
}
,addWindowInfoLines: function() {
var _gthis = this;
buildings_WorkWithHome.prototype.addWindowInfoLines.call(this);
this.city.gui.windowInner.addChild(new gui_GUISpacing(this.city.gui.window,new common_Point(4,4)));
this.city.gui.windowAddInfoText(null,function() {
return _gthis.missionGetTitle();
},"Arial15");
this.city.gui.windowAddInfoText(null,function() {
return _gthis.missionGetText();
});
}
,missionGetTitle: function() {
if(this.currentMission == 8) {
return "Thank You";
}
return "Current Task";
}
,missionGetText: function() {
if(this.currentMission == 8) {
return "We will be forever grateful.";
}
if(this.workers.length != this.get_jobs()) {
return "Give us the followers we need:\nMake sure all 8 jobs are filled.";
}
switch(this.currentMission) {
case 0:
return "Improve Our Home:\nResearch Secretive Living in the Living Research Center.";
case 1:
return "Increase Production:\nProduce 1000 Wood in one day.";
case 2:
return "Green the City:\nBuild fifty Botanical Gardens.";
case 3:
return "Display the Statues:\nBuild twelve Sculpture Gardens.";
case 4:
return "Improve Transportation:\nBuild seven Teleporters.";
case 5:
return "House the Rich:\nBuild five Villas.";
case 6:
return "Know the Hidden:\nGain at least 1000 Knowledge in a day.";
case 7:
return "Finish Our Project:\nBuild the Machine.";
default:
return "";
}
}
,checkMissionCompletions: function() {
var missionComplete = false;
while(true) {
missionComplete = false;
switch(this.currentMission) {
case 0:
missionComplete = common_ArrayExtensions.any(this.city.upgrades.upgrades,function(cu) {
return ((cu) instanceof cityUpgrades_SecretiveLiving);
});
break;
case 1:
missionComplete = common_ArrayExtensions.any(this.city.simulation.stats.materialProduction[MaterialsHelper.findMaterialIndex("wood")],function(mt) {
return mt >= 1000;
});
break;
case 6:
missionComplete = common_ArrayExtensions.any(this.city.simulation.stats.materialProduction[MaterialsHelper.findMaterialIndex("knowledge")],function(mt) {
return mt >= 1000;
});
if(missionComplete) {
this.city.progress.unlocks.unlock(buildings_TheMachine);
}
break;
}
if(this.currentMission != 0 && this.currentMission != 1 && this.currentMission != 6 && this.currentMission < 8 && this.timeToCheckBuildings <= 0) {
var buildingsByType = this.city.getAmountOfPermanentsPerType();
switch(this.currentMission) {
case 2:
missionComplete = buildingsByType.h["buildings.BotanicalGardens"] >= 50;
if(missionComplete) {
this.city.progress.unlocks.unlock(buildings_StatueGarden);
}
break;
case 3:
missionComplete = buildingsByType.h["buildings.StatueGarden"] >= 12;
break;
case 4:
missionComplete = buildingsByType.h["buildings.Teleporter"] >= 7;
if(missionComplete) {
this.city.progress.unlocks.unlock(buildings_Villa);
}
break;
case 5:
missionComplete = buildingsByType.h["buildings.Villa"] >= 5;
break;
case 7:
missionComplete = buildingsByType.h["buildings.TheMachine"] >= 1;
break;
}
this.timeToCheckBuildings = 30;
}
if(missionComplete) {
this.currentMission += 1;
this.timeToCheckBuildings = 0;
this.city.progress.goalHelp.updateHasBuildingGoal();
}
if(!missionComplete) {
break;
}
}
}
,update: function(timeMod) {
buildings_WorkWithHome.prototype.update.call(this,timeMod);
if(this.doingEvent == 1 && this.eventPhase >= 1) {
if(this.manyTeleportAlpha < 1) {
this.manyTeleportAlpha += 0.05;
var _g = 0;
var _g1 = this.workers;
while(_g < _g1.length) {
var worker = _g1[_g];
++_g;
worker.sprite.alpha = this.manyTeleportAlpha;
}
} else {
this.doingEvent = -1;
this.eventPhase = 0;
var _g = 0;
var _g1 = this.workers;
while(_g < _g1.length) {
var worker = _g1[_g];
++_g;
worker.sprite.alpha = 1;
}
}
}
this.checkMissionCompletions();
this.timeToCheckBuildings -= timeMod;
if(!this.givenStatueReward) {
var _g = 0;
var _g1 = this.workers;
while(_g < _g1.length) {
var worker = _g1[_g];
++_g;
if(worker.get_age() >= 500) {
if(!this.givenStatueReward) {
this.city.progress.unlocks.unlock(buildings_StatueOfTheKey);
}
this.givenStatueReward = true;
}
}
}
}
,work: function(citizen,timeMod,shouldStopWorking) {
var _gthis = this;
if(this.doingEvent != -1) {
if(this.doingEvent == 1) {
if(this.eventPhase == 0) {
if(common_ArrayExtensions.all(this.workers,function(w) {
if(w.inPermanent != null && w.inPermanent.is(buildings_Teleporter) && w.relativeX == w.inPermanent.teleportX && w.path == null) {
return !w.isRequestingPath;
} else {
return false;
}
})) {
this.eventPhase = 1;
var _g = 0;
var _g1 = this.workers;
while(_g < _g1.length) {
var worker = _g1[_g];
++_g;
var inPermanent = worker.inPermanent;
inPermanent.createTeleportParticle("spr_teleporter_ray_key");
inPermanent.timesUsed += 1;
worker.onWorld = this.world;
worker.setRelativePos(random_Random.getInt(this.world.rect.width - 2),0);
worker.inPermanent = null;
worker.addToOnWorldStage();
worker.sprite.alpha = 0;
this.manyTeleportAlpha = 0;
}
} else if(citizen.inPermanent == null || !citizen.inPermanent.is(buildings_Teleporter)) {
var manyTeleportTeleporter = this.city.simulation.permanentFinder.quickQueryForCitizen(citizen,function(pm) {
return pm.is(buildings_Teleporter);
},"secretSocietyTeleporterQuery" + this.id,3);
if(manyTeleportTeleporter == null) {
this.doingEvent = -1;
} else {
citizen.simulation.pathfinder.findPath(citizen,manyTeleportTeleporter);
citizen.pathOnFail = null;
}
} else {
var x = citizen.inPermanent.teleportX;
var spd = citizen.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
if(Math.abs(x - citizen.relativeX) < spd) {
citizen.relativeX = x;
} else {
var num = x - citizen.relativeX;
citizen.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
}
}
}
return;
}
if(this.doingEvent == 2) {
if(citizen.inPermanent != null && citizen.inPermanent == this.ownPub) {
var thisPub = citizen.inPermanent;
if(thisPub.markingTexture == "") {
thisPub.setMarking("spr_pub_marking_key");
}
if(((this.city.simulation.time.timeSinceStart | 0) / 60 | 0) % 24 >= 5 && ((this.city.simulation.time.timeSinceStart | 0) / 60 | 0) % 24 < 10) {
this.doingEvent = -1;
} else {
thisPub.beEntertained(citizen,timeMod);
}
return;
}
var thereAreNoPubs = true;
if(this.ownPub != null && this.ownPub.destroyed) {
this.ownPub = null;
}
if(this.ownPub == null) {
var _g = 0;
var _g1 = this.city.permanents;
while(_g < _g1.length) {
var pm = _g1[_g];
++_g;
if(pm.is(buildings_Pub)) {
var thisPub = pm;
if(thisPub.markingTexture == "spr_pub_marking_key") {
this.ownPub = thisPub;
break;
}
thereAreNoPubs = false;
}
}
}
if(this.ownPub == null && !thereAreNoPubs) {
var newOwnPub = this.city.simulation.permanentFinder.quickQueryForCitizen(citizen,function(pm) {
if(pm.is(buildings_Pub)) {
return pm.markingTexture == "";
} else {
return false;
}
},"secretSocietyPub" + this.id,3);
if(newOwnPub == null) {
this.doingEvent = -1;
} else {
this.ownPub = newOwnPub;
}
}
if(this.ownPub != null) {
citizen.simulation.pathfinder.findPath(citizen,this.ownPub);
citizen.pathOnFail = function() {
_gthis.doingEvent = -1;
};
}
return;
}
}
if(citizen.inPermanent != this) {
citizen.simulation.pathfinder.findPath(citizen,this);
citizen.pathOnFail = null;
return;
}
if(shouldStopWorking) {
citizen.currentAction = LifeAction.Nothing;
return;
}
this.walkAround(citizen,150);
if(((this.city.simulation.time.timeSinceStart | 0) / 60 | 0) % 24 > 15) {
if(1 + ((this.city.simulation.time.timeSinceStart | 0) / 1440 | 0) > this.lastEventDoneOnDay) {
this.doingEvent = random_Random.getInt(1,3);
this.eventPhase = 0;
this.lastEventDoneOnDay = 1 + ((this.city.simulation.time.timeSinceStart | 0) / 1440 | 0);
}
}
}
,walkAround: function(citizen,stepsInBuilding) {
var r = random_Random.getInt(5);
if(r == 0 && stepsInBuilding > 120) {
citizen.changeFloorAndWaitRandom(30,60);
} else if(r == 1 || r == 2 && citizen.relativeY < 5) {
citizen.moveAndWait(random_Random.getInt(3,7),random_Random.getInt(30,60),null,false,false);
} else if(r == 2) {
citizen.moveAndWait(random_Random.getInt(12,16),random_Random.getInt(30,60),null,false,false);
} else {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = random_Random.getInt(90,120);
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
}
,getGlobalGoal: function() {
if(this.currentMission == 8) {
return null;
}
return { category : "Secret Society Mission", text : this.missionGetText()};
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_WorkWithHome.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_SecretSocietyHouse.saveDefinition);
}
var value = this.lastEventDoneOnDay;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.doingEvent;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.eventPhase;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.currentMission;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
,load: function(queue,definition) {
buildings_WorkWithHome.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"lastEventDoneOnDay")) {
this.lastEventDoneOnDay = loadMap.h["lastEventDoneOnDay"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"doingEvent")) {
this.doingEvent = loadMap.h["doingEvent"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"eventPhase")) {
this.eventPhase = loadMap.h["eventPhase"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"currentMission")) {
this.currentMission = loadMap.h["currentMission"];
}
}
,__class__: buildings_SecretSocietyHouse
});
var buildings_ShadyHome = function(game,stage,bgStage,city,world,position,worldPosition,id) {
buildings_House.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
};
$hxClasses["buildings.ShadyHome"] = buildings_ShadyHome;
buildings_ShadyHome.__name__ = "buildings.ShadyHome";
buildings_ShadyHome.__super__ = buildings_House;
buildings_ShadyHome.prototype = $extend(buildings_House.prototype,{
get_possibleUpgrades: function() {
return [];
}
,walkAround: function(citizen,stepsInBuilding) {
var r = random_Random.getInt(3);
if(r == 0 && stepsInBuilding > 120) {
citizen.changeFloorAndWaitRandom(30,60);
} else if(r == 1) {
if(citizen.relativeY < 5) {
var r2 = random_Random.getInt(3);
if(r2 == 0) {
citizen.moveAndWait(random_Random.getInt(3,5),random_Random.getInt(30,60),null,false,false);
} else if(r2 == 1) {
citizen.moveAndWait(random_Random.getInt(9,10),random_Random.getInt(30,60),null,false,false);
} else {
citizen.moveAndWait(random_Random.getInt(14,15),random_Random.getInt(30,60),null,false,false);
}
} else {
citizen.moveAndWait(random_Random.getInt(5,15),random_Random.getInt(30,60),null,false,false);
}
} else {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = random_Random.getInt(90,120);
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
}
,__class__: buildings_ShadyHome
});
var buildings_SpaciousHouse = function(game,stage,bgStage,city,world,position,worldPosition,id) {
buildings_House.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
};
$hxClasses["buildings.SpaciousHouse"] = buildings_SpaciousHouse;
buildings_SpaciousHouse.__name__ = "buildings.SpaciousHouse";
buildings_SpaciousHouse.__super__ = buildings_House;
buildings_SpaciousHouse.prototype = $extend(buildings_House.prototype,{
get_possibleUpgrades: function() {
return [buildingUpgrades_SmartLights,buildingUpgrades_SofterBeds];
}
,walkAround: function(citizen,stepsInBuilding) {
var r = random_Random.getInt(3);
if(r == 0 && stepsInBuilding > 120) {
citizen.changeFloorAndWaitRandom(30,60);
} else if(r == 1) {
if(citizen.relativeY < 5) {
citizen.moveAndWait(random_Random.getInt(3,15),random_Random.getInt(30,60),null,false,false);
} else if(random_Random.getInt(2) == 1) {
citizen.moveAndWait(random_Random.getInt(3,7),random_Random.getInt(30,60),null,false,false);
} else {
citizen.moveAndWait(random_Random.getInt(12,16),random_Random.getInt(30,60),null,false,false);
}
} else {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = random_Random.getInt(90,120);
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
}
,update: function(timeMod) {
buildings_House.prototype.update.call(this,timeMod);
}
,__class__: buildings_SpaciousHouse
});
var buildings_StatueGarden = function(game,stage,bgStage,city,world,position,worldPosition,id) {
buildings_Park.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
};
$hxClasses["buildings.StatueGarden"] = buildings_StatueGarden;
buildings_StatueGarden.__name__ = "buildings.StatueGarden";
buildings_StatueGarden.__super__ = buildings_Park;
buildings_StatueGarden.prototype = $extend(buildings_Park.prototype,{
get_myParkTextures: function() {
return "spr_statuegarden_statues";
}
,get_changePlantsText: function() {
return "Change Sculptures";
}
,get_entertainmentType: function() {
return 2;
}
,get_baseEntertainmentCapacity: function() {
return 40;
}
,get_numberOfLockedParkTextures: function() {
return 0;
}
,addWindowInfoLines: function() {
var _gthis = this;
buildings_Park.prototype.addWindowInfoLines.call(this);
var devMessageShown = false;
var devMessageContainerOuter = new gui_GUIContainer(this.city.gui,this.city.gui.innerWindowStage,this.city.gui.windowInner);
var devMessageContainer = null;
this.city.gui.windowInner.addChild(devMessageContainerOuter);
this.city.gui.windowInner.onUpdate = function() {
if(_gthis.currentTexture == 0) {
if(!devMessageShown) {
devMessageShown = true;
devMessageContainer = new gui_GUIContainer(_gthis.city.gui,_gthis.city.gui.innerWindowStage,devMessageContainerOuter);
devMessageContainer.direction = gui_GUIContainerDirection.Vertical;
devMessageContainer.addChild(new gui_GUISpacing(devMessageContainer,new common_Point(2,6)));
devMessageContainer.addChild(new gui_TextElement(devMessageContainer,_gthis.city.gui.innerWindowStage,"A Message from the Developer",null,"Arial15"));
devMessageContainer.addChild(new gui_TextElement(devMessageContainer,_gthis.city.gui.innerWindowStage,"Let's ensure elephants are not just pixely statues on tiny worlds in 2142. The climate crisis is the most important threat facing wildlife - and humans."));
var createClimateCrisisExplainerWindow = null;
createClimateCrisisExplainerWindow = function() {
_gthis.city.gui.createWindow("climateCrisisWindow",Resources.getTexture("spr_9p_window_moreopaque"));
_gthis.city.gui.addWindowToStack(createClimateCrisisExplainerWindow);
gui_ClimateCrisisExplainerWindow.create(_gthis.city,_gthis.city.gui,_gthis.city.gui.innerWindowStage,_gthis.city.gui.windowInner);
};
devMessageContainer.addChild(new gui_TextButton(_gthis.city.gui,_gthis.city.gui.innerWindowStage,devMessageContainer,createClimateCrisisExplainerWindow,"See What You Can Do"));
devMessageContainer.addChild(new gui_GUISpacing(devMessageContainer,new common_Point(2,6)));
devMessageContainerOuter.addChild(devMessageContainer);
_gthis.city.gui.setWindowPositioning(gui_WindowPosition.CenterOffset(devMessageContainer.rect.height / 2 | 0));
}
} else if(devMessageShown) {
devMessageShown = false;
devMessageContainerOuter.removeChild(devMessageContainer);
_gthis.city.gui.setWindowPositioning(gui_WindowPosition.Center);
}
};
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Park.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_StatueGarden.saveDefinition);
}
}
,load: function(queue,definition) {
buildings_Park.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
}
,__class__: buildings_StatueGarden
});
var buildings_StatueOfHappiness = function(game,stage,bgStage,city,world,position,worldPosition,id) {
buildings_Park.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.currentTexture = 0;
this.parkSprite.texture = this.parkTextures[this.currentTexture];
};
$hxClasses["buildings.StatueOfHappiness"] = buildings_StatueOfHappiness;
buildings_StatueOfHappiness.__name__ = "buildings.StatueOfHappiness";
buildings_StatueOfHappiness.__super__ = buildings_Park;
buildings_StatueOfHappiness.prototype = $extend(buildings_Park.prototype,{
get_myParkTextures: function() {
return "spr_statueofhappiness";
}
,get_changePlantsText: function() {
return "Change Statue";
}
,get_entertainmentType: function() {
return 2;
}
,get_baseEntertainmentCapacity: function() {
return 80;
}
,get_numberOfLockedParkTextures: function() {
return 0;
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Park.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_StatueOfHappiness.saveDefinition);
}
}
,load: function(queue,definition) {
buildings_Park.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
}
,__class__: buildings_StatueOfHappiness
});
var buildings_StatueOfTheKey = function(game,stage,bgStage,city,world,position,worldPosition,id) {
buildings_Park.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.currentTexture = 0;
this.parkSprite.texture = this.parkTextures[this.currentTexture];
};
$hxClasses["buildings.StatueOfTheKey"] = buildings_StatueOfTheKey;
buildings_StatueOfTheKey.__name__ = "buildings.StatueOfTheKey";
buildings_StatueOfTheKey.__super__ = buildings_Park;
buildings_StatueOfTheKey.prototype = $extend(buildings_Park.prototype,{
get_myParkTextures: function() {
return "spr_statueofthekey";
}
,get_changePlantsText: function() {
return "Change Statue";
}
,get_entertainmentType: function() {
return 2;
}
,get_baseEntertainmentCapacity: function() {
return 80;
}
,get_numberOfLockedParkTextures: function() {
return 0;
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Park.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_StatueOfTheKey.saveDefinition);
}
}
,load: function(queue,definition) {
buildings_Park.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
}
,__class__: buildings_StatueOfTheKey
});
var buildings_StoneMine = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.stoneMinedPerActionBoost = 1;
buildings_BlueCollarWork.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
};
$hxClasses["buildings.StoneMine"] = buildings_StoneMine;
buildings_StoneMine.__name__ = "buildings.StoneMine";
buildings_StoneMine.__super__ = buildings_BlueCollarWork;
buildings_StoneMine.prototype = $extend(buildings_BlueCollarWork.prototype,{
get_stoneMinedPerAction: function() {
return 0.2 * this.stoneMinedPerActionBoost;
}
,get_possibleUpgrades: function() {
return [buildingUpgrades_BetterPickaxes,buildingUpgrades_AIMining];
}
,work: function(citizen,timeMod,shouldStopWorking) {
var _gthis = this;
this.doBlueCollarJob(citizen,timeMod,shouldStopWorking,[worldResources_Rock,buildings_StoneTeleporter],function(rock) {
var finalStoneMineAction = _gthis.get_stoneMinedPerAction();
var _this = _gthis.city.simulation;
var finalStoneMineAction1 = finalStoneMineAction * (_gthis.city.progress.story.hiddenBoost && _gthis.city.materials.stone <= 4 ? Config.earlyGameFix1 ? 1.6 : 2 : 1) * _gthis.city.upgrades.vars.stoneMiningSpeed * (Config.earlyGameFix1 && _this.citizens.length < 30 ? 1.3 - 0.3 * (_this.citizens.length / 60) : 1) * _gthis.city.simulation.boostManager.currentGlobalBoostAmount;
_gthis.city.materials.stone += finalStoneMineAction1;
_gthis.city.simulation.stats.materialProduction[2][0] += finalStoneMineAction1;
rock.materialsLeft -= finalStoneMineAction1;
},90,120);
}
,__class__: buildings_StoneMine
});
var buildings_StoneResearchCenter = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.hasPickaxeTech = false;
this.currentBonus = 0;
this.totalKnowledgeGenerated = 0;
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
};
$hxClasses["buildings.StoneResearchCenter"] = buildings_StoneResearchCenter;
buildings_StoneResearchCenter.__name__ = "buildings.StoneResearchCenter";
buildings_StoneResearchCenter.__super__ = buildings_Work;
buildings_StoneResearchCenter.prototype = $extend(buildings_Work.prototype,{
get_possibleUpgrades: function() {
return [buildingUpgrades_PickaxeTech,buildingUpgrades_FossilScanner];
}
,postCreate: function() {
this.recalculateBonus();
}
,work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking) {
citizen.currentAction = LifeAction.Nothing;
return;
}
var rnd = random_Random.getInt(3);
if(rnd == 0) {
citizen.changeFloorAndWait(50);
} else if(rnd == 1) {
citizen.moveAndWait(random_Random.getInt(3,7),random_Random.getInt(50,80),null,false,false);
} else if(rnd == 2) {
citizen.moveAndWait(random_Random.getInt(12,16),random_Random.getInt(50,80),null,false,false);
}
}
,update: function(timeMod) {
this.recalculateBonus();
}
,recalculateBonus: function() {
this.currentBonus = 0.0;
var knowledgeProd = this.city.simulation.stats.materialProduction[MaterialsHelper.findMaterialIndex("knowledge")];
var baseBonusOn = 0.0;
if(knowledgeProd.length >= 2) {
baseBonusOn = knowledgeProd[1];
} else if(knowledgeProd.length >= 1) {
baseBonusOn = knowledgeProd[0];
}
var currBonusDivider = this.hasPickaxeTech ? 195 : 200;
var currBonusMultiplier = this.hasPickaxeTech ? 0.1 : 0.075;
var currBonusLogFactor = this.hasPickaxeTech ? 1.65 : 2;
if(baseBonusOn < currBonusDivider) {
this.currentBonus = baseBonusOn / currBonusDivider * 0.15;
} else {
this.currentBonus = Math.log(baseBonusOn / currBonusDivider) / Math.log(currBonusLogFactor) * currBonusMultiplier + 0.15;
}
if(this.hasPickaxeTech) {
this.currentBonus += 2.5e-005 * baseBonusOn;
}
this.currentBonus *= this.workers.length / this.get_jobs();
this.currentBonus = Math.max(0,this.currentBonus);
this.city.upgrades.vars.stoneMiningSpeed = 1.0 + this.currentBonus;
}
,addWindowInfoLines: function() {
var _gthis = this;
buildings_Work.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
_gthis.recalculateBonus();
return "Current stone mining boost: " + (_gthis.currentBonus * 100 | 0) + "%";
});
this.city.gui.windowAddInfoText("This is based on the number of workers and on yesterday's knowledge production.");
if(this.city.upgrades.vars.stoneResearchCenterWithFossils == this) {
this.city.gui.windowAddInfoText(null,function() {
return "Fossils found: " + (_gthis.city.simulation.bonuses.fossilsCollected | 0);
});
}
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Work.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_StoneResearchCenter.saveDefinition);
}
var value = this.totalKnowledgeGenerated;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
}
,load: function(queue,definition) {
buildings_Work.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"totalKnowledgeGenerated")) {
this.totalKnowledgeGenerated = loadMap.h["totalKnowledgeGenerated"];
}
}
,__class__: buildings_StoneResearchCenter
});
var worldResources_ILimitedMaterialGatherPlace = function() { };
$hxClasses["worldResources.ILimitedMaterialGatherPlace"] = worldResources_ILimitedMaterialGatherPlace;
worldResources_ILimitedMaterialGatherPlace.__name__ = "worldResources.ILimitedMaterialGatherPlace";
worldResources_ILimitedMaterialGatherPlace.__isInterface__ = true;
worldResources_ILimitedMaterialGatherPlace.prototype = {
__class__: worldResources_ILimitedMaterialGatherPlace
};
var buildings_StoneTeleporter = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.hasBigStone = false;
this.hasRemoteControl = false;
this.teleportButtonNotPressedTime = 0;
this.teleportButtonPressed = false;
this.maxCitizenX = 13;
this.minCitizenX = 5;
this.initialMaterials = 50;
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.updateStoneTextures();
this.stoneSprite = new PIXI.Sprite(this.stoneTextures[0]);
bgStage.addChild(this.stoneSprite);
this.positionSprites();
this.doorX = 12;
this.materialsLeft = 0;
this.regrowProgress = 0;
this.teleportButtonNotPressedTime = 0;
this.updateTexture();
};
$hxClasses["buildings.StoneTeleporter"] = buildings_StoneTeleporter;
buildings_StoneTeleporter.__name__ = "buildings.StoneTeleporter";
buildings_StoneTeleporter.__interfaces__ = [worldResources_ILimitedMaterialGatherPlace];
buildings_StoneTeleporter.__super__ = buildings_Work;
buildings_StoneTeleporter.prototype = $extend(buildings_Work.prototype,{
get_destroyedOnEmpty: function() {
return false;
}
,get_resourceName: function() {
return "stone";
}
,get_doNotGather: function() {
return false;
}
,get_regrowSpeed: function() {
return 0.0;
}
,get_stayIfEmpty: function() {
return true;
}
,get_possibleUpgrades: function() {
return [buildingUpgrades_StoneTeleporterRemote];
}
,postLoad: function() {
if(this.hasBigStone) {
this.initialMaterials = 150;
this.updateStoneTextures();
}
this.updateTexture();
}
,work: function(citizen,timeMod,shouldStopWorking) {
var _gthis = this;
if(shouldStopWorking) {
citizen.currentAction = LifeAction.Nothing;
} else {
if(!this.hasRemoteControl) {
var spd = citizen.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
if(Math.abs(3 - citizen.relativeX) < spd) {
citizen.relativeX = 3;
} else {
var num = 3 - citizen.relativeX;
citizen.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
}
}
if(this.materialsLeft <= 0) {
this.teleportButtonPressed = true;
this.teleportButtonNotPressedTime = 0;
} else if(this.hasRemoteControl) {
var modifyWithHappiness = true;
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
citizen.moveAndWait(random_Random.getInt(this.minCitizenX,this.maxCitizenX),random_Random.getInt(90,120),function() {
if(_gthis.materialsLeft > 0) {
var stoneProduced = _gthis.city.simulation.boostManager.currentGlobalBoostAmount * 0.2 * _gthis.city.upgrades.vars.stoneMiningSpeed;
_gthis.materialsLeft -= stoneProduced;
_gthis.city.materials.stone += stoneProduced;
_gthis.city.simulation.stats.materialProduction[2][0] += stoneProduced;
}
_gthis.updateTexture();
},modifyWithHappiness,false);
}
}
}
,update: function(timeMod) {
buildings_Work.prototype.update.call(this,timeMod);
if(this.materialsLeft <= 0) {
if(this.teleportButtonPressed) {
if(this.regrowProgress == 0) {
this.hasBigStone = this.city.upgrades.vars.stoneTeleporterHasBigStones;
this.updateStoneTextures();
}
this.regrowProgress += 2 * timeMod;
if(this.regrowProgress >= 100) {
this.regrowProgress = 0;
if(this.hasBigStone) {
this.initialMaterials = 150;
}
this.materialsLeft = this.initialMaterials;
this.teleportButtonPressed = false;
this.teleportButtonNotPressedTime = 0;
if(this.city.upgrades.vars.stoneResearchCenterWithFossils != null && random_Random.getFloat() < 0.00001 * this.initialMaterials) {
this.city.materials.knowledge += 10000;
this.city.simulation.stats.materialProduction[8][0] += 10000;
this.city.simulation.bonuses.fossilsCollected++;
}
}
this.updateTexture();
} else if(this.hasRemoteControl && this.workers.length > 0) {
this.teleportButtonPressed = true;
this.teleportButtonNotPressedTime = 0;
} else {
this.teleportButtonNotPressedTime += timeMod;
}
}
}
,destroy: function() {
buildings_Work.prototype.destroy.call(this);
this.bgStage.removeChild(this.stoneSprite);
}
,positionSprites: function() {
buildings_Work.prototype.positionSprites.call(this);
if(this.stoneSprite != null) {
this.stoneSprite.position.set(this.position.x,this.position.y);
}
}
,addWindowInfoLines: function() {
var _gthis = this;
buildings_Work.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
if(_gthis.materialsLeft > 0 || !_gthis.teleportButtonPressed && _gthis.teleportButtonNotPressedTime < 3) {
return "" + (_gthis.materialsLeft | 0) + " stone left in this meteoroid.";
}
if(!_gthis.teleportButtonPressed) {
return "Waiting for a worker to press the teleport button...";
}
return "Teleporting a meteoroid...";
});
}
,updateStoneTextures: function() {
this.stoneTextures = Resources.getTexturesByWidth(this.hasBigStone ? "spr_stoneteleporter_stone_big" : "spr_stoneteleporter_stone",20);
}
,updateTexture: function() {
if(this.materialsLeft <= 0) {
this.stoneSprite.texture = this.stoneTextures[0];
this.stoneSprite.alpha = this.regrowProgress / 100;
} else {
var materialsLeft = this.materialsLeft;
var initialMaterials = this.initialMaterials;
var textures = this.stoneTextures;
var regrowTextures = null;
var sprite = this.stoneSprite;
if(materialsLeft <= 0.0000001) {
sprite.texture = regrowTextures != null ? regrowTextures[this.regrowProgress / 100 * regrowTextures.length | 0] : textures[textures.length - 1];
} else {
var i = Math.floor((initialMaterials - materialsLeft) / initialMaterials * textures.length);
if(initialMaterials != materialsLeft && i == 0 && textures.length > 1) {
i = 1;
}
sprite.texture = textures[i];
}
this.stoneSprite.alpha = 1;
}
if(this.stoneSprite.texture == null) {
debugger;
console.log("FloatingSpaceCities/buildings/StoneTeleporter.hx:205:","Something went wrong while updating the stone sprite.");
}
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Work.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_StoneTeleporter.saveDefinition);
}
var value = this.regrowProgress;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.materialsLeft;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.hasBigStone;
if(queue.size + 1 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 1) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.b[queue.size] = value ? 1 : 0;
queue.size += 1;
}
,load: function(queue,definition) {
buildings_Work.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"regrowProgress")) {
this.regrowProgress = loadMap.h["regrowProgress"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"materialsLeft")) {
this.materialsLeft = loadMap.h["materialsLeft"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"hasBigStone")) {
this.hasBigStone = loadMap.h["hasBigStone"];
}
this.postLoad();
}
,__class__: buildings_StoneTeleporter
});
var buildings_Supercomputer = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.numberOfLabs = 0;
this.knowledgeSoFar = 0;
Building.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
};
$hxClasses["buildings.Supercomputer"] = buildings_Supercomputer;
buildings_Supercomputer.__name__ = "buildings.Supercomputer";
buildings_Supercomputer.__super__ = Building;
buildings_Supercomputer.prototype = $extend(Building.prototype,{
get_knowledgePerDay: function() {
return 2 * this.city.simulation.stats.peopleWorkingAtLabs;
}
,get_possibleCityUpgrades: function() {
return [cityUpgrades_UniverseMapping,cityUpgrades_OptimizedChipLayouts,cityUpgrades_MedicalMachineLearning];
}
,update: function(timeMod) {
var addKnowledge = timeMod * (this.get_knowledgePerDay() / (1440 / this.city.simulation.time.minutesPerTick)) * this.city.simulation.boostManager.currentGlobalBoostAmount;
this.city.materials.knowledge += addKnowledge;
this.city.simulation.stats.materialProduction[8][0] += addKnowledge;
this.knowledgeSoFar += addKnowledge;
}
,onCityChange: function() {
this.numberOfLabs = Lambda.count(this.city.permanents,function(pm) {
return pm.is(buildings_Laboratory);
});
}
,addWindowInfoLines: function() {
var _gthis = this;
Building.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
return "" + (_gthis.get_knowledgePerDay() | 0) + " knowledge gathered per day.";
});
this.city.gui.windowAddInfoText(null,function() {
return "" + (_gthis.knowledgeSoFar | 0) + " knowledge gathered so far.";
});
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
Building.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_Supercomputer.saveDefinition);
}
var value = this.knowledgeSoFar;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
}
,load: function(queue,definition) {
Building.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"knowledgeSoFar")) {
this.knowledgeSoFar = loadMap.h["knowledgeSoFar"];
}
}
,__class__: buildings_Supercomputer
});
var buildings_Teleporter = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.teleportX = 9.;
this.timesUsedTo = 0;
this.timesUsed = 0;
Building.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.doorX = 12;
city.teleporters.push(this);
};
$hxClasses["buildings.Teleporter"] = buildings_Teleporter;
buildings_Teleporter.__name__ = "buildings.Teleporter";
buildings_Teleporter.__super__ = Building;
buildings_Teleporter.prototype = $extend(Building.prototype,{
get_typeID: function() {
return 1;
}
,destroy: function() {
HxOverrides.remove(this.city.teleporters,this);
Building.prototype.destroy.call(this);
}
,addWindowInfoLines: function() {
var _gthis = this;
Building.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
return "Teleported from " + _gthis.timesUsed + " times.";
});
this.city.gui.windowAddInfoText(null,function() {
return "Teleported to " + _gthis.timesUsedTo + " times.";
});
}
,createTeleportParticle: function(rayTexture) {
if(rayTexture == null) {
rayTexture = "spr_teleporter_ray";
}
this.city.particles.addParticle(Resources.getTexturesByWidth(rayTexture,4),new common_Point(this.position.x + 8,this.position.y + 4));
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
Building.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_Teleporter.saveDefinition);
}
var value = this.timesUsed;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.timesUsedTo;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
,load: function(queue,definition) {
Building.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"timesUsed")) {
this.timesUsed = loadMap.h["timesUsed"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"timesUsedTo")) {
this.timesUsedTo = loadMap.h["timesUsedTo"];
}
}
,__class__: buildings_Teleporter
});
var buildings_TheContraption = function(game,stage,bgStage,city,world,position,worldPosition,id) {
Building.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
};
$hxClasses["buildings.TheContraption"] = buildings_TheContraption;
buildings_TheContraption.__name__ = "buildings.TheContraption";
buildings_TheContraption.__super__ = Building;
buildings_TheContraption.prototype = $extend(Building.prototype,{
__class__: buildings_TheContraption
});
var buildings_TheMachine = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.totalMaterialReward = null;
this.thisDayMaterialReward = null;
this.lastDayReward = -1;
this.animProgress = 0;
this.secretSocietyHouse = null;
Building.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.bgTextures = Resources.getTexturesByWidth("spr_secretsocietymachine_anim",20);
this.backSprite = new PIXI.Sprite(this.bgTextures[0]);
this.backSprite.position.set(position.x,position.y);
bgStage.addChild(this.backSprite);
this.totalMaterialReward = new Materials();
};
$hxClasses["buildings.TheMachine"] = buildings_TheMachine;
buildings_TheMachine.__name__ = "buildings.TheMachine";
buildings_TheMachine.__super__ = Building;
buildings_TheMachine.prototype = $extend(Building.prototype,{
update: function(timeMod) {
if(this.secretSocietyHouse == null || this.secretSocietyHouse.destroyed) {
this.secretSocietyHouse = Lambda.find(this.city.permanents,function(pm) {
return pm.is(buildings_SecretSocietyHouse);
});
}
if(this.secretSocietyHouse != null) {
var _g = 0;
var _g1 = this.secretSocietyHouse.workers;
while(_g < _g1.length) {
var cit = _g1[_g];
++_g;
cit.dieAgeModifier = cit.get_age() - 75 + 3;
}
}
var mainAnimSpeed = 4;
var maxWaitTime = 180;
var beginAnimTime = 480;
var animLength = this.bgTextures.length * mainAnimSpeed * 2 + beginAnimTime + maxWaitTime;
this.animProgress = (this.animProgress + timeMod) % animLength;
if(this.animProgress < beginAnimTime) {
this.backSprite.texture = this.bgTextures[(Math.floor(this.animProgress) / 4 | 0) % 2];
} else if(this.animProgress - beginAnimTime - maxWaitTime > this.bgTextures.length * mainAnimSpeed) {
var val = this.bgTextures.length - 1 - (Math.floor(this.animProgress - this.bgTextures.length * mainAnimSpeed - beginAnimTime - maxWaitTime) / mainAnimSpeed | 0);
var maxVal = this.bgTextures.length - 1;
this.backSprite.texture = this.bgTextures[val < 0 ? 0 : val > maxVal ? maxVal : val];
} else if(this.animProgress - beginAnimTime > this.bgTextures.length * mainAnimSpeed) {
this.backSprite.texture = this.bgTextures[this.bgTextures.length - 1];
} else {
var val = Math.floor(this.animProgress - beginAnimTime) / mainAnimSpeed | 0;
var maxVal = this.bgTextures.length - 1;
this.backSprite.texture = this.bgTextures[val < 0 ? 0 : val > maxVal ? maxVal : val];
}
if(this.lastDayReward != 1 + ((this.city.simulation.time.timeSinceStart | 0) / 1440 | 0)) {
this.setReward();
}
}
,setReward: function() {
var tmp;
switch(random_Random.getInt(10)) {
case 0:
tmp = new Materials(random_Random.getInt(150,301));
break;
case 1:
tmp = new Materials(0,random_Random.getInt(100,501));
break;
case 2:
tmp = new Materials(0,0,random_Random.getInt(200,2001));
break;
case 3:
tmp = new Materials(random_Random.getInt(100,301),random_Random.getInt(50,301),random_Random.getInt(25,201));
break;
case 4:
tmp = new Materials(random_Random.getInt(100,201),random_Random.getInt(150,251));
break;
case 5:
tmp = new Materials(0,0,0,random_Random.getInt(20,31));
break;
case 6:
tmp = new Materials(0,0,0,0,0,random_Random.getInt(40,81));
break;
case 7:
tmp = new Materials(0,0,0,0,0,0,random_Random.getInt(5,11));
break;
case 8:
tmp = new Materials(0,0,0,random_Random.getInt(15,31),0,random_Random.getInt(20,51));
break;
default:
switch(random_Random.getInt(5)) {
case 0:
tmp = new Materials(random_Random.getInt(500,1501),0,random_Random.getInt(1000,2001));
break;
case 1:
tmp = new Materials(0,0,0,0,random_Random.getInt(500,1501));
break;
case 2:
tmp = new Materials(0,random_Random.getInt(1000,2001),0,random_Random.getInt(50,101),0);
break;
case 3:
tmp = new Materials(0,0,0,0,0,random_Random.getInt(200,301));
break;
default:
switch(random_Random.getInt(5)) {
case 0:
tmp = new Materials(1000,0,1000,20,0,40,16);
break;
case 1:
tmp = new Materials(0,0,0,0,0,0,100);
break;
case 2:
tmp = new Materials(0,0,0,0,0,1000);
break;
case 3:
tmp = new Materials(0,10000);
break;
default:
tmp = new Materials(1000,1000,1000,500);
}
}
}
this.thisDayMaterialReward = tmp;
this.thisDayMaterialReward.multiply(this.city.simulation.boostManager.currentGlobalBoostAmount);
this.lastDayReward = 1 + ((this.city.simulation.time.timeSinceStart | 0) / 1440 | 0);
this.thisDayMaterialReward.addToProduction(this.city.simulation.stats);
this.city.materials.add(this.thisDayMaterialReward);
this.totalMaterialReward.add(this.thisDayMaterialReward);
}
,addWindowInfoLines: function() {
var _gthis = this;
if(this.thisDayMaterialReward == null) {
this.setReward();
}
Building.prototype.addWindowInfoLines.call(this);
var lastUpdated = this.lastDayReward;
var lastTotalReward = this.lastDayReward;
this.city.gui.windowAddInfoText("Today's Production:");
var rewardContainer = new gui_MaterialsDisplay(this.thisDayMaterialReward);
var rewardHolder = null;
rewardHolder = new gui_ContainerHolder(this.city.gui.windowInner,this.city.gui.innerWindowStage,rewardContainer,null,function() {
if(_gthis.lastDayReward != lastUpdated) {
rewardContainer.setMaterials(_gthis.thisDayMaterialReward);
lastUpdated = _gthis.lastDayReward;
rewardHolder.updateSize();
}
});
this.city.gui.windowInner.addChild(rewardHolder);
this.city.gui.windowInner.addChild(new gui_GUISpacing(this.city.gui.windowInner,new common_Point(2,6)));
this.city.gui.windowAddInfoText("Total Production:");
var rewardContainer2 = new gui_MaterialsDisplay(this.totalMaterialReward);
var rewardHolder2 = null;
rewardHolder2 = new gui_ContainerHolder(this.city.gui.windowInner,this.city.gui.innerWindowStage,rewardContainer2,null,function() {
if(_gthis.lastDayReward != lastTotalReward) {
rewardContainer2.setMaterials(_gthis.totalMaterialReward);
lastTotalReward = _gthis.lastDayReward;
rewardHolder2.updateSize();
}
});
this.city.gui.windowInner.addChild(rewardHolder2);
this.city.gui.windowInner.addChild(new gui_GUISpacing(this.city.gui.windowInner,new common_Point(2,6)));
this.city.gui.windowAddInfoText(null,function() {
return "Next production in " + (24 - ((_gthis.city.simulation.time.timeSinceStart | 0) / 60 | 0) % 24) + " hour" + (((_gthis.city.simulation.time.timeSinceStart | 0) / 60 | 0) % 24 == 23 ? "" : "s") + ".";
});
}
,positionSprites: function() {
Building.prototype.positionSprites.call(this);
if(this.backSprite != null) {
this.backSprite.position.set(this.position.x,this.position.y);
}
}
,destroy: function() {
Building.prototype.destroy.call(this);
if(this.backSprite != null) {
this.bgStage.removeChild(this.backSprite);
}
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
Building.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_TheMachine.saveDefinition);
}
var value = this.animProgress;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.lastDayReward;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
queue.addString(haxe_Serializer.run(this.thisDayMaterialReward));
queue.addString(haxe_Serializer.run(this.totalMaterialReward));
}
,load: function(queue,definition) {
Building.prototype.load.call(this,queue);
if(queue.version < 8) {
return;
}
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"animProgress")) {
this.animProgress = loadMap.h["animProgress"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"lastDayReward")) {
this.lastDayReward = loadMap.h["lastDayReward"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"thisDayMaterialReward")) {
this.thisDayMaterialReward = loadMap.h["thisDayMaterialReward"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"totalMaterialReward")) {
this.totalMaterialReward = loadMap.h["totalMaterialReward"];
}
}
,__class__: buildings_TheMachine
});
var buildings_TinkerersHome = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.backTextureUsed = 0;
this.frontTextureUsed = 0;
buildings_House.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
if(buildings_TinkerersHome.frontTextures == null) {
buildings_TinkerersHome.frontTextures = Resources.getTexturesByWidth("spr_tinkerershouse_front_alt",20);
buildings_TinkerersHome.backTextures = Resources.getTexturesByWidth("spr_tinkerershouse_back_alt",20);
}
this.frontTextureUsed = random_Random.getInt(buildings_TinkerersHome.frontTextures.length);
this.backTextureUsed = random_Random.getInt(buildings_TinkerersHome.backTextures.length);
this.get_customizableDrawer().setCustomTextures(buildings_TinkerersHome.frontTextures[this.frontTextureUsed],null,buildings_TinkerersHome.backTextures[this.backTextureUsed]);
};
$hxClasses["buildings.TinkerersHome"] = buildings_TinkerersHome;
buildings_TinkerersHome.__name__ = "buildings.TinkerersHome";
buildings_TinkerersHome.__super__ = buildings_House;
buildings_TinkerersHome.prototype = $extend(buildings_House.prototype,{
get_drawerType: function() {
return buildings_buildingDrawers_CustomizableBuildingDrawer;
}
,get_customizableDrawer: function() {
return this.drawer;
}
,get_possibleUpgrades: function() {
return [buildingUpgrades_BetterTools];
}
,onBuild: function() {
buildings_House.prototype.onBuild.call(this);
this.city.progress.unlocks.unlock(cityUpgrades_MechanicalLiving);
}
,postLoad: function() {
this.get_customizableDrawer().setCustomTextures(buildings_TinkerersHome.frontTextures[this.frontTextureUsed],null,buildings_TinkerersHome.backTextures[this.backTextureUsed]);
}
,walkAround: function(citizen,stepsInBuilding) {
if(!citizen.hasBuildingInited) {
citizen.educationLevel = Math.max(Math.min(citizen.educationLevel + 0.01,1.25),citizen.educationLevel);
citizen.hasBuildingInited = true;
}
var r = random_Random.getInt(6);
if(r < 2 && stepsInBuilding > 120) {
citizen.changeFloorAndWaitRandom(30,60);
} else if(r == 2 || r == 3 || stepsInBuilding < 10) {
if(citizen.relativeY < 5) {
if(r == 2) {
citizen.moveAndWait(random_Random.getInt(3,6),random_Random.getInt(30,60),null,false,false);
} else {
citizen.moveAndWait(random_Random.getInt(15,16),random_Random.getInt(30,60),null,false,false);
}
} else if(r == 2) {
citizen.moveAndWait(random_Random.getInt(3,6),random_Random.getInt(30,60),null,false,false);
} else {
citizen.moveAndWait(random_Random.getInt(12,16),random_Random.getInt(30,60),null,false,false);
}
} else {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = random_Random.getInt(90,120);
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_House.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_TinkerersHome.saveDefinition);
}
var value = this.frontTextureUsed;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.backTextureUsed;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
,load: function(queue,definition) {
buildings_House.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"frontTextureUsed")) {
this.frontTextureUsed = loadMap.h["frontTextureUsed"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"backTextureUsed")) {
this.backTextureUsed = loadMap.h["backTextureUsed"];
}
this.postLoad();
}
,__class__: buildings_TinkerersHome
});
var buildings_TreeHuggerBase = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.parkSprite = null;
buildings_House.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.parkSprite = new PIXI.Sprite(Resources.getTexture("spr_treehuggerbase"));
this.parkSprite.position.set(position.x,position.y);
bgStage.addChild(this.parkSprite);
};
$hxClasses["buildings.TreeHuggerBase"] = buildings_TreeHuggerBase;
buildings_TreeHuggerBase.__name__ = "buildings.TreeHuggerBase";
buildings_TreeHuggerBase.__super__ = buildings_House;
buildings_TreeHuggerBase.prototype = $extend(buildings_House.prototype,{
get_drawerType: function() {
return buildings_buildingDrawers_AutoMergingBuildingDrawer;
}
,get_mergingDrawer: function() {
return this.drawer;
}
,postCreate: function() {
buildings_House.prototype.postCreate.call(this);
this.positionSprites();
}
,positionSprites: function() {
buildings_House.prototype.positionSprites.call(this);
if(this.parkSprite != null) {
this.parkSprite.position.set(this.position.x,this.position.y);
}
}
,destroy: function() {
buildings_House.prototype.destroy.call(this);
this.bgStage.removeChild(this.parkSprite);
}
,walkAround: function(citizen,stepsInBuilding) {
if(citizen.relativeX == 10) {
citizen.canViewSelfInBuilding = false;
} else {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = 10;
citizen.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
}
,__class__: buildings_TreeHuggerBase
});
var buildings_TreePlantation = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.regrowSpeedBoost = 1;
this.initialMaterials = 100;
this.regrowProgress = 0;
this.maxCitizenX = 14;
this.minCitizenX = 4;
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
this.materialsLeft = 0;
this.treesCutTextures = Resources.getTexturesByWidth("spr_treeplantation_trees",20);
this.regrowTextures = Resources.getTexturesByWidth("spr_treeplantation_trees_grow",20);
this.treesSprite = new PIXI.Sprite(this.regrowTextures[0]);
this.treesSprite.position.set(position.x,position.y);
bgStage.addChild(this.treesSprite);
};
$hxClasses["buildings.TreePlantation"] = buildings_TreePlantation;
buildings_TreePlantation.__name__ = "buildings.TreePlantation";
buildings_TreePlantation.__interfaces__ = [worldResources_ILimitedMaterialGatherPlace];
buildings_TreePlantation.__super__ = buildings_Work;
buildings_TreePlantation.prototype = $extend(buildings_Work.prototype,{
get_destroyedOnEmpty: function() {
return false;
}
,get_resourceName: function() {
return "wood";
}
,get_regrowSpeed: function() {
return 0.008 * this.getExtraTreeGrowth() * this.regrowSpeedBoost;
}
,get_doNotGather: function() {
return false;
}
,get_stayIfEmpty: function() {
return false;
}
,get_possibleUpgrades: function() {
return [buildingUpgrades_AutomaticWaterManagement];
}
,update: function(timeMod) {
buildings_Work.prototype.update.call(this,timeMod);
var city = this.city;
if(this.materialsLeft <= 0) {
var this1 = city.simulation.time.timeSinceStart / 60 % 24;
var start = 7;
var end = 20;
if(start < end ? this1 >= start && this1 < end : this1 >= start || this1 < end) {
this.regrowProgress += this.get_regrowSpeed() * timeMod;
} else {
var this1 = city.simulation.time.timeSinceStart / 60 % 24;
var start = 7 - 1;
var end = 20 + 1;
if(start < end ? this1 >= start && this1 < end : this1 >= start || this1 < end) {
this.regrowProgress += this.get_regrowSpeed() * timeMod * 0.5;
}
}
if(this.regrowProgress >= 100) {
this.materialsLeft = this.initialMaterials;
this.regrowProgress = 0;
}
this.updateTexture();
}
}
,updateTexture: function() {
var materialsLeft = this.materialsLeft;
var initialMaterials = this.initialMaterials;
var textures = this.treesCutTextures;
var regrowTextures = this.regrowTextures;
var sprite = this.treesSprite;
if(materialsLeft <= 0.0000001) {
sprite.texture = regrowTextures != null ? regrowTextures[this.regrowProgress / 100 * regrowTextures.length | 0] : textures[textures.length - 1];
} else {
var i = Math.floor((initialMaterials - materialsLeft) / initialMaterials * textures.length);
if(initialMaterials != materialsLeft && i == 0 && textures.length > 1) {
i = 1;
}
sprite.texture = textures[i];
}
}
,positionSprites: function() {
buildings_Work.prototype.positionSprites.call(this);
if(this.treesSprite != null) {
this.treesSprite.position.set(this.position.x,this.position.y);
}
}
,destroy: function() {
buildings_Work.prototype.destroy.call(this);
this.bgStage.removeChild(this.treesSprite);
}
,work: function(citizen,timeMod,shouldStopWorking) {
var _gthis = this;
if(shouldStopWorking) {
citizen.currentAction = LifeAction.Nothing;
return;
}
var anyMaterialsLeft = this.materialsLeft > 0;
var modifyWithHappiness = true;
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
citizen.moveAndWait(random_Random.getInt(this.minCitizenX,this.maxCitizenX),random_Random.getInt(anyMaterialsLeft ? 60 : 120,anyMaterialsLeft ? 90 : 180),function() {
if(anyMaterialsLeft) {
var woodCut = _gthis.city.simulation.boostManager.currentGlobalBoostAmount * 0.2;
_gthis.materialsLeft -= woodCut;
_gthis.city.materials.wood += woodCut;
_gthis.city.simulation.stats.materialProduction[1][0] += woodCut;
} else {
_gthis.regrowProgress += 0.5 * _gthis.getExtraTreeGrowth();
}
_gthis.updateTexture();
},modifyWithHappiness,false);
}
,addWindowInfoLines: function() {
var _gthis = this;
buildings_Work.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
if(_gthis.materialsLeft <= 0) {
return "Trees " + (_gthis.regrowProgress | 0) + "% grown.";
} else {
return "" + (_gthis.materialsLeft | 0) + "/" + (_gthis.initialMaterials | 0) + " wood left.";
}
});
}
,getExtraTreeGrowth: function() {
return 1 + this.getEffectsOfAdjecentBuildings("increaseTreeGrowth");
}
,postLoad: function() {
this.updateTexture();
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Work.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_TreePlantation.saveDefinition);
}
var value = this.regrowProgress;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.materialsLeft;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
}
,load: function(queue,definition) {
buildings_Work.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"regrowProgress")) {
this.regrowProgress = loadMap.h["regrowProgress"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"materialsLeft")) {
this.materialsLeft = loadMap.h["materialsLeft"];
}
this.postLoad();
}
,__class__: buildings_TreePlantation
});
var buildings_UnknownBuilding = function(game,stage,bgStage,city,world,position,worldPosition,id) {
Building.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
};
$hxClasses["buildings.UnknownBuilding"] = buildings_UnknownBuilding;
buildings_UnknownBuilding.__name__ = "buildings.UnknownBuilding";
buildings_UnknownBuilding.__super__ = Building;
buildings_UnknownBuilding.prototype = $extend(Building.prototype,{
load: function(queue,definition) {
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var qpos = intToRead;
queue.readStart = qpos;
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
var value = queue.size + 4;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
,__class__: buildings_UnknownBuilding
});
var buildings_Villa = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.teleportX = 3;
this.currentAdjBonus = 0;
this.timesUsedTo = 0;
this.timesUsed = 0;
buildings_House.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
};
$hxClasses["buildings.Villa"] = buildings_Villa;
buildings_Villa.__name__ = "buildings.Villa";
buildings_Villa.__super__ = buildings_House;
buildings_Villa.prototype = $extend(buildings_House.prototype,{
get_hasPrivateTeleporter: function() {
return true;
}
,get_possibleUpgrades: function() {
return [];
}
,walkAround: function(citizen,stepsInBuilding) {
var r = random_Random.getInt(3);
if(r == 0 && stepsInBuilding > 120) {
if(citizen.relativeX < 5) {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = 5;
citizen1.setPath(arr,0,2,true);
citizen.pathEndFunction = function() {
citizen.changeFloorAndWaitRandom(30,60);
};
citizen.pathOnlyRelatedTo = citizen.inPermanent;
} else {
citizen.changeFloorAndWaitRandom(30,60);
}
} else if(r == 1 || stepsInBuilding <= 10 && citizen.relativeX < this.teleportX + 0.5) {
if(citizen.relativeY < 5) {
citizen.moveAndWait(random_Random.getInt(10,16),random_Random.getInt(30,60),null,false,false);
} else if(random_Random.getInt(2) == 1) {
citizen.moveAndWait(random_Random.getInt(5,8),random_Random.getInt(30,60),null,false,false);
} else {
citizen.moveAndWait(random_Random.getInt(13,16),random_Random.getInt(30,60),null,false,false);
}
} else {
var citizen1 = citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = random_Random.getInt(90,120);
citizen1.setPath(arr,0,2,true);
citizen.pathEndFunction = null;
citizen.pathOnlyRelatedTo = citizen.inPermanent;
}
}
,addWindowInfoLines: function() {
var _gthis = this;
buildings_House.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
return "Teleported from " + _gthis.timesUsed + " times.";
});
this.city.gui.windowAddInfoText(null,function() {
return "Teleported to " + _gthis.timesUsedTo + " times.";
});
}
,createTeleportParticle: function(rayTexture) {
if(rayTexture == null) {
rayTexture = "unused";
}
this.city.particles.addParticle(Resources.getTexturesByWidth("spr_smallteleporter_ray",3),new common_Point(this.position.x + 3,this.position.y + 12));
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_House.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_Villa.saveDefinition);
}
var value = this.timesUsed;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.timesUsedTo;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
,load: function(queue,definition) {
buildings_House.prototype.load.call(this,queue);
if(queue.version < 6) {
return;
}
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"timesUsed")) {
this.timesUsed = loadMap.h["timesUsed"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"timesUsedTo")) {
this.timesUsedTo = loadMap.h["timesUsedTo"];
}
}
,__class__: buildings_Villa
});
var buildings_WoodcuttingCentre = function(game,stage,bgStage,city,world,position,worldPosition,id) {
buildings_BlueCollarWork.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
};
$hxClasses["buildings.WoodcuttingCentre"] = buildings_WoodcuttingCentre;
buildings_WoodcuttingCentre.__name__ = "buildings.WoodcuttingCentre";
buildings_WoodcuttingCentre.__super__ = buildings_BlueCollarWork;
buildings_WoodcuttingCentre.prototype = $extend(buildings_BlueCollarWork.prototype,{
work: function(citizen,timeMod,shouldStopWorking) {
var _gthis = this;
this.doBlueCollarJob(citizen,timeMod,shouldStopWorking,[worldResources_Forest,buildings_TreePlantation],function(forest) {
var _this = _gthis.city.simulation;
var finalWoodCutPerAction = 0.2 * (_gthis.city.progress.story.hiddenBoost && _gthis.city.materials.wood <= 6 ? 1.75 : 1) * (Config.earlyGameFix1 && _this.citizens.length < 30 ? 1.3 - 0.3 * (_this.citizens.length / 60) : 1) * _gthis.city.simulation.boostManager.currentGlobalBoostAmount;
_gthis.city.materials.wood += finalWoodCutPerAction;
_gthis.city.simulation.stats.materialProduction[1][0] += finalWoodCutPerAction;
forest.materialsLeft -= finalWoodCutPerAction;
},60,90);
}
,__class__: buildings_WoodcuttingCentre
});
var buildings_Workshop = function(game,stage,bgStage,city,world,position,worldPosition,id) {
this.totalKnowledgeGenerated = 0;
this.totalMaterialUsed = 0;
this.materialMade = 0;
this.isProducingKnowledge = true;
buildings_Work.call(this,game,stage,bgStage,city,world,position,worldPosition,id);
};
$hxClasses["buildings.Workshop"] = buildings_Workshop;
buildings_Workshop.__name__ = "buildings.Workshop";
buildings_Workshop.__super__ = buildings_Work;
buildings_Workshop.prototype = $extend(buildings_Work.prototype,{
onBuild: function() {
this.city.simulation.bonuses.machinePartsFactorySpeed *= 1.25;
}
,get_possibleBuildingModes: function() {
return [buildingUpgrades_WorkshopKnowledge,buildingUpgrades_WorkshopMachineParts];
}
,get_possibleCityUpgrades: function() {
return [cityUpgrades_BuildingRecycling,cityUpgrades_BuildingRecycling2,cityUpgrades_BuildingRecycling3];
}
,work: function(citizen,timeMod,shouldStopWorking) {
if(shouldStopWorking) {
citizen.currentAction = LifeAction.Nothing;
return;
}
if(this.workers.indexOf(citizen) == 0) {
if(random_Random.getInt(5) < 4) {
var modifyWithHappiness = false;
var slowMove = true;
if(slowMove == null) {
slowMove = false;
}
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
citizen.moveAndWait(random_Random.getInt(4,8),random_Random.getInt(60,120),null,modifyWithHappiness,slowMove);
} else {
var modifyWithHappiness = false;
var slowMove = true;
if(slowMove == null) {
slowMove = false;
}
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
citizen.moveAndWait(random_Random.getInt(11,14),random_Random.getInt(60,120),null,modifyWithHappiness,slowMove);
}
} else if(citizen.relativeY < 2) {
citizen.changeFloor();
} else if(random_Random.getInt(2) == 0) {
var modifyWithHappiness = false;
var slowMove = true;
if(slowMove == null) {
slowMove = false;
}
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
citizen.moveAndWait(random_Random.getInt(3,6),random_Random.getInt(60,120),null,modifyWithHappiness,slowMove);
} else {
var modifyWithHappiness = false;
var slowMove = true;
if(slowMove == null) {
slowMove = false;
}
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
citizen.moveAndWait(random_Random.getInt(13,14),random_Random.getInt(60,120),null,modifyWithHappiness,slowMove);
}
if(this.isProducingKnowledge) {
var newKnowledge = 0.15 * citizen.get_educationSpeedModifier() * this.city.simulation.boostManager.currentGlobalBoostAmount;
this.city.materials.knowledge += newKnowledge;
this.city.simulation.stats.materialProduction[8][0] += newKnowledge;
this.totalKnowledgeGenerated += newKnowledge;
} else if(this.city.materials.wood >= 1) {
var convertedInto = 0.075 * citizen.get_educationSpeedModifier() * this.city.simulation.boostManager.currentGlobalBoostAmount;
this.city.materials.machineParts += convertedInto;
this.city.simulation.stats.materialProduction[3][0] += convertedInto;
this.materialMade += convertedInto;
var materialsUsed = convertedInto * 2;
this.city.materials.wood -= materialsUsed;
this.city.simulation.stats.materialUsed[1][0] += materialsUsed;
this.totalMaterialUsed += materialsUsed;
}
}
,update: function(timeMod) {
buildings_Work.prototype.update.call(this,timeMod);
}
,destroy: function() {
buildings_Work.prototype.destroy.call(this);
this.city.simulation.bonuses.machinePartsFactorySpeed /= 1.25;
}
,addWindowInfoLines: function() {
var _gthis = this;
buildings_Work.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
return "" + (_gthis.totalKnowledgeGenerated | 0) + " knowledge gathered. " + ("" + (_gthis.totalMaterialUsed | 0) + " wood used to make " + (_gthis.materialMade | 0) + " machine parts.");
});
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
buildings_Work.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(buildings_Workshop.saveDefinition);
}
var value = this.materialMade;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.totalMaterialUsed;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.totalKnowledgeGenerated;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
}
,load: function(queue,definition) {
buildings_Work.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"materialMade")) {
this.materialMade = loadMap.h["materialMade"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"totalMaterialUsed")) {
this.totalMaterialUsed = loadMap.h["totalMaterialUsed"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"totalKnowledgeGenerated")) {
this.totalKnowledgeGenerated = loadMap.h["totalKnowledgeGenerated"];
}
}
,__class__: buildings_Workshop
});
var buildings_buildingBehaviours_ParkFestivalEntertainment = function(park,bgStage) {
this.park = park;
this.podiumSprite = null;
this.bgStage = bgStage;
};
$hxClasses["buildings.buildingBehaviours.ParkFestivalEntertainment"] = buildings_buildingBehaviours_ParkFestivalEntertainment;
buildings_buildingBehaviours_ParkFestivalEntertainment.__name__ = "buildings.buildingBehaviours.ParkFestivalEntertainment";
buildings_buildingBehaviours_ParkFestivalEntertainment.prototype = {
doFestivalWork: function(festival,citizen,timeMod,currentMainTexture,citizenID) {
var shouldShowBGSprite = true;
var bgSpriteXPos = 3;
if(this.park.leftBuilding != null) {
if(shouldShowBGSprite && this.park.leftBuilding.is(buildings_Park)) {
shouldShowBGSprite = false;
}
if(shouldShowBGSprite && this.park.leftBuilding.is(buildings_BotanicalGardens)) {
shouldShowBGSprite = false;
if(this.park.leftBuilding.bottomBuilding != null && this.park.leftBuilding.bottomBuilding.is(buildings_BotanicalGardens)) {
if(currentMainTexture == 0) {
bgSpriteXPos = -3;
}
shouldShowBGSprite = true;
}
}
}
if(shouldShowBGSprite) {
if(this.podiumSprite == null) {
this.podiumSprite = new PIXI.Sprite(Resources.getTexture("spr_festival_podium_small"));
this.bgStage.addChild(this.podiumSprite);
}
this.podiumSprite.position.set(this.park.position.x + bgSpriteXPos,this.park.position.y + 20 - this.podiumSprite.height - 1);
var myXPos = citizenID == 0 ? bgSpriteXPos + 3 : bgSpriteXPos;
var spd = citizen.pathWalkSpeed * timeMod;
Citizen.shouldUpdateDraw = true;
if(Math.abs(myXPos - citizen.relativeX) < spd) {
citizen.relativeX = myXPos;
} else {
var num = myXPos - citizen.relativeX;
citizen.relativeX += (num > 0 ? 1 : num < 0 ? -1 : 0) * spd;
}
if(citizen.relativeX >= myXPos && citizen.relativeX <= myXPos + 1) {
citizen.setRelativePos(myXPos,4);
}
} else {
if(this.podiumSprite != null) {
this.podiumSprite.destroy();
this.podiumSprite = null;
}
citizen.moveAndWait(random_Random.getInt(0,17),random_Random.getInt(60,90),null,false,false);
}
}
,beEntertainedFestival: function(festival,citizen,timeMod) {
if(this.podiumSprite == null) {
buildings_buildingBehaviours_ParkWalk.beEntertainedPark(this.park.leftBuilding,this.park.rightBuilding,citizen);
} else {
var xMin = Math.ceil(this.podiumSprite.position.x + this.podiumSprite.width - this.park.position.x);
var xMax = this.park.rightBuilding != null && (this.park.rightBuilding.is(buildings_Park) || this.park.rightBuilding.is(buildings_BotanicalGardens));
var modifyWithHappiness = false;
var slowMove = true;
if(slowMove == null) {
slowMove = false;
}
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
citizen.moveAndWait(random_Random.getInt(xMin,xMax ? 19 : 16),random_Random.getInt(100,180),null,modifyWithHappiness,slowMove);
}
}
,destroy: function() {
if(this.podiumSprite != null) {
this.podiumSprite.destroy();
}
}
,stop: function() {
}
,__class__: buildings_buildingBehaviours_ParkFestivalEntertainment
};
var buildings_buildingBehaviours_ParkWalk = function() { };
$hxClasses["buildings.buildingBehaviours.ParkWalk"] = buildings_buildingBehaviours_ParkWalk;
buildings_buildingBehaviours_ParkWalk.__name__ = "buildings.buildingBehaviours.ParkWalk";
buildings_buildingBehaviours_ParkWalk.beEntertainedPark = function(leftBuilding,rightBuilding,citizen) {
var leftGardensSkipBuilding = false;
var rightGardensSkipBuilding = false;
if(leftBuilding != null && leftBuilding.is(buildings_ParkPod)) {
leftBuilding = leftBuilding.leftBuilding;
leftGardensSkipBuilding = true;
}
if(rightBuilding != null && rightBuilding.is(buildings_ParkPod)) {
rightBuilding = rightBuilding.rightBuilding;
rightGardensSkipBuilding = true;
}
var leftGardens = leftBuilding != null && leftBuilding.is(buildings_BotanicalGardens);
var rightGardens = rightBuilding != null && rightBuilding.is(buildings_BotanicalGardens);
var leftGardensCanWalk = leftGardens && (leftBuilding.bottomBuilding == null || !leftBuilding.bottomBuilding.is(buildings_BotanicalGardens));
var rightGardensCanWalk = rightGardens && (rightBuilding.bottomBuilding == null || !rightBuilding.bottomBuilding.is(buildings_BotanicalGardens));
if(!leftGardens) {
if(leftBuilding != null) {
if(leftBuilding.is(buildings_Park)) {
leftGardens = true;
leftGardensCanWalk = true;
}
}
}
if(!rightGardens) {
if(rightBuilding != null) {
if(rightBuilding.is(buildings_Park)) {
rightGardens = true;
rightGardensCanWalk = true;
}
}
}
var doingSomething = false;
var goTo = random_Random.getInt(1 + (leftGardens ? 1 : 0) + (rightGardens ? 1 : 0));
if(leftGardens && goTo == 0) {
if(leftGardensSkipBuilding) {
if(leftGardensCanWalk) {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[10].length > 0 ? pool[10].splice(pool[10].length - 1,1)[0] : new Int32Array(10);
arr[0] = 12;
arr[1] = 50;
arr[2] = 2;
arr[3] = 0;
arr[4] = 2;
arr[5] = 0;
arr[6] = 4;
arr[7] = random_Random.getInt(0,18);
arr[8] = 8;
arr[9] = random_Random.getInt(100,180);
citizen.setPath(arr,0,8,true);
doingSomething = true;
}
} else if(leftGardensCanWalk) {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[8].length > 0 ? pool[8].splice(pool[8].length - 1,1)[0] : new Int32Array(8);
arr[0] = 12;
arr[1] = 50;
arr[2] = 2;
arr[3] = 0;
arr[4] = 4;
arr[5] = random_Random.getInt(0,18);
arr[6] = 8;
arr[7] = random_Random.getInt(100,180);
citizen.setPath(arr,0,8,true);
doingSomething = true;
} else if(random_Random.getInt(2) == 0) {
var modifyWithHappiness = false;
var slowMove = true;
if(slowMove == null) {
slowMove = false;
}
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
citizen.moveAndWait(random_Random.getInt(-3,-3),random_Random.getInt(70,90),null,modifyWithHappiness,slowMove);
doingSomething = true;
}
} else if(rightGardens && goTo == 1) {
if(rightGardensSkipBuilding) {
if(rightGardensCanWalk) {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[10].length > 0 ? pool[10].splice(pool[10].length - 1,1)[0] : new Int32Array(10);
arr[0] = 12;
arr[1] = 50;
arr[2] = 3;
arr[3] = 0;
arr[4] = 3;
arr[5] = 0;
arr[6] = 4;
arr[7] = random_Random.getInt(0,18);
arr[8] = 8;
arr[9] = random_Random.getInt(100,180);
citizen.setPath(arr,0,8,true);
doingSomething = true;
}
} else if(rightGardensCanWalk) {
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[8].length > 0 ? pool[8].splice(pool[8].length - 1,1)[0] : new Int32Array(8);
arr[0] = 12;
arr[1] = 50;
arr[2] = 3;
arr[3] = 0;
arr[4] = 4;
arr[5] = random_Random.getInt(0,18);
arr[6] = 8;
arr[7] = random_Random.getInt(100,180);
citizen.setPath(arr,0,8,true);
doingSomething = true;
} else if(random_Random.getInt(2) == 0) {
var modifyWithHappiness = false;
var slowMove = true;
if(slowMove == null) {
slowMove = false;
}
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
citizen.moveAndWait(random_Random.getInt(21,21),random_Random.getInt(70,90),null,modifyWithHappiness,slowMove);
doingSomething = true;
}
}
if(!doingSomething) {
var modifyWithHappiness = false;
var slowMove = true;
if(slowMove == null) {
slowMove = false;
}
if(modifyWithHappiness == null) {
modifyWithHappiness = false;
}
citizen.moveAndWait(random_Random.getInt(leftGardens ? 0 : 3,rightGardens ? 18 : 15),random_Random.getInt(100,180),null,modifyWithHappiness,slowMove);
}
};
var buildings_buildingDrawers_BuildingDrawer = function(building,stage,bgStage,textureName) {
this.building = building;
this.stage = stage;
this.bgStage = bgStage;
this.currentTextureName = textureName;
this.currentTextureGroupName = textureName;
this.canMergeH = false;
this.canMergeV = false;
};
$hxClasses["buildings.buildingDrawers.BuildingDrawer"] = buildings_buildingDrawers_BuildingDrawer;
buildings_buildingDrawers_BuildingDrawer.__name__ = "buildings.buildingDrawers.BuildingDrawer";
buildings_buildingDrawers_BuildingDrawer.prototype = {
positionSpritesMerging: function() {
}
,positionSprites: function() {
}
,changeMainTexture: function(textureName) {
this.currentTextureName = textureName;
this.currentTextureGroupName = textureName;
}
,changeTextureGroup: function(newGroup) {
this.currentTextureGroupName = newGroup;
}
,destroy: function() {
}
,__class__: buildings_buildingDrawers_BuildingDrawer
};
var buildings_buildingDrawers_AllDirMergingBuildingDrawer = function(building,stage,bgStage,textureName) {
this.fgTexturesSet = null;
this.bgTexturesSet = null;
this.currentSecondaryTexture = 0;
this.secondaryBackgroundTextureName = null;
buildings_buildingDrawers_BuildingDrawer.call(this,building,stage,bgStage,textureName);
this.canMergeH = true;
this.canMergeV = true;
this.bgSpriteTopLeft = new PIXI.Sprite();
bgStage.cacheableChildren.push(this.bgSpriteTopLeft);
bgStage.isInvalid = true;
this.bgSpriteTopRight = new PIXI.Sprite();
bgStage.cacheableChildren.push(this.bgSpriteTopRight);
bgStage.isInvalid = true;
this.spriteTopLeft = new PIXI.Sprite();
stage.cacheableChildren.push(this.spriteTopLeft);
stage.isInvalid = true;
this.spriteTopRight = new PIXI.Sprite();
stage.cacheableChildren.push(this.spriteTopRight);
stage.isInvalid = true;
this.bgSpriteBottomLeft = new PIXI.Sprite();
bgStage.cacheableChildren.push(this.bgSpriteBottomLeft);
bgStage.isInvalid = true;
this.bgSpriteBottomRight = new PIXI.Sprite();
bgStage.cacheableChildren.push(this.bgSpriteBottomRight);
bgStage.isInvalid = true;
this.spriteBottomLeft = new PIXI.Sprite();
stage.cacheableChildren.push(this.spriteBottomLeft);
stage.isInvalid = true;
this.spriteBottomRight = new PIXI.Sprite();
stage.cacheableChildren.push(this.spriteBottomRight);
stage.isInvalid = true;
this.spriteSecondaryBackground = new PIXI.Sprite();
bgStage.cacheableChildren.push(this.spriteSecondaryBackground);
bgStage.isInvalid = true;
this.positionSprites();
this.secondaryBackgroundTextureName = null;
};
$hxClasses["buildings.buildingDrawers.AllDirMergingBuildingDrawer"] = buildings_buildingDrawers_AllDirMergingBuildingDrawer;
buildings_buildingDrawers_AllDirMergingBuildingDrawer.__name__ = "buildings.buildingDrawers.AllDirMergingBuildingDrawer";
buildings_buildingDrawers_AllDirMergingBuildingDrawer.__super__ = buildings_buildingDrawers_BuildingDrawer;
buildings_buildingDrawers_AllDirMergingBuildingDrawer.prototype = $extend(buildings_buildingDrawers_BuildingDrawer.prototype,{
positionSprites: function() {
this.building.city.updateConnectedBuildingSprites = true;
}
,setBackgroundTextures: function(bgTextures) {
this.bgTexturesSet = Resources.getTexturesAsGrid(bgTextures,10,2,2,true);
}
,setForegroundTextures: function(fgTextures) {
this.fgTexturesSet = Resources.getTexturesAsGrid(fgTextures,10,2,2,true);
}
,positionSpritesMerging: function() {
var halfPermWidth = 10. | 0;
var halfPermHeight = 10. | 0;
this.spriteTopLeft.position.set(this.building.position.x,this.building.position.y);
this.bgSpriteTopLeft.position.set(this.building.position.x,this.building.position.y);
this.spriteTopRight.position.set(this.building.position.x + halfPermWidth,this.building.position.y);
this.bgSpriteTopRight.position.set(this.building.position.x + halfPermWidth,this.building.position.y);
this.spriteBottomLeft.position.set(this.building.position.x,this.building.position.y + halfPermHeight);
this.bgSpriteBottomLeft.position.set(this.building.position.x,this.building.position.y + halfPermHeight);
this.spriteBottomRight.position.set(this.building.position.x + halfPermWidth,this.building.position.y + halfPermHeight);
this.bgSpriteBottomRight.position.set(this.building.position.x + halfPermWidth,this.building.position.y + halfPermHeight);
this.spriteSecondaryBackground.position.set(this.building.position.x,this.building.position.y);
var hasLeftBuilding = this.isConnectedBuilding(this.building.leftBuilding);
var hasRightBuilding = this.isConnectedBuilding(this.building.rightBuilding);
var hasTopBuilding = this.isConnectedBuilding(this.building.topBuilding);
var hasBottomBuilding = this.isConnectedBuilding(this.building.bottomBuilding);
var hasTopLeftBuilding = false;
var hasTopRightBuilding = false;
var hasBottomLeftBuilding = false;
var hasBottomRightBuilding = false;
if(hasLeftBuilding && hasTopBuilding) {
hasTopLeftBuilding = this.isConnectedBuilding(this.building.leftBuilding.topBuilding);
}
if(hasRightBuilding && hasTopBuilding) {
hasTopRightBuilding = this.isConnectedBuilding(this.building.rightBuilding.topBuilding);
}
if(hasLeftBuilding && hasBottomBuilding) {
hasBottomLeftBuilding = this.isConnectedBuilding(this.building.leftBuilding.bottomBuilding);
}
if(hasRightBuilding && hasBottomBuilding) {
hasBottomRightBuilding = this.isConnectedBuilding(this.building.rightBuilding.bottomBuilding);
}
hasLeftBuilding = hasLeftBuilding || this.isConnectedBuildingHOnly(this.building.leftBuilding);
hasRightBuilding = hasRightBuilding || this.isConnectedBuildingHOnly(this.building.rightBuilding);
var textures = Resources.getTexturesBySize(this.currentTextureName,halfPermWidth,halfPermHeight,2,true);
var useDoor = this.building.worldPosition.y == 0;
var topLeftIndex = 6 * ((hasLeftBuilding ? 1 : 0) + (hasTopBuilding ? 2 : 0) + (hasTopLeftBuilding ? 1 : 0));
var topRightIndex = 1 + 6 * ((hasRightBuilding ? 1 : 0) + (hasTopBuilding ? 2 : 0) + (hasTopRightBuilding ? 1 : 0));
var bottomLeftIndex = 6 * ((hasLeftBuilding ? 1 : 0) + (hasBottomBuilding ? 2 : 0) + (hasBottomLeftBuilding ? 1 : 0));
var bottomRightIndex = 1 + 6 * ((hasRightBuilding ? 1 : 0) + (hasBottomBuilding ? 2 : 0) + (hasBottomRightBuilding ? 1 : 0));
if(this.fgTexturesSet != null && !useDoor) {
var topLeftIndex2 = 2 * ((hasLeftBuilding ? 1 : 0) + (hasTopBuilding ? 2 : 0) + (hasTopLeftBuilding ? 1 : 0));
this.spriteTopLeft.texture = this.fgTexturesSet[topLeftIndex2][0];
var topRightIndex2 = 1 + 2 * ((hasRightBuilding ? 1 : 0) + (hasTopBuilding ? 2 : 0) + (hasTopRightBuilding ? 1 : 0));
this.spriteTopRight.texture = this.fgTexturesSet[topRightIndex2][0];
var bottomLeftIndex2 = 2 * ((hasLeftBuilding ? 1 : 0) + (hasBottomBuilding ? 2 : 0) + (hasBottomLeftBuilding ? 1 : 0));
this.spriteBottomLeft.texture = this.fgTexturesSet[bottomLeftIndex2][1];
var bottomRightIndex2 = 1 + 2 * ((hasRightBuilding ? 1 : 0) + (hasBottomBuilding ? 2 : 0) + (hasBottomRightBuilding ? 1 : 0));
this.spriteBottomRight.texture = this.fgTexturesSet[bottomRightIndex2][1];
} else {
this.spriteTopLeft.texture = textures[topLeftIndex + (useDoor ? 2 : 0)][0];
this.spriteTopRight.texture = textures[topRightIndex + (useDoor ? 2 : 0)][0];
this.spriteBottomLeft.texture = textures[bottomLeftIndex + (useDoor ? 2 : 0)][1];
this.spriteBottomRight.texture = textures[bottomRightIndex + (useDoor ? 2 : 0)][1];
}
if(this.bgTexturesSet != null) {
var topLeftIndex2 = 2 * ((hasLeftBuilding ? 1 : 0) + (hasTopBuilding ? 2 : 0) + (hasTopLeftBuilding ? 1 : 0));
this.bgSpriteTopLeft.texture = this.bgTexturesSet[topLeftIndex2][0];
var topRightIndex2 = 1 + 2 * ((hasRightBuilding ? 1 : 0) + (hasTopBuilding ? 2 : 0) + (hasTopRightBuilding ? 1 : 0));
this.bgSpriteTopRight.texture = this.bgTexturesSet[topRightIndex2][0];
var bottomLeftIndex2 = 2 * ((hasLeftBuilding ? 1 : 0) + (hasBottomBuilding ? 2 : 0) + (hasBottomLeftBuilding ? 1 : 0));
this.bgSpriteBottomLeft.texture = this.bgTexturesSet[bottomLeftIndex2][1];
var bottomRightIndex2 = 1 + 2 * ((hasRightBuilding ? 1 : 0) + (hasBottomBuilding ? 2 : 0) + (hasBottomRightBuilding ? 1 : 0));
this.bgSpriteBottomRight.texture = this.bgTexturesSet[bottomRightIndex2][1];
} else {
this.bgSpriteTopLeft.texture = textures[topLeftIndex + 4][0];
this.bgSpriteTopRight.texture = textures[topRightIndex + 4][0];
this.bgSpriteBottomLeft.texture = textures[bottomLeftIndex + 4][1];
this.bgSpriteBottomRight.texture = textures[bottomRightIndex + 4][1];
}
this.bgStage.isInvalid = true;
this.stage.isInvalid = true;
if(this.secondaryBackgroundTextureName != null) {
var leaderBuilding = this.building;
var cl = js_Boot.getClass(this.building);
while(leaderBuilding.bottomBuilding != null && leaderBuilding.bottomBuilding.is(cl)) leaderBuilding = leaderBuilding.bottomBuilding;
if(leaderBuilding != this.building) {
var drawer = leaderBuilding.drawer;
if(drawer.secondaryBackgroundTextureName != null) {
var leaderGroup = drawer.getCurrentSecondaryTextureGroup();
if(leaderGroup != this.getCurrentSecondaryTextureGroup()) {
this.setGroupOfSecondaryTextureForBuilding(this.building,leaderGroup);
}
}
}
this.updateSecondaryBackgroundImage(hasTopBuilding,hasBottomBuilding);
}
}
,setSecondaryBackgroundImages: function(image,secondaryBackgroundSets,currentTexture,secondaryTextureOnSet) {
this.secondaryBackgroundTextureName = image;
this.secondaryBackgroundSets = secondaryBackgroundSets;
this.currentSecondaryTexture = currentTexture;
this.secondaryTextureOnSet = secondaryTextureOnSet;
this.updateSecondaryBackgroundImageNoExtraInfo();
}
,updateSecondaryBackgroundImageNoExtraInfo: function() {
this.updateSecondaryBackgroundImage(this.isConnectedBuilding(this.building.topBuilding),this.isConnectedBuilding(this.building.bottomBuilding));
}
,updateSecondaryBackgroundImage: function(hasTopBuilding,hasBottomBuilding) {
if(this.secondaryBackgroundTextureName == null) {
return;
}
var tmp = this.getCurrentSecondaryBackTextures();
this.spriteSecondaryBackground.texture = tmp[(hasBottomBuilding ? 1 : 0) + (hasTopBuilding ? 3 : 0) + (hasTopBuilding && hasBottomBuilding ? -2 : 0)];
this.bgStage.isInvalid = true;
}
,changeMainTexture: function(textureName) {
buildings_buildingDrawers_BuildingDrawer.prototype.changeMainTexture.call(this,textureName);
this.positionSprites();
}
,destroy: function() {
buildings_buildingDrawers_BuildingDrawer.prototype.destroy.call(this);
var _this = this.bgStage;
var child = this.bgSpriteTopLeft;
HxOverrides.remove(_this.cacheableChildren,child);
_this.isInvalid = true;
if(child.parent != null) {
child.parent.removeChild(child);
}
var _this = this.bgStage;
var child = this.bgSpriteTopRight;
HxOverrides.remove(_this.cacheableChildren,child);
_this.isInvalid = true;
if(child.parent != null) {
child.parent.removeChild(child);
}
var _this = this.bgStage;
var child = this.bgSpriteBottomLeft;
HxOverrides.remove(_this.cacheableChildren,child);
_this.isInvalid = true;
if(child.parent != null) {
child.parent.removeChild(child);
}
var _this = this.bgStage;
var child = this.bgSpriteBottomRight;
HxOverrides.remove(_this.cacheableChildren,child);
_this.isInvalid = true;
if(child.parent != null) {
child.parent.removeChild(child);
}
var _this = this.bgStage;
var child = this.spriteSecondaryBackground;
HxOverrides.remove(_this.cacheableChildren,child);
_this.isInvalid = true;
if(child.parent != null) {
child.parent.removeChild(child);
}
var _this = this.stage;
var child = this.spriteTopLeft;
HxOverrides.remove(_this.cacheableChildren,child);
_this.isInvalid = true;
if(child.parent != null) {
child.parent.removeChild(child);
}
var _this = this.stage;
var child = this.spriteTopRight;
HxOverrides.remove(_this.cacheableChildren,child);
_this.isInvalid = true;
if(child.parent != null) {
child.parent.removeChild(child);
}
var _this = this.stage;
var child = this.spriteBottomLeft;
HxOverrides.remove(_this.cacheableChildren,child);
_this.isInvalid = true;
if(child.parent != null) {
child.parent.removeChild(child);
}
var _this = this.stage;
var child = this.spriteBottomRight;
HxOverrides.remove(_this.cacheableChildren,child);
_this.isInvalid = true;
if(child.parent != null) {
child.parent.removeChild(child);
}
this.building.city.updateConnectedBuildingSprites = true;
}
,isConnectedBuilding: function(otherBuilding) {
if(otherBuilding == null) {
return false;
}
var otherAMDrawer = this.getOtherAMDrawer(otherBuilding);
if(otherAMDrawer == null) {
return false;
}
if(otherAMDrawer.currentTextureName != this.currentTextureName) {
return otherAMDrawer.currentTextureGroupName == this.currentTextureGroupName;
} else {
return true;
}
}
,isConnectedBuildingHOnly: function(otherBuilding) {
if(otherBuilding == null) {
return false;
}
var otherAMDrawer = this.getOtherAMDrawerHOnly(otherBuilding);
if(otherAMDrawer == null) {
return false;
}
if(otherAMDrawer.currentTextureName != this.currentTextureName) {
return otherAMDrawer.currentTextureGroupName == this.currentTextureGroupName;
} else {
return true;
}
}
,getOtherAMDrawer: function(otherBuilding) {
if(otherBuilding == null) {
return null;
}
var otherDrawer = otherBuilding.drawer;
if(!otherDrawer.canMergeH || !otherDrawer.canMergeV) {
return null;
}
return otherDrawer;
}
,getOtherAMDrawerHOnly: function(otherBuilding) {
if(otherBuilding == null) {
return null;
}
var otherDrawer = otherBuilding.drawer;
if(!otherDrawer.canMergeH) {
return null;
}
return otherDrawer;
}
,getSecondaryBackTextures: function() {
return Resources.getTexturesBySize(this.secondaryBackgroundTextureName,20,20);
}
,getCurrentSecondaryBackTextures: function() {
return this.getSecondaryBackTextures()[this.currentSecondaryTexture];
}
,getCurrentSecondaryTextureGroup: function() {
return this.getSecondaryTextureGroup(this.currentSecondaryTexture);
}
,getSecondaryTextureGroup: function(tex) {
var currentGroup = -1;
var i = 0;
while(i <= tex) {
++currentGroup;
i += this.secondaryBackgroundSets[currentGroup];
}
return currentGroup;
}
,getFirstSecondaryTextureOfGroup: function(group) {
var actualTexture = 0;
var i = 0;
while(i < group) {
actualTexture += this.secondaryBackgroundSets[i];
++i;
}
return actualTexture;
}
,setSecondaryTextureWithinGroup: function(num) {
this.currentSecondaryTexture = this.getFirstSecondaryTextureOfGroup(this.getCurrentSecondaryTextureGroup()) + num;
this.secondaryTextureOnSet(this.currentSecondaryTexture);
this.updateSecondaryBackgroundImageNoExtraInfo();
}
,setGroupOfSecondaryTexture: function(t) {
var cl = js_Boot.getClass(this.building);
var currentBuilding = this.building;
while(currentBuilding.bottomBuilding != null && currentBuilding.bottomBuilding.is(cl) && this.isConnectedBuilding(currentBuilding.bottomBuilding)) currentBuilding = currentBuilding.bottomBuilding;
while(true) {
this.setGroupOfSecondaryTextureForBuilding(currentBuilding,t);
if(currentBuilding.topBuilding != null && currentBuilding.topBuilding.is(cl) && this.isConnectedBuilding(currentBuilding.topBuilding)) {
currentBuilding = currentBuilding.topBuilding;
} else {
break;
}
}
}
,setGroupOfSecondaryTextureForThisBuilding: function(group) {
this.setGroupOfSecondaryTextureForBuilding(this.building,group);
}
,setGroupOfSecondaryTextureForBuilding: function(currentBuilding,group) {
var drawer = currentBuilding.drawer;
drawer.currentSecondaryTexture = this.getFirstSecondaryTextureOfGroup(group) + random_Random.getInt(this.secondaryBackgroundSets[group]);
drawer.secondaryTextureOnSet(drawer.currentSecondaryTexture);
drawer.updateSecondaryBackgroundImageNoExtraInfo();
}
,__class__: buildings_buildingDrawers_AllDirMergingBuildingDrawer
});
var buildings_buildingDrawers_AutoMergingBuildingDrawer = function(building,stage,bgStage,textureName) {
buildings_buildingDrawers_BuildingDrawer.call(this,building,stage,bgStage,textureName);
this.canMergeH = true;
this.canMergeV = false;
this.bgSpriteLeft = new PIXI.Sprite();
bgStage.cacheableChildren.push(this.bgSpriteLeft);
bgStage.isInvalid = true;
this.bgSpriteRight = new PIXI.Sprite();
bgStage.cacheableChildren.push(this.bgSpriteRight);
bgStage.isInvalid = true;
this.spriteLeft = new PIXI.Sprite();
stage.cacheableChildren.push(this.spriteLeft);
stage.isInvalid = true;
this.spriteRight = new PIXI.Sprite();
stage.cacheableChildren.push(this.spriteRight);
stage.isInvalid = true;
this.positionSprites();
};
$hxClasses["buildings.buildingDrawers.AutoMergingBuildingDrawer"] = buildings_buildingDrawers_AutoMergingBuildingDrawer;
buildings_buildingDrawers_AutoMergingBuildingDrawer.__name__ = "buildings.buildingDrawers.AutoMergingBuildingDrawer";
buildings_buildingDrawers_AutoMergingBuildingDrawer.__super__ = buildings_buildingDrawers_BuildingDrawer;
buildings_buildingDrawers_AutoMergingBuildingDrawer.prototype = $extend(buildings_buildingDrawers_BuildingDrawer.prototype,{
positionSpritesMerging: function() {
var halfPermWidth = 10. | 0;
this.spriteLeft.position.set(this.building.position.x,this.building.position.y);
this.bgSpriteLeft.position.set(this.building.position.x,this.building.position.y);
this.spriteRight.position.set(this.building.position.x + halfPermWidth,this.building.position.y);
this.bgSpriteRight.position.set(this.building.position.x + halfPermWidth,this.building.position.y);
var useDoor = this.building.worldPosition.y == 0;
var hasLeftBuilding = this.isConnectedBuilding(this.building.leftBuilding);
var hasRightBuilding = this.isConnectedBuilding(this.building.rightBuilding);
var textures = Resources.getTexturesByWidth(this.currentTextureName,halfPermWidth,true);
this.bgSpriteLeft.texture = textures[4 + (hasLeftBuilding ? 6 : 0)];
this.bgSpriteRight.texture = textures[5 + (hasRightBuilding ? 6 : 0)];
this.spriteLeft.texture = textures[(useDoor ? 2 : 0) + (hasLeftBuilding ? 6 : 0)];
this.spriteRight.texture = textures[1 + (useDoor ? 2 : 0) + (hasRightBuilding ? 6 : 0)];
this.stage.isInvalid = true;
this.bgStage.isInvalid = true;
}
,positionSprites: function() {
this.building.city.updateConnectedBuildingSprites = true;
}
,changeMainTexture: function(textureName) {
buildings_buildingDrawers_BuildingDrawer.prototype.changeMainTexture.call(this,textureName);
this.positionSprites();
}
,destroy: function() {
buildings_buildingDrawers_BuildingDrawer.prototype.destroy.call(this);
var _this = this.bgStage;
var child = this.bgSpriteLeft;
HxOverrides.remove(_this.cacheableChildren,child);
_this.isInvalid = true;
if(child.parent != null) {
child.parent.removeChild(child);
}
var _this = this.bgStage;
var child = this.bgSpriteRight;
HxOverrides.remove(_this.cacheableChildren,child);
_this.isInvalid = true;
if(child.parent != null) {
child.parent.removeChild(child);
}
var _this = this.stage;
var child = this.spriteLeft;
HxOverrides.remove(_this.cacheableChildren,child);
_this.isInvalid = true;
if(child.parent != null) {
child.parent.removeChild(child);
}
var _this = this.stage;
var child = this.spriteRight;
HxOverrides.remove(_this.cacheableChildren,child);
_this.isInvalid = true;
if(child.parent != null) {
child.parent.removeChild(child);
}
this.building.city.updateConnectedBuildingSprites = true;
}
,isConnectedBuilding: function(otherBuilding) {
if(otherBuilding == null) {
return false;
}
var otherAMDrawer = this.getOtherAMDrawer(otherBuilding);
if(otherAMDrawer == null) {
return false;
}
if(otherAMDrawer.currentTextureName != this.currentTextureName) {
return otherAMDrawer.currentTextureGroupName == this.currentTextureGroupName;
} else {
return true;
}
}
,getOtherAMDrawer: function(otherBuilding) {
if(otherBuilding == null) {
return null;
}
var otherDrawer = otherBuilding.drawer;
if(!otherDrawer.canMergeH) {
return null;
}
return otherDrawer;
}
,__class__: buildings_buildingDrawers_AutoMergingBuildingDrawer
});
var buildings_buildingDrawers_AutoMergingBuildingDrawerDifferentForType = function(building,stage,bgStage,textureName) {
buildings_buildingDrawers_BuildingDrawer.call(this,building,stage,bgStage,textureName);
this.canMergeH = true;
this.canMergeV = false;
this.bgSpriteLeft = new PIXI.Sprite();
bgStage.cacheableChildren.push(this.bgSpriteLeft);
bgStage.isInvalid = true;
this.bgSpriteRight = new PIXI.Sprite();
bgStage.cacheableChildren.push(this.bgSpriteRight);
bgStage.isInvalid = true;
this.spriteLeft = new PIXI.Sprite();
stage.cacheableChildren.push(this.spriteLeft);
stage.isInvalid = true;
this.spriteRight = new PIXI.Sprite();
stage.cacheableChildren.push(this.spriteRight);
stage.isInvalid = true;
this.positionSprites();
};
$hxClasses["buildings.buildingDrawers.AutoMergingBuildingDrawerDifferentForType"] = buildings_buildingDrawers_AutoMergingBuildingDrawerDifferentForType;
buildings_buildingDrawers_AutoMergingBuildingDrawerDifferentForType.__name__ = "buildings.buildingDrawers.AutoMergingBuildingDrawerDifferentForType";
buildings_buildingDrawers_AutoMergingBuildingDrawerDifferentForType.__super__ = buildings_buildingDrawers_BuildingDrawer;
buildings_buildingDrawers_AutoMergingBuildingDrawerDifferentForType.prototype = $extend(buildings_buildingDrawers_BuildingDrawer.prototype,{
positionSpritesMerging: function() {
var halfPermWidth = 10. | 0;
this.spriteLeft.position.set(this.building.position.x,this.building.position.y);
this.bgSpriteLeft.position.set(this.building.position.x,this.building.position.y);
this.spriteRight.position.set(this.building.position.x + halfPermWidth,this.building.position.y);
this.bgSpriteRight.position.set(this.building.position.x + halfPermWidth,this.building.position.y);
var useDoor = this.building.worldPosition.y == 0;
var hasLeftBuilding = this.isConnectedBuilding(this.building.leftBuilding);
var hasRightBuilding = this.isConnectedBuilding(this.building.rightBuilding);
var hasExactSameLeftBuilding = true;
var hasExactSameRightBuilding = true;
if(hasLeftBuilding) {
hasExactSameLeftBuilding = this.isFullyConnectedBuilding(this.building.leftBuilding);
}
if(hasRightBuilding) {
hasExactSameRightBuilding = this.isFullyConnectedBuilding(this.building.rightBuilding);
}
var textures = Resources.getTexturesByWidth(this.currentTextureName,halfPermWidth,true);
this.bgSpriteLeft.texture = textures[4 + (hasLeftBuilding ? 6 : 0) + (hasExactSameLeftBuilding ? 0 : 6)];
this.bgSpriteRight.texture = textures[5 + (hasRightBuilding ? 6 : 0) + (hasExactSameRightBuilding ? 0 : 6)];
this.spriteLeft.texture = textures[(useDoor ? 2 : 0) + (hasLeftBuilding ? 6 : 0) + (hasExactSameLeftBuilding ? 0 : 6)];
this.spriteRight.texture = textures[1 + (useDoor ? 2 : 0) + (hasRightBuilding ? 6 : 0) + (hasExactSameRightBuilding ? 0 : 6)];
this.stage.isInvalid = true;
this.bgStage.isInvalid = true;
}
,positionSprites: function() {
this.building.city.updateConnectedBuildingSprites = true;
}
,changeMainTexture: function(textureName) {
buildings_buildingDrawers_BuildingDrawer.prototype.changeMainTexture.call(this,textureName);
this.positionSprites();
}
,destroy: function() {
buildings_buildingDrawers_BuildingDrawer.prototype.destroy.call(this);
var _this = this.bgStage;
var child = this.bgSpriteLeft;
HxOverrides.remove(_this.cacheableChildren,child);
_this.isInvalid = true;
if(child.parent != null) {
child.parent.removeChild(child);
}
var _this = this.bgStage;
var child = this.bgSpriteRight;
HxOverrides.remove(_this.cacheableChildren,child);
_this.isInvalid = true;
if(child.parent != null) {
child.parent.removeChild(child);
}
var _this = this.stage;
var child = this.spriteLeft;
HxOverrides.remove(_this.cacheableChildren,child);
_this.isInvalid = true;
if(child.parent != null) {
child.parent.removeChild(child);
}
var _this = this.stage;
var child = this.spriteRight;
HxOverrides.remove(_this.cacheableChildren,child);
_this.isInvalid = true;
if(child.parent != null) {
child.parent.removeChild(child);
}
this.building.city.updateConnectedBuildingSprites = true;
}
,isConnectedBuilding: function(otherBuilding) {
if(otherBuilding == null) {
return false;
}
var otherAMDrawer = this.getOtherAMDrawer(otherBuilding);
if(otherAMDrawer == null) {
return false;
}
if(otherAMDrawer.currentTextureName != this.currentTextureName) {
return otherAMDrawer.currentTextureGroupName == this.currentTextureGroupName;
} else {
return true;
}
}
,isFullyConnectedBuilding: function(otherBuilding) {
if(otherBuilding == null) {
return false;
}
var otherAMDrawer = this.getOtherAMDrawer(otherBuilding);
if(otherAMDrawer == null) {
return false;
}
return otherAMDrawer.currentTextureName == this.currentTextureName;
}
,getOtherAMDrawer: function(otherBuilding) {
if(otherBuilding == null) {
return null;
}
var otherDrawer = otherBuilding.drawer;
if(!otherDrawer.canMergeH) {
return null;
}
return otherDrawer;
}
,__class__: buildings_buildingDrawers_AutoMergingBuildingDrawerDifferentForType
});
var buildings_buildingDrawers_AutoMergingBuildingDrawerUD = function(building,stage,bgStage,textureName) {
buildings_buildingDrawers_BuildingDrawer.call(this,building,stage,bgStage,textureName);
this.canMergeH = false;
this.canMergeV = true;
this.bgSpriteTop = new PIXI.Sprite();
bgStage.cacheableChildren.push(this.bgSpriteTop);
bgStage.isInvalid = true;
this.bgSpriteBottom = new PIXI.Sprite();
bgStage.cacheableChildren.push(this.bgSpriteBottom);
bgStage.isInvalid = true;
this.spriteTop = new PIXI.Sprite();
stage.cacheableChildren.push(this.spriteTop);
stage.isInvalid = true;
this.spriteBottom = new PIXI.Sprite();
stage.cacheableChildren.push(this.spriteBottom);
stage.isInvalid = true;
this.positionSprites();
};
$hxClasses["buildings.buildingDrawers.AutoMergingBuildingDrawerUD"] = buildings_buildingDrawers_AutoMergingBuildingDrawerUD;
buildings_buildingDrawers_AutoMergingBuildingDrawerUD.__name__ = "buildings.buildingDrawers.AutoMergingBuildingDrawerUD";
buildings_buildingDrawers_AutoMergingBuildingDrawerUD.__super__ = buildings_buildingDrawers_BuildingDrawer;
buildings_buildingDrawers_AutoMergingBuildingDrawerUD.prototype = $extend(buildings_buildingDrawers_BuildingDrawer.prototype,{
positionSpritesMerging: function() {
var halfPermHeight = 10. | 0;
this.spriteTop.position.set(this.building.position.x,this.building.position.y);
this.bgSpriteTop.position.set(this.building.position.x,this.building.position.y);
this.spriteBottom.position.set(this.building.position.x,this.building.position.y + halfPermHeight);
this.bgSpriteBottom.position.set(this.building.position.x,this.building.position.y + halfPermHeight);
var useDoor = this.building.worldPosition.y == 0;
var hasTopBuilding = this.isConnectedBuilding(this.building.topBuilding);
var hasBottomBuilding = this.isConnectedBuilding(this.building.bottomBuilding);
var textures = Resources.getTexturesAsGrid(this.currentTextureName,6,2,2);
this.bgSpriteTop.texture = textures[2 + (hasTopBuilding ? 3 : 0)][0];
this.bgSpriteBottom.texture = textures[2 + (hasBottomBuilding ? 3 : 0)][1];
this.spriteTop.texture = textures[(useDoor ? 1 : 0) + (hasTopBuilding ? 3 : 0)][0];
this.spriteBottom.texture = textures[(useDoor ? 1 : 0) + (hasBottomBuilding ? 3 : 0)][1];
this.stage.isInvalid = true;
this.bgStage.isInvalid = true;
}
,positionSprites: function() {
this.building.city.updateConnectedBuildingSprites = true;
}
,changeMainTexture: function(textureName) {
buildings_buildingDrawers_BuildingDrawer.prototype.changeMainTexture.call(this,textureName);
this.positionSprites();
}
,destroy: function() {
buildings_buildingDrawers_BuildingDrawer.prototype.destroy.call(this);
var _this = this.bgStage;
var child = this.bgSpriteTop;
HxOverrides.remove(_this.cacheableChildren,child);
_this.isInvalid = true;
if(child.parent != null) {
child.parent.removeChild(child);
}
var _this = this.bgStage;
var child = this.bgSpriteBottom;
HxOverrides.remove(_this.cacheableChildren,child);
_this.isInvalid = true;
if(child.parent != null) {
child.parent.removeChild(child);
}
var _this = this.stage;
var child = this.spriteTop;
HxOverrides.remove(_this.cacheableChildren,child);
_this.isInvalid = true;
if(child.parent != null) {
child.parent.removeChild(child);
}
var _this = this.stage;
var child = this.spriteBottom;
HxOverrides.remove(_this.cacheableChildren,child);
_this.isInvalid = true;
if(child.parent != null) {
child.parent.removeChild(child);
}
this.building.city.updateConnectedBuildingSprites = true;
}
,isConnectedBuilding: function(otherBuilding) {
if(otherBuilding == null) {
return false;
}
var otherAMDrawer = this.getOtherAMDrawer(otherBuilding);
if(otherAMDrawer == null) {
return false;
}
return otherAMDrawer.currentTextureName == this.currentTextureName;
}
,getOtherAMDrawer: function(otherBuilding) {
if(otherBuilding == null) {
return null;
}
var otherDrawer = otherBuilding.drawer;
if(!otherDrawer.canMergeV) {
return null;
}
return otherDrawer;
}
,__class__: buildings_buildingDrawers_AutoMergingBuildingDrawerUD
});
var buildings_buildingDrawers_NormalBuildingDrawer = function(building,stage,bgStage,textureName) {
buildings_buildingDrawers_BuildingDrawer.call(this,building,stage,bgStage,textureName);
this.bgSprite = Resources.makeSprite(this.currentTextureName,new common_Rectangle(44,0,20,20));
bgStage.cacheableChildren.push(this.bgSprite);
bgStage.isInvalid = true;
this.sprite = new PIXI.Sprite();
stage.cacheableChildren.push(this.sprite);
stage.isInvalid = true;
this.positionSprites();
};
$hxClasses["buildings.buildingDrawers.NormalBuildingDrawer"] = buildings_buildingDrawers_NormalBuildingDrawer;
buildings_buildingDrawers_NormalBuildingDrawer.__name__ = "buildings.buildingDrawers.NormalBuildingDrawer";
buildings_buildingDrawers_NormalBuildingDrawer.__super__ = buildings_buildingDrawers_BuildingDrawer;
buildings_buildingDrawers_NormalBuildingDrawer.prototype = $extend(buildings_buildingDrawers_BuildingDrawer.prototype,{
positionSprites: function() {
this.sprite.position.set(this.building.position.x,this.building.position.y);
this.bgSprite.position.set(this.building.position.x,this.building.position.y);
var mainSpriteRect = new common_Rectangle(0,0,20,20);
if(this.building.worldPosition.y == 0) {
mainSpriteRect.x += 22;
}
this.sprite.texture = Resources.getTexture(this.currentTextureName,mainSpriteRect);
this.stage.isInvalid = true;
}
,mirror: function() {
this.bgSprite.anchor.x = 1 - this.bgSprite.anchor.x;
this.bgSprite.scale.x = -this.bgSprite.scale.x;
this.sprite.anchor.x = 1 - this.sprite.anchor.x;
this.sprite.scale.x = -this.sprite.scale.x;
this.bgStage.isInvalid = true;
this.stage.isInvalid = true;
}
,changeMainTexture: function(textureName) {
buildings_buildingDrawers_BuildingDrawer.prototype.changeMainTexture.call(this,textureName);
this.bgSprite.texture = Resources.getTexture(this.currentTextureName,new common_Rectangle(44,0,20,20));
this.bgStage.isInvalid = true;
this.positionSprites();
}
,destroy: function() {
buildings_buildingDrawers_BuildingDrawer.prototype.destroy.call(this);
var _this = this.bgStage;
var child = this.bgSprite;
HxOverrides.remove(_this.cacheableChildren,child);
_this.isInvalid = true;
if(child.parent != null) {
child.parent.removeChild(child);
}
var _this = this.stage;
var child = this.sprite;
HxOverrides.remove(_this.cacheableChildren,child);
_this.isInvalid = true;
if(child.parent != null) {
child.parent.removeChild(child);
}
}
,getBackgroundTexture: function() {
return this.bgSprite.texture;
}
,__class__: buildings_buildingDrawers_NormalBuildingDrawer
});
var buildings_buildingDrawers_CustomizableBuildingDrawer = function(building,stage,bgStage,standardTextureName) {
this.backTexture = null;
this.frontTextureWithDoor = null;
this.frontTextureNoDoor = null;
buildings_buildingDrawers_NormalBuildingDrawer.call(this,building,stage,bgStage,standardTextureName);
};
$hxClasses["buildings.buildingDrawers.CustomizableBuildingDrawer"] = buildings_buildingDrawers_CustomizableBuildingDrawer;
buildings_buildingDrawers_CustomizableBuildingDrawer.__name__ = "buildings.buildingDrawers.CustomizableBuildingDrawer";
buildings_buildingDrawers_CustomizableBuildingDrawer.__super__ = buildings_buildingDrawers_NormalBuildingDrawer;
buildings_buildingDrawers_CustomizableBuildingDrawer.prototype = $extend(buildings_buildingDrawers_NormalBuildingDrawer.prototype,{
positionSprites: function() {
this.sprite.position.set(this.building.position.x,this.building.position.y);
this.bgSprite.position.set(this.building.position.x,this.building.position.y);
var customTexture = this.frontTextureNoDoor;
var mainSpriteRect = new common_Rectangle(0,0,20,20);
if(this.building.worldPosition.y == 0) {
mainSpriteRect.x += 22;
customTexture = this.frontTextureWithDoor;
}
var tmp = customTexture != null ? customTexture : Resources.getTexture(this.currentTextureName,mainSpriteRect);
this.sprite.texture = tmp;
this.stage.isInvalid = true;
}
,setCustomTextures: function(frontTextureNoDoor,frontTextureWithDoor,backTexture) {
this.frontTextureNoDoor = frontTextureNoDoor;
this.frontTextureWithDoor = frontTextureWithDoor;
this.backTexture = backTexture;
if(backTexture != null) {
this.bgSprite.texture = backTexture;
this.bgStage.isInvalid = true;
}
this.positionSprites();
}
,__class__: buildings_buildingDrawers_CustomizableBuildingDrawer
});
var cityActions_CitySpecialAction = function(city) {
this.isActive = false;
this.city = city;
this.gui = city.gui;
};
$hxClasses["cityActions.CitySpecialAction"] = cityActions_CitySpecialAction;
cityActions_CitySpecialAction.__name__ = "cityActions.CitySpecialAction";
cityActions_CitySpecialAction.prototype = {
get_specialActionID: function() {
return "";
}
,activate: function() {
this.isActive = true;
}
,deactivate: function() {
this.isActive = false;
this.city.specialAction = null;
}
,__class__: cityActions_CitySpecialAction
};
var cityActions_ChangeCitizenVitalBuildings = function(city,citizen) {
cityActions_CitySpecialAction.call(this,city);
this.citizen = citizen;
};
$hxClasses["cityActions.ChangeCitizenVitalBuildings"] = cityActions_ChangeCitizenVitalBuildings;
cityActions_ChangeCitizenVitalBuildings.__name__ = "cityActions.ChangeCitizenVitalBuildings";
cityActions_ChangeCitizenVitalBuildings.__super__ = cityActions_CitySpecialAction;
cityActions_ChangeCitizenVitalBuildings.prototype = $extend(cityActions_CitySpecialAction.prototype,{
get_specialActionID: function() {
return "ChangeCitizenVitalBuildings";
}
,activate: function() {
cityActions_CitySpecialAction.prototype.activate.call(this);
}
,deactivate: function() {
cityActions_CitySpecialAction.prototype.deactivate.call(this);
}
,performPermanentAction: function(pm) {
var work = pm;
if(pm.is(buildings_Work) && this.citizen.school == null && this.citizen.get_age() >= 16) {
var theWork = work;
var workerWhoLostJob = null;
if(this.citizen.job != theWork) {
workerWhoLostJob = theWork.workers[0];
if(theWork.workers.length >= theWork.get_jobs()) {
workerWhoLostJob.loseJob(false);
}
this.citizen.loseJob(true);
this.city.simulation.jobAssigner.giveCitizenJob(this.citizen,theWork);
if(this.citizen.home != null && this.citizen.home != theWork && this.citizen.home.is(buildings_Work)) {
var workBuilding = this.citizen.home;
if(this.citizen.home.get_residentCapacity() <= workBuilding.get_jobs()) {
this.citizen.evictFromHome();
}
}
}
if(theWork.is(buildings_House)) {
var theHouse = theWork;
if(this.citizen.home != theHouse) {
var houseIsAtCap = theHouse.residents.length >= theHouse.get_residentCapacity();
var canEnterInHouse = false;
if(workerWhoLostJob != null && workerWhoLostJob.home == theHouse && houseIsAtCap) {
workerWhoLostJob.evictFromHome();
canEnterInHouse = true;
} else if(houseIsAtCap) {
theHouse.residents[0].evictFromHome();
canEnterInHouse = true;
}
if(!houseIsAtCap || canEnterInHouse) {
this.citizen.evictFromHome();
var citizen = this.citizen;
citizen.home = theHouse;
theHouse.residents.push(citizen);
if(!this.citizen.isForcedHome) {
this.city.simulation.houseAssigner.citizensWithFixedHomes.push(this.citizen);
}
this.citizen.isForcedHome = true;
}
}
}
} else {
var house = pm;
if(pm.is(buildings_House)) {
var theHouse = house;
if(this.citizen.home != theHouse) {
if(theHouse.residents.length >= theHouse.get_residentCapacity()) {
theHouse.residents[0].evictFromHome();
}
this.citizen.evictFromHome();
var citizen = this.citizen;
citizen.home = theHouse;
theHouse.residents.push(citizen);
if(!this.citizen.isForcedHome) {
this.city.simulation.houseAssigner.citizensWithFixedHomes.push(this.citizen);
}
this.citizen.isForcedHome = true;
if(this.citizen.job != null && this.citizen.home != this.citizen.job && this.citizen.job.is(buildings_House)) {
var houseBuilding = this.citizen.job;
if(houseBuilding.get_residentCapacity() <= this.citizen.job.get_jobs()) {
this.citizen.loseJob(false);
}
}
}
} else {
var school = pm;
if(pm.is(buildings_School)) {
if(this.citizen.get_age() < 16) {
var theSchool = school;
if(this.citizen.school != theSchool) {
if(theSchool.students.length >= theSchool.get_studentCapacity()) {
theSchool.students[0].leaveSchool();
}
this.citizen.leaveSchool();
this.citizen.school = theSchool;
theSchool.students.push(this.citizen);
}
}
}
}
}
}
,__class__: cityActions_ChangeCitizenVitalBuildings
});
var cityActions_FollowCitizenAction = function(city) {
cityActions_CitySpecialAction.call(this,city);
};
$hxClasses["cityActions.FollowCitizenAction"] = cityActions_FollowCitizenAction;
cityActions_FollowCitizenAction.__name__ = "cityActions.FollowCitizenAction";
cityActions_FollowCitizenAction.__super__ = cityActions_CitySpecialAction;
cityActions_FollowCitizenAction.prototype = $extend(cityActions_CitySpecialAction.prototype,{
get_specialActionID: function() {
return "FollowCitizenAction";
}
,activate: function() {
var _gthis = this;
cityActions_CitySpecialAction.prototype.activate.call(this);
this.gui.showSimpleWindow(this.city.game.textHelper.clickOrTap() + " near a citizen to follow them.",null,true);
this.city.gui.setWindowPositioning(gui_WindowPosition.Top);
this.gui.windowRelatedTo = this;
this.gui.windowOnDestroy = function() {
_gthis.isActive = false;
_gthis.deactivate();
};
}
,deactivate: function() {
if(this.isActive) {
if(this.gui.window != null && this.gui.windowRelatedTo == this) {
this.gui.closeWindow();
}
}
cityActions_CitySpecialAction.prototype.deactivate.call(this);
}
,__class__: cityActions_FollowCitizenAction
});
var cityActions_ViewActions = function(city) {
this.city = city;
this.gui = city.gui;
};
$hxClasses["cityActions.ViewActions"] = cityActions_ViewActions;
cityActions_ViewActions.__name__ = "cityActions.ViewActions";
cityActions_ViewActions.prototype = {
showFollow: function() {
if(this.gui.get_keyboard().down[17] && this.city.simulation.citizens.length > 0) {
random_Random.fromArray(this.city.simulation.citizens).onClick();
if(this.city.specialAction != null) {
this.city.specialAction.deactivate();
}
} else {
this.city.activateSpecialCityAction(new cityActions_FollowCitizenAction(this.city));
}
}
,isFollowOpen: function() {
if(this.city.specialAction != null) {
return this.city.specialAction.get_specialActionID() == "FollowCitizenAction";
} else {
return false;
}
}
,__class__: cityActions_ViewActions
};
var cityUpgrades_CityUpgrade = function() {
var c = js_Boot.getClass(this);
var className = c.__name__;
this.info = Lambda.find(Resources.cityUpgradesInfo,function(i) {
return "cityUpgrades." + i.className == className;
});
};
$hxClasses["cityUpgrades.CityUpgrade"] = cityUpgrades_CityUpgrade;
cityUpgrades_CityUpgrade.__name__ = "cityUpgrades.CityUpgrade";
cityUpgrades_CityUpgrade.__interfaces__ = [ICreatableCityElement];
cityUpgrades_CityUpgrade.prototype = {
addToCity: function(city) {
this.city = city;
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
if(shouldSaveDefinition) {
queue.addString(cityUpgrades_CityUpgrade.saveDefinition);
}
}
,load: function(queue,definition) {
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
}
,__class__: cityUpgrades_CityUpgrade
};
var cityUpgrades_BirthControl = function() {
cityUpgrades_CityUpgrade.call(this);
};
$hxClasses["cityUpgrades.BirthControl"] = cityUpgrades_BirthControl;
cityUpgrades_BirthControl.__name__ = "cityUpgrades.BirthControl";
cityUpgrades_BirthControl.__super__ = cityUpgrades_CityUpgrade;
cityUpgrades_BirthControl.prototype = $extend(cityUpgrades_CityUpgrade.prototype,{
addToCity: function(city) {
this.city = city;
city.upgrades.vars.hasBirthControl = true;
}
,__class__: cityUpgrades_BirthControl
});
var cityUpgrades_BuildingRecycling = function() {
cityUpgrades_CityUpgrade.call(this);
};
$hxClasses["cityUpgrades.BuildingRecycling"] = cityUpgrades_BuildingRecycling;
cityUpgrades_BuildingRecycling.__name__ = "cityUpgrades.BuildingRecycling";
cityUpgrades_BuildingRecycling.__super__ = cityUpgrades_CityUpgrade;
cityUpgrades_BuildingRecycling.prototype = $extend(cityUpgrades_CityUpgrade.prototype,{
addToCity: function(city) {
cityUpgrades_CityUpgrade.prototype.addToCity.call(this,city);
city.upgrades.vars.recyclingAmount = Math.max(city.upgrades.vars.recyclingAmount,0.5);
city.progress.unlocks.unlock(cityUpgrades_BuildingRecycling2);
}
,__class__: cityUpgrades_BuildingRecycling
});
var cityUpgrades_BuildingRecycling2 = function() {
cityUpgrades_CityUpgrade.call(this);
};
$hxClasses["cityUpgrades.BuildingRecycling2"] = cityUpgrades_BuildingRecycling2;
cityUpgrades_BuildingRecycling2.__name__ = "cityUpgrades.BuildingRecycling2";
cityUpgrades_BuildingRecycling2.__super__ = cityUpgrades_CityUpgrade;
cityUpgrades_BuildingRecycling2.prototype = $extend(cityUpgrades_CityUpgrade.prototype,{
addToCity: function(city) {
cityUpgrades_CityUpgrade.prototype.addToCity.call(this,city);
city.upgrades.vars.recyclingAmount = Math.max(city.upgrades.vars.recyclingAmount,0.75);
city.progress.unlocks.unlock(cityUpgrades_BuildingRecycling3);
}
,__class__: cityUpgrades_BuildingRecycling2
});
var cityUpgrades_BuildingRecycling3 = function() {
cityUpgrades_CityUpgrade.call(this);
};
$hxClasses["cityUpgrades.BuildingRecycling3"] = cityUpgrades_BuildingRecycling3;
cityUpgrades_BuildingRecycling3.__name__ = "cityUpgrades.BuildingRecycling3";
cityUpgrades_BuildingRecycling3.__super__ = cityUpgrades_CityUpgrade;
cityUpgrades_BuildingRecycling3.prototype = $extend(cityUpgrades_CityUpgrade.prototype,{
addToCity: function(city) {
cityUpgrades_CityUpgrade.prototype.addToCity.call(this,city);
city.upgrades.vars.recyclingAmount = Math.max(city.upgrades.vars.recyclingAmount,0.9);
}
,__class__: cityUpgrades_BuildingRecycling3
});
var cityUpgrades_ChipBinning = function() {
cityUpgrades_CityUpgrade.call(this);
};
$hxClasses["cityUpgrades.ChipBinning"] = cityUpgrades_ChipBinning;
cityUpgrades_ChipBinning.__name__ = "cityUpgrades.ChipBinning";
cityUpgrades_ChipBinning.__super__ = cityUpgrades_CityUpgrade;
cityUpgrades_ChipBinning.prototype = $extend(cityUpgrades_CityUpgrade.prototype,{
addToCity: function(city) {
this.city = city;
city.upgrades.vars.computerChipFactorySpeed *= 1.2;
}
,__class__: cityUpgrades_ChipBinning
});
var cityUpgrades_CityUpgrades = function(city) {
this.city = city;
this.upgrades = [];
this.vars = new cityUpgrades_UpgradeVars();
};
$hxClasses["cityUpgrades.CityUpgrades"] = cityUpgrades_CityUpgrades;
cityUpgrades_CityUpgrades.__name__ = "cityUpgrades.CityUpgrades";
cityUpgrades_CityUpgrades.prototype = {
addUpgrade: function(upgrade) {
this.upgrades.push(upgrade);
upgrade.addToCity(this.city);
}
,save: function(queue) {
var value = this.upgrades.length;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var _g = 0;
var _g1 = this.upgrades;
while(_g < _g1.length) {
var upgrade = _g1[_g];
++_g;
var c = js_Boot.getClass(upgrade);
queue.addString(c.__name__);
upgrade.save(queue);
}
}
,load: function(queue) {
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var len = intToRead;
var _g = 0;
var _g1 = len;
while(_g < _g1) {
var i = _g++;
var name = queue.readString();
var upg = Type.createInstance($hxClasses[name],[]);
upg.load(queue);
this.addUpgrade(upg);
if(queue.version <= 11) {
if(((upg) instanceof cityUpgrades_SlimyLiving)) {
var _g2 = 0;
var _g3 = this.city.permanents;
while(_g2 < _g3.length) {
var pm = _g3[_g2];
++_g2;
if(pm.is(buildings_AlienHouse)) {
var buildingToUpgrade = pm;
if(!common_ArrayExtensions.any(buildingToUpgrade.upgrades,function(bu) {
return ((bu) instanceof buildingUpgrades_LivingComputer);
})) {
buildingToUpgrade.upgrades.push(Type.createInstance(buildingUpgrades_LivingComputer,[buildingToUpgrade.stage,this.city.cityMidStage,buildingToUpgrade.bgStage,buildingToUpgrade]));
}
}
}
}
}
}
}
,__class__: cityUpgrades_CityUpgrades
};
var cityUpgrades_MechanicalLiving = function() {
cityUpgrades_CityUpgrade.call(this);
};
$hxClasses["cityUpgrades.MechanicalLiving"] = cityUpgrades_MechanicalLiving;
cityUpgrades_MechanicalLiving.__name__ = "cityUpgrades.MechanicalLiving";
cityUpgrades_MechanicalLiving.__super__ = cityUpgrades_CityUpgrade;
cityUpgrades_MechanicalLiving.prototype = $extend(cityUpgrades_CityUpgrade.prototype,{
addToCity: function(city) {
cityUpgrades_CityUpgrade.prototype.addToCity.call(this,city);
city.progress.resources.buildingInfo.h["buildings.MechanicalHouse"].residents += 1;
city.progress.resources.buildingInfo.h["buildings.TinkerersHome"].residents += 1;
}
,__class__: cityUpgrades_MechanicalLiving
});
var cityUpgrades_MedicalMachineLearning = function() {
cityUpgrades_CityUpgrade.call(this);
};
$hxClasses["cityUpgrades.MedicalMachineLearning"] = cityUpgrades_MedicalMachineLearning;
cityUpgrades_MedicalMachineLearning.__name__ = "cityUpgrades.MedicalMachineLearning";
cityUpgrades_MedicalMachineLearning.__super__ = cityUpgrades_CityUpgrade;
cityUpgrades_MedicalMachineLearning.prototype = $extend(cityUpgrades_CityUpgrade.prototype,{
addToCity: function(city) {
this.city = city;
city.upgrades.vars.extendAgeBy += 0.05;
}
,__class__: cityUpgrades_MedicalMachineLearning
});
var cityUpgrades_OptimizedChipLayouts = function() {
cityUpgrades_CityUpgrade.call(this);
};
$hxClasses["cityUpgrades.OptimizedChipLayouts"] = cityUpgrades_OptimizedChipLayouts;
cityUpgrades_OptimizedChipLayouts.__name__ = "cityUpgrades.OptimizedChipLayouts";
cityUpgrades_OptimizedChipLayouts.__super__ = cityUpgrades_CityUpgrade;
cityUpgrades_OptimizedChipLayouts.prototype = $extend(cityUpgrades_CityUpgrade.prototype,{
addToCity: function(city) {
this.city = city;
city.upgrades.vars.computerChipFactorySpeed *= 1.33;
}
,__class__: cityUpgrades_OptimizedChipLayouts
});
var cityUpgrades_SecretiveLiving = function() {
cityUpgrades_CityUpgrade.call(this);
};
$hxClasses["cityUpgrades.SecretiveLiving"] = cityUpgrades_SecretiveLiving;
cityUpgrades_SecretiveLiving.__name__ = "cityUpgrades.SecretiveLiving";
cityUpgrades_SecretiveLiving.__super__ = cityUpgrades_CityUpgrade;
cityUpgrades_SecretiveLiving.prototype = $extend(cityUpgrades_CityUpgrade.prototype,{
addToCity: function(city) {
cityUpgrades_CityUpgrade.prototype.addToCity.call(this,city);
city.progress.resources.buildingInfo.h["buildings.SecretSocietyHouse"].quality += 25;
}
,__class__: cityUpgrades_SecretiveLiving
});
var cityUpgrades_SlimyLiving = function() {
cityUpgrades_CityUpgrade.call(this);
};
$hxClasses["cityUpgrades.SlimyLiving"] = cityUpgrades_SlimyLiving;
cityUpgrades_SlimyLiving.__name__ = "cityUpgrades.SlimyLiving";
cityUpgrades_SlimyLiving.__super__ = cityUpgrades_CityUpgrade;
cityUpgrades_SlimyLiving.prototype = $extend(cityUpgrades_CityUpgrade.prototype,{
addToCity: function(city) {
cityUpgrades_CityUpgrade.prototype.addToCity.call(this,city);
city.progress.resources.buildingInfo.h["buildings.AlienHouse"].quality += 25;
city.progress.unlocks.unlock(buildingUpgrades_LivingComputer,true);
}
,__class__: cityUpgrades_SlimyLiving
});
var cityUpgrades_SpaciousLiving = function() {
cityUpgrades_CityUpgrade.call(this);
};
$hxClasses["cityUpgrades.SpaciousLiving"] = cityUpgrades_SpaciousLiving;
cityUpgrades_SpaciousLiving.__name__ = "cityUpgrades.SpaciousLiving";
cityUpgrades_SpaciousLiving.__super__ = cityUpgrades_CityUpgrade;
cityUpgrades_SpaciousLiving.prototype = $extend(cityUpgrades_CityUpgrade.prototype,{
addToCity: function(city) {
cityUpgrades_CityUpgrade.prototype.addToCity.call(this,city);
city.progress.resources.buildingInfo.h["buildings.SpaciousHouse"].quality += 15;
}
,__class__: cityUpgrades_SpaciousLiving
});
var cityUpgrades_SuperSpaciousLiving = function() {
cityUpgrades_CityUpgrade.call(this);
};
$hxClasses["cityUpgrades.SuperSpaciousLiving"] = cityUpgrades_SuperSpaciousLiving;
cityUpgrades_SuperSpaciousLiving.__name__ = "cityUpgrades.SuperSpaciousLiving";
cityUpgrades_SuperSpaciousLiving.__super__ = cityUpgrades_CityUpgrade;
cityUpgrades_SuperSpaciousLiving.prototype = $extend(cityUpgrades_CityUpgrade.prototype,{
addToCity: function(city) {
cityUpgrades_CityUpgrade.prototype.addToCity.call(this,city);
city.progress.resources.buildingInfo.h["buildings.SpaciousHouse"].residents += 1;
}
,__class__: cityUpgrades_SuperSpaciousLiving
});
var cityUpgrades_UniverseMapping = function() {
cityUpgrades_CityUpgrade.call(this);
};
$hxClasses["cityUpgrades.UniverseMapping"] = cityUpgrades_UniverseMapping;
cityUpgrades_UniverseMapping.__name__ = "cityUpgrades.UniverseMapping";
cityUpgrades_UniverseMapping.__super__ = cityUpgrades_CityUpgrade;
cityUpgrades_UniverseMapping.prototype = $extend(cityUpgrades_CityUpgrade.prototype,{
addToCity: function(city) {
this.city = city;
city.upgrades.vars.stoneTeleporterChanceForRefinedMetals = 0.04;
city.upgrades.vars.stoneTeleporterHasBigStones = true;
city.upgrades.vars.starDatabaseIsMoreEffective = true;
}
,__class__: cityUpgrades_UniverseMapping
});
var cityUpgrades_UpgradeVars = function() {
this.advancedBuildingAllowed = false;
this.stoneResearchCenterWithFossils = null;
this.stoneMiningSpeed = 1.0;
this.computerChipFactorySpeed = 1.0;
this.recyclingAmount = 0.0;
this.hasBirthControl = false;
this.extendAgeBy = 0.0;
this.stoneTeleporterChanceForRefinedMetals = 0.0;
this.starDatabaseIsMoreEffective = false;
this.stoneTeleporterHasBigStones = false;
};
$hxClasses["cityUpgrades.UpgradeVars"] = cityUpgrades_UpgradeVars;
cityUpgrades_UpgradeVars.__name__ = "cityUpgrades.UpgradeVars";
cityUpgrades_UpgradeVars.prototype = {
__class__: cityUpgrades_UpgradeVars
};
var common_AdHelper = function() { };
$hxClasses["common.AdHelper"] = common_AdHelper;
common_AdHelper.__name__ = "common.AdHelper";
common_AdHelper.init = function(game) {
var tmp = null;
common_AdHelper.provider = tmp;
if(2 == 6) {
common_AdHelper.adExpireTime = 0;
} else if(2 == 7) {
common_AdHelper.adExpireTime = common_AdHelper.standardAdExpireTime;
common_AdHelper.adCapRemaining = 3;
}
};
common_AdHelper.update = function(timeMod) {
if(common_AdHelper.adExpireTime >= 0) {
common_AdHelper.adExpireTime -= timeMod;
}
if(common_AdHelper.adExpireTimeRewarded >= 0) {
common_AdHelper.adExpireTimeRewarded -= timeMod;
}
};
common_AdHelper.cityUpdate = function(city,mouse) {
};
common_AdHelper.adAvailableRewarded = function() {
if(common_AdHelper.provider.adAvailableRewarded() && common_AdHelper.adExpireTimeRewarded <= 0) {
return false;
} else {
return false;
}
};
common_AdHelper.showRewardedInterstitial = function(onDone,onFail) {
var failCalled = false;
var failFunction = function() {
if(failCalled) {
return;
}
failCalled = true;
common_AdHelper.adExpireTime = -1;
common_AdHelper.adExpireTimeRewarded = -1;
onFail();
};
common_AdHelper.adExpireTimeRewarded += common_AdHelper.minTimeBetweenRewarded;
var result = common_AdHelper.provider.showRewardedInterstitial(onDone,failFunction);
if(!result) {
failFunction();
}
common_AdHelper.adExpireTime = Math.min(Math.max(common_AdHelper.adExpireTime,common_AdHelper.minTimeBetweenRewarded),common_AdHelper.standardAdExpireTime);
};
common_AdHelper.showNonRewardedInterstitialIfAllowed = function() {
if(common_AdHelper.adExpireTime <= 0) {
if(common_AdHelper.provider.showNonRewardedInterstitialIfAllowed()) {
common_AdHelper.adExpireTime += common_AdHelper.standardAdExpireTime;
}
}
};
common_AdHelper.canShowBanner = function() {
if(common_AdHelper.provider == null) {
return false;
}
return common_AdHelper.provider.canShowBanner();
};
common_AdHelper.showBanner = function() {
common_AdHelper.provider.showBanner();
};
common_AdHelper.hideBanner = function() {
common_AdHelper.provider.hideBanner();
};
var common_AdProviderHelper = function() { };
$hxClasses["common.AdProviderHelper"] = common_AdProviderHelper;
common_AdProviderHelper.__name__ = "common.AdProviderHelper";
common_AdProviderHelper.__isInterface__ = true;
common_AdProviderHelper.prototype = {
__class__: common_AdProviderHelper
};
var common_ArrayExtensions = function() { };
$hxClasses["common.ArrayExtensions"] = common_ArrayExtensions;
common_ArrayExtensions.__name__ = "common.ArrayExtensions";
common_ArrayExtensions.whereMax = function(array,whereTrue,fn) {
if(fn == null) {
fn = function(val) {
return val;
};
}
var arrayMaxVal = -Infinity;
var arrayMaxItem = null;
var _g = 0;
while(_g < array.length) {
var item = array[_g];
++_g;
if(!whereTrue(item)) {
continue;
}
var val = fn(item);
if(val > arrayMaxVal) {
arrayMaxItem = item;
arrayMaxVal = val;
}
}
return arrayMaxItem;
};
common_ArrayExtensions.max = function(array,fn) {
if(fn == null) {
fn = function(val) {
return val;
};
}
var arrayMaxVal = -Infinity;
var arrayMaxItem = null;
var _g = 0;
while(_g < array.length) {
var item = array[_g];
++_g;
var val = fn(item);
if(val > arrayMaxVal) {
arrayMaxItem = item;
arrayMaxVal = val;
}
}
return arrayMaxItem;
};
common_ArrayExtensions.min = function(array,fn) {
if(fn == null) {
fn = function(val) {
return val;
};
}
var arrayMinVal = Infinity;
var arrayMinItem = null;
var _g = 0;
while(_g < array.length) {
var item = array[_g];
++_g;
var val = fn(item);
if(val < arrayMinVal) {
arrayMinItem = item;
arrayMinVal = val;
}
}
return arrayMinItem;
};
common_ArrayExtensions.sum = function(array,fn) {
if(fn == null) {
fn = function(val) {
return val;
};
}
var total = 0;
var _g = 0;
while(_g < array.length) {
var val = array[_g];
++_g;
total += fn(val);
}
return total;
};
common_ArrayExtensions.sumFPoint = function(array,fn) {
if(fn == null) {
fn = function(val) {
return val;
};
}
var total = new common_FPoint(0,0);
var _g = 0;
while(_g < array.length) {
var val = array[_g];
++_g;
var otherPoint = fn(val);
total = new common_FPoint(total.x + otherPoint.x,total.y + otherPoint.y);
}
return total;
};
common_ArrayExtensions.isum = function(array,fn) {
if(fn == null) {
fn = function(val) {
return val;
};
}
var total = 0;
var _g = 0;
while(_g < array.length) {
var val = array[_g];
++_g;
total += fn(val);
}
return total;
};
common_ArrayExtensions.any = function(array,fn) {
var _g = 0;
while(_g < array.length) {
var val = array[_g];
++_g;
if(fn(val)) {
return true;
}
}
return false;
};
common_ArrayExtensions.all = function(array,fn) {
var _g = 0;
while(_g < array.length) {
var val = array[_g];
++_g;
if(!fn(val)) {
return false;
}
}
return true;
};
common_ArrayExtensions.findRandom = function(array,query) {
var i = random_Random.getInt(array.length);
var orig = i;
while(i < array.length) {
var item = array[i];
if(query(item)) {
return item;
}
++i;
}
i = 0;
while(i < orig) {
var item = array[i];
if(query(item)) {
return item;
}
++i;
}
return null;
};
var common_ColorExtensions = function() { };
$hxClasses["common.ColorExtensions"] = common_ColorExtensions;
common_ColorExtensions.__name__ = "common.ColorExtensions";
common_ColorExtensions.toHexInt = function(col) {
return thx_color_Rgb.get_red(col) * 65536 + thx_color_Rgb.get_green(col) * 256 + thx_color_Rgb.get_blue(col);
};
var common_Rectangle = function(x,y,width,height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
};
$hxClasses["common.Rectangle"] = common_Rectangle;
common_Rectangle.__name__ = "common.Rectangle";
common_Rectangle.fromPixiRect = function(rect) {
return new common_Rectangle(rect.x | 0,rect.y | 0,rect.width | 0,rect.height | 0);
};
common_Rectangle.fromStoryRect = function(rect) {
return new common_Rectangle(rect.x,rect.y,rect.width,rect.height);
};
common_Rectangle.prototype = {
get_x2: function() {
return this.x + this.width;
}
,get_y2: function() {
return this.y + this.height;
}
,get_center: function() {
return new common_Point(this.x + (this.width / 2 | 0),this.y + (this.height / 2 | 0));
}
,clone: function() {
return new common_Rectangle(this.x,this.y,this.width,this.height);
}
,intersects: function(other) {
var tmp;
var val = this.x;
if(!(val >= other.x && val < other.x + other.width)) {
var val = other.x;
tmp = val >= this.x && val < this.x + this.width;
} else {
tmp = true;
}
if(tmp) {
var val = other.y;
if(!(val >= this.y && val < this.y + this.height)) {
var val = this.y;
if(val >= other.y) {
return val < other.y + other.height;
} else {
return false;
}
} else {
return true;
}
} else {
return false;
}
}
,fullyContains: function(other) {
if(this.x <= other.x && this.y <= other.y && this.get_x2() > other.get_x2()) {
return this.get_y2() > other.get_y2();
} else {
return false;
}
}
,contains: function(point) {
var val = point.x;
if(val >= this.x && val < this.x + this.width) {
var val = point.y;
if(val >= this.y) {
return val < this.y + this.height;
} else {
return false;
}
} else {
return false;
}
}
,__class__: common_Rectangle
};
var common_FRectangle = function(x,y,width,height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
};
$hxClasses["common.FRectangle"] = common_FRectangle;
common_FRectangle.__name__ = "common.FRectangle";
common_FRectangle.prototype = {
get_x2: function() {
return this.x + this.width;
}
,get_y2: function() {
return this.y + this.height;
}
,clone: function() {
return new common_FRectangle(this.x,this.y,this.width,this.height);
}
,__class__: common_FRectangle
};
var common_Point = function(x,y) {
this.x = x;
this.y = y;
};
$hxClasses["common.Point"] = common_Point;
common_Point.__name__ = "common.Point";
common_Point.distance = function(point1,point2) {
return Math.sqrt((point2.x - point1.x) * (point2.x - point1.x) + (point2.y - point1.y) * (point2.y - point1.y));
};
common_Point.mean = function(point1,point2) {
return new common_FPoint(0.5 * (point1.x + point2.x),0.5 * (point1.y + point2.y));
};
common_Point.prototype = {
__class__: common_Point
};
var common_FPoint = function(x,y) {
this.x = x;
this.y = y;
};
$hxClasses["common.FPoint"] = common_FPoint;
common_FPoint.__name__ = "common.FPoint";
common_FPoint.distance = function(point1,point2) {
return Math.sqrt((point2.x - point1.x) * (point2.x - point1.x) + (point2.y - point1.y) * (point2.y - point1.y));
};
common_FPoint.prototype = {
get_length: function() {
return Math.sqrt(this.x * this.x + this.y * this.y);
}
,__class__: common_FPoint
};
var common_DesktopHelpers = function() { };
$hxClasses["common.DesktopHelpers"] = common_DesktopHelpers;
common_DesktopHelpers.__name__ = "common.DesktopHelpers";
common_DesktopHelpers.update = function(game) {
if(game.keyboard.pressed[119]) {
var mywindow = chrome.app.window.getAll()[0];
mywindow.innerBounds.width = 1280;
mywindow.innerBounds.height = 720;
;
}
if(game.keyboard.pressed[118]) {
var mywindow = chrome.app.window.getAll()[0];
mywindow.innerBounds.width = 1920;
mywindow.innerBounds.height = 1080;
;
}
};
var common_KongTools = function() { };
$hxClasses["common.KongTools"] = common_KongTools;
common_KongTools.__name__ = "common.KongTools";
common_KongTools.init = function() {
jsFunctions.loadJS("site-specific/kong/quickKong.js",function() {
try {
QuickKong.doInitKong();
common_KongTools.kongJSLoaded = true;
} catch( _g ) {
}
});
};
common_KongTools.reportHappiness = function(happiness) {
if(happiness > common_KongTools.highestHappinessKnown) {
common_KongTools.highestHappinessKnown = happiness;
common_KongTools.statTimeout = 60;
}
if(common_KongTools.statTimeout <= 0 && common_KongTools.highestHappinessKnown > common_KongTools.highestHappinessReported && common_KongTools.kongJSLoaded) {
QuickKong.setStat("happiness",common_KongTools.highestHappinessKnown);
common_KongTools.highestHappinessReported = common_KongTools.highestHappinessKnown;
common_KongTools.statTimeout = 120;
}
};
common_KongTools.setStat = function(statName,statAmount) {
if(common_KongTools.kongJSLoaded) {
QuickKong.setStat(statName,statAmount);
}
};
common_KongTools.update = function() {
if(common_KongTools.statTimeout > 0) {
common_KongTools.statTimeout -= 1;
}
};
var common_MathExtensions = function() { };
$hxClasses["common.MathExtensions"] = common_MathExtensions;
common_MathExtensions.__name__ = "common.MathExtensions";
common_MathExtensions.largeNumberFormat = function(cls,n) {
if(n > 1e8) {
return "" + common_MathExtensions.floatFormat(Math,n / 1e6,0) + "m";
}
if(n > 1e6) {
return "" + common_MathExtensions.floatFormat(Math,n / 1e6,1) + "m";
}
if(n > 1e4) {
return "" + common_MathExtensions.floatFormat(Math,n / 1e3,0) + "k";
}
if(n > 1e3) {
return "" + common_MathExtensions.floatFormat(Math,n / 1e3,1) + "k";
}
return "" + n;
};
common_MathExtensions.largeNumberFormatAlt = function(cls,n) {
if(n > 1e6) {
return "" + common_MathExtensions.floatFormat(Math,n / 1e6,1) + "m";
}
if(n > 1e5) {
return "" + common_MathExtensions.floatFormat(Math,n / 1e3,0) + "k";
}
return "" + n;
};
common_MathExtensions.floatFormat = function(cls,n,prec) {
if(prec == 0) {
return Std.string(Math.floor(n));
}
n = Math.round(n * Math.pow(10,prec));
var str = "" + n;
var len = str.length;
if(len <= prec) {
while(len < prec) {
str = "0" + str;
++len;
}
return "0." + str;
} else {
return HxOverrides.substr(str,0,str.length - prec) + "." + HxOverrides.substr(str,str.length - prec,null);
}
};
var common_Performance = function() { };
$hxClasses["common.Performance"] = common_Performance;
common_Performance.__name__ = "common.Performance";
common_Performance.get_fps = function() {
return 1000 / (common_ArrayExtensions.sum(common_Performance.frameTimeValues) / common_Performance.frameTimeValues.length);
};
common_Performance.registerFrame = function() {
var currentTime = window.performance.now();
if(common_Performance.frameTimeValues.length > 60) {
common_Performance.frameTimeValues.splice(0,1);
}
if(common_Performance.previousTime != 0) {
common_Performance.frameTimeValues.push(currentTime - common_Performance.previousTime);
}
common_Performance.previousTime = currentTime;
if(common_Performance.isDrawingFPSCurrently) {
var tmp = Math.round(common_Performance.get_fps());
common_Performance.fpsBitmap.text = tmp + "";
if(common_Performance.get_fps() >= 100) {
common_Performance.fpsRect.clear();
common_Performance.fpsRect.beginFill(0,0.5);
common_Performance.fpsRect.drawRect(7 * common_Performance.dpi,7 * common_Performance.dpi,46 * common_Performance.dpi,29 * common_Performance.dpi);
common_Performance.fpsRect.endFill();
}
}
};
var common_PleaseRotateDevice = function(stage) {
this.text2 = null;
this.stage = stage;
this.subStage1 = new PIXI.Container();
stage.addChild(this.subStage1);
this.subStage2 = new PIXI.Container();
stage.addChild(this.subStage2);
this.logoSprite = new PIXI.Sprite(Resources.getTexture("spr_title"));
this.subStage2.addChild(this.logoSprite);
this.graphics = new PIXI.Graphics();
this.subStage1.addChild(this.graphics);
if(jsFunctions.orientationLockSupported()) {
this.text = new PIXI.extras.BitmapText("Please tap anywhere to continue.",{ font : "Arial18", tint : 16777215});
this.text2 = new PIXI.extras.BitmapText("(if this has no effect, please rotate your device manually)",{ font : "Arial16", tint : 12632256});
this.text.anchor.set(0.5,1);
this.text2.anchor.set(0.5,1);
} else {
this.text = new PIXI.extras.BitmapText("Please rotate your device to continue.",{ font : "Arial18", tint : 16777215});
this.text.anchor.set(0.5,1);
}
this.text.align = "center";
if(this.text2 != null) {
this.text2.align = "center";
this.subStage1.addChild(this.text2);
}
this.subStage1.addChild(this.text);
};
$hxClasses["common.PleaseRotateDevice"] = common_PleaseRotateDevice;
common_PleaseRotateDevice.__name__ = "common.PleaseRotateDevice";
common_PleaseRotateDevice.prototype = {
update: function(width,height,scaling) {
this.subStage1.scale.x = this.subStage1.scale.y = scaling;
var val1 = Math.floor(width * scaling / this.logoSprite.width);
var subStage2Scale = 1 > val1 ? 1 : val1;
this.subStage2.scale.x = this.subStage2.scale.y = subStage2Scale;
this.logoSprite.anchor.set(0.5,0);
this.logoSprite.position.set(width / subStage2Scale * scaling / 2,20);
this.graphics.clear();
this.graphics.beginFill(2626656,1).drawRect(0,0,width,height);
this.text.maxWidth = width - 20;
if(this.text2 != null) {
this.text2.maxWidth = width - 20;
this.text2.position.set(width / 2,height - 20);
this.text.position.set(width / 2,height - 20 - this.text2.textHeight - 10);
} else {
this.text.position.set(width / 2,height - 20);
}
}
,destroy: function() {
this.subStage1.destroy();
this.subStage2.destroy();
}
,__class__: common_PleaseRotateDevice
};
var common_PokiHelpers = function() { };
$hxClasses["common.PokiHelpers"] = common_PokiHelpers;
common_PokiHelpers.__name__ = "common.PokiHelpers";
common_PokiHelpers.reportStartGameplay = function() {
};
common_PokiHelpers.reportStopGameplay = function() {
};
var common_Splash = function(stage,logoUrl,logoWidth,logoHeight,width,height,displayFor,onDone) {
this.stage = stage;
this.splashSprite = new PIXI.Sprite(PIXI.Texture.fromImage(logoUrl,null));
stage.addChild(this.splashSprite);
this.logoWidth = logoWidth;
this.logoHeight = logoHeight;
this.resize(width,height);
this.displayTimeLeft = displayFor;
this.onDone = onDone;
};
$hxClasses["common.Splash"] = common_Splash;
common_Splash.__name__ = "common.Splash";
common_Splash.prototype = {
update: function(timeMod) {
if(this.splashSprite.texture.baseTexture.hasLoaded) {
this.displayTimeLeft -= timeMod;
if(this.displayTimeLeft <= 0) {
this.destroy();
this.onDone();
}
}
}
,resize: function(width,height) {
var baseScale = Math.min(width / this.logoWidth,height / this.logoHeight);
this.splashSprite.scale.x = baseScale;
this.splashSprite.scale.y = baseScale;
this.splashSprite.position.set((width / this.logoWidth - baseScale) * this.logoWidth / 2,(height / this.logoHeight - baseScale) * this.logoHeight / 2);
}
,destroy: function() {
this.splashSprite.destroy();
}
,__class__: common_Splash
};
var common_Storage = function() { };
$hxClasses["common.Storage"] = common_Storage;
common_Storage.__name__ = "common.Storage";
common_Storage.testSupport = function(ifSupported,ifUnsupported) {
if(common_Storage.knowsSupport && !common_Storage.hasSupport) {
ifUnsupported();
return;
}
if(common_Storage.knowsSupport && common_Storage.hasSupport) {
ifSupported();
return;
}
try {
localforage.ready().then(function() {
common_Storage.hasSupport = true;
common_Storage.knowsSupport = true;
ifSupported();
}).catch(function() {
common_Storage.hasSupport = false;
common_Storage.knowsSupport = true;
common_Storage.storageReplacement = new haxe_ds_StringMap();
ifUnsupported();
});
} catch( _g ) {
common_Storage.knowsSupport = true;
common_Storage.hasSupport = true;
ifSupported();
}
};
common_Storage.getItem = function(key,onSuccess,returnBuffer) {
if(returnBuffer == null) {
returnBuffer = false;
}
if(common_Storage.hasSupport) {
if(returnBuffer) {
return localforage.getItemBuffer(key,onSuccess);
} else {
return localforage.getItemParsed(key,onSuccess);
}
}
common_Storage.testSupport(function() {
if((returnBuffer ? localforage.getItemBuffer(key,onSuccess) : localforage.getItemParsed(key,onSuccess)) == null) {
onSuccess("error",null);
}
},function() {
if(!Object.prototype.hasOwnProperty.call(common_Storage.storageReplacement.h,key)) {
onSuccess("error",null);
} else {
onSuccess(null,common_Storage.storageReplacement.h[key]);
}
});
return -1;
};
common_Storage.setItem = function(key,value,onSuccess) {
common_Storage.testSupport(function() {
localforage.setItem(key,value,onSuccess);
},function() {
common_Storage.storageReplacement.h[key] = value;
onSuccess();
});
};
common_Storage.storageSupported = function() {
if(common_Storage.knowsSupport) {
return common_Storage.hasSupport;
} else {
return true;
}
};
var common_StringExtensions = function() { };
$hxClasses["common.StringExtensions"] = common_StringExtensions;
common_StringExtensions.__name__ = "common.StringExtensions";
common_StringExtensions.firstToUpper = function(str) {
if(str.length == 0) {
return str;
}
return str.charAt(0).toUpperCase() + HxOverrides.substr(str,1,null);
};
var common_TextHelper = function(game) {
this.game = game;
};
$hxClasses["common.TextHelper"] = common_TextHelper;
common_TextHelper.__name__ = "common.TextHelper";
common_TextHelper.prototype = {
ifNotMobile: function(thisText) {
if(this.game.isMobile) {
return "";
}
return thisText;
}
,clickOrTap: function(capital) {
if(capital == null) {
capital = true;
}
if(capital) {
if(this.game.isMobile) {
return "Tap";
} else {
return "Click";
}
}
if(this.game.isMobile) {
return "tap";
} else {
return "click";
}
}
,__class__: common_TextHelper
};
var gamesave_GameSaveHelper = function() { };
$hxClasses["gamesave.GameSaveHelper"] = gamesave_GameSaveHelper;
gamesave_GameSaveHelper.__name__ = "gamesave.GameSaveHelper";
gamesave_GameSaveHelper.makeLoadMap = function(definition,queue) {
var loadMap = new haxe_ds_StringMap();
var _g = 0;
var _g1 = definition.split("|");
while(_g < _g1.length) {
var varAndType = _g1[_g];
++_g;
if(varAndType == "") {
continue;
}
var varAndTypeArray = varAndType.split("$");
var res;
var _g2 = varAndTypeArray[1];
switch(_g2) {
case "Bool":
if(queue.version < 29) {
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
res = intToRead == 1 && true;
} else {
var byteToRead = queue.bytes.b[queue.readStart];
queue.readStart += 1;
res = byteToRead > 0;
}
break;
case "FPoint":
res = queue.readFPoint();
break;
case "Float":
var floatToRead = queue.bytes.getDouble(queue.readStart);
queue.readStart += 8;
res = floatToRead;
break;
case "Int":
var intToRead1 = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
res = intToRead1;
break;
case "Point":
res = queue.readPoint();
break;
case "Rectangle":
res = queue.readRectangle();
break;
case "String":
res = queue.readString();
break;
case "ds":
res = haxe_Unserializer.run(queue.readString());
break;
default:
var typeName = _g2;
var resolvedEnum = $hxEnums[typeName];
if(resolvedEnum != null) {
res = Type.createEnum(resolvedEnum,queue.readString());
} else {
throw haxe_Exception.thrown("That type isn't supported while loading the game!");
}
}
loadMap.h[varAndTypeArray[0]] = res;
}
return loadMap;
};
var gamesave_ResizingBytesQueue = function(startWithBytes) {
this.version = 0;
this.bytes = startWithBytes != null ? startWithBytes : new haxe_io_Bytes(new ArrayBuffer(10));
this.size = 0;
this.readStart = 0;
this.stringLocations = new haxe_ds_StringMap();
};
$hxClasses["gamesave.ResizingBytesQueue"] = gamesave_ResizingBytesQueue;
gamesave_ResizingBytesQueue.__name__ = "gamesave.ResizingBytesQueue";
gamesave_ResizingBytesQueue.fromBase64 = function(str) {
var newQueue = new gamesave_ResizingBytesQueue();
newQueue.bytes = haxe_crypto_Base64.decode(str);
newQueue.size = newQueue.bytes.length;
return newQueue;
};
gamesave_ResizingBytesQueue.fromData = function(data) {
var newQueue = new gamesave_ResizingBytesQueue();
newQueue.bytes = haxe_io_Bytes.ofData(data.buffer);
newQueue.size = newQueue.bytes.length;
return newQueue;
};
gamesave_ResizingBytesQueue.prototype = {
addFloat: function(value) {
if(this.size + 8 > this.bytes.length) {
var oldBytes = this.bytes;
this.bytes = new haxe_io_Bytes(new ArrayBuffer((this.size + 8) * 2));
this.bytes.blit(0,oldBytes,0,this.size);
}
this.bytes.setDouble(this.size,value);
this.size += 8;
}
,addInt: function(value) {
if(this.size + 4 > this.bytes.length) {
var oldBytes = this.bytes;
this.bytes = new haxe_io_Bytes(new ArrayBuffer((this.size + 4) * 2));
this.bytes.blit(0,oldBytes,0,this.size);
}
this.bytes.setInt32(this.size,value);
this.size += 4;
}
,addByte: function(value) {
if(this.size + 1 > this.bytes.length) {
var oldBytes = this.bytes;
this.bytes = new haxe_io_Bytes(new ArrayBuffer((this.size + 1) * 2));
this.bytes.blit(0,oldBytes,0,this.size);
}
this.bytes.b[this.size] = value;
this.size += 1;
}
,addBool: function(value) {
if(this.size + 1 > this.bytes.length) {
var oldBytes = this.bytes;
this.bytes = new haxe_io_Bytes(new ArrayBuffer((this.size + 1) * 2));
this.bytes.blit(0,oldBytes,0,this.size);
}
this.bytes.b[this.size] = value ? 1 : 0;
this.size += 1;
}
,addString: function(str) {
var stringLoc = this.stringLocations.h[str];
if(stringLoc != null) {
if(this.size + 1 > this.bytes.length) {
var oldBytes = this.bytes;
this.bytes = new haxe_io_Bytes(new ArrayBuffer((this.size + 1) * 2));
this.bytes.blit(0,oldBytes,0,this.size);
}
this.bytes.b[this.size] = 1;
this.size += 1;
if(this.size + 4 > this.bytes.length) {
var oldBytes = this.bytes;
this.bytes = new haxe_io_Bytes(new ArrayBuffer((this.size + 4) * 2));
this.bytes.blit(0,oldBytes,0,this.size);
}
this.bytes.setInt32(this.size,stringLoc);
this.size += 4;
return;
}
if(this.size + 1 > this.bytes.length) {
var oldBytes = this.bytes;
this.bytes = new haxe_io_Bytes(new ArrayBuffer((this.size + 1) * 2));
this.bytes.blit(0,oldBytes,0,this.size);
}
this.bytes.b[this.size] = 0;
this.size += 1;
var addSizeAt = this.size;
var strSize = str.length;
var strSizeActual = 0;
if(this.size + 4 > this.bytes.length) {
var oldBytes = this.bytes;
this.bytes = new haxe_io_Bytes(new ArrayBuffer((this.size + 4) * 2));
this.bytes.blit(0,oldBytes,0,this.size);
}
this.bytes.setInt32(this.size,0);
this.size += 4;
var i = 0;
var ebts = 0;
while(i < str.length) {
var c = str.charCodeAt(i++);
if(55296 <= c && c <= 56319) {
c = c - 55232 << 10 | str.charCodeAt(i++) & 1023;
++ebts;
}
if(c <= 127) {
if(this.size + 1 > this.bytes.length) {
var oldBytes = this.bytes;
this.bytes = new haxe_io_Bytes(new ArrayBuffer((this.size + 1) * 2));
this.bytes.blit(0,oldBytes,0,this.size);
}
this.bytes.b[this.size] = c;
this.size += 1;
++strSizeActual;
} else if(c <= 2047) {
if(this.size + 1 > this.bytes.length) {
var oldBytes1 = this.bytes;
this.bytes = new haxe_io_Bytes(new ArrayBuffer((this.size + 1) * 2));
this.bytes.blit(0,oldBytes1,0,this.size);
}
this.bytes.b[this.size] = 192 | c >> 6;
this.size += 1;
if(this.size + 1 > this.bytes.length) {
var oldBytes2 = this.bytes;
this.bytes = new haxe_io_Bytes(new ArrayBuffer((this.size + 1) * 2));
this.bytes.blit(0,oldBytes2,0,this.size);
}
this.bytes.b[this.size] = 128 | c & 63;
this.size += 1;
++strSize;
strSizeActual += 2;
} else if(c <= 65535) {
if(this.size + 1 > this.bytes.length) {
var oldBytes3 = this.bytes;
this.bytes = new haxe_io_Bytes(new ArrayBuffer((this.size + 1) * 2));
this.bytes.blit(0,oldBytes3,0,this.size);
}
this.bytes.b[this.size] = 224 | c >> 12;
this.size += 1;
if(this.size + 1 > this.bytes.length) {
var oldBytes4 = this.bytes;
this.bytes = new haxe_io_Bytes(new ArrayBuffer((this.size + 1) * 2));
this.bytes.blit(0,oldBytes4,0,this.size);
}
this.bytes.b[this.size] = 128 | c >> 6 & 63;
this.size += 1;
if(this.size + 1 > this.bytes.length) {
var oldBytes5 = this.bytes;
this.bytes = new haxe_io_Bytes(new ArrayBuffer((this.size + 1) * 2));
this.bytes.blit(0,oldBytes5,0,this.size);
}
this.bytes.b[this.size] = 128 | c & 63;
this.size += 1;
strSize += 2;
strSizeActual += 3;
} else {
if(this.size + 1 > this.bytes.length) {
var oldBytes6 = this.bytes;
this.bytes = new haxe_io_Bytes(new ArrayBuffer((this.size + 1) * 2));
this.bytes.blit(0,oldBytes6,0,this.size);
}
this.bytes.b[this.size] = 240 | c >> 18;
this.size += 1;
if(this.size + 1 > this.bytes.length) {
var oldBytes7 = this.bytes;
this.bytes = new haxe_io_Bytes(new ArrayBuffer((this.size + 1) * 2));
this.bytes.blit(0,oldBytes7,0,this.size);
}
this.bytes.b[this.size] = 128 | c >> 12 & 63;
this.size += 1;
if(this.size + 1 > this.bytes.length) {
var oldBytes8 = this.bytes;
this.bytes = new haxe_io_Bytes(new ArrayBuffer((this.size + 1) * 2));
this.bytes.blit(0,oldBytes8,0,this.size);
}
this.bytes.b[this.size] = 128 | c >> 6 & 63;
this.size += 1;
if(this.size + 1 > this.bytes.length) {
var oldBytes9 = this.bytes;
this.bytes = new haxe_io_Bytes(new ArrayBuffer((this.size + 1) * 2));
this.bytes.blit(0,oldBytes9,0,this.size);
}
this.bytes.b[this.size] = 128 | c & 63;
this.size += 1;
strSize += 3;
strSizeActual += 4;
}
}
this.stringLocations.h[str] = addSizeAt;
this.bytes.setInt32(addSizeAt,strSizeActual);
}
,addRectangle: function(rect) {
var value = rect.x;
if(this.size + 4 > this.bytes.length) {
var oldBytes = this.bytes;
this.bytes = new haxe_io_Bytes(new ArrayBuffer((this.size + 4) * 2));
this.bytes.blit(0,oldBytes,0,this.size);
}
this.bytes.setInt32(this.size,value);
this.size += 4;
var value = rect.y;
if(this.size + 4 > this.bytes.length) {
var oldBytes = this.bytes;
this.bytes = new haxe_io_Bytes(new ArrayBuffer((this.size + 4) * 2));
this.bytes.blit(0,oldBytes,0,this.size);
}
this.bytes.setInt32(this.size,value);
this.size += 4;
var value = rect.width;
if(this.size + 4 > this.bytes.length) {
var oldBytes = this.bytes;
this.bytes = new haxe_io_Bytes(new ArrayBuffer((this.size + 4) * 2));
this.bytes.blit(0,oldBytes,0,this.size);
}
this.bytes.setInt32(this.size,value);
this.size += 4;
var value = rect.height;
if(this.size + 4 > this.bytes.length) {
var oldBytes = this.bytes;
this.bytes = new haxe_io_Bytes(new ArrayBuffer((this.size + 4) * 2));
this.bytes.blit(0,oldBytes,0,this.size);
}
this.bytes.setInt32(this.size,value);
this.size += 4;
}
,readRectangle: function() {
var intToRead = this.bytes.getInt32(this.readStart);
this.readStart += 4;
var intToRead1 = this.bytes.getInt32(this.readStart);
this.readStart += 4;
var intToRead2 = this.bytes.getInt32(this.readStart);
this.readStart += 4;
var intToRead3 = this.bytes.getInt32(this.readStart);
this.readStart += 4;
return new common_Rectangle(intToRead,intToRead1,intToRead2,intToRead3);
}
,addFPoint: function(point) {
var value = point.x;
if(this.size + 8 > this.bytes.length) {
var oldBytes = this.bytes;
this.bytes = new haxe_io_Bytes(new ArrayBuffer((this.size + 8) * 2));
this.bytes.blit(0,oldBytes,0,this.size);
}
this.bytes.setDouble(this.size,value);
this.size += 8;
var value = point.y;
if(this.size + 8 > this.bytes.length) {
var oldBytes = this.bytes;
this.bytes = new haxe_io_Bytes(new ArrayBuffer((this.size + 8) * 2));
this.bytes.blit(0,oldBytes,0,this.size);
}
this.bytes.setDouble(this.size,value);
this.size += 8;
}
,addJSON: function(object) {
this.addString(JSON.stringify(object));
}
,readJSON: function() {
return JSON.parse(this.readString());
}
,readPoint: function() {
var intToRead = this.bytes.getInt32(this.readStart);
this.readStart += 4;
var intToRead1 = this.bytes.getInt32(this.readStart);
this.readStart += 4;
return new common_Point(intToRead,intToRead1);
}
,readFPoint: function() {
var floatToRead = this.bytes.getDouble(this.readStart);
this.readStart += 8;
var floatToRead1 = this.bytes.getDouble(this.readStart);
this.readStart += 8;
return new common_FPoint(floatToRead,floatToRead1);
}
,readString: function() {
var byteToRead = this.bytes.b[this.readStart];
this.readStart += 1;
var whereToRead = byteToRead;
if(whereToRead == 1) {
var intToRead = this.bytes.getInt32(this.readStart);
this.readStart += 4;
var readPos = intToRead;
var stringLength = this.bytes.getInt32(readPos);
return this.bytes.getString(readPos + 4,stringLength);
} else {
var intToRead = this.bytes.getInt32(this.readStart);
this.readStart += 4;
var len = intToRead;
var str = this.bytes.getString(this.readStart,len);
this.readStart += len;
return str;
}
}
,readInt: function() {
var intToRead = this.bytes.getInt32(this.readStart);
this.readStart += 4;
return intToRead;
}
,peekInt: function() {
return this.bytes.getInt32(this.readStart);
}
,readByte: function() {
var byteToRead = this.bytes.b[this.readStart];
this.readStart += 1;
return byteToRead;
}
,readBool: function() {
var byteToRead = this.bytes.b[this.readStart];
this.readStart += 1;
return byteToRead > 0;
}
,readFloat: function() {
var floatToRead = this.bytes.getDouble(this.readStart);
this.readStart += 8;
return floatToRead;
}
,toBase64: function() {
var filledBytes = new haxe_io_Bytes(new ArrayBuffer(this.size));
filledBytes.blit(0,this.bytes,0,this.size);
return haxe_crypto_Base64.encode(filledBytes);
}
,getData: function() {
var filledBytes = new haxe_io_Bytes(new ArrayBuffer(this.size));
filledBytes.blit(0,this.bytes,0,this.size);
return filledBytes.b;
}
,__class__: gamesave_ResizingBytesQueue
};
var gamesave_SaveMetaData = function() { };
$hxClasses["gamesave.SaveMetaData"] = gamesave_SaveMetaData;
gamesave_SaveMetaData.__name__ = "gamesave.SaveMetaData";
gamesave_SaveMetaData.saveMetaData = function(fileName,city) {
var possibleStory = Lambda.find(Resources.allStoriesInfo,function(x) {
return x.link == city.progress.story.storyName;
});
var cityName = "City";
if(possibleStory != null) {
cityName = possibleStory.name;
}
if(city.cityName != "") {
cityName = city.cityName;
}
var metaText = "" + cityName + " - " + city.simulation.citizens.length + " citizens";
common_Storage.setItem(fileName + "__meta",metaText,function() {
});
common_Storage.setItem("__meta__mostRecentlyPlayed",fileName,function() {
});
};
var graphics_CachingContainer = function(cacheWithinRect) {
this.previousCullRectangle = null;
this.isInvalid = true;
PIXI.Container.call(this);
this.cacheWithinRect = cacheWithinRect;
this.cacheableChildren = [];
this.cacheContainer = new PIXI.Container();
this.explicitUncachedContainer = new PIXI.Container();
this.addChild(this.cacheContainer);
this.addChild(this.explicitUncachedContainer);
};
$hxClasses["graphics.CachingContainer"] = graphics_CachingContainer;
graphics_CachingContainer.__name__ = "graphics.CachingContainer";
graphics_CachingContainer.__super__ = PIXI.Container;
graphics_CachingContainer.prototype = $extend(PIXI.Container.prototype,{
preDraw: function(cullRectangle) {
if(this.isInvalid) {
if(Main.isCanvasRenderer && !Main.isMobile || this.cacheableChildren.length < 512 && (!Main.isMobile || this.cacheableChildren.length == 0)) {
this.cacheContainer.cacheAsBitmap = false;
var _g = 0;
var _g1 = this.cacheableChildren;
while(_g < _g1.length) {
var child = _g1[_g];
++_g;
if(child.parent != this.explicitUncachedContainer) {
if(child.parent != null) {
child.parent.removeChild(this.parent);
}
this.explicitUncachedContainer.addChild(child);
child.visible = true;
}
}
} else {
var _g = 0;
var _g1 = this.cacheableChildren;
while(_g < _g1.length) {
var child = _g1[_g];
++_g;
var childRect;
var childAsDynamic = child;
if(childAsDynamic.width != null) {
childRect = new common_Rectangle(Math.floor(child.x),Math.floor(child.y),Math.ceil(childAsDynamic.width + 1),Math.ceil(childAsDynamic.height + 1));
} else {
childRect = common_Rectangle.fromPixiRect(child.getLocalBounds());
}
if(this.cacheWithinRect.fullyContains(childRect)) {
if(child.parent != this.cacheContainer) {
if(child.parent != null) {
child.parent.removeChild(this.parent);
}
this.cacheContainer.addChild(child);
child.visible = true;
}
} else if(child.parent != this.explicitUncachedContainer) {
if(child.parent != null) {
child.parent.removeChild(this.parent);
}
this.explicitUncachedContainer.addChild(child);
}
}
this.cacheContainer.cacheAsBitmap = false;
this.cacheContainer.cacheAsBitmap = true;
}
this.isInvalid = false;
this.cull(cullRectangle);
this.previousCullRectangle = cullRectangle.clone();
} else if(this.previousCullRectangle == null || this.previousCullRectangle.x != cullRectangle.x || this.previousCullRectangle.y != cullRectangle.y || this.previousCullRectangle.width != cullRectangle.width || this.previousCullRectangle.height != cullRectangle.height) {
this.cull(cullRectangle);
this.previousCullRectangle = cullRectangle.clone();
}
}
,uncull: function() {
var _g = 0;
var _g1 = this.explicitUncachedContainer.children;
while(_g < _g1.length) {
var child = _g1[_g];
++_g;
child.visible = true;
}
this.previousCullRectangle = null;
}
,cull: function(cullRectangle) {
var x2 = cullRectangle.get_x2();
var y2 = cullRectangle.get_y2();
var _g = 0;
var _g1 = this.explicitUncachedContainer.children;
while(_g < _g1.length) {
var child = _g1[_g];
++_g;
var childAsDynamic = child;
if(childAsDynamic.width != null) {
child.visible = child.x + childAsDynamic.width >= cullRectangle.x && child.y + childAsDynamic.height >= cullRectangle.y && child.x < x2 && child.y < y2;
}
}
}
,removeCache: function() {
this.cacheContainer.cacheAsBitmap = false;
}
,__class__: graphics_CachingContainer
});
var graphics_GroundDecoration = function(stage,position,textureName,subImage) {
this.stage = stage;
this.position = position;
this.textureName = textureName;
this.textures = Resources.getTexturesByWidth(textureName,20);
if(subImage == null) {
subImage = random_Random.getInt(this.textures.length);
}
this.sprite = new PIXI.Sprite(this.textures[subImage]);
this.subImage = subImage;
this.sprite.position.set(position.x,position.y);
stage.addChild(this.sprite);
};
$hxClasses["graphics.GroundDecoration"] = graphics_GroundDecoration;
graphics_GroundDecoration.__name__ = "graphics.GroundDecoration";
graphics_GroundDecoration.prototype = {
destroy: function() {
this.stage.removeChild(this.sprite);
}
,__class__: graphics_GroundDecoration
};
var graphics_Particle = function() {
};
$hxClasses["graphics.Particle"] = graphics_Particle;
graphics_Particle.__name__ = "graphics.Particle";
graphics_Particle.create = function(stage,textures,position) {
var inst = graphics_Particle.pool.length == 0 ? new graphics_Particle() : graphics_Particle.pool.pop();
inst.___internal_pooling_initObject(stage,textures,position);
return inst;
};
graphics_Particle.prototype = {
___internal_pooling_initObject: function(stage,textures,position) {
this.stage = stage;
this.textures = textures;
this.frame = 0;
this.animSpeed = 0.5;
this.sprite = pooling_PooledSprite.create(textures[0],stage);
this.sprite.position.set(position.x,position.y);
}
,update: function(timeMod) {
this.frame += this.animSpeed * timeMod;
if(this.frame >= this.textures.length) {
var this1 = this.sprite;
var stage = this.stage;
this1.visible = false;
this1.position.set(-100000,-100000);
pooling_PooledSprite.pool.h[stage.__id__].push(this1);
this.destroy();
return true;
}
this.sprite.texture = this.textures[this.frame | 0];
return false;
}
,destroy: function() {
graphics_Particle.pool.push(this);
}
,__class__: graphics_Particle
};
var graphics_ParticleContainerHelper = function() { };
$hxClasses["graphics.ParticleContainerHelper"] = graphics_ParticleContainerHelper;
graphics_ParticleContainerHelper.__name__ = "graphics.ParticleContainerHelper";
graphics_ParticleContainerHelper.recreateContainer = function(cnt) {
var par = cnt.parent;
var pos = cnt.parent.children.indexOf(cnt);
cnt.parent.removeChild(cnt);
par.addChildAt(cnt,pos);
};
var graphics_Particles = function(stage) {
this.stage = stage;
this.particles = [];
};
$hxClasses["graphics.Particles"] = graphics_Particles;
graphics_Particles.__name__ = "graphics.Particles";
graphics_Particles.prototype = {
update: function(timeMod) {
var i = this.particles.length;
while(--i >= 0) if(this.particles[i].update(timeMod)) {
this.particles[i] = this.particles[this.particles.length - 1];
this.particles.pop();
}
}
,addParticle: function(textures,position) {
var newParticle = graphics_Particle.create(this.stage,textures,position);
this.particles.push(newParticle);
return newParticle;
}
,__class__: graphics_Particles
};
var graphics_Stars = function(stage,city) {
this.maxStarY = 800;
this.maxStarX = 800;
this.stage = stage;
this.city = city;
this.sprites = [];
this.resize();
};
$hxClasses["graphics.Stars"] = graphics_Stars;
graphics_Stars.__name__ = "graphics.Stars";
graphics_Stars.prototype = {
get_requiredNumberOfStars: function() {
return this.maxStarX * this.maxStarY / 1000 | 0;
}
,resize: function() {
var xScale = 1.0;
var yScale = 1.0;
if(this.city.get_displayWidth() > this.maxStarX) {
xScale = this.city.get_displayWidth() / this.maxStarX;
this.maxStarX = this.city.get_displayWidth();
}
if(this.city.get_displayHeight() > this.maxStarY) {
yScale = this.city.get_displayHeight() / this.maxStarY;
this.maxStarY = this.city.get_displayHeight();
}
var _g = 0;
var _g1 = this.sprites;
while(_g < _g1.length) {
var spr = _g1[_g];
++_g;
spr.position.x *= xScale;
spr.position.y *= yScale;
}
var _g = this.sprites.length;
var _g1 = this.get_requiredNumberOfStars();
while(_g < _g1) {
var i = _g++;
var spr = Resources.makeSprite("spr_pixel");
var this1 = [random_Random.getFloat(360),random_Random.getFloat(0,1),random_Random.getFloat(0.9,1)];
spr.tint = thx_color_Rgb.toInt(thx_color_Hsl.toRgb(this1));
spr.position.set(random_Random.getInt(this.maxStarX),random_Random.getInt(this.maxStarY));
spr.alpha = random_Random.getFloat(0.2,0.6);
this.sprites.push(spr);
this.stage.addChild(spr);
}
}
,update: function() {
var time = this.city.simulation.time.timeSinceStart / 60 % 24;
if(time >= 23 || time < 4) {
this.stage.alpha = 1;
} else if(time >= 4 && time < 6.) {
this.stage.alpha = 1 - (time - 4) / 2;
} else if(time >= 21. && time < 23) {
this.stage.alpha = 1 - (23 - time) / 2;
} else {
this.stage.alpha = 0;
}
this.stage.visible = this.stage.alpha != 0;
}
,__class__: graphics_Stars
};
var graphics_WorldImage = function() { };
$hxClasses["graphics.WorldImage"] = graphics_WorldImage;
graphics_WorldImage.__name__ = "graphics.WorldImage";
graphics_WorldImage.makeWorldSprite = function(random,width,height) {
var outlineColor = 2103312;
var fillColor = 5259312;
var val = height - 10;
var belowWorldHeight = val < 0 ? 0 : val > 12 ? 12 : val;
var worldHeight = height - belowWorldHeight;
var spriteCanvas = window.document.createElement("canvas");
spriteCanvas.width = width;
spriteCanvas.height = height;
var ctx = spriteCanvas.getContext("2d");
var worldSpriteData = ctx.createImageData(width,height);
var _g = [];
var _g1 = 0;
var _g2 = width / 20 | 0;
while(_g1 < _g2) {
var x = _g1++;
var _g3 = [];
var _g4 = 0;
var _g5 = height / 20 | 0;
while(_g4 < _g5) {
var y = _g4++;
_g3.push(false);
}
_g.push(_g3);
}
var collisionMask = _g;
var minimumYMax = Math.floor(worldHeight - worldHeight / 4);
var minimumYMin = Math.floor(worldHeight - worldHeight / 2);
var maximumYMin = Math.floor(worldHeight - worldHeight / 3);
var outlinePoints = [{ x : 0, y : 0}];
var pixelsFromSide = Math.min(worldHeight / 4 + random.getInt(-5,6),width / 3) | 0;
var numberOfOtherOutlinePoints = Math.max(1,Math.floor((width - pixelsFromSide * 2) / (random.getInt(25,35) + width / 40))) | 0;
var xchange = Math.floor((width - pixelsFromSide * 2) / numberOfOtherOutlinePoints);
var xx = pixelsFromSide + ((width - pixelsFromSide * 2 - xchange * (numberOfOtherOutlinePoints - 0.5)) / 2 | 0);
var _g = 0;
var _g1 = numberOfOtherOutlinePoints;
while(_g < _g1) {
var i = _g++;
outlinePoints.push({ x : xx + random.getInt(-6,7), y : random.getInt(minimumYMax,worldHeight)});
if(i != numberOfOtherOutlinePoints - 1) {
outlinePoints.push({ x : xx + (xchange / 2 | 0) + random.getInt(-6,7), y : random.getInt(minimumYMin,maximumYMin)});
}
xx += xchange;
}
outlinePoints.push({ x : width - 1, y : 0});
var fillPixel = function(x,y) {
var dataPos = 4 * (width * y + x);
worldSpriteData.data[dataPos] = fillColor >> 16 & 255;
worldSpriteData.data[dataPos + 1] = fillColor >> 8 & 255;
worldSpriteData.data[dataPos + 2] = fillColor & 255;
worldSpriteData.data[dataPos + 3] = 255;
collisionMask[x / 20 | 0][y / 20 | 0] = true;
};
var powfactor1 = 1.6;
var powfactor2 = 1.2;
var powChangeFactor = 8;
var currentOutlinePoint = 0;
var addPowFactor = 0.0;
var _g = 0;
var _g1 = width;
while(_g < _g1) {
var i = _g++;
var maxAddPowFactorXChange = powChangeFactor / (Math.abs(outlinePoints[currentOutlinePoint + 1].y - outlinePoints[currentOutlinePoint].y) + 5);
var val = addPowFactor + random.getFloat(-maxAddPowFactorXChange,maxAddPowFactorXChange);
addPowFactor = val < -0.2 ? -0.2 : val > 0.2 ? 0.2 : val;
if(i > outlinePoints[currentOutlinePoint + 1].x) {
if(outlinePoints[currentOutlinePoint + 1].y > outlinePoints[currentOutlinePoint].y) {
var numberOfEarthParts = random.getInt(1,3);
var distBetweenEarthParts = random.getInt(5,8);
var _g2 = 0;
var _g3 = numberOfEarthParts;
while(_g2 < _g3) {
var op = _g2++;
var bx = random.getInt(-2,3) + i - (numberOfEarthParts - 1) * distBetweenEarthParts + (distBetweenEarthParts * 2 * op | 0);
var by = outlinePoints[currentOutlinePoint + 1].y + random.getInt(3);
var fromX = bx - 1;
var toX = bx;
var _g4 = by + 2;
var _g5 = by + 11;
while(_g4 < _g5) {
var y = _g4++;
if(y <= by + 5) {
fromX -= random.getInt(y < by + 5 ? 3 : 2);
toX += random.getInt(y < by + 5 ? 3 : 2);
} else {
var val1 = fromX + random.getInt(y > by + 6 ? 3 : 2);
fromX = toX < val1 ? toX : val1;
var val11 = toX - random.getInt(y > by + 6 ? 3 : 2);
toX = fromX > val11 ? fromX : val11;
}
if(y == by + 2 && toX - fromX == 1) {
++toX;
}
if(y == by + 3 && toX - fromX == 2) {
--fromX;
}
var _g6 = fromX;
var _g7 = toX;
while(_g6 < _g7) {
var x = _g6++;
if(x >= 0 && x < width && y + 2 < height) {
fillPixel(x,y);
}
}
}
}
}
++currentOutlinePoint;
}
var pnt = outlinePoints[currentOutlinePoint];
var nextPnt = outlinePoints[currentOutlinePoint + 1];
var interpolate = (i - pnt.x) / (nextPnt.x - pnt.x);
if(nextPnt.y < pnt.y) {
interpolate = Math.pow(interpolate,powfactor1 - interpolate * powfactor2 + addPowFactor);
} else {
interpolate = 1 - Math.pow(1 - interpolate,powfactor1 - (1 - interpolate) * powfactor2 - addPowFactor);
}
var val12 = Math.floor(interpolate * (nextPnt.y - pnt.y) + pnt.y);
var val2 = worldHeight - 1;
var bottomPixel = val2 < val12 ? val2 : val12;
var _g8 = 0;
var _g9 = bottomPixel + 1;
while(_g8 < _g9) {
var j = _g8++;
fillPixel(i,j);
}
}
var _g = 0;
var _g1 = worldSpriteData.data.length / 4 | 0;
while(_g < _g1) {
var i = _g++;
var x = i % width;
var y = Math.floor(i / width);
if(worldSpriteData.data[i * 4 + 3] == 255 && (x == 0 || y == 0 || x == width - 1 || y == height - 1 || worldSpriteData.data[i * 4 - 1] == 0 || worldSpriteData.data[i * 4 + 7] == 0 || worldSpriteData.data[((y - 1) * width + x) * 4 + 3] == 0 || worldSpriteData.data[((y + 1) * width + x) * 4 + 3] == 0)) {
worldSpriteData.data[i * 4] = outlineColor >> 16 & 255;
worldSpriteData.data[i * 4 + 1] = outlineColor >> 8 & 255;
worldSpriteData.data[i * 4 + 2] = outlineColor & 255;
}
}
ctx.putImageData(worldSpriteData,0,0);
return { sprite : new PIXI.Sprite(PIXI.Texture.fromCanvas(spriteCanvas)), mask : collisionMask};
};
var gui_ActivableButton = function() { };
$hxClasses["gui.ActivableButton"] = gui_ActivableButton;
gui_ActivableButton.__name__ = "gui.ActivableButton";
gui_ActivableButton.create = function(gui,stage,parent,onClick,isActive,text) {
var button1 = new gui_ContainerButton(gui,stage,parent,onClick,isActive,null,"spr_button_activable");
var extraSpacing = gui.game.isMobile ? 3 : 0;
button1.container.padding.top = 3 + extraSpacing;
button1.container.padding.left = 3;
button1.container.padding.right = 3;
button1.container.padding.bottom = extraSpacing;
if(text != null) {
button1.container.addChild(new gui_TextElement(button1.container,gui.innerWindowStage,text));
}
button1.container.fillSecondarySize = true;
return button1;
};
var gui_AdRewardWindow = function() { };
$hxClasses["gui.AdRewardWindow"] = gui_AdRewardWindow;
gui_AdRewardWindow.__name__ = "gui.AdRewardWindow";
gui_AdRewardWindow.create = function(city,gui,stage,thisWindow,extraReward,specialBoostText) {
city.gui.windowAddTitleText("Thank You!");
thisWindow.addChild(new gui_TextElement(thisWindow,stage,"All resource production is now doubled for a while! Additionally, you got the following bonus reward:",null,"Arial"));
thisWindow.addChild(new gui_GUISpacing(thisWindow,new common_Point(2,6)));
thisWindow.addChild(new gui_TextElement(thisWindow,stage,extraReward.text,null,"Arial15"));
var rewardContainer = new gui_MaterialsDisplay(extraReward.materials);
var rewardHolder = new gui_ContainerHolder(city.gui.windowInner,city.gui.innerWindowStage,rewardContainer);
thisWindow.addChild(rewardHolder);
if(specialBoostText != "") {
thisWindow.addChild(new gui_GUISpacing(thisWindow,new common_Point(2,6)));
gui.windowAddInfoText(specialBoostText);
}
gui.windowAddBottomButtons();
};
var gui_IGUIElement = function() { };
$hxClasses["gui.IGUIElement"] = gui_IGUIElement;
gui_IGUIElement.__name__ = "gui.IGUIElement";
gui_IGUIElement.__isInterface__ = true;
gui_IGUIElement.prototype = {
__class__: gui_IGUIElement
};
var gui_Scrollable = function(game,outerStage,parent,position,width,height,origin) {
this.destroyed = false;
this.maskRect = null;
this.game = game;
this.outerStage = outerStage;
this.parent = parent;
this.stage = new PIXI.Container();
outerStage.addChild(this.stage);
this.scrollPosition = new common_Point(0,0);
this.rect = new common_Rectangle(0,0,width,height);
this.origin = origin;
this.updatePosition(position);
this.updateSize();
this.dragDir = new common_FPoint(0,0);
this.dragDirRemaining = new common_FPoint(0,0);
this.remainingStepDragDir = new common_FPoint(0,0);
};
$hxClasses["gui.Scrollable"] = gui_Scrollable;
gui_Scrollable.__name__ = "gui.Scrollable";
gui_Scrollable.__interfaces__ = [gui_IGUIElement];
gui_Scrollable.prototype = {
get_innerHeight: function() {
return this.child.rect.height;
}
,setChild: function(child) {
this.child = child;
this.updateSize();
}
,updateSize: function() {
if(this.child != null) {
var val = this.scrollPosition.y;
var val2 = this.get_innerHeight() - this.rect.height;
var maxVal = val2 > 0 ? val2 : 0;
this.scrollPosition.y = val < 0 ? 0 : val > maxVal ? maxVal : val;
}
if(this.parent != null) {
this.parent.updateSize();
} else {
this.updatePosition(this.position);
}
}
,updateScrollPosition: function(newPosition) {
this.scrollPosition = newPosition;
this.updateSize();
}
,updateStageMask: function() {
if(this.child == null || this.child.rect.width <= this.rect.width && this.get_innerHeight() <= this.rect.height) {
if(this.stage.mask != null) {
this.stage.mask.destroy();
}
this.stage.mask = null;
this.maskRect = null;
return;
}
if(this.maskRect == null || (this.maskRect.x != this.rect.x || this.maskRect.y != this.rect.y || this.maskRect.width != this.rect.width || this.maskRect.height != this.rect.height)) {
this.maskRect = this.rect.clone();
if(this.stage.mask != null) {
this.stage.mask.destroy();
}
var mask = new PIXI.Graphics();
mask.beginFill(0);
mask.alpha = 0;
this.stage.addChild(mask);
mask.drawRect(this.rect.x,this.rect.y - 1,this.rect.width,this.rect.height + 1);
mask.endFill();
this.stage.mask = mask;
}
}
,updatePosition: function(newPosition) {
this.position = newPosition;
var _this = this.rect;
var _this1 = this.position;
var otherPoint_x = this.origin.x * this.rect.width | 0;
var otherPoint_y = this.origin.y * this.rect.height | 0;
var newPos_x = _this1.x - otherPoint_x;
var newPos_y = _this1.y - otherPoint_y;
var inlPoint_x = _this.x = newPos_x;
var inlPoint_y = _this.y = newPos_y;
if(this.child != null) {
var _this = this.rect;
var _this_x = _this.x;
var _this_y = _this.y;
var otherPoint = this.scrollPosition;
this.child.updatePosition(new common_Point(_this_x - otherPoint.x,_this_y - otherPoint.y));
}
this.updateStageMask();
}
,destroy: function() {
if(this.child != null) {
this.child.destroy();
}
this.stage.destroy(true);
this.destroyed = true;
}
,claimMouseForScroll: function(mouse,needsPress) {
if(needsPress == null) {
needsPress = true;
}
var _gthis = this;
if(mouse.hasNoClaim()) {
this.mousePreviousY = mouse.position.y;
mouse.strongClaimMouse("scrollWindow",function() {
if(_gthis.destroyed) {
return;
}
var scrollAmount = _gthis.mousePreviousY - mouse.position.y;
_gthis.updateScrollPosition(new common_Point(_gthis.scrollPosition.x,_gthis.scrollPosition.y + scrollAmount));
_gthis.mousePreviousY = mouse.position.y;
},needsPress);
return true;
}
return false;
}
,handleMouse: function(mouse) {
if(this.rect.contains(mouse.position)) {
this.handleScrollWheel(mouse);
if(mouse.isTouch) {
if(mouse.weakClaimForScroll(this)) {
if(this.claimMouseForScroll(mouse,false)) {
return true;
}
}
}
if(this.child != null) {
if(this.child.handleMouse(mouse)) {
return true;
}
}
if(mouse.isTouch) {
if(this.claimMouseForScroll(mouse)) {
return true;
}
}
mouse.claimMouse(this);
return true;
}
return false;
}
,handleScrollWheel: function(mouse) {
var maxScroll = this.rect.height - 10;
if(mouse.scrollBarMovement != 0) {
var val = Math.round(mouse.scrollBarMovement);
var minVal = -maxScroll;
this.updateScrollPosition(new common_Point(this.scrollPosition.x,this.scrollPosition.y + (val < minVal ? minVal : val > maxScroll ? maxScroll : val)));
}
if(mouse.scrollBarMovementPages != 0) {
var val = Math.round(this.rect.height * mouse.scrollBarMovementPages);
var minVal = -maxScroll;
this.updateScrollPosition(new common_Point(this.scrollPosition.x,this.scrollPosition.y + (val < minVal ? minVal : val > maxScroll ? maxScroll : val)));
}
}
,update: function() {
if(this.child != null) {
this.child.update();
}
if(this.game.mouse.pressed || this.dragDir.get_length() < 0.5) {
this.dragDir.x = 0;
this.dragDir.y = 0;
this.remainingStepDragDir.x = 0;
this.remainingStepDragDir.y = 0;
} else if(!this.game.mouse.hasSpecificClaim("scrollWindow")) {
var dragSpeedTimeout = this.game.mouse.isTouch ? 0.933 : 0.8;
this.dragDir.x *= dragSpeedTimeout;
this.dragDir.y *= dragSpeedTimeout;
var stepDragDir_x = this.dragDir.x + this.dragDirRemaining.x;
var stepDragDir_y = this.dragDir.y + this.dragDirRemaining.y;
this.dragDirRemaining.x += this.dragDir.x - stepDragDir_x;
this.dragDirRemaining.y += this.dragDir.y - stepDragDir_y;
this.remainingStepDragDir.x += stepDragDir_x;
this.remainingStepDragDir.y += stepDragDir_y;
var remStepDragDirToUse = Math.floor(this.remainingStepDragDir.y);
this.updateScrollPosition(new common_Point(this.scrollPosition.x,this.scrollPosition.y + remStepDragDirToUse));
this.remainingStepDragDir.y -= remStepDragDirToUse;
}
}
,__class__: gui_Scrollable
};
var gui_AutoScrollable = function(game,outerStage,parent,position,width,height,origin) {
this.maxWidth = width;
this.maxHeight = height;
gui_Scrollable.call(this,game,outerStage,parent,position,width,height,origin);
};
$hxClasses["gui.AutoScrollable"] = gui_AutoScrollable;
gui_AutoScrollable.__name__ = "gui.AutoScrollable";
gui_AutoScrollable.__super__ = gui_Scrollable;
gui_AutoScrollable.prototype = $extend(gui_Scrollable.prototype,{
updateSize: function() {
if(this.child != null) {
var val1 = this.maxWidth;
var val2 = this.child.rect.width;
this.rect.width = val2 < val1 ? val2 : val1;
var val1 = this.maxHeight;
var val2 = this.child.rect.height;
this.rect.height = val2 < val1 ? val2 : val1;
}
gui_Scrollable.prototype.updateSize.call(this);
}
,updatePosition: function(newPosition) {
gui_Scrollable.prototype.updatePosition.call(this,newPosition);
}
,__class__: gui_AutoScrollable
});
var gui_BirthControlWindow = function() { };
$hxClasses["gui.BirthControlWindow"] = gui_BirthControlWindow;
gui_BirthControlWindow.__name__ = "gui.BirthControlWindow";
gui_BirthControlWindow.create = function(city,gui,stage,thisWindow) {
gui.windowAddTitleText("Birth Control");
var currentType = city.simulation.babyMaker.mode;
gui_UpgradeWindowParts.createActivatableButton(gui,currentType == 1,function() {
city.simulation.babyMaker.mode = 1;
city.simulation.babyMaker.targetPopAmount = city.simulation.citizens.length;
gui.reloadWindow();
},"Greatly Discourage Getting Children","The population will roughly stabilize.");
gui_UpgradeWindowParts.createActivatableButton(gui,currentType == 2,function() {
city.simulation.babyMaker.mode = 2;
gui.reloadWindow();
},"Encourage Contraception","The population will grow slowly.");
gui_UpgradeWindowParts.createActivatableButton(gui,currentType == 0,function() {
city.simulation.babyMaker.mode = 0;
gui.reloadWindow();
},"No Special Policy","Babies will be born at the normal rate.");
gui_UpgradeWindowParts.createActivatableButton(gui,currentType == 3,function() {
city.simulation.babyMaker.mode = 3;
gui.reloadWindow();
},"Encourage Parenthood","More babies will be born, as long as the happiness is high enough.");
gui.windowAddBottomButtons();
};
var gui_BuildingButtons = function(gui,city) {
this.wasLargeMobile = false;
this.previouslyShownCategory = "";
this.mobileStopBuildingOrManagingButton = null;
this.activateBuildModeButton = null;
this.buildingModeEnabled = false;
this.shownManagementOptions = false;
this.shownBuildingModes = false;
this.creatableCityElementsThatNeededAttention = [];
this.categoryButtonPosition = new haxe_ds_StringMap();
this.gui = gui;
this.city = city;
this.createBuildingButtons();
this.shownCategory = "";
this.buttonsByCategory = new haxe_ds_StringMap();
this.buttonsInCategory = new haxe_ds_StringMap();
this.wasLargeMobile = this.gui.game.isLargeMobile;
};
$hxClasses["gui.BuildingButtons"] = gui_BuildingButtons;
gui_BuildingButtons.__name__ = "gui.BuildingButtons";
gui_BuildingButtons.prototype = {
resize: function() {
this.buildingButtons.updatePosition(new common_Point(0,this.gui.game.rect.height));
this.allBuildingModeButtons.updatePosition(new common_Point(0,this.gui.game.rect.height - 20 - 2));
this.allManagementOptionsButtons.updatePosition(new common_Point(0,this.gui.game.rect.height - 20 - 2));
if(this.gui.game.isMobile) {
if(this.gui.game.isLargeMobile != this.wasLargeMobile) {
if(this.wasLargeMobile) {
this.buildingModeEnabled = this.city.builder != null || this.shownCategory != "" || this.shownBuildingModes;
} else {
if(this.buildingModeEnabled) {
this.mobileStopBuildingOrManagingButton = null;
this.gui.createCityInfo();
}
this.buildingModeEnabled = false;
}
this.refreshCategoryBuildingsShown();
this.wasLargeMobile = this.gui.game.isLargeMobile;
}
}
}
,update: function(timeMod) {
this.allBuildingModeButtons.update();
this.buildingButtons.update();
this.allManagementOptionsButtons.update();
this.updateGoalAttentions();
}
,handleMouse: function(mouse) {
if(this.allBuildingModeButtons.handleMouse(mouse)) {
return true;
}
if(this.buildingButtons.handleMouse(mouse)) {
return true;
}
if(this.allManagementOptionsButtons.handleMouse(mouse)) {
return true;
}
return false;
}
,activateLoserState: function() {
this.buildingButtons.clear();
this.allBuildingModeButtons.clear();
this.allManagementOptionsButtons.clear();
}
,createBuildingButtons: function() {
this.buildingButtons = new gui_GUIContainer(this.gui,this.gui.stage,null,new common_Point(0,this.gui.game.rect.height),new common_FPoint(0,1));
this.categoryButtons = new gui_GUIContainer(this.gui,this.gui.stage,this.buildingButtons);
this.allBuildingModeButtons = new gui_GUIContainer(this.gui,this.gui.stage,null,new common_Point(0,this.gui.game.rect.height - 20 - 2),new common_FPoint(0,1));
this.allManagementOptionsButtons = new gui_GUIContainer(this.gui,this.gui.stage,null,new common_Point(0,this.gui.game.rect.height - 20 - 2),new common_FPoint(0,1));
this.buildingInCategoryButtons = new gui_GUIContainer(this.gui,this.gui.stage,this.buildingButtons);
this.buildingButtons.direction = gui_GUIContainerDirection.Vertical;
this.buildingInCategoryButtons.direction = this.gui.game.isMobile ? gui_GUIContainerDirection.Vertical : gui_GUIContainerDirection.Horizontal;
this.buildingInCategoryButtonsCol = null;
this.buildingInCategoryButtonsColAmount = 0;
this.allBuildingModeButtons.direction = this.gui.game.isMobile ? gui_GUIContainerDirection.Horizontal : gui_GUIContainerDirection.Vertical;
this.allManagementOptionsButtons.direction = this.gui.game.isMobile ? gui_GUIContainerDirection.Horizontal : gui_GUIContainerDirection.Vertical;
this.buildingButtons.addChild(this.buildingInCategoryButtons);
this.buildingButtons.addChild(this.categoryButtons);
if(this.gui.game.isMobile && !this.gui.game.isLargeMobile) {
this.createMobileBuildButton();
} else {
this.createBuildingCategoryButtons();
}
}
,showTutorialArrows1: function(overlayElements,windowClosed,gameHelpStage) {
var _gthis = this;
var firstBuildArrow = new gui_HelpArrow(this.gui,gameHelpStage,function() {
return _gthis.categoryButtons.children[_gthis.buildingModeEnabled && !_gthis.gui.game.isLargeMobile ? 1 : 0];
},function() {
if(windowClosed() && _gthis.city.builder == null) {
return _gthis.shownCategory == "";
} else {
return false;
}
});
if(!this.gui.game.isMobile) {
firstBuildArrow.useBigMovement();
}
overlayElements.push(firstBuildArrow);
var secondBuildArrow = new gui_HelpArrow(this.gui,gameHelpStage,function() {
var currentCategoryButtons = _gthis.buildingInCategoryButtons.children[0];
return currentCategoryButtons.children[currentCategoryButtons.children.length - 1];
},function() {
if(windowClosed() && _gthis.city.builder == null) {
return _gthis.shownCategory != "";
} else {
return false;
}
},gui_HelpArrowDirection.Left);
overlayElements.push(secondBuildArrow);
}
,showTutorialArrows101: function(overlayElements,shouldShow,gameHelpStage) {
var _gthis = this;
var helpArrow1 = new gui_HelpArrow(this.gui,gameHelpStage,function() {
return _gthis.categoryButtons.children[_gthis.buildingModeEnabled && !_gthis.gui.game.isLargeMobile ? 1 : 0];
},function() {
if(shouldShow() && _gthis.city.builder == null) {
return _gthis.shownCategory == "";
} else {
return false;
}
});
overlayElements.push(helpArrow1);
var helpArrow2 = new gui_HelpArrow(this.gui,gameHelpStage,function() {
var currentCategoryButtons = _gthis.buildingInCategoryButtons.children[0];
return currentCategoryButtons.children[currentCategoryButtons.direction == gui_GUIContainerDirection.Horizontal ? currentCategoryButtons.children.length - 1 : currentCategoryButtons.children.length - 2];
},function() {
if(shouldShow() && _gthis.city.builder == null) {
return _gthis.shownCategory != "";
} else {
return false;
}
},gui_HelpArrowDirection.Left);
overlayElements.push(helpArrow2);
var text = "You have enough wood. Let's build the stone mine!";
helpArrow1.addText(text);
helpArrow2.addText(text);
}
,showTutorialArrows2: function(overlayElements,everHadPrio,gameHelpStage,windowClosed) {
var _gthis = this;
overlayElements.push(new gui_HelpArrow(this.gui,gameHelpStage,function() {
return _gthis.mobileStopBuildingOrManagingButton;
},function() {
if(windowClosed() && gui_WorkerDistributionWindow.tutorialStoneMineUpButton == null) {
return !everHadPrio();
} else {
return false;
}
},gui_HelpArrowDirection.Down));
}
,createMobileBuildButton: function() {
var _gthis = this;
var createMobileStopBuildingOrManagingButton = null;
var activateMobileBuild = function(wasAlreadyOpen) {
if(wasAlreadyOpen == null) {
wasAlreadyOpen = false;
}
_gthis.buildingModeEnabled = true;
_gthis.activateBuildModeButton = null;
if(!wasAlreadyOpen) {
_gthis.gui.closeWindow();
}
_gthis.gui.hideCityInfo();
_gthis.categoryButtons.clear();
createMobileStopBuildingOrManagingButton();
_gthis.createBuildingCategoryButtons();
if(_gthis.previouslyShownCategory != "") {
_gthis.showOrHideBuildingsOfCategory(_gthis.previouslyShownCategory,_gthis.categoryButtonPosition.h[_gthis.previouslyShownCategory],false,true,true);
_gthis.previouslyShownCategory = "";
}
};
var createMobileBuildButtonInternal = function() {
var mobileBuildButton = new gui_ImageButton(_gthis.gui,_gthis.gui.stage,_gthis.categoryButtons,function() {
activateMobileBuild();
},Resources.getTexture("spr_icon_build"),function() {
return false;
},function() {
_gthis.gui.tooltip.setText(mobileBuildButton,"Build");
});
_gthis.categoryButtons.addChild(mobileBuildButton);
_gthis.activateBuildModeButton = mobileBuildButton;
};
createMobileStopBuildingOrManagingButton = function() {
var _gthis1 = _gthis.gui;
var _gthis2 = _gthis.gui.stage;
var _gthis3 = _gthis.categoryButtons;
var createMobileStopBuildingOrManagingButton = Resources.getTexture("spr_arrow_back");
_gthis.mobileStopBuildingOrManagingButton = new gui_ImageButton(_gthis1,_gthis2,_gthis3,function() {
_gthis.mobileStopBuildingOrManaging();
},createMobileStopBuildingOrManagingButton,function() {
return false;
},function() {
_gthis.gui.tooltip.setText(_gthis.mobileStopBuildingOrManagingButton,"Back");
});
_gthis.categoryButtons.addChild(_gthis.mobileStopBuildingOrManagingButton);
};
if(this.buildingModeEnabled) {
activateMobileBuild(true);
this.shownManagementOptions = false;
return;
}
var activateMobileManagement = function(wasAlreadyOpen) {
if(wasAlreadyOpen == null) {
wasAlreadyOpen = false;
}
_gthis.shownManagementOptions = true;
_gthis.activateBuildModeButton = null;
if(!wasAlreadyOpen) {
_gthis.gui.closeWindow();
}
_gthis.gui.hideCityInfo();
_gthis.categoryButtons.clear();
createMobileStopBuildingOrManagingButton();
_gthis.showManagementOptions(_gthis.categoryButtons);
};
var createMobileManageButtonInternal = function() {
var mobileManageButton = new gui_ImageButton(_gthis.gui,_gthis.gui.stage,_gthis.categoryButtons,function() {
activateMobileManagement();
},Resources.getTexture("spr_icon_management"),function() {
return false;
},function() {
_gthis.gui.tooltip.setText(mobileManageButton,"Management");
});
_gthis.categoryButtons.addChild(mobileManageButton);
};
if(this.shownManagementOptions) {
activateMobileManagement(true);
this.buildingModeEnabled = false;
return;
}
createMobileBuildButtonInternal();
if(this.city.progress.unlocks.unlockedManagementOptions) {
createMobileManageButtonInternal();
}
}
,mobileStopBuildingOrManaging: function() {
if(!this.buildingModeEnabled && !this.shownManagementOptions) {
return;
}
this.mobileStopBuildingOrManagingButton = null;
this.buildingModeEnabled = false;
this.shownManagementOptions = false;
this.gui.createCityInfo();
this.categoryButtons.clear();
if(this.shownCategory != "") {
this.previouslyShownCategory = this.shownCategory;
this.showOrHideBuildingsOfCategory(this.shownCategory,this.categoryButtonPosition.h[this.shownCategory],false,true,true);
}
this.closeExtraBuildingModes();
this.createMobileBuildButton();
}
,createBuildingCategoryButtons: function() {
var _gthis = this;
var totalWidth = 0;
this.buttonsByCategory = new haxe_ds_StringMap();
this.buttonsInCategory = new haxe_ds_StringMap();
var _g = 0;
var _g1 = Resources.buildingCategoriesInfo;
while(_g < _g1.length) {
var category = [_g1[_g]];
++_g;
var anyUnlocked = false;
var _g2 = 0;
var _g3 = this.city.progress.resources.buildingInfoArray;
while(_g2 < _g3.length) {
var building = _g3[_g2];
++_g2;
var name = "buildings." + building.className;
var classToBuild = $hxClasses[name];
var unlockState = this.city.progress.unlocks.getUnlockState(classToBuild);
if(building.category == category[0].name && (unlockState == progress_UnlockState.Unlocked || unlockState == progress_UnlockState.Researched || unlockState == progress_UnlockState.Createable)) {
anyUnlocked = true;
}
}
var _g4 = 0;
var _g5 = Resources.decorationsInfo;
while(_g4 < _g5.length) {
var decoration = _g5[_g4];
++_g4;
if(decoration.category == category[0].name && this.city.progress.unlocks.unlockedDecorationTab) {
anyUnlocked = true;
}
}
var _g6 = 0;
var _g7 = Resources.worldResourcesInfo;
while(_g6 < _g7.length) {
var worldInfo = _g7[_g6];
++_g6;
if(worldInfo.category == category[0].name && this.city.progress.unlocks.unlockedDecorationTab) {
anyUnlocked = true;
}
}
if(anyUnlocked) {
var categoryButton = [null];
var totalWidthNow = [totalWidth];
categoryButton[0] = new gui_ImageButton(this.gui,this.gui.stage,this.categoryButtons,(function(totalWidthNow,categoryButton,category) {
return function() {
categoryButton[0].stopNotify();
_gthis.showOrHideBuildingsOfCategory(category[0].name,totalWidthNow[0]);
_gthis.updateGoalAttentions();
};
})(totalWidthNow,categoryButton,category),Resources.getTexture(category[0].image),(function(category) {
return function() {
return _gthis.shownCategory == category[0].name;
};
})(category),(function(categoryButton,category) {
return function() {
_gthis.gui.tooltip.setText(categoryButton[0],category[0].description,category[0].name);
};
})(categoryButton,category),null,"spr_transparentbutton");
this.categoryButtons.addChild(categoryButton[0]);
this.categoryButtonPosition.h[category[0].name] = totalWidth;
this.buttonsByCategory.h[category[0].name] = categoryButton[0];
totalWidth += 22;
if(this.city.progress.unlocks.getShouldNotifyForCategoryUnlock(category[0].name)) {
if(this.shownCategory == category[0].name) {
this.city.progress.unlocks.stopNotifyCategoryUnlock(category[0].name);
} else {
categoryButton[0].notify(false,(function(_g,categoryName) {
return function() {
_g[0](categoryName[0]);
};
})([($_=this.city.progress.unlocks,$bind($_,$_.stopNotifyCategoryUnlock))],[category[0].name]));
}
}
}
}
if(this.city.progress.unlocks.unlockedBuildingModeButton) {
this.addBuildingModeButtons();
}
if(!this.gui.game.isMobile || this.gui.game.isLargeMobile) {
if(this.city.progress.unlocks.unlockedManagementOptions) {
this.addManagementButtons();
}
}
}
,showOrHideBuildingsOfCategory: function(category,atWidth,neverHide,destroyBuilder,keepExtraBuildingModesOpen) {
if(keepExtraBuildingModesOpen == null) {
keepExtraBuildingModesOpen = false;
}
if(destroyBuilder == null) {
destroyBuilder = true;
}
if(neverHide == null) {
neverHide = false;
}
this.buildingInCategoryButtons.clear();
if(!keepExtraBuildingModesOpen) {
this.closeExtraBuildingModes();
}
if(!keepExtraBuildingModesOpen && this.shownManagementOptions) {
this.closeManagementOptions();
}
this.buildingInCategoryButtonsCol = null;
this.buildingInCategoryButtonsColAmount = 0;
this.buildingInCategoryButtonsNumberOfCols = 0;
this.buttonsInCategory = new haxe_ds_StringMap();
if(destroyBuilder && this.city.builder != null) {
this.city.builder.cancel();
}
if(this.shownCategory == category && !neverHide) {
this.shownCategory = "";
} else {
this.shownCategory = category;
if(atWidth != null && !this.gui.game.isMobile) {
this.buildingInCategoryButtons.padding.left = atWidth;
}
var _g = 0;
var _g1 = this.city.progress.resources.buildingInfoArray;
while(_g < _g1.length) {
var building = _g1[_g];
++_g;
var name = "buildings." + building.className;
var classToBuild = $hxClasses[name];
var unlockState = this.city.progress.unlocks.getUnlockState(classToBuild);
var notificationState = this.city.progress.unlocks.getShouldNotifyForUnlock(classToBuild);
if(building.category == category && (unlockState == progress_UnlockState.Unlocked || unlockState == progress_UnlockState.Researched || unlockState == progress_UnlockState.Createable)) {
this.addBuildingButton(classToBuild,unlockState,notificationState);
}
}
var _g = 0;
var _g1 = Resources.decorationsInfo;
while(_g < _g1.length) {
var decoration = _g1[_g];
++_g;
if(decoration.category == category) {
this.addDecorationButton(decoration);
}
}
var _g = 0;
var _g1 = Resources.worldResourcesInfo;
while(_g < _g1.length) {
var worldInfo = _g1[_g];
++_g;
if(worldInfo.category == category) {
this.addWorldResourceButton(worldInfo);
}
}
var val2 = this.buildingInCategoryButtons.padding.left;
this.buildingInCategoryButtons.padding.left = val2 > 0 ? val2 : 0;
this.buildingInCategoryButtons.updateSize();
}
}
,refreshCategoryBuildingsShown: function() {
this.buildingButtons.destroy();
this.allBuildingModeButtons.destroy();
this.allManagementOptionsButtons.destroy();
this.buttonsByCategory = new haxe_ds_StringMap();
this.createBuildingButtons();
if(this.shownCategory != "") {
this.showOrHideBuildingsOfCategory(this.shownCategory,this.categoryButtonPosition.h[this.shownCategory],true,false,true);
}
this.updateGoalAttentions();
}
,makeSpaceForBuildingButton: function() {
var tooManyBuildingsInCol;
if(this.gui.game.isMobile) {
var val2 = (this.gui.game.rect.width - 40) / 20 | 0;
tooManyBuildingsInCol = this.buildingInCategoryButtonsColAmount >= (val2 > 2 ? val2 : 2);
} else {
var val2 = (this.gui.game.rect.height - 60) / 20 | 0;
tooManyBuildingsInCol = this.buildingInCategoryButtonsColAmount >= (val2 > 2 ? val2 : 2);
}
if(this.buildingInCategoryButtonsCol == null || tooManyBuildingsInCol) {
this.buildingInCategoryButtonsColAmount = 0;
this.buildingInCategoryButtonsCol = new gui_GUIContainer(this.gui,this.gui.stage,this.buildingInCategoryButtons);
if(this.gui.game.isMobile) {
this.buildingInCategoryButtonsCol.direction = gui_GUIContainerDirection.Horizontal;
this.buildingInCategoryButtonsCol.alignment = gui_GUIContainerAlignment.LeftOrTop;
this.buildingInCategoryButtons.insertChild(this.buildingInCategoryButtonsCol,0);
} else {
this.buildingInCategoryButtonsCol.direction = gui_GUIContainerDirection.Vertical;
this.buildingInCategoryButtonsCol.alignment = gui_GUIContainerAlignment.LeftOrTop;
this.buildingInCategoryButtons.addChild(this.buildingInCategoryButtonsCol);
}
this.buildingInCategoryButtonsNumberOfCols += 1;
}
this.buildingInCategoryButtonsColAmount += 1;
}
,addBuildingButton: function(buildingType,unlockState,notificationState) {
var _gthis = this;
this.makeSpaceForBuildingButton();
var sprName = Reflect.field(buildingType,"spriteName");
var typeClassName = buildingType.__name__;
var buildingInfo = this.city.progress.resources.buildingInfo.h[typeClassName];
var buildingButton;
var buildingNeedsUnlock = buildingInfo.showUnlockHint != null && unlockState == progress_UnlockState.Unlocked;
buildingButton = new gui_ImageButton(this.gui,this.gui.stage,this.buildingInCategoryButtonsCol,function() {
if(_gthis.gui.game.isMobile) {
_gthis.closeExtraBuildingModes();
}
if(buildingNeedsUnlock) {
if(_gthis.city.builder != null) {
_gthis.city.builder.cancel();
}
_gthis.gui.showSimpleWindow(buildingInfo.showUnlockHint,"",true,true);
return;
}
if(_gthis.gui.get_keyboard().down[17]) {
var foundBuilding = null;
var leastUpgrades = 10000;
var _g = 0;
var _g1 = _gthis.city.permanents;
while(_g < _g1.length) {
var pm = _g1[_g];
++_g;
if(pm.isBuilding) {
var thisBuilding = pm;
if(thisBuilding.is(buildingType)) {
if(thisBuilding.upgrades.length < leastUpgrades) {
leastUpgrades = thisBuilding.upgrades.length;
foundBuilding = thisBuilding;
}
}
}
}
if(foundBuilding == null) {
_gthis.city.createOrRemoveBuilder(buildingType);
} else {
foundBuilding.showWindow();
}
} else {
_gthis.city.createOrRemoveBuilder(buildingType);
}
},Resources.getTexture(buildingNeedsUnlock ? "spr_lockedbuilding@0,0,20,20" : "" + sprName + "@0,0,20,20"),function() {
if(_gthis.city.builder != null) {
return _gthis.city.builder.get_buildingToBuild() == buildingType;
} else {
return false;
}
},function() {
if(buildingNeedsUnlock) {
_gthis.gui.tooltip.setText(buildingButton,buildingInfo.showUnlockHint);
return;
}
if(!_gthis.gui.get_keyboard().down[17]) {
_gthis.showBuildingTooltip(buildingInfo,buildingType,buildingButton);
} else {
var highlightTextures = Resources.getTexturesByWidth("spr_hoverhint",22);
_gthis.city.setHoverHightlight(function(pm) {
if(pm.is(buildingType)) {
var thisBuilding = pm;
var anyUpgrade = false;
var _g = 0;
var _g1 = thisBuilding.get_possibleUpgrades();
while(_g < _g1.length) {
var ug = [_g1[_g]];
++_g;
if(_gthis.city.progress.unlocks.getUnlockState(ug[0]) == progress_UnlockState.Locked) {
continue;
}
var this1 = Resources.buildingUpgradesInfo;
var key = ug[0].__name__;
var info = this1.h[key];
var materialsToPay = Materials.fromBuildingUpgradesInfo(info);
if(!common_ArrayExtensions.any(thisBuilding.upgrades,(function(ug) {
return function(bu) {
return js_Boot.getClass(bu) == ug[0];
};
})(ug))) {
anyUpgrade = true;
if(_gthis.city.materials.canAfford(materialsToPay)) {
return highlightTextures[2];
}
}
}
var _g = 0;
var _g1 = thisBuilding.get_possibleCityUpgrades();
while(_g < _g1.length) {
var cu = [_g1[_g]];
++_g;
if(_gthis.city.progress.unlocks.getUnlockState(cu[0]) == progress_UnlockState.Locked) {
continue;
}
var this1 = Resources.cityUpgradesInfo;
var key = cu[0].__name__;
var info = this1.h[key];
var materialsToPay = Materials.fromCityUpgradesInfo(info);
if(!common_ArrayExtensions.any(_gthis.city.upgrades.upgrades,(function(cu) {
return function(thisCU) {
return js_Boot.getClass(thisCU) == cu[0];
};
})(cu))) {
anyUpgrade = true;
if(_gthis.city.materials.canAfford(materialsToPay)) {
return highlightTextures[2];
}
}
}
if(anyUpgrade) {
return highlightTextures[1];
} else {
return highlightTextures[0];
}
}
_gthis.city.progress.resetCtrlToHightlightHint();
return null;
},6735360);
}
},Resources.getTexture(buildingNeedsUnlock ? "spr_lockedbuilding@22,0,20,20" : buildingInfo.buttonBack == null ? "" + sprName + "@44,0,20,20" : buildingInfo.buttonBack));
if(notificationState) {
var _g = ($_=this.city.progress.unlocks,$bind($_,$_.stopNotifyForUnlock));
var element = buildingType;
var tmp = function() {
_g(element);
};
buildingButton.notify(true,tmp);
}
this.buttonsInCategory.h[typeClassName] = buildingButton;
if(this.gui.game.isMobile) {
this.buildingInCategoryButtonsCol.addChild(buildingButton);
} else {
this.buildingInCategoryButtonsCol.insertChild(buildingButton,0);
}
}
,showBuildingTooltip: function(buildingInfo,buildingType,tooltipContext,continousDisplay) {
if(continousDisplay == null) {
continousDisplay = false;
}
var cost = this.city.progress.buildingCost.getBuildingCost(buildingInfo);
if(this.city.progress.unlocks.getUnlockState(buildingType) == progress_UnlockState.Researched) {
cost.knowledge = 0;
}
var extraInfo = [];
var extraInfo2;
if(buildingInfo.tooltipBottomIconInfo != null) {
var _this = buildingInfo.tooltipBottomIconInfo;
var result = new Array(_this.length);
var _g = 0;
var _g1 = _this.length;
while(_g < _g1) {
var i = _g++;
var ei = _this[i];
result[i] = { text : ei.text, texture : Resources.getTexture(ei.texture)};
}
extraInfo2 = result;
} else {
extraInfo2 = [];
}
if(buildingInfo.jobs != null && buildingInfo.jobs != 0) {
extraInfo.push({ texture : Resources.getTexture("spr_work"), text : buildingInfo.jobs == null ? "null" : "" + buildingInfo.jobs});
}
if(buildingInfo.residents != null && buildingInfo.residents != 0) {
extraInfo.push({ texture : Resources.getTexture("spr_residents"), text : buildingInfo.residents == null ? "null" : "" + buildingInfo.residents});
}
if(buildingInfo.quality != null && buildingInfo.quality != 0) {
extraInfo.push({ texture : Resources.getTexture("spr_happiness"), text : buildingInfo.quality == null ? "null" : "" + buildingInfo.quality});
}
if(buildingInfo.specialInfo.indexOf("unique") != -1) {
extraInfo.push({ texture : Resources.getTexture("spr_uniquebuilding"), text : common_ArrayExtensions.any(this.city.permanents,function(pm) {
return pm.is(buildingType);
}) ? "[red]Already Built" : "Unique"});
}
var buildingDescription = buildingInfo.description;
if(common_ArrayExtensions.any(this.city.permanents,function(pm) {
return pm.is(buildingType);
})) {
buildingDescription = StringTools.replace(buildingDescription,"!unlocks","");
} else {
buildingDescription = StringTools.replace(buildingDescription,"!unlocks"," Also unlocks new buildings.");
}
if(this.city.progress.shouldShowHoldCtrlToHighlightHint()) {
buildingDescription += "\n\nTip: Hold Ctrl to highlight all buildings of this type!";
}
buildingDescription += this.city.progress.buildingCost.getBuildingCostDescriptionAdder(buildingInfo);
if(continousDisplay) {
this.gui.tooltip.setTextForContinuous(buildingDescription,"Building " + buildingInfo.name + "",cost,extraInfo,extraInfo2);
} else {
this.gui.tooltip.setText(tooltipContext,buildingDescription,buildingInfo.name,cost,extraInfo,extraInfo2);
}
}
,addDecorationButton: function(decorationsInfo) {
var _gthis = this;
this.makeSpaceForBuildingButton();
var decorationButton;
var _g = ($_=this.city,$bind($_,$_.createOrRemoveDecorationBuilder));
var decorationInfo = decorationsInfo;
var value = function() {
_g(decorationInfo);
};
decorationButton = new gui_ImageButton(this.gui,this.gui.stage,this.buildingInCategoryButtonsCol,value,Resources.getTexture("" + decorationsInfo.textureName + "@0,0,20,20"),function() {
if(_gthis.city.builder != null) {
var _g = _gthis.city.builder.builderType;
var value;
if(_g._hx_index == 1) {
var d = _g.decorationInfo;
value = d.name;
} else {
value = "";
}
return value == decorationsInfo.name;
} else {
return false;
}
},function() {
_gthis.showDecorationTooltip(decorationsInfo,decorationButton);
});
if(this.gui.game.isMobile) {
this.buildingInCategoryButtonsCol.addChild(decorationButton);
} else {
this.buildingInCategoryButtonsCol.insertChild(decorationButton,0);
}
}
,showDecorationTooltip: function(decorationsInfo,target,continousDisplay) {
if(continousDisplay == null) {
continousDisplay = false;
}
var cost = Materials.fromDecorationInfo(decorationsInfo);
if(continousDisplay) {
if(decorationsInfo.name == "Remove Decoration") {
this.gui.tooltip.setTextForContinuous(decorationsInfo.description,decorationsInfo.name + "",cost);
} else {
this.gui.tooltip.setTextForContinuous(decorationsInfo.description,"Placing " + decorationsInfo.name + "",cost);
}
} else {
this.gui.tooltip.setText(target,decorationsInfo.description,decorationsInfo.name,cost);
}
}
,addWorldResourceButton: function(worldResourceInfo) {
var _gthis = this;
this.makeSpaceForBuildingButton();
var worldResourceButton;
var _g = ($_=this.city,$bind($_,$_.createOrRemoveWorldResourceBuilder));
var resourceInfo = worldResourceInfo;
var value = function() {
_g(resourceInfo);
};
worldResourceButton = new gui_ImageButton(this.gui,this.gui.stage,this.buildingInCategoryButtonsCol,value,Resources.getTexture("" + worldResourceInfo.textureName),function() {
if(_gthis.city.builder != null) {
var _g = _gthis.city.builder.builderType;
var value;
if(_g._hx_index == 2) {
var d = _g.resourceInfo;
value = d;
} else {
value = null;
}
return value == worldResourceInfo;
} else {
return false;
}
},function() {
_gthis.showWorldResourceTooltip(worldResourceInfo,worldResourceButton);
});
if(this.gui.game.isMobile) {
this.buildingInCategoryButtonsCol.addChild(worldResourceButton);
} else {
this.buildingInCategoryButtonsCol.insertChild(worldResourceButton,0);
}
}
,showWorldResourceTooltip: function(worldResourceInfo,target,continousDisplay) {
if(continousDisplay == null) {
continousDisplay = false;
}
var cost = Materials.fromWorldResourceInfo(worldResourceInfo);
if(continousDisplay) {
this.gui.tooltip.setTextForContinuous(worldResourceInfo.description,"Planting " + worldResourceInfo.name + "",cost);
} else {
this.gui.tooltip.setText(target,worldResourceInfo.description,worldResourceInfo.name,cost);
}
}
,addBuildingModeButtons: function() {
var _gthis = this;
var buildingModeButton;
var getBuildingModeTexture = function(buildingMode) {
switch(buildingMode._hx_index) {
case 0:
return "spr_icon_buildingmode_ontop";
case 1:
return "spr_icon_buildingmode_insert";
case 2:
return "spr_icon_buildingmode_replace";
case 3:
return "spr_icon_buildingmode_drag";
case 4:
return "spr_icon_buildingmode_destroy";
}
};
var showTooltipForBuildingMode = function(target,buildingMode,asContinuous) {
var doTooltipSet = function(target,text,title) {
if(asContinuous) {
_gthis.gui.tooltip.setTextForContinuous(text,title);
} else {
_gthis.gui.tooltip.setText(target,text,title);
}
};
if(_gthis.gui.game.isMobile) {
switch(buildingMode._hx_index) {
case 0:
doTooltipSet(target,"Build only on the ground and on top of buildings, or just below rooftop buildings. Tap on a building for information and options.","Building mode: Normal");
break;
case 1:
doTooltipSet(target,"Build anywhere in a tower.","Building mode: Insert");
break;
case 2:
doTooltipSet(target,"Easily replace existing buildings.","Building mode: Replace");
break;
case 3:
doTooltipSet(target,"Drag to quickly build multiple buildings of the same type.","Building mode: Multi");
break;
case 4:
doTooltipSet(target,"Quickly destroy buildings.","Destroy Mode");
break;
}
return;
}
switch(buildingMode._hx_index) {
case 0:
doTooltipSet(target,"With this building mode active, you can only build on the ground and on top of buildings. Click on a building for information and options. Exception:" + (_gthis.city.builder == null ? " if you have a building type selected," : "") + " clicking on a rooftop building will build a building there.","Building mode: Normal");
break;
case 1:
doTooltipSet(target,"With this building mode active, you can build anywhere in a tower. " + (_gthis.city.builder == null ? "After having selected a building to build, click" : "Click") + " on a building to insert a new building there.","Building mode: Insert");
break;
case 2:
doTooltipSet(target,"With this building mode active, you can easily replace existing buildings.","Building mode: Replace");
break;
case 3:
doTooltipSet(target,"With this building mode active, you can drag to quickly build multiple buildings of the same type.","Building mode: Multi");
break;
case 4:
doTooltipSet(target,"Quickly destroy buildings.","Destroy Mode");
break;
}
};
var showExtraBuildingModes = function() {
var allBuildingModes = [BuildingMode.Normal,BuildingMode.Insert,BuildingMode.Replace,BuildingMode.Destroy];
var _g = 0;
while(_g < allBuildingModes.length) {
var bm = [allBuildingModes[_g]];
++_g;
var imgButton = [];
imgButton[0] = new gui_ImageButton(_gthis.gui,_gthis.gui.stage,_gthis.allBuildingModeButtons,(function(bm) {
return function() {
_gthis.city.buildingMode = bm[0];
if(_gthis.gui.game.isMobile && _gthis.city.builder != null) {
_gthis.city.builder.invalidateCache();
}
if(bm[0] != BuildingMode.Destroy) {
if(!_gthis.gui.game.isMobile || _gthis.shownCategory != "") {
if(_gthis.gui.game.isMobile) {
var value;
switch(bm[0]._hx_index) {
case 0:
value = "Build only on the ground and on top of buildings, or just below rooftop buildings. Tap on a building for information and options.";
break;
case 1:
value = "Build anywhere in a tower.";
break;
case 2:
value = "Easily replace existing buildings.";
break;
case 3:
value = "Drag to quickly build multiple buildings of the same type.";
break;
case 4:
value = "Quickly destroy buildings.";
break;
}
var value1;
switch(bm[0]._hx_index) {
case 0:
value1 = "Building mode: Normal";
break;
case 1:
value1 = "Building mode: Insert";
break;
case 2:
value1 = "Building mode: Replace";
break;
case 3:
value1 = "Building mode: Multi";
break;
default:
value1 = "";
}
_gthis.gui.notify(value,value1,120);
}
_gthis.closeExtraBuildingModes();
}
} else {
if(_gthis.gui.game.isMobile) {
_gthis.allBuildingModeButtons.padding.bottom = 0;
_gthis.allBuildingModeButtons.updateSize();
}
_gthis.showOrHideBuildingsOfCategory(_gthis.shownCategory,_gthis.categoryButtonPosition.h[_gthis.shownCategory],false,true,true);
}
};
})(bm),Resources.getTexture(getBuildingModeTexture(bm[0])),(function(bm) {
return function() {
return _gthis.city.buildingMode == bm[0];
};
})(bm),(function(imgButton,bm) {
return function() {
showTooltipForBuildingMode(imgButton[0],bm[0],false);
};
})(imgButton,bm));
if(_gthis.gui.game.isMobile) {
_gthis.allBuildingModeButtons.addChild(imgButton[0]);
} else {
_gthis.allBuildingModeButtons.insertChild(imgButton[0],0);
}
}
if(_gthis.gui.game.isMobile) {
_gthis.allBuildingModeButtons.padding.bottom = _gthis.shownCategory != "" ? _gthis.buildingInCategoryButtons.baseHeight : 0;
_gthis.allBuildingModeButtons.updateSize();
}
if(_gthis.gui.game.isMobile && _gthis.shownManagementOptions) {
_gthis.closeManagementOptions();
}
};
var toggleMoreBuildingModesMenu = function() {
var maxPos = 0;
var pos = haxe_ds_StringMap.valueIterator(_gthis.categoryButtonPosition.h);
while(pos.hasNext()) {
var pos1 = pos.next();
maxPos = pos1 + 20 + 2;
}
if(_gthis.shownBuildingModes) {
_gthis.closeExtraBuildingModes();
} else {
showExtraBuildingModes();
_gthis.shownBuildingModes = true;
}
};
if(!this.gui.game.isMobile) {
this.allBuildingModeButtons.padding.left = this.categoryButtons.rect.width;
}
buildingModeButton = new gui_ImageButton(this.gui,this.gui.stage,this.categoryButtons,function() {
if(_gthis.gui.game.isMobile) {
toggleMoreBuildingModesMenu();
} else {
_gthis.city.buildingMode = _gthis.city.buildingMode == BuildingMode.Normal ? BuildingMode.Insert : BuildingMode.Normal;
_gthis.closeExtraBuildingModes();
}
},Resources.getTexture(getBuildingModeTexture(this.city.buildingMode)),function() {
if(!_gthis.gui.game.isMobile) {
return false;
}
return _gthis.shownBuildingModes;
},function() {
showTooltipForBuildingMode(buildingModeButton,_gthis.city.buildingMode,false);
},null,"spr_transparentbutton");
var currentlyShownBuildingMode = BuildingMode.Normal;
buildingModeButton.onUpdate = function() {
if(currentlyShownBuildingMode != _gthis.city.buildingMode) {
buildingModeButton.updateTexture(Resources.getTexture(getBuildingModeTexture(_gthis.city.buildingMode)));
currentlyShownBuildingMode = _gthis.city.buildingMode;
}
if(_gthis.gui.game.isMobile && _gthis.shownBuildingModes && _gthis.city.builder == null) {
showTooltipForBuildingMode(buildingModeButton,_gthis.city.buildingMode,true);
}
};
this.categoryButtons.addChild(buildingModeButton);
if(!this.gui.game.isMobile) {
var moreBuildingModesButton = new gui_ImageButton(this.gui,this.gui.stage,this.categoryButtons,toggleMoreBuildingModesMenu,Resources.getTexture("spr_morebuildingmodes_arrowup"),function() {
return _gthis.shownBuildingModes;
},function() {
_gthis.gui.tooltip.setText(moreBuildingModesButton,"All Building Modes");
},null,"spr_morebuildingmodebuttons");
this.categoryButtons.addChild(moreBuildingModesButton);
}
if(this.shownBuildingModes) {
showExtraBuildingModes();
}
}
,closeExtraBuildingModes: function() {
this.allBuildingModeButtons.clear();
this.shownBuildingModes = false;
if(this.city.buildingMode == BuildingMode.Destroy) {
this.city.buildingMode = BuildingMode.Normal;
}
}
,showManagementOptions: function(parentElement) {
var _gthis = this;
if(parentElement == null) {
parentElement = this.allManagementOptionsButtons;
}
if(this.gui.game.isMobile && this.shownBuildingModes) {
this.closeExtraBuildingModes();
}
var imgButton = new gui_ImageButton(this.gui,this.gui.stage,parentElement,function() {
if(_gthis.city.viewActions.isFollowOpen()) {
_gthis.city.specialAction.deactivate();
} else {
_gthis.city.viewActions.showFollow();
}
},Resources.getTexture("spr_icon_followcitizen"),function() {
return _gthis.city.viewActions.isFollowOpen();
},function() {
_gthis.gui.tooltip.setText(imgButton,"Follow Citizen");
});
if(this.gui.game.isMobile) {
parentElement.addChild(imgButton);
} else {
parentElement.insertChild(imgButton,0);
}
var imgButton1 = new gui_ImageButton(this.gui,this.gui.stage,parentElement,function() {
if(_gthis.gui.windowRelatedTo == "global_upgrades") {
_gthis.gui.closeWindow();
} else {
_gthis.gui.createWindow("global_upgrades");
gui_GlobalUpgradeWindow.create(_gthis.city,_gthis.gui,_gthis.gui.innerWindowStage,_gthis.gui.windowInner);
}
},Resources.getTexture("spr_icon_upgrade"),function() {
return _gthis.gui.windowRelatedTo == "global_upgrades";
},function() {
_gthis.gui.tooltip.setText(imgButton1,"Upgrades and Policies");
});
if(this.gui.game.isMobile) {
parentElement.addChild(imgButton1);
} else {
parentElement.insertChild(imgButton1,0);
}
}
,closeManagementOptions: function() {
this.allManagementOptionsButtons.clear();
this.shownManagementOptions = false;
}
,addManagementButtons: function() {
var _gthis = this;
var managementButton = new gui_ImageButton(this.gui,this.gui.stage,this.categoryButtons,function() {
_gthis.shownManagementOptions = !_gthis.shownManagementOptions;
if(!_gthis.shownManagementOptions) {
_gthis.closeManagementOptions();
} else {
_gthis.showManagementOptions();
}
},Resources.getTexture("spr_icon_management"),function() {
return _gthis.shownManagementOptions;
},function() {
_gthis.gui.tooltip.setText(managementButton,"Management");
},null,"spr_transparentbutton");
if(!this.gui.game.isMobile) {
this.allManagementOptionsButtons.padding.left = this.categoryButtons.rect.width;
}
this.categoryButtons.addChild(managementButton);
if(this.shownManagementOptions) {
this.showManagementOptions();
}
}
,updateGoalAttentions: function() {
var _gthis = this;
var updateHighlight = function(thingThatNeedsAttention,needsHighlight) {
var thingClassName = thingThatNeedsAttention.__name__;
var thingBuildingInfo = Resources.buildingInfo.h[thingClassName];
if(thingBuildingInfo != null && (!needsHighlight || _gthis.city.materials.canAfford(Materials.fromBuildingInfo(thingBuildingInfo)))) {
var cat = thingBuildingInfo.category;
var catButton;
if(_gthis.activateBuildModeButton != null) {
_gthis.activateBuildModeButton.setNeedsAttention(needsHighlight);
}
var updateHighlight;
if(cat != null && cat != "") {
catButton = _gthis.buttonsByCategory.h[cat];
updateHighlight = catButton != null;
} else {
updateHighlight = false;
}
if(updateHighlight) {
catButton.setNeedsAttention(needsHighlight);
var bldButton = _gthis.buttonsInCategory.h[thingClassName];
if(bldButton != null) {
bldButton.setNeedsAttention(needsHighlight);
}
}
}
var thingBuildingUpgradeInfo = Resources.buildingUpgradesInfo.h[thingClassName];
if(thingBuildingUpgradeInfo != null && (!needsHighlight || _gthis.city.materials.canAfford(Materials.fromBuildingUpgradesInfo(thingBuildingUpgradeInfo)))) {
var stillNeedsToOpenRightWindow = true;
if(_gthis.gui.window != null && ((_gthis.gui.windowRelatedTo) instanceof Building)) {
var bld = _gthis.gui.windowRelatedTo;
if(bld.get_possibleUpgrades().indexOf(thingThatNeedsAttention) != -1 && !common_ArrayExtensions.any(bld.upgrades,function(bu) {
return js_Boot.getClass(bu) == thingThatNeedsAttention;
})) {
var upgradeButton = _gthis.gui.currentUpgradeButtons.h[thingClassName];
if(upgradeButton != null) {
upgradeButton.setNeedsAttention(needsHighlight);
}
stillNeedsToOpenRightWindow = false;
}
}
if(stillNeedsToOpenRightWindow || !needsHighlight) {
var _g = 0;
var _g1 = _gthis.city.permanents;
while(_g < _g1.length) {
var pm = _g1[_g];
++_g;
if(pm.is(Building)) {
var bld = pm;
if(bld.get_possibleUpgrades().indexOf(thingThatNeedsAttention) != -1 && !common_ArrayExtensions.any(bld.upgrades,function(bu) {
return js_Boot.getClass(bu) == thingThatNeedsAttention;
})) {
if(needsHighlight) {
if(bld.highlightSprite == null) {
bld.highlightSprite = new PIXI.Sprite(Resources.getTexture("spr_whiteoutline"));
bld.highlightSprite.position.set(bld.position.x - 1,bld.position.y - 1);
_gthis.city.farForegroundStage.addChild(bld.highlightSprite);
var this1 = [89,1,0.77];
var updateHighlight = thx_color_Hsv.toRgb(this1);
bld.highlightSprite.tint = common_ColorExtensions.toHexInt(updateHighlight);
}
bld.highlightSprite.alpha = (Math.sin(_gthis.gui.guiTimer / 10) + 1) / 2;
} else if(bld.highlightSprite != null) {
bld.highlightSprite.destroy();
bld.highlightSprite = null;
}
}
}
}
}
}
};
var thingsThatNeedAttention = this.city.progress.story.getDesiredGoalHighlights();
if(this.creatableCityElementsThatNeededAttention != null && this.creatableCityElementsThatNeededAttention.length > 0) {
var _g = 0;
var _g1 = this.creatableCityElementsThatNeededAttention;
while(_g < _g1.length) {
var thingThatNeededAttention = _g1[_g];
++_g;
updateHighlight(thingThatNeededAttention,false);
}
}
var _g = 0;
while(_g < thingsThatNeedAttention.length) {
var thingThatNeedsAttention = thingsThatNeedAttention[_g];
++_g;
updateHighlight(thingThatNeedsAttention,true);
}
this.creatableCityElementsThatNeededAttention = thingsThatNeedAttention;
}
,__class__: gui_BuildingButtons
};
var gui_BuildingTypeImage = function() { };
$hxClasses["gui.BuildingTypeImage"] = gui_BuildingTypeImage;
gui_BuildingTypeImage.__name__ = "gui.BuildingTypeImage";
gui_BuildingTypeImage.create = function(stage,city,buildingType,parentContainer,gui) {
var cont = new PIXI.Container();
var sprName = Reflect.field(buildingType,"spriteName");
var this1 = city.progress.resources.buildingInfo;
var key = buildingType.__name__;
var buildingInfo = this1.h[key];
cont.addChild(Resources.makeSprite(buildingInfo.buttonBack == null ? "" + sprName + "@44,0,20,20" : buildingInfo.buttonBack));
cont.addChild(Resources.makeSprite("" + sprName + "@0,0,20,20"));
var ch = null;
ch = new gui_ContainerHolder(parentContainer,stage,cont,null,null,function(mouse) {
if(ch.rect.contains(mouse.position)) {
gui.tooltip.setText(ch,buildingInfo.name);
return true;
}
return false;
});
return ch;
};
var gui_Button = function(gui,stage,parent,action,isActive,onHover) {
this.keyboardButton = null;
this.canBeHeld = false;
this.mouseOut = false;
this.onUpdate = null;
this.stage = stage;
this.gui = gui;
this.parent = parent;
this.action = action;
this.onHover = onHover;
if(isActive == null) {
isActive = function() {
return false;
};
}
this.isActive = isActive;
this.buttonSound = Audio.get().buttonSound;
};
$hxClasses["gui.Button"] = gui_Button;
gui_Button.__name__ = "gui.Button";
gui_Button.__interfaces__ = [gui_IGUIElement];
gui_Button.prototype = {
updateSize: function() {
if(this.parent != null) {
this.parent.updateSize();
}
}
,updatePosition: function(newPosition) {
this.rect.x = newPosition.x;
this.rect.y = newPosition.y;
}
,handleMouse: function(mouse) {
return this.doHandleMouse(mouse,function() {
},function() {
});
}
,doHandleMouse: function(mouse,onMouseIn,onMouseActive) {
if(this.rect.contains(mouse.position)) {
this.mouseOut = false;
var claim = mouse.claimMouse(this,null,true,this.canBeHeld);
if(claim == MouseState.Confirmed) {
this.action();
if(this.buttonSound != null) {
Audio.get().playSound(this.buttonSound);
}
} else if(claim == MouseState.Active) {
onMouseActive();
} else {
onMouseIn();
}
if(this.onHover != null) {
this.onHover();
}
return true;
}
return false;
}
,update: function() {
if(this.onUpdate != null) {
this.onUpdate();
}
if(this.keyboardButton != null) {
if(this.gui.get_keyboard().pressed[this.keyboardButton]) {
this.action();
}
}
this.mouseOut = true;
}
,destroy: function() {
}
,__class__: gui_Button
};
var gui_ChangeCityNameWindow = function() { };
$hxClasses["gui.ChangeCityNameWindow"] = gui_ChangeCityNameWindow;
gui_ChangeCityNameWindow.__name__ = "gui.ChangeCityNameWindow";
gui_ChangeCityNameWindow.createWindow = function(city) {
city.gui.createWindow("changeCityNameWindow");
var city1 = city;
var tmp = function() {
gui_ChangeCityNameWindow.createWindow(city1);
};
city.gui.addWindowToStack(tmp);
gui_ChangeCityNameWindow.create(city,city.gui,city.gui.innerWindowStage,city.gui.windowInner);
};
gui_ChangeCityNameWindow.create = function(city,gui,stage,thisWindow) {
gui.windowAddTitleText("Change City Name");
thisWindow.addChild(new gui_TextElement(thisWindow,stage,"Give your city a name!"));
thisWindow.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,4)));
var handleInput = function(input) {
if(input == null) {
return false;
}
city.cityName = buildings_CityHall.sanitizeCityName(input);
return true;
};
var textInput = new gui_TextInput(gui.windowInner,gui,city.game,"City name",city.cityName);
thisWindow.addChild(textInput);
textInput.onInput = handleInput;
thisWindow.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,4)));
gui.windowAddBottomButtons();
};
var gui_CheckboxButton = function(gui,stage,parent,action,isChecked,isActive,onHover,buttonSpriteName,buttonSpriteNameChecked) {
if(buttonSpriteNameChecked == null) {
buttonSpriteNameChecked = "spr_button_checked";
}
if(buttonSpriteName == null) {
buttonSpriteName = "spr_button";
}
gui_Button.call(this,gui,stage,parent,action,isActive);
var buttonTextures = Resources.getTextures(buttonSpriteName,3);
var buttonTexturesChecked = Resources.getTextures(buttonSpriteNameChecked,3);
this.buttonPatch = new gui_NinePatch(buttonTextures[0],2,20,20);
this.buttonPatch.texture = buttonTextures[1];
this.buttonPatch.updateTextures(false);
this.buttonPatch.texture = buttonTextures[2];
this.buttonPatch.updateTextures(false);
this.buttonPatch.texture = buttonTexturesChecked[0];
this.buttonPatch.updateTextures(false);
this.buttonPatch.texture = buttonTexturesChecked[1];
this.buttonPatch.updateTextures(false);
this.buttonPatch.texture = buttonTexturesChecked[2];
this.buttonPatch.updateTextures(false);
this.buttonPatch.setTextureSet(0);
stage.addChild(this.buttonPatch);
this.container = new gui_GUIContainer(gui,stage,this);
this.rect = new common_Rectangle(0,0,2,2);
this.isChecked = isChecked;
};
$hxClasses["gui.CheckboxButton"] = gui_CheckboxButton;
gui_CheckboxButton.__name__ = "gui.CheckboxButton";
gui_CheckboxButton.__super__ = gui_Button;
gui_CheckboxButton.prototype = $extend(gui_Button.prototype,{
updatePosition: function(newPosition) {
gui_Button.prototype.updatePosition.call(this,newPosition);
this.buttonPatch.position.set(newPosition.x,newPosition.y);
this.buttonPatch.updateSprites();
this.container.updatePosition(newPosition);
}
,updateSize: function() {
if(this.container != null) {
this.rect.width = this.container.rect.width;
this.rect.height = this.container.rect.height;
this.updateSizeDisplay();
if(this.parent != null) {
this.parent.updateSize();
}
this.container.minWidth = this.container.baseWidth;
}
}
,updateSizeDisplay: function() {
if(this.container != null) {
this.buttonPatch.npWidth = this.rect.width;
this.buttonPatch.npHeight = this.rect.height;
this.buttonPatch.updateSprites();
}
}
,handleMouse: function(mouse) {
var _gthis = this;
var checked = this.isChecked();
return gui_Button.prototype.doHandleMouse.call(this,mouse,function() {
_gthis.buttonPatch.setTextureSet(checked ? 4 : 1);
},function() {
_gthis.buttonPatch.setTextureSet(checked ? 5 : 2);
});
}
,update: function() {
this.container.update();
if(this.mouseOut) {
this.buttonPatch.setTextureSet(this.isChecked() ? 3 : 0);
}
if(this.isActive()) {
this.buttonPatch.setTextureSet(this.isChecked() ? 5 : 2);
}
gui_Button.prototype.update.call(this);
}
,destroy: function() {
gui_Button.prototype.destroy.call(this);
this.container.destroy();
this.stage.removeChild(this.buttonPatch);
}
,__class__: gui_CheckboxButton
});
var gui_CityGUI = function(game,outerStage,city) {
this.gameSpeedOnUse = null;
this.storyHelpButtonOnUse = null;
this.hideShowUIButton = null;
this.cityExtraInfoHidden = false;
this.simulationSpeedChosen = 0;
this.workerAssignButton = null;
this.notificationPanel = null;
GUI.call(this,game,outerStage);
this.tooltip = new gui_Tooltip(game,city,this.tooltipStage);
this.city = city;
this.cityInfo = new gui_GUIContainer(this,this.stage,null,new common_Point(0,0),new common_FPoint(1,1));
this.currentUpgradeButtons = new haxe_ds_StringMap();
this.buildingButtons = new gui_BuildingButtons(this,city);
this.createCityInfo();
this.resize();
};
$hxClasses["gui.CityGUI"] = gui_CityGUI;
gui_CityGUI.__name__ = "gui.CityGUI";
gui_CityGUI.__super__ = GUI;
gui_CityGUI.prototype = $extend(GUI.prototype,{
createWindowInCurrentContext: function(relatedTo,windowBackground) {
GUI.prototype.createWindow.call(this,relatedTo,windowBackground);
}
,createWindow: function(relatedTo,windowBackground) {
GUI.prototype.createWindow.call(this,relatedTo,windowBackground);
}
,createCityInfo: function() {
this.addHelpAndGameSpeedButtons();
if(!this.cityExtraInfoHidden) {
this.addGeneralStatistics();
this.addAllMaterialsInfo();
}
}
,hideCityInfo: function() {
this.cityInfo.clear();
this.materialsInfo = null;
this.workerAssignButton = null;
this.hideShowUIButton = null;
this.woodAmountDisplay = null;
this.stoneAmountDisplay = null;
this.storyHelpButton = null;
}
,miniButtonToUse: function() {
if(this.game.isMobile) {
return "spr_transparentbutton_info_miniplus";
} else {
return "spr_transparentbutton_info_mini";
}
}
,addHelpAndGameSpeedButtons: function() {
var _gthis = this;
var quickControlButtons = new gui_GUIContainer(this,this.stage,this.cityInfo,null);
quickControlButtons.alignment = gui_GUIContainerAlignment.RightOrBottom;
this.cityInfo.addChild(quickControlButtons);
var hasQuickText = function() {
return _gthis.city.progress.goalHelp.hasCurrentGoalHelp();
};
var createQuickMissionWindow = null;
createQuickMissionWindow = function() {
if(_gthis.windowRelatedTo == "quickMissionWindow") {
_gthis.closeWindow();
} else if(hasQuickText()) {
_gthis.city.gui.clearWindowStack();
_gthis.city.gui.createWindow("quickMissionWindow");
_gthis.city.gui.addWindowToStack(createQuickMissionWindow);
if(_gthis.storyHelpButtonOnUse != null) {
_gthis.storyHelpButtonOnUse();
}
gui_CurrentMissionsWindow.create(_gthis.city,_gthis.city.gui,_gthis.city.gui.innerWindowStage,_gthis.city.gui.windowInner);
}
};
this.storyHelpButton = new gui_ImageButton(this,this.stage,quickControlButtons,createQuickMissionWindow,Resources.getTexture("spr_icon_help"),function() {
return _gthis.windowRelatedTo == "quickMissionWindow";
},function() {
if(hasQuickText()) {
var goalTexts = _gthis.city.progress.goalHelp.getCurrentGoalHelp();
if(goalTexts.length == 1) {
_gthis.tooltip.setText(_gthis.storyHelpButton,goalTexts[0].text,goalTexts[0].category == "Main Goal" ? "Current Task" : goalTexts[0].category);
} else {
var fullGoalTexts = "";
var _g = 0;
while(_g < goalTexts.length) {
var goalText = goalTexts[_g];
++_g;
if(fullGoalTexts != "") {
fullGoalTexts += "\n\n";
}
fullGoalTexts += "- " + goalText.category + "\n" + goalText.text;
}
_gthis.tooltip.setText(_gthis.storyHelpButton,fullGoalTexts,"Current Tasks");
}
}
if(_gthis.storyHelpButtonOnUse != null) {
_gthis.storyHelpButtonOnUse();
}
},null,this.miniButtonToUse(),this.game.isMobile ? 4 : 1);
this.storyHelpButton.onUpdate = function() {
if(hasQuickText()) {
_gthis.storyHelpButton.show();
} else {
_gthis.storyHelpButton.hide();
}
};
quickControlButtons.addChild(this.storyHelpButton);
var pausePlayButton = new gui_ImageButton(this,this.stage,quickControlButtons,function() {
_gthis.city.set_pauseGame(!_gthis.city.pauseGame);
if(_gthis.city.pauseGame) {
common_PokiHelpers.reportStopGameplay();
} else {
common_PokiHelpers.reportStartGameplay();
}
},Resources.getTexture("spr_icon_pause"),function() {
return _gthis.city.pauseGame;
},function() {
var theAction = _gthis.game.isMobile ? "Tap" : "Click (or press Space)";
if(_gthis.city.pauseGame) {
_gthis.tooltip.setText(pausePlayButton,theAction + " to unpause.","Game Paused");
} else {
_gthis.tooltip.setText(pausePlayButton,theAction + " to pause.","Game Running");
}
},null,this.miniButtonToUse(),this.game.isMobile ? 4 : 1);
quickControlButtons.addChild(pausePlayButton);
var simulationSpeeds = [{ speed : 1, icon : Resources.getTexture("spr_icon_play"), tooltipTitle : "Normal Speed"},{ speed : 1.5, icon : Resources.getTexture("spr_oneandhalfspeed"), tooltipTitle : "1.5x Speed"},{ speed : 2, icon : Resources.getTexture("spr_icon_speedup"), tooltipTitle : "Double Speed"},{ speed : 0.5, icon : Resources.getTexture("spr_icon_halfspeed"), tooltipTitle : "Half Speed"},{ speed : 0.75, icon : Resources.getTexture("spr_icon_slightlyslowerspeed"), tooltipTitle : "0.75x Speed"}];
if(Config.cheatSpeedEnabled) {
simulationSpeeds.push({ speed : 10, icon : Resources.getTexture("spr_icon_speedup"), tooltipTitle : "Cheat Speed"});
}
this.gameSpeedButton = new gui_ImageButton(this,this.stage,quickControlButtons,function() {
if(_gthis.game.keyboard.down[17]) {
if(_gthis.game.keyboard.down[16]) {
if(--_gthis.simulationSpeedChosen < 0) {
_gthis.simulationSpeedChosen = simulationSpeeds.length - 1;
}
} else if(++_gthis.simulationSpeedChosen >= simulationSpeeds.length) {
_gthis.simulationSpeedChosen = 0;
}
} else if(_gthis.simulationSpeedChosen > 1) {
_gthis.simulationSpeedChosen = 0;
} else {
_gthis.simulationSpeedChosen = 2;
}
_gthis.city.simulationSpeed = simulationSpeeds[_gthis.simulationSpeedChosen].speed;
_gthis.gameSpeedButton.imageSprite.texture = simulationSpeeds[_gthis.simulationSpeedChosen].icon;
if(!_gthis.game.keyboard.down[16]) {
_gthis.city.set_pauseGame(false);
common_PokiHelpers.reportStartGameplay();
}
if(_gthis.gameSpeedOnUse != null) {
_gthis.gameSpeedOnUse();
}
},common_ArrayExtensions.min(simulationSpeeds,function(spd) {
return Math.abs(spd.speed - _gthis.city.simulationSpeed);
}).icon,function() {
return false;
},function() {
_gthis.tooltip.setText(_gthis.gameSpeedButton,_gthis.game.isMobile ? "Tap to change the game speed." : "Click (or press S) to change the game speed.\nCtrl+Click to select an advanced speed." + (_gthis.city.pauseGame ? "\nShift to keep the game paused." : ""),simulationSpeeds[_gthis.simulationSpeedChosen].tooltipTitle);
if(_gthis.gameSpeedOnUse != null) {
_gthis.gameSpeedOnUse();
}
},null,this.miniButtonToUse(),this.game.isMobile ? 4 : 1);
this.gameSpeedButton.keyboardButton = Keyboard.getLetterCode("S");
quickControlButtons.addChild(this.gameSpeedButton);
var menuButton = new gui_ImageButton(this,this.stage,quickControlButtons,function() {
if(_gthis.windowRelatedTo == "gameMenu") {
_gthis.closeWindow();
} else {
gui_GameMenu.create(_gthis,_gthis.city);
}
},Resources.getTexture("spr_icon_menu"),function() {
return _gthis.windowRelatedTo == "gameMenu";
},function() {
_gthis.tooltip.setText(menuButton,"","Game Menu");
},null,this.miniButtonToUse(),this.game.isMobile ? 4 : 1);
menuButton.keyboardButton = Keyboard.getLetterCode("M");
quickControlButtons.addChild(menuButton);
if(this.game.isMobile) {
var hideShowTextures = Resources.getTexturesByWidth("spr_hideui",12);
this.hideShowUIButton = new gui_ImageButton(this,this.stage,quickControlButtons,function() {
if(_gthis.cityExtraInfoHidden) {
_gthis.addGeneralStatistics();
_gthis.addAllMaterialsInfo();
_gthis.cityExtraInfoHidden = false;
} else {
var i = _gthis.cityInfo.children.length - 1;
while(i >= 0) {
var child = _gthis.cityInfo.children[i];
if(child != quickControlButtons) {
_gthis.cityInfo.removeChild(child);
}
--i;
}
_gthis.materialsInfo = null;
_gthis.workerAssignButton = null;
_gthis.woodAmountDisplay = null;
_gthis.stoneAmountDisplay = null;
_gthis.cityExtraInfoHidden = true;
}
_gthis.hideShowUIButton.updateTexture(hideShowTextures[_gthis.cityExtraInfoHidden ? 0 : 1]);
},hideShowTextures[this.cityExtraInfoHidden ? 0 : 1],null,function() {
if(_gthis.cityExtraInfoHidden) {
_gthis.tooltip.setText(_gthis.hideShowUIButton,"Show extra city info & options.");
} else {
_gthis.tooltip.setText(_gthis.hideShowUIButton,"Hide extra city info & options.");
}
},null,this.miniButtonToUse(),this.game.isMobile ? 4 : 1);
quickControlButtons.addChild(this.hideShowUIButton);
}
}
,addGeneralStatistics: function() {
var _gthis = this;
var generalStatistics = new gui_GUIContainer(this,this.stage,this.cityInfo,null);
generalStatistics.alignment = gui_GUIContainerAlignment.RightOrBottom;
generalStatistics.direction = gui_GUIContainerDirection.Vertical;
this.cityInfo.addChild(generalStatistics);
var happiness = this.city.simulation.happiness;
var populationAndHappiness = new gui_GUIContainer(this,this.stage,generalStatistics);
populationAndHappiness.fillSecondarySize = true;
generalStatistics.addChild(populationAndHappiness);
var popInfoButton = this.createInfoButton(function() {
if(_gthis.windowRelatedTo == "popInfo") {
_gthis.closeWindow();
} else {
_gthis.createWindow("popInfo");
gui_PopulationInfoWindow.create(_gthis.city,_gthis,_gthis.innerWindowStage,_gthis.windowInner);
}
},function() {
var numberOfChildren = Lambda.count(_gthis.city.simulation.citizens,function(c) {
return c.get_age() <= 16;
});
_gthis.tooltip.setText("Population","The total amount of citizens in your city.\n" + ("There " + (numberOfChildren == 1 ? "is one child" : "are " + numberOfChildren + " children") + ".\n") + _gthis.game.textHelper.clickOrTap() + " for the age distribution" + (_gthis.city.simulation.citizens.length >= 1950 ? " or to change the population limit" : "") + "." + _gthis.game.textHelper.ifNotMobile("\n\nTip: to follow a citizen, Ctrl+Click on them."));
},function() {
return Std.string(_gthis.city.simulation.citizens.length | 0);
},"spr_population",populationAndHappiness,23,function() {
return _gthis.windowRelatedTo == "popInfo";
});
popInfoButton.keyboardButton = Keyboard.getLetterCode("C");
populationAndHappiness.addChild(popInfoButton);
var happinessBox = null;
happinessBox = this.createInfoButton(function() {
if(_gthis.windowRelatedTo == "happinessWindow") {
_gthis.closeWindow();
} else {
_gthis.createWindow("happinessWindow");
gui_HappinessWindow.create(_gthis.city,_gthis,_gthis.innerWindowStage,_gthis.windowInner);
}
},function() {
var enthusiasmPart = "";
var shortagePart = "";
var boostPart = "";
if(happiness.foodShortageUnhappiness > 0) {
shortagePart += "Food shortage unhappiness: -" + (happiness.foodShortageUnhappiness | 0) + "\n";
}
if(happiness.foodRationingUnhappiness > 0) {
shortagePart += "Food rationing unhappiness: -" + Math.ceil(happiness.foodRationingUnhappiness) + "\n";
}
if(happiness.overtimeUnhappinessShown > 0) {
shortagePart += "Mandatory overtime unhappiness: -" + Math.ceil(happiness.overtimeUnhappinessShown) + "\n";
}
if(happiness.enthusiasmHappiness != 0) {
enthusiasmPart += "New city enthusiasm bonus: +" + (happiness.enthusiasmHappiness | 0) + "\n";
}
var _g = 0;
var _g1 = happiness.happinessBoosts;
while(_g < _g1.length) {
var boost = _g1[_g];
++_g;
boostPart += boost.text + ": " + (boost.boost | 0) + "\n";
}
_gthis.tooltip.setText(happinessBox,"Happy citizens work faster. They also get more children.\n" + ("Home happiness: " + (happiness.homeHappiness | 0) + "\n") + ("Sense of purpose (job/school): " + (happiness.purposeHappiness | 0) + "\n") + ("Entertainment happiness: " + (happiness.entertainmentHappiness | 0) + "\n") + ("Education happiness: " + (happiness.schoolHappiness | 0) + "\n") + ("Medical happiness: " + (happiness.medicalHappiness | 0) + "\n") + shortagePart + "" + boostPart + "" + enthusiasmPart + "\n" + ("With the current happiness, citizens work at " + common_MathExtensions.floatFormat(Math,happiness.actionSpeedModifier,2) + "x their normal speed."),"Happiness");
},function() {
if(_gthis.city.simulation.happiness.happiness >= 99.99) {
if(_gthis.city.simulation.happiness.happiness >= 124.99) {
return "xD";
} else {
return ":D";
}
} else {
return Std.string(_gthis.city.simulation.happiness.happiness | 0);
}
},"spr_happiness",populationAndHappiness,26,function() {
return _gthis.windowRelatedTo == "happinessWindow";
});
happinessBox.keyboardButton = Keyboard.getLetterCode("H");
populationAndHappiness.addChild(happinessBox);
var simulation = this.city.simulation;
var stats = simulation.stats;
var homelessStats = null;
homelessStats = this.createInfoButton(function() {
if(_gthis.windowRelatedTo == "houseInfo") {
_gthis.closeWindow();
} else {
_gthis.createWindow("houseInfo");
gui_HouseInformationWindow.create(_gthis.city,_gthis,_gthis.innerWindowStage,_gthis.windowInner);
}
},function() {
_gthis.tooltip.setText(homelessStats,gui_HouseInformationWindow.getHousingHelpText(stats),"Housing");
},function() {
if(stats.peopleWithHome >= stats.people) {
return "" + (stats.houseCapacity - stats.peopleWithHome);
}
return "[red]-" + (stats.people - stats.peopleWithHome);
},"spr_housing",generalStatistics,20,function() {
return _gthis.windowRelatedTo == "houseInfo";
});
generalStatistics.addChild(homelessStats);
var stats1 = this.city.simulation.stats;
this.workerAssignButton = this.createInfoButton(function() {
if(_gthis.windowRelatedTo == "workersAssign") {
_gthis.closeWindow();
} else {
_gthis.createWindow("workersAssign");
gui_WorkerDistributionWindow.create(_gthis.city,_gthis,_gthis.innerWindowStage,_gthis.windowInner);
}
},function() {
_gthis.tooltip.setText("Work","People with a job / total labor force.\nThere are " + stats1.jobs + " jobs.\n" + _gthis.game.textHelper.clickOrTap() + " to assign workers.");
},function() {
return "" + stats1.peopleWithAJob + "/" + stats1.laborForce;
},"spr_work",generalStatistics,20,function() {
return _gthis.windowRelatedTo == "workersAssign";
});
this.workerAssignButton.keyboardButton = Keyboard.getLetterCode("W");
generalStatistics.addChild(this.workerAssignButton);
}
,addAllMaterialsInfo: function() {
var _gthis = this;
var getProductionInfo = function(materialName,displayName) {
if(displayName == null) {
displayName = materialName;
}
var consumeText = "";
var consumptionYesterday = Math.floor(_gthis.city.simulation.stats.materialUsed[MaterialsHelper.findMaterialIndex(materialName)][1]);
var consumptionToday = Math.floor(_gthis.city.simulation.stats.materialUsed[MaterialsHelper.findMaterialIndex(materialName)][0]);
if((consumptionYesterday != 0 || consumptionToday != 0) && materialName != "food") {
consumeText = "\nYour factories used " + consumptionYesterday + " " + displayName + " yesterday and " + consumptionToday + " today so far.";
}
return "\nYour citizens produced " + Math.floor(_gthis.city.simulation.stats.materialProduction[MaterialsHelper.findMaterialIndex(materialName)][1]) + " " + displayName + " yesterday " + ("and " + Math.floor(_gthis.city.simulation.stats.materialProduction[MaterialsHelper.findMaterialIndex(materialName)][0]) + " today so far.") + consumeText;
};
this.materialsInfo = new gui_GUIContainer(this,this.stage,this.cityInfo,new common_Point(0,0),new common_FPoint(0,0));
this.materialsInfo.direction = gui_GUIContainerDirection.Vertical;
this.cityInfo.addChild(this.materialsInfo);
var materialsUsed = this.city.simulation.stats.materialUsed;
var foodInfo = this.addMaterialInfo("food","Food",function() {
var shortageText = "";
var ofWhichText = "";
if(_gthis.city.materials.cacao >= 1 || _gthis.city.materials.chocolate >= 1) {
ofWhichText = "You have " + Math.floor(_gthis.city.materials.food) + " food, including " + Math.floor(_gthis.city.materials.cacao) + " cacao bean" + (Math.floor(_gthis.city.materials.cacao) == 1 ? "" : "s") + " " + ("and " + Math.floor(_gthis.city.materials.chocolate) + " chocolate bar" + (Math.floor(_gthis.city.materials.chocolate) == 1 ? "" : "s") + ".\n");
}
var eating = _gthis.city.simulation.eating;
if(eating.foodShortage > 0.1) {
shortageText = "\nYou don't have enough food! The next " + Math.ceil(eating.foodShortage) + " food you produce will be eaten instantly by hungry citizens.";
}
return ofWhichText + eating.getFoodText() + getProductionInfo("food") + shortageText;
},function() {
return Math.floor(_gthis.city.materials.food);
},"spr_resource_food",function() {
return _gthis.city.simulation.eating.foodShortage > 0;
},"food");
this.woodAmountDisplay = this.addMaterialInfo("wood","Wood",function() {
return "Used to build." + getProductionInfo("wood");
},function() {
return Math.floor(_gthis.city.materials.wood);
},"spr_resource_wood",null,"wood");
this.stoneAmountDisplay = this.addMaterialInfo("stone","Stone",function() {
return "Used to build and to create machine parts. Can also be purified to refined metals." + getProductionInfo("stone");
},function() {
return Math.floor(_gthis.city.materials.stone);
},"spr_resource_stone",null,"stone");
this.addMaterialInfo("knowledge","Knowledge",function() {
return "Used for research." + getProductionInfo("knowledge");
},function() {
return Math.floor(_gthis.city.materials.knowledge);
},"spr_resource_knowledge",null,"knowledge");
this.addMaterialInfo("machineParts","Machine Parts",function() {
return "Used to build machines and advanced buildings." + getProductionInfo("machineParts","machine parts");
},function() {
return Math.floor(_gthis.city.materials.machineParts);
},"spr_resource_machineparts",null,"machineParts");
this.addMaterialInfo("refinedMetal","Refined Metals",function() {
return "Used to create advanced buildings and computer chips." + getProductionInfo("refinedMetal","refined metals");
},function() {
return Math.floor(_gthis.city.materials.refinedMetal);
},"spr_resource_refinedmetal",null,"refinedMetal");
this.addMaterialInfo("computerChips","Computer Chips",function() {
return "Used to create smart machines." + getProductionInfo("computerChips","computer chips");
},function() {
return Math.floor(_gthis.city.materials.computerChips);
},"spr_resource_computerchips",null,"computerChips");
var _g = 0;
var _g1 = MaterialsHelper.modMaterials;
while(_g < _g1.length) {
var material = [_g1[_g]];
++_g;
this.addMaterialInfo(material[0].variableName,material[0].displayName,(function(material) {
return function() {
return material[0].description + material[0].tooltipExt() + getProductionInfo(material[0].variableName,material[0].displayName.toLowerCase());
};
})(material),(function(material) {
return function() {
return Math.floor(_gthis.city.materials[material[0].variableName]);
};
})(material),"spr_resource_" + material[0].variableName.toLowerCase(),null,material[0].variableName);
}
}
,resize: function() {
GUI.prototype.resize.call(this);
this.buildingButtons.resize();
this.cityInfo.updatePosition(new common_Point(this.game.rect.width,this.game.rect.height));
if(this.notificationPanel != null) {
this.notificationPanel.updatePosition(new common_Point(this.game.rect.width / 2 | 0,0));
}
}
,update: function(timeMod) {
this.buildingButtons.update(timeMod);
this.cityInfo.update();
if(this.notificationPanel != null) {
this.notificationPanel.update();
}
GUI.prototype.update.call(this,timeMod);
}
,onEscapePressWithoutWindow: function() {
gui_GameMenu.create(this,this.city);
}
,handleMouse: function(mouse) {
if(GUI.prototype.handleMouse.call(this,mouse)) {
return true;
}
if(this.buildingButtons.handleMouse(mouse)) {
return true;
}
if(this.cityInfo.handleMouse(mouse)) {
return true;
}
if(this.notificationPanel != null) {
if(this.notificationPanel.handleMouse(mouse)) {
return true;
}
}
return false;
}
,addMaterialInfo: function(material,name,info,getAmount,textureName,makeRed,identifier) {
var _gthis = this;
if(makeRed == null) {
makeRed = function() {
return false;
};
}
var ib = this.createInfoBoxForMaterialsDynamicTooltip(material,name,info,function() {
var basicString = Std.string(getAmount());
if(makeRed != null && makeRed()) {
return "[red]" + basicString;
}
return basicString;
},textureName,this.materialsInfo,42);
ib.onUpdate = function() {
var shouldNotShowDownArrow = _gthis.city.simulation.stats.materialUsed[MaterialsHelper.findMaterialIndex(identifier)][1] + 0.2 < _gthis.city.simulation.stats.materialProduction[MaterialsHelper.findMaterialIndex(identifier)][1] || _gthis.city.simulation.stats.materialUsed[MaterialsHelper.findMaterialIndex(identifier)][1] < 0.2 && identifier != "food" || 1 + ((_gthis.city.simulation.time.timeSinceStart | 0) / 1440 | 0) <= 5;
if(!shouldNotShowDownArrow) {
var threeDayTotalUse = 0.0;
var threeDayTotalProd = 0.0;
var skipDays = 0;
while(skipDays < 2 && _gthis.city.simulation.festivalManager.wasFestivalOnDay[1 + skipDays]) ++skipDays;
threeDayTotalUse += _gthis.city.simulation.stats.materialUsed[MaterialsHelper.findMaterialIndex(identifier)][1 + skipDays];
threeDayTotalProd += _gthis.city.simulation.stats.materialProduction[MaterialsHelper.findMaterialIndex(identifier)][1 + skipDays];
while(skipDays < 2 && _gthis.city.simulation.festivalManager.wasFestivalOnDay[2 + skipDays]) ++skipDays;
threeDayTotalUse += _gthis.city.simulation.stats.materialUsed[MaterialsHelper.findMaterialIndex(identifier)][2 + skipDays];
threeDayTotalProd += _gthis.city.simulation.stats.materialProduction[MaterialsHelper.findMaterialIndex(identifier)][2 + skipDays];
while(skipDays < 2 && _gthis.city.simulation.festivalManager.wasFestivalOnDay[3 + skipDays]) ++skipDays;
threeDayTotalUse += _gthis.city.simulation.stats.materialUsed[MaterialsHelper.findMaterialIndex(identifier)][3 + skipDays];
threeDayTotalProd += _gthis.city.simulation.stats.materialProduction[MaterialsHelper.findMaterialIndex(identifier)][3 + skipDays];
shouldNotShowDownArrow = threeDayTotalUse + 0.2 <= threeDayTotalProd;
}
if(!shouldNotShowDownArrow) {
var prodToday = _gthis.city.simulation.stats.materialProduction[MaterialsHelper.findMaterialIndex(identifier)][0];
var consToday = _gthis.city.simulation.stats.materialUsed[MaterialsHelper.findMaterialIndex(identifier)][0];
if(_gthis.city.simulation.time.timeSinceStart / 60 % 24 > 10 && prodToday > consToday) {
if(!ib.hasAdditionalSprite()) {
shouldNotShowDownArrow = true;
} else if(prodToday * (1.1 + 0.1 * Math.max(0,12.0 - _gthis.city.simulation.time.timeSinceStart / 60 % 24)) > consToday) {
shouldNotShowDownArrow = true;
}
}
}
if(_gthis.city.progress.sandbox.unlimitedResources || shouldNotShowDownArrow) {
ib.setAdditionalSprite(null);
} else {
ib.setAdditionalSprite(Resources.getTexture("spr_resource_downtrend"));
}
};
return ib;
}
,createInfoBoxForMaterialsDynamicTooltip: function(material,title,info,getAmount,textureName,parent,minWidth) {
if(minWidth == null) {
minWidth = 42;
}
var _gthis = this;
var button = new gui_ContainerButton(this,this.stage,parent,function() {
if(_gthis.windowRelatedTo == material) {
_gthis.closeWindow();
} else {
_gthis.createWindow(material,Resources.getTexture("spr_9p_window_moreopaque"));
gui_infoWindows_MaterialInfoWindow.create(_gthis.city,_gthis,_gthis.innerWindowStage,_gthis.windowInner,material,title);
}
},function() {
return _gthis.windowRelatedTo == material;
},function() {
_gthis.tooltip.setText(button,info(),title);
},"spr_transparentbutton_info");
button.container.fillSecondarySize = true;
var newInfoBox = new gui_InfoBox(this,this.stage,button.container,function() {
return getAmount();
},Resources.getTexture(textureName),minWidth,function() {
},"none",function() {
return _gthis.city.progress.sandbox.unlimitedResources;
});
newInfoBox.fillSecondarySize = true;
newInfoBox.fillPrimarySize = true;
button.container.addChild(newInfoBox);
parent.addChild(button);
return newInfoBox;
}
,createInfoButton: function(onClick,onHover,getAmount,textureName,parent,minWidth,isActive) {
if(minWidth == null) {
minWidth = 42;
}
var infoButton = new gui_ContainerButton(this,this.stage,parent,onClick,isActive,onHover,"spr_transparentbutton_info");
infoButton.container.fillSecondarySize = true;
var extraSpacing = this.game.isMobile ? 3 : 0;
var extraSpacingText = this.game.isMobile ? 2 : 0;
infoButton.container.padding = { left : 2 + extraSpacing, right : extraSpacing + 3, top : extraSpacing + 2, bottom : extraSpacing + (-1)};
infoButton.container.updateSize();
infoButton.container.addChild(new gui_ContainerHolder(infoButton.container,this.stage,new PIXI.Sprite(Resources.getTexture(textureName))));
infoButton.container.addChild(new gui_TextElement(infoButton.container,this.stage,null,getAmount,null,{ left : 1 + extraSpacingText, right : 0, top : 1, bottom : 0}));
infoButton.container.minWidth = minWidth;
return infoButton;
}
,closeWindow: function(inProcessOfOpeningAnother) {
if(inProcessOfOpeningAnother == null) {
inProcessOfOpeningAnother = false;
}
if(this.city.pauseGame && this.pausedForWindow) {
this.city.set_pauseGame(false);
this.pausedForWindow = false;
}
if(!this.city.pauseGame && (this.city.gui.windowStackMeta.indexOf("GameMenu") == -1 || this.city.gui.windowStackMeta.length == 1) && !inProcessOfOpeningAnother) {
common_PokiHelpers.reportStartGameplay();
}
GUI.prototype.closeWindow.call(this,inProcessOfOpeningAnother);
}
,pauseForWindow: function() {
var wasPaused = this.city.pauseGame;
this.city.set_pauseGame(true);
if(!wasPaused) {
this.pausedForWindow = true;
}
}
,activateLoserState: function() {
this.cityInfo.clear();
this.buildingButtons.activateLoserState();
}
,showTutorialArrows1: function() {
var _gthis = this;
var oldWindowOnDestroy = this.windowOnDestroy;
var windowClosed = false;
this.windowOnDestroy = function() {
windowClosed = true;
if(oldWindowOnDestroy != null) {
oldWindowOnDestroy();
}
};
this.overlayElements.push(new gui_HelpArrow(this,this.gameHelpStage,function() {
return _gthis.windowInner.children[_gthis.windowInner.children.length - 1].children[1];
},function() {
return !windowClosed;
},gui_HelpArrowDirection.Left,180));
this.buildingButtons.showTutorialArrows1(this.overlayElements,function() {
return windowClosed;
},this.gameHelpStage);
}
,showTutorialArrowsBuildStoneMine: function(windowClosed) {
var _gthis = this;
var woodAmountArrow = new gui_HelpArrow(this,this.gameHelpStage,function() {
return _gthis.woodAmountDisplay;
},function() {
if(windowClosed()) {
return _gthis.city.materials.wood < 4;
} else {
return false;
}
},gui_HelpArrowDirection.DownHint,0);
woodAmountArrow.addText("See your wood here.");
this.overlayElements.push(woodAmountArrow);
this.buildingButtons.showTutorialArrows101(this.overlayElements,function() {
return _gthis.city.materials.wood >= 4;
},this.gameHelpStage);
}
,showTutorialArrows2: function(windowClosed) {
var _gthis = this;
var everHadAnyPrio = false;
var origWindow = null;
var everHadPrio = function() {
if(everHadAnyPrio && origWindow == null) {
origWindow = _gthis.window;
}
everHadAnyPrio = everHadAnyPrio || Object.prototype.hasOwnProperty.call(_gthis.city.simulation.jobAssigner.priorityJobs.h,"buildings.StoneMine") && _gthis.city.simulation.jobAssigner.priorityJobs.h["buildings.StoneMine"] != 0;
return everHadAnyPrio;
};
this.overlayElements.push(new gui_HelpArrow(this,this.gameHelpStage,function() {
return _gthis.hideShowUIButton;
},function() {
if(windowClosed() && gui_WorkerDistributionWindow.tutorialStoneMineUpButton == null && !everHadPrio()) {
return _gthis.cityExtraInfoHidden;
} else {
return false;
}
},gui_HelpArrowDirection.Down));
var ha2 = new gui_HelpArrow(this,this.gameHelpStage,function() {
return _gthis.workerAssignButton;
},function() {
if(windowClosed() && gui_WorkerDistributionWindow.tutorialStoneMineUpButton == null) {
return !everHadPrio();
} else {
return false;
}
},gui_HelpArrowDirection.Down);
if(!this.game.isMobile) {
ha2.useBigMovement();
}
this.overlayElements.push(ha2);
this.overlayElements.push(new gui_HelpArrow(this,this.gameHelpStage,function() {
return gui_WorkerDistributionWindow.tutorialStoneMineUpButton;
},function() {
if(gui_WorkerDistributionWindow.tutorialStoneMineUpButton != null) {
return !everHadPrio();
} else {
return false;
}
},gui_HelpArrowDirection.Left));
var stoneAmountArrow = new gui_HelpArrow(this,this.gameHelpStage,function() {
return _gthis.woodAmountDisplay;
},function() {
if(everHadPrio()) {
if(_gthis.window != null) {
return _gthis.window == origWindow;
} else {
return true;
}
} else {
return false;
}
},gui_HelpArrowDirection.DownHint,0);
if(this.game.rect.width < 900) {
stoneAmountArrow.pleaseAlignExtraTextRight = true;
}
stoneAmountArrow.addText("Great! Now, let's gather 6 wood and 4 stone.");
this.overlayElements.push(stoneAmountArrow);
this.buildingButtons.showTutorialArrows2(this.overlayElements,everHadPrio,this.gameHelpStage,windowClosed);
var needsSecondHelp = function() {
if(_gthis.city.materials.stone > 6 && _gthis.city.materials.wood < 6) {
return !Lambda.exists(_gthis.city.permanents,function(pm) {
if(pm.is(buildings_WoodcuttingCentre)) {
return pm.workers.length > 0;
} else {
return false;
}
});
} else {
return false;
}
};
var hasWorkersOnStone = function() {
if(Object.prototype.hasOwnProperty.call(_gthis.city.simulation.jobAssigner.priorityJobs.h,"buildings.StoneMine")) {
return _gthis.city.simulation.jobAssigner.priorityJobs.h["buildings.StoneMine"] >= 3;
} else {
return false;
}
};
var reduceStoneText = "You have enough stone for now! Let's get some workers back on cutting wood.";
var ciButton = new gui_HelpArrow(this,this.gameHelpStage,function() {
return _gthis.hideShowUIButton;
},function() {
if(gui_WorkerDistributionWindow.tutorialStoneMineUpButton == null && needsSecondHelp()) {
return _gthis.cityExtraInfoHidden;
} else {
return false;
}
},gui_HelpArrowDirection.Down);
ciButton.addText(reduceStoneText);
this.overlayElements.push(ciButton);
var waButton = new gui_HelpArrow(this,this.gameHelpStage,function() {
return _gthis.workerAssignButton;
},function() {
if(gui_WorkerDistributionWindow.tutorialStoneMineUpButton == null) {
return needsSecondHelp();
} else {
return false;
}
},gui_HelpArrowDirection.Down);
waButton.addText(reduceStoneText);
this.overlayElements.push(waButton);
var stoneMineDownButton = new gui_HelpArrow(this,this.gameHelpStage,function() {
return gui_WorkerDistributionWindow.tutorialStoneMineDownButton;
},function() {
if(gui_WorkerDistributionWindow.tutorialStoneMineDownButton != null && needsSecondHelp()) {
return hasWorkersOnStone();
} else {
return false;
}
},gui_HelpArrowDirection.Left);
stoneMineDownButton.addText("Reduce the priority of stone mining.");
this.overlayElements.push(stoneMineDownButton);
var woodUpButton = new gui_HelpArrow(this,this.gameHelpStage,function() {
return gui_WorkerDistributionWindow.tutorialWoodCuttersUpButton;
},function() {
if(gui_WorkerDistributionWindow.tutorialWoodCuttersUpButton != null && needsSecondHelp()) {
return !hasWorkersOnStone();
} else {
return false;
}
},gui_HelpArrowDirection.Left);
woodUpButton.addText("Increase the priority of woodcutting!");
this.overlayElements.push(woodUpButton);
}
,showTutorialArrows3: function() {
var _gthis = this;
var storyHelpButtonUsed = false;
var stoneAmountArrow = new gui_HelpArrow(this,this.gameHelpStage,function() {
return _gthis.storyHelpButton;
},function() {
if(!storyHelpButtonUsed) {
return _gthis.window == null;
} else {
return false;
}
},gui_HelpArrowDirection.DownHint,0);
stoneAmountArrow.addText("Tip! If you ever forget what to do, just " + (this.game.isMobile ? "tap on" : "hover over") + " the ? here.");
this.overlayElements.push(stoneAmountArrow);
this.storyHelpButtonOnUse = function() {
storyHelpButtonUsed = true;
_gthis.storyHelpButtonOnUse = null;
};
}
,showTutorialArrows4: function() {
var _gthis = this;
if(!this.game.isMobile && this.simulationSpeedChosen == 0) {
var gameSpeedUsed = false;
var speedHelpArrow = new gui_HelpArrow(this,this.gameHelpStage,function() {
return _gthis.gameSpeedButton;
},function() {
if(!gameSpeedUsed) {
return _gthis.window == null;
} else {
return false;
}
},gui_HelpArrowDirection.DownHint,0);
speedHelpArrow.addText("Tip! If you ever think the game is going a bit too slowly, you can speed it up with the button here.");
this.overlayElements.push(speedHelpArrow);
this.gameSpeedOnUse = function() {
gameSpeedUsed = true;
_gthis.gameSpeedOnUse = null;
};
}
}
,showWindowCloseWarning: function(time) {
if(time == null) {
time = 300;
}
var _gthis = this;
var oldWindowOnDestroy = this.windowOnDestroy;
var windowClosed = false;
this.windowOnDestroy = function() {
windowClosed = true;
if(oldWindowOnDestroy != null) {
oldWindowOnDestroy();
}
};
this.overlayElements.push(new gui_HelpArrow(this,this.gameHelpStage,function() {
return _gthis.windowInner.children[_gthis.windowInner.children.length - 1].children[1];
},function() {
return !windowClosed;
},gui_HelpArrowDirection.Left,time));
return function() {
return windowClosed;
};
}
,clearTutorial: function() {
var _g = 0;
var _g1 = this.overlayElements;
while(_g < _g1.length) {
var elem = _g1[_g];
++_g;
elem.destroy();
}
this.overlayElements = [];
}
,refreshCategoryBuildingsShown: function() {
this.buildingButtons.refreshCategoryBuildingsShown();
}
,__class__: gui_CityGUI
});
var gui_ClimateCrisisExplainerWindow = function() { };
$hxClasses["gui.ClimateCrisisExplainerWindow"] = gui_ClimateCrisisExplainerWindow;
gui_ClimateCrisisExplainerWindow.__name__ = "gui.ClimateCrisisExplainerWindow";
gui_ClimateCrisisExplainerWindow.create = function(city,gui,stage,thisWindow) {
city.gui.windowAddTitleText("Let's Stop the Crimate Crisis!");
thisWindow.addChild(new gui_TextElement(thisWindow,stage,"As you probably know, our climate is changing because of greenhouse gas emissions caused by humans. " + "We only have about a decade left to drastically reduce emissions if we want to prevent the worst effects, which could include flooding, droughts and major health risks. " + "Here are just a few actions you can take:",null,"Arial"));
thisWindow.addChild(new gui_GUISpacing(thisWindow,new common_Point(2,6)));
thisWindow.addChild(new gui_TextElement(thisWindow,stage,"Vote!",null,"Arial15"));
thisWindow.addChild(new gui_TextElement(thisWindow,stage,"It is very important that governments create laws that help companies and people reduce greenhouse gas emissions. " + "Therefore, please vote for a sensible party whenever you can.",null,"Arial"));
thisWindow.addChild(new gui_GUISpacing(thisWindow,new common_Point(2,6)));
thisWindow.addChild(new gui_TextElement(thisWindow,stage,"Eat Less Meat",null,"Arial15"));
thisWindow.addChild(new gui_TextElement(thisWindow,stage,"There are amazing meat alternatives, that taste great and cause far less harmful emissions. Also, beans or nuts can be a good alternative source of protein.",null,"Arial"));
thisWindow.addChild(new gui_GUISpacing(thisWindow,new common_Point(2,6)));
thisWindow.addChild(new gui_TextElement(thisWindow,stage,"Don't Fly",null,"Arial15"));
thisWindow.addChild(new gui_TextElement(thisWindow,stage,"Flying causes a huge amount of CO2 emission. Stay on the ground whenever you can. If you like to travel, taking the train is a great, fun option!",null,"Arial"));
thisWindow.addChild(new gui_GUISpacing(thisWindow,new common_Point(2,6)));
thisWindow.addChild(new gui_TextElement(thisWindow,stage,"Be Informed",null,"Arial15"));
thisWindow.addChild(new gui_TextElement(thisWindow,stage,"Knowledge is power! Read climate news and facts on sites like The Guardian Environment and the Climate Reality Project.",null,"Arial"));
thisWindow.addChild(new gui_GUISpacing(thisWindow,new common_Point(2,6)));
thisWindow.addChild(new gui_TextElement(thisWindow,stage,"Thanks,",null,"Arial"));
thisWindow.addChild(new gui_GUISpacing(thisWindow,new common_Point(2,6)));
thisWindow.addChild(new gui_TextElement(thisWindow,stage,"Florian van Strien",null,"Arial"));
thisWindow.addChild(new gui_GUISpacing(thisWindow,new common_Point(2,10)));
gui.windowAddBottomButtons([{ text : "Read More (External Link)", onHover : function() {
city.game.setOnClickTo = function() {
window.open("https://www.climaterealityproject.org/climate-101","_blank");
};
}, action : function() {
}}]);
};
var gui_ContainerButton = function(gui,stage,parent,action,isActive,onHover,buttonSpriteName) {
if(buttonSpriteName == null) {
buttonSpriteName = "spr_button";
}
this.needsAttention = false;
this.highlightPatch = null;
gui_Button.call(this,gui,stage,parent,action,isActive,onHover);
this.buttonTextures = Resources.getTextures(buttonSpriteName,3);
this.buttonPatch = new gui_NinePatch(this.buttonTextures[0],2,2,2);
this.buttonPatch.texture = this.buttonTextures[1];
this.buttonPatch.updateTextures(false);
this.buttonPatch.texture = this.buttonTextures[2];
this.buttonPatch.updateTextures(false);
this.buttonPatch.setTextureSet(0);
stage.addChild(this.buttonPatch);
this.container = new gui_GUIContainer(gui,stage,this);
this.rect = new common_Rectangle(0,0,2,2);
};
$hxClasses["gui.ContainerButton"] = gui_ContainerButton;
gui_ContainerButton.__name__ = "gui.ContainerButton";
gui_ContainerButton.__super__ = gui_Button;
gui_ContainerButton.prototype = $extend(gui_Button.prototype,{
setNeedsAttention: function(needsAttention) {
if(needsAttention == null) {
needsAttention = false;
}
this.needsAttention = needsAttention;
this.updateNeedsAttention();
}
,updateNeedsAttention: function() {
if(this.buttonPatch == null) {
return;
}
if(this.needsAttention && this.highlightPatch == null) {
this.highlightPatch = new gui_NinePatch(Resources.getTexture("spr_greenoutline"),2,this.buttonPatch.npWidth,this.buttonPatch.npHeight);
this.stage.addChild(this.highlightPatch);
this.highlightPatch.position.set(this.rect.x,this.rect.y);
this.highlightPatch.updateSprites();
}
if(this.highlightPatch != null) {
if(this.needsAttention && this.buttonPatch.currentTextureSet == 0) {
this.highlightPatch.alpha = (Math.sin(this.gui.guiTimer / 10) + 1) / 2;
} else {
this.highlightPatch.alpha = 0;
}
}
}
,updatePosition: function(newPosition) {
gui_Button.prototype.updatePosition.call(this,newPosition);
this.buttonPatch.position.set(newPosition.x,newPosition.y);
this.buttonPatch.updateSprites();
if(this.highlightPatch != null) {
this.highlightPatch.position.set(newPosition.x,newPosition.y);
this.highlightPatch.updateSprites();
}
this.container.updatePosition(newPosition);
}
,updateSize: function() {
if(this.container != null) {
this.rect.width = this.container.rect.width;
this.rect.height = this.container.rect.height;
this.updateSizeDisplay();
if(this.parent != null) {
this.parent.updateSize();
}
this.container.minWidth = this.container.baseWidth;
}
}
,updateSizeDisplay: function() {
if(this.container != null) {
this.buttonPatch.npWidth = this.rect.width;
this.buttonPatch.npHeight = this.rect.height;
this.buttonPatch.updateSprites();
if(this.highlightPatch != null) {
this.highlightPatch.npWidth = this.rect.width;
this.highlightPatch.npHeight = this.rect.height;
this.highlightPatch.updateSprites();
}
}
}
,handleMouse: function(mouse) {
var _gthis = this;
return gui_Button.prototype.doHandleMouse.call(this,mouse,function() {
_gthis.buttonPatch.setTextureSet(1);
},function() {
_gthis.buttonPatch.setTextureSet(2);
});
}
,update: function() {
this.container.update();
if(this.mouseOut) {
this.buttonPatch.setTextureSet(0);
}
if(this.isActive()) {
this.buttonPatch.setTextureSet(2);
}
this.updateNeedsAttention();
gui_Button.prototype.update.call(this);
}
,destroy: function() {
gui_Button.prototype.destroy.call(this);
this.container.destroy();
this.stage.removeChild(this.buttonPatch);
if(this.highlightPatch != null) {
this.highlightPatch.destroy();
}
}
,__class__: gui_ContainerButton
});
var gui_ContainerButtonWithProgress = function(gui,stage,parent,action,isActive,onHover,buttonSpriteName,backColor,frontColor,autoSetProgress) {
if(frontColor == null) {
frontColor = 16777215;
}
if(backColor == null) {
backColor = 10526880;
}
if(buttonSpriteName == null) {
buttonSpriteName = "spr_button";
}
this.progressAmount = 0;
gui_ContainerButton.call(this,gui,stage,parent,action,isActive,onHover,buttonSpriteName);
this.graphics = new PIXI.Graphics(false);
stage.addChild(this.graphics);
this.backColor = backColor;
this.frontColor = frontColor;
this.autoSetProgress = autoSetProgress;
};
$hxClasses["gui.ContainerButtonWithProgress"] = gui_ContainerButtonWithProgress;
gui_ContainerButtonWithProgress.__name__ = "gui.ContainerButtonWithProgress";
gui_ContainerButtonWithProgress.__super__ = gui_ContainerButton;
gui_ContainerButtonWithProgress.prototype = $extend(gui_ContainerButton.prototype,{
update: function() {
gui_ContainerButton.prototype.update.call(this);
if(this.autoSetProgress != null) {
this.setProgress(this.autoSetProgress());
}
}
,updateProgressDisplay: function() {
if(this.progressAmount < 0) {
this.graphics.clear();
return;
}
var _this = this.rect;
var inlPoint_x = _this.x;
var inlPoint_y = _this.y;
this.graphics.position.x = inlPoint_x;
var _this = this.rect;
var inlPoint_x = _this.x;
var inlPoint_y = _this.y;
this.graphics.position.y = inlPoint_y;
this.graphics.clear().beginFill(this.backColor,1).drawRect(1,1,this.rect.width - 2,this.rect.height - 2).endFill().beginFill(this.frontColor,1).drawRect(1,1,Math.round((this.rect.width - 2) * this.progressAmount),this.rect.height - 2).endFill();
}
,updatePosition: function(newPosition) {
gui_ContainerButton.prototype.updatePosition.call(this,newPosition);
this.updateProgressDisplay();
}
,updateSizeDisplay: function() {
gui_ContainerButton.prototype.updateSizeDisplay.call(this);
this.updateProgressDisplay();
}
,setProgress: function(progressAmount) {
this.progressAmount = progressAmount;
this.updateProgressDisplay();
}
,destroy: function() {
gui_ContainerButton.prototype.destroy.call(this);
this.graphics.destroy();
}
,__class__: gui_ContainerButtonWithProgress
});
var gui_ContainerHolder = function(parent,stage,container,padding,update,handleMouse) {
this.container = container;
this.stage = stage;
this.updateFunction = update;
this.handleMouseFunction = handleMouse;
stage.addChild(container);
this.rect = new common_Rectangle(0,0,0,0);
if(padding == null) {
padding = { left : 0, top : 0, right : 0, bottom : 0};
}
this.padding = padding;
this.updateSize();
this.parent = parent;
};
$hxClasses["gui.ContainerHolder"] = gui_ContainerHolder;
gui_ContainerHolder.__name__ = "gui.ContainerHolder";
gui_ContainerHolder.__interfaces__ = [gui_IGUIElement];
gui_ContainerHolder.prototype = {
updateSize: function() {
var m = this.container;
if(((this.container) instanceof gui_MaterialsCostDisplay) || ((this.container) instanceof gui_MaterialsDisplay)) {
this.rect.width = Math.round(m.displayWidth);
} else {
this.rect.width = Math.round(this.container.width);
}
this.rect.height = Math.round(this.container.height);
this.afterSizeUpdate();
}
,afterSizeUpdate: function() {
this.rect.width += this.padding.left + this.padding.right;
this.rect.height += this.padding.top + this.padding.bottom;
if(this.parent != null) {
this.parent.updateSize();
}
}
,updatePosition: function(newPosition) {
this.rect.x = newPosition.x;
this.rect.y = newPosition.y;
this.container.position.x = newPosition.x + this.padding.left;
this.container.position.y = newPosition.y + this.padding.top;
}
,handleMouse: function(mouse) {
if(this.handleMouseFunction != null) {
return this.handleMouseFunction(mouse);
}
return false;
}
,update: function() {
if(this.updateFunction != null) {
this.updateFunction();
}
}
,destroy: function() {
this.stage.removeChild(this.container);
}
,__class__: gui_ContainerHolder
};
var gui_GUIContainer = function(gui,stage,parent,position,origin,children,background,padding) {
this.neverDownsize = false;
this.minHeight = 0;
this.minWidth = 0;
this.fillPrimarySize = false;
this.fillSecondarySize = false;
this.direction = gui_GUIContainerDirection.Horizontal;
this.alignment = gui_GUIContainerAlignment.LeftOrTop;
this.parent = parent;
this.stage = stage;
this.gui = gui;
this.children = children == null ? [] : children;
this.background = background;
if(padding == null) {
padding = { top : 0, right : 0, bottom : 0, left : 0};
}
this.padding = padding;
if(background != null) {
stage.addChild(background);
}
this.rect = new common_Rectangle(0,0,0,0);
this.origin = origin == null ? new common_FPoint(0,0) : origin;
if(position == null) {
position = new common_Point(0,0);
}
this.updatePosition(position);
this.updateSize();
};
$hxClasses["gui.GUIContainer"] = gui_GUIContainer;
gui_GUIContainer.__name__ = "gui.GUIContainer";
gui_GUIContainer.__interfaces__ = [gui_IGUIElement];
gui_GUIContainer.prototype = {
handleMouse: function(mouse) {
var _g = 0;
var _g1 = this.children;
while(_g < _g1.length) {
var child = _g1[_g];
++_g;
if(child.handleMouse(mouse)) {
return true;
}
}
if(this.background != null && this.rect.contains(mouse.position)) {
mouse.claimMouse(this);
return true;
}
return false;
}
,update: function() {
if(this.onUpdate != null) {
this.onUpdate();
}
var _g = 0;
var _g1 = this.children;
while(_g < _g1.length) {
var child = _g1[_g];
++_g;
child.update();
}
}
,updateSize: function() {
this.updateSizeNonRecursive();
if(this.parent != null) {
this.parent.updateSize();
} else {
this.updateChildrenPosition();
}
}
,updateSizeNonRecursive: function() {
this.rect.width = 0;
this.rect.height = 0;
var _g = 0;
var _g1 = this.children;
while(_g < _g1.length) {
var child = _g1[_g];
++_g;
if(((child) instanceof gui_GUIFiller)) {
continue;
}
if(((child) instanceof gui_GUIContainer)) {
var childContainer = child;
if(this.direction == gui_GUIContainerDirection.Horizontal) {
this.rect.width += childContainer.originalRectWidth;
var val1 = this.rect.height;
var val2 = childContainer.originalRectHeight;
this.rect.height = val2 > val1 ? val2 : val1;
} else {
var val11 = this.rect.width;
var val21 = childContainer.originalRectWidth;
this.rect.width = val21 > val11 ? val21 : val11;
this.rect.height += childContainer.originalRectHeight;
}
} else if(this.direction == gui_GUIContainerDirection.Horizontal) {
this.rect.width += child.rect.width;
var val12 = this.rect.height;
var val22 = child.rect.height;
this.rect.height = val22 > val12 ? val22 : val12;
} else {
var val13 = this.rect.width;
var val23 = child.rect.width;
this.rect.width = val23 > val13 ? val23 : val13;
this.rect.height += child.rect.height;
}
}
if(this.neverDownsize) {
if(this.rect.width > this.minWidth) {
this.minWidth = this.rect.width;
}
if(this.rect.height > this.minHeight) {
this.minHeight = this.rect.height;
}
}
if(this.rect.width < this.minWidth) {
this.rect.width = this.minWidth;
}
if(this.rect.height < this.minHeight) {
this.rect.height = this.minHeight;
}
this.baseWidth = this.rect.width;
this.baseHeight = this.rect.height;
var _g = 0;
var _g1 = this.children;
while(_g < _g1.length) {
var child = _g1[_g];
++_g;
if(((child) instanceof gui_GUIFiller)) {
var childFiller = child;
switch(this.direction._hx_index) {
case 0:
this.rect.width += childFiller.minFill;
break;
case 1:
this.rect.height += childFiller.minFill;
break;
}
}
}
this.rect.width += this.padding.left + this.padding.right;
this.rect.height += this.padding.top + this.padding.bottom;
this.originalRectWidth = this.rect.width;
this.originalRectHeight = this.rect.height;
this.nonBaseWidth = this.rect.width - this.baseWidth;
this.nonBaseHeight = this.rect.height - this.baseHeight;
}
,updateBackgroundSize: function() {
if(this.background != null) {
var oldBackgroundWidth = this.background.npWidth;
var oldBackgroundHeight = this.background.npHeight;
this.background.npWidth = this.rect.width;
this.background.npHeight = this.rect.height;
if(this.background != null) {
this.background.position.x = this.rect.x;
this.background.position.y = this.rect.y;
this.background.updateSprites();
}
if(oldBackgroundWidth != this.background.npWidth || oldBackgroundHeight != this.background.npHeight) {
this.background.updateSprites();
}
}
}
,updatePosition: function(newPosition) {
this.position = newPosition;
this.updateChildrenPosition();
if(this.background != null) {
this.background.position.x = this.rect.x;
this.background.position.y = this.rect.y;
this.background.updateSprites();
}
}
,updateChildrenPosition: function() {
var _this = this.rect;
var _this1 = this.position;
var otherPoint_x = this.origin.x * this.rect.width | 0;
var otherPoint_y = this.origin.y * this.rect.height | 0;
var newPos_x = _this1.x - otherPoint_x;
var newPos_y = _this1.y - otherPoint_y;
var inlPoint_x = _this.x = newPos_x;
var inlPoint_y = _this.y = newPos_y;
var extraFillAmount = 0;
var extraFillNumberLeft = 0;
if(this.rect.width > this.originalRectWidth || this.rect.height > this.originalRectHeight) {
var originalChildrenSize = 0;
var _g = 0;
var _g1 = this.children;
while(_g < _g1.length) {
var child = _g1[_g];
++_g;
if(((child) instanceof gui_GUIContainer) && child.fillPrimarySize) {
var childContainer = child;
++extraFillNumberLeft;
switch(this.direction._hx_index) {
case 0:
originalChildrenSize += childContainer.originalRectWidth;
break;
case 1:
originalChildrenSize += childContainer.originalRectHeight;
break;
}
} else {
switch(this.direction._hx_index) {
case 0:
originalChildrenSize += child.rect.width;
break;
case 1:
originalChildrenSize += child.rect.height;
break;
}
}
}
if(extraFillNumberLeft >= 0) {
switch(this.direction._hx_index) {
case 0:
originalChildrenSize -= this.nonBaseWidth;
extraFillAmount = this.rect.width - originalChildrenSize;
break;
case 1:
originalChildrenSize -= this.nonBaseHeight;
extraFillAmount = this.rect.height - originalChildrenSize;
break;
}
}
}
var secundarySizeFillWidth = this.rect.width - this.padding.left - this.padding.right;
var secundarySizeFillHeight = this.rect.height - this.padding.top - this.padding.bottom;
var _g = 0;
var _g1 = this.children;
while(_g < _g1.length) {
var child = _g1[_g];
++_g;
if(((child) instanceof gui_GUIFiller)) {
switch(this.direction._hx_index) {
case 0:
child.rect.width = this.rect.width - this.padding.left - this.padding.right - this.baseWidth;
break;
case 1:
child.rect.height = this.rect.height - this.padding.top - this.padding.bottom - this.baseHeight;
break;
}
} else if(((child) instanceof gui_ContainerButton) || ((child) instanceof gui_CheckboxButton)) {
var childContainerButton = child;
if(childContainerButton.container.fillSecondarySize) {
if(this.direction == gui_GUIContainerDirection.Horizontal) {
child.rect.height = secundarySizeFillHeight;
childContainerButton.container.rect.height = secundarySizeFillHeight;
} else {
child.rect.width = secundarySizeFillWidth;
childContainerButton.container.rect.width = secundarySizeFillWidth;
}
}
childContainerButton.updateSizeDisplay();
} else if(((child) instanceof gui_GUIContainer)) {
var childContainer = child;
if(childContainer.fillSecondarySize) {
if(this.direction == gui_GUIContainerDirection.Horizontal) {
child.rect.height = secundarySizeFillHeight;
} else {
child.rect.width = secundarySizeFillWidth;
}
}
if(childContainer.fillPrimarySize) {
var thisFillAmount = extraFillAmount / extraFillNumberLeft | 0;
switch(this.direction._hx_index) {
case 0:
child.rect.width = childContainer.originalRectWidth + thisFillAmount;
break;
case 1:
child.rect.height = childContainer.originalRectHeight + thisFillAmount;
break;
}
extraFillAmount -= thisFillAmount;
--extraFillNumberLeft;
}
}
}
var x = this.rect.x + this.padding.left;
var y = this.rect.y + this.padding.top;
switch(this.direction._hx_index) {
case 0:
var _g = 0;
var _g1 = this.children;
while(_g < _g1.length) {
var child = _g1[_g];
++_g;
if(((child) instanceof gui_GUIContainer)) {
var childContainer = child;
switch(childContainer.alignment._hx_index) {
case 0:
child.updatePosition(new common_Point(x,y));
break;
case 1:
child.updatePosition(new common_Point(x,y + ((this.rect.height - this.padding.top - this.padding.bottom - child.rect.height) / 2 | 0)));
break;
case 2:
child.updatePosition(new common_Point(x,this.rect.get_y2() - this.padding.bottom - child.rect.height));
break;
}
} else {
child.updatePosition(new common_Point(x,y));
}
x += child.rect.width;
}
break;
case 1:
var _g = 0;
var _g1 = this.children;
while(_g < _g1.length) {
var child = _g1[_g];
++_g;
if(((child) instanceof gui_GUIContainer)) {
var childContainer = child;
switch(childContainer.alignment._hx_index) {
case 0:
child.updatePosition(new common_Point(x,y));
break;
case 1:
child.updatePosition(new common_Point(x + ((this.rect.width - this.padding.left - this.padding.right - child.rect.width) / 2 | 0),y));
break;
case 2:
child.updatePosition(new common_Point(this.rect.get_x2() - child.rect.width - this.padding.right,y));
break;
}
} else {
child.updatePosition(new common_Point(x,y));
}
y += child.rect.height;
}
break;
}
this.updateBackgroundSize();
}
,addChild: function(child) {
this.children.push(child);
this.updateSize();
return child;
}
,addChildWithoutSizeUpdate: function(child) {
this.children.push(child);
return child;
}
,insertChild: function(child,atPosition) {
this.children.splice(atPosition,0,child);
this.updateSize();
return child;
}
,removeChild: function(child,thenUpdateSize) {
if(thenUpdateSize == null) {
thenUpdateSize = true;
}
child.destroy();
HxOverrides.remove(this.children,child);
if(thenUpdateSize) {
this.updateSize();
}
}
,clear: function() {
Lambda.iter(this.children,function(c) {
c.destroy();
});
this.children = [];
this.updateSize();
}
,destroy: function() {
if(this.onDestroy != null) {
this.onDestroy();
}
Lambda.iter(this.children,function(c) {
c.destroy();
});
if(this.background != null) {
this.stage.removeChild(this.background);
}
}
,__class__: gui_GUIContainer
};
var gui_ContainerWithScrollbar = function(maxWidthWithoutScrollbar,maxHeight,gui,stage,parent,position,origin,children,background,padding,extraPadding) {
if(extraPadding == null) {
extraPadding = 1;
}
this.setScrollPositionNextUpdate = null;
this.extraPadding = 1;
this.scrollable = null;
gui_GUIContainer.call(this,gui,stage,parent,position,origin,children,background,padding);
this.maxWidthWithoutScrollbar = maxWidthWithoutScrollbar;
this.maxHeight = maxHeight;
this.scrollbar = null;
this.extraPadding = extraPadding;
};
$hxClasses["gui.ContainerWithScrollbar"] = gui_ContainerWithScrollbar;
gui_ContainerWithScrollbar.__name__ = "gui.ContainerWithScrollbar";
gui_ContainerWithScrollbar.__super__ = gui_GUIContainer;
gui_ContainerWithScrollbar.prototype = $extend(gui_GUIContainer.prototype,{
setInnerContainer: function(container) {
this.clear();
var paddingContainer = new gui_GUIContainer(this.gui,this.stage,this,null,null,null,null,{ top : this.extraPadding, right : this.extraPadding, bottom : this.extraPadding, left : this.extraPadding});
this.addChild(paddingContainer);
this.scrollable = new gui_AutoScrollable(this.gui.game,this.stage,paddingContainer,new common_Point(0,0),this.maxWidthWithoutScrollbar,this.maxHeight,new common_FPoint(0,0));
this.innerContainer = container;
this.innerContainer.parent = this.scrollable;
this.scrollable.setChild(this.innerContainer);
paddingContainer.addChild(this.scrollable);
}
,addScrollBar: function() {
this.scrollbar = new gui_ScrollBar(this,this.stage,this.scrollable);
this.addChild(this.scrollbar);
}
,setScrollPosition: function(scrollPosition) {
if(this.scrollable != null) {
this.scrollable.updateScrollPosition(scrollPosition);
}
if(this.scrollbar != null) {
this.scrollbar.redraw();
}
}
,forceSetScrollPosition: function(scrollPosition) {
this.setScrollPosition(new common_Point(scrollPosition.x,scrollPosition.y));
this.setScrollPositionNextUpdate = scrollPosition;
}
,update: function() {
gui_GUIContainer.prototype.update.call(this);
if(this.setScrollPositionNextUpdate != null) {
this.setScrollPosition(this.setScrollPositionNextUpdate);
this.setScrollPositionNextUpdate = null;
}
}
,updateSize: function() {
if(this.scrollable != null) {
if(this.scrollbar != null) {
if(this.scrollable.rect.height >= this.scrollable.get_innerHeight()) {
this.removeChild(this.scrollbar,false);
this.scrollbar = null;
}
} else if(this.scrollbar == null) {
if(this.scrollable.rect.height < this.scrollable.get_innerHeight()) {
this.addScrollBar();
}
}
}
if(this.scrollbar != null && this.scrollable != null) {
this.scrollbar.rect.height = this.scrollable.rect.height + this.extraPadding * 2;
}
gui_GUIContainer.prototype.updateSize.call(this);
}
,__class__: gui_ContainerWithScrollbar
});
var gui_CreateBuildingUpgrades = function() { };
$hxClasses["gui.CreateBuildingUpgrades"] = gui_CreateBuildingUpgrades;
gui_CreateBuildingUpgrades.__name__ = "gui.CreateBuildingUpgrades";
gui_CreateBuildingUpgrades.upgradeAll = function(city,building,upgrade,materialsToPay,onUpgrade) {
var _g = 0;
var _g1 = city.permanents;
while(_g < _g1.length) {
var permanent = _g1[_g];
++_g;
if(!permanent.isBuilding) {
continue;
}
var buildingToUpgrade = permanent;
if(js_Boot.getClass(buildingToUpgrade) == js_Boot.getClass(building)) {
if(!common_ArrayExtensions.any(buildingToUpgrade.upgrades,function(bu) {
return js_Boot.getClass(bu) == upgrade;
}) && city.materials.canAfford(materialsToPay)) {
city.materials.remove(materialsToPay);
onUpgrade(buildingToUpgrade);
}
}
}
};
gui_CreateBuildingUpgrades.getUpgradeAllNumberAndCanAfford = function(city,building,upgrade,materialsToPay) {
var mats = city.materials.copy();
var num = 0;
var canAffordAll = true;
var matsToPay = materialsToPay.copy();
matsToPay.knowledge = 0;
var _g = 0;
var _g1 = city.permanents;
while(_g < _g1.length) {
var permanent = _g1[_g];
++_g;
if(!permanent.isBuilding) {
continue;
}
var buildingToUpgrade = permanent;
if(js_Boot.getClass(buildingToUpgrade) == js_Boot.getClass(building)) {
if(!common_ArrayExtensions.any(buildingToUpgrade.upgrades,function(bu) {
return js_Boot.getClass(bu) == upgrade;
})) {
if(mats.canAfford(matsToPay)) {
mats.remove(matsToPay);
++num;
} else {
canAffordAll = false;
}
}
}
}
if(!canAffordAll && num == 0) {
num = 1;
}
return { number : num, canAffordAll : canAffordAll};
};
gui_CreateBuildingUpgrades.setUpgradeAllDisplay = function(city,building,mcd,upgrade,materialsToPay,ch,notForParticularBuilding) {
if(notForParticularBuilding == null) {
notForParticularBuilding = false;
}
var numAndAfford = gui_CreateBuildingUpgrades.getUpgradeAllNumberAndCanAfford(city,building,upgrade,materialsToPay);
var wdt = mcd.displayWidth;
if(numAndAfford.number <= 1) {
mcd.setBeforeKnowledgeText(numAndAfford.number == 0 ? "per building" : notForParticularBuilding ? "for one building" : "for this building");
mcd.setCost(materialsToPay);
if(wdt != mcd.displayWidth) {
ch.updateSize();
}
} else {
mcd.setBeforeKnowledgeText("for " + (numAndAfford.canAffordAll ? "all" : "" + numAndAfford.number) + " buildings");
var mats = materialsToPay.copy();
mats.multiply(numAndAfford.number);
mats.knowledge = materialsToPay.knowledge;
mcd.setCost(mats);
if(wdt != mcd.displayWidth) {
ch.updateSize();
}
}
};
gui_CreateBuildingUpgrades.addUpgradeButton = function(city,building,upgrade,onUpgrade,canRemoveUpgrade,onButtonClickSound,notForParticularBuilding) {
if(notForParticularBuilding == null) {
notForParticularBuilding = false;
}
var gui = city.gui;
var this1 = Resources.buildingUpgradesInfo;
var key = upgrade.__name__;
var info = this1.h[key];
var materialsToPay = Materials.fromBuildingUpgradesInfo(info);
if(city.progress.unlocks.getUnlockState(upgrade) == progress_UnlockState.Researched) {
materialsToPay.knowledge = 0;
}
var hasUpgrade = common_ArrayExtensions.any(building.upgrades,function(bu) {
return js_Boot.getClass(bu) == upgrade;
}) || building.buildingMode != null && js_Boot.getClass(building.buildingMode) == upgrade;
var thisHasUpgrade = hasUpgrade;
if(notForParticularBuilding) {
var numAndAfford = gui_CreateBuildingUpgrades.getUpgradeAllNumberAndCanAfford(city,building,upgrade,materialsToPay);
hasUpgrade = numAndAfford.number == 0;
}
var infoContainerInfo = gui_UpgradeWindowParts.createActivatableButton(gui,hasUpgrade,function() {
if(city.materials.canAfford(materialsToPay)) {
if(onButtonClickSound != null) {
Audio.get().playSound(onButtonClickSound);
}
if(!thisHasUpgrade) {
city.materials.remove(materialsToPay);
onUpgrade(building);
}
city.simulation.houseAssigner.shouldUpdateHouses = true;
city.progress.unlocks.research(upgrade);
materialsToPay.knowledge = 0;
if(gui_UpgradeWindowParts.hasMultiUpgradeModeOn) {
gui_CreateBuildingUpgrades.upgradeAll(city,building,upgrade,materialsToPay,onUpgrade);
}
city.gui.reloadWindow();
}
},info.name,info.description);
if(infoContainerInfo.button != null) {
infoContainerInfo.button.buttonSound = null;
}
var infoContainer = infoContainerInfo.container;
if(infoContainerInfo.button != null) {
var this1 = gui.currentUpgradeButtons;
var k = upgrade.__name__;
var v = infoContainerInfo.button;
this1.h[k] = v;
}
if(!hasUpgrade) {
if(materialsToPay.any()) {
var mcdContainer = new gui_GUIContainer(gui,gui.innerWindowStage,infoContainer);
var mcd = new gui_MaterialsCostDisplay(city,materialsToPay,gui_UpgradeWindowParts.hasMultiUpgradeModeOn ? "per building" : "");
var ch = mcdContainer.addChild(new gui_ContainerHolder(mcdContainer,gui.innerWindowStage,mcd,{ left : 0, right : 0, top : 0, bottom : gui_UpgradeWindowParts.hasMultiUpgradeModeOn ? materialsToPay.knowledge == 0 ? 0 : 1 : 2},$bind(mcd,mcd.updateCostDisplay)));
if(gui_UpgradeWindowParts.hasMultiUpgradeModeOn) {
gui_CreateBuildingUpgrades.setUpgradeAllDisplay(city,building,mcd,upgrade,materialsToPay,ch,notForParticularBuilding);
var city1 = city;
var building1 = building;
var mcd1 = mcd;
var upgrade1 = upgrade;
var materialsToPay1 = materialsToPay;
var ch1 = ch;
var notForParticularBuilding1 = notForParticularBuilding;
mcdContainer.onUpdate = function() {
gui_CreateBuildingUpgrades.setUpgradeAllDisplay(city1,building1,mcd1,upgrade1,materialsToPay1,ch1,notForParticularBuilding1);
};
}
infoContainer.addChild(mcdContainer);
}
} else if(!notForParticularBuilding) {
var thisBuildingUpgrade = Lambda.find(building.upgrades,function(bu) {
return js_Boot.getClass(bu) == upgrade;
});
if(thisBuildingUpgrade == null) {
thisBuildingUpgrade = building.buildingMode;
}
if(canRemoveUpgrade || thisBuildingUpgrade.textures.length > 1) {
var extraButtons = new gui_GUIContainer(gui,gui.innerWindowStage,infoContainer);
if(canRemoveUpgrade) {
infoContainer.padding.bottom += 1;
extraButtons.addChild(new gui_TextButton(gui,gui.innerWindowStage,infoContainer,function() {
thisBuildingUpgrade.destroy();
HxOverrides.remove(building.upgrades,thisBuildingUpgrade);
city.simulation.houseAssigner.shouldUpdateHouses = true;
city.gui.reloadWindow();
},"Remove"));
extraButtons.addChild(new gui_GUISpacing(infoContainer,new common_Point(2,1)));
}
if(thisBuildingUpgrade.textures.length > 1) {
var changeAppearanceButton = null;
changeAppearanceButton = new gui_TextButton(gui,gui.innerWindowStage,infoContainer,function() {
thisBuildingUpgrade.changeAppearance();
},"Change Variant",null,function() {
gui.tooltip.setText(changeAppearanceButton,"Change the appearance of this upgrade.");
});
extraButtons.addChild(changeAppearanceButton);
}
infoContainer.addChild(extraButtons);
infoContainer.addChild(new gui_GUISpacing(infoContainer,new common_Point(1,2)));
}
}
};
gui_CreateBuildingUpgrades.addUpgradesOrBuildingModes = function(city,building,thesePossibleUpgrades,categoryName,onUpgrade,canRemoveUpgrades,upgradeOneText,upgradeAllText,upgradeAllTextNoCost,onAllButtonSelect,onButtonClickSound,notForParticularBuilding) {
if(notForParticularBuilding == null) {
notForParticularBuilding = false;
}
var gui = city.gui;
if(!common_ArrayExtensions.any(thesePossibleUpgrades,function(pu) {
return city.progress.unlocks.getUnlockState(pu) != progress_UnlockState.Locked;
})) {
return;
}
var upgradesTitleContainer = null;
if(categoryName != null) {
upgradesTitleContainer = gui_UpgradeWindowParts.createHeader(gui,categoryName);
}
var anyNewUpgrade = false;
var anyUpgradeWithCost = false;
var _g = 0;
while(_g < thesePossibleUpgrades.length) {
var upgrade = [thesePossibleUpgrades[_g]];
++_g;
if(city.progress.unlocks.getUnlockState(upgrade[0]) == progress_UnlockState.Locked) {
continue;
}
var hasUpgrade = common_ArrayExtensions.any(building.upgrades,(function(upgrade) {
return function(bu) {
return js_Boot.getClass(bu) == upgrade[0];
};
})(upgrade)) || building.buildingMode != null && js_Boot.getClass(building.buildingMode) == upgrade[0];
if(!hasUpgrade) {
var this1 = Resources.buildingUpgradesInfo;
var key = upgrade[0].__name__;
var info = this1.h[key];
var costWithoutKnowledge = Materials.fromBuildingUpgradesInfo(info);
costWithoutKnowledge.knowledge = 0;
if(costWithoutKnowledge.any()) {
anyUpgradeWithCost = true;
}
}
if(!hasUpgrade) {
anyNewUpgrade = true;
}
gui_CreateBuildingUpgrades.addUpgradeButton(city,building,upgrade[0],(function(_g,a1) {
return function(a2) {
_g[0](a1[0],a2);
};
})([onUpgrade],[upgrade[0]]),canRemoveUpgrades,onButtonClickSound,notForParticularBuilding);
}
if(anyNewUpgrade && upgradesTitleContainer != null) {
gui_UpgradeWindowParts.addOneAndMaxButtons(gui,upgradesTitleContainer,function() {
gui_UpgradeWindowParts.hasMultiUpgradeModeOn = false;
city.gui.reloadWindow();
},function() {
gui_UpgradeWindowParts.hasMultiUpgradeModeOn = true;
if(onAllButtonSelect != null) {
onAllButtonSelect();
}
city.gui.reloadWindow();
},upgradeOneText,upgradeAllText,upgradeAllTextNoCost,anyUpgradeWithCost);
}
gui.windowInner.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,4)));
};
gui_CreateBuildingUpgrades.addUpgradeParts = function(building,city,showTitle,notForParticularBuilding) {
if(notForParticularBuilding == null) {
notForParticularBuilding = false;
}
var type = js_Boot.getClass(building);
gui_CreateBuildingUpgrades.addUpgradesOrBuildingModes(city,building,building.get_possibleUpgrades(),showTitle ? "Upgrades" : null,function(upgrade,buildingToUpgrade) {
buildingToUpgrade.upgrades.push(Type.createInstance(upgrade,[building.stage,city.cityMidStage,building.bgStage,buildingToUpgrade]));
},false,"Upgrade only this building.",function() {
return "Upgrade as many buildings of this type as you can afford. There are " + city.simulation.stats.amountOfBuildingsOfType(type) + ".";
},function() {
return "Upgrade all buildings of this type. There are " + city.simulation.stats.amountOfBuildingsOfType(type);
},null,Audio.get().buildingUpgradeSound,notForParticularBuilding);
};
gui_CreateBuildingUpgrades.createMainWindowPart = function(building,city) {
var gui = city.gui;
gui.currentUpgradeButtons = new haxe_ds_StringMap();
gui_CreateBuildingUpgrades.addUpgradeParts(building,city,true);
var onBuildingMode = function(upgrade,buildingToUpgrade) {
if(buildingToUpgrade.buildingMode != null) {
buildingToUpgrade.buildingMode.destroy();
}
buildingToUpgrade.buildingMode = Type.createInstance(upgrade,[building.stage,city.cityMidStage,building.bgStage,buildingToUpgrade]);
};
var type = js_Boot.getClass(building);
gui_CreateBuildingUpgrades.addUpgradesOrBuildingModes(city,building,building.get_possibleBuildingModes(),"Building Modes",onBuildingMode,false,"Set the building mode of only this building.",function() {
return "Set the building mode of as many buildings of this type as you can afford. There are " + city.simulation.stats.amountOfBuildingsOfType(type) + ".";
},function() {
return "Set the building mode of all buildings of this type. There are " + city.simulation.stats.amountOfBuildingsOfType(type) + ".";
},function() {
var thisClass = js_Boot.getClass(building.buildingMode);
var this1 = Resources.buildingUpgradesInfo;
var key = thisClass.__name__;
var info = this1.h[key];
var materialsToPay = Materials.fromBuildingUpgradesInfo(info);
materialsToPay.knowledge = 0;
var _g = onBuildingMode;
var a1 = thisClass;
var tmp = function(a2) {
_g(a1,a2);
};
gui_CreateBuildingUpgrades.upgradeAll(city,building,thisClass,materialsToPay,tmp);
});
gui_CreateCityUpgrades.create(building.get_possibleCityUpgrades(),city);
gui_CreatePolicies.create(building.get_possiblePolicies(),city);
};
gui_CreateBuildingUpgrades.createBuildingUpgradesForType = function(building,city) {
city.gui.windowInner.addChild(new gui_GUISpacing(city.gui.windowInner,new common_Point(2,4)));
gui_UpgradeWindowParts.hasMultiUpgradeModeOn = true;
gui_CreateBuildingUpgrades.addUpgradeParts(building,city,false,true);
gui_CreateCityUpgrades.create(building.get_possibleCityUpgrades(),city,false);
gui_CreatePolicies.create(building.get_possiblePolicies(),city,false);
};
var gui_CreateCityUpgrades = function() { };
$hxClasses["gui.CreateCityUpgrades"] = gui_CreateCityUpgrades;
gui_CreateCityUpgrades.__name__ = "gui.CreateCityUpgrades";
gui_CreateCityUpgrades.create = function(upgrades,city,addHeader) {
if(addHeader == null) {
addHeader = true;
}
var gui = city.gui;
var _g = [];
var _g1 = 0;
var _g2 = upgrades;
while(_g1 < _g2.length) {
var v = _g2[_g1];
++_g1;
if(city.progress.unlocks.getUnlockState(v) == progress_UnlockState.Unlocked) {
_g.push(v);
}
}
var unlockedUpgrades = _g;
var cityUpgrades = city.upgrades;
var cityUpgradesList = cityUpgrades.upgrades;
if(unlockedUpgrades.length == 0) {
return;
}
if(addHeader) {
gui_UpgradeWindowParts.createHeader(gui,"City Upgrades");
}
var buttonsContainer = new gui_GUIContainer(gui,gui.innerWindowStage,gui.windowInner);
gui.windowInner.addChild(buttonsContainer);
buttonsContainer.direction = gui_GUIContainerDirection.Vertical;
buttonsContainer.fillSecondarySize = true;
var recreateButtons = function() {
buttonsContainer.clear();
var _g = 0;
while(_g < unlockedUpgrades.length) {
var upgrade = [unlockedUpgrades[_g]];
++_g;
var hasUpgrade = common_ArrayExtensions.any(cityUpgradesList,(function(upgrade) {
return function(bu) {
return js_Boot.getClass(bu) == upgrade[0];
};
})(upgrade));
var upgradeName = [upgrade[0].__name__];
var info = Resources.cityUpgradesInfo.h[upgradeName[0]];
var currentName = info.name;
var currentDescription = info.description;
if(info.nextUpgrade != null && info.nextUpgrade != "") {
var nextUpgrade = "cityUpgrades." + info.nextUpgrade;
if(city.progress.unlocks.getUnlockState($hxClasses[nextUpgrade]) != progress_UnlockState.Locked) {
continue;
}
} else if(hasUpgrade) {
if(info.nameIfNotDone != null) {
currentName = info.nameIfNotDone;
}
if(info.descriptionIfNotDone != null) {
currentDescription = info.descriptionIfNotDone;
}
}
var materialsToPay = [Materials.fromCityUpgradesInfo(info)];
var infoContainerInfo = gui_UpgradeWindowParts.createActivatableButton(gui,hasUpgrade,(function(materialsToPay,upgradeName,upgrade) {
return function() {
if(city.materials.canAfford(materialsToPay[0])) {
city.materials.remove(materialsToPay[0]);
city.upgrades.addUpgrade(Type.createInstance(upgrade[0],[]));
Analytics.sendEvent("research",upgradeName[0]);
city.simulation.houseAssigner.shouldUpdateHouses = true;
city.gui.reloadWindow();
Audio.get().playSound(Audio.get().buildingUpgradeSound);
}
};
})(materialsToPay,upgradeName,upgrade),currentName,currentDescription,buttonsContainer,null);
if(infoContainerInfo.button != null) {
infoContainerInfo.button.buttonSound = null;
}
if(!hasUpgrade) {
if(materialsToPay[0].any()) {
var mcdContainer = new gui_GUIContainer(gui,gui.innerWindowStage,infoContainerInfo.container);
var mcd = new gui_MaterialsCostDisplay(city,materialsToPay[0],"");
mcdContainer.addChild(new gui_ContainerHolder(mcdContainer,gui.innerWindowStage,mcd,{ left : 0, right : 0, top : 0, bottom : 2},$bind(mcd,mcd.updateCostDisplay)));
infoContainerInfo.container.addChild(mcdContainer);
}
}
}
};
recreateButtons();
gui.windowInner.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,4)));
};
var gui_CreatePolicies = function() { };
$hxClasses["gui.CreatePolicies"] = gui_CreatePolicies;
gui_CreatePolicies.__name__ = "gui.CreatePolicies";
gui_CreatePolicies.create = function(policies,city,addHeader) {
if(addHeader == null) {
addHeader = true;
}
var gui = city.gui;
var _g = [];
var _g1 = 0;
var _g2 = policies;
while(_g1 < _g2.length) {
var v = _g2[_g1];
++_g1;
if(city.progress.unlocks.getUnlockState(v) == progress_UnlockState.Unlocked) {
_g.push(v);
}
}
var unlockedPolicies = _g;
var policies = city.policies;
var policiesList = policies.policies;
if(unlockedPolicies.length == 0) {
return;
}
if(addHeader) {
gui_UpgradeWindowParts.createHeader(gui,"City Policies");
}
var buttonsContainer = new gui_GUIContainer(gui,gui.innerWindowStage,gui.windowInner);
gui.windowInner.addChild(buttonsContainer);
buttonsContainer.direction = gui_GUIContainerDirection.Vertical;
buttonsContainer.fillSecondarySize = true;
var recreateButtons = function() {
buttonsContainer.clear();
var _g = 0;
while(_g < unlockedPolicies.length) {
var policy = [unlockedPolicies[_g]];
++_g;
var policyName = policy[0].__name__;
var info = Resources.policiesInfo.h[policyName];
var currentName = info.name;
var currentDescription = info.description;
var materialsToPay = [Materials.fromPoliciesInfo(info)];
var infoContainerInfo = gui_UpgradeWindowParts.createCheckboxButton(gui,(function(policy) {
return function() {
return common_ArrayExtensions.any(policiesList,(function(policy) {
return function(bu) {
return js_Boot.getClass(bu) == policy[0];
};
})(policy));
};
})(policy),(function(materialsToPay,policy) {
return function() {
var existingPolicy = Lambda.find(policiesList,(function(policy) {
return function(bu) {
return js_Boot.getClass(bu) == policy[0];
};
})(policy));
if(existingPolicy != null) {
city.policies.removePolicy(existingPolicy);
city.simulation.houseAssigner.shouldUpdateHouses = true;
} else if(city.materials.canAfford(materialsToPay[0])) {
city.materials.remove(materialsToPay[0]);
city.policies.addPolicy(Type.createInstance(policy[0],[]));
city.simulation.houseAssigner.shouldUpdateHouses = true;
}
};
})(materialsToPay,policy),currentName,currentDescription,buttonsContainer,null);
}
};
recreateButtons();
gui.windowInner.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,4)));
};
var gui_CreditsWindow = function() { };
$hxClasses["gui.CreditsWindow"] = gui_CreditsWindow;
gui_CreditsWindow.__name__ = "gui.CreditsWindow";
gui_CreditsWindow.create = function(city,gui,stage,$window) {
gui.windowAddTitleText("Credits");
$window.addChild(new gui_TextElement($window,stage,"A game by Florian van Strien.",null,"Arial15"));
$window.addChild(new gui_TextElement($window,stage,"Music & SFX by Stijn Cappetijn.",null,"Arial15"));
$window.addChild(new gui_GUISpacing($window,new common_Point(2,6)));
if(2 == 4) {
$window.addChild(new gui_TextElement($window,stage,"Big thanks to CoolMath Games for their sponsorship!",null,"Arial"));
$window.addChild(new gui_GUISpacing($window,new common_Point(2,6)));
} else {
var tmp = Main.isMobile;
}
$window.addChild(new gui_TextElement($window,stage,"Software",null,"Arial15"));
$window.addChild(new gui_TextElement($window,stage,"Built with Haxe.",null,"Arial"));
$window.addChild(new gui_TextElement($window,stage,"Rendered with pixi.js.",null,"Arial"));
$window.addChild(new gui_TextElement($window,stage,"FileSaver.js; localForage; canvas-toBlob.js;",null,"Arial"));
$window.addChild(new gui_TextElement($window,stage,"polygonal-ds; thx.color; pixi-sound",null,"Arial"));
$window.addChild(new gui_GUISpacing($window,new common_Point(2,6)));
$window.addChild(new gui_TextElement($window,stage,"Early Feedback: Douwe",null,"Arial"));
$window.addChild(new gui_GUISpacing($window,new common_Point(2,6)));
$window.addChild(new gui_TextElement($window,stage,"Thanks a lot for playing!",null,"Arial"));
if(2 == 4) {
$window.addChild(new gui_TextElement($window,stage,"While you're here on CoolMath Games, also check out my other games circloO 1 & 2 and Stop the Darkness!",null,"Arial"));
}
if(Config.get_enableCrossPromo() && jsFunctions.crossPromoInited()) {
var useFallBack = false;
gui.windowAddBottomButtons([{ text : "Play More Games!", action : function() {
jsFunctions.showCrossPromoDisplay(useFallBack);
}}]);
} else {
gui.windowAddBottomButtons();
}
};
var gui_CurrentMissionsWindow = function() { };
$hxClasses["gui.CurrentMissionsWindow"] = gui_CurrentMissionsWindow;
gui_CurrentMissionsWindow.__name__ = "gui.CurrentMissionsWindow";
gui_CurrentMissionsWindow.create = function(city,gui,stage,thisWindow) {
var theHeader = gui.windowAddTitleText("Current Tasks");
var thereWereMoreMissions = true;
var theText = new gui_TextElement(thisWindow,stage,null,function() {
var goalTexts = city.progress.goalHelp.getCurrentGoalHelp();
var fullGoalTexts = "";
var _g = 0;
while(_g < goalTexts.length) {
var goalText = goalTexts[_g];
++_g;
if(fullGoalTexts != "") {
fullGoalTexts += "\n\n";
}
fullGoalTexts += "- " + goalText.category + "\n" + goalText.text;
}
if(goalTexts.length != 1 != thereWereMoreMissions) {
if(goalTexts.length == 1) {
theHeader.setText("Current Task");
} else {
theHeader.setText("Current Tasks");
}
thereWereMoreMissions = goalTexts.length != 1;
}
if(fullGoalTexts == "") {
fullGoalTexts = "---";
}
return fullGoalTexts;
});
thisWindow.addChild(theText);
gui.windowAddBottomButtons();
};
var gui_FollowingCitizen = function() { };
$hxClasses["gui.FollowingCitizen"] = gui_FollowingCitizen;
gui_FollowingCitizen.__name__ = "gui.FollowingCitizen";
gui_FollowingCitizen.createWindow = function(city,citizen,clearWindowStack) {
if(clearWindowStack == null) {
clearWindowStack = true;
}
if(clearWindowStack) {
city.gui.clearWindowStack();
}
window.globalFollowingCitizen = citizen;
city.gui.createWindow(citizen);
city.gui.setWindowPositioning(city.game.isMobile ? gui_WindowPosition.TopLeft : gui_WindowPosition.Top);
var city1 = city;
var citizen1 = citizen;
var clearWindowStack1 = clearWindowStack;
var tmp = function() {
gui_FollowingCitizen.createWindow(city1,citizen1,clearWindowStack1);
};
city.gui.setWindowReload(tmp);
var city2 = city;
var citizen2 = citizen;
var clearWindowStack2 = clearWindowStack;
var tmp = function() {
gui_FollowingCitizen.createWindow(city2,citizen2,clearWindowStack2);
};
city.gui.addWindowToStack(tmp);
var windowTitle = "Following " + (citizen.nameIndex < Resources.citizenNames.length ? Resources.citizenNames[citizen.nameIndex] : "Citizen");
var nameIdentifier = citizen.nameIndex < Resources.citizenNames.length ? Resources.citizenNames[citizen.nameIndex] : "this citizen";
city.gui.windowAddTitleText(windowTitle);
city.gui.windowInner.addChild(new gui_TextElement(city.gui.windowInner,city.gui.innerWindowStage,null,function() {
var educationLevelDescription = citizen.educationLevel < 0.01 ? "None" : citizen.educationLevel < 0.1 ? "Poor" : citizen.educationLevel < 0.2 ? "Weak" : citizen.educationLevel < 0.4 ? "Limited" : citizen.educationLevel < 0.6 ? "Moderate" : citizen.educationLevel < 0.7 ? "Fair" : citizen.educationLevel < 0.8 ? "Good" : citizen.educationLevel < 1 ? "Very Good" : citizen.educationLevel <= 1.005 ? "Great" : citizen.educationLevel <= 1.2 ? "Superior" : citizen.educationLevel < 1.4 ? "Excellent" : citizen.educationLevel < 1.6 ? "Exceptional" : citizen.educationLevel < 1.8 ? "Amazing" : citizen.educationLevel < 2 ? "Incredible" : citizen.educationLevel < 2.2 ? "World-Class" : "Phenomenal";
return "Age: " + Math.floor(citizen.get_age()) + "\nEducation: " + educationLevelDescription;
}));
var citizenCanWork = citizen.get_age() >= 16 && citizen.school == null;
var addedButtons = city.gui.windowAddBottomButtons([{ text : citizenCanWork ? "Change Home/Job" : "Change Home/School", action : function() {
gui_FollowingCitizen.createChangeHomeAndWorkOfCitizenWindow(city,citizen);
}}]);
city.viewIsControlled = true;
var selectedSprite = Resources.makeSprite("spr_selectedhuman");
city.furtherForegroundStage.addChild(selectedSprite);
city.gui.windowOnLateUpdate = function() {
window.__temp1 = citizen;
if(citizen.hasDied) {
gui_FollowingCitizen.onCitizenDie(city,citizen,nameIdentifier,windowTitle);
return;
}
if(!citizenCanWork && (citizen.get_age() >= 16 && citizen.school == null)) {
addedButtons[0].setText("Change Home/Job");
citizenCanWork = true;
}
var citizenPos = citizen.getCityPosition();
city.viewPos = new common_FPoint(citizenPos.x,citizenPos.y);
selectedSprite.position.set(citizenPos.x - 1,citizenPos.y - 6);
city.cityView.updateMovingView();
};
city.gui.windowOnDestroy = function() {
city.viewIsControlled = false;
city.cityView.isDraggingView = false;
city.furtherForegroundStage.removeChild(selectedSprite);
};
var point = citizen.getCityPosition();
var tmp = new common_FPoint(point.x,point.y);
city.viewPos = tmp;
city.cityView.updateMovingView();
};
gui_FollowingCitizen.onCitizenDie = function(city,citizen,nameIdentifier,windowTitle) {
city.gui.clearWindowStack();
city.gui.closeWindow();
city.gui.createWindow();
city.gui.windowAddTitleText(windowTitle);
city.gui.windowInner.addChild(new gui_TextElement(city.gui.windowInner,city.gui.innerWindowStage,"Unfortunately, " + nameIdentifier + " passed away. :("));
city.gui.windowAddBottomButtons();
};
gui_FollowingCitizen.createChangeHomeAndWorkOfCitizenWindow = function(city,citizen) {
var nameIdentifier = citizen.nameIndex < Resources.citizenNames.length ? Resources.citizenNames[citizen.nameIndex] : "this citizen";
var selectedSprite = Resources.makeSprite("spr_selectedhuman");
city.furtherForegroundStage.addChild(selectedSprite);
city.activateSpecialCityAction(new cityActions_ChangeCitizenVitalBuildings(city,citizen));
city.gui.createWindow(citizen);
city.gui.setWindowPositioning(city.game.isMobile ? gui_WindowPosition.TopLeft : gui_WindowPosition.Top);
var city1 = city;
var citizen1 = citizen;
var tmp = function() {
gui_FollowingCitizen.createChangeHomeAndWorkOfCitizenWindow(city1,citizen1);
};
city.gui.setWindowReload(tmp);
var city2 = city;
var citizen2 = citizen;
var tmp = function() {
gui_FollowingCitizen.createChangeHomeAndWorkOfCitizenWindow(city2,citizen2);
};
city.gui.addWindowToStack(tmp);
var windowTitle = function() {
var citizenCanWork = citizen.get_age() >= 16 && citizen.school == null;
var text = citizenCanWork ? "Change Home/Job" : "Change Home/School";
return text + " for " + (citizen.nameIndex < Resources.citizenNames.length ? Resources.citizenNames[citizen.nameIndex] : "Citizen");
};
city.gui.windowAddTitleText(null,windowTitle);
city.gui.windowAddBottomButtons();
city.gui.windowOnLateUpdate = function() {
if(citizen.hasDied) {
gui_FollowingCitizen.onCitizenDie(city,citizen,nameIdentifier,windowTitle());
return;
}
var citizenPos = citizen.getCityPosition();
selectedSprite.position.set(citizenPos.x - 1,citizenPos.y - 6);
var hhTextures = Resources.getTextures("spr_hoverhints_citizen",4);
city.setHoverHightlight(function(pm) {
if(citizen.job == pm && citizen.home == pm) {
return hhTextures[3];
} else if(citizen.job == pm) {
return hhTextures[0];
} else if(citizen.home == pm) {
return hhTextures[1];
} else if(citizen.school == pm) {
return hhTextures[2];
} else {
return null;
}
},6735360);
};
city.gui.windowOnDestroy = function() {
city.furtherForegroundStage.removeChild(selectedSprite);
if(city.specialAction != null) {
city.specialAction.deactivate();
}
};
};
var gui_FreePlayConfigureWindow = function() { };
$hxClasses["gui.FreePlayConfigureWindow"] = gui_FreePlayConfigureWindow;
gui_FreePlayConfigureWindow.__name__ = "gui.FreePlayConfigureWindow";
gui_FreePlayConfigureWindow.createWindow = function(city,gui,onContinue,onCancel) {
gui.createWindow();
var city1 = city;
var gui1 = gui;
var onContinue1 = onContinue;
var onCancel1 = onCancel;
gui.addWindowToStack(function() {
gui_FreePlayConfigureWindow.createWindow(city1,gui1,onContinue1,onCancel1);
});
gui.windowAddTitleText("Customize Free Play");
gui.windowInner.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,2)));
gui.windowAddInfoText("Starting Resources",null,"Arial15");
var normalResources = city.materials.copy();
var standardNumber = common_ArrayExtensions.isum(city.progress.story.storyInfo.worlds,function(w) {
return common_ArrayExtensions.isum(w.citizens,function(wc) {
return wc.amount;
});
});
var ab = gui_ActivableButton.create(gui,gui.innerWindowStage,gui.windowInner,function() {
city.progress.sandbox.disableUnlimitedResources();
city.materials.remove(city.materials);
city.materials.add(normalResources);
var _g = city.materials;
_g.set_food(_g.food + (city.simulation.citizens.length - standardNumber) * 3);
},function() {
if(!city.progress.sandbox.unlimitedResources) {
return city.materials.wood < 1000;
} else {
return false;
}
},"Normal Resources");
gui.windowInner.addChild(ab);
gui.windowInner.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,2)));
var ab = gui_ActivableButton.create(gui,gui.innerWindowStage,gui.windowInner,function() {
city.progress.sandbox.disableUnlimitedResources();
city.materials.remove(city.materials);
city.materials.add(new Materials(1000,1000,1000,100,500));
var _g = city.materials;
_g.set_food(_g.food + (city.simulation.citizens.length - standardNumber) * 3);
},function() {
if(!city.progress.sandbox.unlimitedResources) {
return city.materials.wood >= 1000;
} else {
return false;
}
},"Extra Resources");
gui.windowInner.addChild(ab);
if(Config.allowUnlimitedResources) {
gui.windowInner.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,2)));
var ab = gui_ActivableButton.create(gui,gui.innerWindowStage,gui.windowInner,function() {
city.progress.sandbox.enableUnlimitedResources();
},function() {
return city.progress.sandbox.unlimitedResources;
},"Unlimited Resources");
gui.windowInner.addChild(ab);
}
gui.windowInner.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,6)));
gui.windowAddInfoText("Starting Citizens",null,"Arial15");
var startingCitizensChooser = new gui_GUIContainer(gui,gui.innerWindowStage,gui.windowInner);
startingCitizensChooser.direction = gui_GUIContainerDirection.Horizontal;
var ab = gui_ActivableButton.create(gui,gui.innerWindowStage,gui.windowInner,function() {
gui_FreePlayConfigureWindow.setCityCitizens(city,standardNumber);
},function() {
return city.simulation.citizens.length == standardNumber;
},standardNumber + "");
startingCitizensChooser.addChild(ab);
startingCitizensChooser.addChild(new gui_GUISpacing(startingCitizensChooser,new common_Point(2,2)));
var ab = gui_ActivableButton.create(gui,gui.innerWindowStage,gui.windowInner,function() {
gui_FreePlayConfigureWindow.setCityCitizens(city,10);
},function() {
return city.simulation.citizens.length == 10;
},"10");
startingCitizensChooser.addChild(ab);
startingCitizensChooser.addChild(new gui_GUISpacing(startingCitizensChooser,new common_Point(2,2)));
var ab = gui_ActivableButton.create(gui,gui.innerWindowStage,gui.windowInner,function() {
gui_FreePlayConfigureWindow.setCityCitizens(city,25);
},function() {
return city.simulation.citizens.length == 25;
},"25");
startingCitizensChooser.addChild(ab);
startingCitizensChooser.addChild(new gui_GUISpacing(startingCitizensChooser,new common_Point(2,2)));
var ab = gui_ActivableButton.create(gui,gui.innerWindowStage,gui.windowInner,function() {
gui_FreePlayConfigureWindow.setCityCitizens(city,100);
},function() {
return city.simulation.citizens.length == 100;
},"100");
startingCitizensChooser.addChild(ab);
if(Config.allowUnlimitedResources) {
startingCitizensChooser.addChild(new gui_GUISpacing(startingCitizensChooser,new common_Point(2,2)));
var ab = gui_ActivableButton.create(gui,gui.innerWindowStage,gui.windowInner,function() {
gui_FreePlayConfigureWindow.setCityCitizens(city,200);
},function() {
return city.simulation.citizens.length == 200;
},"200");
startingCitizensChooser.addChild(ab);
startingCitizensChooser.addChild(new gui_GUISpacing(startingCitizensChooser,new common_Point(2,2)));
var ab = gui_ActivableButton.create(gui,gui.innerWindowStage,gui.windowInner,function() {
gui_FreePlayConfigureWindow.setCityCitizens(city,500);
},function() {
return city.simulation.citizens.length == 500;
},"500");
startingCitizensChooser.addChild(ab);
}
gui.windowInner.addChild(startingCitizensChooser);
if(Config.allowUnlimitedResources) {
gui.windowInner.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,6)));
gui.windowAddInfoText("Buildings & Research",null,"Arial15");
var ab = gui_ActivableButton.create(gui,gui.innerWindowStage,gui.windowInner,function() {
city.progress.unlocks.unlockMost = false;
},function() {
return !city.progress.unlocks.unlockMost;
},"Standard Unlocks");
gui.windowInner.addChild(ab);
gui.windowInner.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,2)));
var ab = gui_ActivableButton.create(gui,gui.innerWindowStage,gui.windowInner,function() {
city.progress.unlocks.unlockMost = true;
},function() {
return city.progress.unlocks.unlockMost;
},"Most Unlocks");
gui.windowInner.addChild(ab);
}
gui.windowInner.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,6)));
gui.windowAddBottomButtons([{ text : "Back", action : function() {
onCancel();
}}],"Continue",function() {
onContinue();
});
gui.windowOnDestroy = onCancel;
};
gui_FreePlayConfigureWindow.setCityCitizens = function(city,number) {
if(city.simulation.citizens.length > number) {
while(city.simulation.citizens.length > number) {
city.simulation.citizens[city.simulation.citizens.length - 1].tryRemove();
var _g = city.materials;
_g.set_food(_g.food - 3);
}
} else {
while(city.simulation.citizens.length < number) {
var city1 = city.simulation;
var _g = [];
var _g1 = 0;
var _g2 = city.worlds;
while(_g1 < _g2.length) {
var v = _g2[_g1];
++_g1;
if(common_ArrayExtensions.any(city.simulation.citizens,(function(w) {
return function(ct) {
return ct.onWorld == w[0];
};
})([v]))) {
_g.push(v);
}
}
city1.createCitizen(_g[0],random_Random.getFloat(18,40));
var _g3 = city.materials;
_g3.set_food(_g3.food + 3);
}
}
};
var gui_GUIContainerDirection = $hxEnums["gui.GUIContainerDirection"] = { __ename__ : "gui.GUIContainerDirection", __constructs__ : ["Horizontal","Vertical"]
,Horizontal: {_hx_index:0,__enum__:"gui.GUIContainerDirection",toString:$estr}
,Vertical: {_hx_index:1,__enum__:"gui.GUIContainerDirection",toString:$estr}
};
var gui_GUIContainerAlignment = $hxEnums["gui.GUIContainerAlignment"] = { __ename__ : "gui.GUIContainerAlignment", __constructs__ : ["LeftOrTop","Center","RightOrBottom"]
,LeftOrTop: {_hx_index:0,__enum__:"gui.GUIContainerAlignment",toString:$estr}
,Center: {_hx_index:1,__enum__:"gui.GUIContainerAlignment",toString:$estr}
,RightOrBottom: {_hx_index:2,__enum__:"gui.GUIContainerAlignment",toString:$estr}
};
var gui_GUIContainerWithSizeCallback = function(gui,stage,parent,position,origin,children,background,padding) {
this.sizeCallback = null;
gui_GUIContainer.call(this,gui,stage,parent,position,origin,children,background,padding);
};
$hxClasses["gui.GUIContainerWithSizeCallback"] = gui_GUIContainerWithSizeCallback;
gui_GUIContainerWithSizeCallback.__name__ = "gui.GUIContainerWithSizeCallback";
gui_GUIContainerWithSizeCallback.__super__ = gui_GUIContainer;
gui_GUIContainerWithSizeCallback.prototype = $extend(gui_GUIContainer.prototype,{
setSizeCallback: function(newSizeCallback) {
this.sizeCallback = newSizeCallback;
}
,updateSize: function() {
gui_GUIContainer.prototype.updateSize.call(this);
if(this.sizeCallback != null) {
this.sizeCallback();
}
}
,__class__: gui_GUIContainerWithSizeCallback
});
var gui_GUIFiller = function(parent,minFill) {
if(minFill == null) {
minFill = 0;
}
this.parent = parent;
this.minFill = minFill;
this.rect = new common_Rectangle(0,0,1,1);
};
$hxClasses["gui.GUIFiller"] = gui_GUIFiller;
gui_GUIFiller.__name__ = "gui.GUIFiller";
gui_GUIFiller.__interfaces__ = [gui_IGUIElement];
gui_GUIFiller.prototype = {
updateSize: function() {
this.parent.updateSize();
}
,updatePosition: function(newPosition) {
var _this = this.rect;
new common_Point(_this.x = newPosition.x,_this.y = newPosition.y);
}
,destroy: function() {
}
,handleMouse: function(mouse) {
return false;
}
,update: function() {
}
,__class__: gui_GUIFiller
};
var gui_GUISpacing = function(parent,extraSpace) {
this.parent = parent;
this.rect = new common_Rectangle(0,0,1,1);
this.rect.width = extraSpace.x;
this.rect.height = extraSpace.y;
};
$hxClasses["gui.GUISpacing"] = gui_GUISpacing;
gui_GUISpacing.__name__ = "gui.GUISpacing";
gui_GUISpacing.__interfaces__ = [gui_IGUIElement];
gui_GUISpacing.prototype = {
updateSize: function() {
this.parent.updateSize();
}
,updatePosition: function(newPosition) {
var _this = this.rect;
new common_Point(_this.x = newPosition.x,_this.y = newPosition.y);
}
,destroy: function() {
}
,handleMouse: function(mouse) {
return false;
}
,update: function() {
}
,__class__: gui_GUISpacing
};
var gui_GameMenu = function() { };
$hxClasses["gui.GameMenu"] = gui_GameMenu;
gui_GameMenu.__name__ = "gui.GameMenu";
gui_GameMenu.create = function(gui,city) {
var imageButtonToUse = "spr_button_small";
var imageOffsetToUse = 2;
if(city.game.isMobile) {
imageButtonToUse = "spr_button_medium";
imageOffsetToUse = 4;
}
gui.createWindow("gameMenu");
gui.clearWindowStack();
var gui1 = gui;
var city1 = city;
var tmp = function() {
gui_GameMenu.create(gui1,city1);
};
gui.addWindowToStack(tmp,true,"GameMenu");
gui.windowAddTitleText("Game Menu");
common_PokiHelpers.reportStopGameplay();
var stage = gui.innerWindowStage;
gui.windowAddInfoText(null,function() {
if(common_Storage.storageSupported()) {
return "Last saved " + common_MathExtensions.floatFormat(Math,city.secondsSinceAutoSave,1) + " seconds ago.";
} else {
return "Warning: temporary save!";
}
});
var saveLoadButtons = new gui_GUIContainer(gui,stage,null,new common_Point(0,0),new common_FPoint(0,0));
saveLoadButtons.addChild(new gui_TextButton(gui,stage,saveLoadButtons,function() {
gui_SaveLoadWindows.createSaveWindow(city.game,gui,"Which save slot would you like to save to?",function(fileName) {
city.cityFile = fileName;
city.saveToBrowserStorage();
});
},"Save..."));
saveLoadButtons.addChild(new gui_GUISpacing(saveLoadButtons,new common_Point(2,2)));
saveLoadButtons.addChild(new gui_TextButton(gui,stage,saveLoadButtons,function() {
gui_SaveLoadWindows.createLoadWindow(city.game,gui,"Which city would you like to load?",function(fileName) {
city.game.loadFromStorage(fileName);
});
if(2 == 6 && Config.hadFullStepWithInput) {
common_AdHelper.showNonRewardedInterstitialIfAllowed();
}
},"Load..."));
saveLoadButtons.addChild(new gui_GUISpacing(saveLoadButtons,new common_Point(2,2)));
if(!city.game.isMobile || !jsFunctions.isAnyApple()) {
saveLoadButtons.addChild(new gui_TextButton(gui,stage,saveLoadButtons,function() {
var saveFile = city.saveToString();
jsFunctions.saveAs(new Blob([saveFile],{ type : "text/plain;charset=utf-8"}),"theFinalEarth2_save.sav");
},"Export"));
saveLoadButtons.addChild(new gui_GUISpacing(saveLoadButtons,new common_Point(2,2)));
}
saveLoadButtons.addChild(new gui_TextButton(gui,stage,saveLoadButtons,function() {
},"Import...",null,function() {
city.game.setOnClickTo = function() {
var importButton = window.document.getElementById("importFile");
importButton.value = "";
importButton.click();
city.game.onClick = null;
};
}));
gui.windowInner.addChild(saveLoadButtons);
gui.windowInner.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,6)));
var fullReset = new gui_GUIContainer(gui,stage,null,new common_Point(0,0),new common_FPoint(0,0));
var newGameButton = new gui_TextButton(gui,stage,fullReset,function() {
gui_MainMenuGUI.createNewScenarioWindow(city.game,gui);
if(2 == 6 && Config.hadFullStepWithInput) {
common_AdHelper.showNonRewardedInterstitialIfAllowed();
}
},"New City");
newGameButton.extraWidth = 15;
newGameButton.setText("New City");
fullReset.addChild(newGameButton);
fullReset.addChild(new gui_GUISpacing(fullReset,new common_Point(2,2)));
var winGoal = city.progress.story.findGoal("Win");
if(city.progress.story.currentGoal == null && winGoal != null && winGoal.nextStory != null && winGoal.nextStory != "" && progress_StoryLoader.hasCompletedRequirements(city.game,Lambda.find(Resources.allStoriesInfo,function(sd) {
return sd.link == winGoal.nextStory;
}))) {
var textButton = new gui_TextButton(gui,stage,saveLoadButtons,function() {
var _g = ($_=city.game,$bind($_,$_.newCity));
var storyName = winGoal.nextStory;
var textButton = function(saveFileName) {
_g(storyName,saveFileName);
};
gui_SaveLoadWindows.createSaveWindow(city.game,city.gui,"Which save slot would you like to use?",textButton);
if(2 == 6 && Config.hadFullStepWithInput) {
common_AdHelper.showNonRewardedInterstitialIfAllowed();
}
},"Next Scenario",null);
fullReset.addChild(textButton);
textButton.extraWidth = 14;
textButton.setText("Next Scenario");
} else {
var doFullReset = null;
doFullReset = function() {
gui.createWindow();
gui.addWindowToStack(doFullReset);
gui.windowAddTitleText("Restart Scenario?");
gui.windowAddInfoText("Are you sure you'd like to restart the scenario from the beginning?");
gui.windowAddBottomButtons([{ text : "Restart", action : function() {
city.saveToBrowserStorage("preReset");
city.game.newCity(city.progress.story.storyName,city.cityFile);
city.saveToBrowserStorage();
gui_GameMenu.canUndoReset = true;
}}]);
if(2 == 6 && Config.hadFullStepWithInput) {
common_AdHelper.showNonRewardedInterstitialIfAllowed();
}
};
fullReset.addChild(new gui_TextButton(gui,stage,saveLoadButtons,doFullReset,"Restart Scenario",null));
}
gui.windowInner.addChild(fullReset);
if(gui_GameMenu.canUndoReset) {
gui.windowInner.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,2)));
var fullResetUndo = new gui_GUIContainer(gui,stage,null,new common_Point(0,0),new common_FPoint(0,0));
fullResetUndo.addChild(new gui_TextButton(gui,stage,fullReset,function() {
common_Storage.getItem("preReset",function(err,savedCity) {
gui_GameMenu.canUndoReset = false;
if(err == null || savedCity != null) {
city.game.loadFromTypedArray(savedCity,city.cityFile);
}
},true);
},"Undo Restart",null));
gui.windowInner.addChild(fullResetUndo);
}
gui.windowInner.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,6)));
if(2 == 3) {
var armorPromo = new gui_GUIContainer(gui,stage,null,new common_Point(0,0),new common_FPoint(0,0));
var playMoreButton = new gui_TextButton(gui,stage,fullReset,function() {
},"Play More Games",function() {
return false;
},function() {
city.game.setOnClickTo = function() {
window.open("http://armor.ag/MoreGames","_blank");
};
});
playMoreButton.extraWidth = 6;
playMoreButton.setText("Play More Games");
armorPromo.addChild(playMoreButton);
armorPromo.addChild(new gui_GUISpacing(armorPromo,new common_Point(2,2)));
var likeUsButton = new gui_TextButton(gui,stage,fullReset,function() {
},"Like Us!",function() {
return false;
},function() {
city.game.setOnClickTo = function() {
window.open("http://www.facebook.com/ArmorGames","_blank");
};
});
likeUsButton.extraWidth = 16;
likeUsButton.setText("Like Us!");
armorPromo.addChild(likeUsButton);
gui.windowInner.addChild(armorPromo);
gui.windowInner.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,6)));
}
var soundButtons = new gui_GUIContainer(gui,stage,null);
gui.windowInner.addChild(soundButtons);
var musicTextures = Resources.getTextures("spr_music",2);
var imgButton = null;
imgButton = new gui_ImageButton(gui,stage,soundButtons,function() {
city.game.audio.changeMusicEnabledness(!Settings.musicOn);
imgButton.imageSprite.texture = musicTextures[Settings.musicOn ? 0 : 1];
},musicTextures[Settings.musicOn ? 0 : 1],function() {
return false;
},function() {
gui.tooltip.setText(imgButton,Settings.musicOn ? "Mute Music" : "Unmute Music");
},null,imageButtonToUse,imageOffsetToUse);
imgButton.imageSprite.tint = 0;
soundButtons.addChild(imgButton);
soundButtons.addChild(new gui_GUISpacing(soundButtons,new common_Point(2,2)));
var soundTextures = Resources.getTextures("spr_sound",2);
var imgButton1 = null;
imgButton1 = new gui_ImageButton(gui,stage,soundButtons,function() {
city.game.audio.changeSoundEnabledness(!Settings.soundOn);
imgButton1.imageSprite.texture = soundTextures[Settings.soundOn ? 0 : 1];
},soundTextures[Settings.soundOn ? 0 : 1],function() {
return false;
},function() {
gui.tooltip.setText(imgButton1,Settings.soundOn ? "Mute Sound Effects" : "Unmute Sound Effects");
},null,imageButtonToUse,imageOffsetToUse);
imgButton1.imageSprite.tint = 0;
soundButtons.addChild(imgButton1);
soundButtons.addChild(new gui_GUISpacing(soundButtons,new common_Point(2,2)));
var moreSettingsTexture = Resources.getTexture("spr_moresettings");
var imgButton2;
var doCreateMoreSettingsWindow = null;
doCreateMoreSettingsWindow = function() {
gui.createWindow("moreSettingsWindow");
gui.addWindowToStack(doCreateMoreSettingsWindow);
gui_MoreSettingsWindow.create(city,gui,gui.innerWindowStage,gui.windowInner,imageButtonToUse,imageOffsetToUse);
};
imgButton2 = new gui_ImageButton(gui,stage,soundButtons,doCreateMoreSettingsWindow,moreSettingsTexture,function() {
return false;
},function() {
gui.tooltip.setText(imgButton2,"Advanced Settings");
},null,imageButtonToUse,imageOffsetToUse);
imgButton2.imageSprite.tint = 0;
soundButtons.addChild(imgButton2);
soundButtons.addChild(new gui_GUISpacing(soundButtons,new common_Point(6,2)));
if(Config.hasFullscreen && 2 != 8) {
var fullScreenTexture = Resources.getTexture("spr_fullscreen");
var imgButton3 = new gui_ImageButton(gui,stage,soundButtons,function() {
},fullScreenTexture,function() {
return false;
},function() {
gui.tooltip.setText(imgButton3,"Full Screen");
city.game.setOnClickTo = function() {
jsFunctions.goFullscreen(true);
};
},null,imageButtonToUse,imageOffsetToUse);
imgButton3.imageSprite.tint = 0;
soundButtons.addChild(imgButton3);
soundButtons.addChild(new gui_GUISpacing(soundButtons,new common_Point(2,2)));
}
if(!city.game.isMobile || !jsFunctions.isAnyApple()) {
var screenshotTexture = Resources.getTexture("spr_camera");
var imgButton4;
var city2 = city;
var imgButton5 = function() {
gui_GameMenu.saveScreenShot(city2);
};
imgButton4 = new gui_ImageButton(gui,stage,soundButtons,imgButton5,screenshotTexture,function() {
return false;
},function() {
gui.tooltip.setText(imgButton4,"Save Screenshot");
},null,imageButtonToUse,imageOffsetToUse);
imgButton4.imageSprite.tint = 0;
soundButtons.addChild(imgButton4);
soundButtons.addChild(new gui_GUISpacing(soundButtons,new common_Point(6,2)));
}
var creditsTexture = Resources.getTexture("spr_credits");
var imgButton5;
var doCreateCreditsWindow = null;
doCreateCreditsWindow = function() {
gui.createWindow("creditsWindow");
gui.addWindowToStack(doCreateCreditsWindow);
gui_CreditsWindow.create(city,gui,gui.innerWindowStage,gui.windowInner);
};
imgButton5 = new gui_ImageButton(gui,stage,soundButtons,doCreateCreditsWindow,creditsTexture,function() {
return false;
},function() {
gui.tooltip.setText(imgButton5,"View Credits");
},null,imageButtonToUse,imageOffsetToUse);
imgButton5.imageSprite.tint = 0;
soundButtons.addChild(imgButton5);
soundButtons.addChild(new gui_GUISpacing(soundButtons,new common_Point(2,2)));
var twitterButtonImage = Resources.getTexture("spr_twitter");
var imgButton6 = new gui_ImageButton(gui,stage,soundButtons,function() {
},twitterButtonImage,function() {
return false;
},function() {
gui.tooltip.setText(imgButton6,"Follow me @FlorianStrien on Twitter and get the latest news on updates and new games!");
city.game.setOnClickTo = function() {
window.open("https://twitter.com/FlorianStrien","_blank");
};
},null,imageButtonToUse,imageOffsetToUse);
imgButton6.imageSprite.tint = 0;
soundButtons.addChild(imgButton6);
soundButtons.addChild(new gui_GUISpacing(soundButtons,new common_Point(2,2)));
if(!Config.hasFullscreen) {
var mailingButtonImage = Resources.getTexture("spr_mailinglist");
var imgButton7 = new gui_ImageButton(gui,stage,soundButtons,function() {
},mailingButtonImage,function() {
return false;
},function() {
gui.tooltip.setText(imgButton7,"I'll send you cool The Final Earth 2 news and facts, plus info on my future releases!","Subscribe to my mailing list!");
city.game.setOnClickTo = function() {
window.open(Config.mailingListURL,"_blank");
};
},null,imageButtonToUse,imageOffsetToUse);
imgButton7.imageSprite.tint = 0;
soundButtons.addChild(imgButton7);
soundButtons.addChild(new gui_GUISpacing(soundButtons,new common_Point(2,2)));
}
gui.windowInner.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,6)));
if(Config.isLimitedDemo) {
var textButton = new gui_TextButton(gui,stage,gui.windowInner,function() {
greenworks.activateGameOverlayToWebPage("https://store.steampowered.com/app/1180130/The_Final_Earth_2/");
},"Wishlist Full Version!");
textButton.extraWidth = 48;
textButton.setText("Wishlist Full Version!");
gui.windowInner.addChild(textButton);
gui.windowInner.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,6)));
}
var _g = ($_=city.game,$bind($_,$_.createMainMenu));
var tmp = function() {
_g();
};
gui.windowAddBottomButtons([{ text : "Back to Title", action : tmp}]);
};
gui_GameMenu.saveScreenShot = function(city) {
var edges = city.getCityEdges();
var minX = edges.minX;
var maxX = edges.maxX;
var minY = edges.minY;
var maxY = edges.maxY;
var renderTexture = PIXI.RenderTexture.create(maxX - minX,maxY - minY,null,1);
var renderer = city.game.application.renderer;
var oldX = city.movingViewStage.position.x;
var oldY = city.movingViewStage.position.y;
var oldScale = city.movingViewStage.scale.x;
city.movingViewStage.position.x = -minX;
city.movingViewStage.position.y = -minY;
city.movingViewStage.scale.x = 1;
city.movingViewStage.scale.y = 1;
var sky = new PIXI.Graphics();
sky.beginFill(city.skyColor);
sky.drawRect(minX,minY,maxX - minX,maxY - minY);
sky.endFill();
city.movingViewStage.addChildAt(sky,0);
city.uncull();
renderer.render(city.movingViewStage,renderTexture,true,null,false);
var canvas = renderer.plugins.extract.canvas(renderTexture);
canvas.toBlob(function(blob) {
jsFunctions.saveAs(blob,"TheFinalEarth2_screenshot.png");
});
city.movingViewStage.position.x = oldX;
city.movingViewStage.position.y = oldY;
city.movingViewStage.scale.x = city.movingViewStage.scale.y = oldScale;
city.movingViewStage.removeChild(sky);
};
var gui_GlobalUpgradeWindow = function() { };
$hxClasses["gui.GlobalUpgradeWindow"] = gui_GlobalUpgradeWindow;
gui_GlobalUpgradeWindow.__name__ = "gui.GlobalUpgradeWindow";
gui_GlobalUpgradeWindow.create = function(city,gui,stage,$window) {
gui_GlobalUpgradeWindow.createWindow(city,gui,stage,$window);
};
gui_GlobalUpgradeWindow.createWindow = function(city,gui,stage,$window) {
gui.windowAllowBanner();
$window.clear();
city.gui.windowAddTitleText("Upgrades and Policies");
var buildingTypesWithUpgradeUnsorted = [];
var buildingTypesWithUpgradeClassNames = [];
var _g = 0;
var _g1 = city.permanents;
while(_g < _g1.length) {
var pm = _g1[_g];
++_g;
if(pm.isBuilding && (common_ArrayExtensions.any(pm.get_possibleUpgrades(),function(u) {
return city.progress.unlocks.getUnlockState(u) != progress_UnlockState.Locked;
}) || common_ArrayExtensions.any(pm.get_possibleCityUpgrades(),function(u) {
return city.progress.unlocks.getUnlockState(u) != progress_UnlockState.Locked;
}) || common_ArrayExtensions.any(pm.get_possiblePolicies(),function(u) {
return city.progress.unlocks.getUnlockState(u) != progress_UnlockState.Locked;
}))) {
var cls = js_Boot.getClass(pm);
var i = buildingTypesWithUpgradeUnsorted.indexOf(cls);
if(i == -1) {
i = buildingTypesWithUpgradeUnsorted.length;
buildingTypesWithUpgradeUnsorted.push(cls);
var splitClassName = cls.__name__.split(".");
buildingTypesWithUpgradeClassNames.push(splitClassName[splitClassName.length - 1]);
}
}
}
var buildingTypesWithUpgrade = [];
var _g = 0;
var _g1 = city.progress.resources.buildingInfoArray;
while(_g < _g1.length) {
var bi = _g1[_g];
++_g;
var i = buildingTypesWithUpgradeClassNames.indexOf(bi.className);
if(i != -1) {
buildingTypesWithUpgrade.push(buildingTypesWithUpgradeUnsorted[i]);
}
}
var _g = 0;
var _g1 = buildingTypesWithUpgrade.length;
while(_g < _g1) {
var i = _g++;
var buildingType = [buildingTypesWithUpgrade[i]];
var buildingTypeContainer = new gui_GUIContainer(gui,gui.innerWindowStage,gui.windowInner);
var this1 = city.progress.resources.buildingInfo;
var key = buildingType[0].__name__;
var buildingInfo = this1.h[key];
buildingTypeContainer.addChild(gui_BuildingTypeImage.create(stage,city,buildingType[0],buildingTypeContainer,gui));
buildingTypeContainer.addChild(new gui_TextElement(buildingTypeContainer,gui.innerWindowStage,buildingInfo.name,null,"Arial16",{ top : 3, left : 3, right : 0, bottom : 0}));
gui.windowInner.addChildWithoutSizeUpdate(buildingTypeContainer);
gui_CreateBuildingUpgrades.createBuildingUpgradesForType(Lambda.find(city.permanents,(function(buildingType) {
return function(pm) {
return pm.is(buildingType[0]);
};
})(buildingType)),city);
if(buildingType[0] == buildings_Laboratory) {
gui_GlobalUpgradeWindow.addSmartUpgradeForLabs(city);
}
}
gui.windowInner.updateSize();
if(buildingTypesWithUpgrade.length == 0) {
city.gui.windowInner.addChild(new gui_TextElement(city.gui.windowInner,city.gui.innerWindowStage,"No upgrades available."));
}
gui.windowAddBottomButtons();
var city1 = city;
var gui1 = gui;
var stage1 = stage;
var window1 = $window;
var tmp = function() {
gui_GlobalUpgradeWindow.createWindow(city1,gui1,stage1,window1);
};
city.gui.setWindowReload(tmp);
var _g = ($_=city.gui,$bind($_,$_.reloadWindow));
var city2 = city;
var gui2 = gui;
var stage2 = stage;
var window2 = $window;
var createWindowFunc = function() {
gui_GlobalUpgradeWindow.createWindow(city2,gui2,stage2,window2);
};
var tmp = function() {
_g(createWindowFunc);
};
city.windowRelatedOnBuildOrDestroy = tmp;
$window.onDestroy = function() {
city.windowRelatedOnBuildOrDestroy = null;
};
};
gui_GlobalUpgradeWindow.addSmartUpgradeForLabs = function(city) {
var upgradeCost = new Materials();
var upgrade1 = buildingUpgrades_FarmingResearch;
var upgrade2 = buildingUpgrades_TreePlantationResearch;
var _g = [];
var _g1 = 0;
var _g2 = city.permanents;
while(_g1 < _g2.length) {
var v = _g2[_g1];
++_g1;
if(v.is(buildings_Laboratory) && v.getEffectsOfAdjecentBuildings("farm") > 0 && !common_ArrayExtensions.any(v.upgrades,function(up) {
return js_Boot.__instanceof(up,upgrade1);
})) {
_g.push(v);
}
}
var relevantLabs1 = _g;
var _g = [];
var _g1 = 0;
var _g2 = city.permanents;
while(_g1 < _g2.length) {
var v = _g2[_g1];
++_g1;
if(v.is(buildings_Laboratory) && (v.leftBuilding != null && v.leftBuilding.is(buildings_TreePlantation) || v.rightBuilding != null && v.rightBuilding.is(buildings_TreePlantation) || v.topBuilding != null && v.topBuilding.is(buildings_TreePlantation) || v.bottomBuilding != null && v.bottomBuilding.is(buildings_TreePlantation)) && !common_ArrayExtensions.any(v.upgrades,function(up) {
return js_Boot.__instanceof(up,upgrade2);
})) {
_g.push(v);
}
}
var relevantLabs2 = _g;
var doesNotHaveUpgrade = relevantLabs1.length > 0 || relevantLabs2.length > 0;
var infoContainerInfo = gui_UpgradeWindowParts.createActivatableButton(city.gui,!doesNotHaveUpgrade,function() {
if(city.materials.canAfford(upgradeCost)) {
city.materials.remove(upgradeCost);
var _g = 0;
while(_g < relevantLabs1.length) {
var building = relevantLabs1[_g];
++_g;
building.upgrades.push(Type.createInstance(upgrade1,[building.stage,city.cityMidStage,building.bgStage,building]));
}
var _g = 0;
while(_g < relevantLabs2.length) {
var building = relevantLabs2[_g];
++_g;
building.upgrades.push(Type.createInstance(upgrade2,[building.stage,city.cityMidStage,building.bgStage,building]));
}
Audio.get().playSound(Audio.get().buildingUpgradeSound);
city.gui.reloadWindow();
}
},"Auto-Upgrade","Upgrade all labs with the relevant upgrade(s) for their adjacent buildings.",city.gui.windowInner,null);
if(infoContainerInfo.button != null) {
infoContainerInfo.button.buttonSound = null;
}
var this1 = Resources.buildingUpgradesInfo;
var key = upgrade1.__name__;
var origCost1 = Materials.fromBuildingUpgradesInfo(this1.h[key]);
upgradeCost = origCost1.copy();
upgradeCost.multiply(relevantLabs1.length);
var this1 = Resources.buildingUpgradesInfo;
var key = upgrade2.__name__;
var origCost2 = Materials.fromBuildingUpgradesInfo(this1.h[key]);
var upgradeCost2 = origCost2.copy();
upgradeCost2.multiply(relevantLabs2.length);
if(city.progress.unlocks.getUnlockState(upgrade1) == progress_UnlockState.Researched) {
upgradeCost.knowledge = 0;
} else {
upgradeCost.knowledge = Math.min(upgradeCost.knowledge,origCost1.knowledge);
}
if(city.progress.unlocks.getUnlockState(upgrade2) == progress_UnlockState.Researched) {
upgradeCost2.knowledge = 0;
} else {
upgradeCost2.knowledge = Math.min(upgradeCost2.knowledge,origCost2.knowledge);
}
upgradeCost.add(upgradeCost2);
if(doesNotHaveUpgrade) {
if(upgradeCost.any()) {
var mcdContainer = new gui_GUIContainer(city.gui,city.gui.innerWindowStage,infoContainerInfo.container);
var mcd = new gui_MaterialsCostDisplay(city,upgradeCost,"");
mcdContainer.addChild(new gui_ContainerHolder(mcdContainer,city.gui.innerWindowStage,mcd,{ left : 0, right : 0, top : 0, bottom : 2},$bind(mcd,mcd.updateCostDisplay)));
infoContainerInfo.container.addChild(mcdContainer);
}
}
city.gui.windowInner.addChild(new gui_GUISpacing(city.gui.windowInner,new common_Point(2,4)));
};
var gui_HappinessWindow = function() { };
$hxClasses["gui.HappinessWindow"] = gui_HappinessWindow;
gui_HappinessWindow.__name__ = "gui.HappinessWindow";
gui_HappinessWindow.create = function(city,gui,stage,$window) {
gui.windowAllowBanner();
gui.windowAddTitleText("Happiness",null,Resources.getTexture("spr_happiness"));
var lineHeight = 12;
var mainContainer = new gui_GUIContainer(gui,stage,$window);
$window.addChild(mainContainer);
var mainTexts = new gui_GUIContainer(gui,stage,mainContainer);
mainTexts.direction = gui_GUIContainerDirection.Vertical;
mainContainer.addChild(mainTexts);
var mainNumbers = new gui_GUIContainer(gui,stage,mainContainer);
mainNumbers.direction = gui_GUIContainerDirection.Vertical;
mainContainer.addChild(mainNumbers);
var addTexts = function(getText,getText2,isVisible,paddingLeft,paddingTop) {
if(paddingTop == null) {
paddingTop = 0;
}
if(paddingLeft == null) {
paddingLeft = 0;
}
var mainTextsHider = new gui_HideableContainer(mainTexts,isVisible);
var mainTextsChild = new gui_GUIContainer(gui,stage,mainTextsHider,null,null,null,null,{ left : paddingLeft, right : 0, bottom : 0, top : paddingTop});
mainTextsChild.addChild(new gui_TextElement(mainTextsChild,stage,null,getText,null,null,null,true));
mainTextsChild.addChild(new gui_GUISpacing(mainTextsChild,new common_Point(5,lineHeight)));
mainTextsHider.setChild(mainTextsChild);
mainTexts.addChild(mainTextsHider);
var mainNumbersHider = new gui_HideableContainer(mainNumbers,isVisible);
var mainNumbersChilds = new gui_GUIContainer(gui,stage,mainNumbersHider,null,null,null,null,{ left : 0, right : 0, bottom : 0, top : paddingTop});
mainNumbersChilds.addChild(new gui_TextElement(mainNumbersChilds,stage,null,getText2,null,null,null,true));
mainNumbersChilds.addChild(new gui_GUISpacing(mainNumbersChilds,new common_Point(0,lineHeight)));
mainNumbersHider.setChild(mainNumbersChilds);
mainNumbers.addChild(mainNumbersHider);
};
var happiness = city.simulation.happiness;
addTexts(function() {
return "Home happiness:";
},function() {
return "" + (happiness.homeHappiness | 0);
});
addTexts(function() {
return "Sense of purpose (job/school):";
},function() {
return "" + (happiness.purposeHappiness | 0);
});
addTexts(function() {
return "Entertainment happiness:";
},function() {
return "" + (happiness.entertainmentHappiness | 0);
});
var happiness1 = city.simulation.happiness;
var _g = 0;
var _g1 = happiness1.entertainmentTypes.length;
while(_g < _g1) {
var i = [_g++];
var entertainmentType = [happiness1.entertainmentTypes[i[0]]];
addTexts((function(entertainmentType) {
return function() {
return simulation_EntertainmentTypeHelpers.getName(entertainmentType[0]) + ":";
};
})(entertainmentType),(function(i) {
return function() {
return "" + (happiness1.happinessPerEntertainmentType[i[0]] | 0);
};
})(i),null,10);
}
addTexts(function() {
return "Education happiness:";
},function() {
return "" + (happiness1.schoolHappiness | 0);
});
addTexts(function() {
return "Medical happiness:";
},function() {
return "" + (happiness1.medicalHappiness | 0);
});
addTexts(function() {
return "Food shortage unhappiness:";
},function() {
return "-" + (happiness1.foodShortageUnhappiness | 0);
},function() {
return happiness1.foodShortageUnhappiness > 0;
});
addTexts(function() {
return "Food rationing unhappiness:";
},function() {
return "-" + (happiness1.foodRationingUnhappiness | 0);
},function() {
return happiness1.foodRationingUnhappiness > 0;
});
addTexts(function() {
return "Mandatory overtime unhappiness:";
},function() {
return "-" + happiness1.overtimeUnhappinessShown;
},function() {
return happiness1.overtimeUnhappinessShown > 0;
});
addTexts(function() {
return "New city enthusiasm bonus:";
},function() {
return "+" + (happiness1.enthusiasmHappiness | 0);
},function() {
return happiness1.enthusiasmHappiness != 0;
});
addTexts(function() {
var res = "";
var _g = 0;
var _g1 = happiness1.happinessBoosts;
while(_g < _g1.length) {
var bst = _g1[_g];
++_g;
if(res != "") {
res += "\n";
}
res += "" + bst.text + ":";
}
return res;
},function() {
var res = "";
var _g = 0;
var _g1 = happiness1.happinessBoosts;
while(_g < _g1.length) {
var bst = _g1[_g];
++_g;
if(res != "") {
res += "\n";
}
res += "+" + (bst.boost | 0);
}
return res;
},function() {
return happiness1.happinessBoosts.length > 0;
},0,4);
addTexts(function() {
return "Total Happiness:";
},function() {
return "" + (happiness1.happiness | 0);
},null,0,4);
addTexts(function() {
return "Work Speed Modifier:";
},function() {
return "" + common_MathExtensions.floatFormat(Math,happiness1.actionSpeedModifier,2);
});
gui.windowAddBottomButtons();
};
var gui_HelpArrowDirection = $hxEnums["gui.HelpArrowDirection"] = { __ename__ : "gui.HelpArrowDirection", __constructs__ : ["Down","Left","DownHint"]
,Down: {_hx_index:0,__enum__:"gui.HelpArrowDirection",toString:$estr}
,Left: {_hx_index:1,__enum__:"gui.HelpArrowDirection",toString:$estr}
,DownHint: {_hx_index:2,__enum__:"gui.HelpArrowDirection",toString:$estr}
};
var gui_HelpArrow = function(gui,stage,getPointsTo,isActive,direction,onlyVisibleAfter) {
if(onlyVisibleAfter == null) {
onlyVisibleAfter = 0;
}
this.pleaseAlignExtraTextRight = false;
this.circleTme = Math.PI / 2;
this.arrowTime = 0;
this.gui = gui;
this.getPointsTo = getPointsTo;
this.stage = stage;
this.isActive = isActive;
this.direction = direction == null ? gui_HelpArrowDirection.Down : direction;
this.onlyVisibleAfter = onlyVisibleAfter;
switch(this.direction._hx_index) {
case 0:
this.sprite = new PIXI.Sprite(Resources.getTexture("spr_tutorialarrowdown"));
this.sprite.anchor.set(0.5,1);
break;
case 1:
this.sprite = new PIXI.Sprite(Resources.getTexture("spr_tutorialarrowleft"));
this.sprite.anchor.set(0,0.5);
break;
case 2:
this.sprite = new PIXI.Sprite(Resources.getTexture("spr_hintinfo_arrow"));
this.sprite.anchor.set(0.5,1);
break;
}
stage.addChild(this.sprite);
this.extraText9P = null;
this.extraText = "";
this.extraTextElement = null;
this.setPosition();
};
$hxClasses["gui.HelpArrow"] = gui_HelpArrow;
gui_HelpArrow.__name__ = "gui.HelpArrow";
gui_HelpArrow.prototype = {
useBigMovement: function() {
this.useCircle = true;
this.setPosition();
}
,addText: function(text) {
if(this.extraTextElement != null) {
this.extraText = text;
this.extraTextElement.text = text;
this.setExtraTextPosition();
return;
}
this.extraText = text;
this.extraTextElement = new PIXI.extras.BitmapText(text,{ font : "Arial", tint : 0});
if(text.length < 45) {
this.extraTextElement.maxWidth = 133;
} else {
this.extraTextElement.maxWidth = 200;
}
this.extraText9P = new gui_NinePatch(Resources.getTexture("spr_9p_hintinfo"),5,(this.extraTextElement.width | 0) + 6,(this.extraTextElement.height | 0) + 6);
this.stage.addChild(this.extraText9P);
this.stage.addChild(this.extraTextElement);
this.setExtraTextPosition();
}
,update: function(timeMod) {
var pointsTo;
var tmp;
if(this.isActive() && this.arrowTime >= this.onlyVisibleAfter) {
pointsTo = this.getPointsTo();
tmp = pointsTo != null;
} else {
tmp = false;
}
if(tmp && this.useCircle && this.circleTme > 0) {
this.circleTme -= 0.015 * timeMod + 0.04 * timeMod * (this.circleTme / (Math.PI / 2));
}
this.arrowTime += timeMod;
this.setPosition();
this.setExtraTextPosition();
}
,destroy: function() {
this.stage.removeChild(this.sprite);
if(this.extraText9P != null) {
this.extraText9P.destroy();
}
if(this.extraTextElement != null) {
this.extraTextElement.destroy();
}
}
,setPosition: function() {
var pointsTo;
var tmp;
if(this.isActive() && this.arrowTime >= this.onlyVisibleAfter) {
pointsTo = this.getPointsTo();
tmp = pointsTo != null;
} else {
tmp = false;
}
if(tmp) {
switch(this.direction._hx_index) {
case 0:
this.sprite.position.set(pointsTo.rect.get_center().x,pointsTo.rect.y - 2 - Math.sin(this.arrowTime / 10) * 2);
break;
case 1:
this.sprite.position.set(pointsTo.rect.get_x2() + 2 + Math.sin(this.arrowTime / 10) * 2,pointsTo.rect.get_center().y);
break;
case 2:
if(this.pleaseAlignExtraTextRight) {
this.sprite.position.set(this.gui.game.rect.width - 5 - this.sprite.width,pointsTo.rect.y - 2);
} else {
this.sprite.position.set(pointsTo.rect.get_center().x,pointsTo.rect.y - 2);
}
break;
}
if(this.useCircle && this.circleTme > 0) {
if(this.sprite.position.x < this.gui.game.rect.width / 2) {
this.sprite.rotation = this.circleTme;
} else {
this.sprite.rotation = -this.circleTme;
}
this.sprite.position.set(Math.cos(this.circleTme) * (this.sprite.position.x - this.gui.game.rect.width / 2) + this.gui.game.rect.width / 2,Math.sin(this.circleTme) * (this.gui.game.rect.height / 2 - this.sprite.position.y) + this.sprite.position.y);
this.sprite.alpha = Math.cos(this.circleTme);
} else {
this.sprite.rotation = 0;
this.sprite.alpha = 1;
}
this.sprite.visible = true;
} else {
this.sprite.visible = false;
}
}
,setExtraTextPosition: function() {
if(this.extraText9P == null) {
return;
}
var pointsTo;
var tmp;
if(this.isActive() && this.arrowTime >= this.onlyVisibleAfter) {
pointsTo = this.getPointsTo();
tmp = pointsTo != null;
} else {
tmp = false;
}
if(tmp) {
switch(this.direction._hx_index) {
case 0:
if(pointsTo.rect.get_center().x > this.extraText9P.width + 5 + Math.floor(this.sprite.width / 2)) {
this.extraText9P.position.set(pointsTo.rect.get_center().x - Math.floor(this.sprite.width / 2) - 2 - this.extraText9P.width,pointsTo.rect.y - 2 - this.extraText9P.height);
} else {
this.extraText9P.position.set(pointsTo.rect.get_center().x + Math.floor(this.sprite.width / 2) + 2,pointsTo.rect.y - 2 - this.extraText9P.height);
}
break;
case 1:
if(pointsTo.rect.get_x2() + this.extraText9P.width > this.gui.game.rect.width) {
this.extraText9P.position.set(this.gui.game.rect.width - this.extraText9P.width - 5,pointsTo.rect.get_center().y - 2 - Math.floor(this.sprite.height / 2) - this.extraText9P.height);
} else {
this.extraText9P.position.set(pointsTo.rect.get_x2(),pointsTo.rect.get_center().y - 2 - Math.floor(this.sprite.height / 2) - this.extraText9P.height);
}
break;
case 2:
if(this.pleaseAlignExtraTextRight) {
this.extraText9P.position.set(this.gui.game.rect.width - 5 - this.extraText9P.width,pointsTo.rect.y - 2 - this.sprite.height - this.extraText9P.height);
} else if(pointsTo.rect.get_center().x > this.extraText9P.width + 5 + Math.floor(this.sprite.width / 2)) {
this.extraText9P.position.set(pointsTo.rect.get_center().x - this.extraText9P.width + Math.floor(this.sprite.width / 2),pointsTo.rect.y - 2 - this.sprite.height - this.extraText9P.height);
} else if(pointsTo.rect.get_center().x - this.sprite.width + this.extraText9P.width < this.gui.game.rect.width) {
this.extraText9P.position.set(pointsTo.rect.get_center().x - Math.floor(this.sprite.width / 2),pointsTo.rect.y - 2 - this.sprite.height - this.extraText9P.height);
} else {
this.extraText9P.position.set(5,pointsTo.rect.y - 2 - this.sprite.height - this.extraText9P.height);
}
break;
}
this.extraTextElement.position.set(this.extraText9P.position.x + 3,this.extraText9P.position.y + 2);
this.extraTextElement.visible = true;
this.extraText9P.visible = true;
} else {
this.extraText9P.visible = false;
this.extraTextElement.visible = false;
}
}
,__class__: gui_HelpArrow
};
var gui_HideableContainer = function(parent,isShown) {
this.alwaysUpdateChild = false;
this.visible = true;
this.parent = parent;
this.isShown = isShown;
this.rect = new common_Rectangle(0,0,0,0);
};
$hxClasses["gui.HideableContainer"] = gui_HideableContainer;
gui_HideableContainer.__name__ = "gui.HideableContainer";
gui_HideableContainer.__interfaces__ = [gui_IGUIElement];
gui_HideableContainer.prototype = {
show: function() {
this.visible = true;
this.updateSize();
}
,hide: function() {
this.visible = false;
this.child.updatePosition(new common_Point(-10000,-10000));
this.updateSize();
}
,setChild: function(child) {
this.child = child;
this.updateSize();
if(this.isShown != null) {
this.visible = this.isShown();
if(!this.visible) {
this.hide();
}
}
}
,updateSize: function() {
if(this.visible && this.child != null) {
this.rect = this.child.rect;
} else {
this.rect.width = 0;
this.rect.height = 0;
}
if(this.parent != null) {
this.parent.updateSize();
}
}
,updatePosition: function(newPosition) {
if(this.visible && this.child != null) {
this.child.updatePosition(newPosition);
}
}
,destroy: function() {
if(this.child != null) {
this.child.destroy();
}
}
,handleMouse: function(mouse) {
if(this.visible && this.child != null) {
return this.child.handleMouse(mouse);
}
return false;
}
,update: function() {
if(this.isShown != null) {
var newVisible = this.isShown();
if(newVisible != this.visible) {
this.visible = newVisible;
if(this.visible) {
this.show();
} else {
this.hide();
}
}
}
if((this.visible || this.alwaysUpdateChild) && this.child != null) {
this.child.update();
}
}
,__class__: gui_HideableContainer
};
var gui_HouseInformationWindow = function() { };
$hxClasses["gui.HouseInformationWindow"] = gui_HouseInformationWindow;
gui_HouseInformationWindow.__name__ = "gui.HouseInformationWindow";
gui_HouseInformationWindow.create = function(city,gui,stage,$window) {
gui_HouseInformationWindow.createWindow(city,gui,stage,$window);
};
gui_HouseInformationWindow.createWindow = function(city,gui,stage,$window) {
$window.clear();
gui.windowAddTitleText("Housing Information",null,Resources.getTexture("spr_housing"));
$window.addChild(new gui_TextElement($window,stage,null,function() {
return gui_HouseInformationWindow.getHousingHelpText(city.simulation.stats);
}));
var homeTypesUnsorted = [];
var homeTypeClassNames = [];
var _g = 0;
var _g1 = city.permanents;
while(_g < _g1.length) {
var pm = _g1[_g];
++_g;
if(pm.is(buildings_House)) {
var cls = js_Boot.getClass(pm);
var i = homeTypesUnsorted.indexOf(cls);
if(i == -1) {
i = homeTypesUnsorted.length;
homeTypesUnsorted.push(cls);
var splitClassName = cls.__name__.split(".");
homeTypeClassNames.push(splitClassName[splitClassName.length - 1]);
}
}
}
var buildingTypesWithJob = [];
var _g = 0;
var _g1 = city.progress.resources.buildingInfoArray;
while(_g < _g1.length) {
var bi = _g1[_g];
++_g;
var i = homeTypeClassNames.indexOf(bi.className);
if(i != -1) {
buildingTypesWithJob.push(homeTypesUnsorted[i]);
}
}
var allBuildingTypeData = [];
var updateBuildingTypeData = function() {
allBuildingTypeData = [];
var _g = 0;
while(_g < buildingTypesWithJob.length) {
var bt = buildingTypesWithJob[_g];
++_g;
allBuildingTypeData.push({ number : 0, filledHousing : 0, housing : 0});
}
var _g = 0;
var _g1 = city.permanents;
while(_g < _g1.length) {
var pm = _g1[_g];
++_g;
if(pm.is(buildings_House)) {
var thisHouse = pm;
var cls = js_Boot.getClass(pm);
var i = buildingTypesWithJob.indexOf(cls);
if(i != -1) {
var data = allBuildingTypeData[i];
data.housing += thisHouse.get_residentCapacity();
data.filledHousing += thisHouse.residents.length;
data.number += 1;
}
}
}
};
updateBuildingTypeData();
$window.onUpdate = updateBuildingTypeData;
var infoPadding = { left : 2, top : 5, bottom : 0, right : 0};
var singleRowHeight = 20;
var singleRowHeightWithoutPadding = singleRowHeight - 5;
var buildingOptionsContainer = new gui_GUIContainer(gui,stage,$window);
var buildingPictures = new gui_GUIContainer(gui,stage,buildingOptionsContainer);
var buildingWorkerNumbersContainer = new gui_GUIContainer(gui,stage,buildingOptionsContainer);
buildingPictures.direction = gui_GUIContainerDirection.Vertical;
buildingWorkerNumbersContainer.direction = gui_GUIContainerDirection.Vertical;
var _g = 0;
var _g1 = buildingTypesWithJob.length;
while(_g < _g1) {
var i = [_g++];
var buildingType = buildingTypesWithJob[i[0]];
var className = buildingType.__name__;
var buildingTypeData = allBuildingTypeData[i[0]];
var thisBuildingPictureContainer = new gui_GUIContainer(gui,stage,buildingPictures);
var cont = new PIXI.Container();
var sprName = Reflect.field(buildingType,"spriteName");
var this1 = city.progress.resources.buildingInfo;
var key = buildingType.__name__;
var buildingInfo = [this1.h[key]];
cont.addChild(Resources.makeSprite(buildingInfo[0].buttonBack == null ? "" + sprName + "@44,0,20,20" : buildingInfo[0].buttonBack));
cont.addChild(Resources.makeSprite("" + sprName + "@0,0,20,20"));
var ch = [null];
ch[0] = new gui_ContainerHolder(thisBuildingPictureContainer,stage,cont,null,null,(function(ch,buildingInfo) {
return function(mouse) {
if(ch[0].rect.contains(mouse.position)) {
gui.tooltip.setText(ch[0],buildingInfo[0].name);
return true;
}
return false;
};
})(ch,buildingInfo));
thisBuildingPictureContainer.addChild(ch[0]);
var thisBuildingNumberContainer = new gui_GUIContainer(gui,stage,thisBuildingPictureContainer,null,null,null,null,infoPadding);
thisBuildingNumberContainer.addChild(new gui_TextElement(thisBuildingNumberContainer,stage,"x" + buildingTypeData.number + ": "));
thisBuildingPictureContainer.addChild(thisBuildingNumberContainer);
buildingPictures.addChild(thisBuildingPictureContainer);
var workerNumberContainer = new gui_GUIContainer(gui,stage,buildingWorkerNumbersContainer,null,null,null,null,infoPadding);
workerNumberContainer.minHeight = singleRowHeightWithoutPadding;
workerNumberContainer.addChild(new gui_TextElement(workerNumberContainer,stage,null,(function(i) {
return function() {
return "" + allBuildingTypeData[i[0]].filledHousing + "/" + allBuildingTypeData[i[0]].housing + " residents";
};
})(i)));
buildingWorkerNumbersContainer.addChild(workerNumberContainer);
}
if(buildingTypesWithJob.length == 0) {
gui.windowAddInfoText("There are no houses!");
}
buildingOptionsContainer.addChild(buildingPictures);
buildingOptionsContainer.addChild(buildingWorkerNumbersContainer);
$window.addChild(buildingOptionsContainer);
var _g = ($_=city.gui,$bind($_,$_.reloadWindow));
var city1 = city;
var gui1 = gui;
var stage1 = stage;
var window1 = $window;
var createWindowFunc = function() {
gui_HouseInformationWindow.createWindow(city1,gui1,stage1,window1);
};
var tmp = function() {
_g(createWindowFunc);
};
city.windowRelatedOnBuildOrDestroy = tmp;
$window.onDestroy = function() {
city.windowRelatedOnBuildOrDestroy = null;
};
gui.windowAddBottomButtons();
};
gui_HouseInformationWindow.getHousingHelpText = function(stats) {
if(stats.peopleWithHome >= stats.people) {
if(stats.houseCapacity == stats.peopleWithHome) {
return "There are exactly enough homes for your citizens.";
} else {
return "There's " + (stats.houseCapacity - stats.peopleWithHome) + " house capacity remaining.";
}
} else {
var homeless = stats.people - stats.peopleWithHome;
if(homeless == 1) {
return "There's one homeless person.";
} else {
return "There are " + homeless + " homeless people.";
}
}
};
var gui_IconListDisplay = function(displayedIcons) {
PIXI.Container.call(this);
this.setDisplay(displayedIcons);
};
$hxClasses["gui.IconListDisplay"] = gui_IconListDisplay;
gui_IconListDisplay.__name__ = "gui.IconListDisplay";
gui_IconListDisplay.__super__ = PIXI.Container;
gui_IconListDisplay.prototype = $extend(PIXI.Container.prototype,{
wouldChangeDisplay: function(newIcons) {
if(this.displayedIcons.length != newIcons.length) {
return true;
}
var _g = 0;
var _g1 = this.displayedIcons.length;
while(_g < _g1) {
var i = _g++;
if(newIcons[i].texture != this.displayedIcons[i].texture || newIcons[i].text != this.displayedIcons[i].text) {
return true;
}
}
return false;
}
,setDisplay: function(displayedIcons) {
this.displayedIcons = displayedIcons;
var i = this.children.length;
while(--i >= 0) this.children.splice(i,1);
var xx = 0;
var _g = 0;
while(_g < displayedIcons.length) {
var displayedIcon = displayedIcons[_g];
++_g;
var spr = new PIXI.Sprite(displayedIcon.texture);
spr.position.x = xx;
this.addChild(spr);
xx += (spr.width | 0) + 2;
var displayText = displayedIcon.text;
var col = 0;
if(HxOverrides.substr(displayedIcon.text,0,"[red]".length) == "[red]") {
displayText = HxOverrides.substr(displayText,"[red]".length,null);
col = 16711680;
}
var bitmapText = new PIXI.extras.BitmapText(displayText,{ font : "Arial", tint : col});
if(displayText == "1") {
--xx;
}
bitmapText.position.set(xx,-1);
if(displayText == "1") {
--xx;
}
this.addChild(bitmapText);
xx += (bitmapText.textWidth | 0) + 3;
}
this.displayWidth = xx;
}
,__class__: gui_IconListDisplay
});
var gui_ImageButton = function(gui,stage,parent,action,spriteTexture,isActive,onHover,backSpriteTexture,buttonSpriteName,imageSpriteOffset) {
if(imageSpriteOffset == null) {
imageSpriteOffset = 1;
}
if(buttonSpriteName == null) {
buttonSpriteName = "spr_buildingbutton";
}
this.needsAttention = false;
this.attentionGetterSprite = null;
this.imageSpriteOffset = 1;
this.removeNotificationOnHover = true;
this.shown = true;
gui_Button.call(this,gui,stage,parent,action,isActive,onHover);
this.buttonTextures = Resources.getTextures(buttonSpriteName,3);
this.buttonSprite = new PIXI.Sprite(this.buttonTextures[0]);
stage.addChild(this.buttonSprite);
if(backSpriteTexture != null) {
this.imageSpriteBack = new PIXI.Sprite(backSpriteTexture);
this.imageSpriteBack.position.set(1,1);
stage.addChild(this.imageSpriteBack);
}
this.imageSpriteOffset = imageSpriteOffset;
this.imageSprite = new PIXI.Sprite(spriteTexture);
this.imageSprite.position.set(imageSpriteOffset,imageSpriteOffset);
stage.addChild(this.imageSprite);
this.rect = new common_Rectangle(0,0,(spriteTexture.width | 0) + imageSpriteOffset * 2,(spriteTexture.height | 0) + imageSpriteOffset * 2);
};
$hxClasses["gui.ImageButton"] = gui_ImageButton;
gui_ImageButton.__name__ = "gui.ImageButton";
gui_ImageButton.__super__ = gui_Button;
gui_ImageButton.prototype = $extend(gui_Button.prototype,{
updateTexture: function(newTexture) {
this.imageSprite.texture = newTexture;
}
,updatePosition: function(newPosition) {
gui_Button.prototype.updatePosition.call(this,newPosition);
this.buttonSprite.position.set(newPosition.x,newPosition.y);
this.imageSprite.position.set(newPosition.x + this.imageSpriteOffset,newPosition.y + this.imageSpriteOffset);
if(this.imageSpriteBack != null) {
this.imageSpriteBack.position.set(newPosition.x + 1,newPosition.y + 1);
}
if(this.imageSpriteForeground != null) {
this.imageSpriteForeground.position.set(newPosition.x,newPosition.y);
}
if(this.attentionGetterSprite != null) {
this.attentionGetterSprite.position.set(newPosition.x,newPosition.y);
}
}
,handleMouse: function(mouse) {
var _gthis = this;
if(!this.shown) {
return false;
}
return gui_Button.prototype.doHandleMouse.call(this,mouse,function() {
_gthis.buttonSprite.texture = _gthis.buttonTextures[1];
if(_gthis.removeNotificationOnHover) {
_gthis.stopNotify();
}
},function() {
_gthis.buttonSprite.texture = _gthis.buttonTextures[2];
_gthis.stopNotify();
});
}
,update: function() {
if(this.mouseOut) {
this.buttonSprite.texture = this.buttonTextures[0];
}
if(this.isActive()) {
this.buttonSprite.texture = this.buttonTextures[2];
}
this.updateNeedsAttention();
gui_Button.prototype.update.call(this);
}
,setNeedsAttention: function(needsAttention) {
if(needsAttention == null) {
needsAttention = false;
}
this.needsAttention = needsAttention;
this.updateNeedsAttention();
}
,updateNeedsAttention: function() {
if(this.buttonSprite == null) {
return;
}
if(this.needsAttention && this.buttonSprite.texture == this.buttonTextures[0]) {
if(this.attentionGetterSprite == null) {
this.attentionGetterSprite = new PIXI.Sprite(Resources.getTexture("spr_whiteoutline"));
this.attentionGetterSprite.position.set(this.buttonSprite.position.x,this.buttonSprite.position.y);
if(this.buttonSprite.parent != null) {
this.buttonSprite.parent.addChild(this.attentionGetterSprite);
}
}
var this1 = [89,1,0.77];
var tmp = thx_color_Hsv.toRgb(this1);
this.attentionGetterSprite.tint = common_ColorExtensions.toHexInt(tmp);
this.attentionGetterSprite.alpha = (Math.sin(this.gui.guiTimer / 10) + 1) / 2;
} else if(this.attentionGetterSprite != null) {
if(!this.needsAttention) {
this.attentionGetterSprite.destroy();
this.attentionGetterSprite = null;
} else {
this.attentionGetterSprite.alpha = 0;
}
}
}
,destroy: function() {
gui_Button.prototype.destroy.call(this);
this.stage.removeChild(this.buttonSprite);
this.stage.removeChild(this.imageSprite);
if(this.imageSpriteBack != null) {
this.stage.removeChild(this.imageSpriteBack);
}
if(this.imageSpriteForeground != null) {
this.stage.removeChild(this.imageSpriteForeground);
}
if(this.attentionGetterSprite != null) {
this.attentionGetterSprite.destroy();
}
}
,hide: function() {
if(this.imageSpriteBack != null) {
this.imageSpriteBack.visible = false;
}
this.imageSprite.visible = false;
this.buttonSprite.visible = false;
if(this.imageSpriteForeground != null) {
this.imageSpriteForeground.visible = false;
}
if(this.attentionGetterSprite != null) {
this.attentionGetterSprite.visible = false;
}
this.shown = false;
}
,show: function() {
if(this.imageSpriteBack != null) {
this.imageSpriteBack.visible = true;
}
this.imageSprite.visible = true;
this.buttonSprite.visible = true;
if(this.imageSpriteForeground != null) {
this.imageSpriteForeground.visible = true;
}
if(this.attentionGetterSprite != null) {
this.attentionGetterSprite.visible = true;
}
this.shown = true;
}
,notify: function(removeNotificationOnHover,onRemove) {
this.removeNotificationOnHover = removeNotificationOnHover;
if(this.imageSpriteForeground != null) {
return;
}
this.imageSpriteForeground = new PIXI.Sprite(Resources.getTexture("spr_buttonnotification"));
var _this = this.rect;
var _this_x = _this.x;
var _this_y = _this.y;
var tmp = new PIXI.Point(_this_x,_this_y);
this.imageSpriteForeground.position = tmp;
this.stage.addChild(this.imageSpriteForeground);
this.doOnStopNotify = onRemove;
}
,stopNotify: function() {
if(this.imageSpriteForeground == null) {
return;
}
this.stage.removeChild(this.imageSpriteForeground);
this.imageSpriteForeground = null;
this.doOnStopNotify();
}
,__class__: gui_ImageButton
});
var gui_InfoBox = function(gui,stage,parent,onUpdate,iconTexture,minWidth,onHover,backgroundSpriteName,shouldShowInfinitySign) {
if(backgroundSpriteName == null) {
backgroundSpriteName = "spr_9p_info";
}
if(minWidth == null) {
minWidth = 0;
}
this.showingInfinitySign = false;
this.additionalSprite = null;
if(shouldShowInfinitySign == null) {
this.shouldShowInfinitySign = function() {
return false;
};
} else {
this.shouldShowInfinitySign = shouldShowInfinitySign;
}
var backgroundPatch = backgroundSpriteName == "none" ? null : new gui_NinePatch(Resources.getTexture(backgroundSpriteName),2,10,14);
var extraSpacing = gui.game.isMobile ? 3 : 0;
gui_GUIContainer.call(this,gui,stage,parent,null,null,null,backgroundPatch,{ left : 2 + extraSpacing, right : 2 + extraSpacing, top : 2 + extraSpacing, bottom : extraSpacing + (-1)});
this.fillSecondarySize = true;
this.fillPrimarySize = true;
this.onHover = onHover;
this.minWidth = minWidth;
this.onTextUpdate = onUpdate;
this.shouldShowInfinitySign = shouldShowInfinitySign;
this.spriteContainer = new PIXI.Sprite(iconTexture);
if(iconTexture != null) {
this.addChild(new gui_ContainerHolder(this,stage,this.spriteContainer));
}
this.createSecondElement();
};
$hxClasses["gui.InfoBox"] = gui_InfoBox;
gui_InfoBox.__name__ = "gui.InfoBox";
gui_InfoBox.__super__ = gui_GUIContainer;
gui_InfoBox.prototype = $extend(gui_GUIContainer.prototype,{
update: function() {
if(this.shouldShowInfinitySign() != this.showingInfinitySign) {
this.secondElement.destroy();
this.removeChild(this.secondElement,false);
this.createSecondElement();
}
gui_GUIContainer.prototype.update.call(this);
}
,createSecondElement: function() {
this.showingInfinitySign = this.shouldShowInfinitySign();
if(this.showingInfinitySign) {
this.secondElement = this.addChild(new gui_ContainerHolder(this,this.stage,new PIXI.Sprite(Resources.getTexture("spr_icon_unlimited"))));
} else {
var extraSpacingText = this.gui.game.isMobile ? 2 : 0;
this.secondElement = new gui_TextElement(this,this.stage,null,this.onTextUpdate,null,{ left : 1 + extraSpacingText, right : 1, top : 1, bottom : 0});
this.addChild(this.secondElement);
}
}
,setAdditionalSprite: function(texture) {
if(texture == null) {
if(this.additionalSprite != null) {
this.additionalSprite.destroy();
}
this.additionalSprite = null;
return;
}
if(this.additionalSprite == null) {
this.additionalSprite = new PIXI.Sprite();
}
this.additionalSprite.texture = texture;
this.spriteContainer.addChild(this.additionalSprite);
}
,hasAdditionalSprite: function() {
return this.additionalSprite != null;
}
,handleMouse: function(mouse) {
if(this.rect.contains(mouse.position)) {
if(this.onHover != null) {
this.onHover();
}
mouse.claimMouse(this);
return true;
}
return false;
}
,updateSize: function() {
gui_GUIContainer.prototype.updateSize.call(this);
this.minWidth = this.baseWidth;
}
,__class__: gui_InfoBox
});
var gui_MainMenuGUI = function(game,outerStage) {
GUI.call(this,game,outerStage);
};
$hxClasses["gui.MainMenuGUI"] = gui_MainMenuGUI;
gui_MainMenuGUI.__name__ = "gui.MainMenuGUI";
gui_MainMenuGUI.createNewScenarioWindow = function(game,gui,windowOnDestroy) {
gui.createWindow();
var game1 = game;
var gui1 = gui;
var windowOnDestroy1 = windowOnDestroy;
var tmp = function() {
gui_MainMenuGUI.createNewScenarioWindow(game1,gui1,windowOnDestroy1);
};
gui.addWindowToStack(tmp);
gui.windowAddTitleText("Start Scenario");
var stories = Resources.allStoriesInfo;
var _g = 0;
while(_g < stories.length) {
var story = stories[_g];
++_g;
if(!StringTools.startsWith(story.name,"Free Play") && progress_StoryLoader.hasCompletedRequirements(game,story)) {
gui_MainMenuGUI.addStoryToWindow(game,gui,story);
}
}
if(progress_StoryLoader.shouldShowUnlockAllStoriesButton(game)) {
var button = new gui_ContainerButton(gui,gui.innerWindowStage,gui.windowInner,function() {
game.metaGame.unlockAll();
var game1 = game;
var gui1 = gui;
var windowOnDestroy1 = windowOnDestroy;
var button = function() {
gui_MainMenuGUI.createNewScenarioWindow(game1,gui1,windowOnDestroy1);
};
gui.reloadWindow(button);
});
button.container.padding.top = 3;
button.container.padding.left = 3;
button.container.padding.right = 3;
button.container.padding.bottom = 1;
button.container.fillSecondarySize = true;
button.container.addChild(new gui_TextElement(button.container,gui.innerWindowStage,"Unlock All"));
gui.windowInner.addChild(button);
}
gui.windowInner.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(4,6)));
gui.windowAddInfoText("Free Play:",null,"Arial");
var _g = 0;
while(_g < stories.length) {
var story = stories[_g];
++_g;
if(StringTools.startsWith(story.name,"Free Play") && progress_StoryLoader.hasCompletedRequirements(game,story)) {
gui_MainMenuGUI.addStoryToWindow(game,gui,story);
}
}
gui.windowAddBottomButtons();
gui.windowOnDestroy = windowOnDestroy;
};
gui_MainMenuGUI.createPlayedBeforeWindow = function(game,gui,windowOnDestroy) {
gui.createWindow();
var game1 = game;
var gui1 = gui;
var windowOnDestroy1 = windowOnDestroy;
var tmp = function() {
gui_MainMenuGUI.createPlayedBeforeWindow(game1,gui1,windowOnDestroy1);
};
gui.addWindowToStack(tmp);
gui.windowAddTitleText("Welcome Back!");
var activableButton = gui_UpgradeWindowParts.createActivatableButton(gui,false,function() {
},"Import City","Got an exported save file?",gui.windowInner);
activableButton.button.onHover = function() {
game.setOnClickTo = function() {
var importButton = window.document.getElementById("importFile");
importButton.value = "";
importButton.click();
game.onClick = null;
};
};
gui_UpgradeWindowParts.createActivatableButton(gui,false,function() {
gui_MainMenuGUI.createNewScenarioWindow(game,gui,windowOnDestroy);
},"New City","Start with any scenario or Free Play.",gui.windowInner);
gui.windowAddBottomButtons();
gui.windowOnDestroy = windowOnDestroy;
};
gui_MainMenuGUI.addStoryToWindow = function(game,gui,story) {
var description = "";
if(game.metaGame.hasWonScenario(story.link)) {
var time = game.metaGame.getScenarioTime(story.link);
description = "Best time: " + (time / 1440 | 0) + "d " + (time / 60 | 0) % 24 + "h " + time % 60 + "m " + "\n";
}
description += story.description;
gui_UpgradeWindowParts.createActivatableButton(gui,false,function() {
var oldOnDestroy = gui.windowOnDestroy;
gui.windowOnDestroy = null;
game.createNewGameState(story.link);
},StringTools.replace(story.name,"Free Play - ",""),description,gui.windowInner);
};
gui_MainMenuGUI.__super__ = GUI;
gui_MainMenuGUI.prototype = $extend(GUI.prototype,{
createPlayWindow: function(windowOnDestroy) {
gui_MainMenuGUI.createNewScenarioWindow(this.game,this,windowOnDestroy);
}
,doCreatePlayedBeforeWindow: function(windowOnDestroy) {
gui_MainMenuGUI.createPlayedBeforeWindow(this.game,this,windowOnDestroy);
}
,__class__: gui_MainMenuGUI
});
var gui_MaterialsCostDisplay = function(city,cost,beforeKnowledgeText) {
if(beforeKnowledgeText == null) {
beforeKnowledgeText = "";
}
this.maxDisplayWidth = -1;
this.displayCityAmounts = false;
PIXI.Container.call(this);
this.city = city;
this.materialDisplayedRed = new haxe_ds_StringMap();
this.materialDisplayedRed.h["food"] = false;
this.materialDisplayedRed.h["wood"] = false;
this.materialDisplayedRed.h["stone"] = false;
this.materialDisplayedRed.h["machineParts"] = false;
this.materialDisplayedRed.h["refinedMetal"] = false;
this.materialDisplayedRed.h["computerChips"] = false;
this.materialDisplayedRed.h["cacao"] = false;
this.materialDisplayedRed.h["chocolate"] = false;
var _g = 0;
var _g1 = MaterialsHelper.modMaterials;
while(_g < _g1.length) {
var modMaterial = _g1[_g];
++_g;
var currentMaterial = modMaterial.variableName;
this.materialDisplayedRed.h[currentMaterial] = false;
}
this.materialDisplayedRed.h["knowledge"] = false;
this.beforeKnowledgeText = beforeKnowledgeText;
this.cost = cost;
this.cityAmountDisplayed = null;
this.updateCostDisplay();
};
$hxClasses["gui.MaterialsCostDisplay"] = gui_MaterialsCostDisplay;
gui_MaterialsCostDisplay.__name__ = "gui.MaterialsCostDisplay";
gui_MaterialsCostDisplay.__super__ = PIXI.Container;
gui_MaterialsCostDisplay.prototype = $extend(PIXI.Container.prototype,{
setBeforeKnowledgeText: function(value) {
this.beforeKnowledgeText = value;
}
,setCost: function(cost) {
this.cost = cost;
this.updateCostDisplay();
}
,updateCostDisplay: function() {
var _gthis = this;
var hasMaximumDisplayWidthFailed = false;
var shouldUpdateCostDisplayAgain = true;
while(shouldUpdateCostDisplayAgain) {
shouldUpdateCostDisplayAgain = false;
var i = this.children.length;
while(--i >= 0) this.children.splice(i,1);
var xx = [0];
var shownBeforeKnowledgeText = false;
var anyMaterialShownBefore = false;
if(this.cost.food > 0) {
xx[0] -= 2;
anyMaterialShownBefore = true;
var spr = new PIXI.Sprite(Resources.getTexture("spr_resource_" + "food".toLowerCase()));
spr.position.x = xx[0];
this.addChild(spr);
xx[0] += (spr.width | 0) + 1;
xx[0] -= 2;
var extraText = "";
if(this.displayCityAmounts && !hasMaximumDisplayWidthFailed && !this.city.progress.sandbox.unlimitedResources) {
extraText = "/" + common_MathExtensions.largeNumberFormat(Math,this.city.materials.food | 0);
}
var tooLittleOfMaterial = this.city != null && this.city.materials.food < this.cost.food;
var bitmapText = new PIXI.extras.BitmapText(this.cost.food + extraText,{ font : "Arial", tint : this.city != null && tooLittleOfMaterial ? 16711680 : 0});
this.materialDisplayedRed.h["food"] = tooLittleOfMaterial;
bitmapText.position.set(xx[0],-1);
this.addChild(bitmapText);
xx[0] += (bitmapText.textWidth | 0) + 3;
} else {
this.materialDisplayedRed.h["food"] = false;
}
if(this.cost.wood > 0) {
anyMaterialShownBefore = true;
var spr1 = new PIXI.Sprite(Resources.getTexture("spr_resource_" + "wood".toLowerCase()));
spr1.position.x = xx[0];
this.addChild(spr1);
xx[0] += (spr1.width | 0) + 1;
var extraText1 = "";
if(this.displayCityAmounts && !hasMaximumDisplayWidthFailed && !this.city.progress.sandbox.unlimitedResources) {
extraText1 = "/" + common_MathExtensions.largeNumberFormat(Math,this.city.materials.wood | 0);
}
var tooLittleOfMaterial1 = this.city != null && this.city.materials.wood < this.cost.wood;
var bitmapText1 = new PIXI.extras.BitmapText(this.cost.wood + extraText1,{ font : "Arial", tint : this.city != null && tooLittleOfMaterial1 ? 16711680 : 0});
this.materialDisplayedRed.h["wood"] = tooLittleOfMaterial1;
bitmapText1.position.set(xx[0],-1);
this.addChild(bitmapText1);
xx[0] += (bitmapText1.textWidth | 0) + 3;
} else {
this.materialDisplayedRed.h["wood"] = false;
}
if(this.cost.stone > 0) {
anyMaterialShownBefore = true;
var spr2 = new PIXI.Sprite(Resources.getTexture("spr_resource_" + "stone".toLowerCase()));
spr2.position.x = xx[0];
this.addChild(spr2);
xx[0] += (spr2.width | 0) + 1;
var extraText2 = "";
if(this.displayCityAmounts && !hasMaximumDisplayWidthFailed && !this.city.progress.sandbox.unlimitedResources) {
extraText2 = "/" + common_MathExtensions.largeNumberFormat(Math,this.city.materials.stone | 0);
}
var tooLittleOfMaterial2 = this.city != null && this.city.materials.stone < this.cost.stone;
var bitmapText2 = new PIXI.extras.BitmapText(this.cost.stone + extraText2,{ font : "Arial", tint : this.city != null && tooLittleOfMaterial2 ? 16711680 : 0});
this.materialDisplayedRed.h["stone"] = tooLittleOfMaterial2;
bitmapText2.position.set(xx[0],-1);
this.addChild(bitmapText2);
xx[0] += (bitmapText2.textWidth | 0) + 3;
} else {
this.materialDisplayedRed.h["stone"] = false;
}
if(this.cost.machineParts > 0) {
anyMaterialShownBefore = true;
var spr3 = new PIXI.Sprite(Resources.getTexture("spr_resource_" + "machineParts".toLowerCase()));
spr3.position.x = xx[0];
this.addChild(spr3);
xx[0] += (spr3.width | 0) + 1;
var extraText3 = "";
if(this.displayCityAmounts && !hasMaximumDisplayWidthFailed && !this.city.progress.sandbox.unlimitedResources) {
extraText3 = "/" + common_MathExtensions.largeNumberFormat(Math,this.city.materials.machineParts | 0);
}
var tooLittleOfMaterial3 = this.city != null && this.city.materials.machineParts < this.cost.machineParts;
var bitmapText3 = new PIXI.extras.BitmapText(this.cost.machineParts + extraText3,{ font : "Arial", tint : this.city != null && tooLittleOfMaterial3 ? 16711680 : 0});
this.materialDisplayedRed.h["machineParts"] = tooLittleOfMaterial3;
bitmapText3.position.set(xx[0],-1);
this.addChild(bitmapText3);
xx[0] += (bitmapText3.textWidth | 0) + 3;
} else {
this.materialDisplayedRed.h["machineParts"] = false;
}
if(this.cost.refinedMetal > 0) {
anyMaterialShownBefore = true;
var spr4 = new PIXI.Sprite(Resources.getTexture("spr_resource_" + "refinedMetal".toLowerCase()));
spr4.position.x = xx[0];
this.addChild(spr4);
xx[0] += (spr4.width | 0) + 1;
var extraText4 = "";
if(this.displayCityAmounts && !hasMaximumDisplayWidthFailed && !this.city.progress.sandbox.unlimitedResources) {
extraText4 = "/" + common_MathExtensions.largeNumberFormat(Math,this.city.materials.refinedMetal | 0);
}
var tooLittleOfMaterial4 = this.city != null && this.city.materials.refinedMetal < this.cost.refinedMetal;
var bitmapText4 = new PIXI.extras.BitmapText(this.cost.refinedMetal + extraText4,{ font : "Arial", tint : this.city != null && tooLittleOfMaterial4 ? 16711680 : 0});
this.materialDisplayedRed.h["refinedMetal"] = tooLittleOfMaterial4;
bitmapText4.position.set(xx[0],-1);
this.addChild(bitmapText4);
xx[0] += (bitmapText4.textWidth | 0) + 3;
} else {
this.materialDisplayedRed.h["refinedMetal"] = false;
}
if(this.cost.computerChips > 0) {
anyMaterialShownBefore = true;
var spr5 = new PIXI.Sprite(Resources.getTexture("spr_resource_" + "computerChips".toLowerCase()));
spr5.position.x = xx[0];
this.addChild(spr5);
xx[0] += (spr5.width | 0) + 1;
var extraText5 = "";
if(this.displayCityAmounts && !hasMaximumDisplayWidthFailed && !this.city.progress.sandbox.unlimitedResources) {
extraText5 = "/" + common_MathExtensions.largeNumberFormat(Math,this.city.materials.computerChips | 0);
}
var tooLittleOfMaterial5 = this.city != null && this.city.materials.computerChips < this.cost.computerChips;
var bitmapText5 = new PIXI.extras.BitmapText(this.cost.computerChips + extraText5,{ font : "Arial", tint : this.city != null && tooLittleOfMaterial5 ? 16711680 : 0});
this.materialDisplayedRed.h["computerChips"] = tooLittleOfMaterial5;
bitmapText5.position.set(xx[0],-1);
this.addChild(bitmapText5);
xx[0] += (bitmapText5.textWidth | 0) + 3;
} else {
this.materialDisplayedRed.h["computerChips"] = false;
}
if(this.cost.cacao > 0) {
anyMaterialShownBefore = true;
var spr6 = new PIXI.Sprite(Resources.getTexture("spr_resource_" + "cacao".toLowerCase()));
spr6.position.x = xx[0];
this.addChild(spr6);
xx[0] += (spr6.width | 0) + 1;
var extraText6 = "";
if(this.displayCityAmounts && !hasMaximumDisplayWidthFailed && !this.city.progress.sandbox.unlimitedResources) {
extraText6 = "/" + common_MathExtensions.largeNumberFormat(Math,this.city.materials.cacao | 0);
}
var tooLittleOfMaterial6 = this.city != null && this.city.materials.cacao < this.cost.cacao;
var bitmapText6 = new PIXI.extras.BitmapText(this.cost.cacao + extraText6,{ font : "Arial", tint : this.city != null && tooLittleOfMaterial6 ? 16711680 : 0});
this.materialDisplayedRed.h["cacao"] = tooLittleOfMaterial6;
bitmapText6.position.set(xx[0],-1);
this.addChild(bitmapText6);
xx[0] += (bitmapText6.textWidth | 0) + 3;
} else {
this.materialDisplayedRed.h["cacao"] = false;
}
if(this.cost.chocolate > 0) {
anyMaterialShownBefore = true;
var spr7 = new PIXI.Sprite(Resources.getTexture("spr_resource_" + "chocolate".toLowerCase()));
spr7.position.x = xx[0];
this.addChild(spr7);
xx[0] += (spr7.width | 0) + 1;
var extraText7 = "";
if(this.displayCityAmounts && !hasMaximumDisplayWidthFailed && !this.city.progress.sandbox.unlimitedResources) {
extraText7 = "/" + common_MathExtensions.largeNumberFormat(Math,this.city.materials.chocolate | 0);
}
var tooLittleOfMaterial7 = this.city != null && this.city.materials.chocolate < this.cost.chocolate;
var bitmapText7 = new PIXI.extras.BitmapText(this.cost.chocolate + extraText7,{ font : "Arial", tint : this.city != null && tooLittleOfMaterial7 ? 16711680 : 0});
this.materialDisplayedRed.h["chocolate"] = tooLittleOfMaterial7;
bitmapText7.position.set(xx[0],-1);
this.addChild(bitmapText7);
xx[0] += (bitmapText7.textWidth | 0) + 3;
} else {
this.materialDisplayedRed.h["chocolate"] = false;
}
var _g = 0;
var _g1 = MaterialsHelper.modMaterials;
while(_g < _g1.length) {
var modMaterial = _g1[_g];
++_g;
var currentMaterial = modMaterial.variableName;
if(this.cost[currentMaterial] > 0) {
if(currentMaterial == "food") {
xx[0] -= 2;
} else if(currentMaterial == "knowledge" && this.beforeKnowledgeText != "" && anyMaterialShownBefore) {
var bitmapText8 = new PIXI.extras.BitmapText(this.beforeKnowledgeText,{ font : "Arial", tint : 0});
bitmapText8.position.set(xx[0],-1);
this.addChild(bitmapText8);
shownBeforeKnowledgeText = true;
xx[0] += (bitmapText8.textWidth | 0) + 3;
}
anyMaterialShownBefore = true;
var spr8 = new PIXI.Sprite(Resources.getTexture("spr_resource_" + currentMaterial.toLowerCase()));
spr8.position.x = xx[0];
this.addChild(spr8);
xx[0] += (spr8.width | 0) + 1;
if(currentMaterial == "food") {
xx[0] -= 2;
}
var extraText8 = "";
if(this.displayCityAmounts && !hasMaximumDisplayWidthFailed && !this.city.progress.sandbox.unlimitedResources) {
extraText8 = "/" + common_MathExtensions.largeNumberFormat(Math,this.city.materials[currentMaterial] | 0);
}
if(currentMaterial == "knowledge") {
extraText8 = " to research";
}
var tooLittleOfMaterial8 = this.city != null && this.city.materials[currentMaterial] < this.cost[currentMaterial];
var bitmapText9 = new PIXI.extras.BitmapText(this.cost[currentMaterial] + extraText8,{ font : "Arial", tint : this.city != null && tooLittleOfMaterial8 ? 16711680 : 0});
this.materialDisplayedRed.h[currentMaterial] = tooLittleOfMaterial8;
bitmapText9.position.set(xx[0],-1);
this.addChild(bitmapText9);
xx[0] += (bitmapText9.textWidth | 0) + 3;
} else {
this.materialDisplayedRed.h[currentMaterial] = false;
}
}
if(this.cost.knowledge > 0) {
if(this.beforeKnowledgeText != "" && anyMaterialShownBefore) {
var bitmapText10 = new PIXI.extras.BitmapText(this.beforeKnowledgeText,{ font : "Arial", tint : 0});
bitmapText10.position.set(xx[0],-1);
this.addChild(bitmapText10);
shownBeforeKnowledgeText = true;
xx[0] += (bitmapText10.textWidth | 0) + 3;
}
anyMaterialShownBefore = true;
var spr9 = new PIXI.Sprite(Resources.getTexture("spr_resource_" + "knowledge".toLowerCase()));
spr9.position.x = xx[0];
this.addChild(spr9);
xx[0] += (spr9.width | 0) + 1;
var extraText9 = "";
if(this.displayCityAmounts && !hasMaximumDisplayWidthFailed && !this.city.progress.sandbox.unlimitedResources) {
extraText9 = "/" + common_MathExtensions.largeNumberFormat(Math,this.city.materials.knowledge | 0);
}
extraText9 = " to research";
var tooLittleOfMaterial9 = this.city != null && this.city.materials.knowledge < this.cost.knowledge;
var bitmapText11 = new PIXI.extras.BitmapText(this.cost.knowledge + extraText9,{ font : "Arial", tint : this.city != null && tooLittleOfMaterial9 ? 16711680 : 0});
this.materialDisplayedRed.h["knowledge"] = tooLittleOfMaterial9;
bitmapText11.position.set(xx[0],-1);
this.addChild(bitmapText11);
xx[0] += (bitmapText11.textWidth | 0) + 3;
} else {
this.materialDisplayedRed.h["knowledge"] = false;
}
if(!shownBeforeKnowledgeText && this.beforeKnowledgeText != "") {
var bitmapText12 = new PIXI.extras.BitmapText(this.beforeKnowledgeText,{ font : "Arial", tint : 0});
bitmapText12.position.set(xx[0],-1);
this.addChild(bitmapText12);
xx[0] += (bitmapText12.textWidth | 0) + 3;
}
var addExtraIcon = (function(xx) {
return function(textureName,amount) {
var spr = new PIXI.Sprite(Resources.getTexture(textureName));
spr.position.x = xx[0];
_gthis.addChild(spr);
xx[0] += (spr.width | 0) + 1;
var bitmapText = new PIXI.extras.BitmapText("" + amount,{ font : "Arial", tint : 0});
bitmapText.position.set(xx[0],-1);
_gthis.addChild(bitmapText);
xx[0] += (bitmapText.textWidth | 0) + 3;
};
})(xx);
this.displayWidth = xx[0];
if(!hasMaximumDisplayWidthFailed && this.maxDisplayWidth > 0 && xx[0] > this.maxDisplayWidth) {
hasMaximumDisplayWidthFailed = true;
shouldUpdateCostDisplayAgain = true;
}
}
if(this.city != null) {
this.cityAmountDisplayed = this.city.materials.copy();
}
}
,wouldChangeDisplay: function(newCost) {
if(this.displayCityAmounts) {
if(this.cityAmountDisplayed == null) {
return true;
}
if(this.cityAmountDisplayed.anyMaterialDifferent(this.city.materials)) {
return true;
}
}
if(newCost.food != this.cost.food) {
return true;
}
var tooLittleOfMaterial = this.city != null && this.city.materials.food < newCost.food;
if(this.materialDisplayedRed.h["food"] != tooLittleOfMaterial) {
return true;
}
if(newCost.wood != this.cost.wood) {
return true;
}
var tooLittleOfMaterial = this.city != null && this.city.materials.wood < newCost.wood;
if(this.materialDisplayedRed.h["wood"] != tooLittleOfMaterial) {
return true;
}
if(newCost.stone != this.cost.stone) {
return true;
}
var tooLittleOfMaterial = this.city != null && this.city.materials.stone < newCost.stone;
if(this.materialDisplayedRed.h["stone"] != tooLittleOfMaterial) {
return true;
}
if(newCost.machineParts != this.cost.machineParts) {
return true;
}
var tooLittleOfMaterial = this.city != null && this.city.materials.machineParts < newCost.machineParts;
if(this.materialDisplayedRed.h["machineParts"] != tooLittleOfMaterial) {
return true;
}
if(newCost.refinedMetal != this.cost.refinedMetal) {
return true;
}
var tooLittleOfMaterial = this.city != null && this.city.materials.refinedMetal < newCost.refinedMetal;
if(this.materialDisplayedRed.h["refinedMetal"] != tooLittleOfMaterial) {
return true;
}
if(newCost.computerChips != this.cost.computerChips) {
return true;
}
var tooLittleOfMaterial = this.city != null && this.city.materials.computerChips < newCost.computerChips;
if(this.materialDisplayedRed.h["computerChips"] != tooLittleOfMaterial) {
return true;
}
if(newCost.cacao != this.cost.cacao) {
return true;
}
var tooLittleOfMaterial = this.city != null && this.city.materials.cacao < newCost.cacao;
if(this.materialDisplayedRed.h["cacao"] != tooLittleOfMaterial) {
return true;
}
if(newCost.chocolate != this.cost.chocolate) {
return true;
}
var tooLittleOfMaterial = this.city != null && this.city.materials.chocolate < newCost.chocolate;
if(this.materialDisplayedRed.h["chocolate"] != tooLittleOfMaterial) {
return true;
}
var _g = 0;
var _g1 = MaterialsHelper.modMaterials;
while(_g < _g1.length) {
var modMaterial = _g1[_g];
++_g;
var currentMaterial = modMaterial.variableName;
if(newCost[currentMaterial] != this.cost[currentMaterial]) {
return true;
}
var tooLittleOfMaterial = this.city != null && this.city.materials[currentMaterial] < newCost[currentMaterial];
if(this.materialDisplayedRed.h[currentMaterial] != tooLittleOfMaterial) {
return true;
}
}
if(newCost.knowledge != this.cost.knowledge) {
return true;
}
var tooLittleOfMaterial = this.city != null && this.city.materials.knowledge < newCost.knowledge;
if(this.materialDisplayedRed.h["knowledge"] != tooLittleOfMaterial) {
return true;
}
return false;
}
,__class__: gui_MaterialsCostDisplay
});
var gui_MaterialsDisplay = function(materials) {
PIXI.Container.call(this);
this.materials = materials;
this.updateMaterialsDisplay();
};
$hxClasses["gui.MaterialsDisplay"] = gui_MaterialsDisplay;
gui_MaterialsDisplay.__name__ = "gui.MaterialsDisplay";
gui_MaterialsDisplay.__super__ = PIXI.Container;
gui_MaterialsDisplay.prototype = $extend(PIXI.Container.prototype,{
setMaterials: function(materials) {
this.materials = materials;
this.updateMaterialsDisplay();
}
,updateMaterialsDisplay: function() {
var _gthis = this;
var i = this.children.length;
while(--i >= 0) this.children.splice(i,1);
var xx = 0;
if(this.materials.food > 0) {
xx -= 2;
var spr = new PIXI.Sprite(Resources.getTexture("spr_resource_" + "food".toLowerCase()));
spr.position.x = xx;
this.addChild(spr);
xx += (spr.width | 0) + 1;
xx -= 2;
var bitmapText = new PIXI.extras.BitmapText("" + this.materials.food,{ font : "Arial", tint : 0});
bitmapText.position.set(xx,-1);
this.addChild(bitmapText);
xx += (bitmapText.textWidth | 0) + 3;
}
if(this.materials.wood > 0) {
var spr = new PIXI.Sprite(Resources.getTexture("spr_resource_" + "wood".toLowerCase()));
spr.position.x = xx;
this.addChild(spr);
xx += (spr.width | 0) + 1;
var bitmapText = new PIXI.extras.BitmapText("" + this.materials.wood,{ font : "Arial", tint : 0});
bitmapText.position.set(xx,-1);
this.addChild(bitmapText);
xx += (bitmapText.textWidth | 0) + 3;
}
if(this.materials.stone > 0) {
var spr = new PIXI.Sprite(Resources.getTexture("spr_resource_" + "stone".toLowerCase()));
spr.position.x = xx;
this.addChild(spr);
xx += (spr.width | 0) + 1;
var bitmapText = new PIXI.extras.BitmapText("" + this.materials.stone,{ font : "Arial", tint : 0});
bitmapText.position.set(xx,-1);
this.addChild(bitmapText);
xx += (bitmapText.textWidth | 0) + 3;
}
if(this.materials.machineParts > 0) {
var spr = new PIXI.Sprite(Resources.getTexture("spr_resource_" + "machineParts".toLowerCase()));
spr.position.x = xx;
this.addChild(spr);
xx += (spr.width | 0) + 1;
var bitmapText = new PIXI.extras.BitmapText("" + this.materials.machineParts,{ font : "Arial", tint : 0});
bitmapText.position.set(xx,-1);
this.addChild(bitmapText);
xx += (bitmapText.textWidth | 0) + 3;
}
if(this.materials.refinedMetal > 0) {
var spr = new PIXI.Sprite(Resources.getTexture("spr_resource_" + "refinedMetal".toLowerCase()));
spr.position.x = xx;
this.addChild(spr);
xx += (spr.width | 0) + 1;
var bitmapText = new PIXI.extras.BitmapText("" + this.materials.refinedMetal,{ font : "Arial", tint : 0});
bitmapText.position.set(xx,-1);
this.addChild(bitmapText);
xx += (bitmapText.textWidth | 0) + 3;
}
if(this.materials.computerChips > 0) {
var spr = new PIXI.Sprite(Resources.getTexture("spr_resource_" + "computerChips".toLowerCase()));
spr.position.x = xx;
this.addChild(spr);
xx += (spr.width | 0) + 1;
var bitmapText = new PIXI.extras.BitmapText("" + this.materials.computerChips,{ font : "Arial", tint : 0});
bitmapText.position.set(xx,-1);
this.addChild(bitmapText);
xx += (bitmapText.textWidth | 0) + 3;
}
if(this.materials.cacao > 0) {
var spr = new PIXI.Sprite(Resources.getTexture("spr_resource_" + "cacao".toLowerCase()));
spr.position.x = xx;
this.addChild(spr);
xx += (spr.width | 0) + 1;
var bitmapText = new PIXI.extras.BitmapText("" + this.materials.cacao,{ font : "Arial", tint : 0});
bitmapText.position.set(xx,-1);
this.addChild(bitmapText);
xx += (bitmapText.textWidth | 0) + 3;
}
if(this.materials.chocolate > 0) {
var spr = new PIXI.Sprite(Resources.getTexture("spr_resource_" + "chocolate".toLowerCase()));
spr.position.x = xx;
this.addChild(spr);
xx += (spr.width | 0) + 1;
var bitmapText = new PIXI.extras.BitmapText("" + this.materials.chocolate,{ font : "Arial", tint : 0});
bitmapText.position.set(xx,-1);
this.addChild(bitmapText);
xx += (bitmapText.textWidth | 0) + 3;
}
var _g = 0;
var _g1 = MaterialsHelper.modMaterials;
while(_g < _g1.length) {
var modMaterial = _g1[_g];
++_g;
var currentMaterial = modMaterial.variableName;
if(this.materials[currentMaterial] > 0) {
if(currentMaterial == "food") {
xx -= 2;
}
var spr = new PIXI.Sprite(Resources.getTexture("spr_resource_" + currentMaterial.toLowerCase()));
spr.position.x = xx;
this.addChild(spr);
xx += (spr.width | 0) + 1;
if(currentMaterial == "food") {
xx -= 2;
}
var bitmapText = new PIXI.extras.BitmapText("" + this.materials[currentMaterial],{ font : "Arial", tint : 0});
bitmapText.position.set(xx,-1);
this.addChild(bitmapText);
xx += (bitmapText.textWidth | 0) + 3;
}
}
if(this.materials.knowledge > 0) {
var spr = new PIXI.Sprite(Resources.getTexture("spr_resource_" + "knowledge".toLowerCase()));
spr.position.x = xx;
this.addChild(spr);
xx += (spr.width | 0) + 1;
var bitmapText = new PIXI.extras.BitmapText("" + this.materials.knowledge,{ font : "Arial", tint : 0});
bitmapText.position.set(xx,-1);
this.addChild(bitmapText);
xx += (bitmapText.textWidth | 0) + 3;
}
var addExtraIcon = function(textureName,amount) {
var spr = new PIXI.Sprite(Resources.getTexture(textureName));
spr.position.x = xx;
_gthis.addChild(spr);
xx += (spr.width | 0) + 1;
var bitmapText = new PIXI.extras.BitmapText("" + amount,{ font : "Arial", tint : 0});
bitmapText.position.set(xx,-1);
_gthis.addChild(bitmapText);
xx += (bitmapText.textWidth | 0) + 3;
};
this.displayWidth = xx;
}
,__class__: gui_MaterialsDisplay
});
var gui_MoreSettingsWindow = function() { };
$hxClasses["gui.MoreSettingsWindow"] = gui_MoreSettingsWindow;
gui_MoreSettingsWindow.__name__ = "gui.MoreSettingsWindow";
gui_MoreSettingsWindow.create = function(city,gui,stage,thisWindow,imageButtonToUse,imageOffsetToUse) {
gui.windowAddTitleText("Advanced Settings");
if(city.progress.story.canHaveUnlimitedResources() && (Config.allowUnlimitedResources || city.progress.sandbox.unlimitedResources)) {
var doConfirmUnlimited = null;
doConfirmUnlimited = function() {
gui.createWindow("confirmUnlimited");
gui.addWindowToStack(doConfirmUnlimited);
gui.windowAddTitleText(!city.progress.sandbox.unlimitedResources ? "Enable Unlimited Resources" : "Disable Unlimited Resources");
gui.windowAddInfoText(!city.progress.sandbox.unlimitedResources ? "Do you want to play with unlimited resources for this save file?" : "Do you want to play with normal resource contraints? You can always re-enable unlimited resources later.");
gui.windowAddBottomButtons([{ text : "Yes", action : function() {
if(city.progress.sandbox.unlimitedResources) {
city.progress.sandbox.disableUnlimitedResources();
} else {
city.progress.sandbox.enableUnlimitedResources();
}
gui.goPreviousWindow();
}}]);
};
var unlimitedButton = new gui_TextButton(gui,stage,gui.windowInner,doConfirmUnlimited,"Unlimited");
thisWindow.addChild(unlimitedButton);
if(!city.game.isMobile) {
unlimitedButton.extraWidth = 18;
}
unlimitedButton.setText(!city.progress.sandbox.unlimitedResources ? "Enable Unlimited Resources" : "Disable Unlimited Resources");
thisWindow.addChild(new gui_GUISpacing(thisWindow,new common_Point(2,4)));
}
if(!city.game.isMobile) {
var threadLimitController = new gui_GUIContainer(gui,stage,thisWindow);
threadLimitController.direction = gui_GUIContainerDirection.Vertical;
var threadLimitController2 = new gui_GUIContainer(gui,stage,thisWindow);
threadLimitController2.direction = gui_GUIContainerDirection.Horizontal;
threadLimitController2.padding.bottom = 6;
var threadLimitText = new gui_TextElement(threadLimitController,stage,"Pathfinding Thread Limit: ");
threadLimitText.handleMouseFunction = function(mouse) {
if(threadLimitText.rect.contains(mouse.position)) {
gui.tooltip.setText(null,"Pathfinding threads are used to compute movement paths for citizens. If all pathfinding threads are busy, citizens may stand still and wait until one is available. " + "Increasing this will improve the simulation in large cities. The recommended value is the number of physical cores of your processor minus one. " + "Higher values may have a negative impact on the frame rate. " + "\nIf you don't know what this all means, I completely understand! Just keep this at the default.");
return true;
}
return false;
};
threadLimitText.padding.top = 1;
threadLimitController2.addChild(threadLimitText);
threadLimitController2.addChild(new gui_GUISpacing(threadLimitController2,new common_Point(4,2)));
var numberSelectControl = new gui_NumberSelectControl(gui,stage,threadLimitController2,{ left : 0, right : 0, top : 0, bottom : 0},function() {
return 1;
},function() {
return 15;
},Settings.pathfindingWorkers,function(v) {
Settings.pathfindingWorkers = v;
city.simulation.pathfinder.setWorkerNumber(v,true);
Settings.save();
},function() {
return Settings.resetPathfindingWorkers();
},"Click to reset the pathfinding thread limit to the default.");
threadLimitController2.addChild(numberSelectControl);
threadLimitController.addChild(threadLimitController2);
thisWindow.addChild(threadLimitController);
}
thisWindow.addChild(new gui_TextElement(thisWindow,gui.innerWindowStage,"Have or want a Secret Code?"));
var secretButtonDiv = new gui_GUIContainer(gui,gui.innerWindowStage,gui.windowInner);
var doCreateSecretInputWindow = null;
doCreateSecretInputWindow = function() {
gui.createWindow("secretWindow");
gui.addWindowToStack(doCreateSecretInputWindow);
gui_SecretCodeWindow.create(city,gui,gui.innerWindowStage,gui.windowInner);
};
var secretButton = new gui_TextButton(gui,stage,gui.windowInner,doCreateSecretInputWindow,"Input Secret Code");
secretButton.extraHeight += 3;
secretButton.extraTextPosY += 1;
secretButton.setText("Input Secret Code");
secretButtonDiv.addChild(secretButton);
secretButtonDiv.addChild(new gui_GUISpacing(secretButtonDiv,new common_Point(2,4)));
var thisButtonImage = Resources.getTexture("spr_mailinglist");
var imgButton = new gui_ImageButton(gui,stage,secretButtonDiv,function() {
},thisButtonImage,function() {
return false;
},function() {
gui.tooltip.setText(imgButton,"I'll send you cool The Final Earth 2 news and facts, plus info on my future releases!\n\nPlus, as a small gesture of thanks, you'll get a secret code to unlock some nice cosmetic options right away!","Subscribe to my mailing list!");
city.game.setOnClickTo = function() {
window.open(Config.mailingListURL,"_blank");
};
},null,imageButtonToUse,imageOffsetToUse);
imgButton.imageSprite.tint = 0;
secretButtonDiv.addChild(imgButton);
thisWindow.addChild(secretButtonDiv);
thisWindow.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,4)));
gui.windowAddBottomButtons();
};
var gui_MultiFollowWindow = function() { };
$hxClasses["gui.MultiFollowWindow"] = gui_MultiFollowWindow;
gui_MultiFollowWindow.__name__ = "gui.MultiFollowWindow";
gui_MultiFollowWindow.createWindow = function(city,citizens,topText,relatedBuilding,nothingFoundText) {
city.gui.createWindow(citizens);
city.gui.setWindowPositioning(city.game.isMobile ? gui_WindowPosition.TopLeft : gui_WindowPosition.Top);
var city1 = city;
var citizens1 = citizens;
var topText1 = topText;
var relatedBuilding1 = relatedBuilding;
var nothingFoundText1 = nothingFoundText;
var tmp = function() {
gui_MultiFollowWindow.createWindow(city1,citizens1,topText1,relatedBuilding1,nothingFoundText1);
};
city.gui.setWindowReload(tmp);
var city2 = city;
var citizens2 = citizens;
var topText2 = topText;
var relatedBuilding2 = relatedBuilding;
var nothingFoundText2 = nothingFoundText;
var tmp = function() {
gui_MultiFollowWindow.createWindow(city2,citizens2,topText2,relatedBuilding2,nothingFoundText2);
};
city.gui.addWindowToStack(tmp);
var windowTitle = topText;
city.gui.windowAddTitleText(windowTitle);
var allCitizensElem = new gui_GUIContainer(city.gui,city.gui.innerWindowStage,city.gui.windowInner);
allCitizensElem.direction = gui_GUIContainerDirection.Vertical;
var allCitizensSubElems = [];
city.gui.windowInner.addChild(allCitizensElem);
city.gui.windowAddBottomButtons();
var selectedTexture = Resources.getTexture("spr_selectedhuman");
var selectedSpritePool = [];
var selectedBuildingSprite = null;
if(relatedBuilding != null) {
selectedBuildingSprite = Resources.makeSprite("spr_selectedbuilding");
selectedBuildingSprite.alpha = 0.5;
selectedBuildingSprite.position.set(relatedBuilding.position.x - 1,relatedBuilding.position.y - 1);
city.farForegroundStage.addChild(selectedBuildingSprite);
}
city.gui.windowOnLateUpdate = function() {
if(relatedBuilding != null) {
if(relatedBuilding.destroyed) {
city.gui.clearWindowStack();
city.gui.closeWindow();
return;
}
selectedBuildingSprite.position.set(relatedBuilding.position.x - 1,relatedBuilding.position.y - 1);
}
if(citizens.length == 0) {
if(allCitizensSubElems.length > 0) {
var _g = 0;
while(_g < allCitizensSubElems.length) {
var elem = allCitizensSubElems[_g];
++_g;
elem.elem.destroy();
}
allCitizensSubElems = [];
allCitizensElem.clear();
}
if(allCitizensElem.children.length == 0) {
allCitizensElem.addChild(new gui_TextElement(allCitizensElem,city.gui.innerWindowStage,nothingFoundText));
}
} else {
if(allCitizensSubElems.length == 0) {
allCitizensElem.clear();
}
var _g = 0;
while(_g < citizens.length) {
var citizen = [citizens[_g]];
++_g;
var thisCitizenElement = Lambda.find(allCitizensSubElems,(function(citizen) {
return function(elem) {
return elem.citizen == citizen[0];
};
})(citizen));
if(thisCitizenElement == null) {
var newButton = new gui_ContainerButton(city.gui,city.gui.innerWindowStage,allCitizensElem,(function(citizen) {
return function() {
gui_FollowingCitizen.createWindow(city,citizen[0],false);
};
})(citizen));
newButton.container.padding.top = 3;
newButton.container.padding.left = 3;
newButton.container.padding.right = 3;
newButton.container.padding.bottom = 0;
newButton.container.fillSecondarySize = true;
newButton.container.addChildWithoutSizeUpdate(new gui_TextElement(newButton.container,city.gui.innerWindowStage,citizen[0].nameIndex < Resources.citizenNames.length ? Resources.citizenNames[citizen[0].nameIndex] : "Citizen"));
newButton.container.updateSizeNonRecursive();
var nbcp = newButton.container.parent.parent;
newButton.container.parent.parent = null;
newButton.container.parent.updateSize();
newButton.container.parent.parent = nbcp;
newButton.container.updateChildrenPosition();
allCitizensElem.addChildWithoutSizeUpdate(newButton);
var spacingElem = new gui_GUISpacing(allCitizensElem,new common_Point(2,4));
allCitizensElem.addChildWithoutSizeUpdate(spacingElem);
allCitizensSubElems.push({ elem : newButton, elem2 : spacingElem, citizen : citizen[0]});
}
}
allCitizensElem.updateSize();
var i = allCitizensSubElems.length - 1;
while(i >= 0) {
var elem = allCitizensSubElems[i];
if(citizens.indexOf(elem.citizen) == -1) {
allCitizensElem.removeChild(elem.elem);
allCitizensElem.removeChild(elem.elem2);
allCitizensSubElems.splice(i,1);
}
--i;
}
}
if(selectedSpritePool.length > citizens.length) {
var _g = citizens.length;
var _g1 = selectedSpritePool.length;
while(_g < _g1) {
var i = _g++;
selectedSpritePool[i].destroy();
}
selectedSpritePool.splice(citizens.length,selectedSpritePool.length - citizens.length);
}
var _g = 0;
var _g1 = citizens.length;
while(_g < _g1) {
var i = _g++;
if(i >= selectedSpritePool.length) {
var spr = new PIXI.Sprite(selectedTexture);
selectedSpritePool.push(spr);
city.furtherForegroundStage.addChild(spr);
}
var citizen1 = citizens[i];
var citizenPos = citizen1.getCityPosition();
selectedSpritePool[i].position.set(citizenPos.x - 1,citizenPos.y - 6);
}
};
city.gui.windowOnDestroy = function() {
var _g = 0;
while(_g < selectedSpritePool.length) {
var spr = selectedSpritePool[_g];
++_g;
spr.destroy();
}
if(selectedBuildingSprite != null) {
selectedBuildingSprite.destroy();
}
};
};
var gui_NinePatch = function(texture,sidePixels,width,height) {
this.currentTextureSet = 0;
this.npWidth = width;
this.npHeight = height;
PIXI.Container.call(this);
this.textureSets = [];
this.texture = texture;
this.sidePixels = sidePixels;
this.updateTextures();
this.updateSprites();
};
$hxClasses["gui.NinePatch"] = gui_NinePatch;
gui_NinePatch.__name__ = "gui.NinePatch";
gui_NinePatch.__super__ = PIXI.Container;
gui_NinePatch.prototype = $extend(PIXI.Container.prototype,{
setTextureSet: function(setNumber) {
var newTextureSet = this.textureSets[setNumber];
this.currentTextureSet = setNumber;
if(newTextureSet != this.textureParts) {
this.textureParts = newTextureSet;
this.updateSprites();
}
}
,updateTextures: function(destroyOld) {
if(destroyOld == null) {
destroyOld = true;
}
if(this.textureParts == null) {
this.textureParts = [];
} else if(destroyOld) {
this.textureSets.pop();
} else {
this.textureParts = [];
}
if(gui_NinePatch.ninePatchTextureCache.h.__keys__[this.texture.__id__] != null && gui_NinePatch.ninePatchTextureCache.h[this.texture.__id__].h.hasOwnProperty(this.sidePixels)) {
this.textureParts = gui_NinePatch.ninePatchTextureCache.h[this.texture.__id__].h[this.sidePixels];
} else {
var _g = 0;
while(_g < 9) {
var i = _g++;
this.textureParts[i] = this.texture.clone();
var frame = new PIXI.Rectangle();
if(i % 3 == 1) {
frame.width = this.texture.width - 2 * this.sidePixels;
frame.x = this.sidePixels;
} else {
frame.width = this.sidePixels;
if(i % 3 == 2) {
frame.x = this.texture.width - this.sidePixels;
}
}
if(i >= 3 && i <= 5) {
frame.height = this.texture.height - 2 * this.sidePixels;
frame.y = this.sidePixels;
} else {
frame.height = this.sidePixels;
if(i > 5) {
frame.y = this.texture.height - this.sidePixels;
}
}
this.textureParts[i].frame = new PIXI.Rectangle(this.textureParts[i].frame.x + frame.x,this.textureParts[i].frame.y + frame.y,frame.width,frame.height);
this.textureParts[i].update();
}
if(gui_NinePatch.ninePatchTextureCache.h.__keys__[this.texture.__id__] == null) {
var this1 = gui_NinePatch.ninePatchTextureCache;
var k = this.texture;
var v = new haxe_ds_IntMap();
this1.set(k,v);
}
var v = this.textureParts;
gui_NinePatch.ninePatchTextureCache.h[this.texture.__id__].h[this.sidePixels] = v;
}
this.textureSets.push(this.textureParts);
}
,updateSprites: function(refresh) {
if(refresh == null) {
refresh = false;
}
if(this.npWidth == 0 || this.npHeight == 0) {
this.visible = false;
return;
}
this.visible = true;
if(refresh) {
var _g = 0;
var _g1 = this.children;
while(_g < _g1.length) {
var child = _g1[_g];
++_g;
child.destroy();
}
this.children = [];
}
var _g = 0;
while(_g < 9) {
var i = _g++;
var thisSprite = null;
if(this.children.length <= i) {
thisSprite = new PIXI.Sprite(this.textureParts[i]);
this.addChild(thisSprite);
} else {
thisSprite = this.children[i];
thisSprite.texture = this.textureParts[i];
}
var tmp;
switch(i % 3) {
case 1:
tmp = this.sidePixels;
break;
case 2:
tmp = this.npWidth - this.sidePixels;
break;
default:
tmp = 0;
}
thisSprite.position.x = tmp;
if(i % 3 == 1) {
thisSprite.width = this.npWidth - this.sidePixels * 2;
}
var tmp1;
switch(i / 3 | 0) {
case 1:
tmp1 = this.sidePixels;
break;
case 2:
tmp1 = this.npHeight - this.sidePixels;
break;
default:
tmp1 = 0;
}
thisSprite.position.y = tmp1;
if((i / 3 | 0) == 1) {
if(this.npHeight - this.sidePixels * 2 < 0) {
thisSprite.height = 0;
} else {
thisSprite.height = this.npHeight - this.sidePixels * 2;
}
}
}
}
,__class__: gui_NinePatch
});
var gui_NumberSelectControl = function(gui,stage,parent,padding,getMinValue,getMaxValue,initialValue,setValue,setToOnClick,onClickHelp,stepSize) {
if(stepSize == null) {
stepSize = 1;
}
if(onClickHelp == null) {
onClickHelp = "";
}
if(initialValue == null) {
initialValue = 0;
}
this.number = 0;
var _gthis = this;
gui_GUIContainer.call(this,gui,stage,parent,null,null,null,null,padding);
this.getMinValue = getMinValue;
this.getMaxValue = getMaxValue;
this.number = initialValue;
this.setValue = setValue;
this.setToOnClick = setToOnClick;
this.numberButton = new gui_ContainerButton(gui,stage,this,function() {
var originalNumber = _gthis.number;
_gthis.number = setToOnClick();
if(_gthis.number != originalNumber) {
setValue(_gthis.number);
}
},null,function() {
gui.tooltip.setText(_gthis,onClickHelp);
});
var extraSpacing = gui.game.isMobile ? 2 : 0;
var extraSpacingLR = gui.game.isMobile ? 4 : 0;
this.numberButton.container.padding = { left : 3 + extraSpacingLR, right : 3 + extraSpacingLR, top : 3 + extraSpacing, bottom : -1 + extraSpacing};
this.numberButton.container.minHeight = 12;
this.numberButton.container.minWidth = 20;
this.numberButton.container.addChild(new gui_TextElement(this.numberButton.container,stage,null,function() {
if(_gthis.number == _gthis.beyondHighestValue) {
return _gthis.beyondHighestText;
} else {
return "" + _gthis.number;
}
}));
this.addChild(this.numberButton);
this.numberButton.buttonPatch.updateSprites(true);
var upDownButtons = new gui_GUIContainer(gui,stage,this);
upDownButtons.direction = gui.game.isMobile ? gui_GUIContainerDirection.Horizontal : gui_GUIContainerDirection.Vertical;
this.upButton = new gui_ImageButton(gui,stage,this,function() {
if(!(_gthis.beyondHighestValue != null && _gthis.number == _gthis.beyondHighestValue)) {
if(getMaxValue == null || _gthis.number + stepSize <= getMaxValue()) {
_gthis.number += stepSize;
if(setValue != null) {
setValue(_gthis.number);
}
} else if(_gthis.beyondHighestValue != null && _gthis.number != _gthis.beyondHighestValue) {
_gthis.number = _gthis.beyondHighestValue;
if(setValue != null) {
setValue(_gthis.number);
}
}
}
},Resources.getTexture(gui.game.isMobile ? "spr_arrowup_big" : "spr_arrowup"),null,null,null,gui.game.isMobile ? "spr_button_small" : "spr_minibutton");
this.upButton.canBeHeld = true;
upDownButtons.addChild(this.upButton);
this.downButton = new gui_ImageButton(gui,stage,this,function() {
if(_gthis.beyondHighestValue != null && _gthis.number == _gthis.beyondHighestValue) {
if(getMaxValue != null) {
_gthis.number = getMaxValue();
}
if(setValue != null) {
setValue(_gthis.number);
}
} else if(getMinValue == null || _gthis.number - stepSize >= getMinValue()) {
_gthis.number -= stepSize;
if(setValue != null) {
setValue(_gthis.number);
}
}
},Resources.getTexture(gui.game.isMobile ? "spr_arrowdown_big" : "spr_arrowdown"),null,null,null,gui.game.isMobile ? "spr_button_small" : "spr_minibutton");
this.downButton.canBeHeld = true;
upDownButtons.addChild(this.downButton);
this.addChild(upDownButtons);
};
$hxClasses["gui.NumberSelectControl"] = gui_NumberSelectControl;
gui_NumberSelectControl.__name__ = "gui.NumberSelectControl";
gui_NumberSelectControl.__super__ = gui_GUIContainer;
gui_NumberSelectControl.prototype = $extend(gui_GUIContainer.prototype,{
enableBeyondHighestValuePossibility: function(valueUsed,textShown) {
this.beyondHighestValue = valueUsed;
this.beyondHighestText = textShown;
}
,update: function() {
gui_GUIContainer.prototype.update.call(this);
if(this.number != this.beyondHighestValue) {
var originalNumber = this.number;
if(this.getMinValue != null) {
var val1 = this.getMinValue();
var val2 = this.number;
this.number = val2 > val1 ? val2 : val1;
}
if(this.getMaxValue != null) {
var val1 = this.getMaxValue();
var val2 = this.number;
this.number = val2 < val1 ? val2 : val1;
}
if(this.number != originalNumber) {
this.setValue(this.number);
}
}
}
,__class__: gui_NumberSelectControl
});
var gui_PopulationInfoWindow = function() { };
$hxClasses["gui.PopulationInfoWindow"] = gui_PopulationInfoWindow;
gui_PopulationInfoWindow.__name__ = "gui.PopulationInfoWindow";
gui_PopulationInfoWindow.create = function(city,gui,stage,$window) {
gui_PopulationInfoWindow.createWindow(city,gui,stage,$window);
};
gui_PopulationInfoWindow.createWindow = function(city,gui,stage,$window) {
$window.clear();
gui.windowAddTitleText("Population by Age",null,Resources.getTexture("spr_population"));
var childrenTotal = 0;
gui.windowAddInfoText(null,function() {
return "There are " + city.simulation.citizens.length + " citizens, of whom " + childrenTotal + " children.";
});
gui.windowAddInfoText(null,function() {
return "The amount of citizens of each age is shown below.";
});
var ageExceedingCitizensExist = false;
var oldestAge = 0;
var graphicsContainer = new PIXI.Container();
var graphics = new PIXI.Graphics();
var citizensPerAge;
var graphStartX = 40;
var graphMaxWidth = 210;
var maxAge = 120;
var ageRangeSize = 10;
var drawAgeGraphicsAndStats = function() {
ageExceedingCitizensExist = false;
oldestAge = 0;
graphics.clear();
graphics.beginFill(0);
graphics.drawRect(0,0,1,maxAge);
graphics.drawRect(graphStartX - 1,0,1,maxAge);
graphics.drawRect(0,maxAge,graphStartX,1);
var _g = [];
var _g1 = 0;
var _g2 = maxAge + 1;
while(_g1 < _g2) {
var i = _g1++;
_g.push(0);
}
citizensPerAge = _g;
childrenTotal = 0;
var _g = 0;
var _g1 = city.simulation.citizens;
while(_g < _g1.length) {
var citizen = _g1[_g];
++_g;
var age = citizen.get_age() | 0;
if(age > maxAge) {
citizensPerAge[maxAge]++;
ageExceedingCitizensExist = true;
} else {
citizensPerAge[age]++;
}
if(age < 16) {
childrenTotal += 1;
}
if(age > oldestAge) {
oldestAge = age;
}
}
var maxCitizens = common_ArrayExtensions.max(citizensPerAge);
if(maxCitizens != 0) {
var _g = 0;
var _g1 = maxAge + 1;
while(_g < _g1) {
var age = _g++;
var scale = citizensPerAge[age] / maxCitizens;
graphics.drawRect(graphStartX,age,scale * graphMaxWidth,1);
graphics.drawRect(graphStartX,age,scale * graphMaxWidth,1);
if(age % ageRangeSize == 0) {
graphics.drawRect(0,age,graphStartX,1);
}
}
}
graphics.endFill();
};
drawAgeGraphicsAndStats();
graphicsContainer.addChild(graphics);
var holder = null;
holder = new gui_ContainerHolder($window,stage,graphicsContainer,{ left : 0, right : 0, top : 0, bottom : 3},drawAgeGraphicsAndStats,function(mouse) {
var holder1;
var val = mouse.get_x();
if(val >= holder.rect.x && val < holder.rect.x + holder.rect.width) {
var val = mouse.get_y();
holder1 = val >= holder.rect.y && val < holder.rect.y + holder.rect.height;
} else {
holder1 = false;
}
if(holder1) {
if(mouse.get_x() >= holder.rect.x + graphStartX) {
var selectedAge = mouse.get_y() - holder.rect.y;
if(selectedAge < maxAge || selectedAge == maxAge && !ageExceedingCitizensExist) {
gui.tooltip.setText(holder,(citizensPerAge[selectedAge] == 1 ? "One citizen is" : "" + citizensPerAge[selectedAge] + " citizens are") + (" " + selectedAge + " years old."));
} else if(selectedAge == maxAge) {
gui.tooltip.setText(holder,(citizensPerAge[selectedAge] == 1 ? "One citizen is" : "" + citizensPerAge[selectedAge] + " citizens are") + (" " + selectedAge + " or older. The oldest is " + oldestAge + "."));
}
} else {
var selectedAgeRange = ((mouse.get_y() - holder.rect.y) / ageRangeSize | 0) * ageRangeSize;
if(selectedAgeRange < maxAge) {
var numberOfCitizensInRange = 0;
var isLastAgeRange = selectedAgeRange == maxAge - ageRangeSize;
var _g = selectedAgeRange;
var _g1 = selectedAgeRange + ageRangeSize + (isLastAgeRange ? 1 : 0);
while(_g < _g1) {
var i = _g++;
numberOfCitizensInRange += citizensPerAge[i];
}
if(isLastAgeRange && ageExceedingCitizensExist) {
gui.tooltip.setText(holder,(numberOfCitizensInRange == 1 ? "One citizen is" : "" + numberOfCitizensInRange + " citizens are") + (" " + selectedAgeRange + " or older."));
} else {
gui.tooltip.setText(holder,(numberOfCitizensInRange == 1 ? "One citizen is" : "" + numberOfCitizensInRange + " citizens are") + (" between " + selectedAgeRange + " and " + (selectedAgeRange + ageRangeSize) + " years old."));
}
}
}
return true;
}
return false;
});
$window.addChild(holder);
var _g = 0;
var _g1 = maxAge / ageRangeSize | 0;
while(_g < _g1) {
var i = _g++;
var bitmapText = new PIXI.extras.BitmapText("" + i * 10 + "-" + (i * 10 + 10),{ font : "Arial10", tint : 0});
if(i == (maxAge / ageRangeSize | 0) - 1 && ageExceedingCitizensExist) {
bitmapText.text = "" + i * 10 + "+";
}
bitmapText.position.set(2,i * 10);
graphicsContainer.addChild(bitmapText);
}
$window.onDestroy = function() {
graphics.destroy();
};
var popLimitController = new gui_GUIContainer(gui,stage,$window);
popLimitController.direction = gui_GUIContainerDirection.Vertical;
var hasCreatedPopLimitController = false;
popLimitController.onUpdate = function() {
if(!hasCreatedPopLimitController && city.simulation.citizens.length >= 1950) {
var popLimitController2 = new gui_GUIContainer(gui,stage,$window);
popLimitController2.direction = gui_GUIContainerDirection.Horizontal;
hasCreatedPopLimitController = true;
popLimitController2.padding.bottom = 6;
var popLimitText = new gui_TextElement(popLimitController,stage,"Population Limit: ");
popLimitText.padding.top = 1;
popLimitController2.addChild(popLimitText);
popLimitController2.addChild(new gui_GUISpacing(popLimitController2,new common_Point(4,2)));
var gui1 = gui;
var stage1 = stage;
var city1 = city.simulation.babyMaker.softPopLimit;
var numberSelectControl = city.game.textHelper.clickOrTap() + " to reset the population limit to the default.";
var numberSelectControl1 = new gui_NumberSelectControl(gui1,stage1,popLimitController2,{ left : 0, right : 0, top : 0, bottom : 0},function() {
return 2000;
},function() {
return 10000;
},city1,function(v) {
city.simulation.babyMaker.softPopLimit = v;
},function() {
return 2000;
},numberSelectControl,25);
popLimitController2.addChild(numberSelectControl1);
popLimitController.addChild(popLimitController2);
popLimitController.addChild(new gui_TextElement(popLimitController,stage,"Your population will no longer grow once you reach this limit. Please note that increasing this may result in a low frame rate and/or severe lag!"));
}
};
$window.addChild(popLimitController);
gui.windowAddBottomButtons([{ text : "Follow Citizen", action : function() {
city.viewActions.showFollow();
}}]);
};
var gui_PrivacyWindow = function() { };
$hxClasses["gui.PrivacyWindow"] = gui_PrivacyWindow;
gui_PrivacyWindow.__name__ = "gui.PrivacyWindow";
gui_PrivacyWindow.create = function(city,gui,stage,$window) {
gui.windowAddTitleText("Privacy Statement");
$window.addChild(new gui_TextElement($window,stage,"Welcome to this game by Wagtail Games (a sole proprietorship under Dutch law by Florian van Strien). Your privacy is very important to me." + " That's why the data this game collects about you is very limited.\n" + "Note that the portal or website on which you are playing might collect additional data, which is not covered by this privacy statement.\n\n" + "This game uses Google Analytics to collect limited, anonymous data on how you play the game. Google Analytics also uses cookies.\n" + "These analytics are used to improve this game and other games in the future. I feel this limited use of personal data and cookies is allowed as \"Legitimate Interest\" under the GDPR and similar laws. I have taken the following measures to protect your privacy, as recommended by the Dutch authority for personal data (\"Authoriteit Persoonsgegevens\"):\n" + "- I have entered into a processor agreement with Google\n" + "- I mask the last octet of your IP address\n" + "- I turned off \"data sharing\" with Google\n" + "- I do not use other Google services (such as ads) in combination with Google Analytics",null,"Arial"));
gui.windowAddBottomButtons();
};
var gui_ReplaceAllHousesWindow = function() { };
$hxClasses["gui.ReplaceAllHousesWindow"] = gui_ReplaceAllHousesWindow;
gui_ReplaceAllHousesWindow.__name__ = "gui.ReplaceAllHousesWindow";
gui_ReplaceAllHousesWindow.create = function(city,gui,stage,$window) {
gui_ReplaceAllHousesWindow.createWindow(city,gui,stage,$window);
};
gui_ReplaceAllHousesWindow.createWindow = function(city,gui,stage,$window) {
$window.clear();
gui.windowAddTitleText("Upgrade Basic Houses");
gui.windowAddInfoText("Basic Houses can't be upgraded to 100 quality. Instead, you can quickly upgrade them all to another type here.\n\nFirst, select a type to upgrade to:");
gui.windowInner.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,2)));
var allTypesDisplay = new gui_GUIContainer(gui,stage,$window);
allTypesDisplay.direction = gui_GUIContainerDirection.Horizontal;
gui.windowInner.addChild(allTypesDisplay);
var buildingsInDisplay = 0;
var _g = 0;
var _g1 = city.progress.resources.buildingInfoArray;
while(_g < _g1.length) {
var building = [_g1[_g]];
++_g;
var name = "buildings." + building[0].className;
var classToBuild = $hxClasses[name];
var unlockState = city.progress.unlocks.getUnlockState(classToBuild);
var sprName = Reflect.field(classToBuild,"spriteName");
if(building[0].category == "Houses" && (unlockState == progress_UnlockState.Unlocked && building[0].showUnlockHint == null || unlockState == progress_UnlockState.Researched || unlockState == progress_UnlockState.Createable) && building[0].specialInfo.indexOf("rooftop") == -1 && building[0].residents != null && building[0].className != "NormalHouse") {
if(buildingsInDisplay > 8) {
allTypesDisplay = new gui_GUIContainer(gui,stage,$window);
allTypesDisplay.direction = gui_GUIContainerDirection.Horizontal;
gui.windowInner.addChild(allTypesDisplay);
buildingsInDisplay = 0;
}
++buildingsInDisplay;
var createReplaceHousesStep2 = [null];
createReplaceHousesStep2[0] = (function(createReplaceHousesStep2,building) {
return function() {
city.gui.createWindow($window);
gui_ReplaceAllHousesWindowStep2.create(city,city.gui,city.gui.innerWindowStage,city.gui.windowInner,building[0]);
city.gui.addWindowToStack(createReplaceHousesStep2[0]);
};
})(createReplaceHousesStep2,building);
var buildingButton = new gui_ImageButton(gui,stage,allTypesDisplay,createReplaceHousesStep2[0],Resources.getTexture("" + sprName + "@0,0,20,20"),(function() {
return function() {
return false;
};
})(),(function() {
return function() {
};
})(),Resources.getTexture(building[0].buttonBack == null ? "" + sprName + "@44,0,20,20" : building[0].buttonBack));
allTypesDisplay.addChild(buildingButton);
}
}
gui.windowInner.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,6)));
gui.windowAddBottomButtons();
};
var gui_ReplaceAllHousesWindowStep2 = function() { };
$hxClasses["gui.ReplaceAllHousesWindowStep2"] = gui_ReplaceAllHousesWindowStep2;
gui_ReplaceAllHousesWindowStep2.__name__ = "gui.ReplaceAllHousesWindowStep2";
gui_ReplaceAllHousesWindowStep2.create = function(city,gui,stage,$window,newType) {
gui_ReplaceAllHousesWindowStep2.createWindow(city,gui,stage,$window,newType);
};
gui_ReplaceAllHousesWindowStep2.createWindow = function(city,gui,stage,$window,newType) {
$window.clear();
gui.windowAddTitleText("Upgrade to " + newType.name);
var costElement = new gui_MaterialsCostDisplay(city,new Materials(2,2));
var mcdContainer = new gui_GUIContainer(gui,gui.innerWindowStage,gui.windowInner);
var ch = mcdContainer.addChild(new gui_ContainerHolder(mcdContainer,gui.innerWindowStage,costElement,{ left : 0, right : 0, top : 0, bottom : 2}));
var newTypeCost = Materials.fromBuildingInfo(newType);
var totalCost = null;
var houses = null;
var canAffordNumber = 0;
var confirmButton = null;
gui.windowAddInfoText(null,function() {
var _g = [];
var _g1 = 0;
var _g2 = city.permanents;
while(_g1 < _g2.length) {
var v = _g2[_g1];
++_g1;
if(js_Boot.getClass(v) == buildings_NormalHouse) {
_g.push(v);
}
}
houses = _g;
if(houses.length == 0) {
costElement.setCost(new Materials());
canAffordNumber = 0;
confirmButton.setText("-");
return "There are no basic Houses.";
}
confirmButton.setText("Confirm");
var newTypeCostCurrent = newTypeCost.copy();
var name = "buildings." + newType.className;
if(city.progress.unlocks.getUnlockState($hxClasses[name]) == progress_UnlockState.Researched) {
newTypeCostCurrent.knowledge = 0;
}
var houseRefund = new Materials(4,4);
houseRefund.multiply(city.upgrades.vars.recyclingAmount);
newTypeCostCurrent.remove(houseRefund);
newTypeCostCurrent.roundAll();
totalCost = newTypeCostCurrent.copy();
var noKnowledgeCost = newTypeCostCurrent.copy();
noKnowledgeCost.knowledge = 0;
var val = city.materials.canAffordNumber(noKnowledgeCost);
var maxVal = houses.length;
canAffordNumber = val < 1 ? 1 : val > maxVal ? maxVal : val;
totalCost.multiply(canAffordNumber);
totalCost.knowledge = newTypeCostCurrent.knowledge;
var displayCost = totalCost.copy();
if(displayCost.wood < 0) {
displayCost.wood = 0;
}
if(displayCost.stone < 0) {
displayCost.stone = 0;
}
costElement.setCost(displayCost);
ch.updateSize();
return "Please note this cannot be undone.\n\nUpgrade " + canAffordNumber + " of " + houses.length + " basic Houses for:";
});
gui.windowInner.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,4)));
gui.windowInner.addChild(mcdContainer);
gui.windowInner.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,4)));
confirmButton = new gui_TextButton(gui,stage,gui.windowInner,function() {
if(totalCost != null && houses != null && houses.length > 0 && canAffordNumber > 0 && city.materials.canAfford(totalCost)) {
var newHouses = [];
var name = "buildings." + newType.className;
var bldClass = $hxClasses[name];
city.progress.unlocks.research(bldClass);
var _g = 0;
var _g1 = canAffordNumber;
while(_g < _g1) {
var i = _g++;
var house = houses[i];
house.destroyForReplacement();
house.world.build(bldClass,house.worldPosition.x,house.worldPosition.y);
newHouses.push(house);
}
city.connections.updateCityConnections();
city.simulation.updatePathfinder(true);
var _g = 0;
while(_g < newHouses.length) {
var newHouse = newHouses[_g];
++_g;
newHouse.postCreate();
}
city.progress.unlocks.checkBuildRelatedUnlocks();
city.materials.remove(totalCost);
gui.showSimpleWindow("Success! Upgraded " + canAffordNumber + " houses.",null,true);
}
},"Confirm");
gui.windowInner.addChild(confirmButton);
gui.windowInner.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,6)));
gui.windowAddBottomButtons();
};
var gui_SaveLoadWindows = function() { };
$hxClasses["gui.SaveLoadWindows"] = gui_SaveLoadWindows;
gui_SaveLoadWindows.__name__ = "gui.SaveLoadWindows";
gui_SaveLoadWindows.createSaveWindow = function(game,gui,text,windowOnDone,windowOnDestroy) {
gui.createWindow();
gui.windowRelatedTo = "saveLoad";
var game1 = game;
var gui1 = gui;
var text1 = text;
var windowOnDone1 = windowOnDone;
var windowOnDestroy1 = windowOnDestroy;
var tmp = function() {
gui_SaveLoadWindows.createSaveWindow(game1,gui1,text1,windowOnDone1,windowOnDestroy1);
};
gui.addWindowToStack(tmp);
gui.windowAddTitleText("Choose Save Slot");
gui.windowAddInfoText(text);
gui.windowAddBottomButtons();
gui_SaveLoadWindows.addSaveSlotButtons(game,gui,function(res) {
windowOnDone(res);
gui.windowOnDestroy = null;
gui.closeWindow();
},false,true);
gui.windowOnDestroy = windowOnDestroy;
};
gui_SaveLoadWindows.createLoadWindow = function(game,gui,text,windowOnDone,windowOnDestroy) {
gui.createWindow();
gui.windowRelatedTo = "saveLoad";
var game1 = game;
var gui1 = gui;
var text1 = text;
var windowOnDone1 = windowOnDone;
var windowOnDestroy1 = windowOnDestroy;
var tmp = function() {
gui_SaveLoadWindows.createLoadWindow(game1,gui1,text1,windowOnDone1,windowOnDestroy1);
};
gui.addWindowToStack(tmp);
gui.windowAddTitleText("Load a Game");
gui.windowAddInfoText(text);
gui.windowAddBottomButtons([{ text : "Import...", action : function() {
}, onHover : function() {
game.setOnClickTo = function() {
var importButton = window.document.getElementById("importFile");
importButton.value = "";
importButton.click();
game.onClick = null;
};
}}]);
gui_SaveLoadWindows.addSaveSlotButtons(game,gui,function(res) {
windowOnDone(res);
gui.windowOnDestroy = null;
gui.closeWindow();
},true,false);
gui.windowOnDestroy = windowOnDestroy;
};
gui_SaveLoadWindows.addSaveSlotButtons = function(game,gui,onDone,makeInactiveIfEmpty,showOverwrite) {
gui_SaveLoadWindows.createSaveSlotButton(game,gui,0,onDone,makeInactiveIfEmpty,showOverwrite,false);
gui_SaveLoadWindows.createSaveSlotButton(game,gui,1,onDone,makeInactiveIfEmpty,showOverwrite,false);
gui_SaveLoadWindows.createSaveSlotButton(game,gui,2,onDone,makeInactiveIfEmpty,showOverwrite,false);
gui_SaveLoadWindows.createSaveSlotButton(game,gui,3,onDone,makeInactiveIfEmpty,showOverwrite,false);
gui_SaveLoadWindows.createSaveSlotButton(game,gui,4,onDone,makeInactiveIfEmpty,showOverwrite,false);
if(2 == 8) {
gui_SaveLoadWindows.createSaveSlotButton(game,gui,5,onDone,makeInactiveIfEmpty,showOverwrite,true);
}
};
gui_SaveLoadWindows.createSaveSlotButton = function(game,gui,slot,onChoose,makeInactiveIfEmpty,showOverwrite,recurseIfFull) {
if(recurseIfFull == null) {
recurseIfFull = true;
}
if(gui.windowRelatedTo != "saveLoad") {
return;
}
var parentContainer = new gui_GUIContainer(gui,gui.innerWindowStage,gui.windowInner);
parentContainer.fillSecondarySize = true;
parentContainer.direction = gui_GUIContainerDirection.Vertical;
common_Storage.getItem("" + slot + "__meta",function(err,slotBottomText) {
var makeInactive = false;
var extraText = "";
var needsOverwrite = false;
var shouldRecurse = false;
if(err != null || slotBottomText == null) {
slotBottomText = "(empty)";
makeInactive = makeInactiveIfEmpty;
} else {
if(showOverwrite) {
extraText = "(overwrite)";
needsOverwrite = true;
}
shouldRecurse = true;
}
var overwriteIsOn = false;
var ab = null;
ab = gui_UpgradeWindowParts.createActivatableButton(gui,makeInactive,function() {
if(needsOverwrite && !overwriteIsOn) {
overwriteIsOn = true;
ab.titleText.setText("Really overwrite slot " + (slot + 1) + "?");
} else {
onChoose("" + slot);
}
},"Slot " + (slot + 1) + " " + extraText,slotBottomText,parentContainer,"spr_9p_button_disabled",null,gui_SaveLoadWindows.isWeirdText(slotBottomText));
if(recurseIfFull && slot < 100 && shouldRecurse) {
gui_SaveLoadWindows.createSaveSlotButton(game,gui,slot + 1,onChoose,makeInactiveIfEmpty,showOverwrite,true);
}
});
parentContainer.padding.bottom = 2;
gui.windowInner.insertChild(parentContainer,gui.windowInner.children.length - 1);
};
gui_SaveLoadWindows.isWeirdText = function(str) {
var r = new EReg("[^a-zA-Z\\-: 0-9<>\\[\\]{}~`=|\\\\@!#$%^&*\\(\\)_?]+","g");
return r.match(str);
};
var gui_ScrollBar = function(parent,stage,scrollable) {
this.resetTexturesNextUpdate = false;
this.width = 10;
if(Main.isMobile) {
this.width = 14;
}
this.parent = parent;
this.stage = stage;
this.scrollable = scrollable;
this.rect = new common_Rectangle(0,0,this.width,0);
var windowParts = Resources.getTextures("spr_windowparts",4);
this.background = new gui_NinePatch(windowParts[0],3,9,9);
stage.addChild(this.background);
this.scrollbar = new gui_NinePatch(windowParts[1],3,9,9);
this.scrollbar.texture = windowParts[2];
this.scrollbar.updateTextures(false);
this.scrollbar.texture = windowParts[3];
this.scrollbar.updateTextures(false);
this.scrollbar.texture = windowParts[1];
this.scrollbar.updateTextures(false);
stage.addChild(this.scrollbar);
};
$hxClasses["gui.ScrollBar"] = gui_ScrollBar;
gui_ScrollBar.__name__ = "gui.ScrollBar";
gui_ScrollBar.__interfaces__ = [gui_IGUIElement];
gui_ScrollBar.prototype = {
get_scrollPart: function() {
return this.scrollable.scrollPosition.y;
}
,get_scrollHandlePosition: function() {
return Math.round(this.get_scrollPart() / this.scrollable.get_innerHeight() * this.rect.height);
}
,get_scrollHandleHeight: function() {
return Math.round(this.scrollable.rect.height / this.scrollable.get_innerHeight() * this.rect.height);
}
,updateSize: function() {
this.parent.updateSize();
}
,updatePosition: function(newPosition) {
var _this = this.rect;
var inlPoint_x = _this.x = newPosition.x;
var inlPoint_y = _this.y = newPosition.y;
this.redraw();
}
,redraw: function() {
if(this.scrollable != null) {
this.background.npWidth = this.width;
this.background.npHeight = this.rect.height;
var _this = this.rect;
var inlPoint_x = _this.x;
var inlPoint_y = _this.y;
this.background.position.x = inlPoint_x;
var _this = this.rect;
var inlPoint_x = _this.x;
var inlPoint_y = _this.y;
this.background.position.y = inlPoint_y;
this.background.updateSprites(true);
this.scrollbar.npWidth = this.width;
this.scrollbar.npHeight = this.get_scrollHandleHeight();
var _this = this.rect;
var inlPoint_x = _this.x;
var inlPoint_y = _this.y;
this.scrollbar.position.x = inlPoint_x;
var _this = this.rect;
var inlPoint_x = _this.x;
var inlPoint_y = _this.y;
var tmp = this.get_scrollHandlePosition();
this.scrollbar.position.y = inlPoint_y + tmp;
this.scrollbar.updateSprites(true);
}
}
,destroy: function() {
this.stage.removeChild(this.background);
this.stage.removeChild(this.scrollbar);
}
,handleMouse: function(mouse) {
var _gthis = this;
if(this.rect.contains(mouse.position)) {
this.scrollable.handleScrollWheel(mouse);
var wasInScrollbarHandle = true;
var mouseStartY = 0;
var mouseRelativeStartY = 0;
var relativeMouseY;
var isInScrollBarHandle;
relativeMouseY = mouse.get_y() - _gthis.rect.y;
var lower = _gthis.get_scrollHandlePosition();
var upper = _gthis.get_scrollHandlePosition() + _gthis.get_scrollHandleHeight();
isInScrollBarHandle = relativeMouseY >= lower && relativeMouseY < upper;
if(isInScrollBarHandle) {
this.scrollbar.setTextureSet(1);
this.resetTexturesNextUpdate = false;
}
mouse.strongClaimMouse(this,function() {
if(_gthis.scrollable != null && _gthis.background.parent != null) {
_gthis.resetTexturesNextUpdate = false;
_gthis.scrollbar.setTextureSet(2);
relativeMouseY = mouse.get_y() - _gthis.rect.y;
var lower = _gthis.get_scrollHandlePosition();
var upper = _gthis.get_scrollHandlePosition() + _gthis.get_scrollHandleHeight();
isInScrollBarHandle = relativeMouseY >= lower && relativeMouseY < upper;
if(mouse.pressed) {
mouseStartY = relativeMouseY;
mouseRelativeStartY = mouseStartY - _gthis.get_scrollHandlePosition();
wasInScrollbarHandle = isInScrollBarHandle;
}
var maxScrollY = _gthis.scrollable.get_innerHeight() - _gthis.scrollable.rect.height;
var newScrollPart = _gthis.scrollable.scrollPosition.y;
if(wasInScrollbarHandle) {
var newScrollBarTop = relativeMouseY - mouseRelativeStartY;
if(_gthis.rect.height != 0) {
newScrollPart = Math.round(newScrollBarTop * (_gthis.scrollable.get_innerHeight() / _gthis.rect.height));
}
} else {
var scrollBarMid = _gthis.get_scrollHandlePosition() + _gthis.get_scrollHandleHeight() / 2;
var currentScrollSpeed = Math.round(8 * mouse.timeMod);
if(relativeMouseY < scrollBarMid - currentScrollSpeed) {
newScrollPart -= currentScrollSpeed;
} else if(relativeMouseY >= scrollBarMid + currentScrollSpeed) {
newScrollPart += currentScrollSpeed;
}
}
if(newScrollPart < 0) {
newScrollPart = 0;
} else if(newScrollPart > maxScrollY) {
newScrollPart = maxScrollY;
}
_gthis.scrollable.updateScrollPosition(new common_Point(_gthis.scrollable.scrollPosition.x,newScrollPart));
}
});
return true;
}
return false;
}
,update: function() {
if(this.resetTexturesNextUpdate) {
this.scrollbar.setTextureSet(0);
}
this.resetTexturesNextUpdate = true;
}
,__class__: gui_ScrollBar
};
var gui_SecretCodeWindow = function() { };
$hxClasses["gui.SecretCodeWindow"] = gui_SecretCodeWindow;
gui_SecretCodeWindow.__name__ = "gui.SecretCodeWindow";
gui_SecretCodeWindow.create = function(city,gui,stage,thisWindow) {
gui.windowAddTitleText("Secret Code");
thisWindow.addChild(new gui_TextElement(thisWindow,stage,"You can use secret codes to unlock cool cosmetic options.\n" + "Subscribe to my mailing list, and I'll send you a code right away as a small gesture of thanks! I'll also update you on this game and future releases."));
thisWindow.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,2)));
thisWindow.addChild(new gui_TextButton(gui,stage,gui.windowInner,function() {
},"Subscribe to my mailing list!",function() {
return false;
},function() {
city.game.setOnClickTo = function() {
window.open(Config.mailingListURL,"_blank");
};
}));
thisWindow.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,6)));
thisWindow.addChild(new gui_TextElement(thisWindow,stage,"Plus, you can try the following code as a reward for your curiosity: Dance All Night"));
thisWindow.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,4)));
var handleInput = function(input) {
if(input == null) {
return false;
}
switch(input.toLowerCase()) {
case "coolmath":
var createThisWindow = null;
createThisWindow = function() {
gui.showSimpleWindow(gui_SecretCodeWindow.getCoolMathText(city,true),"",true);
gui.addWindowToStack(createThisWindow,true);
gui.setWindowReload(createThisWindow);
};
createThisWindow();
return true;
case "dance all night":
Settings.unlockSecretCode("nightClubColors");
var createThisWindow1 = null;
createThisWindow1 = function() {
gui.showSimpleWindow("You can now change the light show of night clubs!","Secret Code Activated!",true);
gui.addWindowToStack(createThisWindow1,true);
gui.setWindowReload(createThisWindow1);
};
createThisWindow1();
return true;
case "debug_pathfinder":
gui.createWindow();
gui.windowAddInfoText(null,function() {
return "" + city.simulation.pathfinder.getTotalNumberOfRequested();
});
return true;
case "hangar":
Settings.unlockSecretCode("hangar");
var createThisWindow2 = null;
createThisWindow2 = function() {
gui.showSimpleWindow("You can now choose between multiple space ships for Landing Pads.","Secret Code Activated!",true);
gui.addWindowToStack(createThisWindow2,true);
gui.setWindowReload(createThisWindow2);
};
createThisWindow2();
return true;
case "orchid":
Settings.unlockSecretCode("orchid");
var createThisWindow3 = null;
createThisWindow3 = function() {
gui.showSimpleWindow("Thanks a lot for having subscribed to my mailing list! New plant and flower options have now been unlocked.","Secret Code Activated!",true);
gui.addWindowToStack(createThisWindow3,true);
gui.setWindowReload(createThisWindow3);
};
createThisWindow3();
return true;
case "stats":
var createThisWindow4 = null;
createThisWindow4 = function() {
gui.showSimpleWindow(gui_SecretCodeWindow.getCoolMathText(city,false),"",true);
gui.addWindowToStack(createThisWindow4,true);
gui.setWindowReload(createThisWindow4);
};
createThisWindow4();
return true;
}
return false;
};
if(2 == 8) {
thisWindow.addChild(new gui_TextButton(gui,stage,gui.windowInner,function() {
var inp = window.prompt("Enter a Secret Code");
if(inp != null && !handleInput(inp)) {
window.alert("Unfortunately, that code isn't correct!");
}
},"Enter Secret Code",function() {
return false;
}));
} else {
var textInput = new gui_TextInput(gui.windowInner,gui,city.game,"Enter Secret Code");
thisWindow.addChild(textInput);
textInput.onInput = handleInput;
}
thisWindow.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,4)));
gui.windowAddBottomButtons();
};
gui_SecretCodeWindow.getCoolMathText = function(city,triggeredByCoolmath) {
var numberOfBuildings = Lambda.count(city.permanents,function(pm) {
return pm.isBuilding;
});
var nameDataText = "";
if(Resources.citizenNames.length > 0) {
var namesOccurences_h = Object.create(null);
var _g = 0;
var _g1 = city.simulation.citizens;
while(_g < _g1.length) {
var citizen = _g1[_g];
++_g;
if(!Object.prototype.hasOwnProperty.call(namesOccurences_h,citizen.nameIndex < Resources.citizenNames.length ? Resources.citizenNames[citizen.nameIndex] : "Citizen")) {
namesOccurences_h[citizen.nameIndex < Resources.citizenNames.length ? Resources.citizenNames[citizen.nameIndex] : "Citizen"] = 1;
} else {
var _g2 = citizen.nameIndex < Resources.citizenNames.length ? Resources.citizenNames[citizen.nameIndex] : "Citizen";
var v = namesOccurences_h[_g2] + 1;
namesOccurences_h[_g2] = v;
}
}
var mostOccuringName = "";
var mostOccuringNameOcc = 0;
var totalUniqueNames = 0;
var occ = haxe_ds_StringMap.keysIterator(namesOccurences_h);
while(occ.hasNext()) {
var occ1 = occ.next();
if(mostOccuringNameOcc < namesOccurences_h[occ1]) {
mostOccuringName = occ1;
mostOccuringNameOcc = namesOccurences_h[occ1];
}
++totalUniqueNames;
}
var sce = "";
if(mostOccuringNameOcc > 2 && triggeredByCoolmath) {
sce = " If you want to know why there is a name that is so relatively common, take a look at the birthday paradox.";
}
nameDataText = "\n\nYour " + city.simulation.citizens.length + " citizens share " + totalUniqueNames + " unique names. The most common one is " + mostOccuringName + ", which occurs " + namesOccurences_h[mostOccuringName] + " times." + sce;
}
var highestStack = 0;
var _g = 0;
var _g1 = city.worlds;
while(_g < _g1.length) {
var w = _g1[_g];
++_g;
var _g2 = 0;
var _g3 = w.permanents;
while(_g2 < _g3.length) {
var s = _g3[_g2];
++_g2;
var thisStackLen = 0;
var maxStackLen = 0;
var _g4 = 0;
while(_g4 < s.length) {
var b = s[_g4];
++_g4;
if(b != null && b.isBuilding) {
++thisStackLen;
} else {
thisStackLen = 0;
}
if(maxStackLen <= thisStackLen) {
maxStackLen = thisStackLen;
}
}
if(highestStack <= maxStackLen) {
highestStack = maxStackLen;
}
}
}
var transportStats = "";
if(city.landingSites.length > 0) {
if(transportStats == "") {
transportStats = "\n\n";
} else {
transportStats += " ";
}
transportStats += "In total, your landing pads have been used " + common_ArrayExtensions.sum(city.landingSites,function(ls) {
return ls.timesUsed;
}) + " times, including " + common_ArrayExtensions.sum(city.landingSites,function(ls) {
return ls.timesUsedStopOver;
}) + " times as stopover.";
if(city.simulation.flyingSaucers.length > 10) {
var spaceShipPeople = common_ArrayExtensions.isum(city.simulation.flyingSaucers,function(fs) {
return fs.passengers.length;
});
transportStats += " Right now, there are " + city.simulation.flyingSaucers.length + " space ships in the air, containing " + spaceShipPeople + " people.";
}
}
var _g = [];
var _g1 = 0;
var _g2 = city.permanents;
while(_g1 < _g2.length) {
var v = _g2[_g1];
++_g1;
if(v.is(buildings_HyperElevator)) {
_g.push(v);
}
}
var hyperElevators = _g;
if(hyperElevators.length > 0) {
if(transportStats == "") {
transportStats = "\n\n";
} else {
transportStats += "\n";
}
transportStats += "Your hyper elevators have been used " + common_ArrayExtensions.sum(hyperElevators,function(he) {
return he.timesUsed;
}) + " times.";
}
if(city.teleporters.length > 0) {
if(transportStats == "") {
transportStats = "\n\n";
} else {
transportStats += "\n";
}
transportStats += "Your teleporters have been used " + common_ArrayExtensions.sum(city.teleporters,function(tp) {
return tp.timesUsed;
}) + " times.";
}
var statsText = "Alright, here are some stats about your city!";
if(triggeredByCoolmath) {
statsText = "Alright, I did some cool math; here are some stats about your city!";
}
return "" + statsText + " :)\n\nThere are " + numberOfBuildings + " buildings. The highest tower is " + highestStack + " buildings high." + transportStats + nameDataText;
};
var gui_TextButton = function(gui,stage,parent,action,text,isActive,onHover,buttonSpriteName) {
if(buttonSpriteName == null) {
buttonSpriteName = "spr_button";
}
this.extraTextPosY = 0;
this.extraHeight = 0;
this.extraWidth = 0;
if(Main.isMobile) {
this.extraHeight += 4;
this.extraTextPosY += 2;
}
gui_Button.call(this,gui,stage,parent,action,isActive,onHover);
this.buttonTextures = Resources.getTextures(buttonSpriteName,3);
this.buttonPatch = new gui_NinePatch(this.buttonTextures[0],2,2,this.buttonTextures[0].height | 0);
this.buttonPatch.texture = this.buttonTextures[1];
this.buttonPatch.updateTextures(false);
this.buttonPatch.texture = this.buttonTextures[2];
this.buttonPatch.updateTextures(false);
this.buttonPatch.setTextureSet(0);
stage.addChild(this.buttonPatch);
this.rect = new common_Rectangle(0,0,1,(this.buttonTextures[0].height | 0) + 2);
this.bitmapText = new PIXI.extras.BitmapText(text,{ font : "Arial", tint : 0});
this.setText(text,false);
stage.addChild(this.bitmapText);
};
$hxClasses["gui.TextButton"] = gui_TextButton;
gui_TextButton.__name__ = "gui.TextButton";
gui_TextButton.__super__ = gui_Button;
gui_TextButton.prototype = $extend(gui_Button.prototype,{
setText: function(text,calculateSize) {
if(calculateSize == null) {
calculateSize = true;
}
this.text = text;
this.bitmapText.text = text;
this.rect.width = Math.ceil(this.bitmapText.textWidth) + 6 + this.extraWidth;
this.rect.height = Math.ceil(this.bitmapText.textHeight) + 3 + this.extraHeight;
this.buttonPatch.npWidth = this.rect.width;
this.buttonPatch.npHeight = this.rect.height;
if(calculateSize) {
this.updateSize();
}
}
,updatePosition: function(newPosition) {
var _this = this.rect;
var inlPoint_x = _this.x = newPosition.x;
var inlPoint_y = _this.y = newPosition.y;
this.buttonPatch.position.set(newPosition.x,newPosition.y);
this.buttonPatch.updateSprites();
this.bitmapText.position.set(newPosition.x + 3 + (this.extraWidth / 2 | 0),newPosition.y + 1 + this.extraTextPosY);
gui_Button.prototype.updatePosition.call(this,newPosition);
}
,handleMouse: function(mouse) {
var _gthis = this;
return gui_Button.prototype.doHandleMouse.call(this,mouse,function() {
_gthis.buttonPatch.setTextureSet(1);
},function() {
_gthis.buttonPatch.setTextureSet(2);
});
}
,update: function() {
if(this.mouseOut) {
this.buttonPatch.setTextureSet(0);
}
if(this.isActive()) {
this.buttonPatch.setTextureSet(2);
}
gui_Button.prototype.update.call(this);
}
,destroy: function() {
gui_Button.prototype.destroy.call(this);
this.stage.removeChild(this.buttonPatch);
this.stage.removeChild(this.bitmapText);
}
,__class__: gui_TextButton
});
var gui_TextElement = function(parent,stage,text,textUpdateFunction,font,padding,maxWidth,neverDecreaseSize) {
if(neverDecreaseSize == null) {
neverDecreaseSize = false;
}
if(maxWidth == null) {
maxWidth = 250;
}
if(font == null) {
font = "Arial";
}
if(text == null) {
text = "";
}
var textContainer = new PIXI.extras.BitmapText("",{ font : font, tint : 0});
textContainer.maxWidth = maxWidth;
textContainer.text = text;
this.textUpdateFunction = textUpdateFunction;
this.neverDecreaseSize = neverDecreaseSize;
var addToPadding;
switch(font) {
case "Arial":
addToPadding = { left : 0, right : 0, top : -2, bottom : 2};
break;
case "Arial10":
addToPadding = { left : 0, right : 0, top : -3, bottom : 3};
break;
case "Arial15":
addToPadding = { left : 0, right : 0, top : -3, bottom : 2};
break;
case "Arial16":
addToPadding = { left : 0, right : 0, top : -2, bottom : 4};
break;
default:
addToPadding = { left : 0, right : 0, top : -3, bottom : 2};
}
if(padding == null) {
padding = addToPadding;
} else {
padding = { left : padding.left + addToPadding.left, right : padding.right + addToPadding.right, top : padding.top + addToPadding.top, bottom : padding.bottom + addToPadding.bottom};
}
gui_ContainerHolder.call(this,parent,stage,textContainer,padding);
};
$hxClasses["gui.TextElement"] = gui_TextElement;
gui_TextElement.__name__ = "gui.TextElement";
gui_TextElement.__super__ = gui_ContainerHolder;
gui_TextElement.prototype = $extend(gui_ContainerHolder.prototype,{
get_textContainer: function() {
return this.container;
}
,updateSize: function() {
var newWidth;
var newHeight;
var oldWidthNoPadding = this.rect.width - this.padding.left - this.padding.right;
var oldHeightNoPadding = this.rect.height - this.padding.top - this.padding.bottom;
if(this.get_textContainer().text == "") {
newWidth = 0;
newHeight = 0;
} else {
var bitmapContainer = this.container;
newWidth = Math.round(bitmapContainer.textWidth);
newHeight = Math.round(bitmapContainer.textHeight);
}
if(this.neverDecreaseSize) {
this.rect.width = newWidth > oldWidthNoPadding ? newWidth : oldWidthNoPadding;
this.rect.height = newHeight > oldHeightNoPadding ? newHeight : oldHeightNoPadding;
} else {
this.rect.width = newWidth;
this.rect.height = newHeight;
}
if(oldWidthNoPadding != this.rect.width || oldHeightNoPadding != this.rect.height) {
gui_ContainerHolder.prototype.afterSizeUpdate.call(this);
}
}
,setTextAndTextUpdate: function(text,updateFunc) {
this.setText(text);
this.textUpdateFunction = updateFunc;
}
,setText: function(text) {
var bitmapContainer = this.container;
if(StringTools.startsWith(text,"[red]")) {
text = HxOverrides.substr(text,"[red]".length,null);
bitmapContainer.tint = 16711680;
} else if(StringTools.startsWith(text,"[green]")) {
text = HxOverrides.substr(text,"[green]".length,null);
bitmapContainer.tint = 65280;
} else {
bitmapContainer.tint = 0;
}
this.get_textContainer().text = text;
this.updateSize();
}
,update: function() {
if(this.textUpdateFunction != null) {
var newText = this.textUpdateFunction();
if(this.get_textContainer().text != newText) {
this.setText(newText);
}
}
}
,__class__: gui_TextElement
});
var gui_TextElementAlt = function(parent,stage,text,textUpdateFunction,font,padding,maxWidth,neverDecreaseSize,fontSize) {
if(fontSize == null) {
fontSize = 12;
}
if(neverDecreaseSize == null) {
neverDecreaseSize = false;
}
if(maxWidth == null) {
maxWidth = 250;
}
if(font == null) {
font = "Arial";
}
if(text == null) {
text = "";
}
var textContainer = new PIXI.Text("",{ fontFamily : font, fill : 0, fontSize : fontSize * 2, wordWrap : true, wordWrapWidth : maxWidth * 2});
textContainer.text = text;
textContainer.scale.x = 0.5;
textContainer.scale.y = 0.5;
textContainer.roundPixels = true;
this.textUpdateFunction = textUpdateFunction;
this.neverDecreaseSize = neverDecreaseSize;
var padding = { left : 0, right : 0, top : -3, bottom : 2};
gui_ContainerHolder.call(this,parent,stage,textContainer,padding);
};
$hxClasses["gui.TextElementAlt"] = gui_TextElementAlt;
gui_TextElementAlt.__name__ = "gui.TextElementAlt";
gui_TextElementAlt.__super__ = gui_ContainerHolder;
gui_TextElementAlt.prototype = $extend(gui_ContainerHolder.prototype,{
get_textContainer: function() {
return this.container;
}
,setText: function(text) {
var textContainer = this.container;
textContainer.text = text;
this.updateSize();
}
,update: function() {
if(this.textUpdateFunction != null) {
var newText = this.textUpdateFunction();
if(this.get_textContainer().text != newText) {
this.setText(newText);
}
}
}
,__class__: gui_TextElementAlt
});
var gui_TextInput = function(parent,gui,game,placeholder,defaultText) {
if(defaultText == null) {
defaultText = "";
}
if(placeholder == null) {
placeholder = "";
}
this.onInput = null;
var _gthis = this;
this.parent = parent;
this.gui = gui;
this.game = game;
this.rect = new common_Rectangle(0,0,250,20);
this.inputElement = window.document.createElement("input");
this.inputElement.type = "text";
this.inputElement.style.position = "absolute";
this.inputElement.style.left = "10px";
this.inputElement.style.top = "10px";
this.inputElement.style.fontFamily = "Arial,sans-serif";
this.inputElement.style.fontSize = "20px";
this.inputElement.value = defaultText;
this.inputElement.placeholder = placeholder;
window.document.body.appendChild(this.inputElement);
this.inputElement.focus();
game.keyboard.inputs.push(this.inputElement);
this.inputElement.addEventListener("input",function() {
if(_gthis.onInput != null) {
_gthis.onInput(_gthis.inputElement.value);
}
});
};
$hxClasses["gui.TextInput"] = gui_TextInput;
gui_TextInput.__name__ = "gui.TextInput";
gui_TextInput.__interfaces__ = [gui_IGUIElement];
gui_TextInput.prototype = {
updateSize: function() {
var tmp = "" + Math.floor(this.rect.width * this.game.get_preDPIAdjustScaling() - 6);
this.inputElement.style.width = tmp + "px";
var tmp = "" + Math.floor(10 * this.game.get_preDPIAdjustScaling());
this.inputElement.style.fontSize = tmp + "px";
var tmp = "" + Math.floor(this.rect.height * this.game.get_preDPIAdjustScaling() - 6);
this.inputElement.style.height = tmp + "px";
}
,updatePosition: function(newPosition) {
var tmp = Math.floor(newPosition.x * this.game.get_preDPIAdjustScaling());
this.inputElement.style.left = tmp + "px";
var tmp = Math.floor(newPosition.y * this.game.get_preDPIAdjustScaling());
this.inputElement.style.top = tmp + "px";
this.updateSize();
}
,destroy: function() {
this.inputElement.parentNode.removeChild(this.inputElement);
HxOverrides.remove(this.game.keyboard.inputs,this.inputElement);
}
,handleMouse: function(mouse) {
if(this.rect.contains(mouse.position)) {
return true;
}
return false;
}
,update: function() {
}
,__class__: gui_TextInput
};
var gui_Tooltip = function(game,city,stage) {
this.isContinousDisplay = false;
this.contentsSetLastStep = false;
this.timeBeforeShown = 0;
this.owner = null;
this.emptyCost = new Materials();
this.game = game;
this.stage = stage;
this.bg = new gui_NinePatch(Resources.getTexture("spr_9p_tooltip"),2,4,4);
this.bg.position.set(0,0);
stage.addChild(this.bg);
this.tooltipHeader = new PIXI.extras.BitmapText("",{ font : "Arial16", tint : 0});
this.tooltipHeader.position.set(2,0);
stage.addChild(this.tooltipHeader);
this.tooltipText = new PIXI.extras.BitmapText("",{ font : "Arial", tint : 0});
this.tooltipText.position.set(3,0);
stage.addChild(this.tooltipText);
this.tooltipCost = new gui_MaterialsCostDisplay(city,this.emptyCost);
this.tooltipCost.position.set(3,0);
stage.addChild(this.tooltipCost);
this.tooltipExtraIcons = new gui_IconListDisplay([]);
stage.addChild(this.tooltipExtraIcons);
this.tooltipExtraIcons2 = new gui_IconListDisplay([]);
this.tooltipExtraIcons2.position.set(2,0);
stage.addChild(this.tooltipExtraIcons2);
this.tooltipPosition = new common_Point(0,0);
stage.position.set(-100,-100);
this.owner = null;
this.timeBeforeShown = 0;
this.setTextDisplay("","");
};
$hxClasses["gui.Tooltip"] = gui_Tooltip;
gui_Tooltip.__name__ = "gui.Tooltip";
gui_Tooltip.prototype = {
get_tooltipDelay: function() {
if(this.game.mouse.isTouch) {
return 30;
} else {
return 0;
}
}
,update: function(timeMod) {
if(!this.contentsSetLastStep) {
this.setTextDisplay();
this.isContinousDisplay = false;
this.owner = null;
this.timeBeforeShown = 0;
return;
}
this.contentsSetLastStep = false;
if(this.timeBeforeShown > 0) {
if(!this.isContinousDisplay) {
this.setTextDisplay();
}
this.timeBeforeShown -= timeMod;
if(!this.isContinousDisplay) {
return;
}
} else if(this.text == "" && this.header == "") {
return;
}
if(this.isContinousDisplay) {
this.tooltipPosition = new common_Point(0,0);
var _this_x = 0;
var _this_y = 0;
var tmp = new PIXI.Point(_this_x,_this_y);
this.stage.position = tmp;
var tmp = this.game.state == null || this.game.state.get_publicGUI().window == null;
this.stage.visible = tmp;
} else {
this.stage.visible = true;
if(!this.game.mouse.isTouch) {
this.tooltipPosition = this.game.mouse.position;
}
var _this = this.tooltipPosition;
var tmp = new PIXI.Point(_this.x,_this.y);
this.stage.position = tmp;
this.stage.position.y += this.tooltipPosition.y > this.height ? -this.height : 21 / this.game.scaling | 0;
if(this.stage.position.x + this.width > this.game.rect.width) {
this.stage.position.x -= this.width;
if(this.stage.position.x < 0) {
this.stage.position.x = 0;
}
}
}
}
,setText: function(owner,text,header,costInfo,extraDisplay,extraDisplay2) {
if(header == null) {
header = "";
}
this.contentsSetLastStep = true;
if(this.owner != owner || this.game.mouse.pressed) {
this.owner = owner;
this.timeBeforeShown = this.get_tooltipDelay();
if(this.game.mouse.isTouch) {
this.tooltipPosition = this.game.mouse.position;
}
}
if(this.timeBeforeShown > 0) {
if(this.game.mouse.isTouch && !this.game.mouse.down) {
this.owner = null;
this.contentsSetLastStep = false;
}
return;
}
if(this.game.mouse.isTouch) {
this.game.mouse.claimMouse(this);
}
if(this.isContinousDisplay && this.game.mouse.isTouch) {
this.tooltipPosition = this.game.mouse.position;
}
this.isContinousDisplay = false;
this.setTextDisplay(text,header,costInfo,extraDisplay,extraDisplay2);
}
,setTextForContinuous: function(text,header,costInfo,extraDisplay,extraDisplay2) {
if(header == null) {
header = "";
}
if(this.owner != null) {
return;
}
this.contentsSetLastStep = true;
this.isContinousDisplay = true;
this.setTextDisplay(text,header,costInfo,extraDisplay,extraDisplay2);
this.isContinousDisplay = true;
}
,setTextDisplay: function(text,header,costInfo,extraDisplay,extraDisplay2) {
if(header == null) {
header = "";
}
if(text == null) {
text = "";
}
var addW = 6;
var y = 0;
var extraDisplayY = y;
var headerWidth = 0;
if(this.header == header && this.text == text && (costInfo == null && !this.tooltipCost.wouldChangeDisplay(this.emptyCost) || !this.tooltipCost.wouldChangeDisplay(costInfo)) && (extraDisplay == null && !this.tooltipExtraIcons.wouldChangeDisplay([]) || !this.tooltipExtraIcons.wouldChangeDisplay(extraDisplay)) && (extraDisplay2 == null && !this.tooltipExtraIcons2.wouldChangeDisplay([]) || !this.tooltipExtraIcons2.wouldChangeDisplay(extraDisplay2))) {
return;
}
var maxTooltipWidth = Math.max(this.game.rect.width / 2,Math.min(Math.max(this.tooltipPosition.x - 10,this.game.rect.width - this.tooltipPosition.x - 10),240));
if(this.isContinousDisplay) {
maxTooltipWidth = this.game.rect.width;
}
this.header = header;
this.text = text;
this.costInfo = costInfo;
if(extraDisplay != null && extraDisplay.length > 0) {
this.tooltipExtraIcons.setDisplay(extraDisplay);
}
this.width = 0;
if(this.isContinousDisplay && (this.header != "" || this.text != "")) {
this.width = Math.ceil(maxTooltipWidth);
}
if(header != "") {
extraDisplayY = y;
--y;
var val = maxTooltipWidth - this.tooltipExtraIcons.displayWidth - 10;
var maxVal = this.isContinousDisplay ? 1000 : 350;
this.tooltipHeader.maxWidth = val < 100 ? 100 : val > maxVal ? maxVal : val;
this.tooltipHeader.text = header;
headerWidth = Math.ceil(this.tooltipHeader.textWidth) + addW;
var val1 = this.width;
this.width = headerWidth > val1 ? headerWidth : val1;
y += Math.ceil(this.tooltipHeader.textHeight) + 2;
} else {
this.tooltipHeader.text = "";
}
if(text != "") {
++y;
var val = maxTooltipWidth - 10;
var maxVal = this.isContinousDisplay ? 1000 : 350;
this.tooltipText.maxWidth = val < 100 ? 100 : val > maxVal ? maxVal : val;
this.tooltipText.text = text;
this.tooltipText.position.y = y;
var val1 = this.width;
var val2 = Math.ceil(this.tooltipText.textWidth) + addW;
this.width = val2 > val1 ? val2 : val1;
y += Math.ceil(this.tooltipText.textHeight);
} else {
this.tooltipText.text = "";
}
if(extraDisplay2 != null && extraDisplay2.length > 0) {
this.tooltipExtraIcons2.setDisplay(extraDisplay2);
this.tooltipExtraIcons2.position.y = y + 1;
var val1 = this.width;
var val2 = Math.ceil(this.tooltipExtraIcons2.displayWidth) + addW;
this.width = val2 > val1 ? val2 : val1;
y += 12;
} else {
this.tooltipExtraIcons2.setDisplay([]);
}
if(costInfo != null && costInfo.any()) {
y += 2;
this.tooltipCost.position.y = y;
this.tooltipCost.displayCityAmounts = this.game.isMobile && !this.game.isLargeMobile && this.isContinousDisplay;
this.tooltipCost.maxDisplayWidth = this.game.rect.width;
this.tooltipCost.setCost(costInfo);
var val1 = this.width;
var val2 = this.tooltipCost.displayWidth + addW - 6;
this.width = val2 > val1 ? val2 : val1;
y += 11;
} else {
this.tooltipCost.setCost(this.emptyCost);
}
if(extraDisplay != null && extraDisplay.length > 0) {
var val1 = this.width;
var val2 = headerWidth + this.tooltipExtraIcons.displayWidth;
this.width = val2 > val1 ? val2 : val1;
this.tooltipExtraIcons.position.x = this.width - 1 - this.tooltipExtraIcons.displayWidth;
this.tooltipExtraIcons.position.y = extraDisplayY + 3;
} else {
this.tooltipExtraIcons.setDisplay([]);
}
y += 2;
this.height = y;
this.bg.npWidth = this.width;
this.bg.npHeight = this.height;
this.bg.updateSprites();
}
,shown: function() {
if(this.text == "") {
return this.header != "";
} else {
return true;
}
}
,__class__: gui_Tooltip
};
var gui_TopScreenNotification = function(game,gui,outerStage,header,text,displayTime) {
if(displayTime == null) {
displayTime = 600;
}
this.fadeout = 1;
this.game = game;
this.gui = gui;
this.stage = new PIXI.Container();
this.outerStage = outerStage;
this.outerStage.addChild(this.stage);
this.bg = new gui_NinePatch(Resources.getTexture("spr_9p_tooltip"),2,4,4);
this.bg.position.set(0,0);
this.stage.addChild(this.bg);
this.tooltipHeader = new PIXI.extras.BitmapText("",{ font : "Arial16", tint : 0});
this.tooltipHeader.position.set(2,0);
this.stage.addChild(this.tooltipHeader);
this.tooltipText = new PIXI.extras.BitmapText("",{ font : "Arial", tint : 0});
this.tooltipText.position.set(3,0);
this.stage.addChild(this.tooltipText);
this.tooltipPosition = new common_Point(0,0);
this.stage.position.set(0,0);
this.setTextDisplay(header,text);
this.displayTime = displayTime;
};
$hxClasses["gui.TopScreenNotification"] = gui_TopScreenNotification;
gui_TopScreenNotification.__name__ = "gui.TopScreenNotification";
gui_TopScreenNotification.prototype = {
update: function(timeMod) {
if(this.displayTime < 0) {
this.fadeout -= 0.05 * timeMod;
this.stage.alpha = this.fadeout;
if(this.fadeout < 0) {
this.stage.destroy();
HxOverrides.remove(this.gui.notifications,this);
}
return;
}
this.displayTime -= timeMod;
}
,setTextDisplay: function(text,header) {
if(header == null) {
header = "";
}
if(text == null) {
text = "";
}
var addW = 6;
var y = 0;
var headerWidth = 0;
if(this.header == header && this.text == text) {
return;
}
var maxTooltipWidth = this.game.rect.width;
this.header = header;
this.text = text;
this.width = 0;
if(this.header != "" || this.text != "") {
this.width = Math.ceil(maxTooltipWidth);
}
if(header != "") {
--y;
var val = maxTooltipWidth - 10;
this.tooltipHeader.maxWidth = val < 100 ? 100 : val > 1000 ? 1000 : val;
this.tooltipHeader.text = header;
headerWidth = Math.ceil(this.tooltipHeader.textWidth) + addW;
y += Math.ceil(this.tooltipHeader.textHeight) + 2;
} else {
this.tooltipHeader.text = "";
}
if(text != "") {
++y;
var val = maxTooltipWidth - 10;
this.tooltipText.maxWidth = val < 100 ? 100 : val > 1000 ? 1000 : val;
this.tooltipText.text = text;
this.tooltipText.position.y = y;
y += Math.ceil(this.tooltipText.textHeight);
} else {
this.tooltipText.text = "";
}
y += 2;
this.height = y;
this.bg.npWidth = this.width;
this.bg.npHeight = this.height;
this.bg.updateSprites();
}
,__class__: gui_TopScreenNotification
};
var gui_UpgradeWindowParts = function() { };
$hxClasses["gui.UpgradeWindowParts"] = gui_UpgradeWindowParts;
gui_UpgradeWindowParts.__name__ = "gui.UpgradeWindowParts";
gui_UpgradeWindowParts.createActivatableButton = function(gui,isActive,onClick,name,description,addToContainer,activeTexture,buttonSound,useAlternativeTextElement) {
if(useAlternativeTextElement == null) {
useAlternativeTextElement = false;
}
if(activeTexture == null) {
activeTexture = "spr_9p_button_active";
}
var infoContainer;
if(addToContainer == null) {
addToContainer = gui.windowInner;
}
var createdButton = null;
if(!isActive) {
var containerButton = new gui_ContainerButton(gui,gui.innerWindowStage,addToContainer,onClick);
infoContainer = containerButton.container;
addToContainer.addChild(containerButton);
if(buttonSound != null) {
containerButton.buttonSound = buttonSound;
}
createdButton = containerButton;
} else {
infoContainer = new gui_GUIContainer(gui,gui.innerWindowStage,addToContainer,null,null,null,new gui_NinePatch(Resources.getTexture(activeTexture),1,3,3));
addToContainer.addChild(infoContainer);
}
infoContainer.padding.top = 3;
infoContainer.padding.left = 3;
infoContainer.padding.right = 3;
infoContainer.padding.bottom = 1;
infoContainer.fillSecondarySize = true;
infoContainer.direction = gui_GUIContainerDirection.Vertical;
var nameElement = infoContainer.addChild(new gui_TextElement(infoContainer,gui.innerWindowStage,name));
var descriptionElement;
if(useAlternativeTextElement) {
descriptionElement = infoContainer.addChild(new gui_TextElementAlt(infoContainer,gui.innerWindowStage,description,null,"Arial",null,250,null,10));
} else {
descriptionElement = infoContainer.addChild(new gui_TextElement(infoContainer,gui.innerWindowStage,description,null,"Arial10"));
}
addToContainer.addChild(new gui_GUISpacing(addToContainer,new common_Point(2,2)));
return { container : infoContainer, titleText : nameElement, description : descriptionElement, button : createdButton};
};
gui_UpgradeWindowParts.createCheckboxButton = function(gui,isChecked,onClick,name,description,addToContainer,activeTexture,buttonSound) {
if(activeTexture == null) {
activeTexture = "spr_9p_button_active";
}
if(addToContainer == null) {
addToContainer = gui.windowInner;
}
var createdButton = null;
var containerButton = new gui_CheckboxButton(gui,gui.innerWindowStage,addToContainer,onClick,isChecked);
var infoContainer = containerButton.container;
addToContainer.addChild(containerButton);
if(buttonSound != null) {
containerButton.buttonSound = buttonSound;
}
createdButton = containerButton;
infoContainer.padding.top = 3;
infoContainer.padding.left = 3;
infoContainer.padding.right = 3;
infoContainer.padding.bottom = 1;
infoContainer.fillSecondarySize = true;
infoContainer.direction = gui_GUIContainerDirection.Vertical;
var checkboxAndNameElement = new gui_GUIContainer(gui,gui.innerWindowStage,infoContainer);
checkboxAndNameElement.direction = gui_GUIContainerDirection.Horizontal;
var checkboxTextures = Resources.getTextures("spr_checkbox",2);
var spr = new PIXI.Sprite(checkboxTextures[1]);
var spriteContainerHolder = new gui_ContainerHolder(checkboxAndNameElement,gui.innerWindowStage,spr,{ left : 0, right : 3, top : 0, bottom : 0},function() {
var checkboxTextures1 = checkboxTextures;
var spriteContainerHolder = isChecked() ? 0 : 1;
spr.texture = checkboxTextures1[spriteContainerHolder];
});
checkboxAndNameElement.addChild(spriteContainerHolder);
var nameElement = new gui_TextElement(checkboxAndNameElement,gui.innerWindowStage,name);
checkboxAndNameElement.addChild(nameElement);
infoContainer.addChild(checkboxAndNameElement);
var descriptionElement = infoContainer.addChild(new gui_TextElement(infoContainer,gui.innerWindowStage,description,null,"Arial10"));
addToContainer.addChild(new gui_GUISpacing(addToContainer,new common_Point(2,2)));
return { container : infoContainer, titleText : nameElement, description : descriptionElement, button : createdButton};
};
gui_UpgradeWindowParts.createHeader = function(gui,name,parent) {
if(parent == null) {
parent = gui.windowInner;
}
var upgradesTitleContainer = new gui_GUIContainer(gui,gui.innerWindowStage,parent);
upgradesTitleContainer.fillSecondarySize = true;
upgradesTitleContainer.addChild(new gui_TextElement(upgradesTitleContainer,gui.innerWindowStage,name,null,"Arial15",{ left : 0, right : 0, top : 3, bottom : 0}));
upgradesTitleContainer.addChild(new gui_GUIFiller(upgradesTitleContainer,2));
parent.addChild(upgradesTitleContainer);
parent.addChild(new gui_GUISpacing(parent,new common_Point(2,2)));
return upgradesTitleContainer;
};
gui_UpgradeWindowParts.addOneAndMaxButtons = function(gui,titleContainer,whenSwitchedOff,whenSwitchedOn,upgradeOneText,upgradeAllText,upgradeAllTextNoCost,anyUpgradeWithCost) {
var upgradeOneButton = new gui_TextButton(gui,gui.innerWindowStage,titleContainer,whenSwitchedOff,"One",function() {
return !gui_UpgradeWindowParts.hasMultiUpgradeModeOn;
},function() {
gui.tooltip.setText(upgradeOneButton,upgradeOneText);
});
titleContainer.addChild(upgradeOneButton);
titleContainer.addChild(new gui_GUISpacing(titleContainer,new common_Point(2,2)));
var upgradeAllButton = new gui_TextButton(gui,gui.innerWindowStage,titleContainer,whenSwitchedOn,anyUpgradeWithCost ? "Max" : "All",function() {
return gui_UpgradeWindowParts.hasMultiUpgradeModeOn;
},function() {
gui.tooltip.setText(upgradeAllButton,anyUpgradeWithCost ? upgradeAllText() : upgradeAllTextNoCost());
});
titleContainer.addChild(upgradeAllButton);
};
var gui_WindowPosition = $hxEnums["gui.WindowPosition"] = { __ename__ : "gui.WindowPosition", __constructs__ : ["Top","Center","CenterOffset","TopLeft","CenterWithBanner"]
,Top: {_hx_index:0,__enum__:"gui.WindowPosition",toString:$estr}
,Center: {_hx_index:1,__enum__:"gui.WindowPosition",toString:$estr}
,CenterOffset: ($_=function(offsetToTop) { return {_hx_index:2,offsetToTop:offsetToTop,__enum__:"gui.WindowPosition",toString:$estr}; },$_.__params__ = ["offsetToTop"],$_)
,TopLeft: {_hx_index:3,__enum__:"gui.WindowPosition",toString:$estr}
,CenterWithBanner: {_hx_index:4,__enum__:"gui.WindowPosition",toString:$estr}
};
var gui_WorkerDistributionWindow = function() { };
$hxClasses["gui.WorkerDistributionWindow"] = gui_WorkerDistributionWindow;
gui_WorkerDistributionWindow.__name__ = "gui.WorkerDistributionWindow";
gui_WorkerDistributionWindow.create = function(city,gui,stage,$window) {
gui_WorkerDistributionWindow.createWindow(city,gui,stage,$window);
};
gui_WorkerDistributionWindow.createWindow = function(city,gui,stage,$window) {
gui.windowAllowBanner();
$window.clear();
gui.windowAddTitleText("Assign Workers",null,Resources.getTexture("spr_work"));
var buildingTypesWithJobUnsorted = [];
var buildingTypesWithJobClassNames = [];
var _g = 0;
var _g1 = city.permanents;
while(_g < _g1.length) {
var pm = _g1[_g];
++_g;
if(pm.is(buildings_Work)) {
var cls = js_Boot.getClass(pm);
var i = buildingTypesWithJobUnsorted.indexOf(cls);
if(i == -1) {
i = buildingTypesWithJobUnsorted.length;
buildingTypesWithJobUnsorted.push(cls);
var splitClassName = cls.__name__.split(".");
buildingTypesWithJobClassNames.push(splitClassName[splitClassName.length - 1]);
}
}
}
var buildingTypesWithJob = [];
var _g = 0;
var _g1 = city.progress.resources.buildingInfoArray;
while(_g < _g1.length) {
var bi = _g1[_g];
++_g;
var i = buildingTypesWithJobClassNames.indexOf(bi.className);
if(i != -1) {
buildingTypesWithJob.push(buildingTypesWithJobUnsorted[i]);
}
}
var allBuildingTypeData = [];
var updateBuildingTypeData = function() {
allBuildingTypeData = [];
var _g = 0;
while(_g < buildingTypesWithJob.length) {
var bt = buildingTypesWithJob[_g];
++_g;
allBuildingTypeData.push({ number : 0, filledJobs : 0, jobs : 0});
}
var _g = 0;
var _g1 = city.permanents;
while(_g < _g1.length) {
var pm = _g1[_g];
++_g;
if(pm.is(buildings_Work)) {
var thisJob = pm;
var cls = js_Boot.getClass(pm);
var i = buildingTypesWithJob.indexOf(cls);
if(i != -1) {
var data = allBuildingTypeData[i];
data.jobs += thisJob.get_jobs();
data.filledJobs += thisJob.workers.length;
data.number += 1;
}
}
}
};
updateBuildingTypeData();
$window.onUpdate = updateBuildingTypeData;
var infoPadding = { left : 2, top : 5, bottom : 0, right : 0};
var singleRowHeight = 20;
var singleRowHeightWithoutPadding = singleRowHeight - 5;
var buildingOptionsContainer = new gui_GUIContainer(gui,stage,$window);
var buildingPictures = new gui_GUIContainer(gui,stage,buildingOptionsContainer);
var buildingWorkerNumbersContainer = new gui_GUIContainer(gui,stage,buildingOptionsContainer);
var priorityChooseContainer = new gui_GUIContainer(gui,stage,buildingOptionsContainer);
buildingPictures.direction = gui_GUIContainerDirection.Vertical;
buildingWorkerNumbersContainer.direction = gui_GUIContainerDirection.Vertical;
priorityChooseContainer.direction = gui_GUIContainerDirection.Vertical;
var _g = 0;
var _g1 = buildingTypesWithJob.length;
while(_g < _g1) {
var i = [_g++];
var buildingType = [buildingTypesWithJob[i[0]]];
var className = [buildingType[0].__name__];
var buildingTypeData = allBuildingTypeData[i[0]];
var thisBuildingPictureContainer = new gui_GUIContainer(gui,stage,buildingPictures);
thisBuildingPictureContainer.addChild(gui_BuildingTypeImage.create(stage,city,buildingType[0],thisBuildingPictureContainer,gui));
var thisBuildingNumberContainer = new gui_GUIContainer(gui,stage,thisBuildingPictureContainer,null,null,null,null,infoPadding);
thisBuildingNumberContainer.addChild(new gui_TextElement(thisBuildingNumberContainer,stage,"x" + buildingTypeData.number + ": "));
thisBuildingPictureContainer.addChild(thisBuildingNumberContainer);
buildingPictures.addChild(thisBuildingPictureContainer);
var workerNumberContainer = new gui_GUIContainer(gui,stage,buildingWorkerNumbersContainer,null,null,null,null,infoPadding);
workerNumberContainer.minHeight = singleRowHeightWithoutPadding;
workerNumberContainer.addChild(new gui_TextElement(workerNumberContainer,stage,null,(function(i) {
return function() {
return "" + allBuildingTypeData[i[0]].filledJobs + "/" + allBuildingTypeData[i[0]].jobs + " workers,";
};
})(i)));
buildingWorkerNumbersContainer.addChild(workerNumberContainer);
var topPaddingPrio = 2;
var priorityWorkersContainer = new gui_GUIContainer(gui,stage,priorityChooseContainer,null,null,null,null,{ left : 4, top : topPaddingPrio, bottom : 0, right : 0});
priorityWorkersContainer.minHeight = singleRowHeight - topPaddingPrio;
var currentPrioNumber = city.simulation.jobAssigner.priorityJobs.h[className[0]];
if(currentPrioNumber == null) {
currentPrioNumber = 0;
}
var numberSelectControl = new gui_NumberSelectControl(gui,stage,priorityWorkersContainer,null,(function() {
return function() {
return 0;
};
})(),(function(i) {
return function() {
return allBuildingTypeData[i[0]].jobs;
};
})(i),currentPrioNumber,(function(className,buildingType) {
return function(n) {
var currentPrioJobs = city.simulation.jobAssigner.priorityJobs.h[className[0]];
if(currentPrioJobs > n) {
city.simulation.jobAssigner.availableClassesForJob.push({ classType : PermanentMetaHelper.getClassID(buildingType[0].__name__), number : currentPrioJobs - n});
}
city.simulation.jobAssigner.priorityJobs.h[className[0]] = n;
city.simulation.jobAssigner.buildingsHaveWork = true;
};
})(className,buildingType),(function(i) {
return function() {
if(city.game.keyboard.down[16]) {
return 0;
} else if(city.game.keyboard.down[17]) {
return 1000000;
}
return allBuildingTypeData[i[0]].filledJobs;
};
})(i),city.game.isMobile ? "Tap to set the number of priority jobs to the current number of workers." : "Click to set the number of priority jobs to the current number of workers. Shift+Click to set it to 0. Ctrl+Click to set it to max.");
numberSelectControl.enableBeyondHighestValuePossibility(1000000,"Max");
priorityWorkersContainer.addChild(numberSelectControl);
if(className[0] == "buildings.StoneMine") {
gui_WorkerDistributionWindow.tutorialStoneMineUpButton = numberSelectControl.upButton;
gui_WorkerDistributionWindow.tutorialStoneMineDownButton = numberSelectControl.downButton;
} else if(className[0] == "buildings.WoodcuttingCentre") {
gui_WorkerDistributionWindow.tutorialWoodCuttersUpButton = numberSelectControl.upButton;
}
priorityWorkersContainer.addChild(new gui_TextElement(priorityWorkersContainer,stage," priority.",null,null,{ left : 0, top : 3, bottom : 0, right : 0}));
priorityChooseContainer.addChild(priorityWorkersContainer);
}
if(buildingTypesWithJob.length == 0) {
gui.windowAddInfoText("There are no buildings with work yet!");
}
buildingOptionsContainer.addChild(buildingPictures);
buildingOptionsContainer.addChild(buildingWorkerNumbersContainer);
buildingOptionsContainer.addChild(priorityChooseContainer);
$window.addChild(buildingOptionsContainer);
var _g = ($_=city.gui,$bind($_,$_.reloadWindow));
var city1 = city;
var gui1 = gui;
var stage1 = stage;
var window1 = $window;
var createWindowFunc = function() {
gui_WorkerDistributionWindow.createWindow(city1,gui1,stage1,window1);
};
var tmp = function() {
_g(createWindowFunc);
};
city.windowRelatedOnBuildOrDestroy = tmp;
$window.onDestroy = function() {
city.windowRelatedOnBuildOrDestroy = null;
gui_WorkerDistributionWindow.tutorialStoneMineUpButton = null;
gui_WorkerDistributionWindow.tutorialStoneMineDownButton = null;
gui_WorkerDistributionWindow.tutorialWoodCuttersUpButton = null;
};
gui.windowAddBottomButtons();
};
var gui_infoWindows_MaterialInfoWindow = function() { };
$hxClasses["gui.infoWindows.MaterialInfoWindow"] = gui_infoWindows_MaterialInfoWindow;
gui_infoWindows_MaterialInfoWindow.__name__ = "gui.infoWindows.MaterialInfoWindow";
gui_infoWindows_MaterialInfoWindow.create = function(city,gui,stage,$window,material,materialName) {
gui_infoWindows_MaterialInfoWindow.createWindow(city,gui,stage,$window,material,materialName);
};
gui_infoWindows_MaterialInfoWindow.createWindow = function(city,gui,stage,$window,material,materialName) {
$window.clear();
gui.windowAddTitleText(materialName + "",null,Resources.getTexture("spr_resource_" + material.toLowerCase()));
var graphicsContainer = new PIXI.Container();
var graphics = new PIXI.Graphics();
var textContainer = new PIXI.Container();
var stats = city.simulation.stats;
var graphTopSpacing = 5;
var graphBarMaxHeight = 100;
var holder = null;
var barWidth = 9;
var barSpacing = 4;
var daysToDraw = 7;
var graphMaxWidth = 34 + barWidth * 2 * daysToDraw + barSpacing * daysToDraw;
var drawMaterialInfo = function() {
graphics.clear();
graphics.beginFill(16711680,0);
graphics.drawRect(0,0,1,1);
graphics.endFill();
var maxMaterials = 9.0;
var ind = MaterialsHelper.findMaterialIndex(material);
var thisMaterialProdStats = stats.materialProduction[ind];
var thisMaterialConsStats = stats.materialUsed[ind];
var anyMaterialsUsed = false;
maxMaterials = Math.max(maxMaterials,thisMaterialProdStats[0]);
maxMaterials = Math.max(maxMaterials,thisMaterialConsStats[0]);
if(thisMaterialConsStats[0] > 0) {
anyMaterialsUsed = true;
}
maxMaterials = Math.max(maxMaterials,thisMaterialProdStats[1]);
maxMaterials = Math.max(maxMaterials,thisMaterialConsStats[1]);
if(thisMaterialConsStats[1] > 0) {
anyMaterialsUsed = true;
}
maxMaterials = Math.max(maxMaterials,thisMaterialProdStats[2]);
maxMaterials = Math.max(maxMaterials,thisMaterialConsStats[2]);
if(thisMaterialConsStats[2] > 0) {
anyMaterialsUsed = true;
}
maxMaterials = Math.max(maxMaterials,thisMaterialProdStats[3]);
maxMaterials = Math.max(maxMaterials,thisMaterialConsStats[3]);
if(thisMaterialConsStats[3] > 0) {
anyMaterialsUsed = true;
}
maxMaterials = Math.max(maxMaterials,thisMaterialProdStats[4]);
maxMaterials = Math.max(maxMaterials,thisMaterialConsStats[4]);
if(thisMaterialConsStats[4] > 0) {
anyMaterialsUsed = true;
}
maxMaterials = Math.max(maxMaterials,thisMaterialProdStats[5]);
maxMaterials = Math.max(maxMaterials,thisMaterialConsStats[5]);
if(thisMaterialConsStats[5] > 0) {
anyMaterialsUsed = true;
}
maxMaterials = Math.max(maxMaterials,thisMaterialProdStats[6]);
maxMaterials = Math.max(maxMaterials,thisMaterialConsStats[6]);
if(thisMaterialConsStats[6] > 0) {
anyMaterialsUsed = true;
}
var zeroes = Math.floor(Math.log(maxMaterials) / Math.log(10));
var dividers = Math.floor(Math.pow(10,zeroes));
if((Math.ceil(maxMaterials) / dividers | 0) < 2) {
dividers = dividers / 5 | 0;
} else if((Math.ceil(maxMaterials) / dividers | 0) < 4) {
dividers = dividers / 2 | 0;
}
var graphTopAmount = Math.floor(maxMaterials / dividers) * dividers + dividers;
var barScaling = graphBarMaxHeight / graphTopAmount;
var numbersOnAxis = (graphTopAmount / dividers | 0) + 1;
var xx = graphMaxWidth - barWidth;
var _g = 0;
var _g1 = daysToDraw;
while(_g < _g1) {
var i = _g++;
var barHeightprod = barScaling * thisMaterialProdStats[i];
var barHeightcons = barScaling * thisMaterialConsStats[i];
if(anyMaterialsUsed) {
graphics.beginFill(16711680);
graphics.drawRect(xx,graphTopSpacing + graphBarMaxHeight - barHeightcons,barWidth,barHeightcons);
graphics.endFill();
xx -= barWidth;
graphics.beginFill(255);
graphics.drawRect(xx,graphTopSpacing + graphBarMaxHeight - barHeightprod,barWidth,barHeightprod);
graphics.endFill();
xx -= barWidth + barSpacing;
} else {
xx -= barWidth;
graphics.beginFill(255);
graphics.drawRect(xx,graphTopSpacing + graphBarMaxHeight - barHeightprod,barWidth * 2,barHeightprod);
graphics.endFill();
xx -= barWidth + barSpacing;
}
}
var guideXPos = xx + barWidth + barSpacing - 2;
graphics.beginFill(0,1);
graphics.drawRect(guideXPos - 1,0,1,graphBarMaxHeight + graphTopSpacing);
graphics.drawRect(guideXPos - 1,graphBarMaxHeight + graphTopSpacing,graphMaxWidth - guideXPos + 3,1);
textContainer.removeChildren();
var textIntervals = Math.floor(graphTopAmount / (numbersOnAxis - 1));
var _g = 0;
var _g1 = numbersOnAxis;
while(_g < _g1) {
var i = _g++;
var axisText = new PIXI.extras.BitmapText("" + common_MathExtensions.largeNumberFormatAlt(Math,textIntervals * i),{ font : "Arial10", tint : 0});
axisText.anchor.set(1,0.5);
var yPos = graphTopSpacing + graphBarMaxHeight - barScaling * textIntervals * i;
axisText.position.set(guideXPos - 5,yPos);
graphics.drawRect(guideXPos - 3,yPos,2,1);
textContainer.addChild(axisText);
}
var xx = graphMaxWidth;
var maxY = 0;
var _g = 0;
var _g1 = daysToDraw;
while(_g < _g1) {
var i = _g++;
var text = "";
switch(i) {
case 0:
text = "Today";
break;
case 1:
text = "Yesterday";
break;
default:
text = i + " days ago";
}
var axisText = new PIXI.extras.BitmapText(text,{ font : "Arial10", tint : 0});
axisText.anchor.set(0,0.5);
axisText.rotation = Math.PI / 2;
axisText.position.set(xx - barWidth,graphTopSpacing + graphBarMaxHeight + 4);
textContainer.addChild(axisText);
xx -= barWidth * 2 + barSpacing;
var val2 = Math.ceil(axisText.position.y + axisText.textWidth);
if(val2 > maxY) {
maxY = val2;
}
}
graphics.endFill();
var yy = maxY + 5;
var xx = 0;
var drawLegendPart = function(source,color) {
var legendText = new PIXI.extras.BitmapText(source,{ font : "Arial10", tint : 0});
if(xx + 13 + Math.ceil(legendText.width) > graphMaxWidth) {
xx = 0;
yy += 13;
}
graphics.beginFill(color,1);
graphics.drawRect(xx,yy,10,10);
xx += 13;
legendText.position.set(xx,yy);
xx += Math.ceil(legendText.width) + 3;
textContainer.addChild(legendText);
graphics.endFill();
};
drawLegendPart("Production",255);
if(anyMaterialsUsed) {
yy += 13;
xx = 0;
drawLegendPart("Usage",16711680);
}
if(holder != null) {
holder.updateSize();
}
};
drawMaterialInfo();
graphicsContainer.addChild(graphics);
graphicsContainer.addChild(textContainer);
holder = new gui_ContainerHolder($window,stage,graphicsContainer,{ left : 0, right : 0, top : 0, bottom : 3},drawMaterialInfo,function(mouse) {
return false;
});
$window.addChild(holder);
var bitmapText = new PIXI.extras.BitmapText("" + 0 + "-" + 10,{ font : "Arial10", tint : 0});
var bitmapText = new PIXI.extras.BitmapText("" + 10 + "-" + 20,{ font : "Arial10", tint : 0});
var bitmapText = new PIXI.extras.BitmapText("" + 20 + "-" + 30,{ font : "Arial10", tint : 0});
var bitmapText = new PIXI.extras.BitmapText("" + 30 + "-" + 40,{ font : "Arial10", tint : 0});
var bitmapText = new PIXI.extras.BitmapText("" + 40 + "-" + 50,{ font : "Arial10", tint : 0});
var bitmapText = new PIXI.extras.BitmapText("" + 50 + "-" + 60,{ font : "Arial10", tint : 0});
var bitmapText = new PIXI.extras.BitmapText("" + 60 + "-" + 70,{ font : "Arial10", tint : 0});
$window.onDestroy = function() {
graphics.destroy();
};
if(material == "food") {
gui.windowInner.addChild(new gui_TextElement(gui.windowInner,gui.innerWindowStage,"",function() {
return city.simulation.eating.getFoodText();
},"Arial",null,graphMaxWidth - 10,true));
}
gui.windowAddBottomButtons();
};
var gui_windowParts_CycleValueButton = function() { };
$hxClasses["gui.windowParts.CycleValueButton"] = gui_windowParts_CycleValueButton;
gui_windowParts_CycleValueButton.__name__ = "gui.windowParts.CycleValueButton";
gui_windowParts_CycleValueButton.create = function(gui,getValue,setValue,maxValue,text,textGetter,increment) {
if(increment == null) {
increment = 1;
}
if(text == null) {
text = "";
}
if(textGetter == null) {
textGetter = function() {
return text;
};
}
var button = gui_windowParts_FullSizeTextButton.create(gui,function() {
var curr = getValue();
curr += increment;
if(curr >= maxValue()) {
setValue(curr % increment);
} else {
setValue(curr);
}
},gui.windowInner,textGetter,gui.innerWindowStage);
gui.windowInner.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,4)));
return button;
};
var gui_windowParts_FullSizeTextButton = function() { };
$hxClasses["gui.windowParts.FullSizeTextButton"] = gui_windowParts_FullSizeTextButton;
gui_windowParts_FullSizeTextButton.__name__ = "gui.windowParts.FullSizeTextButton";
gui_windowParts_FullSizeTextButton.create = function(gui,onClick,parent,getText,stage) {
var containerButton = new gui_ContainerButton(gui,stage,parent,onClick);
var infoContainer = containerButton.container;
parent.addChild(containerButton);
infoContainer.padding.top = 3;
infoContainer.padding.left = 3;
infoContainer.padding.right = 3;
infoContainer.padding.bottom = 0;
infoContainer.fillSecondarySize = true;
infoContainer.direction = gui_GUIContainerDirection.Vertical;
var subContainer = new gui_GUIContainer(gui,stage,infoContainer);
subContainer.alignment = gui_GUIContainerAlignment.Center;
infoContainer.addChild(subContainer);
subContainer.addChild(new gui_TextElement(subContainer,stage,null,function() {
return getText();
}));
containerButton.buttonPatch.updateSprites(true);
return containerButton;
};
var haxe_IMap = function() { };
$hxClasses["haxe.IMap"] = haxe_IMap;
haxe_IMap.__name__ = "haxe.IMap";
haxe_IMap.__isInterface__ = true;
var haxe_Exception = function(message,previous,native) {
Error.call(this,message);
this.message = message;
this.__previousException = previous;
this.__nativeException = native != null ? native : this;
};
$hxClasses["haxe.Exception"] = haxe_Exception;
haxe_Exception.__name__ = "haxe.Exception";
haxe_Exception.thrown = function(value) {
if(((value) instanceof haxe_Exception)) {
return value.get_native();
} else if(((value) instanceof Error)) {
return value;
} else {
var e = new haxe_ValueException(value);
return e;
}
};
haxe_Exception.__super__ = Error;
haxe_Exception.prototype = $extend(Error.prototype,{
get_native: function() {
return this.__nativeException;
}
,__class__: haxe_Exception
});
var haxe_Int32 = {};
haxe_Int32.ucompare = function(a,b) {
if(a < 0) {
if(b < 0) {
return ~b - ~a | 0;
} else {
return 1;
}
}
if(b < 0) {
return -1;
} else {
return a - b | 0;
}
};
var haxe_Int64 = {};
haxe_Int64.divMod = function(dividend,divisor) {
if(divisor.high == 0) {
switch(divisor.low) {
case 0:
throw haxe_Exception.thrown("divide by zero");
case 1:
var this1 = new haxe__$Int64__$_$_$Int64(dividend.high,dividend.low);
var this2 = new haxe__$Int64__$_$_$Int64(0,0);
return { quotient : this1, modulus : this2};
}
}
var divSign = dividend.high < 0 != divisor.high < 0;
var modulus;
if(dividend.high < 0) {
var high = ~dividend.high;
var low = ~dividend.low + 1 | 0;
if(low == 0) {
var ret = high++;
high = high | 0;
}
var this1 = new haxe__$Int64__$_$_$Int64(high,low);
modulus = this1;
} else {
var this1 = new haxe__$Int64__$_$_$Int64(dividend.high,dividend.low);
modulus = this1;
}
if(divisor.high < 0) {
var high = ~divisor.high;
var low = ~divisor.low + 1 | 0;
if(low == 0) {
var ret = high++;
high = high | 0;
}
var this1 = new haxe__$Int64__$_$_$Int64(high,low);
divisor = this1;
}
var this1 = new haxe__$Int64__$_$_$Int64(0,0);
var quotient = this1;
var this1 = new haxe__$Int64__$_$_$Int64(0,1);
var mask = this1;
while(!(divisor.high < 0)) {
var v = haxe_Int32.ucompare(divisor.high,modulus.high);
var cmp = v != 0 ? v : haxe_Int32.ucompare(divisor.low,modulus.low);
var b = 1;
b &= 63;
if(b == 0) {
var this1 = new haxe__$Int64__$_$_$Int64(divisor.high,divisor.low);
divisor = this1;
} else if(b < 32) {
var this2 = new haxe__$Int64__$_$_$Int64(divisor.high << b | divisor.low >>> 32 - b,divisor.low << b);
divisor = this2;
} else {
var this3 = new haxe__$Int64__$_$_$Int64(divisor.low << b - 32,0);
divisor = this3;
}
var b1 = 1;
b1 &= 63;
if(b1 == 0) {
var this4 = new haxe__$Int64__$_$_$Int64(mask.high,mask.low);
mask = this4;
} else if(b1 < 32) {
var this5 = new haxe__$Int64__$_$_$Int64(mask.high << b1 | mask.low >>> 32 - b1,mask.low << b1);
mask = this5;
} else {
var this6 = new haxe__$Int64__$_$_$Int64(mask.low << b1 - 32,0);
mask = this6;
}
if(cmp >= 0) {
break;
}
}
while(true) {
var b_high = 0;
var b_low = 0;
if(!(mask.high != b_high || mask.low != b_low)) {
break;
}
var v = haxe_Int32.ucompare(modulus.high,divisor.high);
if((v != 0 ? v : haxe_Int32.ucompare(modulus.low,divisor.low)) >= 0) {
var this1 = new haxe__$Int64__$_$_$Int64(quotient.high | mask.high,quotient.low | mask.low);
quotient = this1;
var high = modulus.high - divisor.high | 0;
var low = modulus.low - divisor.low | 0;
if(haxe_Int32.ucompare(modulus.low,divisor.low) < 0) {
var ret = high--;
high = high | 0;
}
var this2 = new haxe__$Int64__$_$_$Int64(high,low);
modulus = this2;
}
var b = 1;
b &= 63;
if(b == 0) {
var this3 = new haxe__$Int64__$_$_$Int64(mask.high,mask.low);
mask = this3;
} else if(b < 32) {
var this4 = new haxe__$Int64__$_$_$Int64(mask.high >>> b,mask.high << 32 - b | mask.low >>> b);
mask = this4;
} else {
var this5 = new haxe__$Int64__$_$_$Int64(0,mask.high >>> b - 32);
mask = this5;
}
var b1 = 1;
b1 &= 63;
if(b1 == 0) {
var this6 = new haxe__$Int64__$_$_$Int64(divisor.high,divisor.low);
divisor = this6;
} else if(b1 < 32) {
var this7 = new haxe__$Int64__$_$_$Int64(divisor.high >>> b1,divisor.high << 32 - b1 | divisor.low >>> b1);
divisor = this7;
} else {
var this8 = new haxe__$Int64__$_$_$Int64(0,divisor.high >>> b1 - 32);
divisor = this8;
}
}
if(divSign) {
var high = ~quotient.high;
var low = ~quotient.low + 1 | 0;
if(low == 0) {
var ret = high++;
high = high | 0;
}
var this1 = new haxe__$Int64__$_$_$Int64(high,low);
quotient = this1;
}
if(dividend.high < 0) {
var high = ~modulus.high;
var low = ~modulus.low + 1 | 0;
if(low == 0) {
var ret = high++;
high = high | 0;
}
var this1 = new haxe__$Int64__$_$_$Int64(high,low);
modulus = this1;
}
return { quotient : quotient, modulus : modulus};
};
var haxe__$Int64__$_$_$Int64 = function(high,low) {
this.high = high;
this.low = low;
};
$hxClasses["haxe._Int64.___Int64"] = haxe__$Int64__$_$_$Int64;
haxe__$Int64__$_$_$Int64.__name__ = "haxe._Int64.___Int64";
haxe__$Int64__$_$_$Int64.prototype = {
__class__: haxe__$Int64__$_$_$Int64
};
var haxe_Serializer = function() {
this.buf = new StringBuf();
this.cache = [];
this.useCache = haxe_Serializer.USE_CACHE;
this.useEnumIndex = haxe_Serializer.USE_ENUM_INDEX;
this.shash = new haxe_ds_StringMap();
this.scount = 0;
};
$hxClasses["haxe.Serializer"] = haxe_Serializer;
haxe_Serializer.__name__ = "haxe.Serializer";
haxe_Serializer.run = function(v) {
var s = new haxe_Serializer();
s.serialize(v);
return s.toString();
};
haxe_Serializer.prototype = {
toString: function() {
return this.buf.b;
}
,serializeString: function(s) {
var x = this.shash.h[s];
if(x != null) {
this.buf.b += "R";
this.buf.b += x == null ? "null" : "" + x;
return;
}
this.shash.h[s] = this.scount++;
this.buf.b += "y";
s = encodeURIComponent(s);
this.buf.b += Std.string(s.length);
this.buf.b += ":";
this.buf.b += s == null ? "null" : "" + s;
}
,serializeRef: function(v) {
var vt = typeof(v);
var _g = 0;
var _g1 = this.cache.length;
while(_g < _g1) {
var i = _g++;
var ci = this.cache[i];
if(typeof(ci) == vt && ci == v) {
this.buf.b += "r";
this.buf.b += i == null ? "null" : "" + i;
return true;
}
}
this.cache.push(v);
return false;
}
,serializeFields: function(v) {
var _g = 0;
var _g1 = Reflect.fields(v);
while(_g < _g1.length) {
var f = _g1[_g];
++_g;
this.serializeString(f);
this.serialize(Reflect.field(v,f));
}
this.buf.b += "g";
}
,serialize: function(v) {
var _g = Type.typeof(v);
switch(_g._hx_index) {
case 0:
this.buf.b += "n";
break;
case 1:
var v1 = v;
if(v1 == 0) {
this.buf.b += "z";
return;
}
this.buf.b += "i";
this.buf.b += v1 == null ? "null" : "" + v1;
break;
case 2:
var v1 = v;
if(isNaN(v1)) {
this.buf.b += "k";
} else if(!isFinite(v1)) {
this.buf.b += v1 < 0 ? "m" : "p";
} else {
this.buf.b += "d";
this.buf.b += v1 == null ? "null" : "" + v1;
}
break;
case 3:
this.buf.b += v ? "t" : "f";
break;
case 4:
if(js_Boot.__instanceof(v,Class)) {
var className = v.__name__;
this.buf.b += "A";
this.serializeString(className);
} else if(js_Boot.__instanceof(v,Enum)) {
this.buf.b += "B";
this.serializeString(v.__ename__);
} else {
if(this.useCache && this.serializeRef(v)) {
return;
}
this.buf.b += "o";
this.serializeFields(v);
}
break;
case 5:
throw haxe_Exception.thrown("Cannot serialize function");
case 6:
var c = _g.c;
if(c == String) {
this.serializeString(v);
return;
}
if(this.useCache && this.serializeRef(v)) {
return;
}
switch(c) {
case Array:
var ucount = 0;
this.buf.b += "a";
var l = v["length"];
var _g1 = 0;
var _g2 = l;
while(_g1 < _g2) {
var i = _g1++;
if(v[i] == null) {
++ucount;
} else {
if(ucount > 0) {
if(ucount == 1) {
this.buf.b += "n";
} else {
this.buf.b += "u";
this.buf.b += ucount == null ? "null" : "" + ucount;
}
ucount = 0;
}
this.serialize(v[i]);
}
}
if(ucount > 0) {
if(ucount == 1) {
this.buf.b += "n";
} else {
this.buf.b += "u";
this.buf.b += ucount == null ? "null" : "" + ucount;
}
}
this.buf.b += "h";
break;
case Date:
var d = v;
this.buf.b += "v";
this.buf.b += Std.string(d.getTime());
break;
case haxe_ds_IntMap:
this.buf.b += "q";
var v1 = v;
var k = v1.keys();
while(k.hasNext()) {
var k1 = k.next();
this.buf.b += ":";
this.buf.b += k1 == null ? "null" : "" + k1;
this.serialize(v1.h[k1]);
}
this.buf.b += "h";
break;
case haxe_ds_List:
this.buf.b += "l";
var v1 = v;
var _g_head = v1.h;
while(_g_head != null) {
var val = _g_head.item;
_g_head = _g_head.next;
var i = val;
this.serialize(i);
}
this.buf.b += "h";
break;
case haxe_ds_ObjectMap:
this.buf.b += "M";
var v1 = v;
var k = v1.keys();
while(k.hasNext()) {
var k1 = k.next();
var id = Reflect.field(k1,"__id__");
Reflect.deleteField(k1,"__id__");
this.serialize(k1);
k1["__id__"] = id;
this.serialize(v1.h[k1.__id__]);
}
this.buf.b += "h";
break;
case haxe_ds_StringMap:
this.buf.b += "b";
var v1 = v;
var k = haxe_ds_StringMap.keysIterator(v1.h);
while(k.hasNext()) {
var k1 = k.next();
this.serializeString(k1);
this.serialize(v1.h[k1]);
}
this.buf.b += "h";
break;
case haxe_io_Bytes:
var v1 = v;
this.buf.b += "s";
this.buf.b += Std.string(Math.ceil(v1.length * 8 / 6));
this.buf.b += ":";
var i = 0;
var max = v1.length - 2;
var b64 = haxe_Serializer.BASE64_CODES;
if(b64 == null) {
var this1 = new Array(haxe_Serializer.BASE64.length);
b64 = this1;
var _g1 = 0;
var _g2 = haxe_Serializer.BASE64.length;
while(_g1 < _g2) {
var i1 = _g1++;
b64[i1] = HxOverrides.cca(haxe_Serializer.BASE64,i1);
}
haxe_Serializer.BASE64_CODES = b64;
}
while(i < max) {
var b1 = v1.b[i++];
var b2 = v1.b[i++];
var b3 = v1.b[i++];
this.buf.b += String.fromCodePoint(b64[b1 >> 2]);
this.buf.b += String.fromCodePoint(b64[(b1 << 4 | b2 >> 4) & 63]);
this.buf.b += String.fromCodePoint(b64[(b2 << 2 | b3 >> 6) & 63]);
this.buf.b += String.fromCodePoint(b64[b3 & 63]);
}
if(i == max) {
var b1 = v1.b[i++];
var b2 = v1.b[i++];
this.buf.b += String.fromCodePoint(b64[b1 >> 2]);
this.buf.b += String.fromCodePoint(b64[(b1 << 4 | b2 >> 4) & 63]);
this.buf.b += String.fromCodePoint(b64[b2 << 2 & 63]);
} else if(i == max + 1) {
var b1 = v1.b[i++];
this.buf.b += String.fromCodePoint(b64[b1 >> 2]);
this.buf.b += String.fromCodePoint(b64[b1 << 4 & 63]);
}
break;
default:
if(this.useCache) {
this.cache.pop();
}
if(v.hxSerialize != null) {
this.buf.b += "C";
this.serializeString(c.__name__);
if(this.useCache) {
this.cache.push(v);
}
v.hxSerialize(this);
this.buf.b += "g";
} else {
this.buf.b += "c";
this.serializeString(c.__name__);
if(this.useCache) {
this.cache.push(v);
}
this.serializeFields(v);
}
}
break;
case 7:
var e = _g.e;
if(this.useCache) {
if(this.serializeRef(v)) {
return;
}
this.cache.pop();
}
this.buf.b += Std.string(this.useEnumIndex ? "j" : "w");
this.serializeString(e.__ename__);
if(this.useEnumIndex) {
this.buf.b += ":";
this.buf.b += Std.string(v._hx_index);
} else {
var e = v;
this.serializeString($hxEnums[e.__enum__].__constructs__[e._hx_index]);
}
this.buf.b += ":";
var params = Type.enumParameters(v);
this.buf.b += Std.string(params.length);
var _g = 0;
while(_g < params.length) {
var p = params[_g];
++_g;
this.serialize(p);
}
if(this.useCache) {
this.cache.push(v);
}
break;
default:
throw haxe_Exception.thrown("Cannot serialize " + Std.string(v));
}
}
,__class__: haxe_Serializer
};
var haxe__$Unserializer_DefaultResolver = function() {
};
$hxClasses["haxe._Unserializer.DefaultResolver"] = haxe__$Unserializer_DefaultResolver;
haxe__$Unserializer_DefaultResolver.__name__ = "haxe._Unserializer.DefaultResolver";
haxe__$Unserializer_DefaultResolver.prototype = {
resolveClass: function(name) {
return $hxClasses[name];
}
,resolveEnum: function(name) {
return $hxEnums[name];
}
,__class__: haxe__$Unserializer_DefaultResolver
};
var haxe_Unserializer = function(buf) {
this.buf = buf;
this.length = buf.length;
this.pos = 0;
this.scache = [];
this.cache = [];
var r = haxe_Unserializer.DEFAULT_RESOLVER;
if(r == null) {
r = new haxe__$Unserializer_DefaultResolver();
haxe_Unserializer.DEFAULT_RESOLVER = r;
}
this.resolver = r;
};
$hxClasses["haxe.Unserializer"] = haxe_Unserializer;
haxe_Unserializer.__name__ = "haxe.Unserializer";
haxe_Unserializer.initCodes = function() {
var codes = [];
var _g = 0;
var _g1 = haxe_Unserializer.BASE64.length;
while(_g < _g1) {
var i = _g++;
codes[haxe_Unserializer.BASE64.charCodeAt(i)] = i;
}
return codes;
};
haxe_Unserializer.run = function(v) {
return new haxe_Unserializer(v).unserialize();
};
haxe_Unserializer.prototype = {
readDigits: function() {
var k = 0;
var s = false;
var fpos = this.pos;
while(true) {
var c = this.buf.charCodeAt(this.pos);
if(c != c) {
break;
}
if(c == 45) {
if(this.pos != fpos) {
break;
}
s = true;
this.pos++;
continue;
}
if(c < 48 || c > 57) {
break;
}
k = k * 10 + (c - 48);
this.pos++;
}
if(s) {
k *= -1;
}
return k;
}
,readFloat: function() {
var p1 = this.pos;
while(true) {
var c = this.buf.charCodeAt(this.pos);
if(c != c) {
break;
}
if(c >= 43 && c < 58 || c == 101 || c == 69) {
this.pos++;
} else {
break;
}
}
return parseFloat(HxOverrides.substr(this.buf,p1,this.pos - p1));
}
,unserializeObject: function(o) {
while(true) {
if(this.pos >= this.length) {
throw haxe_Exception.thrown("Invalid object");
}
if(this.buf.charCodeAt(this.pos) == 103) {
break;
}
var k = this.unserialize();
if(typeof(k) != "string") {
throw haxe_Exception.thrown("Invalid object key");
}
var v = this.unserialize();
o[k] = v;
}
this.pos++;
}
,unserializeEnum: function(edecl,tag) {
if(this.buf.charCodeAt(this.pos++) != 58) {
throw haxe_Exception.thrown("Invalid enum format");
}
var nargs = this.readDigits();
if(nargs == 0) {
return Type.createEnum(edecl,tag);
}
var args = [];
while(nargs-- > 0) args.push(this.unserialize());
return Type.createEnum(edecl,tag,args);
}
,unserialize: function() {
switch(this.buf.charCodeAt(this.pos++)) {
case 65:
var name = this.unserialize();
var cl = this.resolver.resolveClass(name);
if(cl == null) {
throw haxe_Exception.thrown("Class not found " + name);
}
return cl;
case 66:
var name = this.unserialize();
var e = this.resolver.resolveEnum(name);
if(e == null) {
throw haxe_Exception.thrown("Enum not found " + name);
}
return e;
case 67:
var name = this.unserialize();
var cl = this.resolver.resolveClass(name);
if(cl == null) {
throw haxe_Exception.thrown("Class not found " + name);
}
var o = Object.create(cl.prototype);
this.cache.push(o);
o.hxUnserialize(this);
if(this.buf.charCodeAt(this.pos++) != 103) {
throw haxe_Exception.thrown("Invalid custom data");
}
return o;
case 77:
var h = new haxe_ds_ObjectMap();
this.cache.push(h);
var buf = this.buf;
while(this.buf.charCodeAt(this.pos) != 104) {
var s = this.unserialize();
h.set(s,this.unserialize());
}
this.pos++;
return h;
case 82:
var n = this.readDigits();
if(n < 0 || n >= this.scache.length) {
throw haxe_Exception.thrown("Invalid string reference");
}
return this.scache[n];
case 97:
var buf = this.buf;
var a = [];
this.cache.push(a);
while(true) {
var c = this.buf.charCodeAt(this.pos);
if(c == 104) {
this.pos++;
break;
}
if(c == 117) {
this.pos++;
var n = this.readDigits();
a[a.length + n - 1] = null;
} else {
a.push(this.unserialize());
}
}
return a;
case 98:
var h = new haxe_ds_StringMap();
this.cache.push(h);
var buf = this.buf;
while(this.buf.charCodeAt(this.pos) != 104) {
var s = this.unserialize();
var value = this.unserialize();
h.h[s] = value;
}
this.pos++;
return h;
case 99:
var name = this.unserialize();
var cl = this.resolver.resolveClass(name);
if(cl == null) {
throw haxe_Exception.thrown("Class not found " + name);
}
var o = Object.create(cl.prototype);
this.cache.push(o);
this.unserializeObject(o);
return o;
case 100:
return this.readFloat();
case 102:
return false;
case 105:
return this.readDigits();
case 106:
var name = this.unserialize();
var edecl = this.resolver.resolveEnum(name);
if(edecl == null) {
throw haxe_Exception.thrown("Enum not found " + name);
}
this.pos++;
var index = this.readDigits();
var tag = edecl.__constructs__.slice()[index];
if(tag == null) {
throw haxe_Exception.thrown("Unknown enum index " + name + "@" + index);
}
var e = this.unserializeEnum(edecl,tag);
this.cache.push(e);
return e;
case 107:
return NaN;
case 108:
var l = new haxe_ds_List();
this.cache.push(l);
var buf = this.buf;
while(this.buf.charCodeAt(this.pos) != 104) l.add(this.unserialize());
this.pos++;
return l;
case 109:
return -Infinity;
case 110:
return null;
case 111:
var o = { };
this.cache.push(o);
this.unserializeObject(o);
return o;
case 112:
return Infinity;
case 113:
var h = new haxe_ds_IntMap();
this.cache.push(h);
var buf = this.buf;
var c = this.buf.charCodeAt(this.pos++);
while(c == 58) {
var i = this.readDigits();
var value = this.unserialize();
h.h[i] = value;
c = this.buf.charCodeAt(this.pos++);
}
if(c != 104) {
throw haxe_Exception.thrown("Invalid IntMap format");
}
return h;
case 114:
var n = this.readDigits();
if(n < 0 || n >= this.cache.length) {
throw haxe_Exception.thrown("Invalid reference");
}
return this.cache[n];
case 115:
var len = this.readDigits();
var buf = this.buf;
if(this.buf.charCodeAt(this.pos++) != 58 || this.length - this.pos < len) {
throw haxe_Exception.thrown("Invalid bytes length");
}
var codes = haxe_Unserializer.CODES;
if(codes == null) {
codes = haxe_Unserializer.initCodes();
haxe_Unserializer.CODES = codes;
}
var i = this.pos;
var rest = len & 3;
var size = (len >> 2) * 3 + (rest >= 2 ? rest - 1 : 0);
var max = i + (len - rest);
var bytes = new haxe_io_Bytes(new ArrayBuffer(size));
var bpos = 0;
while(i < max) {
var c1 = codes[buf.charCodeAt(i++)];
var c2 = codes[buf.charCodeAt(i++)];
bytes.b[bpos++] = c1 << 2 | c2 >> 4;
var c3 = codes[buf.charCodeAt(i++)];
bytes.b[bpos++] = c2 << 4 | c3 >> 2;
var c4 = codes[buf.charCodeAt(i++)];
bytes.b[bpos++] = c3 << 6 | c4;
}
if(rest >= 2) {
var c1 = codes[buf.charCodeAt(i++)];
var c2 = codes[buf.charCodeAt(i++)];
bytes.b[bpos++] = c1 << 2 | c2 >> 4;
if(rest == 3) {
var c3 = codes[buf.charCodeAt(i++)];
bytes.b[bpos++] = c2 << 4 | c3 >> 2;
}
}
this.pos += len;
this.cache.push(bytes);
return bytes;
case 116:
return true;
case 118:
var d;
if(this.buf.charCodeAt(this.pos) >= 48 && this.buf.charCodeAt(this.pos) <= 57 && this.buf.charCodeAt(this.pos + 1) >= 48 && this.buf.charCodeAt(this.pos + 1) <= 57 && this.buf.charCodeAt(this.pos + 2) >= 48 && this.buf.charCodeAt(this.pos + 2) <= 57 && this.buf.charCodeAt(this.pos + 3) >= 48 && this.buf.charCodeAt(this.pos + 3) <= 57 && this.buf.charCodeAt(this.pos + 4) == 45) {
d = HxOverrides.strDate(HxOverrides.substr(this.buf,this.pos,19));
this.pos += 19;
} else {
d = new Date(this.readFloat());
}
this.cache.push(d);
return d;
case 119:
var name = this.unserialize();
var edecl = this.resolver.resolveEnum(name);
if(edecl == null) {
throw haxe_Exception.thrown("Enum not found " + name);
}
var e = this.unserializeEnum(edecl,this.unserialize());
this.cache.push(e);
return e;
case 120:
throw haxe_Exception.thrown(this.unserialize());
case 121:
var len = this.readDigits();
if(this.buf.charCodeAt(this.pos++) != 58 || this.length - this.pos < len) {
throw haxe_Exception.thrown("Invalid string length");
}
var s = HxOverrides.substr(this.buf,this.pos,len);
this.pos += len;
s = decodeURIComponent(s.split("+").join(" "));
this.scache.push(s);
return s;
case 122:
return 0;
default:
}
this.pos--;
throw haxe_Exception.thrown("Invalid char " + this.buf.charAt(this.pos) + " at position " + this.pos);
}
,__class__: haxe_Unserializer
};
var haxe_ValueException = function(value,previous,native) {
haxe_Exception.call(this,String(value),previous,native);
this.value = value;
};
$hxClasses["haxe.ValueException"] = haxe_ValueException;
haxe_ValueException.__name__ = "haxe.ValueException";
haxe_ValueException.__super__ = haxe_Exception;
haxe_ValueException.prototype = $extend(haxe_Exception.prototype,{
__class__: haxe_ValueException
});
var haxe_io_Bytes = function(data) {
this.length = data.byteLength;
this.b = new Uint8Array(data);
this.b.bufferValue = data;
data.hxBytes = this;
data.bytes = this.b;
};
$hxClasses["haxe.io.Bytes"] = haxe_io_Bytes;
haxe_io_Bytes.__name__ = "haxe.io.Bytes";
haxe_io_Bytes.ofString = function(s,encoding) {
if(encoding == haxe_io_Encoding.RawNative) {
var buf = new Uint8Array(s.length << 1);
var _g = 0;
var _g1 = s.length;
while(_g < _g1) {
var i = _g++;
var c = s.charCodeAt(i);
buf[i << 1] = c & 255;
buf[i << 1 | 1] = c >> 8;
}
return new haxe_io_Bytes(buf.buffer);
}
var a = [];
var i = 0;
while(i < s.length) {
var c = s.charCodeAt(i++);
if(55296 <= c && c <= 56319) {
c = c - 55232 << 10 | s.charCodeAt(i++) & 1023;
}
if(c <= 127) {
a.push(c);
} else if(c <= 2047) {
a.push(192 | c >> 6);
a.push(128 | c & 63);
} else if(c <= 65535) {
a.push(224 | c >> 12);
a.push(128 | c >> 6 & 63);
a.push(128 | c & 63);
} else {
a.push(240 | c >> 18);
a.push(128 | c >> 12 & 63);
a.push(128 | c >> 6 & 63);
a.push(128 | c & 63);
}
}
return new haxe_io_Bytes(new Uint8Array(a).buffer);
};
haxe_io_Bytes.ofData = function(b) {
var hb = b.hxBytes;
if(hb != null) {
return hb;
}
return new haxe_io_Bytes(b);
};
haxe_io_Bytes.prototype = {
blit: function(pos,src,srcpos,len) {
if(pos < 0 || srcpos < 0 || len < 0 || pos + len > this.length || srcpos + len > src.length) {
throw haxe_Exception.thrown(haxe_io_Error.OutsideBounds);
}
if(srcpos == 0 && len == src.b.byteLength) {
this.b.set(src.b,pos);
} else {
this.b.set(src.b.subarray(srcpos,srcpos + len),pos);
}
}
,getDouble: function(pos) {
if(this.data == null) {
this.data = new DataView(this.b.buffer,this.b.byteOffset,this.b.byteLength);
}
return this.data.getFloat64(pos,true);
}
,setDouble: function(pos,v) {
if(this.data == null) {
this.data = new DataView(this.b.buffer,this.b.byteOffset,this.b.byteLength);
}
this.data.setFloat64(pos,v,true);
}
,getInt32: function(pos) {
if(this.data == null) {
this.data = new DataView(this.b.buffer,this.b.byteOffset,this.b.byteLength);
}
return this.data.getInt32(pos,true);
}
,setInt32: function(pos,v) {
if(this.data == null) {
this.data = new DataView(this.b.buffer,this.b.byteOffset,this.b.byteLength);
}
this.data.setInt32(pos,v,true);
}
,getString: function(pos,len,encoding) {
if(pos < 0 || len < 0 || pos + len > this.length) {
throw haxe_Exception.thrown(haxe_io_Error.OutsideBounds);
}
if(encoding == null) {
encoding = haxe_io_Encoding.UTF8;
}
var s = "";
var b = this.b;
var i = pos;
var max = pos + len;
switch(encoding._hx_index) {
case 0:
var debug = pos > 0;
while(i < max) {
var c = b[i++];
if(c < 128) {
if(c == 0) {
break;
}
s += String.fromCodePoint(c);
} else if(c < 224) {
var code = (c & 63) << 6 | b[i++] & 127;
s += String.fromCodePoint(code);
} else if(c < 240) {
var c2 = b[i++];
var code1 = (c & 31) << 12 | (c2 & 127) << 6 | b[i++] & 127;
s += String.fromCodePoint(code1);
} else {
var c21 = b[i++];
var c3 = b[i++];
var u = (c & 15) << 18 | (c21 & 127) << 12 | (c3 & 127) << 6 | b[i++] & 127;
s += String.fromCodePoint(u);
}
}
break;
case 1:
while(i < max) {
var c = b[i++] | b[i++] << 8;
s += String.fromCodePoint(c);
}
break;
}
return s;
}
,toString: function() {
return this.getString(0,this.length);
}
,__class__: haxe_io_Bytes
};
var haxe_io_Encoding = $hxEnums["haxe.io.Encoding"] = { __ename__ : "haxe.io.Encoding", __constructs__ : ["UTF8","RawNative"]
,UTF8: {_hx_index:0,__enum__:"haxe.io.Encoding",toString:$estr}
,RawNative: {_hx_index:1,__enum__:"haxe.io.Encoding",toString:$estr}
};
var haxe_crypto_Base64 = function() { };
$hxClasses["haxe.crypto.Base64"] = haxe_crypto_Base64;
haxe_crypto_Base64.__name__ = "haxe.crypto.Base64";
haxe_crypto_Base64.encode = function(bytes,complement) {
if(complement == null) {
complement = true;
}
var str = new haxe_crypto_BaseCode(haxe_crypto_Base64.BYTES).encodeBytes(bytes).toString();
if(complement) {
switch(bytes.length % 3) {
case 1:
str += "==";
break;
case 2:
str += "=";
break;
default:
}
}
return str;
};
haxe_crypto_Base64.decode = function(str,complement) {
if(complement == null) {
complement = true;
}
if(complement) {
while(HxOverrides.cca(str,str.length - 1) == 61) str = HxOverrides.substr(str,0,-1);
}
return new haxe_crypto_BaseCode(haxe_crypto_Base64.BYTES).decodeBytes(haxe_io_Bytes.ofString(str));
};
var haxe_crypto_BaseCode = function(base) {
var len = base.length;
var nbits = 1;
while(len > 1 << nbits) ++nbits;
if(nbits > 8 || len != 1 << nbits) {
throw haxe_Exception.thrown("BaseCode : base length must be a power of two.");
}
this.base = base;
this.nbits = nbits;
};
$hxClasses["haxe.crypto.BaseCode"] = haxe_crypto_BaseCode;
haxe_crypto_BaseCode.__name__ = "haxe.crypto.BaseCode";
haxe_crypto_BaseCode.prototype = {
encodeBytes: function(b) {
var nbits = this.nbits;
var base = this.base;
var size = b.length * 8 / nbits | 0;
var out = new haxe_io_Bytes(new ArrayBuffer(size + (b.length * 8 % nbits == 0 ? 0 : 1)));
var buf = 0;
var curbits = 0;
var mask = (1 << nbits) - 1;
var pin = 0;
var pout = 0;
while(pout < size) {
while(curbits < nbits) {
curbits += 8;
buf <<= 8;
buf |= b.b[pin++];
}
curbits -= nbits;
out.b[pout++] = base.b[buf >> curbits & mask];
}
if(curbits > 0) {
out.b[pout++] = base.b[buf << nbits - curbits & mask];
}
return out;
}
,initTable: function() {
var tbl = [];
var _g = 0;
while(_g < 256) {
var i = _g++;
tbl[i] = -1;
}
var _g = 0;
var _g1 = this.base.length;
while(_g < _g1) {
var i = _g++;
tbl[this.base.b[i]] = i;
}
this.tbl = tbl;
}
,decodeBytes: function(b) {
var nbits = this.nbits;
var base = this.base;
if(this.tbl == null) {
this.initTable();
}
var tbl = this.tbl;
var size = b.length * nbits >> 3;
var out = new haxe_io_Bytes(new ArrayBuffer(size));
var buf = 0;
var curbits = 0;
var pin = 0;
var pout = 0;
while(pout < size) {
while(curbits < 8) {
curbits += nbits;
buf <<= nbits;
var i = tbl[b.b[pin++]];
if(i == -1) {
throw haxe_Exception.thrown("BaseCode : invalid encoded char");
}
buf |= i;
}
curbits -= 8;
out.b[pout++] = buf >> curbits & 255;
}
return out;
}
,__class__: haxe_crypto_BaseCode
};
var haxe_ds_GenericCell = function(elt,next) {
this.elt = elt;
this.next = next;
};
$hxClasses["haxe.ds.GenericCell"] = haxe_ds_GenericCell;
haxe_ds_GenericCell.__name__ = "haxe.ds.GenericCell";
haxe_ds_GenericCell.prototype = {
__class__: haxe_ds_GenericCell
};
var haxe_ds_GenericStack = function() {
};
$hxClasses["haxe.ds.GenericStack"] = haxe_ds_GenericStack;
haxe_ds_GenericStack.__name__ = "haxe.ds.GenericStack";
haxe_ds_GenericStack.prototype = {
__class__: haxe_ds_GenericStack
};
var haxe_ds_IntMap = function() {
this.h = { };
};
$hxClasses["haxe.ds.IntMap"] = haxe_ds_IntMap;
haxe_ds_IntMap.__name__ = "haxe.ds.IntMap";
haxe_ds_IntMap.__interfaces__ = [haxe_IMap];
haxe_ds_IntMap.prototype = {
remove: function(key) {
if(!this.h.hasOwnProperty(key)) {
return false;
}
delete(this.h[key]);
return true;
}
,keys: function() {
var a = [];
for( var key in this.h ) if(this.h.hasOwnProperty(key)) a.push(key | 0);
return new haxe_iterators_ArrayIterator(a);
}
,iterator: function() {
return { ref : this.h, it : this.keys(), hasNext : function() {
return this.it.hasNext();
}, next : function() {
var i = this.it.next();
return this.ref[i];
}};
}
,__class__: haxe_ds_IntMap
};
var haxe_ds_List = function() {
this.length = 0;
};
$hxClasses["haxe.ds.List"] = haxe_ds_List;
haxe_ds_List.__name__ = "haxe.ds.List";
haxe_ds_List.prototype = {
add: function(item) {
var x = new haxe_ds__$List_ListNode(item,null);
if(this.h == null) {
this.h = x;
} else {
this.q.next = x;
}
this.q = x;
this.length++;
}
,iterator: function() {
return new haxe_ds__$List_ListIterator(this.h);
}
,__class__: haxe_ds_List
};
var haxe_ds__$List_ListNode = function(item,next) {
this.item = item;
this.next = next;
};
$hxClasses["haxe.ds._List.ListNode"] = haxe_ds__$List_ListNode;
haxe_ds__$List_ListNode.__name__ = "haxe.ds._List.ListNode";
haxe_ds__$List_ListNode.prototype = {
__class__: haxe_ds__$List_ListNode
};
var haxe_ds__$List_ListIterator = function(head) {
this.head = head;
};
$hxClasses["haxe.ds._List.ListIterator"] = haxe_ds__$List_ListIterator;
haxe_ds__$List_ListIterator.__name__ = "haxe.ds._List.ListIterator";
haxe_ds__$List_ListIterator.prototype = {
hasNext: function() {
return this.head != null;
}
,next: function() {
var val = this.head.item;
this.head = this.head.next;
return val;
}
,__class__: haxe_ds__$List_ListIterator
};
var haxe_ds_ObjectMap = function() {
this.h = { __keys__ : { }};
};
$hxClasses["haxe.ds.ObjectMap"] = haxe_ds_ObjectMap;
haxe_ds_ObjectMap.__name__ = "haxe.ds.ObjectMap";
haxe_ds_ObjectMap.__interfaces__ = [haxe_IMap];
haxe_ds_ObjectMap.prototype = {
set: function(key,value) {
var id = key.__id__;
if(id == null) {
id = (key.__id__ = $global.$haxeUID++);
}
this.h[id] = value;
this.h.__keys__[id] = key;
}
,remove: function(key) {
var id = key.__id__;
if(this.h.__keys__[id] == null) {
return false;
}
delete(this.h[id]);
delete(this.h.__keys__[id]);
return true;
}
,keys: function() {
var a = [];
for( var key in this.h.__keys__ ) {
if(this.h.hasOwnProperty(key)) {
a.push(this.h.__keys__[key]);
}
}
return new haxe_iterators_ArrayIterator(a);
}
,__class__: haxe_ds_ObjectMap
};
var haxe_ds_StringMap = function() {
this.h = Object.create(null);
};
$hxClasses["haxe.ds.StringMap"] = haxe_ds_StringMap;
haxe_ds_StringMap.__name__ = "haxe.ds.StringMap";
haxe_ds_StringMap.__interfaces__ = [haxe_IMap];
haxe_ds_StringMap.keysIterator = function(h) {
var keys = Object.keys(h);
var len = keys.length;
var idx = 0;
return { hasNext : function() {
return idx < len;
}, next : function() {
idx += 1;
return keys[idx - 1];
}};
};
haxe_ds_StringMap.valueIterator = function(h) {
var keys = Object.keys(h);
var len = keys.length;
var idx = 0;
return { hasNext : function() {
return idx < len;
}, next : function() {
idx += 1;
return h[keys[idx - 1]];
}};
};
haxe_ds_StringMap.prototype = {
iterator: function() {
return haxe_ds_StringMap.valueIterator(this.h);
}
,__class__: haxe_ds_StringMap
};
var haxe_io_Error = $hxEnums["haxe.io.Error"] = { __ename__ : "haxe.io.Error", __constructs__ : ["Blocked","Overflow","OutsideBounds","Custom"]
,Blocked: {_hx_index:0,__enum__:"haxe.io.Error",toString:$estr}
,Overflow: {_hx_index:1,__enum__:"haxe.io.Error",toString:$estr}
,OutsideBounds: {_hx_index:2,__enum__:"haxe.io.Error",toString:$estr}
,Custom: ($_=function(e) { return {_hx_index:3,e:e,__enum__:"haxe.io.Error",toString:$estr}; },$_.__params__ = ["e"],$_)
};
var haxe_iterators_ArrayIterator = function(array) {
this.current = 0;
this.array = array;
};
$hxClasses["haxe.iterators.ArrayIterator"] = haxe_iterators_ArrayIterator;
haxe_iterators_ArrayIterator.__name__ = "haxe.iterators.ArrayIterator";
haxe_iterators_ArrayIterator.prototype = {
hasNext: function() {
return this.current < this.array.length;
}
,next: function() {
return this.array[this.current++];
}
,__class__: haxe_iterators_ArrayIterator
};
var js_Boot = function() { };
$hxClasses["js.Boot"] = js_Boot;
js_Boot.__name__ = "js.Boot";
js_Boot.getClass = function(o) {
if(o == null) {
return null;
} else if(((o) instanceof Array)) {
return Array;
} else {
var cl = o.__class__;
if(cl != null) {
return cl;
}
var name = js_Boot.__nativeClassName(o);
if(name != null) {
return js_Boot.__resolveNativeClass(name);
}
return null;
}
};
js_Boot.__string_rec = function(o,s) {
if(o == null) {
return "null";
}
if(s.length >= 5) {
return "<...>";
}
var t = typeof(o);
if(t == "function" && (o.__name__ || o.__ename__)) {
t = "object";
}
switch(t) {
case "function":
return "<function>";
case "object":
if(o.__enum__) {
var e = $hxEnums[o.__enum__];
var n = e.__constructs__[o._hx_index];
var con = e[n];
if(con.__params__) {
s = s + "\t";
return n + "(" + ((function($this) {
var $r;
var _g = [];
{
var _g1 = 0;
var _g2 = con.__params__;
while(true) {
if(!(_g1 < _g2.length)) {
break;
}
var p = _g2[_g1];
_g1 = _g1 + 1;
_g.push(js_Boot.__string_rec(o[p],s));
}
}
$r = _g;
return $r;
}(this))).join(",") + ")";
} else {
return n;
}
}
if(((o) instanceof Array)) {
var str = "[";
s += "\t";
var _g = 0;
var _g1 = o.length;
while(_g < _g1) {
var i = _g++;
str += (i > 0 ? "," : "") + js_Boot.__string_rec(o[i],s);
}
str += "]";
return str;
}
var tostr;
try {
tostr = o.toString;
} catch( _g ) {
return "???";
}
if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
var s2 = o.toString();
if(s2 != "[object Object]") {
return s2;
}
}
var str = "{\n";
s += "\t";
var hasp = o.hasOwnProperty != null;
var k = null;
for( k in o ) {
if(hasp && !o.hasOwnProperty(k)) {
continue;
}
if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
continue;
}
if(str.length != 2) {
str += ", \n";
}
str += s + k + " : " + js_Boot.__string_rec(o[k],s);
}
s = s.substring(1);
str += "\n" + s + "}";
return str;
case "string":
return o;
default:
return String(o);
}
};
js_Boot.__interfLoop = function(cc,cl) {
if(cc == null) {
return false;
}
if(cc == cl) {
return true;
}
var intf = cc.__interfaces__;
if(intf != null) {
var _g = 0;
var _g1 = intf.length;
while(_g < _g1) {
var i = _g++;
var i1 = intf[i];
if(i1 == cl || js_Boot.__interfLoop(i1,cl)) {
return true;
}
}
}
return js_Boot.__interfLoop(cc.__super__,cl);
};
js_Boot.__instanceof = function(o,cl) {
if(cl == null) {
return false;
}
switch(cl) {
case Array:
return ((o) instanceof Array);
case Bool:
return typeof(o) == "boolean";
case Dynamic:
return o != null;
case Float:
return typeof(o) == "number";
case Int:
if(typeof(o) == "number") {
return ((o | 0) === o);
} else {
return false;
}
break;
case String:
return typeof(o) == "string";
default:
if(o != null) {
if(typeof(cl) == "function") {
if(js_Boot.__downcastCheck(o,cl)) {
return true;
}
} else if(typeof(cl) == "object" && js_Boot.__isNativeObj(cl)) {
if(((o) instanceof cl)) {
return true;
}
}
} else {
return false;
}
if(cl == Class ? o.__name__ != null : false) {
return true;
}
if(cl == Enum ? o.__ename__ != null : false) {
return true;
}
return o.__enum__ != null ? $hxEnums[o.__enum__] == cl : false;
}
};
js_Boot.__downcastCheck = function(o,cl) {
if(!((o) instanceof cl)) {
if(cl.__isInterface__) {
return js_Boot.__interfLoop(js_Boot.getClass(o),cl);
} else {
return false;
}
} else {
return true;
}
};
js_Boot.__implements = function(o,iface) {
return js_Boot.__interfLoop(js_Boot.getClass(o),iface);
};
js_Boot.__nativeClassName = function(o) {
var name = js_Boot.__toStr.call(o).slice(8,-1);
if(name == "Object" || name == "Function" || name == "Math" || name == "JSON") {
return null;
}
return name;
};
js_Boot.__isNativeObj = function(o) {
return js_Boot.__nativeClassName(o) != null;
};
js_Boot.__resolveNativeClass = function(name) {
return $global[name];
};
var modding_ModTools = $hx_exports["ModTools"] = function() { };
$hxClasses["modding.ModTools"] = modding_ModTools;
modding_ModTools.__name__ = "modding.ModTools";
modding_ModTools._performOnLoadEarly = function(city,queue) {
modding_ModTools._performOnLoadAny(city,queue,modding_ModTools.onGlobalSaveFuncsEarly);
};
modding_ModTools._performOnLoad = function(city,queue) {
modding_ModTools._performOnLoadAny(city,queue,modding_ModTools.onGlobalSaveFuncs);
};
modding_ModTools._performOnLoadAny = function(city,queue,saveFuncs) {
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var len = intToRead;
var loadFuncs_h = Object.create(null);
Lambda.iter(saveFuncs,function(funcs) {
loadFuncs_h[funcs.modIdentifier] = funcs;
});
var _g = 0;
var _g1 = len;
while(_g < _g1) {
var i = _g++;
var modIdentifier = queue.readString();
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var modVer = intToRead;
var intToRead1 = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var continueReadingOn = intToRead1;
var funcInfo = loadFuncs_h[modIdentifier];
if(funcInfo != null) {
loadFuncs_h[modIdentifier].onLoad(city,queue,modVer);
}
queue.readStart = continueReadingOn;
}
};
var pathfinder_DirectConnectionFinder = function() { };
$hxClasses["pathfinder.DirectConnectionFinder"] = pathfinder_DirectConnectionFinder;
pathfinder_DirectConnectionFinder.__name__ = "pathfinder.DirectConnectionFinder";
pathfinder_DirectConnectionFinder.find = function(city,fromBuilding,isGoal,ignoreBuilding) {
var queue = new polygonal_ds_ArrayedQueue();
if(queue.capacity == queue.mSize) {
queue.grow();
}
queue.mData[(queue.mSize++ + queue.mFront) % queue.capacity] = fromBuilding;
city.simulation.permanentFinder.pfSeenStart += 3;
if(city.simulation.permanentFinder.pfSeenStart > 100000) {
city.simulation.permanentFinder.pfSeenStart = 1;
}
fromBuilding.pfSeen = city.simulation.permanentFinder.pfSeenStart;
while(queue.mSize > 0) {
var x = queue.mData[queue.mFront++];
if(queue.mFront == queue.capacity) {
queue.mFront = 0;
}
queue.mSize--;
var bld = x;
if(isGoal(bld)) {
return bld;
}
var bld2 = bld.leftBuilding;
if(bld2 != null) {
if(!ignoreBuilding(bld2)) {
if(bld2.pfSeen != city.simulation.permanentFinder.pfSeenStart) {
if(queue.capacity == queue.mSize) {
queue.grow();
}
queue.mData[(queue.mSize++ + queue.mFront) % queue.capacity] = bld2;
bld2.pfSeen = city.simulation.permanentFinder.pfSeenStart;
}
}
}
var bld21 = bld.rightBuilding;
if(bld21 != null) {
if(!ignoreBuilding(bld21)) {
if(bld21.pfSeen != city.simulation.permanentFinder.pfSeenStart) {
if(queue.capacity == queue.mSize) {
queue.grow();
}
queue.mData[(queue.mSize++ + queue.mFront) % queue.capacity] = bld21;
bld21.pfSeen = city.simulation.permanentFinder.pfSeenStart;
}
}
}
var bld22 = bld.topBuilding;
if(bld22 != null) {
if(!ignoreBuilding(bld22)) {
if(bld22.pfSeen != city.simulation.permanentFinder.pfSeenStart) {
if(queue.capacity == queue.mSize) {
queue.grow();
}
queue.mData[(queue.mSize++ + queue.mFront) % queue.capacity] = bld22;
bld22.pfSeen = city.simulation.permanentFinder.pfSeenStart;
}
}
}
var bld23 = bld.bottomBuilding;
if(bld23 != null) {
if(!ignoreBuilding(bld23)) {
if(bld23.pfSeen != city.simulation.permanentFinder.pfSeenStart) {
if(queue.capacity == queue.mSize) {
queue.grow();
}
queue.mData[(queue.mSize++ + queue.mFront) % queue.capacity] = bld23;
bld23.pfSeen = city.simulation.permanentFinder.pfSeenStart;
}
}
}
}
return null;
};
var pathfinder_FlyingPathfinder = function(city) {
this.city = city;
this.allWaypoints = [];
};
$hxClasses["pathfinder.FlyingPathfinder"] = pathfinder_FlyingPathfinder;
pathfinder_FlyingPathfinder.__name__ = "pathfinder.FlyingPathfinder";
pathfinder_FlyingPathfinder.prototype = {
updateWaypoints: function() {
this.allWaypoints = [];
var obstructions = [];
var gridxstart = 0;
var gridxmax = 20;
if(this.city.worlds.length > 0) {
gridxstart = common_ArrayExtensions.min(this.city.worlds,function(w) {
return w.rect.x;
}).rect.x - 40;
gridxmax = common_ArrayExtensions.max(this.city.worlds,function(w) {
return w.rect.get_x2();
}).rect.get_x2() + 40;
}
var sortedWorlds = [];
sortedWorlds = this.city.worlds.slice();
sortedWorlds.sort(function(w1,w2) {
return w1.rect.y - w2.rect.y;
});
var istart = gridxstart / 20 | 0;
var obstructionsLength = (gridxmax / 20 | 0) - istart + 1;
var _g = [];
var _g1 = 0;
var _g2 = obstructionsLength;
while(_g1 < _g2) {
var i = _g1++;
_g.push([]);
}
var landingSites = _g;
var _g = 0;
var _g1 = this.city.landingSites;
while(_g < _g1.length) {
var landingSite = _g1[_g];
++_g;
landingSites[(landingSite.position.x / 20 | 0) - istart].push(landingSite);
}
var _g = 0;
var _g1 = obstructionsLength;
while(_g < _g1) {
var i = _g++;
var x = (i + istart) * 20;
obstructions.push([]);
var _g2 = 0;
while(_g2 < sortedWorlds.length) {
var world = sortedWorlds[_g2];
++_g2;
var lower = world.rect.x;
var upper = world.rect.get_x2();
if(x >= lower && x < upper) {
var worldRelativeIndex = (x - world.rect.x) / 20 | 0;
var maxY = null;
if(world.mask != null) {
var thisMask = world.mask[worldRelativeIndex];
var _g3 = 0;
var _g4 = thisMask.length;
while(_g3 < _g4) {
var j = _g3++;
if(thisMask[j]) {
maxY = j;
}
}
}
var startY = [world.rect.y - world.permanents[worldRelativeIndex].length * 20];
var pm = world.permanents[worldRelativeIndex].length;
var hole = false;
var topBuilding = world.permanents[worldRelativeIndex][pm - 1];
var topWasLandingSite = topBuilding != null && topBuilding.is(buildings_LandingSite);
while(--pm > 0) {
var thisPermanent = world.permanents[worldRelativeIndex][pm];
if(thisPermanent == null) {
if(!hole) {
if(pm != world.permanents[worldRelativeIndex].length - 1) {
var endY = world.rect.y - (pm + 1) * 20;
var nextRelevantObstruction = obstructions[i][obstructions[i].length - 1];
if(topWasLandingSite) {
startY[0] += 20;
} else if(obstructions[i].length == 0 || startY[0] > nextRelevantObstruction + 20) {
startY[0] -= 20;
}
if(obstructions[i].length == 0 || startY[0] > nextRelevantObstruction) {
obstructions[i].push(startY[0]);
obstructions[i].push(endY);
} else {
obstructions[i][obstructions[i].length - 1] = endY;
}
}
hole = true;
}
} else if(hole) {
startY[0] = world.rect.y - (pm + 1) * 20;
hole = false;
topWasLandingSite = thisPermanent.is(buildings_LandingSite);
}
}
if(maxY != null) {
var endY1 = (maxY + 1) * 20 + world.rect.y;
var nextRelevantObstruction1 = obstructions[i][obstructions[i].length - 1];
if(common_ArrayExtensions.any(landingSites[i],(function(startY) {
return function(ls) {
return ls.position.y == startY[0];
};
})(startY))) {
startY[0] += 20;
} else if(obstructions[i].length == 0 || startY[0] > nextRelevantObstruction1 + 20) {
startY[0] -= 20;
}
if(obstructions[i].length == 0 || startY[0] > nextRelevantObstruction1) {
obstructions[i].push(startY[0]);
obstructions[i].push(endY1);
} else {
obstructions[i][obstructions[i].length - 1] = endY1;
}
}
}
}
}
var previousPathfindingWaypoints = new haxe_ds_IntMap();
var prevWayPoints = [];
var _g = 1;
var _g1 = (gridxmax / 20 | 0) - istart;
while(_g < _g1) {
var i = _g++;
var x = (i + istart) * 20;
var wayPoints = [];
var obstructionsLength = obstructions[i].length / 2 | 0;
var nextObstructions = [obstructions[i + 1]];
var prevWPNum = 0;
var k = 0;
var thesePathfindingWaypoints = new haxe_ds_IntMap();
var _g2 = 0;
var _g3 = obstructionsLength + 1;
while(_g2 < _g3) {
var j = _g2++;
var theseWaypoints = [[]];
var yfrom = [-1000000];
var yto = [1000000];
if(obstructionsLength != 0) {
if(j == 0) {
yto[0] = obstructions[i][0];
} else if(j == obstructionsLength) {
yfrom[0] = obstructions[i][obstructionsLength * 2 - 1];
} else {
yfrom[0] = obstructions[i][j * 2 - 1];
yto[0] = obstructions[i][j * 2];
}
}
var addNextWaypointToAvoidBlockers = (function(yto,yfrom,theseWaypoints,nextObstructions) {
return function(wp) {
var b = 0;
var blockerFrom = -1;
var blockerTo = -1;
while(b < nextObstructions[0].length) {
if(wp >= nextObstructions[0][b] && wp < nextObstructions[0][b + 1]) {
blockerFrom = nextObstructions[0][b];
blockerTo = nextObstructions[0][b + 1];
break;
}
if(nextObstructions[0][b] > wp) {
break;
}
b += 2;
}
if(blockerFrom != -1) {
if(blockerFrom > yfrom[0]) {
theseWaypoints[0].push(blockerFrom - 20);
} else if(blockerTo < yto[0]) {
theseWaypoints[0].push(blockerTo);
}
}
};
})(yto,yfrom,theseWaypoints,nextObstructions);
while(k < nextObstructions[0].length) {
if(nextObstructions[0][k] > yfrom[0] && nextObstructions[0][k + 1] < yto[0]) {
theseWaypoints[0].push(nextObstructions[0][k] - 20);
theseWaypoints[0].push(nextObstructions[0][k + 1]);
} else if(nextObstructions[0][k] > yfrom[0]) {
break;
}
k += 2;
}
while(prevWPNum < prevWayPoints.length) {
var wp = prevWayPoints[prevWPNum];
if(wp >= yfrom[0] && wp < yto[0]) {
theseWaypoints[0].push(wp);
addNextWaypointToAvoidBlockers(wp);
} else if(wp >= yfrom[0]) {
break;
}
++prevWPNum;
}
var _g4 = 0;
var _g5 = landingSites[i];
while(_g4 < _g5.length) {
var landingSite = _g5[_g4];
++_g4;
if(landingSite.position.y == yto[0] - 20) {
theseWaypoints[0].push(landingSite.position.y);
addNextWaypointToAvoidBlockers(landingSite.position.y);
}
}
theseWaypoints[0].sort((function() {
return function(wp1,wp2) {
return wp1 - wp2;
};
})());
var prevWaypoint = null;
var j1 = theseWaypoints[0].length;
while(--j1 >= 0) {
if(theseWaypoints[0][j1] == prevWaypoint) {
theseWaypoints[0].splice(j1,1);
}
prevWaypoint = theseWaypoints[0][j1];
}
var prevwp = null;
var _g6 = 0;
while(_g6 < theseWaypoints[0].length) {
var wp1 = theseWaypoints[0][_g6];
++_g6;
wayPoints.push(wp1);
var pathfindingWaypoint = new pathfinder_FlyingPathfinderWaypoint(x,wp1);
if(prevwp != null) {
prevwp.connections.push(pathfindingWaypoint);
pathfindingWaypoint.connections.push(prevwp);
}
if(previousPathfindingWaypoints.h.hasOwnProperty(wp1)) {
var connectToPrevious = previousPathfindingWaypoints.h[wp1];
connectToPrevious.connections.push(pathfindingWaypoint);
pathfindingWaypoint.connections.push(connectToPrevious);
}
thesePathfindingWaypoints.h[wp1] = pathfindingWaypoint;
this.allWaypoints.push(pathfindingWaypoint);
prevwp = pathfindingWaypoint;
}
}
var _g7 = 0;
var _g8 = landingSites[i];
while(_g7 < _g8.length) {
var landingSite1 = [_g8[_g7]];
++_g7;
var tmp = (function(landingSite) {
return function(wp) {
return wp.y == landingSite[0].position.y;
};
})(landingSite1);
landingSite1[0].connectedWaypoint = Lambda.find(thesePathfindingWaypoints,tmp);
if(landingSite1[0].connectedWaypoint != null) {
landingSite1[0].connectedWaypoint.connectedSite = landingSite1[0];
}
}
prevWayPoints = wayPoints;
previousPathfindingWaypoints = thesePathfindingWaypoints;
}
}
,findRoute: function(from,to) {
if(from.connectedWaypoint == null || to.connectedWaypoint == null) {
console.log("FloatingSpaceCities/pathfinder/FlyingPathfinder.hx:274:","problem while finding an air route from:");
console.log("FloatingSpaceCities/pathfinder/FlyingPathfinder.hx:275:",from);
console.log("FloatingSpaceCities/pathfinder/FlyingPathfinder.hx:276:","to:");
console.log("FloatingSpaceCities/pathfinder/FlyingPathfinder.hx:277:",to);
console.log("FloatingSpaceCities/pathfinder/FlyingPathfinder.hx:278:","If you're an end user, please report this problem. The game should continue normally now, but saving+loading the game may help if you do encounter further pathfinding problems.");
return null;
}
var _g = 0;
var _g1 = this.allWaypoints;
while(_g < _g1.length) {
var wp = _g1[_g];
++_g;
wp.seen = 0;
}
var pathQueue = new polygonal_ds_PriorityQueue(null,true);
var start = from.connectedWaypoint;
start.priority = 0;
pathQueue.enqueue(start);
var goal = to.connectedWaypoint;
while(pathQueue.mSize != 0) {
var currentWaypoint = pathQueue.dequeue();
currentWaypoint.seen = 2;
if(currentWaypoint == goal) {
var path = [];
while(currentWaypoint != start) {
path.push(currentWaypoint);
currentWaypoint = currentWaypoint.prevWaypoint;
}
path.push(start);
return path;
}
var _g = 0;
var _g1 = currentWaypoint.connections;
while(_g < _g1.length) {
var connection = _g1[_g];
++_g;
switch(connection.seen) {
case 0:
connection.seen = 1;
connection.prevWaypoint = currentWaypoint;
connection.priority = currentWaypoint.priority + (Math.abs(currentWaypoint.x - connection.x) + Math.abs(currentWaypoint.y - connection.y));
pathQueue.enqueue(connection);
break;
case 1:
var newPriority = currentWaypoint.priority + (Math.abs(currentWaypoint.x - connection.x) + Math.abs(currentWaypoint.y - connection.y));
if(newPriority < connection.priority) {
connection.prevWaypoint = currentWaypoint;
pathQueue.reprioritize(connection,newPriority);
}
break;
}
}
}
return null;
}
,findAnyOtherLandingSite: function(from) {
if(from.connectedWaypoint == null) {
return null;
}
var _g = 0;
var _g1 = this.allWaypoints;
while(_g < _g1.length) {
var wp = _g1[_g];
++_g;
wp.seen = 0;
}
var pathQueue = new haxe_ds_GenericStack();
var start = from.connectedWaypoint;
start.priority = 0;
pathQueue.head = new haxe_ds_GenericCell(start,pathQueue.head);
while(pathQueue.head != null) {
var k = pathQueue.head;
var currentWaypoint;
if(k == null) {
currentWaypoint = null;
} else {
pathQueue.head = k.next;
currentWaypoint = k.elt;
}
currentWaypoint.seen = 2;
if(currentWaypoint.connectedSite != null && currentWaypoint.connectedSite != from && currentWaypoint.connectedSite.landingSiteGroup != null) {
return currentWaypoint.connectedSite;
}
var _g = 0;
var _g1 = currentWaypoint.connections;
while(_g < _g1.length) {
var connection = _g1[_g];
++_g;
if(connection.seen == 0) {
connection.seen = 1;
connection.prevWaypoint = currentWaypoint;
pathQueue.head = new haxe_ds_GenericCell(connection,pathQueue.head);
}
}
}
return null;
}
,__class__: pathfinder_FlyingPathfinder
};
var polygonal_ds_Prioritizable = function() { };
$hxClasses["polygonal.ds.Prioritizable"] = polygonal_ds_Prioritizable;
polygonal_ds_Prioritizable.__name__ = "polygonal.ds.Prioritizable";
polygonal_ds_Prioritizable.__isInterface__ = true;
polygonal_ds_Prioritizable.prototype = {
__class__: polygonal_ds_Prioritizable
};
var pathfinder_FlyingPathfinderWaypoint = function(x,y) {
this.connectedSite = null;
this.prevWaypoint = null;
this.seen = 0;
this.connections = [];
this.position = 0;
this.priority = 0;
this.x = x;
this.y = y;
};
$hxClasses["pathfinder.FlyingPathfinderWaypoint"] = pathfinder_FlyingPathfinderWaypoint;
pathfinder_FlyingPathfinderWaypoint.__name__ = "pathfinder.FlyingPathfinderWaypoint";
pathfinder_FlyingPathfinderWaypoint.__interfaces__ = [polygonal_ds_Prioritizable];
pathfinder_FlyingPathfinderWaypoint.prototype = {
__class__: pathfinder_FlyingPathfinderWaypoint
};
var pathfinder_PathfinderManager = function(city) {
this.previousRequestSentToWorker = 0;
this.currentMaxThreads = 15;
this.usedWorkers = 0;
this.activeWorkers = 0;
this.restartPathfindingLimit = 1000;
this.totalNumRequested = 0;
this.city = city;
this.workers = [];
var _g = [];
_g.push(new polygonal_ds_ArrayedQueue());
_g.push(new polygonal_ds_ArrayedQueue());
_g.push(new polygonal_ds_ArrayedQueue());
_g.push(new polygonal_ds_ArrayedQueue());
_g.push(new polygonal_ds_ArrayedQueue());
_g.push(new polygonal_ds_ArrayedQueue());
_g.push(new polygonal_ds_ArrayedQueue());
_g.push(new polygonal_ds_ArrayedQueue());
_g.push(new polygonal_ds_ArrayedQueue());
_g.push(new polygonal_ds_ArrayedQueue());
_g.push(new polygonal_ds_ArrayedQueue());
_g.push(new polygonal_ds_ArrayedQueue());
_g.push(new polygonal_ds_ArrayedQueue());
_g.push(new polygonal_ds_ArrayedQueue());
_g.push(new polygonal_ds_ArrayedQueue());
this.citizensForPaths = _g;
var _g = [];
_g.push(null);
_g.push(null);
_g.push(null);
_g.push(null);
_g.push(null);
_g.push(null);
_g.push(null);
_g.push(null);
_g.push(null);
_g.push(null);
_g.push(null);
_g.push(null);
_g.push(null);
_g.push(null);
_g.push(null);
this.storedPathMessages = _g;
var _g = [];
_g.push(null);
_g.push(null);
_g.push(null);
_g.push(null);
_g.push(null);
_g.push(null);
_g.push(null);
_g.push(null);
_g.push(null);
_g.push(null);
_g.push(null);
_g.push(null);
_g.push(null);
_g.push(null);
_g.push(null);
this.pathRequests = _g;
var _g = [];
_g.push(0);
_g.push(0);
_g.push(0);
_g.push(0);
_g.push(0);
_g.push(0);
_g.push(0);
_g.push(0);
_g.push(0);
_g.push(0);
_g.push(0);
_g.push(0);
_g.push(0);
_g.push(0);
_g.push(0);
this.pathRequestPos = _g;
this.setWorkerNumber(Settings.pathfindingWorkers,false);
};
$hxClasses["pathfinder.PathfinderManager"] = pathfinder_PathfinderManager;
pathfinder_PathfinderManager.__name__ = "pathfinder.PathfinderManager";
pathfinder_PathfinderManager.prototype = {
setWorkerNumber: function(newWorkerNumber,sendPathfindInfo) {
if(newWorkerNumber <= 0) {
return;
}
if(newWorkerNumber > this.activeWorkers) {
var workersToAdd = newWorkerNumber - this.activeWorkers;
var origWorkers = this.activeWorkers;
var _g = 0;
var _g1 = workersToAdd;
while(_g < _g1) {
var i = _g++;
this.initNewWorkerIfPossible();
if(sendPathfindInfo && this.activeWorkers > i + origWorkers) {
var pf = this.getPathfindingInfo();
this.postInt32Array(pf,i + origWorkers,false);
}
}
} else {
this.usedWorkers = newWorkerNumber;
}
}
,terminate: function() {
var _g = 0;
var _g1 = this.workers;
while(_g < _g1.length) {
var worker = _g1[_g];
++_g;
worker.terminate();
}
this.activeWorkers = 0;
}
,initNewWorkerIfPossible: function() {
if(this.activeWorkers < this.currentMaxThreads) {
this.initWorker(this.activeWorkers);
this.initPathRequests(this.activeWorkers);
this.activeWorkers++;
this.usedWorkers++;
}
}
,initWorker: function(workerID) {
var _gthis = this;
try {
this.workers[workerID] = new Worker(Resources.pathfinderCodeUrl);
} catch( _g ) {
this.workers[workerID] = new Worker("js/pathfinder.js");
}
this.useModernPostMessage = true;
try {
var testArray = new Int32Array(1);
testArray[0] = 2;
this.workers[workerID].postMessage(testArray.buffer,[testArray.buffer]);
} catch( _g ) {
this.useModernPostMessage = false;
console.log("FloatingSpaceCities/pathfinder/PathfinderManager.hx:111:","Using legacy mode for web workers.");
}
this.storedPathMessages[workerID] = new polygonal_ds_ArrayedQueue(200);
this.workers[workerID].onmessage = function(e) {
var _this = _gthis.storedPathMessages[workerID];
var val = new Int32Array(e.data);
if(_this.capacity == _this.mSize) {
_this.grow();
}
_this.mData[(_this.mSize++ + _this.mFront) % _this.capacity] = val;
};
}
,getPathfindingInfo: function() {
var permanentsInfoLength = 0;
var _g = 0;
var _g1 = this.city.worlds;
while(_g < _g1.length) {
var world = _g1[_g];
++_g;
permanentsInfoLength += 3;
var _g2 = 0;
var _g3 = world.permanents;
while(_g2 < _g3.length) {
var permanentsArray = _g3[_g2];
++_g2;
permanentsInfoLength += 1 + 2 * permanentsArray.length;
}
}
var data = new Int32Array(permanentsInfoLength + 3 * this.city.connections.directWorldConnectionNumber + 4 + this.city.connections.landingSiteGroups.length + this.city.landingSites.length);
var i = 0;
data[i++] = 0;
data[i++] = this.city.worlds.length;
var _g = 0;
var _g1 = this.city.worlds;
while(_g < _g1.length) {
var world = _g1[_g];
++_g;
data[i++] = world.permanents.length;
data[i++] = world.rect.x;
data[i++] = world.rect.y;
var _g2 = 0;
var _g3 = world.permanents;
while(_g2 < _g3.length) {
var permanentsArray = _g3[_g2];
++_g2;
data[i++] = permanentsArray.length;
var _g4 = 0;
while(_g4 < permanentsArray.length) {
var permanent = permanentsArray[_g4];
++_g4;
if(permanent != null) {
data[i++] = permanent.id;
if(!permanent.isBuilding) {
data[i++] = 6;
} else {
data[i++] = permanent.get_typeID() * 2 + (permanent.isBuilding && permanent.isRooftopBuilding ? 1 : 0);
}
} else {
data[i++] = -1;
data[i++] = -1;
}
}
}
}
data[i++] = this.city.connections.directWorldConnectionNumber;
var _g = 0;
var _g1 = this.city.worlds;
while(_g < _g1.length) {
var world = _g1[_g];
++_g;
var _g2 = 0;
var _g3 = world.permanents[0];
while(_g2 < _g3.length) {
var permanent = _g3[_g2];
++_g2;
if(permanent != null && permanent.isBuilding) {
var building = permanent;
if(building.leftBuilding != null) {
var otherBuilding = building.leftBuilding;
var otherWorld = otherBuilding.world;
if(otherWorld.rect.y > world.rect.y || otherWorld.rect.y == world.rect.y && otherWorld.rect.x > world.rect.x) {
data[i++] = 2;
data[i++] = building.id;
data[i++] = otherBuilding.id;
data[i++] = 3;
data[i++] = otherBuilding.id;
data[i++] = building.id;
}
}
}
}
var _g4 = 0;
var _g5 = world.permanents[world.permanents.length - 1];
while(_g4 < _g5.length) {
var permanent1 = _g5[_g4];
++_g4;
if(permanent1 != null && permanent1.isBuilding) {
var building1 = permanent1;
if(building1.rightBuilding != null) {
var otherBuilding1 = building1.rightBuilding;
var otherWorld1 = otherBuilding1.world;
if(otherWorld1.rect.y > world.rect.y || otherWorld1.rect.y == world.rect.y && otherWorld1.rect.x > world.rect.x) {
data[i++] = 3;
data[i++] = building1.id;
data[i++] = otherBuilding1.id;
data[i++] = 2;
data[i++] = otherBuilding1.id;
data[i++] = building1.id;
}
}
}
}
}
data[i++] = this.city.connections.landingSiteGroups.length;
var _g = 0;
var _g1 = this.city.connections.landingSiteGroups;
while(_g < _g1.length) {
var lsg = _g1[_g];
++_g;
data[i++] = lsg.length;
var _g2 = 0;
while(_g2 < lsg.length) {
var landingSite = lsg[_g2];
++_g2;
data[i++] = landingSite.id;
}
}
return data;
}
,sendPathfindingInfo: function() {
var data = this.getPathfindingInfo();
var _g = 0;
var _g1 = this.activeWorkers;
while(_g < _g1) {
var worker = _g++;
this.postInt32Array(data,worker,true);
}
}
,findPath: function(citizen,goal) {
this.previousRequestSentToWorker++;
if(this.previousRequestSentToWorker >= this.usedWorkers) {
this.previousRequestSentToWorker = 0;
}
var workerID = this.previousRequestSentToWorker;
var thesePathRequests = this.pathRequests[workerID];
if(citizen.inPermanent != null) {
thesePathRequests[this.pathRequestPos[workerID]++] = -1;
thesePathRequests[this.pathRequestPos[workerID]++] = citizen.inPermanent.id;
} else {
thesePathRequests[this.pathRequestPos[workerID]++] = this.city.worlds.indexOf(citizen.onWorld);
thesePathRequests[this.pathRequestPos[workerID]++] = citizen.relativeX | 0;
}
thesePathRequests[this.pathRequestPos[workerID]++] = goal.id;
if(citizen.home != null && citizen.home.get_hasPrivateTeleporter()) {
thesePathRequests[this.pathRequestPos[workerID]++] = citizen.home.id;
} else {
thesePathRequests[this.pathRequestPos[workerID]++] = -1;
}
var _this = this.citizensForPaths[workerID];
if(_this.capacity == _this.mSize) {
_this.grow();
}
_this.mData[(_this.mSize++ + _this.mFront) % _this.capacity] = citizen;
citizen.isRequestingPath = true;
citizen.requestingPathGoal = goal;
if(this.pathRequestPos[workerID] >= 402) {
this.requestPaths(workerID);
}
}
,requestAllPaths: function() {
var _g = 0;
var _g1 = this.activeWorkers;
while(_g < _g1) {
var i = _g++;
this.requestPaths(i);
}
}
,requestPaths: function(workerID) {
if(this.pathRequestPos[workerID] > 2) {
this.pathRequests[workerID][0] = 1;
this.pathRequests[workerID][1] = (this.pathRequestPos[workerID] - 2) / 4 | 0;
this.postInt32Array(this.pathRequests[workerID],workerID,false);
this.totalNumRequested += (this.pathRequestPos[workerID] - 2) / 4 | 0;
this.initPathRequests(workerID);
}
}
,initPathRequests: function(workerID) {
this.pathRequests[workerID] = new Int32Array(402);
this.pathRequestPos[workerID] = 2;
}
,distributePaths: function() {
var _g = 0;
var _g1 = this.activeWorkers;
while(_g < _g1) {
var i = _g++;
while(this.storedPathMessages[i].mSize != 0) {
var _this = this.storedPathMessages[i];
var x = _this.mData[_this.mFront++];
if(_this.mFront == _this.capacity) {
_this.mFront = 0;
}
_this.mSize--;
var theseStoredPaths = x;
var pathPos = 1;
var _g2 = 0;
var _g3 = theseStoredPaths[0];
while(_g2 < _g3) {
var _ = _g2++;
var pathLength = theseStoredPaths[pathPos];
var _this1 = this.citizensForPaths[i];
var x1 = _this1.mData[_this1.mFront++];
if(_this1.mFront == _this1.capacity) {
_this1.mFront = 0;
}
_this1.mSize--;
var cfp = x1;
if(cfp != null) {
cfp.setPath(theseStoredPaths,pathPos + 1,pathLength);
}
pathPos += pathLength + 1;
}
}
this.totalNumRequested = 0;
}
}
,getTotalNumberOfRequested: function() {
var total = 0;
var _g = 0;
var _g1 = this.activeWorkers;
while(_g < _g1) {
var i = _g++;
total += this.citizensForPaths[i].mSize;
}
return total;
}
,postInt32Array: function(arrayToPost,workerID,neverTransferControl) {
if(this.useModernPostMessage && !neverTransferControl) {
this.workers[workerID].postMessage(arrayToPost.buffer,[arrayToPost.buffer]);
} else {
this.workers[workerID].postMessage(arrayToPost.buffer);
}
}
,invalidateAllPaths: function() {
var _g = 0;
var _g1 = this.citizensForPaths;
while(_g < _g1.length) {
var pathQueue = _g1[_g];
++_g;
var citizen = pathQueue.iterator();
while(citizen.hasNext()) {
var citizen1 = citizen.next();
if(citizen1 != null) {
citizen1.isRequestingPath = false;
}
}
}
var _g = 0;
var _g1 = this.activeWorkers;
while(_g < _g1) {
var i = _g++;
if(this.citizensForPaths[i].mSize > Math.min(this.city.simulation.citizens.length,this.restartPathfindingLimit)) {
this.workers[i].terminate();
this.citizensForPaths[i].clear();
this.initWorker(i);
} else {
var len = this.citizensForPaths[i].mSize - ((this.pathRequestPos[i] - 2) / 4 | 0);
this.citizensForPaths[i].clear();
var _g2 = 0;
var _g3 = len;
while(_g2 < _g3) {
var nullToAdd = _g2++;
var _this = this.citizensForPaths[i];
if(_this.capacity == _this.mSize) {
_this.grow();
}
_this.mData[(_this.mSize++ + _this.mFront) % _this.capacity] = null;
}
}
this.initPathRequests(i);
}
}
,__class__: pathfinder_PathfinderManager
};
var pathfinder_PathfindingTools = function() { };
$hxClasses["pathfinder.PathfindingTools"] = pathfinder_PathfindingTools;
pathfinder_PathfindingTools.__name__ = "pathfinder.PathfindingTools";
pathfinder_PathfindingTools.findNearestBestBuildingStack = function(citizen,ratingFunc) {
var citizenPosition = citizen.get_worldX();
var bestRating = -Infinity;
var bestStack = null;
var bestDistance = Infinity;
var _g = 0;
var _g1 = citizen.onWorld.permanents.length;
while(_g < _g1) {
var i = _g++;
var stack = citizen.onWorld.permanents[i];
var rating = ratingFunc(stack);
var distance = Math.abs(citizenPosition - i * 20);
if(rating > bestRating || rating == bestRating && distance < bestDistance) {
bestStack = i;
bestDistance = distance;
bestRating = rating;
}
}
return bestStack;
};
var pathfinder_PermanentFinder = function(city) {
this.pfSeenStart = 1;
this.limitQueryAmountFor = 0;
this.updateQueries = 0;
this.pathQueue = new polygonal_ds_PriorityQueue(10,true);
this.city = city;
this.savedResults = new haxe_ds_StringMap();
};
$hxClasses["pathfinder.PermanentFinder"] = pathfinder_PermanentFinder;
pathfinder_PermanentFinder.__name__ = "pathfinder.PermanentFinder";
pathfinder_PermanentFinder.prototype = {
preUpdate: function() {
this.updateQueries = 0;
if(this.limitQueryAmountFor > 0) {
this.limitQueryAmountFor--;
}
}
,requestQueryLimiting: function(strictInFirstUpdate) {
if(strictInFirstUpdate == null) {
strictInFirstUpdate = false;
}
this.limitQueryAmountFor = 120;
if(strictInFirstUpdate) {
this.updateQueries = 10;
}
}
,canPerformQuery: function() {
if(this.limitQueryAmountFor > 0) {
return this.updateQueries < 10;
} else {
return true;
}
}
,query: function(from,isGoal,goalNiceness,fromWorld,fromWorldX,maximumDistance,citizen,bestExpectedGoalNiceness) {
if(bestExpectedGoalNiceness == null) {
bestExpectedGoalNiceness = 100000000;
}
if(maximumDistance == null) {
maximumDistance = -1;
}
var _gthis = this;
this.updateQueries += 1;
this.pfSeenStart += 3;
if(this.pfSeenStart > 100000) {
this.pfSeenStart = 1;
}
if(from != null) {
var newPrioritizable = pathfinder_PermanentPrioritizable.create(0,from);
from.pfRelatedPrioritizable = newPrioritizable;
this.pathQueue.enqueue(newPrioritizable);
} else {
var _g = 0;
var _g1 = fromWorld.permanents;
while(_g < _g1.length) {
var bottomPermanents = _g1[_g];
++_g;
if(bottomPermanents.length == 0 || bottomPermanents[0] == null) {
continue;
}
var newPriority = Math.abs(bottomPermanents[0].position.x - fromWorldX);
if(maximumDistance != -1 && newPriority > maximumDistance) {
continue;
}
bottomPermanents[0].pfRelatedPrioritizable = pathfinder_PermanentPrioritizable.create(newPriority,bottomPermanents[0]);
this.pathQueue.enqueue(bottomPermanents[0].pfRelatedPrioritizable);
bottomPermanents[0].pfSeen = this.pfSeenStart;
}
}
var maxNiceNess = -10000.0;
var bestPermanent = null;
var landingSiteGroups = this.city.connections.landingSiteGroups;
var teleportersDone = false;
var _g = [];
var _g1 = 0;
while(_g1 < landingSiteGroups.length) {
var i = landingSiteGroups[_g1];
++_g1;
_g.push(false);
}
var landingSitesDone = _g;
var privateTeleporter = null;
if(citizen != null && citizen.home != null) {
privateTeleporter = citizen.home.get_hasPrivateTeleporter() ? citizen.home : null;
}
while(this.pathQueue.mSize != 0) {
var currentQueueItem = this.pathQueue.dequeue();
var currentPermanent = currentQueueItem.permanent;
currentPermanent.pfSeen = this.pfSeenStart + 1;
if(isGoal(currentPermanent)) {
if(goalNiceness != null) {
var thisNiceness = goalNiceness(currentPermanent);
if(thisNiceness >= bestExpectedGoalNiceness) {
bestPermanent = currentPermanent;
break;
}
if(thisNiceness > maxNiceNess) {
bestPermanent = currentPermanent;
maxNiceNess = thisNiceness;
}
} else {
while(this.pathQueue.mSize != 0) this.pathQueue.dequeue().destroy();
bestPermanent = currentPermanent;
break;
}
}
if(currentPermanent.isBuilding) {
var currentBuilding = currentPermanent;
var permanentTo = currentBuilding.leftBuilding;
if(permanentTo != null) {
if(permanentTo.pfSeen == _gthis.pfSeenStart) {
var relatedPrioritizable = permanentTo.pfRelatedPrioritizable;
var newPriority = currentQueueItem.priority + 20;
if(newPriority < relatedPrioritizable.priority) {
_gthis.pathQueue.reprioritize(relatedPrioritizable,newPriority);
}
} else if(permanentTo.pfSeen != _gthis.pfSeenStart + 1) {
var newPriority1 = currentQueueItem.priority + 20;
if(maximumDistance == -1 || newPriority1 <= maximumDistance) {
permanentTo.pfSeen = _gthis.pfSeenStart;
permanentTo.pfRelatedPrioritizable = pathfinder_PermanentPrioritizable.create(newPriority1,permanentTo);
_gthis.pathQueue.enqueue(permanentTo.pfRelatedPrioritizable);
}
}
}
var permanentTo1 = currentBuilding.rightBuilding;
if(permanentTo1 != null) {
if(permanentTo1.pfSeen == _gthis.pfSeenStart) {
var relatedPrioritizable1 = permanentTo1.pfRelatedPrioritizable;
var newPriority2 = currentQueueItem.priority + 20;
if(newPriority2 < relatedPrioritizable1.priority) {
_gthis.pathQueue.reprioritize(relatedPrioritizable1,newPriority2);
}
} else if(permanentTo1.pfSeen != _gthis.pfSeenStart + 1) {
var newPriority3 = currentQueueItem.priority + 20;
if(maximumDistance == -1 || newPriority3 <= maximumDistance) {
permanentTo1.pfSeen = _gthis.pfSeenStart;
permanentTo1.pfRelatedPrioritizable = pathfinder_PermanentPrioritizable.create(newPriority3,permanentTo1);
_gthis.pathQueue.enqueue(permanentTo1.pfRelatedPrioritizable);
}
}
}
var permanentTo2 = currentBuilding.topBuilding;
if(permanentTo2 != null) {
if(permanentTo2.pfSeen == _gthis.pfSeenStart) {
var relatedPrioritizable2 = permanentTo2.pfRelatedPrioritizable;
var newPriority4 = currentQueueItem.priority + 20;
if(newPriority4 < relatedPrioritizable2.priority) {
_gthis.pathQueue.reprioritize(relatedPrioritizable2,newPriority4);
}
} else if(permanentTo2.pfSeen != _gthis.pfSeenStart + 1) {
var newPriority5 = currentQueueItem.priority + 20;
if(maximumDistance == -1 || newPriority5 <= maximumDistance) {
permanentTo2.pfSeen = _gthis.pfSeenStart;
permanentTo2.pfRelatedPrioritizable = pathfinder_PermanentPrioritizable.create(newPriority5,permanentTo2);
_gthis.pathQueue.enqueue(permanentTo2.pfRelatedPrioritizable);
}
}
}
var permanentTo3 = currentBuilding.bottomBuilding;
if(permanentTo3 != null) {
if(permanentTo3.pfSeen == _gthis.pfSeenStart) {
var relatedPrioritizable3 = permanentTo3.pfRelatedPrioritizable;
var newPriority6 = currentQueueItem.priority + 20;
if(newPriority6 < relatedPrioritizable3.priority) {
_gthis.pathQueue.reprioritize(relatedPrioritizable3,newPriority6);
}
} else if(permanentTo3.pfSeen != _gthis.pfSeenStart + 1) {
var newPriority7 = currentQueueItem.priority + 20;
if(maximumDistance == -1 || newPriority7 <= maximumDistance) {
permanentTo3.pfSeen = _gthis.pfSeenStart;
permanentTo3.pfRelatedPrioritizable = pathfinder_PermanentPrioritizable.create(newPriority7,permanentTo3);
_gthis.pathQueue.enqueue(permanentTo3.pfRelatedPrioritizable);
}
}
}
var isPrivateTeleporter = privateTeleporter == currentPermanent;
var canTeleportFromHere = currentPermanent.is(buildings_Teleporter) || isPrivateTeleporter;
if(!teleportersDone && canTeleportFromHere) {
var rnd = random_Random.getFloat(2);
var tp = 0;
var len = this.city.teleporters.length;
var invlen = 2 / len;
var _g = 0;
var _g1 = len;
while(_g < _g1) {
var tp1 = _g++;
var teleporter = this.city.teleporters[tp1];
var priorityAdd = 9 + (rnd + tp1 * invlen) % 2.0;
if(teleporter != null) {
if(teleporter.pfSeen == _gthis.pfSeenStart) {
var relatedPrioritizable4 = teleporter.pfRelatedPrioritizable;
var newPriority8 = currentQueueItem.priority + priorityAdd;
if(newPriority8 < relatedPrioritizable4.priority) {
_gthis.pathQueue.reprioritize(relatedPrioritizable4,newPriority8);
}
} else if(teleporter.pfSeen != _gthis.pfSeenStart + 1) {
var newPriority9 = currentQueueItem.priority + priorityAdd;
if(maximumDistance == -1 || newPriority9 <= maximumDistance) {
teleporter.pfSeen = _gthis.pfSeenStart;
teleporter.pfRelatedPrioritizable = pathfinder_PermanentPrioritizable.create(newPriority9,teleporter);
_gthis.pathQueue.enqueue(teleporter.pfRelatedPrioritizable);
}
}
}
}
if(!isPrivateTeleporter && privateTeleporter != null) {
if(privateTeleporter != null) {
if(privateTeleporter.pfSeen == _gthis.pfSeenStart) {
var relatedPrioritizable5 = privateTeleporter.pfRelatedPrioritizable;
var newPriority10 = currentQueueItem.priority + 10;
if(newPriority10 < relatedPrioritizable5.priority) {
_gthis.pathQueue.reprioritize(relatedPrioritizable5,newPriority10);
}
} else if(privateTeleporter.pfSeen != _gthis.pfSeenStart + 1) {
var newPriority11 = currentQueueItem.priority + 10;
if(maximumDistance == -1 || newPriority11 <= maximumDistance) {
privateTeleporter.pfSeen = _gthis.pfSeenStart;
privateTeleporter.pfRelatedPrioritizable = pathfinder_PermanentPrioritizable.create(newPriority11,privateTeleporter);
_gthis.pathQueue.enqueue(privateTeleporter.pfRelatedPrioritizable);
}
}
}
}
teleportersDone = true;
} else if(currentPermanent.is(buildings_LandingSite) && !landingSitesDone[currentPermanent.landingSiteGroup]) {
var thisGroup = currentPermanent.landingSiteGroup;
var _g2 = 0;
var _g3 = this.city.connections.landingSiteGroups[thisGroup];
while(_g2 < _g3.length) {
var landingSite = _g3[_g2];
++_g2;
var priorityAdd1 = landingSite.estimatedFlyingDistanceTo(currentPermanent);
if(landingSite != null) {
if(landingSite.pfSeen == _gthis.pfSeenStart) {
var relatedPrioritizable6 = landingSite.pfRelatedPrioritizable;
var newPriority12 = currentQueueItem.priority + priorityAdd1;
if(newPriority12 < relatedPrioritizable6.priority) {
_gthis.pathQueue.reprioritize(relatedPrioritizable6,newPriority12);
}
} else if(landingSite.pfSeen != _gthis.pfSeenStart + 1) {
var newPriority13 = currentQueueItem.priority + priorityAdd1;
if(maximumDistance == -1 || newPriority13 <= maximumDistance) {
landingSite.pfSeen = _gthis.pfSeenStart;
landingSite.pfRelatedPrioritizable = pathfinder_PermanentPrioritizable.create(newPriority13,landingSite);
_gthis.pathQueue.enqueue(landingSite.pfRelatedPrioritizable);
}
}
}
}
landingSitesDone[thisGroup] = true;
} else if(!currentQueueItem.dontCheckElevators && currentPermanent.is(buildings_HyperElevator) && currentPermanent.pfSeen != 3) {
var _g4 = 0;
var _g5 = this.city.connections.elevatorConnections.h[currentBuilding.world.__id__][currentBuilding.worldPosition.x];
while(_g4 < _g5.length) {
var elevator = _g5[_g4];
++_g4;
var priorityAdd2 = Math.abs(elevator.worldPosition.y - currentBuilding.worldPosition.y);
if(elevator != null) {
if(elevator.pfSeen == _gthis.pfSeenStart) {
var relatedPrioritizable7 = elevator.pfRelatedPrioritizable;
var newPriority14 = currentQueueItem.priority + priorityAdd2;
if(newPriority14 < relatedPrioritizable7.priority) {
_gthis.pathQueue.reprioritize(relatedPrioritizable7,newPriority14);
}
} else if(elevator.pfSeen != _gthis.pfSeenStart + 1) {
var newPriority15 = currentQueueItem.priority + priorityAdd2;
if(maximumDistance == -1 || newPriority15 <= maximumDistance) {
elevator.pfSeen = _gthis.pfSeenStart;
elevator.pfRelatedPrioritizable = pathfinder_PermanentPrioritizable.create(newPriority15,elevator);
_gthis.pathQueue.enqueue(elevator.pfRelatedPrioritizable);
}
}
}
if(elevator.pfRelatedPrioritizable != null) {
elevator.pfRelatedPrioritizable.dontCheckElevators = true;
}
}
}
}
if(currentPermanent.worldPosition.y == 0) {
var _g6 = 0;
var _g7 = currentPermanent.world.permanents;
while(_g6 < _g7.length) {
var bottomPermanents = _g7[_g6];
++_g6;
if(bottomPermanents.length == 0 || bottomPermanents[0] == null) {
continue;
}
var permanentTo4 = bottomPermanents[0];
var priorityAdd3 = Math.abs(bottomPermanents[0].position.x - currentPermanent.position.x);
if(permanentTo4 != null) {
if(permanentTo4.pfSeen == _gthis.pfSeenStart) {
var relatedPrioritizable8 = permanentTo4.pfRelatedPrioritizable;
var newPriority16 = currentQueueItem.priority + priorityAdd3;
if(newPriority16 < relatedPrioritizable8.priority) {
_gthis.pathQueue.reprioritize(relatedPrioritizable8,newPriority16);
}
} else if(permanentTo4.pfSeen != _gthis.pfSeenStart + 1) {
var newPriority17 = currentQueueItem.priority + priorityAdd3;
if(maximumDistance == -1 || newPriority17 <= maximumDistance) {
permanentTo4.pfSeen = _gthis.pfSeenStart;
permanentTo4.pfRelatedPrioritizable = pathfinder_PermanentPrioritizable.create(newPriority17,permanentTo4);
_gthis.pathQueue.enqueue(permanentTo4.pfRelatedPrioritizable);
}
}
}
}
}
currentQueueItem.destroy();
}
return bestPermanent;
}
,queryForCitizen: function(citizen,isGoal,goalNiceness,maximumDistance,isQuickQuery) {
if(isQuickQuery == null) {
isQuickQuery = false;
}
if(maximumDistance == null) {
maximumDistance = -1;
}
if(citizen.inPermanent != null) {
return this.query(citizen.inPermanent,isGoal,goalNiceness,null,0,maximumDistance,isQuickQuery ? null : citizen);
} else {
return this.query(null,isGoal,goalNiceness,citizen.onWorld,citizen.relativeX,maximumDistance,isQuickQuery ? null : citizen);
}
}
,quickQueryForCitizen: function(citizen,isGoal,queryKey,expiryHours,goalNiceness,maximumDistance) {
if(maximumDistance == null) {
maximumDistance = -1;
}
var time = this.city.simulation.time.timeSinceStart;
var xInd;
var yInd;
if(citizen.inPermanent != null) {
xInd = citizen.inPermanent.worldPosition.x;
yInd = citizen.inPermanent.worldPosition.y / 5 | 0;
} else {
xInd = (citizen.relativeX | 0) / 20 | 0;
yInd = 0;
}
var key = citizen.onWorld.rect.x + ";" + citizen.onWorld.rect.y + ";" + xInd + ";" + yInd + queryKey;
var savedResult = this.savedResults.h[key];
var permanentToReturn = null;
if(savedResult != null) {
if(time < savedResult.expiry) {
permanentToReturn = savedResult.permanent;
} else if(savedResult.permanent != null && isGoal(savedResult.permanent)) {
savedResult.expiry += expiryHours * 60;
permanentToReturn = savedResult.permanent;
}
}
if(permanentToReturn == null) {
var foundPermanent = this.queryForCitizen(citizen,isGoal,goalNiceness,maximumDistance,true);
var v = { permanent : foundPermanent, expiry : time + expiryHours * 60};
this.savedResults.h[key] = v;
permanentToReturn = foundPermanent;
}
return permanentToReturn;
}
,invalidatePathfindingRelatedInfo: function() {
this.savedResults = new haxe_ds_StringMap();
}
,__class__: pathfinder_PermanentFinder
};
var pathfinder_PermanentPrioritizable = function() {
this.dontCheckElevators = false;
};
$hxClasses["pathfinder.PermanentPrioritizable"] = pathfinder_PermanentPrioritizable;
pathfinder_PermanentPrioritizable.__name__ = "pathfinder.PermanentPrioritizable";
pathfinder_PermanentPrioritizable.__interfaces__ = [polygonal_ds_Prioritizable];
pathfinder_PermanentPrioritizable.create = function(priority,permanent) {
var inst = pathfinder_PermanentPrioritizable.pool.length == 0 ? new pathfinder_PermanentPrioritizable() : pathfinder_PermanentPrioritizable.pool.pop();
inst.___internal_pooling_initObject(priority,permanent);
return inst;
};
pathfinder_PermanentPrioritizable.prototype = {
___internal_pooling_initObject: function(priority,permanent) {
this.priority = priority;
this.permanent = permanent;
}
,destroy: function() {
pathfinder_PermanentPrioritizable.pool.push(this);
}
,__class__: pathfinder_PermanentPrioritizable
};
var policies_Policy = function() {
var c = js_Boot.getClass(this);
var className = c.__name__;
this.info = Lambda.find(Resources.cityUpgradesInfo,function(i) {
return "policies." + i.className == className;
});
};
$hxClasses["policies.Policy"] = policies_Policy;
policies_Policy.__name__ = "policies.Policy";
policies_Policy.__interfaces__ = [ICreatableCityElement];
policies_Policy.prototype = {
addToCity: function(city) {
this.city = city;
}
,destroy: function() {
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
if(shouldSaveDefinition) {
queue.addString(policies_Policy.saveDefinition);
}
}
,load: function(queue,definition) {
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
}
,__class__: policies_Policy
};
var policies_FoodRationing = function() {
policies_Policy.call(this);
};
$hxClasses["policies.FoodRationing"] = policies_FoodRationing;
policies_FoodRationing.__name__ = "policies.FoodRationing";
policies_FoodRationing.__super__ = policies_Policy;
policies_FoodRationing.prototype = $extend(policies_Policy.prototype,{
addToCity: function(city) {
this.city = city;
this.city.simulation.eating.foodRationing = true;
}
,destroy: function() {
this.city.simulation.eating.foodRationing = false;
}
,__class__: policies_FoodRationing
});
var policies_MandatoryOvertime = function() {
policies_Policy.call(this);
};
$hxClasses["policies.MandatoryOvertime"] = policies_MandatoryOvertime;
policies_MandatoryOvertime.__name__ = "policies.MandatoryOvertime";
policies_MandatoryOvertime.__super__ = policies_Policy;
policies_MandatoryOvertime.prototype = $extend(policies_Policy.prototype,{
addToCity: function(city) {
this.city = city;
city.policies.vars.workTimeChange = 2;
}
,destroy: function() {
this.city.policies.vars.workTimeChange = 0;
}
,__class__: policies_MandatoryOvertime
});
var policies_Policies = function(city) {
this.city = city;
this.policies = [];
this.vars = new policies_PolicyVars();
};
$hxClasses["policies.Policies"] = policies_Policies;
policies_Policies.__name__ = "policies.Policies";
policies_Policies.prototype = {
addPolicy: function(policy) {
this.policies.push(policy);
policy.addToCity(this.city);
}
,removePolicy: function(policy) {
HxOverrides.remove(this.policies,policy);
policy.destroy();
}
,save: function(queue) {
var value = this.policies.length;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var _g = 0;
var _g1 = this.policies;
while(_g < _g1.length) {
var policy = _g1[_g];
++_g;
var c = js_Boot.getClass(policy);
queue.addString(c.__name__);
policy.save(queue);
}
}
,load: function(queue) {
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var len = intToRead;
var _g = 0;
var _g1 = len;
while(_g < _g1) {
var i = _g++;
var name = queue.readString();
var poli = Type.createInstance($hxClasses[name],[]);
poli.load(queue);
this.addPolicy(poli);
}
}
,__class__: policies_Policies
};
var policies_PolicyVars = function() {
this.workTimeChange = 0;
this.schoolMaxEdu = 1;
this.schoolClassSizeMod = 1;
};
$hxClasses["policies.PolicyVars"] = policies_PolicyVars;
policies_PolicyVars.__name__ = "policies.PolicyVars";
policies_PolicyVars.prototype = {
__class__: policies_PolicyVars
};
var policies_SmallerClasses = function() {
policies_Policy.call(this);
};
$hxClasses["policies.SmallerClasses"] = policies_SmallerClasses;
policies_SmallerClasses.__name__ = "policies.SmallerClasses";
policies_SmallerClasses.__super__ = policies_Policy;
policies_SmallerClasses.prototype = $extend(policies_Policy.prototype,{
addToCity: function(city) {
this.city = city;
city.policies.vars.schoolClassSizeMod = 0.6666667;
city.simulation.schoolAssigner.schoolsShouldBeUpdated = true;
city.policies.vars.schoolMaxEdu = 1.15;
var _g = 0;
var _g1 = city.permanents;
while(_g < _g1.length) {
var pm = _g1[_g];
++_g;
if(pm.is(buildings_School)) {
var pmSchool = pm;
while(pmSchool.students.length > pmSchool.get_studentCapacity()) pmSchool.students[pmSchool.students.length - 1].leaveSchool();
}
}
}
,destroy: function() {
this.city.policies.vars.schoolClassSizeMod = 1;
this.city.simulation.schoolAssigner.schoolsShouldBeUpdated = true;
this.city.policies.vars.schoolMaxEdu = 1;
}
,__class__: policies_SmallerClasses
});
var polygonal_ds_Hashable = function() { };
$hxClasses["polygonal.ds.Hashable"] = polygonal_ds_Hashable;
polygonal_ds_Hashable.__name__ = "polygonal.ds.Hashable";
polygonal_ds_Hashable.__isInterface__ = true;
var polygonal_ds_Collection = function() { };
$hxClasses["polygonal.ds.Collection"] = polygonal_ds_Collection;
polygonal_ds_Collection.__name__ = "polygonal.ds.Collection";
polygonal_ds_Collection.__isInterface__ = true;
polygonal_ds_Collection.__interfaces__ = [polygonal_ds_Hashable];
var polygonal_ds_Queue = function() { };
$hxClasses["polygonal.ds.Queue"] = polygonal_ds_Queue;
polygonal_ds_Queue.__name__ = "polygonal.ds.Queue";
polygonal_ds_Queue.__isInterface__ = true;
polygonal_ds_Queue.__interfaces__ = [polygonal_ds_Collection];
var polygonal_ds_ArrayedQueue = function(initialCapacity,source,fixed) {
if(initialCapacity == null) {
initialCapacity = 16;
}
this.mIterator = null;
this.mFront = 0;
this.mSize = 0;
this.reuseIterator = false;
this.growthRate = -2;
this.mInitialCapacity = 1 > initialCapacity ? 1 : initialCapacity;
this.capacity = this.mInitialCapacity;
if(source != null) {
this.mSize = source.length;
var x = this.mSize;
var y = this.capacity;
this.capacity = x > y ? x : y;
}
this.mData = new Array(this.capacity);
if(source != null) {
var d = this.mData;
var _g = 0;
var _g1 = this.mSize;
while(_g < _g1) {
var i = _g++;
d[i] = source[i];
}
}
if(fixed) {
this.growthRate = 0;
}
};
$hxClasses["polygonal.ds.ArrayedQueue"] = polygonal_ds_ArrayedQueue;
polygonal_ds_ArrayedQueue.__name__ = "polygonal.ds.ArrayedQueue";
polygonal_ds_ArrayedQueue.__interfaces__ = [polygonal_ds_Queue];
polygonal_ds_ArrayedQueue.prototype = {
clear: function(gc) {
if(gc == null) {
gc = false;
}
if(gc) {
polygonal_ds_tools_NativeArrayTools.nullify(this.mData);
}
this.mFront = this.mSize = 0;
}
,iterator: function() {
if(this.reuseIterator) {
if(this.mIterator == null) {
this.mIterator = new polygonal_ds_ArrayedQueueIterator(this);
} else {
this.mIterator.reset();
}
return this.mIterator;
} else {
return new polygonal_ds_ArrayedQueueIterator(this);
}
}
,grow: function() {
var t = this.capacity;
this.capacity = polygonal_ds_tools_GrowthRate.compute(this.growthRate,this.capacity);
this.resizeContainer(t,this.capacity);
}
,resizeContainer: function(oldSize,newSize) {
var dst = new Array(newSize);
if(oldSize < newSize) {
if(this.mFront + this.mSize > oldSize) {
var n1 = oldSize - this.mFront;
var n2 = oldSize - n1;
polygonal_ds_tools_NativeArrayTools.blit(this.mData,this.mFront,dst,0,n1);
polygonal_ds_tools_NativeArrayTools.blit(this.mData,0,dst,n1,n2);
} else {
polygonal_ds_tools_NativeArrayTools.blit(this.mData,this.mFront,dst,0,this.mSize);
}
} else if(this.mFront + this.mSize > oldSize) {
var n1 = oldSize - this.mFront;
var n2 = this.mSize - this.mFront;
polygonal_ds_tools_NativeArrayTools.blit(this.mData,this.mFront,dst,0,n1);
polygonal_ds_tools_NativeArrayTools.blit(this.mData,0,dst,this.mFront,n2);
} else {
polygonal_ds_tools_NativeArrayTools.blit(this.mData,this.mFront,dst,0,this.mSize);
}
this.mData = dst;
this.mFront = 0;
}
,__class__: polygonal_ds_ArrayedQueue
};
var polygonal_ds_Itr = function() { };
$hxClasses["polygonal.ds.Itr"] = polygonal_ds_Itr;
polygonal_ds_Itr.__name__ = "polygonal.ds.Itr";
polygonal_ds_Itr.__isInterface__ = true;
polygonal_ds_Itr.prototype = {
__class__: polygonal_ds_Itr
};
var polygonal_ds_ArrayedQueueIterator = function(x) {
this.mObject = x;
this.reset();
};
$hxClasses["polygonal.ds.ArrayedQueueIterator"] = polygonal_ds_ArrayedQueueIterator;
polygonal_ds_ArrayedQueueIterator.__name__ = "polygonal.ds.ArrayedQueueIterator";
polygonal_ds_ArrayedQueueIterator.__interfaces__ = [polygonal_ds_Itr];
polygonal_ds_ArrayedQueueIterator.prototype = {
reset: function() {
this.mFront = this.mObject.mFront;
this.mCapacity = this.mObject.capacity;
this.mSize = this.mObject.mSize;
this.mI = 0;
this.mData = this.mObject.mData.slice();
return this;
}
,hasNext: function() {
return this.mI < this.mSize;
}
,next: function() {
return this.mData[(this.mI++ + this.mFront) % this.mCapacity];
}
,__class__: polygonal_ds_ArrayedQueueIterator
};
var polygonal_ds_PriorityQueue = function(initalCapacity,inverse,source) {
if(inverse == null) {
inverse = false;
}
if(initalCapacity == null) {
initalCapacity = 1;
}
this.mSize = 0;
this.growthRate = -2;
this.mInitialCapacity = 1 > initalCapacity ? 1 : initalCapacity;
this.capacity = initalCapacity;
this.mInverse = inverse;
if(source != null) {
this.mSize = source.length;
var x = this.mSize;
var y = this.capacity;
this.capacity = x > y ? x : y;
}
this.mData = new Array(this.capacity + 1);
this.mData[0] = null;
if(source != null) {
var d = this.mData;
var _g = 1;
var _g1 = this.mSize + 1;
while(_g < _g1) {
var i = _g++;
d[i] = source[i - 1];
}
this.repair();
}
};
$hxClasses["polygonal.ds.PriorityQueue"] = polygonal_ds_PriorityQueue;
polygonal_ds_PriorityQueue.__name__ = "polygonal.ds.PriorityQueue";
polygonal_ds_PriorityQueue.__interfaces__ = [polygonal_ds_Queue];
polygonal_ds_PriorityQueue.prototype = {
enqueue: function(val) {
if(this.mSize == this.capacity) {
this.grow();
}
this.mData[++this.mSize] = val;
val.position = this.mSize;
var index = this.mSize;
var d = this.mData;
var parent = index >> 1;
var t = d[index];
var p = t.priority;
if(this.mInverse) {
while(parent > 0) {
var parentVal = d[parent];
if(p - parentVal.priority < 0) {
d[index] = parentVal;
parentVal.position = index;
index = parent;
parent >>= 1;
} else {
break;
}
}
} else {
while(parent > 0) {
var parentVal = d[parent];
if(p - parentVal.priority > 0) {
d[index] = parentVal;
parentVal.position = index;
index = parent;
parent >>= 1;
} else {
break;
}
}
}
d[index] = t;
t.position = index;
}
,dequeue: function() {
var d = this.mData;
var x = d[1];
x.position = -1;
d[1] = d[this.mSize];
var index = 1;
var d = this.mData;
var child = index << 1;
var childVal;
var t = d[index];
var p = t.priority;
if(this.mInverse) {
while(child < this.mSize) {
if(child < this.mSize - 1) {
if(d[child].priority - d[child + 1].priority > 0) {
++child;
}
}
childVal = d[child];
if(p - childVal.priority > 0) {
d[index] = childVal;
childVal.position = index;
t.position = child;
index = child;
child <<= 1;
} else {
break;
}
}
} else {
while(child < this.mSize) {
if(child < this.mSize - 1) {
if(d[child].priority - d[child + 1].priority < 0) {
++child;
}
}
childVal = d[child];
if(p - childVal.priority < 0) {
d[index] = childVal;
childVal.position = index;
t.position = child;
index = child;
child <<= 1;
} else {
break;
}
}
}
d[index] = t;
t.position = index;
this.mSize--;
return x;
}
,reprioritize: function(val,priority) {
var oldPriority = val.priority;
if(oldPriority == priority) {
return this;
}
val.priority = priority;
var pos = val.position;
if(this.mInverse) {
if(priority < oldPriority) {
var index = pos;
var d = this.mData;
var parent = index >> 1;
var t = d[index];
var p = t.priority;
if(this.mInverse) {
while(parent > 0) {
var parentVal = d[parent];
if(p - parentVal.priority < 0) {
d[index] = parentVal;
parentVal.position = index;
index = parent;
parent >>= 1;
} else {
break;
}
}
} else {
while(parent > 0) {
var parentVal = d[parent];
if(p - parentVal.priority > 0) {
d[index] = parentVal;
parentVal.position = index;
index = parent;
parent >>= 1;
} else {
break;
}
}
}
d[index] = t;
t.position = index;
} else {
var index = pos;
var d = this.mData;
var child = index << 1;
var childVal;
var t = d[index];
var p = t.priority;
if(this.mInverse) {
while(child < this.mSize) {
if(child < this.mSize - 1) {
if(d[child].priority - d[child + 1].priority > 0) {
++child;
}
}
childVal = d[child];
if(p - childVal.priority > 0) {
d[index] = childVal;
childVal.position = index;
t.position = child;
index = child;
child <<= 1;
} else {
break;
}
}
} else {
while(child < this.mSize) {
if(child < this.mSize - 1) {
if(d[child].priority - d[child + 1].priority < 0) {
++child;
}
}
childVal = d[child];
if(p - childVal.priority < 0) {
d[index] = childVal;
childVal.position = index;
t.position = child;
index = child;
child <<= 1;
} else {
break;
}
}
}
d[index] = t;
t.position = index;
var index = this.mSize;
var d = this.mData;
var parent = index >> 1;
var t = d[index];
var p = t.priority;
if(this.mInverse) {
while(parent > 0) {
var parentVal = d[parent];
if(p - parentVal.priority < 0) {
d[index] = parentVal;
parentVal.position = index;
index = parent;
parent >>= 1;
} else {
break;
}
}
} else {
while(parent > 0) {
var parentVal = d[parent];
if(p - parentVal.priority > 0) {
d[index] = parentVal;
parentVal.position = index;
index = parent;
parent >>= 1;
} else {
break;
}
}
}
d[index] = t;
t.position = index;
}
} else if(priority > oldPriority) {
var index = pos;
var d = this.mData;
var parent = index >> 1;
var t = d[index];
var p = t.priority;
if(this.mInverse) {
while(parent > 0) {
var parentVal = d[parent];
if(p - parentVal.priority < 0) {
d[index] = parentVal;
parentVal.position = index;
index = parent;
parent >>= 1;
} else {
break;
}
}
} else {
while(parent > 0) {
var parentVal = d[parent];
if(p - parentVal.priority > 0) {
d[index] = parentVal;
parentVal.position = index;
index = parent;
parent >>= 1;
} else {
break;
}
}
}
d[index] = t;
t.position = index;
} else {
var index = pos;
var d = this.mData;
var child = index << 1;
var childVal;
var t = d[index];
var p = t.priority;
if(this.mInverse) {
while(child < this.mSize) {
if(child < this.mSize - 1) {
if(d[child].priority - d[child + 1].priority > 0) {
++child;
}
}
childVal = d[child];
if(p - childVal.priority > 0) {
d[index] = childVal;
childVal.position = index;
t.position = child;
index = child;
child <<= 1;
} else {
break;
}
}
} else {
while(child < this.mSize) {
if(child < this.mSize - 1) {
if(d[child].priority - d[child + 1].priority < 0) {
++child;
}
}
childVal = d[child];
if(p - childVal.priority < 0) {
d[index] = childVal;
childVal.position = index;
t.position = child;
index = child;
child <<= 1;
} else {
break;
}
}
}
d[index] = t;
t.position = index;
var index = this.mSize;
var d = this.mData;
var parent = index >> 1;
var t = d[index];
var p = t.priority;
if(this.mInverse) {
while(parent > 0) {
var parentVal = d[parent];
if(p - parentVal.priority < 0) {
d[index] = parentVal;
parentVal.position = index;
index = parent;
parent >>= 1;
} else {
break;
}
}
} else {
while(parent > 0) {
var parentVal = d[parent];
if(p - parentVal.priority > 0) {
d[index] = parentVal;
parentVal.position = index;
index = parent;
parent >>= 1;
} else {
break;
}
}
}
d[index] = t;
t.position = index;
}
return this;
}
,repair: function() {
var i = this.mSize >> 1;
while(i >= 1) {
this.heapify(i,this.mSize);
--i;
}
}
,heapify: function(p,s) {
var d = this.mData;
var l = p << 1;
var r = l + 1;
var max = p;
if(this.mInverse) {
if(l <= s && d[l].priority - d[max].priority < 0) {
max = l;
}
if(l + 1 <= s && d[l + 1].priority - d[max].priority < 0) {
max = r;
}
} else {
if(l <= s && d[l].priority - d[max].priority > 0) {
max = l;
}
if(l + 1 <= s && d[l + 1].priority - d[max].priority > 0) {
max = r;
}
}
var a;
var b;
var t;
if(max != p) {
a = d[max];
b = d[p];
d[max] = b;
d[p] = a;
t = a.position;
a.position = b.position;
b.position = t;
this.heapify(max,s);
}
}
,grow: function() {
this.capacity = polygonal_ds_tools_GrowthRate.compute(this.growthRate,this.capacity);
this.resizeContainer(this.capacity);
}
,resizeContainer: function(newSize) {
var t = new Array(newSize + 1);
polygonal_ds_tools_NativeArrayTools.blit(this.mData,0,t,0,this.mSize + 1);
this.mData = t;
}
,__class__: polygonal_ds_PriorityQueue
};
var polygonal_ds_tools_GrowthRate = function() { };
$hxClasses["polygonal.ds.tools.GrowthRate"] = polygonal_ds_tools_GrowthRate;
polygonal_ds_tools_GrowthRate.__name__ = "polygonal.ds.tools.GrowthRate";
polygonal_ds_tools_GrowthRate.compute = function(rate,capacity) {
if(rate > 0) {
capacity += rate;
} else {
switch(rate) {
case -3:
capacity <<= 1;
break;
case -2:
capacity = (capacity * 3 >> 1) + 1;
break;
case -1:
var newSize = capacity + 1;
capacity = (newSize >> 3) + (newSize < 9 ? 3 : 6);
capacity += newSize;
break;
case 0:
throw haxe_Exception.thrown("out of space");
}
}
return capacity;
};
var polygonal_ds_tools_NativeArrayTools = function() { };
$hxClasses["polygonal.ds.tools.NativeArrayTools"] = polygonal_ds_tools_NativeArrayTools;
polygonal_ds_tools_NativeArrayTools.__name__ = "polygonal.ds.tools.NativeArrayTools";
polygonal_ds_tools_NativeArrayTools.blit = function(src,srcPos,dst,dstPos,n) {
if(n > 0) {
if(src == dst) {
if(srcPos < dstPos) {
var i = srcPos + n;
var j = dstPos + n;
var _g = 0;
var _g1 = n;
while(_g < _g1) {
var k = _g++;
--i;
--j;
src[j] = src[i];
}
} else if(srcPos > dstPos) {
var i = srcPos;
var j = dstPos;
var _g = 0;
var _g1 = n;
while(_g < _g1) {
var k = _g++;
src[j] = src[i];
++i;
++j;
}
}
} else if(srcPos == 0 && dstPos == 0) {
var _g = 0;
var _g1 = n;
while(_g < _g1) {
var i = _g++;
dst[i] = src[i];
}
} else if(srcPos == 0) {
var _g = 0;
var _g1 = n;
while(_g < _g1) {
var i = _g++;
dst[dstPos + i] = src[i];
}
} else if(dstPos == 0) {
var _g = 0;
var _g1 = n;
while(_g < _g1) {
var i = _g++;
dst[i] = src[srcPos + i];
}
} else {
var _g = 0;
var _g1 = n;
while(_g < _g1) {
var i = _g++;
dst[dstPos + i] = src[srcPos + i];
}
}
}
};
polygonal_ds_tools_NativeArrayTools.nullify = function(a,first,n) {
if(n == null) {
n = 0;
}
if(first == null) {
first = 0;
}
var min = first;
var max = n <= 0 ? a.length : min + n;
while(min < max) a[min++] = null;
return a;
};
var pooling_Int32ArrayPool = function() { };
$hxClasses["pooling.Int32ArrayPool"] = pooling_Int32ArrayPool;
pooling_Int32ArrayPool.__name__ = "pooling.Int32ArrayPool";
pooling_Int32ArrayPool.returnToPool = function(arr) {
if(arr.length < 20 && pooling_Int32ArrayPool.pool[arr.length].length < 10000) {
pooling_Int32ArrayPool.pool[arr.length].push(arr);
}
};
var pooling_PooledSprite = {};
pooling_PooledSprite.create = function(texture,stage) {
if(pooling_PooledSprite.pool.h[stage.__id__] == null) {
var v = [];
pooling_PooledSprite.pool.set(stage,v);
}
var spr;
if(pooling_PooledSprite.pool.h[stage.__id__].length == 0) {
var this1 = new PIXI.Sprite();
spr = this1;
stage.addChild(spr);
} else {
spr = pooling_PooledSprite.pool.h[stage.__id__].pop();
}
spr.texture = texture;
spr.visible = true;
return spr;
};
var progress_BuildingCost = function(city) {
this.city = city;
};
$hxClasses["progress.BuildingCost"] = progress_BuildingCost;
progress_BuildingCost.__name__ = "progress.BuildingCost";
progress_BuildingCost.prototype = {
getBuildingCost: function(buildingInfo) {
if(buildingInfo.className == "NormalHouse" && this.city.progress.story.storyName == "theLostShip" && this.city.progress.story.currentGoal != null && this.city.progress.story.currentGoal.name == "BuildIndoorFarmAndHouse" && (this.city.getAmountOfPermanentsPerType().h["buildings.NormalHouse"] == null || this.city.getAmountOfPermanentsPerType().h["buildings.NormalHouse"] == 0)) {
return new Materials(2,2);
}
return Materials.fromBuildingInfo(buildingInfo);
}
,getBuildingCostDescriptionAdder: function(buildingInfo) {
if(buildingInfo.className == "NormalHouse" && this.city.progress.story.storyName == "theLostShip" && this.city.progress.story.currentGoal != null && this.city.progress.story.currentGoal.name == "BuildIndoorFarmAndHouse" && (this.city.getAmountOfPermanentsPerType().h["buildings.NormalHouse"] == null || this.city.getAmountOfPermanentsPerType().h["buildings.NormalHouse"] == 0)) {
return " The first house is cheaper as you can use some scrap material from your ship.";
}
return "";
}
,__class__: progress_BuildingCost
};
var progress_CityIntro = function(city) {
this.city = city;
city.enableDisplayOnly();
this.spaceShipSprite = new PIXI.Sprite(Resources.getTexture("spr_explorationship"));
};
$hxClasses["progress.CityIntro"] = progress_CityIntro;
progress_CityIntro.__name__ = "progress.CityIntro";
progress_CityIntro.prototype = {
update: function(timeMod) {
this.city.gui.stage.visible = false;
this.city.gui.windowStage.visible = false;
if(this.spaceShipSprite != null && this.spaceShipSprite.parent == null) {
this.city.cityMidStage.addChild(this.spaceShipSprite);
this.spaceShipSprite.position.set(this.city.viewPos.x,this.city.viewPos.y);
}
}
,handleMouse: function(mouse) {
this.spaceShipSprite.x = mouse.cityPosition.x;
if(mouse.pressed) {
this.city.disableDisplayOnlyMode(null);
this.city.gui.stage.visible = true;
this.city.gui.windowStage.visible = true;
this.city.progress.cityIntro = null;
}
return true;
}
,__class__: progress_CityIntro
};
var progress_CityResources = function() {
Resources.initializeCityResources(this);
};
$hxClasses["progress.CityResources"] = progress_CityResources;
progress_CityResources.__name__ = "progress.CityResources";
progress_CityResources.prototype = {
__class__: progress_CityResources
};
var progress_GameProgress = function(city,storyName) {
this.shownCtrlToHighlightHint = false;
this.city = city;
this.storyName = storyName;
this.goalHelp = new progress_GoalHelp(city);
this.sandbox = new progress_SandboxHelper(city);
this.buildingCost = new progress_BuildingCost(city);
};
$hxClasses["progress.GameProgress"] = progress_GameProgress;
progress_GameProgress.__name__ = "progress.GameProgress";
progress_GameProgress.prototype = {
init: function() {
this.resources = new progress_CityResources();
this.unlocks = new progress_Unlocks(this.city);
this.story = new progress_Story(this.city,this.storyName);
}
,handleMouse: function(mouse) {
if(this.cityIntro != null) {
return this.cityIntro.handleMouse(mouse);
}
return false;
}
,update: function(timeMod) {
this.story.update(timeMod);
this.unlocks.update(timeMod);
this.sandbox.update(timeMod);
if(this.cityIntro != null) {
this.cityIntro.update(timeMod);
}
}
,save: function(queue) {
this.story.save(queue);
this.unlocks.save(queue);
var value = this.shownCtrlToHighlightHint ? 1 : 0;
if(queue.size + 1 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 1) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.b[queue.size] = value;
queue.size += 1;
this.sandbox.save(queue);
}
,load: function(queue) {
this.story.load(queue);
this.unlocks.load(queue);
if(queue.version >= 13) {
var byteToRead = queue.bytes.b[queue.readStart];
queue.readStart += 1;
this.shownCtrlToHighlightHint = byteToRead == 1;
}
if(queue.version >= 25) {
this.sandbox.load(queue);
}
}
,shouldShowHoldCtrlToHighlightHint: function() {
if(this.city.simulation.citizens.length < 100 || this.city.game.isMobile) {
return false;
}
if(this.city.simulation.citizens.length > 200) {
return false;
}
return !this.shownCtrlToHighlightHint;
}
,resetCtrlToHightlightHint: function() {
if(this.city.simulation.citizens.length >= 100) {
this.shownCtrlToHighlightHint = true;
}
}
,__class__: progress_GameProgress
};
var progress_GenerateWorld = function() { };
$hxClasses["progress.GenerateWorld"] = progress_GenerateWorld;
progress_GenerateWorld.__name__ = "progress.GenerateWorld";
progress_GenerateWorld.doGenerate = function(generatorScript,generatorArgs,city,storyInfo,cityStage,cityMidStage,cityBgStage) {
if(generatorScript == "RandomMiniWorlds") {
progress_worldGenerators_RandomMiniWorlds.doGenerate(generatorArgs,city,storyInfo,cityStage,cityMidStage,cityBgStage);
}
};
var progress_GoalHelp = function(city) {
this.neverUpdatedBuildingGoal = true;
this.knowsHasBuildingGoalHelp = false;
this.city = city;
};
$hxClasses["progress.GoalHelp"] = progress_GoalHelp;
progress_GoalHelp.__name__ = "progress.GoalHelp";
progress_GoalHelp.prototype = {
getCurrentGoalHelp: function() {
var goalHelp = [];
if(this.city.progress.story != null && this.city.progress.story.currentGoal != null && this.city.progress.story.currentGoal.quickText != "") {
goalHelp.push({ category : "Main Goal", text : this.city.progress.story.currentGoal.quickText});
}
var currentBuildingGoalHelps = this.getCurrentBuildingGoalHelp();
var _g = 0;
while(_g < currentBuildingGoalHelps.length) {
var bg = currentBuildingGoalHelps[_g];
++_g;
goalHelp.push(bg);
}
return goalHelp;
}
,getCurrentBuildingGoalHelp: function() {
var goalHelp = [];
var _g = 0;
var _g1 = this.city.permanents;
while(_g < _g1.length) {
var pm = _g1[_g];
++_g;
if(pm.is(Building)) {
var bld = pm;
var buildingGlobalGoal = bld.getGlobalGoal();
if(buildingGlobalGoal != null) {
goalHelp.push(buildingGlobalGoal);
}
}
}
return goalHelp;
}
,updateHasBuildingGoal: function() {
this.knowsHasBuildingGoalHelp = this.getCurrentBuildingGoalHelp().length > 0;
}
,hasCurrentGoalHelp: function() {
if(this.city.progress.story != null && this.city.progress.story.currentGoal != null && this.city.progress.story.currentGoal.quickText != "") {
return true;
}
if(this.neverUpdatedBuildingGoal) {
this.updateHasBuildingGoal();
this.neverUpdatedBuildingGoal = false;
}
return this.knowsHasBuildingGoalHelp;
}
,__class__: progress_GoalHelp
};
var progress_MetaGame = function(onLoadComplete) {
this.unlockedAll = false;
var _gthis = this;
common_Storage.getItem("progressFile",function(error,result) {
if(error == null && result != null) {
_gthis.scenarioTimes = result;
if(2 == 1) {
if(Object.prototype.hasOwnProperty.call(_gthis.scenarioTimes.h,"theLostShip")) {
common_KongTools.setStat("binaryWontheLostShip",1);
}
if(Object.prototype.hasOwnProperty.call(_gthis.scenarioTimes.h,"multipleWorlds")) {
common_KongTools.setStat("binaryWonmultipleWorlds",1);
}
}
} else {
_gthis.scenarioTimes = new haxe_ds_StringMap();
}
onLoadComplete();
});
common_Storage.getItem("unlockedAllScenarios",function(error,result) {
if(error == null && result != null) {
_gthis.unlockedAll = result;
}
});
};
$hxClasses["progress.MetaGame"] = progress_MetaGame;
progress_MetaGame.__name__ = "progress.MetaGame";
progress_MetaGame.prototype = {
unlockAll: function() {
this.unlockedAll = true;
common_Storage.setItem("unlockedAllScenarios",true,function() {
});
}
,winScenario: function(scenario,time) {
if(!Object.prototype.hasOwnProperty.call(this.scenarioTimes.h,scenario) || this.scenarioTimes.h[scenario] > time) {
this.scenarioTimes.h[scenario] = time;
if(2 == 1) {
common_KongTools.setStat("win" + scenario,time);
common_KongTools.setStat("binaryWon" + scenario,1);
}
this.saveProgress();
}
}
,getScenarioTime: function(scenario) {
if(!Object.prototype.hasOwnProperty.call(this.scenarioTimes.h,scenario)) {
return null;
}
return this.scenarioTimes.h[scenario];
}
,hasWonScenario: function(scenario) {
return Object.prototype.hasOwnProperty.call(this.scenarioTimes.h,scenario);
}
,saveProgress: function() {
common_Storage.setItem("progressFile",this.scenarioTimes,function() {
});
}
,__class__: progress_MetaGame
};
var progress_SandboxHelper = function(city) {
this.everPlayedWithUnlimitedResources = false;
this.unlimitedResources = false;
this.city = city;
};
$hxClasses["progress.SandboxHelper"] = progress_SandboxHelper;
progress_SandboxHelper.__name__ = "progress.SandboxHelper";
progress_SandboxHelper.prototype = {
update: function(timeMod) {
if(this.unlimitedResources) {
if(this.city.materials.food < 10000000) {
this.city.materials.set_food(10000000);
}
if(this.city.materials.wood < 10000000) {
this.city.materials.wood = 10000000;
}
if(this.city.materials.stone < 10000000) {
this.city.materials.stone = 10000000;
}
if(this.city.materials.machineParts < 10000000) {
this.city.materials.machineParts = 10000000;
}
if(this.city.materials.refinedMetal < 10000000) {
this.city.materials.refinedMetal = 10000000;
}
if(this.city.materials.computerChips < 10000000) {
this.city.materials.computerChips = 10000000;
}
if(this.city.materials.cacao < 10000000 && false) {
this.city.materials.cacao = 10000000;
}
if(this.city.materials.chocolate < 10000000 && false) {
this.city.materials.chocolate = 10000000;
}
var _g = 0;
var _g1 = MaterialsHelper.modMaterials;
while(_g < _g1.length) {
var modMaterial = _g1[_g];
++_g;
var currentMaterial = modMaterial.variableName;
if(this.city.materials[currentMaterial] < 10000000 && currentMaterial != "cacao" && currentMaterial != "chocolate") {
this.city.materials[currentMaterial] = 10000000;
}
}
if(this.city.materials.knowledge < 10000000) {
this.city.materials.knowledge = 10000000;
}
}
}
,enableUnlimitedResources: function() {
if(this.unlimitedResources) {
return;
}
this.unlimitedResources = true;
this.everPlayedWithUnlimitedResources = true;
var _g = this.city.materials;
_g.set_food(_g.food + 10000000);
this.city.materials.wood += 10000000;
this.city.materials.stone += 10000000;
this.city.materials.machineParts += 10000000;
this.city.materials.refinedMetal += 10000000;
this.city.materials.computerChips += 10000000;
var _g = 0;
var _g1 = MaterialsHelper.modMaterials;
while(_g < _g1.length) {
var modMaterial = _g1[_g];
++_g;
var currentMaterial = modMaterial.variableName;
if(currentMaterial != "cacao" && currentMaterial != "chocolate") {
this.city.materials[currentMaterial] += 10000000;
}
}
this.city.materials.knowledge += 10000000;
}
,disableUnlimitedResources: function() {
if(!this.unlimitedResources) {
return;
}
this.unlimitedResources = false;
var _g = this.city.materials;
_g.set_food(_g.food - 10000000);
if(this.city.materials.food < 0) {
this.city.materials.set_food(0);
}
this.city.materials.wood -= 10000000;
if(this.city.materials.wood < 0) {
this.city.materials.wood = 0;
}
this.city.materials.stone -= 10000000;
if(this.city.materials.stone < 0) {
this.city.materials.stone = 0;
}
this.city.materials.machineParts -= 10000000;
if(this.city.materials.machineParts < 0) {
this.city.materials.machineParts = 0;
}
this.city.materials.refinedMetal -= 10000000;
if(this.city.materials.refinedMetal < 0) {
this.city.materials.refinedMetal = 0;
}
this.city.materials.computerChips -= 10000000;
if(this.city.materials.computerChips < 0) {
this.city.materials.computerChips = 0;
}
var _g = 0;
var _g1 = MaterialsHelper.modMaterials;
while(_g < _g1.length) {
var modMaterial = _g1[_g];
++_g;
var currentMaterial = modMaterial.variableName;
if(currentMaterial != "cacao" && currentMaterial != "chocolate") {
this.city.materials[currentMaterial] -= 10000000;
if(this.city.materials[currentMaterial] < 0) {
this.city.materials[currentMaterial] = 0;
}
}
}
this.city.materials.knowledge -= 10000000;
if(this.city.materials.knowledge < 0) {
this.city.materials.knowledge = 0;
}
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
if(shouldSaveDefinition) {
queue.addString(progress_SandboxHelper.saveDefinition);
}
var value = this.unlimitedResources;
if(queue.size + 1 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 1) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.b[queue.size] = value ? 1 : 0;
queue.size += 1;
var value = this.everPlayedWithUnlimitedResources;
if(queue.size + 1 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 1) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.b[queue.size] = value ? 1 : 0;
queue.size += 1;
}
,load: function(queue,definition) {
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"unlimitedResources")) {
this.unlimitedResources = loadMap.h["unlimitedResources"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"everPlayedWithUnlimitedResources")) {
this.everPlayedWithUnlimitedResources = loadMap.h["everPlayedWithUnlimitedResources"];
}
}
,__class__: progress_SandboxHelper
};
var progress_ScriptedStoryPart = function(city,story) {
this.city = city;
this.simulation = city.simulation;
this.story = story;
};
$hxClasses["progress.ScriptedStoryPart"] = progress_ScriptedStoryPart;
progress_ScriptedStoryPart.__name__ = "progress.ScriptedStoryPart";
progress_ScriptedStoryPart.prototype = {
update: function(timeMod) {
}
,initialize: function($with) {
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
if(shouldSaveDefinition) {
queue.addString(progress_ScriptedStoryPart.saveDefinition);
}
}
,load: function(queue,definition) {
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
}
,__class__: progress_ScriptedStoryPart
};
var progress_Story = function(city,storyName) {
if(storyName == null) {
storyName = "theLostShip";
}
this.hiddenBoost = false;
this.disableDestroy = false;
this.disableDying = false;
this.city = city;
this.storyInfo = Resources.storiesInfo.h[storyName];
this.storyName = storyName;
this.plannings = [];
this.scriptedParts = [];
};
$hxClasses["progress.Story"] = progress_Story;
progress_Story.__name__ = "progress.Story";
progress_Story.prototype = {
get_speedUpStartNights: function() {
if(this.storyInfo.speedUpStartNights == null) {
return false;
} else {
return this.storyInfo.speedUpStartNights;
}
}
,start: function() {
this.city.materials.add(Materials.fromStoryMaterials(this.storyInfo.initialMaterials));
if(this.storyInfo.lockPermanents != null) {
var _g = 0;
var _g1 = this.storyInfo.lockPermanents;
while(_g < _g1.length) {
var pm = _g1[_g];
++_g;
this.city.progress.unlocks.lock($hxClasses["buildings." + pm]);
}
}
if(this.storyInfo.lockAllPermanents == true) {
this.city.progress.unlocks.unlockedDecorationTab = false;
this.city.progress.unlocks.unlockedBuildingModeButton = false;
this.city.progress.unlocks.unlockedManagementOptions = false;
var _g = 0;
var _g1 = this.city.progress.resources.buildingInfoArray;
while(_g < _g1.length) {
var pm = _g1[_g];
++_g;
var name = "buildings." + pm.className;
this.city.progress.unlocks.lock($hxClasses[name]);
}
}
if(this.storyInfo.startGoal != "") {
this.startGoal(this.findGoal(this.storyInfo.startGoal));
}
if(this.storyInfo.viewYFromBottom != null) {
this.city.fixViewBottom(this.city.game.isMobile && this.storyInfo.viewYMobi != null ? this.storyInfo.viewYMobi : this.storyInfo.viewYFromBottom);
this.city.resize();
this.city.fixViewBottom(null);
}
if(this.city.game.isMobile && this.storyInfo.mobileViewStartX != null) {
this.city.viewPos.x = this.storyInfo.mobileViewStartX;
this.city.resize();
}
}
,update: function(timeMod) {
if(this.city.displayOnly && this.storyInfo.viewYFromBottom != null) {
this.city.fixViewBottom(this.city.game.isMobile && this.storyInfo.viewYMobi != null ? this.storyInfo.viewYMobi : this.storyInfo.viewYFromBottom);
this.city.resize();
this.city.fixViewBottom(null);
}
if(this.currentGoal != null && this.city.gui.windowRelatedTo != this) {
if(this.goalComplete(this.currentGoal)) {
Analytics.sendEvent("story","goal_complete",null,this.storyName + "-" + this.currentGoal.name);
if(this.currentGoal.name != this.storyInfo.startGoal) {
if(2 == 6) {
if(this.currentGoal.name == "Win") {
PokiSDK.happyTime(1);
} else {
PokiSDK.happyTime(0.3);
}
}
}
if(this.currentGoal.nextGoal != "") {
this.startGoal(this.findGoal(this.currentGoal.nextGoal));
} else {
this.currentGoal = null;
}
}
}
var i = this.plannings.length;
while(--i >= 0) {
var planning = this.plannings[i];
if(planning.plan.length > planning.nextEventToHandle) {
var nextPlanItem = planning.plan[planning.nextEventToHandle];
if(planning.timeStart + nextPlanItem.time < this.city.simulation.time.timeSinceStart / 60) {
this.executePlannedEvent(nextPlanItem);
planning.nextEventToHandle += 1;
}
}
if(planning.plan.length <= planning.nextEventToHandle) {
this.plannings.splice(i,1);
}
}
var i = this.scriptedParts.length;
while(--i >= 0) this.scriptedParts[i].update(timeMod);
}
,executePlannedEvent: function(event) {
switch(event.type) {
case "ScriptedStoryPart":
var scriptedStoryPartEvent = event;
var name = "progress.scriptedStoryParts." + scriptedStoryPartEvent.className;
var newSSP = Type.createInstance($hxClasses[name],[this.city,this]);
newSSP.initialize(scriptedStoryPartEvent);
this.scriptedParts.push(newSSP);
break;
case "SpawnCitizens":
var spawnCitizensEvent = event;
this.spawnCitizens(this.city.worlds[spawnCitizensEvent.world],spawnCitizensEvent);
break;
case "SpawnCitizensFlyingSaucer":
var spawnCitizensEvent = event;
this.city.simulation.citizenSpawners.push(new simulation_SpawnFlyingSaucer(this.city.simulation,this.city.farForegroundStage,this.city.worlds[spawnCitizensEvent.world],spawnCitizensEvent,spawnCitizensEvent.toXIndex));
break;
}
}
,getDesiredGoalHighlights: function() {
if(this.currentGoal == null) {
return [];
}
var highlights = [];
var _g = 0;
var _g1 = this.currentGoal.subGoals;
while(_g < _g1.length) {
var subGoal = _g1[_g];
++_g;
if(!this.subGoalComplete(subGoal)) {
switch(subGoal.type) {
case "BuildPermanents":
var buildPermanentsGoal = subGoal;
var className = buildPermanentsGoal.permanentToBuildClass;
if(!StringTools.startsWith(className,"buildings.") && !StringTools.startsWith(className,"worldResources.")) {
className = "buildings." + className;
}
highlights.push($hxClasses[className]);
break;
case "PerformBuildingUpgrades":
var performBuildingUpgradesGoal = subGoal;
var className1 = performBuildingUpgradesGoal.upgradeClass;
if(!StringTools.startsWith(className1,"buildingUpgrades.")) {
className1 = "buildingUpgrades." + className1;
}
highlights.push($hxClasses[className1]);
break;
}
}
}
return highlights;
}
,goalComplete: function(goal) {
var allComplete = true;
var _g = 0;
var _g1 = goal.subGoals;
while(_g < _g1.length) {
var subGoal = _g1[_g];
++_g;
if(!this.subGoalComplete(subGoal)) {
allComplete = false;
}
}
return allComplete;
}
,subGoalComplete: function(goal) {
switch(goal.type) {
case "BuildPermanents":
var buildPermanentsGoal = goal;
var className = buildPermanentsGoal.permanentToBuildClass;
if(!StringTools.startsWith(className,"buildings.") && !StringTools.startsWith(className,"worldResources.")) {
className = "buildings." + className;
}
var countFunc = buildPermanentsGoal.needsExactClass != null && buildPermanentsGoal.needsExactClass ? function(pm) {
var c = js_Boot.getClass(pm);
return c.__name__ == className;
} : function(pm) {
return pm.is($hxClasses[className]);
};
if(buildPermanentsGoal.onWorld != null) {
var world = this.city.worlds[buildPermanentsGoal.onWorld];
var oldCountFunc = countFunc;
countFunc = function(pm) {
if(oldCountFunc(pm)) {
return pm.world == world;
} else {
return false;
}
};
} else if(buildPermanentsGoal.notOnWorld != null) {
var world1 = this.city.worlds[buildPermanentsGoal.notOnWorld];
var oldCountFunc1 = countFunc;
countFunc = function(pm) {
if(oldCountFunc1(pm)) {
return pm.world != world1;
} else {
return false;
}
};
}
return Lambda.count(this.city.permanents,countFunc) >= buildPermanentsGoal.amount;
case "CompleteHackerMissions":
var hackerMissionsGoal = goal;
var _g = 0;
var _g1 = this.city.permanents;
while(_g < _g1.length) {
var pm = _g1[_g];
++_g;
if(pm.is(buildings_HackerHQ)) {
var hackerHQ = pm;
return hackerHQ.currentMission >= hackerMissionsGoal.amount;
}
}
return false;
case "ExploreAlienRuins":
var _g = 0;
var _g1 = this.city.worlds;
while(_g < _g1.length) {
var world2 = _g1[_g];
++_g;
var _g2 = 0;
var _g3 = world2.permanents;
while(_g2 < _g3.length) {
var pm = _g3[_g2];
++_g2;
if(pm.length >= 1 && pm[0] != null && pm[0].is(worldResources_ComputerAlienRuins)) {
var car = pm[0];
return car.explored >= 99.99;
}
}
}
return false;
case "GatherMaterials":
var gatherMaterialsGoal = goal;
if(gatherMaterialsGoal.materials.food != null) {
if(this.city.materials.food < gatherMaterialsGoal.materials.food) {
return false;
}
}
if(gatherMaterialsGoal.materials.wood != null) {
if(this.city.materials.wood < gatherMaterialsGoal.materials.wood) {
return false;
}
}
if(gatherMaterialsGoal.materials.stone != null) {
if(this.city.materials.stone < gatherMaterialsGoal.materials.stone) {
return false;
}
}
if(gatherMaterialsGoal.materials.machineParts != null) {
if(this.city.materials.machineParts < gatherMaterialsGoal.materials.machineParts) {
return false;
}
}
if(gatherMaterialsGoal.materials.refinedMetal != null) {
if(this.city.materials.refinedMetal < gatherMaterialsGoal.materials.refinedMetal) {
return false;
}
}
if(gatherMaterialsGoal.materials.computerChips != null) {
if(this.city.materials.computerChips < gatherMaterialsGoal.materials.computerChips) {
return false;
}
}
if(gatherMaterialsGoal.materials.cacao != null) {
if(this.city.materials.cacao < gatherMaterialsGoal.materials.cacao) {
return false;
}
}
if(gatherMaterialsGoal.materials.chocolate != null) {
if(this.city.materials.chocolate < gatherMaterialsGoal.materials.chocolate) {
return false;
}
}
var _g = 0;
var _g1 = MaterialsHelper.modMaterials;
while(_g < _g1.length) {
var modMaterial = _g1[_g];
++_g;
var currentMaterial = modMaterial.variableName;
if(gatherMaterialsGoal.materials[currentMaterial] != null) {
if(this.city.materials[currentMaterial] < gatherMaterialsGoal.materials[currentMaterial]) {
return false;
}
}
}
if(gatherMaterialsGoal.materials.knowledge != null) {
if(this.city.materials.knowledge < gatherMaterialsGoal.materials.knowledge) {
return false;
}
}
return true;
case "HousingCapacity":
var houseCapGoal = goal;
return this.city.simulation.stats.houseCapacity >= houseCapGoal.amount;
case "MinimumHappiness":
var happinessGoal = goal;
return this.city.simulation.happiness.happiness >= happinessGoal.happiness;
case "PerformBuildingUpgrades":
var performBuildingUpgradesGoal = goal;
var className1 = performBuildingUpgradesGoal.upgradeClass;
if(!StringTools.startsWith(className1,"buildingUpgrades.")) {
className1 = "buildingUpgrades." + className1;
}
var classType = $hxClasses[className1];
var total = Lambda.count(this.city.permanents,function(pm) {
if(pm.isBuilding) {
return common_ArrayExtensions.any(pm.upgrades,function(up) {
return js_Boot.__instanceof(up,classType);
});
} else {
return false;
}
});
return total >= performBuildingUpgradesGoal.amount;
case "WaitForDecryption":
var _g = 0;
var _g1 = this.city.permanents;
while(_g < _g1.length) {
var pm = _g1[_g];
++_g;
if(pm.is(buildings_AlienDecryptor)) {
var ad = pm;
return ad.timeWorking >= 1440;
}
}
return false;
}
return false;
}
,findGoal: function(goalName) {
return Lambda.find(this.storyInfo.goals,function(g) {
return g.name == goalName;
});
}
,startGoal: function(goal) {
var _gthis = this;
this.currentGoal = goal;
if(goal.flags != null) {
this.handleFlagsChanges(goal.flags);
}
this.showGoalText();
if(goal.unlocks != null) {
var _g = 0;
var _g1 = goal.unlocks;
while(_g < _g1.length) {
var className = _g1[_g];
++_g;
if(className == "decorations") {
this.city.progress.unlocks.unlockedDecorationTab = true;
} else if(className == "buildingModes") {
this.city.progress.unlocks.unlockedBuildingModeButton = true;
} else if(className == "managementOptions") {
this.city.progress.unlocks.unlockedManagementOptions = true;
} else {
this.city.progress.unlocks.unlock($hxClasses["buildings." + className]);
}
}
}
if(goal.planning != null) {
this.plannings.push({ goalName : goal.name, plan : goal.planning, nextEventToHandle : 0, timeStart : this.city.simulation.time.timeSinceStart / 60});
}
if(goal.name == "Win") {
this.city.game.metaGame.winScenario(this.storyName,this.city.simulation.time.timeSinceStart | 0);
}
this.city.gui.clearTutorial();
this.city.postCreateBuilder = null;
if(goal.showTutorial != null) {
if(goal.showTutorial == 1) {
this.city.gui.showTutorialArrows1();
this.city.postCreateBuilder = function() {
_gthis.city.builder.fixBuilder(_gthis.city.worlds[0],2);
};
} else if(goal.showTutorial == 2) {
var closeWarning = this.city.gui.showWindowCloseWarning(120);
this.city.gui.showTutorialArrows2(closeWarning);
} else if(goal.showTutorial == 101) {
var closeWarning = this.city.gui.showWindowCloseWarning(120);
this.city.gui.showTutorialArrowsBuildStoneMine(closeWarning);
} else if(goal.showTutorial == 3) {
this.city.gui.showTutorialArrows3();
} else if(goal.showTutorial == 4) {
this.city.gui.showTutorialArrows4();
}
}
}
,showGoalText: function(tldr) {
if(tldr == null) {
tldr = false;
}
var _gthis = this;
var goal = this.currentGoal;
this.city.gui.createWindow(this);
if(goal.title != null && goal.title != "") {
this.city.gui.windowAddTitleText(goal.title);
}
var text = "";
var goalText = goal.text;
if(Config.isLimitedDemo && goal.flags != null && goal.flags.demoText != null) {
goalText += goal.flags.demoText;
}
var commandStart = goalText.indexOf("[");
var isAddingText = true;
var goalComplete = this.goalComplete(goal);
while(commandStart != -1) {
if(isAddingText) {
text += HxOverrides.substr(goalText,0,commandStart);
}
goalText = HxOverrides.substr(goalText,commandStart + 1,null);
var commandEnd = goalText.indexOf("]");
var command = HxOverrides.substr(goalText,0,commandEnd);
goalText = HxOverrides.substr(goalText,commandEnd + 1,null);
if(command == "n") {
isAddingText = !goalComplete;
} else if(command == "c") {
isAddingText = goalComplete;
} else if(command == "mobi") {
isAddingText = this.city.game.isMobile;
} else if(command == "nonmobi") {
isAddingText = !this.city.game.isMobile;
} else if(command == "nmobi") {
isAddingText = !goalComplete && this.city.game.isMobile;
} else if(command == "nnonmobi") {
isAddingText = !goalComplete && !this.city.game.isMobile;
} else if(command == "/") {
isAddingText = true;
} else if(command == "d") {
var _this = this.city.simulation.time;
text += "" + (1 + ((_this.timeSinceStart | 0) / 1440 | 0) == 1 ? "one day" : "" + (1 + ((_this.timeSinceStart | 0) / 1440 | 0)) + " days") + ", " + (((_this.timeSinceStart | 0) / 60 | 0) % 24 == 1 ? "one hour" : "" + ((_this.timeSinceStart | 0) / 60 | 0) % 24 + " hours") + ", " + ("and " + ((_this.timeSinceStart | 0) % 60 == 1 ? "one minute" : (_this.timeSinceStart | 0) % 60 + " minutes"));
}
commandStart = goalText.indexOf("[");
}
if(isAddingText) {
text += goalText;
}
this.city.gui.windowAddInfoText(tldr ? goal.tldr : text);
this.city.gui.pauseForWindow();
var hasTldrButton = goal.tldr != null;
var bottomButtonsList = [];
if(hasTldrButton) {
bottomButtonsList.push({ text : tldr ? "Too short?" : "tl;dr?", action : function() {
_gthis.showGoalText(!tldr);
}});
}
if(goal.name == "Win") {
if(Config.isLimitedDemo) {
bottomButtonsList.push({ text : "Wishlist the Full Version Now!", action : function() {
greenworks.activateGameOverlayToWebPage("https://store.steampowered.com/app/1180130/The_Final_Earth_2/");
}});
}
if(goal.nextStory != null && goal.nextStory != "") {
bottomButtonsList.push({ text : "Next Scenario", action : function() {
var _g = ($_=_gthis.city.game,$bind($_,$_.newCity));
var storyName = goal.nextStory;
var tmp = function(saveFileName) {
_g(storyName,saveFileName);
};
gui_SaveLoadWindows.createSaveWindow(_gthis.city.game,_gthis.city.gui,"Which save slot would you like to use?",tmp);
if(2 == 6 && Config.hadFullStepWithInput) {
common_AdHelper.showNonRewardedInterstitialIfAllowed();
}
}});
} else {
var game = this.city.game;
var gui = this.city.gui;
bottomButtonsList.push({ text : "New City", action : function() {
gui_MainMenuGUI.createNewScenarioWindow(game,gui);
}});
}
}
var bottomButtons = this.city.gui.windowAddBottomButtons(bottomButtonsList);
if(hasTldrButton && !tldr && bottomButtons.length > 0) {
bottomButtons[0].onHover = function() {
_gthis.city.gui.tooltip.setText(_gthis,"Want a shorter version?");
};
}
}
,makeWorlds: function(game,cityStage,cityMidStage,cityBgStage) {
var _g = 0;
var _g1 = this.storyInfo.worlds;
while(_g < _g1.length) {
var worldToMake = _g1[_g];
++_g;
var newWorld = new World(game,this.city,cityStage,cityMidStage,cityBgStage,common_Rectangle.fromStoryRect(worldToMake.rect),worldToMake.seed);
this.city.worlds.push(newWorld);
var _g2 = 0;
var _g3 = worldToMake.worldResources;
while(_g2 < _g3.length) {
var worldResourceToMake = _g3[_g2];
++_g2;
var name = "worldResources." + worldResourceToMake.className;
newWorld.createWorldResource($hxClasses[name],worldResourceToMake.position);
}
var _g4 = 0;
var _g5 = worldToMake.buildingStacks;
while(_g4 < _g5.length) {
var buildingToMake = _g5[_g4];
++_g4;
var _g6 = 0;
var _g7 = buildingToMake.classNames;
while(_g6 < _g7.length) {
var className = _g7[_g6];
++_g6;
newWorld.build($hxClasses["buildings." + className],buildingToMake.position);
}
}
var _g8 = 0;
var _g9 = worldToMake.citizens;
while(_g8 < _g9.length) {
var spawn = _g9[_g8];
++_g8;
this.spawnCitizens(newWorld,spawn);
}
if(worldToMake.unbuildableAliens != null && worldToMake.unbuildableAliens) {
newWorld.setUnbuildableAliens();
}
}
if(this.storyInfo.generatorScripts != null) {
var _g = 0;
var _g1 = this.storyInfo.generatorScripts;
while(_g < _g1.length) {
var gs = _g1[_g];
++_g;
progress_GenerateWorld.doGenerate(gs.name,gs.args,this.city,this.storyInfo,cityStage,cityMidStage,cityBgStage);
}
}
}
,spawnCitizens: function(onWorld,spawn) {
var _g = 0;
var _g1 = spawn.amount;
while(_g < _g1) {
var i = _g++;
var age = spawn.ageRangeMin;
if(spawn.ageRangeMin != spawn.ageRangeMax) {
age = random_Random.getFloat(spawn.ageRangeMin,spawn.ageRangeMax);
}
var startX = null;
if(spawn.minX != null && spawn.maxX != null) {
startX = spawn.minX == spawn.maxX ? spawn.minX : random_Random.getInt(spawn.minX,spawn.maxX);
}
this.city.simulation.createCitizen(onWorld,age,null,startX);
}
}
,handleFlagsChanges: function(flags) {
if(flags.disableDying != null) {
this.disableDying = flags.disableDying;
}
if(flags.disableDestroy != null) {
this.disableDestroy = flags.disableDestroy;
}
if(flags.happinessEnthusiasmLevel != null) {
this.city.simulation.happiness.happinessEnthusiasmLevel = flags.happinessEnthusiasmLevel;
}
if(flags.hiddenBoost != null) {
this.hiddenBoost = flags.hiddenBoost;
}
if(flags.disableRewardedAd != null && this.city.simulation.boostManager != null) {
this.city.simulation.boostManager.disableRewardedAd = flags.disableRewardedAd;
}
if(flags.setBuildableAliens != null) {
var _g = 0;
var _g1 = this.city.worlds;
while(_g < _g1.length) {
var world = _g1[_g];
++_g;
world.makeBuildableAliens();
}
}
}
,save: function(queue) {
this.saveBasics(queue);
queue.addString(this.currentGoal == null ? "" : this.currentGoal.name);
var value = this.plannings.length;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var _g = 0;
var _g1 = this.plannings;
while(_g < _g1.length) {
var p = _g1[_g];
++_g;
queue.addString(p.goalName);
var value = p.nextEventToHandle;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value1 = p.timeStart;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes1 = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes1,0,queue.size);
}
queue.bytes.setDouble(queue.size,value1);
queue.size += 8;
}
var value = this.scriptedParts.length;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var _g = 0;
var _g1 = this.scriptedParts;
while(_g < _g1.length) {
var p = _g1[_g];
++_g;
var c = js_Boot.getClass(p);
queue.addString(c.__name__);
p.save(queue);
}
}
,load: function(queue) {
this.loadBasics(queue);
this.storyInfo = Resources.storiesInfo.h[this.storyName];
var currentGoalName = queue.readString();
this.currentGoal = currentGoalName == "" ? null : this.findGoal(currentGoalName);
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var planningAmount = intToRead;
var _g = 0;
var _g1 = planningAmount;
while(_g < _g1) {
var i = _g++;
var goalName = queue.readString();
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var nextEventToHandle = intToRead;
var floatToRead = queue.bytes.getDouble(queue.readStart);
queue.readStart += 8;
var timeSinceStart = floatToRead;
this.plannings.push({ goalName : goalName, plan : this.findGoal(goalName).planning, nextEventToHandle : nextEventToHandle, timeStart : timeSinceStart});
}
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var scriptedPartsLen = intToRead;
var _g = 0;
var _g1 = scriptedPartsLen;
while(_g < _g1) {
var i = _g++;
var name = queue.readString();
var p = Type.createInstance($hxClasses[name],[this.city,this]);
p.load(queue);
this.scriptedParts.push(p);
}
if(currentGoalName == "" || currentGoalName == "Win") {
if(this.storyName == "theLostShip") {
common_KongTools.setStat("binaryWontheLostShip",1);
} else if(this.storyName == "multipleWorlds") {
common_KongTools.setStat("binaryWontheLostShip",1);
common_KongTools.setStat("binaryWonmultipleWorlds",1);
}
}
}
,canHaveUnlimitedResources: function() {
return this.currentGoal == null;
}
,saveBasics: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
if(shouldSaveDefinition) {
queue.addString(progress_Story.saveDefinition);
}
queue.addString(this.storyName);
var value = this.disableDying;
if(queue.size + 1 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 1) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.b[queue.size] = value ? 1 : 0;
queue.size += 1;
var value = this.disableDestroy;
if(queue.size + 1 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 1) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.b[queue.size] = value ? 1 : 0;
queue.size += 1;
var value = this.hiddenBoost;
if(queue.size + 1 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 1) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.b[queue.size] = value ? 1 : 0;
queue.size += 1;
}
,loadBasics: function(queue,definition) {
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"storyName")) {
this.storyName = loadMap.h["storyName"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"disableDying")) {
this.disableDying = loadMap.h["disableDying"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"disableDestroy")) {
this.disableDestroy = loadMap.h["disableDestroy"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"hiddenBoost")) {
this.hiddenBoost = loadMap.h["hiddenBoost"];
}
}
,__class__: progress_Story
};
var progress_StoryLoader = function(storyName,onSuccess,onFail) {
var fileName = "stories/" + storyName + ".json";
var loader = new PIXI.loaders.Loader();
loader.add(fileName);
var hasError = false;
loader.use(function(res,next) {
if(res.error) {
console.log("FloatingSpaceCities/progress/StoryLoader.hx:21:",res.error);
if(!hasError) {
onFail();
hasError = true;
}
return;
}
var v = res.data;
Resources.storiesInfo.h[storyName] = v;
next();
});
loader.load(onSuccess);
};
$hxClasses["progress.StoryLoader"] = progress_StoryLoader;
progress_StoryLoader.__name__ = "progress.StoryLoader";
progress_StoryLoader.shouldShowUnlockAllStoriesButton = function(game) {
var stories = Resources.allStoriesInfo;
var _g = 0;
while(_g < stories.length) {
var story = stories[_g];
++_g;
if(story.unlockedWithAll && !progress_StoryLoader.hasCompletedRequirements(game,story)) {
return true;
}
}
return false;
};
progress_StoryLoader.hasCompletedRequirements = function(game,story) {
if(story.requirements == null) {
return true;
}
if(story.unlockedWithAll && game.metaGame.unlockedAll) {
return true;
}
return common_ArrayExtensions.all(story.requirements,function(r) {
if(!(r == "notDemo" && !Config.isLimitedDemo)) {
return game.metaGame.hasWonScenario(r);
} else {
return true;
}
});
};
progress_StoryLoader.prototype = {
__class__: progress_StoryLoader
};
var progress_UnlockState = $hxEnums["progress.UnlockState"] = { __ename__ : "progress.UnlockState", __constructs__ : ["Locked","Unlocked","Createable","Researched"]
,Locked: {_hx_index:0,__enum__:"progress.UnlockState",toString:$estr}
,Unlocked: {_hx_index:1,__enum__:"progress.UnlockState",toString:$estr}
,Createable: {_hx_index:2,__enum__:"progress.UnlockState",toString:$estr}
,Researched: {_hx_index:3,__enum__:"progress.UnlockState",toString:$estr}
};
var progress_Unlocks = function(city) {
this.unlockMost = false;
this.checkBuildRelatedUnlocksIn = 0;
this.numberOfModernArtMuseumArtworksUnlocked = 4;
this.unlockedManagementOptions = true;
this.unlockedBuildingModeButton = true;
this.unlockedDecorationTab = true;
this.city = city;
this.unlockState = new haxe_ds_StringMap();
this.shouldNotifyForUnlock = new haxe_ds_StringMap();
this.shouldNotifyForCategoryUnlock = new haxe_ds_StringMap();
this.explicityLocked = [];
var building = haxe_ds_StringMap.valueIterator(city.progress.resources.buildingInfo.h);
while(building.hasNext()) {
var building1 = building.next();
var v = building1.unlockedByDefault && building1.knowledge == 0 ? progress_UnlockState.Researched : building1.unlockedByDefault ? progress_UnlockState.Unlocked : progress_UnlockState.Locked;
this.unlockState.h["buildings." + building1.className] = v;
}
var buildingUpgrade = haxe_ds_StringMap.valueIterator(Resources.buildingUpgradesInfo.h);
while(buildingUpgrade.hasNext()) {
var buildingUpgrade1 = buildingUpgrade.next();
var upgradeDefaultUnlocked = buildingUpgrade1.unlockedByDefault == null || buildingUpgrade1.unlockedByDefault;
var v = upgradeDefaultUnlocked && buildingUpgrade1.knowledge == 0 ? progress_UnlockState.Researched : upgradeDefaultUnlocked ? progress_UnlockState.Unlocked : progress_UnlockState.Locked;
this.unlockState.h["buildingUpgrades." + buildingUpgrade1.className] = v;
}
var cityUpgrade = haxe_ds_StringMap.valueIterator(Resources.cityUpgradesInfo.h);
while(cityUpgrade.hasNext()) {
var cityUpgrade1 = cityUpgrade.next();
var upgradeDefaultUnlocked = cityUpgrade1.unlockedByDefault == null || cityUpgrade1.unlockedByDefault;
var v = upgradeDefaultUnlocked ? progress_UnlockState.Unlocked : progress_UnlockState.Locked;
this.unlockState.h["cityUpgrades." + cityUpgrade1.className] = v;
}
var policy = haxe_ds_StringMap.valueIterator(Resources.policiesInfo.h);
while(policy.hasNext()) {
var policy1 = policy.next();
var upgradeDefaultUnlocked = policy1.unlockedByDefault == null || policy1.unlockedByDefault;
var v = upgradeDefaultUnlocked ? progress_UnlockState.Unlocked : progress_UnlockState.Locked;
this.unlockState.h["policies." + policy1.className] = v;
}
};
$hxClasses["progress.Unlocks"] = progress_Unlocks;
progress_Unlocks.__name__ = "progress.Unlocks";
progress_Unlocks.prototype = {
postInitialCreate: function() {
if(this.unlockMost) {
var building = haxe_ds_StringMap.valueIterator(this.city.progress.resources.buildingInfo.h);
while(building.hasNext()) {
var building1 = building.next();
var v = !building1.notUnlockedWithAll && building1.knowledge == 0 ? progress_UnlockState.Researched : !building1.notUnlockedWithAll ? progress_UnlockState.Createable : progress_UnlockState.Locked;
this.unlockState.h["buildings." + building1.className] = v;
}
var buildingUpgrade = haxe_ds_StringMap.valueIterator(Resources.buildingUpgradesInfo.h);
while(buildingUpgrade.hasNext()) {
var buildingUpgrade1 = buildingUpgrade.next();
var upgradeDefaultUnlocked = buildingUpgrade1.notUnlockedWithAll == null || !buildingUpgrade1.notUnlockedWithAll;
var v = upgradeDefaultUnlocked && buildingUpgrade1.knowledge == 0 ? progress_UnlockState.Researched : upgradeDefaultUnlocked ? progress_UnlockState.Createable : progress_UnlockState.Locked;
this.unlockState.h["buildingUpgrades." + buildingUpgrade1.className] = v;
}
var cityUpgrade = haxe_ds_StringMap.valueIterator(Resources.cityUpgradesInfo.h);
while(cityUpgrade.hasNext()) {
var cityUpgrade1 = cityUpgrade.next();
var upgradeDefaultUnlocked = cityUpgrade1.notUnlockedWithAll == null || !cityUpgrade1.notUnlockedWithAll;
var v = upgradeDefaultUnlocked ? progress_UnlockState.Createable : progress_UnlockState.Locked;
this.unlockState.h["cityUpgrades." + cityUpgrade1.className] = v;
}
var policy = haxe_ds_StringMap.valueIterator(Resources.policiesInfo.h);
while(policy.hasNext()) {
var policy1 = policy.next();
var upgradeDefaultUnlocked = policy1.notUnlockedWithAll == null || !policy1.notUnlockedWithAll;
var v = upgradeDefaultUnlocked ? progress_UnlockState.Createable : progress_UnlockState.Locked;
this.unlockState.h["policies." + policy1.className] = v;
}
}
}
,postLoad: function() {
var building = haxe_ds_StringMap.valueIterator(this.city.progress.resources.buildingInfo.h);
while(building.hasNext()) {
var building1 = building.next();
var key = "buildings." + building1.className;
var needToUnlock = building1.unlockedByDefault && this.explicityLocked.indexOf(key) == -1;
if(needToUnlock && building1.knowledge == 0) {
var v = progress_UnlockState.Researched;
this.unlockState.h[key] = v;
} else if(needToUnlock && (this.unlockState.h[key] == null || this.unlockState.h[key] == progress_UnlockState.Locked)) {
var v1 = progress_UnlockState.Unlocked;
this.unlockState.h[key] = v1;
} else if(this.unlockState.h[key] == null) {
var v2 = progress_UnlockState.Locked;
this.unlockState.h[key] = v2;
}
}
var buildingUpgrade = haxe_ds_StringMap.valueIterator(Resources.buildingUpgradesInfo.h);
while(buildingUpgrade.hasNext()) {
var buildingUpgrade1 = buildingUpgrade.next();
var key = "buildingUpgrades." + buildingUpgrade1.className;
var upgradeDefaultUnlocked = (buildingUpgrade1.unlockedByDefault == null || buildingUpgrade1.unlockedByDefault) && this.explicityLocked.indexOf(key) == -1;
if(upgradeDefaultUnlocked && buildingUpgrade1.knowledge == 0) {
var v = progress_UnlockState.Researched;
this.unlockState.h[key] = v;
} else if(upgradeDefaultUnlocked && (this.unlockState.h[key] == null || this.unlockState.h[key] == progress_UnlockState.Locked)) {
var v1 = progress_UnlockState.Unlocked;
this.unlockState.h[key] = v1;
} else if(this.unlockState.h[key] == null) {
var v2 = progress_UnlockState.Locked;
this.unlockState.h[key] = v2;
}
}
var cityUpgrade = haxe_ds_StringMap.valueIterator(Resources.cityUpgradesInfo.h);
while(cityUpgrade.hasNext()) {
var cityUpgrade1 = cityUpgrade.next();
var key = "cityUpgrades." + cityUpgrade1.className;
var upgradeDefaultUnlocked = cityUpgrade1.unlockedByDefault == null || cityUpgrade1.unlockedByDefault;
if(upgradeDefaultUnlocked && (this.unlockState.h[key] == null || this.unlockState.h[key] == progress_UnlockState.Locked)) {
var v = progress_UnlockState.Unlocked;
this.unlockState.h[key] = v;
} else if(this.unlockState.h[key] == null) {
var v1 = progress_UnlockState.Locked;
this.unlockState.h[key] = v1;
}
}
var policy = haxe_ds_StringMap.valueIterator(Resources.policiesInfo.h);
while(policy.hasNext()) {
var policy1 = policy.next();
var key = "policies." + policy1.className;
var upgradeDefaultUnlocked = policy1.unlockedByDefault == null || policy1.unlockedByDefault;
if(upgradeDefaultUnlocked && (this.unlockState.h[key] == null || this.unlockState.h[key] == progress_UnlockState.Locked)) {
var v = progress_UnlockState.Unlocked;
this.unlockState.h[key] = v;
} else if(this.unlockState.h[key] == null) {
var v1 = progress_UnlockState.Locked;
this.unlockState.h[key] = v1;
}
}
this.city.permanentNumberCached = null;
this.checkBuildRelatedUnlocks();
this.city.gui.refreshCategoryBuildingsShown();
}
,lock: function(element) {
var elementName = element.__name__;
var v = progress_UnlockState.Locked;
this.unlockState.h[elementName] = v;
this.city.gui.refreshCategoryBuildingsShown();
this.explicityLocked.push(elementName);
}
,unlock: function(element,dontReloadWindow) {
if(dontReloadWindow == null) {
dontReloadWindow = false;
}
var elementName = element.__name__;
if(this.unlockState.h[elementName] == null || this.unlockState.h[elementName] == progress_UnlockState.Locked) {
var elementInfo = this.city.progress.resources.buildingInfo.h[elementName];
if(elementInfo == null) {
elementInfo = Resources.buildingUpgradesInfo.h[elementName];
}
if(elementInfo == null) {
elementInfo = Resources.cityUpgradesInfo.h[elementName];
}
var v = elementInfo.knowledge == 0 && elementInfo.showUnlockHint == null ? progress_UnlockState.Researched : progress_UnlockState.Unlocked;
this.unlockState.h[elementName] = v;
if(elementInfo.showUnlockHint == null) {
this.notifyForUnlock(element);
}
this.city.gui.refreshCategoryBuildingsShown();
if(!dontReloadWindow) {
this.city.gui.reloadWindow();
}
this.city.permanentNumberCached = null;
this.checkBuildRelatedUnlocks();
return true;
}
return false;
}
,fullyUnlock: function(element) {
var elementName = element.__name__;
if(this.unlockState.h[elementName] == progress_UnlockState.Unlocked) {
var v = progress_UnlockState.Createable;
this.unlockState.h[elementName] = v;
this.notifyForUnlock(element);
this.city.gui.refreshCategoryBuildingsShown();
this.city.gui.reloadWindow();
}
}
,research: function(element) {
var elementName = element.__name__;
var originalState = this.unlockState.h[elementName];
var v = progress_UnlockState.Researched;
this.unlockState.h[elementName] = v;
if(originalState == progress_UnlockState.Locked) {
this.city.gui.refreshCategoryBuildingsShown();
}
if(originalState != progress_UnlockState.Researched) {
Analytics.sendEvent("research",elementName);
}
}
,getUnlockState: function(element) {
var elementName = element.__name__;
return this.unlockState.h[elementName];
}
,getShouldNotifyForUnlock: function(element) {
var elementName = element.__name__;
var shouldNotifyForThis = this.shouldNotifyForUnlock.h[elementName];
if(shouldNotifyForThis != null) {
return shouldNotifyForThis;
} else {
return false;
}
}
,notifyForUnlock: function(element) {
var elementName = element.__name__;
this.shouldNotifyForUnlock.h[elementName] = true;
var elementInfo = this.city.progress.resources.buildingInfo.h[elementName];
if(elementInfo != null) {
this.shouldNotifyForCategoryUnlock.h[elementInfo.category] = true;
}
}
,stopNotifyForUnlock: function(element) {
var elementName = element.__name__;
this.shouldNotifyForUnlock.h[elementName] = false;
}
,getShouldNotifyForCategoryUnlock: function(categoryName) {
return this.shouldNotifyForCategoryUnlock.h[categoryName];
}
,stopNotifyCategoryUnlock: function(categoryName) {
this.shouldNotifyForCategoryUnlock.h[categoryName] = false;
}
,checkBuildRelatedUnlocksSoon: function() {
this.checkBuildRelatedUnlocksIn = this.checkBuildRelatedUnlocksIn > 0 ? this.checkBuildRelatedUnlocksIn : 60;
}
,update: function(timeMod) {
if(this.checkBuildRelatedUnlocksIn > 0) {
this.checkBuildRelatedUnlocksIn -= timeMod;
if(this.checkBuildRelatedUnlocksIn <= 0) {
this.checkBuildRelatedUnlocks();
}
}
}
,checkBuildRelatedUnlocks: function() {
var pmPerType = this.city.getAmountOfPermanentsPerType();
if(pmPerType.h["buildings.Park"] >= 5) {
this.unlock(buildings_BotanicalGardens);
if(pmPerType.h["buildings.Park"] >= 10 && pmPerType.h["buildings.Laboratory"] >= 5) {
this.fullyUnlock(buildings_BotanicalGardens);
}
}
if(pmPerType.h["buildings.ModernArtMuseum"] >= 3) {
this.fullyUnlock(buildings_ArtColony);
}
if(this.unlockState.h["buildings.BotanicalGardens"] == progress_UnlockState.Researched || this.unlockState.h["buildings.BotanicalGardens"] == progress_UnlockState.Createable) {
this.unlock(buildings_EcoFarm);
if(pmPerType.h["buildings.BotanicalGardens"] >= 10 && pmPerType.h["buildings.ExperimentalFarm"] >= 1) {
this.fullyUnlock(buildings_EcoFarm);
}
}
if(pmPerType.h["buildings.Laboratory"] >= 5 && pmPerType.h["buildings.RefinedMetalFactory"] >= 1) {
this.fullyUnlock(buildings_ComputerResearchCenter);
}
if(pmPerType.h["buildings.ComputerResearchCenter"] >= 1) {
this.unlock(buildings_ComputerChipFactory);
}
if(pmPerType.h["buildings.MachinePartsFactory"] >= 3) {
this.fullyUnlock(buildings_MechanicalHouse);
}
if(pmPerType.h["buildings.LivingResearchCenter"] >= 1) {
this.fullyUnlock(buildings_CuttingEdgeHome);
this.unlock(buildings_ParkPod);
}
if(pmPerType.h["buildings.ComputerChipFactory"] >= 1) {
this.unlock(buildings_HackerHQ);
if(pmPerType.h["buildings.Arcade"] >= 3) {
this.fullyUnlock(buildings_HackerHQ);
}
}
if(pmPerType.h["buildings.Pub"] >= 2) {
this.unlock(buildings_Restaurant);
if(pmPerType.h["buildings.Pub"] >= 5) {
this.fullyUnlock(buildings_Restaurant);
this.unlock(buildings_HerbGarden);
}
}
if(pmPerType.h["buildings.Restaurant"] >= 2) {
this.fullyUnlock(buildings_HerbGarden);
}
if(pmPerType.h["buildings.BlossomRestaurant"] >= 2) {
this.unlock(buildings_BlossomHut);
if(pmPerType.h["buildings.BlossomRestaurant"] >= 10) {
this.fullyUnlock(buildings_BlossomHut);
}
}
if(pmPerType.h["buildings.FarmByProductProcessor"] >= 10 && pmPerType.h["buildings.BotanicalGardens"] >= 200 && pmPerType.h["buildings.BlossomHut"] >= 50) {
this.unlock(buildings_TreeHuggerBase);
}
if(pmPerType.h["buildings.RefinedMetalFactory"] >= 1) {
if(pmPerType.h["buildings.StoneMine"] >= 15 && pmPerType.h["buildings.StoneTeleporter"] >= 3) {
this.fullyUnlock(buildings_StoneResearchCenter);
}
}
if(pmPerType.h["buildings.MechanicalHouse"] >= 4 && pmPerType.h["buildings.RefinedMetalFactory"] >= 3 && pmPerType.h["buildings.ComputerChipFactory"] >= 1) {
this.unlock(buildings_ExperimentationLab);
if(pmPerType.h["buildings.MechanicalHouse"] >= 12 && pmPerType.h["buildings.RefinedMetalFactory"] >= 10 && pmPerType.h["buildings.ComputerChipFactory"] >= 3) {
this.fullyUnlock(buildings_ExperimentationLab);
}
}
if(pmPerType.h["buildings.TheMachine"] >= 1 && pmPerType.h["buildings.FestivalHQ"] >= 1) {
this.unlock(buildings_FlowerPenthouse);
}
if(pmPerType.h["buildings.School"] >= 5) {
this.unlock(buildings_Library);
}
if(pmPerType.h["buildings.StatueOfHappiness"] >= 1) {
this.unlock(buildings_Beacon);
}
if(this.getUnlockState(buildings_BlossomHippieHQ) == progress_UnlockState.Unlocked) {
if(pmPerType.h["buildings.BotanicalGardens"] >= 20) {
var isOk = false;
var _g = 0;
var _g1 = this.city.permanents;
while(_g < _g1.length) {
var bld = _g1[_g];
++_g;
if(bld.is(buildings_BotanicalGardens)) {
var grd = bld;
if(grd.bottomBuilding == null || !grd.bottomBuilding.is(buildings_BotanicalGardens)) {
var topBld = grd.topBuilding;
var i = 1;
while(topBld != null && topBld.is(buildings_BotanicalGardens)) {
topBld = topBld.topBuilding;
++i;
}
if(i >= 20) {
isOk = true;
}
}
}
}
if(isOk) {
this.fullyUnlock(buildings_BlossomHippieHQ);
}
}
}
}
,checkStatRelatedUnlocks: function() {
if(this.city.simulation.stats.peopleWithHome >= 200) {
this.fullyUnlock(buildings_LivingResearchCenter);
}
if(this.city.simulation.citizens.length >= 200) {
this.fullyUnlock(buildings_HyperElevator);
}
if(this.city.simulation.happiness.happiness >= 99.99) {
if(this.unlock(buildings_StatueOfHappiness)) {
if(2 == 6) {
PokiSDK.happyTime(1);
}
}
}
if(this.city.simulation.citizens.length >= 500 && this.city.teleporters.length > 1) {
this.unlock(buildings_SecretSocietyHouse);
}
if(this.city.simulation.bonuses.fossilsCollected >= 5) {
this.unlock(buildings_FossilMuseum);
}
if(this.city.simulation.citizens.length >= 750) {
this.unlock(buildings_BlossomHippieHQ);
}
if(this.getUnlockState(buildings_Beacon) == progress_UnlockState.Unlocked) {
if(this.city.simulation.happiness.fullHappinessTime >= 20160) {
this.fullyUnlock(buildings_Beacon);
console.log("FloatingSpaceCities/progress/Unlocks.hx:492:","beacon_unlocked");
}
}
if(this.city.simulation.citizens.length >= 100) {
this.unlock(buildings_CityHall);
}
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
if(shouldSaveDefinition) {
queue.addString(progress_Unlocks.saveDefinition);
}
queue.addString(haxe_Serializer.run(this.unlockState));
queue.addString(haxe_Serializer.run(this.explicityLocked));
var value = this.unlockedDecorationTab;
if(queue.size + 1 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 1) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.b[queue.size] = value ? 1 : 0;
queue.size += 1;
var value = this.unlockedBuildingModeButton;
if(queue.size + 1 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 1) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.b[queue.size] = value ? 1 : 0;
queue.size += 1;
var value = this.unlockedManagementOptions;
if(queue.size + 1 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 1) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.b[queue.size] = value ? 1 : 0;
queue.size += 1;
var value = this.numberOfModernArtMuseumArtworksUnlocked;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
,load: function(queue,definition) {
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"unlockState")) {
this.unlockState = loadMap.h["unlockState"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"explicityLocked")) {
this.explicityLocked = loadMap.h["explicityLocked"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"unlockedDecorationTab")) {
this.unlockedDecorationTab = loadMap.h["unlockedDecorationTab"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"unlockedBuildingModeButton")) {
this.unlockedBuildingModeButton = loadMap.h["unlockedBuildingModeButton"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"unlockedManagementOptions")) {
this.unlockedManagementOptions = loadMap.h["unlockedManagementOptions"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"numberOfModernArtMuseumArtworksUnlocked")) {
this.numberOfModernArtMuseumArtworksUnlocked = loadMap.h["numberOfModernArtMuseumArtworksUnlocked"];
}
this.postLoad();
}
,__class__: progress_Unlocks
};
var progress_scriptedStoryParts_AlienInvasion = function(city,story) {
this.alienRayInited = false;
this.isInvasionFinished = false;
this.isInvasion = false;
this.invasionProgress = 0;
this.timeUntilInvasion = 0;
progress_ScriptedStoryPart.call(this,city,story);
};
$hxClasses["progress.scriptedStoryParts.AlienInvasion"] = progress_scriptedStoryParts_AlienInvasion;
progress_scriptedStoryParts_AlienInvasion.__name__ = "progress.scriptedStoryParts.AlienInvasion";
progress_scriptedStoryParts_AlienInvasion.__super__ = progress_ScriptedStoryPart;
progress_scriptedStoryParts_AlienInvasion.prototype = $extend(progress_ScriptedStoryPart.prototype,{
initialize: function($with) {
this.timeUntilInvasion = $with.timeUntilInvasion;
}
,update: function(timeMod) {
var _gthis = this;
if(!this.isInvasionFinished) {
if(this.isInvasion) {
this.invasionProgress += timeMod;
var alph = 0.0;
if(!this.alienRayInited) {
this.graphics = new PIXI.Graphics();
this.city.movingViewStage.addChild(this.graphics);
this.alienRayInited = true;
}
if(this.invasionProgress >= 30) {
this.city.mainMovingViewStage.alpha = 0;
alph = 1 - (this.invasionProgress - 30) / 30;
if(this.invasionProgress >= 60) {
this.city.progress.story.currentGoal = null;
this.loseAliens();
this.isInvasionFinished = true;
}
} else {
alph = this.invasionProgress / 30;
}
this.graphics.clear();
if(alph > 0) {
this.graphics.beginFill(4388075,alph);
var x1 = common_ArrayExtensions.min(this.city.worlds,function(w) {
return w.rect.x - 10;
}).rect.x - 10;
var w = common_ArrayExtensions.min(this.city.worlds,function(w) {
return w.rect.y - common_ArrayExtensions.max(w.permanents,function(p) {
return p.length * 20;
}).length * 20 - _gthis.city.game.rect.height * _gthis.city.game.scaling;
});
var y1 = w.rect.y - common_ArrayExtensions.max(w.permanents,function(p) {
return p.length * 20;
}).length * 20 - _gthis.city.game.rect.height * _gthis.city.game.scaling;
this.graphics.drawRect(x1,y1,common_ArrayExtensions.max(this.city.worlds,function(w) {
return w.rect.get_x2() + 10;
}).rect.get_x2() + 10 - x1,common_ArrayExtensions.max(this.city.worlds,function(w) {
return w.rect.get_y2();
}).rect.get_y2() + this.city.game.rect.height * this.city.game.scaling - y1);
this.graphics.endFill();
}
} else {
this.timeUntilInvasion -= timeMod;
this.isInvasion = true;
}
}
}
,loseAliens: function() {
var _gthis = this;
this.city.activateLoserState();
this.city.gui.createWindow();
this.city.gui.windowAddTitleText("You Lost!");
this.city.gui.windowAddInfoText("Aliens have destroyed your city blah blah.");
this.city.gui.windowAddBottomButtons(null,"Try Again");
this.city.gui.windowOnDestroy = function() {
_gthis.city.game.newCity(_gthis.city.progress.story.storyName,_gthis.city.cityFile);
};
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
progress_ScriptedStoryPart.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(progress_scriptedStoryParts_AlienInvasion.saveDefinition);
}
var value = this.timeUntilInvasion;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.invasionProgress;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.isInvasion;
if(queue.size + 1 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 1) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.b[queue.size] = value ? 1 : 0;
queue.size += 1;
var value = this.isInvasionFinished;
if(queue.size + 1 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 1) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.b[queue.size] = value ? 1 : 0;
queue.size += 1;
}
,load: function(queue,definition) {
progress_ScriptedStoryPart.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"timeUntilInvasion")) {
this.timeUntilInvasion = loadMap.h["timeUntilInvasion"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"invasionProgress")) {
this.invasionProgress = loadMap.h["invasionProgress"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"isInvasion")) {
this.isInvasion = loadMap.h["isInvasion"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"isInvasionFinished")) {
this.isInvasionFinished = loadMap.h["isInvasionFinished"];
}
}
,__class__: progress_scriptedStoryParts_AlienInvasion
});
var progress_scriptedStoryParts_SpawnCitizensRegularly = function(city,story) {
this.afterDoneMessage = null;
this.timeBetweenMax = 0;
this.timeBetweenMin = 0;
this.worldID = 0;
this.ageRangeMax = 0;
this.ageRangeMin = 0;
this.groupSizeMax = 1;
this.groupSizeMin = 0;
this.nextSpawn = 0;
this.spawnNumber = 0;
progress_ScriptedStoryPart.call(this,city,story);
};
$hxClasses["progress.scriptedStoryParts.SpawnCitizensRegularly"] = progress_scriptedStoryParts_SpawnCitizensRegularly;
progress_scriptedStoryParts_SpawnCitizensRegularly.__name__ = "progress.scriptedStoryParts.SpawnCitizensRegularly";
progress_scriptedStoryParts_SpawnCitizensRegularly.__super__ = progress_ScriptedStoryPart;
progress_scriptedStoryParts_SpawnCitizensRegularly.prototype = $extend(progress_ScriptedStoryPart.prototype,{
update: function(timeMod) {
if(this.spawnNumber > 0 && this.simulation.time.timeSinceStart >= this.nextSpawn) {
var val1 = this.spawnNumber;
var val2 = random_Random.getInt(this.groupSizeMin,this.groupSizeMax + 1);
var spawnAmount = val2 < val1 ? val2 : val1;
this.spawnNumber -= spawnAmount;
if(this.city.simulation.citizens.length < 200) {
var globalBoost = this.city.simulation.boostManager.currentGlobalBoostAmount;
if(globalBoost > 1.5) {
spawnAmount *= 2;
}
}
this.city.simulation.citizenSpawners.push(new simulation_SpawnFlyingSaucer(this.city.simulation,this.city.farForegroundStage,this.city.worlds[this.worldID],{ time : 0, type : "SpawnCitizensFlyingSaucer", amount : spawnAmount, ageRangeMin : this.ageRangeMin, ageRangeMax : this.ageRangeMax, world : this.worldID}));
var nextSpawnMultiplier = 1.0;
if(this.city.simulation.stats.houseCapacity > this.city.simulation.stats.peopleWithHome + this.groupSizeMin && this.city.simulation.stats.jobs > this.city.simulation.stats.laborForce + this.groupSizeMin && this.spawnNumber > 5) {
nextSpawnMultiplier = this.city.materials.food > 10 ? 0.6 : 0.7;
}
this.nextSpawn = this.simulation.time.timeSinceStart + 60 * nextSpawnMultiplier * random_Random.getFloat(this.timeBetweenMin,this.timeBetweenMax);
} else if(this.spawnNumber <= 0 && this.simulation.citizenSpawners.length == 0) {
if(this.afterDoneMessage != null && this.afterDoneMessage != "") {
if(this.city.gui.showSimpleWindow(this.afterDoneMessage,null,false,true)) {
HxOverrides.remove(this.story.scriptedParts,this);
}
} else {
HxOverrides.remove(this.story.scriptedParts,this);
}
}
}
,initialize: function($with) {
this.spawnNumber = $with.spawnNumber;
this.groupSizeMin = $with.groupSizeMin;
this.groupSizeMax = $with.groupSizeMax;
this.ageRangeMin = $with.ageRangeMin;
this.ageRangeMax = $with.ageRangeMax;
this.worldID = $with.world;
this.timeBetweenMin = $with.timeBetweenMin;
this.timeBetweenMax = $with.timeBetweenMax;
this.afterDoneMessage = $with.afterDoneMessage;
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
progress_ScriptedStoryPart.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(progress_scriptedStoryParts_SpawnCitizensRegularly.saveDefinition);
}
var value = this.spawnNumber;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.nextSpawn;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.groupSizeMin;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.groupSizeMax;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.ageRangeMin;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.ageRangeMax;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.worldID;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.timeBetweenMin;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.timeBetweenMax;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
queue.addString(this.afterDoneMessage);
}
,load: function(queue,definition) {
progress_ScriptedStoryPart.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"spawnNumber")) {
this.spawnNumber = loadMap.h["spawnNumber"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"nextSpawn")) {
this.nextSpawn = loadMap.h["nextSpawn"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"groupSizeMin")) {
this.groupSizeMin = loadMap.h["groupSizeMin"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"groupSizeMax")) {
this.groupSizeMax = loadMap.h["groupSizeMax"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"ageRangeMin")) {
this.ageRangeMin = loadMap.h["ageRangeMin"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"ageRangeMax")) {
this.ageRangeMax = loadMap.h["ageRangeMax"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"worldID")) {
this.worldID = loadMap.h["worldID"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"timeBetweenMin")) {
this.timeBetweenMin = loadMap.h["timeBetweenMin"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"timeBetweenMax")) {
this.timeBetweenMax = loadMap.h["timeBetweenMax"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"afterDoneMessage")) {
this.afterDoneMessage = loadMap.h["afterDoneMessage"];
}
}
,__class__: progress_scriptedStoryParts_SpawnCitizensRegularly
});
var progress_worldGenerators_RandomMiniWorlds = function() { };
$hxClasses["progress.worldGenerators.RandomMiniWorlds"] = progress_worldGenerators_RandomMiniWorlds;
progress_worldGenerators_RandomMiniWorlds.__name__ = "progress.worldGenerators.RandomMiniWorlds";
progress_worldGenerators_RandomMiniWorlds.doGenerate = function(generatorArgs,city,storyInfo,cityStage,cityMidStage,cityBgStage) {
var numberOfWorldsMin = generatorArgs.numberOfWorldsMin;
var numberOfWorldsMax = generatorArgs.numberOfWorldsMax;
var minX = generatorArgs.minX;
var minY = generatorArgs.minY;
var maxX = generatorArgs.maxX;
var maxY = generatorArgs.maxY;
var minWidth = generatorArgs.minWidth;
var maxWidth = generatorArgs.maxWidth;
var minHeight = generatorArgs.minHeight;
var maxHeight = generatorArgs.maxHeight;
var heightVariation = generatorArgs.heightVariation;
var allAddedWorlds = [];
var _g = 0;
var _g1 = random_Random.getInt(numberOfWorldsMin,numberOfWorldsMax);
while(_g < _g1) {
var i = _g++;
var tries = 0;
while(++tries < 10000) {
var xx = random_Random.getInt(minX / 20 | 0,(maxX / 20 | 0) + 1) * 20;
var yy = random_Random.getInt(minY / 20 | 0,(maxY / 20 | 0) + 1) * 20;
var ww = random_Random.getInt(minWidth / 20 | 0,(maxWidth / 20 | 0) + 1) * 20;
var val = Math.round(((ww - minWidth) / (maxWidth - minWidth) * (maxHeight - minHeight) + minHeight + random_Random.getInt(heightVariation)) / 20);
var hh = (val < 1 ? 1 : val > 100 ? 100 : val) * 20;
var canCreateWorld = true;
var _g2 = 0;
var _g3 = city.worlds;
while(_g2 < _g3.length) {
var otherWorld = _g3[_g2];
++_g2;
if(otherWorld.rect.intersects(new common_Rectangle(xx - 20,yy - 40,ww + 41,hh + 61))) {
canCreateWorld = false;
break;
}
}
if(!canCreateWorld) {
continue;
}
var newWorld = new World(city.game,city,cityStage,cityMidStage,cityBgStage,new common_Rectangle(xx,yy,ww,hh),random_Random.getInt(1000000));
city.worlds.push(newWorld);
allAddedWorlds.push(newWorld);
break;
}
if(tries >= 1000) {
console.log("FloatingSpaceCities/progress/worldGenerators/RandomMiniWorlds.hx:48:","world not generated; max # of tries exceeded - RandomMiniWorlds.doGenerate with args:");
console.log("FloatingSpaceCities/progress/worldGenerators/RandomMiniWorlds.hx:49:",generatorArgs);
}
}
var buildOnWorlds = allAddedWorlds.slice();
var createPermanents = [];
var _g = 0;
var _g1 = generatorArgs.initialBuildings;
while(_g < _g1.length) {
var initialBuilding = _g1[_g];
++_g;
var _g2 = 0;
var _g3 = random_Random.getInt(initialBuilding.numberMin,initialBuilding.numberMax);
while(_g2 < _g3) {
var i = _g2++;
var name = "buildings." + Std.string(initialBuilding.className);
createPermanents.push($hxClasses[name]);
}
}
var _g = 0;
var _g1 = generatorArgs.initialWorldResources;
while(_g < _g1.length) {
var initialWR = _g1[_g];
++_g;
var _g2 = 0;
var _g3 = random_Random.getInt(initialWR.numberMin,initialWR.numberMax);
while(_g2 < _g3) {
var i = _g2++;
var name = "worldResources." + Std.string(initialWR.className);
createPermanents.push($hxClasses[name]);
}
}
var handledAllBuildings = false;
var _g = 0;
while(_g < createPermanents.length) {
var pm = createPermanents[_g];
++_g;
var pmIsBuilding = pm.__name__.indexOf("buildings.") != -1;
if(!handledAllBuildings && !pmIsBuilding) {
if(generatorArgs.rememberWorldSpreadBetweenBuildingsAndWorldResources) {
buildOnWorlds = allAddedWorlds.slice();
}
handledAllBuildings = true;
}
var buildOptions = [];
var tries = 0;
while(++tries <= 2) {
var worldArrayToUse = allAddedWorlds;
if(generatorArgs.spreadBuildingsEvenlyBetweenWorlds && pmIsBuilding || generatorArgs.spreadWorldResourcesEvenlyBetweenWorlds && !pmIsBuilding) {
worldArrayToUse = buildOnWorlds;
}
var _g1 = 0;
while(_g1 < worldArrayToUse.length) {
var world = worldArrayToUse[_g1];
++_g1;
var pmPositionsFree = 0;
var _g2 = 0;
var _g3 = world.permanents.length;
while(_g2 < _g3) {
var xx = _g2++;
var pmStack = world.permanents[xx];
if(pmStack.length == 0) {
++pmPositionsFree;
}
}
if(pmIsBuilding || (!generatorArgs.avoidGeneratingOverfullWorlds || world.permanents.length > 1 && pmPositionsFree > 1)) {
var _g4 = 0;
var _g5 = world.permanents.length;
while(_g4 < _g5) {
var xx1 = _g4++;
var pmStack1 = world.permanents[xx1];
if(pmStack1.length == 0) {
buildOptions.push({ world : world, xPos : xx1});
}
}
}
}
if(buildOptions.length == 0) {
buildOnWorlds = allAddedWorlds.slice();
} else {
break;
}
}
if(buildOptions.length > 0) {
var chosenOption = random_Random.fromArray(buildOptions);
HxOverrides.remove(buildOnWorlds,chosenOption.world);
if(pmIsBuilding) {
chosenOption.world.build(pm,chosenOption.xPos);
} else {
chosenOption.world.createWorldResource(pm,chosenOption.xPos);
}
}
}
};
var random_Random = function() { };
$hxClasses["random.Random"] = random_Random;
random_Random.__name__ = "random.Random";
random_Random.getFloat = function(val0,val1) {
var min = 0;
var max = 1;
if(val0 != null && val1 != null) {
min = val0;
max = val1;
} else if(val0 != null) {
max = val0;
}
return Math.random() * (max - min) + min;
};
random_Random.getInt = function(val0,val1) {
var min = 0;
var max = 2147483647;
if(val0 != null && val1 != null) {
min = val0;
max = val1;
} else if(val0 != null) {
max = val0;
}
return Math.floor(Math.random() * (max - min)) + min;
};
random_Random.fromArray = function(arr) {
if(arr.length == 0) {
throw haxe_Exception.thrown("You can't get a random item from an empty array!");
}
return arr[random_Random.getInt(arr.length)];
};
var random_SeedeableRandom = function(seed) {
var x = this.seed = seed == null ? Std.random(2147483647) : seed;
var this1 = new haxe__$Int64__$_$_$Int64(x >> 31,x);
this.state0 = this1;
var this1 = new haxe__$Int64__$_$_$Int64(0,89432);
this.state1 = this1;
};
$hxClasses["random.SeedeableRandom"] = random_SeedeableRandom;
random_SeedeableRandom.__name__ = "random.SeedeableRandom";
random_SeedeableRandom.prototype = {
getInt64: function() {
var s0 = this.state0;
var s1 = this.state1;
this.state0 = s1;
var b = 23;
b &= 63;
var b1;
if(b == 0) {
var this1 = new haxe__$Int64__$_$_$Int64(s1.high,s1.low);
b1 = this1;
} else if(b < 32) {
var this1 = new haxe__$Int64__$_$_$Int64(s1.high << b | s1.low >>> 32 - b,s1.low << b);
b1 = this1;
} else {
var this1 = new haxe__$Int64__$_$_$Int64(s1.low << b - 32,0);
b1 = this1;
}
var this1 = new haxe__$Int64__$_$_$Int64(s1.high ^ b1.high,s1.low ^ b1.low);
s1 = this1;
var b = 18;
b &= 63;
var b1;
if(b == 0) {
var this1 = new haxe__$Int64__$_$_$Int64(s1.high,s1.low);
b1 = this1;
} else if(b < 32) {
var this1 = new haxe__$Int64__$_$_$Int64(s1.high >> b,s1.high << 32 - b | s1.low >>> b);
b1 = this1;
} else {
var this1 = new haxe__$Int64__$_$_$Int64(s1.high >> 31,s1.high >> b - 32);
b1 = this1;
}
var this1 = new haxe__$Int64__$_$_$Int64(s1.high ^ b1.high,s1.low ^ b1.low);
s1 = this1;
var this1 = new haxe__$Int64__$_$_$Int64(s1.high ^ s0.high,s1.low ^ s0.low);
s1 = this1;
var b = 5;
b &= 63;
var b1;
if(b == 0) {
var this1 = new haxe__$Int64__$_$_$Int64(s0.high,s0.low);
b1 = this1;
} else if(b < 32) {
var this1 = new haxe__$Int64__$_$_$Int64(s0.high >> b,s0.high << 32 - b | s0.low >>> b);
b1 = this1;
} else {
var this1 = new haxe__$Int64__$_$_$Int64(s0.high >> 31,s0.high >> b - 32);
b1 = this1;
}
var this1 = new haxe__$Int64__$_$_$Int64(s1.high ^ b1.high,s1.low ^ b1.low);
s1 = this1;
this.state1 = s1;
var a = this.state0;
var b = this.state1;
var high = a.high + b.high | 0;
var low = a.low + b.low | 0;
if(haxe_Int32.ucompare(low,a.low) < 0) {
var ret = high++;
high = high | 0;
}
var this1 = new haxe__$Int64__$_$_$Int64(high,low);
return this1;
}
,getInt: function(val0,val1) {
var min = 0;
var max = 2147483647;
if(val0 != null && val1 != null) {
min = val0;
max = val1;
} else if(val0 != null) {
max = val0;
}
var a = this.getInt64();
var b = 1;
b &= 63;
var a1;
if(b == 0) {
var this1 = new haxe__$Int64__$_$_$Int64(a.high,a.low);
a1 = this1;
} else if(b < 32) {
var this1 = new haxe__$Int64__$_$_$Int64(a.high >>> b,a.high << 32 - b | a.low >>> b);
a1 = this1;
} else {
var this1 = new haxe__$Int64__$_$_$Int64(0,a.high >>> b - 32);
a1 = this1;
}
var x = max - min;
var this1 = new haxe__$Int64__$_$_$Int64(x >> 31,x);
var x = haxe_Int64.divMod(a1,this1).modulus;
if(x.high != x.low >> 31) {
throw haxe_Exception.thrown("Overflow");
}
return min + x.low;
}
,getFloat: function(val0,val1) {
var min = 0;
var max = 1;
if(val0 != null && val1 != null) {
min = val0;
max = val1;
} else if(val0 != null) {
max = val0;
}
var rndVal = this.getInt64();
return Math.abs(rndVal.low / 2147483647) * (max - min) + min;
}
,__class__: random_SeedeableRandom
};
var simulation_BabyMaker = function(city,simulation) {
this.totalBabyMakeCapacity = 0;
this.targetPopAmount = -1;
this.mode = 0;
this.softPopLimit = 2000;
this.updateStatsIn = -2;
this.city = city;
this.simulation = simulation;
this.babyMakerCapacity = new haxe_ds_ObjectMap();
this.babiesPerYear = new haxe_ds_ObjectMap();
};
$hxClasses["simulation.BabyMaker"] = simulation_BabyMaker;
simulation_BabyMaker.__name__ = "simulation.BabyMaker";
simulation_BabyMaker.prototype = {
getCurrentBabyProduction: function() {
if(this.simulation.happiness.happiness < 10 && this.simulation.stats.peopleWithHome < this.simulation.stats.people / 2 && this.city.materials.food < 1) {
return 0.0;
}
if(this.simulation.happiness.happiness < 10) {
return 0.8;
}
switch(this.mode) {
case 0:
return 1 + this.simulation.happiness.happiness / 140 / Math.pow((Math.pow(this.simulation.citizens.length,1.2) + 500) / 1400,0.4);
case 1:
if(this.targetPopAmount == -1) {
return 1;
} else if(this.simulation.citizens.length >= this.targetPopAmount) {
return 0.1;
} else {
return 3.0;
}
break;
case 2:
return 1 + 0.4 * (this.simulation.happiness.happiness / 140) / Math.pow((Math.pow(this.simulation.citizens.length,1.2) + 500) / 1400,0.4);
case 3:
return 1 + (this.simulation.happiness.happiness / 140 + Math.max(0,(this.simulation.happiness.happiness - 60) / 120)) / Math.pow((Math.pow(this.simulation.citizens.length,1.2) + 500) / 1400,0.4);
}
}
,update: function(timeMod) {
if(this.updateStatsIn <= 0) {
this.updateStatsIn += 60;
this.updateStats();
}
this.updateStatsIn -= timeMod;
var yearsPast = this.simulation.time.minutesPerTick * timeMod / 60 / 24;
var _g = 0;
var _g1 = this.city.worlds;
while(_g < _g1.length) {
var w = _g1[_g];
++_g;
if(this.simulation.citizens.length < this.softPopLimit && this.simulation.citizens.length >= 2 && this.babyMakerCapacity.h[w.__id__] >= 2 && random_Random.getFloat() < this.babiesPerYear.h[w.__id__] * yearsPast) {
this.createBaby(w);
}
}
}
,createBaby: function(w) {
if(this.simulation.citizens.length == 0) {
return;
}
var possibleParent = common_ArrayExtensions.findRandom(this.simulation.citizens,function(c) {
if(c.onWorld == w && c.get_age() >= 20) {
return c.get_age() < 55;
} else {
return false;
}
});
var fatherOrMother = this.simulation.citizens[0];
if(possibleParent != null) {
fatherOrMother = possibleParent;
}
this.simulation.createCitizen(fatherOrMother.onWorld,0,fatherOrMother.inPermanent,fatherOrMother.relativeX | 0);
}
,onCitizenDeath: function() {
if(this.simulation.citizens.length == this.softPopLimit) {
if(this.totalBabyMakeCapacity != 0) {
var r = random_Random.getFloat();
var w = this.city.worlds[0];
var _g = 0;
var _g1 = this.city.worlds;
while(_g < _g1.length) {
var wrld = _g1[_g];
++_g;
r -= this.babyMakerCapacity.h[wrld.__id__] / this.totalBabyMakeCapacity;
if(r <= 0) {
w = wrld;
}
}
this.createBaby(w);
}
}
}
,updateStats: function() {
var _g = 0;
var _g1 = this.city.worlds;
while(_g < _g1.length) {
var w = _g1[_g];
++_g;
this.babyMakerCapacity.set(w,0);
}
var _g = 0;
var _g1 = this.simulation.citizens;
while(_g < _g1.length) {
var c = _g1[_g];
++_g;
var _g2 = c.onWorld;
var _g3 = this.babyMakerCapacity;
var v = _g3.h[_g2.__id__] + (c.get_age() >= 20 && c.get_age() < 45 ? 1 : c.get_age() >= 45 && c.get_age() < 55 ? 1 - (c.get_age() - 45) / 10 : 0);
_g3.set(_g2,v);
}
var _g = 0;
var _g1 = this.city.worlds;
while(_g < _g1.length) {
var w = _g1[_g];
++_g;
var currentBabiesPerPerson = this.getCurrentBabyProduction();
var v = this.babyMakerCapacity.h[w.__id__] * currentBabiesPerPerson / 30.;
this.babiesPerYear.set(w,v);
this.totalBabyMakeCapacity += this.babyMakerCapacity.h[w.__id__];
}
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
if(shouldSaveDefinition) {
queue.addString(simulation_BabyMaker.saveDefinition);
}
var value = this.softPopLimit;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
queue.addString(haxe_Serializer.run(this.mode));
var value = this.targetPopAmount;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
,load: function(queue,definition) {
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"softPopLimit")) {
this.softPopLimit = loadMap.h["softPopLimit"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"mode")) {
this.mode = loadMap.h["mode"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"targetPopAmount")) {
this.targetPopAmount = loadMap.h["targetPopAmount"];
}
}
,__class__: simulation_BabyMaker
};
var simulation_BonusResults = function() {
this.fossilsCollected = 0;
this.indoorFarmSpeed = 1;
this.labSpeed = 1;
this.machinePartsFactorySpeed = 1;
this.extraFoodFromFarms = 0;
};
$hxClasses["simulation.BonusResults"] = simulation_BonusResults;
simulation_BonusResults.__name__ = "simulation.BonusResults";
simulation_BonusResults.prototype = {
save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
if(shouldSaveDefinition) {
queue.addString(simulation_BonusResults.saveDefinition);
}
var value = this.extraFoodFromFarms;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.machinePartsFactorySpeed;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.labSpeed;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.indoorFarmSpeed;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.fossilsCollected;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
,load: function(queue,definition) {
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"extraFoodFromFarms")) {
this.extraFoodFromFarms = loadMap.h["extraFoodFromFarms"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"machinePartsFactorySpeed")) {
this.machinePartsFactorySpeed = loadMap.h["machinePartsFactorySpeed"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"labSpeed")) {
this.labSpeed = loadMap.h["labSpeed"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"indoorFarmSpeed")) {
this.indoorFarmSpeed = loadMap.h["indoorFarmSpeed"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"fossilsCollected")) {
this.fossilsCollected = loadMap.h["fossilsCollected"];
}
}
,__class__: simulation_BonusResults
};
var simulation_ExtraBoostType = $hxEnums["simulation.ExtraBoostType"] = { __ename__ : "simulation.ExtraBoostType", __constructs__ : ["DoubleBoost","TripleBoost","DoubleMaterialReward","TripleMaterialReward"]
,DoubleBoost: {_hx_index:0,__enum__:"simulation.ExtraBoostType",toString:$estr}
,TripleBoost: {_hx_index:1,__enum__:"simulation.ExtraBoostType",toString:$estr}
,DoubleMaterialReward: {_hx_index:2,__enum__:"simulation.ExtraBoostType",toString:$estr}
,TripleMaterialReward: {_hx_index:3,__enum__:"simulation.ExtraBoostType",toString:$estr}
};
var simulation_BoostManager = function(simulation) {
this.timeUntilNextExtraBoost = 0;
this.claimedExtraBoostType = null;
this.currentExtraBoostLeft = 0;
this.currentExtraBoostType = null;
this.currentExtraBoostArrow = null;
this.disableRewardedAd = false;
this.currentGlobalBoostAmount = 1.0;
this.infoButtonShown = false;
this.infoButtonParent = null;
this.normalMaxBoost = 10800;
this.maxBoost = 10800;
this.boostLeft = 0;
this.simulation = simulation;
this.city = simulation.city;
if(2 == 6) {
this.maxBoost = 7200;
this.normalMaxBoost = 7200;
} else if(2 == 8) {
this.normalMaxBoost = 14400;
}
this.timeUntilNextExtraBoost = 36000 + random_Random.getFloat(36000);
};
$hxClasses["simulation.BoostManager"] = simulation_BoostManager;
simulation_BoostManager.__name__ = "simulation.BoostManager";
simulation_BoostManager.prototype = {
update: function(timeMod) {
if(this.boostLeft > 0) {
this.boostLeft -= timeMod;
this.currentGlobalBoostAmount = 2.0;
} else {
this.currentGlobalBoostAmount = 1;
}
if(this.infoButtonParent != null) {
if(this.boostLeft > 0 || this.boostAvailable()) {
if(!this.infoButtonShown) {
this.infoButtonShown = true;
this.actuallyCreateBoostButton();
}
} else if(this.infoButtonShown) {
this.infoButtonShown = false;
this.infoButtonParent.removeChild(this.infoButton);
this.infoButton = null;
}
}
this.optionallyCreateExtraBoost(timeMod);
}
,optionallyCreateExtraBoost: function(timeMod) {
if(this.city.simulationSpeed < 0.1 || this.city.pauseGame) {
return;
}
if(this.city.game.isMobile) {
return;
}
if(2 != 6) {
return;
}
var actualTimeMod = timeMod / (this.city.simulationSpeed * 0.6666666666666666666);
if(this.currentExtraBoostArrow == null) {
if(this.infoButton != null && this.boostAvailable()) {
if(this.timeUntilNextExtraBoost <= 0) {
this.createExtraBoost();
this.timeUntilNextExtraBoost = 54000 + random_Random.getFloat(36000);
}
}
this.timeUntilNextExtraBoost -= timeMod;
} else {
this.currentExtraBoostLeft -= actualTimeMod;
if(this.currentExtraBoostLeft <= 0) {
this.destroyExtraBoost();
} else {
this.currentExtraBoostArrow.update(timeMod);
this.currentExtraBoostArrow.addText(this.getExtraBoostTypeText() + " Claim within " + (this.currentExtraBoostLeft / 60 | 0) + "s.");
}
}
}
,getExtraBoostTypeText: function() {
if(this.currentExtraBoostType == null) {
return "";
}
switch(this.currentExtraBoostType._hx_index) {
case 0:
return "2x boost duration!";
case 1:
return "3x boost duration!";
case 2:
return "Double bonus resources!";
case 3:
return "Triple bonus resources!";
}
}
,getSpecialSuccessText: function() {
if(this.claimedExtraBoostType == null) {
return "";
}
switch(this.claimedExtraBoostType._hx_index) {
case 0:
return "You successfully claimed a special boost. This boost will last twice as long!";
case 1:
return "You successfully claimed a special boost. This boost will last three times as long!";
case 2:
return "You successfully claimed a special boost. The bonus resource reward above has been doubled!";
case 3:
return "You successfully claimed a special boost. The bonus resource reward above has been tripled!";
}
}
,destroyExtraBoost: function() {
if(this.currentExtraBoostArrow != null) {
this.currentExtraBoostArrow.destroy();
this.currentExtraBoostArrow = null;
}
this.currentExtraBoostLeft = 0;
this.currentExtraBoostType = null;
}
,createExtraBoost: function() {
var _gthis = this;
if(this.currentExtraBoostArrow == null) {
this.currentExtraBoostArrow = new gui_HelpArrow(this.city.gui,this.city.gui.stage,function() {
if(!_gthis.infoButtonShown) {
return null;
}
return _gthis.infoButton;
},function() {
return true;
},gui_HelpArrowDirection.DownHint);
this.currentExtraBoostType = random_Random.fromArray([simulation_ExtraBoostType.DoubleBoost,simulation_ExtraBoostType.DoubleBoost,simulation_ExtraBoostType.DoubleBoost,simulation_ExtraBoostType.TripleBoost,simulation_ExtraBoostType.DoubleMaterialReward,simulation_ExtraBoostType.TripleMaterialReward]);
var duration = 16;
this.currentExtraBoostArrow.addText(this.getExtraBoostTypeText() + " Claim within " + duration + "s.");
this.currentExtraBoostLeft = duration * 60;
}
}
,boostAvailable: function() {
if(common_AdHelper.adAvailableRewarded() && this.boostLeft <= 0) {
return !this.disableRewardedAd;
} else {
return false;
}
}
,actuallyCreateBoostButton: function() {
var _gthis = this;
var parent = this.infoButtonParent;
var stage = this.city.gui.stage;
var theGUI = this.city.gui;
var onClick = function() {
if(_gthis.boostLeft <= 0 && _gthis.boostAvailable()) {
if(_gthis.currentExtraBoostType != null && _gthis.currentExtraBoostLeft >= 0) {
_gthis.claimedExtraBoostType = _gthis.currentExtraBoostType;
_gthis.destroyExtraBoost();
}
common_AdHelper.showRewardedInterstitial(function() {
_gthis.boostLeft = _gthis.normalMaxBoost;
_gthis.maxBoost = _gthis.normalMaxBoost;
var specialBoostText = "";
var extraRewardMultiplier = 1;
if(_gthis.claimedExtraBoostType != null) {
switch(_gthis.claimedExtraBoostType._hx_index) {
case 0:
_gthis.boostLeft *= 2;
_gthis.maxBoost *= 2;
break;
case 1:
_gthis.boostLeft *= 3;
_gthis.maxBoost *= 3;
break;
case 2:
extraRewardMultiplier *= 2;
break;
case 3:
extraRewardMultiplier *= 3;
break;
}
specialBoostText = _gthis.getSpecialSuccessText();
_gthis.claimedExtraBoostType = null;
}
if(simulation_BoostManager.enableExtraReward) {
var mouse = _gthis.city.game.mouse;
mouse.resetPosition();
var extraReward = _gthis.getRandomReward(extraRewardMultiplier);
extraReward.materials.addToProduction(_gthis.city.simulation.stats);
_gthis.city.materials.add(extraReward.materials);
var createAdRewardWindow = null;
createAdRewardWindow = function() {
_gthis.city.gui.createWindow("adRewardWindow");
_gthis.city.gui.setWindowReload(createAdRewardWindow);
gui_AdRewardWindow.create(_gthis.city,_gthis.city.gui,_gthis.city.gui.innerWindowStage,_gthis.city.gui.windowInner,extraReward,specialBoostText);
};
createAdRewardWindow();
}
},function() {
_gthis.city.gui.showSimpleWindow("Sorry, the Boost failed to load! Please try again later.");
});
}
};
var onHover = function() {
if(_gthis.boostLeft > 0) {
theGUI.tooltip.setText("Boost","All resource production is now doubled!","Boost Active");
} else {
theGUI.tooltip.setText("Boost","Double your resource production for a while by watching a short ad!" + (simulation_BoostManager.enableExtraReward ? "\nPlus, instantly get a random extra resource reward!" : ""));
}
};
var getAmount = function() {
return "Boost";
};
var textureName = "spr_icon_boost";
var minWidth = 20;
var isActive = function() {
return _gthis.boostLeft > 0;
};
this.infoButton = new gui_ContainerButtonWithProgress(this.city.gui,stage,parent,onClick,isActive,onHover,"spr_transparentbutton_info",10526880,16777215,function() {
if(_gthis.boostLeft <= 0) {
return -1;
}
var val = _gthis.boostLeft / _gthis.maxBoost;
if(val < 0) {
return 0;
} else if(val > 1) {
return 1;
} else {
return val;
}
});
this.infoButton.container.fillSecondarySize = true;
var extraSpacing = theGUI.game.isMobile ? 3 : 0;
var extraSpacingText = theGUI.game.isMobile ? 2 : 0;
this.infoButton.container.padding = { left : 2 + extraSpacing, right : extraSpacing + 3, top : extraSpacing + 2, bottom : extraSpacing + 1};
this.infoButton.container.updateSize();
this.infoButton.container.addChild(new gui_ContainerHolder(this.infoButton.container,stage,new PIXI.Sprite(Resources.getTexture(textureName))));
this.infoButton.container.addChild(new gui_TextElement(this.infoButton.container,stage,null,getAmount,"Arial15",{ left : 1 + extraSpacingText, right : 0, top : 2, bottom : 0}));
this.infoButton.container.minWidth = minWidth;
parent.insertChild(this.infoButton,0);
return this.infoButton;
}
,getRandomReward: function(extraRewardMultiplier) {
var rewardText = "";
var rewardMaterials = new Materials();
var canGiveMachineParts = false;
var canGiveRefinedMetal = false;
var canGiveComputerChips = false;
var baseRewardMaxI = 11;
if(this.city.materials.machineParts > 0.2) {
baseRewardMaxI = 16;
canGiveMachineParts = true;
}
if(this.city.materials.refinedMetal > 0.2) {
baseRewardMaxI = 19;
canGiveRefinedMetal = true;
}
if(this.city.materials.computerChips > 0.2) {
baseRewardMaxI = 22;
canGiveComputerChips = true;
}
var baseRewardI = random_Random.getInt(baseRewardMaxI);
switch(baseRewardI) {
case 0:
rewardText = "Lunchbox";
rewardMaterials.add(new Materials(0,0,10));
break;
case 1:
rewardText = "Pile of Wood";
rewardMaterials.add(new Materials(25));
break;
case 2:
rewardText = "Book";
rewardMaterials.add(new Materials(0,0,0,0,15));
break;
case 3:
rewardText = "Alien Candy Bar";
rewardMaterials.add(new Materials(0,0,15,0,5));
break;
case 4:
rewardText = "Rock";
rewardMaterials.add(new Materials(0,20,0,0,0));
break;
case 5:
rewardText = "Pile of Materials";
rewardMaterials.add(new Materials(random_Random.getInt(10,30),random_Random.getInt(10,30),0,0,0));
break;
case 6:
rewardText = "Flower";
rewardMaterials.add(new Materials(5,0,0,0,9));
break;
case 7:
rewardText = "Statue";
rewardMaterials.add(new Materials(0,15,0,0,7));
break;
case 8:
rewardText = "Comet";
rewardMaterials.add(new Materials(0,20,0,0,15));
break;
case 9:
rewardText = "Brick";
rewardMaterials.add(new Materials(0,25,0,0));
break;
case 10:
rewardText = random_Random.fromArray(["Cabbage","Potato","Carrot","Bread"]);
rewardMaterials.add(new Materials(0,0,7));
break;
case 11:
rewardText = "Box of Wires";
rewardMaterials.add(new Materials(5,0,0,10,0));
break;
case 12:
rewardText = "Toolbox";
rewardMaterials.add(new Materials(0,12,0,9));
break;
case 13:
rewardText = "Mechanical Pear";
rewardMaterials.add(new Materials(0,0,1,1,20));
break;
case 14:
rewardText = "Beeping Device";
rewardMaterials.add(new Materials(0,10,0,5,2));
break;
case 15:
rewardText = "Robot Arm";
rewardMaterials.add(new Materials(0,10,0,10,25));
break;
case 16:
rewardText = "Sphere";
rewardMaterials.add(new Materials(0,0,0,0,10,10,0));
break;
case 17:
rewardText = "Gem";
rewardMaterials.add(new Materials(0,0,0,0,0,20,0));
break;
case 18:
rewardText = "Pile of Pebbles";
rewardMaterials.add(new Materials(0,40,0,0,0,10,0));
break;
case 19:
rewardText = "Laptop";
rewardMaterials.add(new Materials(0,0,0,5,0,4,1));
break;
case 20:
rewardText = "UFO";
rewardMaterials.add(new Materials(0,0,0,0,15,5,2));
break;
case 21:
rewardText = "Flashing Box";
rewardMaterials.add(new Materials(0,20,0,0,8,0,1));
break;
}
var extraWordR = random_Random.getFloat(0.8);
var addedExtra = false;
if(extraWordR < 0.05 && !addedExtra) {
rewardText = "Big " + rewardText;
rewardMaterials.multiply(1.5);
addedExtra = true;
}
extraWordR -= 0.05;
if(extraWordR < 0.04 && !addedExtra) {
rewardText = "Mega " + rewardText;
rewardMaterials.multiply(2);
addedExtra = true;
}
extraWordR -= 0.04;
if(extraWordR < 0.02 && !addedExtra) {
rewardText = "Giant " + rewardText;
rewardMaterials.multiply(3);
addedExtra = true;
}
extraWordR -= 0.02;
if(extraWordR < 0.02 && !addedExtra) {
rewardText = "Smart " + rewardText;
rewardMaterials.knowledge += 5;
if(canGiveComputerChips) {
rewardMaterials.computerChips += 1;
}
addedExtra = true;
}
extraWordR -= 0.02;
if(extraWordR < 0.01 && canGiveComputerChips && !addedExtra) {
rewardText = "Network-Connected " + rewardText;
rewardMaterials.computerChips += 2;
addedExtra = true;
}
extraWordR -= 0.01;
if(extraWordR < 0.02 && !addedExtra) {
rewardText = "Edible " + rewardText;
var _g = rewardMaterials;
_g.set_food(_g.food + 20);
addedExtra = true;
}
extraWordR -= 0.02;
if(extraWordR < 0.02 && !addedExtra) {
rewardText = "Slimy " + rewardText;
var _g = rewardMaterials;
_g.set_food(_g.food + 5);
addedExtra = true;
}
extraWordR -= 0.02;
if(extraWordR < 0.02 && canGiveRefinedMetal && !addedExtra) {
rewardText = "Cold " + rewardText;
rewardMaterials.refinedMetal += 5;
addedExtra = true;
}
extraWordR -= 0.02;
if(extraWordR < 0.02 && canGiveMachineParts && !addedExtra && rewardText.indexOf("Mechanical") == -1) {
rewardText = "Mechanical " + rewardText;
rewardMaterials.machineParts += 6;
addedExtra = true;
}
extraWordR -= 0.02;
if(extraWordR < 0.02 && !addedExtra) {
rewardText = "Growing " + rewardText;
rewardMaterials.wood += 20;
rewardMaterials.multiply(1.5);
addedExtra = true;
}
extraWordR -= 0.02;
if(extraWordR < 0.02 && !addedExtra && canGiveRefinedMetal) {
rewardText = "Metal " + rewardText;
rewardMaterials.refinedMetal += 4;
addedExtra = true;
}
extraWordR -= 0.02;
if(extraWordR < 0.02 && !addedExtra) {
rewardText = "Musical " + rewardText;
rewardMaterials.wood += 5;
rewardMaterials.knowledge += 10;
addedExtra = true;
}
extraWordR -= 0.02;
if(extraWordR < 0.02 && !addedExtra) {
rewardText = "Paper " + rewardText;
rewardMaterials.multiply(0.5);
rewardMaterials.knowledge += 15;
addedExtra = true;
}
extraWordR -= 0.02;
if(extraWordR < 0.02 && !addedExtra && canGiveMachineParts) {
rewardText = "Rotating " + rewardText;
rewardMaterials.machineParts += 10;
addedExtra = true;
}
extraWordR -= 0.02;
if(extraWordR < 0.03 && !addedExtra) {
rewardText = "Cool-Looking " + rewardText;
rewardMaterials.multiply(2.2);
rewardMaterials.knowledge += 1;
addedExtra = true;
}
extraWordR -= 0.03;
if(extraWordR < 0.02 && !addedExtra && canGiveComputerChips) {
rewardText = "IOT " + rewardText;
rewardMaterials.computerChips += 1;
addedExtra = true;
}
extraWordR -= 0.02;
if(extraWordR < 0.02 && !addedExtra) {
rewardText = "Overgrown " + rewardText;
rewardMaterials.wood *= 3;
rewardMaterials.wood += 20;
addedExtra = true;
}
extraWordR -= 0.02;
if(extraWordR < 0.01 && !addedExtra) {
rewardText = "Tiny " + rewardText;
rewardMaterials.multiply(0.75);
addedExtra = true;
}
extraWordR -= 0.01;
if(extraWordR < 0.02 && !addedExtra && canGiveComputerChips) {
rewardText = "Luminous " + rewardText;
rewardMaterials.computerChips += 1;
rewardMaterials.knowledge += 2;
addedExtra = true;
}
extraWordR -= 0.02;
if(extraWordR < 0.02 && !addedExtra) {
rewardText = "Dark " + rewardText;
rewardMaterials.knowledge += 5;
rewardMaterials.stone += 2;
addedExtra = true;
}
extraWordR -= 0.02;
if(extraWordR < 0.02 && !addedExtra) {
rewardText = "Stony " + rewardText;
rewardMaterials.stone += 20;
addedExtra = true;
}
extraWordR -= 0.02;
if(extraWordR < 0.02 && !addedExtra) {
rewardText = "Ancient " + rewardText;
rewardMaterials.stone += 10;
addedExtra = true;
}
extraWordR -= 0.02;
if(extraWordR < 0.02 && !addedExtra) {
rewardText = "Starry " + rewardText;
rewardMaterials.stone += 10;
rewardMaterials.knowledge += 5;
addedExtra = true;
}
extraWordR -= 0.02;
if(extraWordR < 0.02 && !addedExtra) {
rewardText = "Delicious " + rewardText;
var _g = rewardMaterials;
_g.set_food(_g.food + 10);
addedExtra = true;
}
extraWordR -= 0.02;
if(extraWordR < 0.02 && !addedExtra) {
rewardText = "Profitable " + rewardText;
rewardMaterials.multiply(1.2);
var _g = rewardMaterials;
_g.set_food(_g.food + 15);
addedExtra = true;
}
extraWordR -= 0.02;
if(extraWordR < 0.02 && !addedExtra) {
rewardText = "Extremely Normal-Looking " + rewardText;
addedExtra = true;
}
extraWordR -= 0.02;
if(extraWordR < 0.02 && !addedExtra && canGiveRefinedMetal) {
rewardText = "Shiny " + rewardText;
rewardMaterials.refinedMetal += 10;
addedExtra = true;
}
extraWordR -= 0.02;
if(extraWordR < 0.02 && !addedExtra && canGiveMachineParts) {
rewardText = "Dancing " + rewardText;
rewardMaterials.machineParts += 8;
addedExtra = true;
}
extraWordR -= 0.02;
if(extraWordR < 0.02 && !addedExtra && canGiveComputerChips) {
rewardText = "Computerized " + rewardText;
rewardMaterials.computerChips += 2;
addedExtra = true;
}
extraWordR -= 0.02;
var productionBasedMultiplier = Math.pow(this.city.simulation.stats.materialProduction[MaterialsHelper.findMaterialIndex("wood")][1] + this.city.simulation.stats.materialProduction[MaterialsHelper.findMaterialIndex("stone")][1] + this.city.simulation.stats.materialProduction[MaterialsHelper.findMaterialIndex("food")][1] + this.city.simulation.stats.materialProduction[MaterialsHelper.findMaterialIndex("knowledge")][1],0.66) / 16;
var minVal = extraRewardMultiplier > 1.5 ? 2 : 1;
rewardMaterials.multiply(productionBasedMultiplier < minVal ? minVal : productionBasedMultiplier > 12 ? 12 : productionBasedMultiplier);
rewardMaterials.multiply(extraRewardMultiplier);
rewardMaterials.roundAll();
return { text : rewardText, materials : rewardMaterials};
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
if(shouldSaveDefinition) {
queue.addString(simulation_BoostManager.saveDefinition);
}
var value = this.boostLeft;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.maxBoost;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.normalMaxBoost;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
}
,load: function(queue,definition) {
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"boostLeft")) {
this.boostLeft = loadMap.h["boostLeft"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"maxBoost")) {
this.maxBoost = loadMap.h["maxBoost"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"normalMaxBoost")) {
this.normalMaxBoost = loadMap.h["normalMaxBoost"];
}
}
,__class__: simulation_BoostManager
};
var simulation_CitizenEntertainment = function(citizen) {
this.entertainmentInited = false;
this.tryForDayEntertainment = 0;
this.tryForEntertainment = 0;
this.entertainmentFinishedTime = 0;
var _g = [];
var _g1 = 0;
var _g2 = simulation_EntertainmentTypeHelpers.entertainmentTypeNumber;
while(_g1 < _g2) {
var i = _g1++;
_g.push(0.0);
}
this.recentEntertainmentTypes = _g;
this.citizen = citizen;
this.entertainmentInited = false;
this.tryForDayEntertainment = 0;
this.setAgeRelatedEntertainment();
};
$hxClasses["simulation.CitizenEntertainment"] = simulation_CitizenEntertainment;
simulation_CitizenEntertainment.__name__ = "simulation.CitizenEntertainment";
simulation_CitizenEntertainment.prototype = {
get_normallyAtHomeTimeFrom: function() {
var tmp = this.citizen.get_workTimePreference();
var tmp1;
if(this.citizen.job == null) {
tmp1 = 23;
} else {
var this1 = this.citizen.job.endTime;
var this2 = this1;
var newTime = this2;
newTime += 4;
newTime %= 24;
tmp1 = newTime;
}
return tmp + tmp1;
}
,get_normallyAtHomeTimeTo: function() {
var tmp = this.citizen.get_workTimePreference();
var tmp1;
if(this.citizen.job == null) {
tmp1 = 8;
} else {
var this1 = this.citizen.job.startTime;
tmp1 = this1;
}
return tmp + tmp1;
}
,setAgeRelatedEntertainment: function() {
if(this.citizen.get_age() < 16 && random_Random.getInt(1000) < 998) {
this.recentEntertainmentTypes[0] = this.citizen.simulation.time.timeSinceStart + 1440 * (this.citizen.get_age() - random_Random.getFloat(14,16));
}
}
,updateEntertainment: function(timeMod) {
var busy = false;
if(this.citizen.inPermanent != null && this.citizen.inPermanent.isBuilding && this.citizen.inPermanent.isEntertainment) {
var busy1 = true;
var entertainmentBuilding = this.citizen.inPermanent;
var timeSinceStart = this.citizen.simulation.time.timeSinceStart;
if(!this.entertainmentInited) {
if(entertainmentBuilding.get_isOpen()) {
var currentEntertainmentDesirability = 1.0;
if(this.citizen.job == null && this.citizen.school == null) {
currentEntertainmentDesirability = 0.75;
}
this.entertainmentFinishedTime = timeSinceStart + 60 * random_Random.getFloat(entertainmentBuilding.get_minimumNormalTimeToSpend(),entertainmentBuilding.get_maximumNormalTimeToSpend());
this.recentEntertainmentTypes[entertainmentBuilding.get_entertainmentType()] = timeSinceStart + 1440 * random_Random.getFloat(entertainmentBuilding.get_minimumEntertainmentGroupSatisfy(),entertainmentBuilding.get_maximumEntertainmentGroupSatisfy()) * currentEntertainmentDesirability;
this.entertainmentInited = true;
} else {
this.entertainmentFinishedTime = timeSinceStart - 1000;
}
}
if(!entertainmentBuilding.get_isOpenForExistingVisitors() || timeSinceStart >= this.entertainmentFinishedTime) {
if(entertainmentBuilding.finishEntertainment(this.citizen,timeMod)) {
busy1 = false;
this.entertainmentInited = false;
} else {
entertainmentBuilding.beEntertained(this.citizen,timeMod);
}
} else {
entertainmentBuilding.beEntertained(this.citizen,timeMod);
}
busy = busy1;
}
if(busy) {
return true;
}
var tmp;
if(this.citizen.get_age() > 16 && this.citizen.likesNightclubs) {
var this1 = this.citizen.simulation.time.timeSinceStart / 60 % 24;
var start = 23 + this.citizen.get_workTimePreference();
var end = 6 + this.citizen.get_workTimePreference();
tmp = start < end ? this1 >= start && this1 < end : this1 >= start || this1 < end;
} else {
tmp = false;
}
if(tmp && this.citizen.wantsNightEntertainmentIn <= 0) {
busy = this.searchNightEntertainment();
} else {
var this1 = this.citizen.simulation.time.timeSinceStart / 60 % 24;
var start = this.get_normallyAtHomeTimeFrom();
var end = this.get_normallyAtHomeTimeTo();
if(!(start < end ? this1 >= start && this1 < end : this1 >= start || this1 < end)) {
busy = this.searchDayEntertainment();
}
}
return busy;
}
,stop: function() {
this.entertainmentInited = false;
}
,searchNightEntertainment: function() {
if(this.citizen.simulation.time.timeSinceStart >= this.tryForEntertainment) {
if(!this.citizen.simulation.permanentFinder.canPerformQuery()) {
return true;
}
var nightEntertainment = this.citizen.simulation.permanentFinder.quickQueryForCitizen(this.citizen,function(pm) {
if(!pm.isBuilding || !pm.isEntertainment) {
return false;
}
var entertainmentBuilding = pm;
return entertainmentBuilding.get_isOpen();
},"nightEntertainmentFind",1,null,random_Random.getFloat() < 0.02 ? 480 : 320);
if(nightEntertainment == null) {
this.tryForEntertainment = this.citizen.simulation.time.timeSinceStart + 120 * this.citizen.simulation.time.minutesPerTick;
} else {
var _this = this.citizen;
_this.simulation.pathfinder.findPath(_this,nightEntertainment);
_this.pathOnFail = null;
this.entertainmentInited = false;
return true;
}
}
return false;
}
,searchDayEntertainment: function() {
var _gthis = this;
var timeSinceStart = this.citizen.simulation.time.timeSinceStart;
if(timeSinceStart >= this.tryForDayEntertainment) {
if(!this.citizen.simulation.permanentFinder.canPerformQuery()) {
return false;
}
var dayEntertainment = this.citizen.simulation.permanentFinder.queryForCitizen(this.citizen,function(pm) {
if(!pm.isBuilding || !pm.isEntertainment) {
return false;
}
var entertainmentBuilding = pm;
if(entertainmentBuilding.get_isOpen()) {
return timeSinceStart >= _gthis.recentEntertainmentTypes[entertainmentBuilding.get_entertainmentType()];
} else {
return false;
}
},null,random_Random.getFloat() < 0.02 ? 480 : 160);
if(dayEntertainment == null) {
this.tryForDayEntertainment = timeSinceStart + 120 * this.citizen.simulation.time.minutesPerTick;
} else {
var _this = this.citizen;
_this.simulation.pathfinder.findPath(_this,dayEntertainment);
_this.pathOnFail = null;
this.entertainmentInited = false;
return true;
}
}
return false;
}
,__class__: simulation_CitizenEntertainment
};
var simulation_CitizenSpecialAction = function(citizen) {
this.citizen = null;
this.citizen = citizen;
this.simulation = citizen.onWorld.city.simulation;
this.time = this.simulation.time;
};
$hxClasses["simulation.CitizenSpecialAction"] = simulation_CitizenSpecialAction;
simulation_CitizenSpecialAction.__name__ = "simulation.CitizenSpecialAction";
simulation_CitizenSpecialAction.prototype = {
update: function(timeMod) {
}
,isActive: function() {
return false;
}
,onDie: function() {
this.simulation.possibleCitizenHobbies.push({ hobbyClass : js_Boot.getClass(this), minimumCitizenAmount : 0});
}
,__class__: simulation_CitizenSpecialAction
};
var simulation_CitizenUpdater = function(simulation) {
this.i = 0;
this.simulation = simulation;
};
$hxClasses["simulation.CitizenUpdater"] = simulation_CitizenUpdater;
simulation_CitizenUpdater.__name__ = "simulation.CitizenUpdater";
simulation_CitizenUpdater.prototype = {
update: function(timeMod) {
this.i++;
var _g = 0;
var _g1 = this.simulation.citizens;
while(_g < _g1.length) {
var citizen = _g1[_g];
++_g;
citizen.update(timeMod);
}
}
,__class__: simulation_CitizenUpdater
};
var simulation_CityConnections = function(city) {
this.city = city;
};
$hxClasses["simulation.CityConnections"] = simulation_CityConnections;
simulation_CityConnections.__name__ = "simulation.CityConnections";
simulation_CityConnections.prototype = {
updateCityConnections: function() {
var _gthis = this;
this.city.simulation.flyingPathfinder.updateWaypoints();
var worlds = this.city.worlds;
var permanents = this.city.permanents;
var worldsWithTeleporter = [];
var _g = 0;
while(_g < permanents.length) {
var permanent = permanents[_g];
++_g;
if(permanent.isBuilding) {
permanent.leftBuilding = null;
permanent.rightBuilding = null;
permanent.topBuilding = null;
permanent.bottomBuilding = null;
}
}
this.elevatorConnections = new haxe_ds_ObjectMap();
var _g = 0;
while(_g < worlds.length) {
var world = worlds[_g];
++_g;
var theseElevators = [];
this.elevatorConnections.set(world,theseElevators);
var _g1 = 0;
var _g2 = world.permanents.length - 1;
while(_g1 < _g2) {
var i = _g1++;
var permanentStack = world.permanents[i];
var nextPermanentStack = world.permanents[i + 1];
var _g3 = 0;
var val1 = permanentStack.length;
var val2 = nextPermanentStack.length;
var _g4 = val2 < val1 ? val2 : val1;
while(_g3 < _g4) {
var j = _g3++;
var thisPermanent = permanentStack[j];
var nextPermanent = nextPermanentStack[j];
if(thisPermanent != null && nextPermanent != null && thisPermanent.isBuilding && nextPermanent.isBuilding) {
var thisBuilding = thisPermanent;
var nextBuilding = nextPermanent;
if(!thisBuilding.isRooftopBuilding && !nextBuilding.isRooftopBuilding) {
thisBuilding.rightBuilding = nextBuilding;
nextBuilding.leftBuilding = thisBuilding;
}
}
}
}
var _g5 = 0;
var _g6 = world.permanents;
while(_g5 < _g6.length) {
var permanentStack1 = _g6[_g5];
++_g5;
var stackElevators = [];
theseElevators.push(stackElevators);
var _g7 = 0;
while(_g7 < permanentStack1.length) {
var pm = permanentStack1[_g7];
++_g7;
if(pm != null && pm.is(buildings_HyperElevator)) {
stackElevators.push(pm);
}
}
var _g8 = 0;
var _g9 = permanentStack1.length - 1;
while(_g8 < _g9) {
var i1 = _g8++;
var thisPermanent1 = permanentStack1[i1];
var nextPermanent1 = permanentStack1[i1 + 1];
if(thisPermanent1 != null && nextPermanent1 != null && thisPermanent1.isBuilding && nextPermanent1.isBuilding && !thisPermanent1.isRooftopBuilding) {
thisPermanent1.topBuilding = nextPermanent1;
nextPermanent1.bottomBuilding = thisPermanent1;
}
}
}
}
var _g = 0;
var _g1 = this.city.teleporters;
while(_g < _g1.length) {
var teleporter = _g1[_g];
++_g;
if(worldsWithTeleporter.indexOf(teleporter.world) == -1) {
worldsWithTeleporter.push(teleporter.world);
}
}
var simulation = this.city.simulation;
this.landingSiteGroups = [];
var _g = 0;
var _g1 = this.city.landingSites;
while(_g < _g1.length) {
var landingSite = _g1[_g];
++_g;
landingSite.landingSiteGroup = null;
}
var _g = 0;
var _g1 = this.city.landingSites;
while(_g < _g1.length) {
var landingSite = _g1[_g];
++_g;
var addedToGroup = false;
var otherLS = simulation.flyingPathfinder.findAnyOtherLandingSite(landingSite);
if(otherLS != null) {
addedToGroup = true;
landingSite.landingSiteGroup = otherLS.landingSiteGroup;
this.landingSiteGroups[otherLS.landingSiteGroup].push(landingSite);
}
if(!addedToGroup) {
landingSite.landingSiteGroup = this.landingSiteGroups.length;
this.landingSiteGroups.push([landingSite]);
}
}
this.directWorldConnectionNumber = 0;
var _g = 0;
while(_g < worlds.length) {
var world = worlds[_g];
++_g;
if(worldsWithTeleporter.indexOf(world) != -1) {
world.reachableWorlds = worldsWithTeleporter;
} else {
world.reachableWorlds = [world];
}
}
var _g = 0;
var _g1 = this.landingSiteGroups;
while(_g < _g1.length) {
var landingSiteGroup = _g1[_g];
++_g;
var theseReachableWorlds = null;
var _g2 = 0;
while(_g2 < landingSiteGroup.length) {
var ls = landingSiteGroup[_g2];
++_g2;
if(theseReachableWorlds == null) {
theseReachableWorlds = ls.world.reachableWorlds;
} else if(ls.world.reachableWorlds != theseReachableWorlds) {
var _g3 = 0;
var _g4 = ls.world.reachableWorlds;
while(_g3 < _g4.length) {
var w = _g4[_g3];
++_g3;
if(theseReachableWorlds.indexOf(w) == -1) {
theseReachableWorlds.push(w);
}
w.reachableWorlds = theseReachableWorlds;
}
ls.world.reachableWorlds = theseReachableWorlds;
}
}
}
var _g = 0;
while(_g < worlds.length) {
var world = [worlds[_g]];
++_g;
var hasWorldsCached = [world[0].relevantWorldsForDirectCityConnectionsCache != null];
var arr = [hasWorldsCached[0] ? world[0].relevantWorldsForDirectCityConnectionsCache : worlds];
if(!hasWorldsCached[0]) {
world[0].relevantWorldsForDirectCityConnectionsCache = [];
}
var testPossibleConnection = (function(arr,hasWorldsCached,world) {
return function(permanentStack,nonNullPosX,nextToDir) {
if(nonNullPosX != null) {
var _g = 0;
while(_g < arr[0].length) {
var otherWorld = arr[0][_g];
++_g;
if((otherWorld.rect.y > world[0].rect.y || otherWorld.rect.y == world[0].rect.y && otherWorld.rect.x > world[0].rect.x) && otherWorld.rect.x % 20 == world[0].rect.x % 20 && otherWorld.rect.y % 20 == world[0].rect.y % 20) {
var otherPermanentStackX = ((nonNullPosX - otherWorld.rect.x) / 20 | 0) + nextToDir;
if(otherPermanentStackX >= 0 && otherPermanentStackX < otherWorld.permanents.length) {
if(!hasWorldsCached[0] && world[0].relevantWorldsForDirectCityConnectionsCache.indexOf(otherWorld) == -1) {
world[0].relevantWorldsForDirectCityConnectionsCache.push(otherWorld);
}
var otherPermanentStack = otherWorld.permanents[otherPermanentStackX];
var permanentHeightsBetweenWorlds = (otherWorld.rect.y - world[0].rect.y) / 20 | 0;
if(otherPermanentStack.length > permanentHeightsBetweenWorlds) {
var isAnyConnection = false;
var _g1 = 0;
var val1 = permanentStack.length;
var val2 = otherPermanentStack.length - permanentHeightsBetweenWorlds;
var _g2 = val2 < val1 ? val2 : val1;
while(_g1 < _g2) {
var i = _g1++;
var thisPermanent = permanentStack[i];
var otherPermanent = otherPermanentStack[i + permanentHeightsBetweenWorlds];
if(thisPermanent != null && otherPermanent != null && thisPermanent.isBuilding && otherPermanent.isBuilding) {
var thisBuilding = thisPermanent;
var otherBuilding = otherPermanent;
if(!thisBuilding.isRooftopBuilding && !otherBuilding.isRooftopBuilding) {
if(nextToDir == 1) {
thisBuilding.rightBuilding = otherBuilding;
otherBuilding.leftBuilding = thisBuilding;
} else {
thisBuilding.leftBuilding = otherBuilding;
otherBuilding.rightBuilding = thisBuilding;
}
isAnyConnection = true;
_gthis.directWorldConnectionNumber += 2;
}
}
}
if(isAnyConnection) {
var oldRWs = world[0].reachableWorlds;
if(world[0].reachableWorlds != otherWorld.reachableWorlds) {
world[0].reachableWorlds = otherWorld.reachableWorlds;
var _g3 = 0;
while(_g3 < oldRWs.length) {
var w = oldRWs[_g3];
++_g3;
if(world[0].reachableWorlds.indexOf(w) == -1) {
world[0].reachableWorlds.push(w);
}
}
}
var _g4 = 0;
while(_g4 < worlds.length) {
var world2 = worlds[_g4];
++_g4;
if(world2.reachableWorlds == oldRWs) {
world2.reachableWorlds = world[0].reachableWorlds;
}
}
}
}
}
}
}
}
};
})(arr,hasWorldsCached,world);
testPossibleConnection(world[0].permanents[0],world[0].rect.x,-1);
testPossibleConnection(world[0].permanents[world[0].permanents.length - 1],world[0].rect.x + 20 * (world[0].permanents.length - 1),1);
}
var currentWorldGroup = 0;
var _g = 0;
var _g1 = this.city.worlds;
while(_g < _g1.length) {
var world1 = _g1[_g];
++_g;
world1.worldGroup = null;
}
var _g = 0;
var _g1 = this.city.worlds;
while(_g < _g1.length) {
var world1 = _g1[_g];
++_g;
if(world1.worldGroup != null) {
continue;
}
var haveTeleporter = false;
if(worldsWithTeleporter.indexOf(world1) != -1) {
haveTeleporter = true;
}
var _g2 = 0;
var _g3 = world1.reachableWorlds;
while(_g2 < _g3.length) {
var world2 = _g3[_g2];
++_g2;
world2.worldGroup = currentWorldGroup;
world2.hasTeleporterOnGroup = haveTeleporter;
}
++currentWorldGroup;
}
this.numberOfWorldGroups = currentWorldGroup;
if(this.city.builder != null) {
this.city.builder.invalidateCache();
}
}
,__class__: simulation_CityConnections
};
var simulation_Eating = function(simulation) {
this.foodRationing = false;
this.currentFoodSaveByHerbsPct = 0;
this.herbsCap = 0;
this.foodShortage = 0;
this.totalConsumedFoodPerDay = -1;
this.simulation = simulation;
};
$hxClasses["simulation.Eating"] = simulation_Eating;
simulation_Eating.__name__ = "simulation.Eating";
simulation_Eating.prototype = {
update: function(timeMod) {
var time = this.simulation.time.timeSinceStart / 60 % 24;
if(this.totalConsumedFoodPerDay != 0) {
this.currentFoodSaveByHerbsPct = Math.min(1,this.herbsCap / this.totalConsumedFoodPerDay);
} else {
this.currentFoodSaveByHerbsPct = 0;
}
var foodSavedByHerbs = 0.2 * Math.min(this.totalConsumedFoodPerDay,this.herbsCap);
this.totalConsumedFoodPerDay = this.simulation.citizens.length - this.simulation.stats.children * 0.5;
this.totalConsumedFoodPerDay -= foodSavedByHerbs;
if(this.foodRationing) {
this.totalConsumedFoodPerDay *= 0.5;
}
if(time >= 7 && time < 20) {
var partOfDay = this.simulation.time.minutesPerTick * timeMod / 60 / (20 - 7);
var wantsToConsumeFood = Math.max(0,this.totalConsumedFoodPerDay * partOfDay);
var consumedFoodNow = Math.min(this.simulation.city.materials.food,wantsToConsumeFood);
var city = this.simulation.city;
var _g = city.materials;
_g.set_food(_g.food - consumedFoodNow);
city.simulation.stats.materialUsed[0][0] += consumedFoodNow;
this.foodShortage += wantsToConsumeFood - consumedFoodNow;
this.foodShortage = Math.min(this.foodShortage,Math.ceil(this.totalConsumedFoodPerDay / 2));
}
if(this.foodShortage > 0 && this.simulation.city.materials.food > 0.1) {
var reduceShortageBy = Math.min(this.simulation.city.materials.food,this.foodShortage);
this.foodShortage -= reduceShortageBy;
var city = this.simulation.city;
var _g = city.materials;
_g.set_food(_g.food - reduceShortageBy);
city.simulation.stats.materialUsed[0][0] += reduceShortageBy;
if(this.simulation.city.materials.food > 0) {
this.foodShortage = 0;
}
}
}
,getFoodText: function() {
var reductionText = "";
if(this.foodRationing) {
reductionText = "Rationing halves this. ";
}
return "Your citizens need to eat!\n" + "Adults eat about one food per day, children eat 1/2 food. " + reductionText + (this.currentFoodSaveByHerbsPct < 0.0001 ? "" : "Herbs reduce this by " + Math.round(this.currentFoodSaveByHerbsPct * 0.2 * 100) + "/" + 20 + "%. ") + (this.totalConsumedFoodPerDay == -1 ? "" : "Currently, " + (this.totalConsumedFoodPerDay | 0) + " food is being consumed each day.");
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
if(shouldSaveDefinition) {
queue.addString(simulation_Eating.saveDefinition);
}
var value = this.foodShortage;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
}
,load: function(queue,definition) {
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"foodShortage")) {
this.foodShortage = loadMap.h["foodShortage"];
}
}
,__class__: simulation_Eating
};
var simulation_EntertainmentTypeHelpers = function() { };
$hxClasses["simulation.EntertainmentTypeHelpers"] = simulation_EntertainmentTypeHelpers;
simulation_EntertainmentTypeHelpers.__name__ = "simulation.EntertainmentTypeHelpers";
simulation_EntertainmentTypeHelpers.getName = function(type) {
switch(type) {
case 0:
return "Night Clubs";
case 1:
return "Pubs & Restaurants";
case 2:
return "Art";
case 3:
return "Nature";
case 4:
return "Gaming";
case 5:
return "Libraries";
}
};
var simulation_Fish = function(city,stage,inPermanent,relativeX,relativeY) {
this.verticalHeightToUse = 0;
this.verticalWidthToUse = 0;
this.startSlowingProb = 0.05;
this.stopMoveProb = 0.2;
this.normalSlowdown = 0.1;
this.normalAcceleration = 0.05;
this.maxSpeed = 0.6;
this.stopSpeedSpeed = 0.4;
this.slowing = false;
this.speeding = false;
this.moveSpeed = 0;
this.relativeY = 2;
this.relativeX = 2;
this.inPermanent = null;
this.spriteCanBeRotated = false;
this.height = 1;
this.width = 2;
this.type = 0;
this.city = city;
this.stage = stage;
this.type = random_Random.getInt(10);
this.sprite = new PIXI.Sprite();
stage.addChild(this.sprite);
this.setTypeSprite();
this.sprite.anchor.set(0.5,0.5);
this.inPermanent = inPermanent;
this.relativeX = relativeX;
this.relativeY = relativeY;
this.moveDirection = 0;
this.moveSpeed = 0;
};
$hxClasses["simulation.Fish"] = simulation_Fish;
simulation_Fish.__name__ = "simulation.Fish";
simulation_Fish.prototype = {
destroy: function() {
this.sprite.destroy();
HxOverrides.remove(this.city.simulation.fishes.fishes,this);
}
,save: function(queue) {
this.saveBasics(queue);
var value = this.inPermanent.id;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
,load: function(queue) {
this.loadBasics(queue);
var this1 = this.city.permanentsByID;
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
this.inPermanent = this1.h[intToRead];
this.updateDisplay();
}
,update: function(timeMod) {
if(this.moveSpeed > 0 || this.speeding) {
var movePot = 0.0;
switch(this.moveDirection) {
case 0:
movePot = this.leftMovePotential();
if(movePot <= 0) {
this.moveSpeed = 0;
this.speeding = false;
this.slowing = false;
} else {
this.relativeX -= Math.min(movePot,timeMod * this.moveSpeed);
}
break;
case 1:
movePot = this.topMovePotential();
if(movePot <= 0) {
this.moveSpeed = 0;
this.speeding = false;
this.slowing = false;
} else {
this.relativeY -= Math.min(movePot,timeMod * this.moveSpeed);
}
break;
case 2:
movePot = this.rightMovePotential();
if(movePot <= 0) {
this.moveSpeed = 0;
this.speeding = false;
this.slowing = false;
} else {
this.relativeX += Math.min(movePot,timeMod * this.moveSpeed);
}
break;
case 3:
movePot = this.bottomMovePotential();
if(movePot <= 0) {
this.moveSpeed = 0;
this.speeding = false;
this.slowing = false;
} else {
this.relativeY += Math.min(movePot,timeMod * this.moveSpeed);
}
break;
default:
}
var bld = this.inPermanent;
if(this.relativeX < 0 && bld.leftIsWaterFilled) {
this.relativeX += 20;
this.inPermanent = bld.leftAsWaterFilled;
}
if(this.relativeY < 0 && bld.topIsWaterFilled) {
this.relativeY += 20;
this.inPermanent = bld.topAsWaterFilled;
}
if(this.relativeX >= 20 && bld.rightIsWaterFilled) {
this.relativeX -= 20;
this.inPermanent = bld.rightAsWaterFilled;
}
if(this.relativeY >= 20 && bld.bottomIsWaterFilled) {
this.relativeY -= 20;
this.inPermanent = bld.bottomAsWaterFilled;
}
if(this.speeding) {
this.moveSpeed = Math.min(this.maxSpeed,this.moveSpeed + this.normalAcceleration * timeMod);
if(this.moveSpeed > this.stopSpeedSpeed && random_Random.getFloat(1) < this.stopMoveProb * timeMod || movePot < 2) {
this.speeding = false;
}
} else if(this.slowing) {
this.moveSpeed = Math.max(0,this.moveSpeed - this.normalSlowdown * timeMod);
} else if(random_Random.getFloat(1) < this.startSlowingProb * (5 / (movePot < 1 ? 1 : movePot > 15 ? 15 : movePot)) * timeMod || movePot < 3) {
this.slowing = true;
}
}
if(this.moveSpeed == 0) {
var dir = random_Random.getInt(12);
if(dir == 0 || dir == 4 || this.moveDirection == 0 && dir == 11) {
if(this.leftMovePotential() > 3) {
this.moveDirection = 0;
this.speeding = true;
this.slowing = false;
}
} else if(dir == 1 || dir == 5 || this.moveDirection == 2 && dir == 11) {
if(this.rightMovePotential() > 3) {
this.moveDirection = 2;
this.speeding = true;
this.slowing = false;
}
} else if(dir == 2 || this.moveDirection == 1 && dir >= 10) {
if(this.topMovePotential() > 3) {
this.moveDirection = 1;
this.speeding = true;
this.slowing = false;
}
} else if(dir == 3 || this.moveDirection == 3 && dir >= 10) {
if(this.bottomMovePotential() > 3) {
this.moveDirection = 3;
this.speeding = true;
this.slowing = false;
}
} else {
this.speeding = false;
this.slowing = false;
}
}
this.updateDisplay();
}
,leftMovePotential: function() {
var lmp = 0.0;
var bld = this.inPermanent;
lmp += this.relativeX - this.width / 2 - 3;
if(bld != null) {
bld = bld.leftAsWaterFilled;
if(bld != null && (this.relativeY > 3 + this.height / 2 || bld.topIsWaterFilled) && (this.relativeY < 17 - this.height / 2 || bld.bottomIsWaterFilled)) {
lmp += 20;
}
}
return lmp;
}
,rightMovePotential: function() {
var mp = 0.0;
var bld = this.inPermanent;
mp += 17 - this.width / 2 - this.relativeX;
if(bld != null) {
bld = bld.rightAsWaterFilled;
if(bld != null && (this.relativeY > 3 + this.height / 2 || bld.topIsWaterFilled) && (this.relativeY < 17 - this.height / 2 || bld.bottomIsWaterFilled)) {
mp += 20;
}
}
return mp;
}
,topMovePotential: function() {
var lmp = 0.0;
var bld = this.inPermanent;
lmp += this.relativeY - this.verticalWidthToUse / 2 - 3;
if(bld != null) {
bld = bld.topAsWaterFilled;
if(bld != null && (this.relativeX > 3 + this.verticalHeightToUse / 2 || bld.leftIsWaterFilled) && (this.relativeX < 17 - this.verticalHeightToUse / 2 || bld.rightIsWaterFilled)) {
lmp += 20;
}
}
return lmp;
}
,bottomMovePotential: function() {
var mp = 0.0;
var bld = this.inPermanent;
mp += 17 - this.verticalWidthToUse / 2 - this.relativeY;
if(bld != null) {
bld = bld.bottomAsWaterFilled;
if(bld != null && (this.relativeX > 3 + this.verticalHeightToUse / 2 || bld.leftIsWaterFilled) && (this.relativeX < 17 - this.verticalHeightToUse / 2 || bld.rightIsWaterFilled)) {
mp += 20;
}
}
return mp;
}
,updateDisplay: function() {
this.sprite.position.set(this.inPermanent.position.x + this.relativeX,this.inPermanent.position.y + this.relativeY);
if(this.spriteCanBeRotated) {
if(this.moveDirection == 1) {
this.sprite.rotation = 1.5 * Math.PI;
} else if(this.moveDirection == 3) {
this.sprite.rotation = 0.5 * Math.PI;
} else if(this.moveDirection == 2) {
this.sprite.rotation = 0;
} else {
this.sprite.rotation = Math.PI;
}
}
}
,postLoad: function() {
this.setTypeSprite();
}
,setTypeSprite: function() {
var smallFishTextures = Resources.getTexturesByWidth("spr_fish",2);
var jellyTextures = Resources.getTexturesByWidth("spr_fish_jelly",5);
var bigFishTextures = Resources.getTexturesByWidth("spr_fish_big",4);
var snakeTextures = Resources.getTexturesByWidth("spr_fish_snake",8);
var bigFishTextures2 = Resources.getTexturesByWidth("spr_fish_big2",5);
this.spriteCanBeRotated = false;
switch(this.type) {
case 0:
this.sprite.texture = smallFishTextures[0];
this.spriteCanBeRotated = true;
break;
case 1:
this.sprite.texture = smallFishTextures[1];
this.spriteCanBeRotated = true;
break;
case 2:
this.sprite.texture = jellyTextures[0];
this.maxSpeed = 0.4;
this.stopSpeedSpeed = 0.2;
this.normalAcceleration = 0.025;
this.normalSlowdown = 0.025;
this.spriteCanBeRotated = false;
this.stopMoveProb = 0.03;
this.startSlowingProb = 0.1;
break;
case 3:
this.sprite.texture = bigFishTextures[0];
this.spriteCanBeRotated = true;
break;
case 4:
this.sprite.texture = snakeTextures[0];
this.spriteCanBeRotated = true;
this.maxSpeed = 0.3;
this.stopSpeedSpeed = 0.2;
this.normalAcceleration = 0.02;
this.normalSlowdown = 0.02;
this.stopMoveProb = 0.02;
this.startSlowingProb = 0.1;
break;
case 5:
this.sprite.texture = smallFishTextures[2];
this.spriteCanBeRotated = true;
break;
case 6:
this.sprite.texture = bigFishTextures[1];
this.spriteCanBeRotated = true;
break;
case 7:
this.sprite.texture = bigFishTextures2[0];
this.spriteCanBeRotated = true;
break;
case 8:
this.sprite.texture = smallFishTextures[3];
this.spriteCanBeRotated = true;
break;
case 9:
this.sprite.texture = smallFishTextures[4];
this.spriteCanBeRotated = true;
break;
}
this.width = Math.round(this.sprite.texture.width);
this.height = Math.round(this.sprite.texture.height);
if(this.spriteCanBeRotated) {
this.verticalWidthToUse = this.width;
this.verticalHeightToUse = this.height;
} else {
this.verticalWidthToUse = this.height;
this.verticalHeightToUse = this.width;
}
}
,pushBackIntoPermanent: function() {
var bld = this.inPermanent;
var widthToUse = this.moveDirection == 1 || this.moveDirection == 3 ? this.verticalHeightToUse : this.width;
var heightToUse = this.moveDirection == 1 || this.moveDirection == 3 ? this.verticalWidthToUse : this.height;
if(!bld.leftIsWaterFilled && this.relativeX < 3 + widthToUse / 2) {
this.relativeX = 3 + widthToUse / 2;
}
if(!bld.topIsWaterFilled && this.relativeY < 3 + heightToUse / 2) {
this.relativeY = 3 + heightToUse / 2;
}
if(!bld.rightIsWaterFilled && this.relativeX > 17 - widthToUse / 2) {
this.relativeX = 17 - widthToUse / 2;
}
if(!bld.bottomIsWaterFilled && this.relativeY > 17 - heightToUse / 2) {
this.relativeY = 17 - heightToUse / 2;
}
}
,saveBasics: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
if(shouldSaveDefinition) {
queue.addString(simulation_Fish.saveDefinition);
}
var value = this.type;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.relativeX;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.relativeY;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
}
,loadBasics: function(queue,definition) {
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"type")) {
this.type = loadMap.h["type"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"relativeX")) {
this.relativeX = loadMap.h["relativeX"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"relativeY")) {
this.relativeY = loadMap.h["relativeY"];
}
this.postLoad();
}
,__class__: simulation_Fish
};
var simulation_FishManager = function(simulation) {
this.simulation = simulation;
this.fishes = [];
};
$hxClasses["simulation.FishManager"] = simulation_FishManager;
simulation_FishManager.__name__ = "simulation.FishManager";
simulation_FishManager.prototype = {
update: function(timeMod) {
var _g = 0;
var _g1 = this.fishes;
while(_g < _g1.length) {
var fish = _g1[_g];
++_g;
fish.update(timeMod);
}
}
,save: function(queue) {
var value = this.fishes.length;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var _g = 0;
var _g1 = this.fishes;
while(_g < _g1.length) {
var fish = _g1[_g];
++_g;
fish.save(queue);
}
}
,load: function(queue) {
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var len = intToRead;
var _g = 0;
var _g1 = len;
while(_g < _g1) {
var i = _g++;
var newFish = new simulation_Fish(this.simulation.city,this.simulation.city.aboveCitizensInBuildingStage,null,0,0);
newFish.load(queue);
this.fishes.push(newFish);
}
}
,__class__: simulation_FishManager
};
var simulation_FlyingSaucer = function(simulation,stage,path,start,destination) {
this.stage = stage;
this.simulation = simulation;
this.start = start;
this.destination = destination;
this.pathPos = path.length - 1;
this.position = new common_FPoint(path[this.pathPos].x,path[this.pathPos].y);
this.sprite = Resources.makeSprite(start.get_saucherTexture());
this.sprite.position.set(this.position.x,this.position.y);
stage.addChild(this.sprite);
this.path = path;
this.passengers = [];
this.leavingIn = 12;
start.currentlyLandedSaucer = this;
};
$hxClasses["simulation.FlyingSaucer"] = simulation_FlyingSaucer;
simulation_FlyingSaucer.__name__ = "simulation.FlyingSaucer";
simulation_FlyingSaucer.prototype = {
setDestination: function(newDestination,newPath) {
this.path = newPath;
this.pathPos = this.path.length - 1;
this.destination = newDestination;
}
,addPassenger: function(citizen) {
this.passengers.push(citizen);
this.start.timesUsed++;
}
,destroy: function() {
HxOverrides.remove(this.simulation.flyingSaucers,this);
this.stage.removeChild(this.sprite);
}
,cancel: function() {
var _g = 0;
var _g1 = this.passengers;
while(_g < _g1.length) {
var person = _g1[_g];
++_g;
person.fullyBeingControlled = false;
person.canViewSelfInBuilding = true;
if(person.recyclePathArray) {
pooling_Int32ArrayPool.returnToPool(person.path);
person.recyclePathArray = false;
}
person.path = null;
person.nextPathPos = -1;
person.pathEnd = -1;
person.currentPathAction = null;
if(!person.canViewSelfInBuilding) {
person.delayCanViewSelfInBuilding = true;
}
person.canViewSelfInBuilding = true;
person.verticalPathProgress = 0;
person.pathEndFunction = null;
person.requestingPathGoal = null;
person.pathOnlyRelatedTo = null;
person.pathWalkSpeed = 1;
person.pathCanBeReconsidered = true;
if(person.sprite.alpha > 0 && person.sprite.alpha < 1) {
person.sprite.alpha = 1;
}
}
this.destroy();
}
,update: function(timeMod) {
if(this.leavingIn > 0) {
this.leavingIn -= timeMod;
if(this.leavingIn <= 0) {
this.start.currentlyLandedSaucer = null;
}
return;
}
var flyingDistanceLeft = timeMod * 3;
while(flyingDistanceLeft > 0) {
var goalX = this.path[this.pathPos].x;
var goalY = this.path[this.pathPos].y;
if(Math.abs(this.position.x - goalX) > 0.01) {
var diff = goalX - this.position.x;
this.position.x += (diff > 0 ? 1 : diff < 0 ? -1 : 0) * Math.min(flyingDistanceLeft,Math.abs(diff));
flyingDistanceLeft -= Math.abs(diff);
} else if(Math.abs(this.position.y - goalY) > 0.01) {
var diff1 = goalY - this.position.y;
this.position.y += (diff1 > 0 ? 1 : diff1 < 0 ? -1 : 0) * Math.min(flyingDistanceLeft,Math.abs(diff1));
flyingDistanceLeft -= Math.abs(diff1);
} else {
this.position.x = goalX;
this.position.y = goalY;
if(this.pathPos == 0) {
var _g = 0;
var _g1 = this.passengers;
while(_g < _g1.length) {
var person = _g1[_g];
++_g;
person.fullyBeingControlled = false;
if(person.inPermanent != null) {
person.inPermanent.onCitizenLeave(person,this.destination);
}
person.inPermanent = this.destination;
person.onWorld = person.inPermanent.world;
person.inBuildingSince = person.city.simulation.time.timeSinceStart;
if(person.currentPathActionPermanent != this.destination) {
this.destination.timesUsedStopOver++;
} else {
this.destination.timesUsedTo++;
}
}
this.destination.addFlyingSaucer();
this.destroy();
return;
} else {
this.pathPos--;
}
}
}
this.sprite.position.set(this.position.x,this.position.y);
}
,__class__: simulation_FlyingSaucer
};
var simulation_Happiness = function(city,simulation) {
this.healthCapacityByType = null;
this.veryUnhappyFromDay = -1;
this.lastShownVeryUnhappyWarning = -1;
this.shouldUpdateHappinessIn = 0;
this.happinessEnthusiasmLevel = 0;
this.actualHappiness = 0;
this.lastRestoreTime = -1;
this.lastOvertimeDay = -1;
this.lastOvertime = 0;
this.overtimeStarted = 0;
this.overtimeUnhappinessShown = 0;
this.overtimeUnhappinessActual = 0;
this.foodRationingUnhappiness = 0;
this.foodShortageUnhappiness = 0;
this.enthusiasmHappiness = 0;
this.fullHappinessTime = 0;
this.happiness = -1;
this.city = city;
this.simulation = simulation;
this.entertainmentTypes = [0,1,2,3,4];
HxOverrides.remove(this.entertainmentTypes,5);
var _g = [];
var _g1 = 0;
var _g2 = this.entertainmentTypes.length;
while(_g1 < _g2) {
var i = _g1++;
_g.push(0);
}
this.happinessPerEntertainmentType = _g;
this.actionSpeedModifierWithoutPenalties = 1;
this.happinessBoosts = [];
};
$hxClasses["simulation.Happiness"] = simulation_Happiness;
simulation_Happiness.__name__ = "simulation.Happiness";
simulation_Happiness.prototype = {
set_happiness: function(newHappiness) {
this.actionSpeedModifier = newHappiness <= 50 ? 0.25 + newHappiness / 50 * 0.75 : 1 + (newHappiness - 50) / 50;
return this.happiness = newHappiness;
}
,update: function(timeMod) {
var time = this.simulation.time;
var b = this.happinessBoosts.length - 1;
while(b >= 0) {
var boost = this.happinessBoosts[b];
if(boost.hasPassed(time)) {
this.happinessBoosts.splice(b,1);
}
--b;
}
if(this.shouldUpdateHappinessIn <= 0) {
this.actualHappiness = this.getActualHappiness();
this.shouldUpdateHappinessIn = 60;
} else {
this.shouldUpdateHappinessIn -= Math.max(1,timeMod);
}
if(this.happiness == -1) {
this.set_happiness(this.actualHappiness);
}
var changeHappinessWith = 0.05 * timeMod;
if(Math.abs(this.actualHappiness - this.happiness) < changeHappinessWith) {
this.set_happiness(this.actualHappiness);
} else {
var _g = this;
var num = this.actualHappiness - this.happiness;
_g.set_happiness(_g.happiness + (num > 0 ? 1 : num < 0 ? -1 : 0) * changeHappinessWith);
}
if(this.happiness >= 99.99) {
this.fullHappinessTime += timeMod * this.city.simulation.time.minutesPerTick;
} else {
this.fullHappinessTime = 0;
}
if(this.happiness <= 10.01) {
if(1 + ((time.timeSinceStart | 0) / 1440 | 0) != this.lastShownVeryUnhappyWarning) {
if(this.veryUnhappyFromDay == -1) {
this.veryUnhappyFromDay = 1 + ((time.timeSinceStart | 0) / 1440 | 0);
this.lastShownVeryUnhappyWarning = 1 + ((time.timeSinceStart | 0) / 1440 | 0);
this.city.gui.showSimpleWindow("Your citizens are very unhappy! They work much slower while they're unhappy, so it's a good idea to solve their problems. " + this.city.game.textHelper.clickOrTap() + " on the Happiness button near the bottom right for more information.","Your citizens are unhappy!",true,true);
this.city.gui.pauseForWindow();
}
}
} else {
this.veryUnhappyFromDay = -1;
}
if(2 == 1) {
common_KongTools.reportHappiness(this.happiness | 0);
}
}
,getActualHappiness: function() {
var doneWorld = new haxe_ds_ObjectMap();
var worldGroup = new haxe_ds_ObjectMap();
var maxWorldGroup = 0;
var entertainmentPerGroup = [];
var entertainmentSubtypeBuildingsPerGroup = [];
var medicalBuildingsPerGroup = [];
var citizensPerGroup = [];
var entertainmentTypeNum = this.entertainmentTypes.length;
var _g = 0;
var _g1 = this.city.worlds;
while(_g < _g1.length) {
var worldForGrouping = _g1[_g];
++_g;
if(!doneWorld.h[worldForGrouping.__id__]) {
var _g2 = [];
var _g3 = 0;
var _g4 = entertainmentTypeNum;
while(_g3 < _g4) {
var i = _g3++;
_g2.push([]);
}
var theseEntertainmentSubtypesBuildings = _g2;
var theseMedicalBuildings = [];
var entertainment = 0.0;
var _g5 = 0;
var _g6 = worldForGrouping.reachableWorlds;
while(_g5 < _g6.length) {
var world = _g6[_g5];
++_g5;
worldGroup.set(world,maxWorldGroup);
doneWorld.set(world,true);
var _g7 = 0;
var _g8 = world.permanents;
while(_g7 < _g8.length) {
var permanentStack = _g8[_g7];
++_g7;
var _g9 = 0;
while(_g9 < permanentStack.length) {
var permanent = permanentStack[_g9];
++_g9;
if(permanent == null) {
continue;
}
if(permanent.isBuilding) {
if(permanent.isEntertainment) {
var entertainmentBuilding = permanent;
var index = this.entertainmentTypes.indexOf(entertainmentBuilding.get_entertainmentType());
if(index != -1) {
theseEntertainmentSubtypesBuildings[index].push(entertainmentBuilding);
}
} else if(permanent.isMedical) {
var medicalBuilding = permanent;
theseMedicalBuildings.push(medicalBuilding);
}
}
entertainment += permanent.get_baseEntertainmentCapacity() + permanent.bonusEntertainmentCapacity;
}
}
}
entertainmentPerGroup[maxWorldGroup] = entertainment;
entertainmentSubtypeBuildingsPerGroup[maxWorldGroup] = theseEntertainmentSubtypesBuildings;
medicalBuildingsPerGroup[maxWorldGroup] = theseMedicalBuildings;
citizensPerGroup[maxWorldGroup] = 0;
++maxWorldGroup;
}
}
this.homeHappiness = 0;
this.schoolHappiness = 0;
this.purposeHappiness = 0;
var kids = 0;
var _g = 0;
var _g1 = this.simulation.citizens;
while(_g < _g1.length) {
var citizen = _g1[_g];
++_g;
if(citizen.home != null) {
this.homeHappiness += citizen.home.get_attractiveness();
}
if(citizen.job != null) {
this.purposeHappiness += 100;
} else if(citizen.lastInfrequentUpdateAge < 16) {
++kids;
if(citizen.school != null) {
this.schoolHappiness += 100;
this.purposeHappiness += 100;
}
}
citizensPerGroup[worldGroup.h[citizen.onWorld.__id__]] += 1;
}
if(this.simulation.citizens.length > 0) {
this.homeHappiness /= this.simulation.citizens.length;
this.purposeHappiness /= this.simulation.citizens.length;
}
if(kids > 0) {
this.schoolHappiness /= kids;
} else {
this.schoolHappiness = common_ArrayExtensions.any(this.city.permanents,function(p) {
if(p.is(buildings_School)) {
return p.workers.length >= 1;
} else {
return false;
}
}) ? 100 : 0;
}
var _g = 0;
var _g1 = this.happinessPerEntertainmentType.length;
while(_g < _g1) {
var i = _g++;
this.happinessPerEntertainmentType[i] = 0;
}
this.entertainmentHappiness = 0;
this.medicalHappiness = 0;
var _g = [];
_g.push(0);
_g.push(0);
_g.push(0);
_g.push(0);
_g.push(0);
_g.push(0);
_g.push(0);
_g.push(0);
_g.push(0);
_g.push(0);
this.healthCapacityByType = _g;
var _g = 0;
var _g1 = maxWorldGroup;
while(_g < _g1) {
var i = _g++;
var thisEntertainmentHappiness = 32.999999999999993 * Math.min(entertainmentPerGroup[i],citizensPerGroup[i]);
var _g2 = 0;
var _g3 = entertainmentSubtypeBuildingsPerGroup[i].length;
while(_g2 < _g3) {
var j = _g2++;
var subTypeBuildings = entertainmentSubtypeBuildingsPerGroup[i][j];
subTypeBuildings.sort(function(b1,b2) {
var num = b2.get_entertainmentQuality() - b1.get_entertainmentQuality();
if(num > 0) {
return 1;
} else if(num < 0) {
return -1;
} else {
return 0;
}
});
var amountOfCitizensLeft = citizensPerGroup[i];
var thisEntertainmentHappinessPart = 0;
var _g4 = 0;
while(_g4 < subTypeBuildings.length) {
var entertainmentBuilding = subTypeBuildings[_g4];
++_g4;
var citizensForBuilding = amountOfCitizensLeft > entertainmentBuilding.get_entertainmentCapacity() ? entertainmentBuilding.get_entertainmentCapacity() : amountOfCitizensLeft;
thisEntertainmentHappinessPart += citizensForBuilding * entertainmentBuilding.get_entertainmentQuality();
amountOfCitizensLeft -= citizensForBuilding;
if(amountOfCitizensLeft <= 0) {
break;
}
}
thisEntertainmentHappiness += thisEntertainmentHappinessPart * (0.67 / entertainmentTypeNum);
this.happinessPerEntertainmentType[j] += thisEntertainmentHappinessPart / this.simulation.citizens.length;
}
this.entertainmentHappiness += thisEntertainmentHappiness / this.simulation.citizens.length;
var theseMedicalBuildings = medicalBuildingsPerGroup[i];
theseMedicalBuildings.sort(function(b1,b2) {
var num = b2.get_medicalQuality() - b1.get_medicalQuality() + 0.01 * (b2.get_medicalTypeID() - b1.get_medicalTypeID());
if(num > 0) {
return 1;
} else if(num < 0) {
return -1;
} else {
return 0;
}
});
var amountOfCitizensLeft1 = citizensPerGroup[i];
var thisMedicalPart = 0;
var medicalTypes = 0;
var _g5 = 0;
while(_g5 < theseMedicalBuildings.length) {
var medicalBuilding = theseMedicalBuildings[_g5];
++_g5;
var val2 = medicalBuilding.get_medicalTypeID() + 1;
if(val2 > medicalTypes) {
medicalTypes = val2;
}
}
var _g6 = [];
var _g7 = 0;
var _g8 = medicalTypes;
while(_g7 < _g8) {
var i1 = _g7++;
_g6.push(0.0);
}
var medicalLimitUsedPerType = _g6;
var _g9 = 0;
while(_g9 < theseMedicalBuildings.length) {
var medicalBuilding1 = theseMedicalBuildings[_g9];
++_g9;
var citizensForBuilding1 = amountOfCitizensLeft1 > medicalBuilding1.get_medicalCapacity() ? medicalBuilding1.get_medicalCapacity() : amountOfCitizensLeft1;
var thisMaxLimit = medicalBuilding1.get_medicalTypeLimit() * citizensPerGroup[i];
var val = thisMaxLimit - medicalLimitUsedPerType[medicalBuilding1.get_medicalTypeID()];
if(val < 0) {
citizensForBuilding1 = 0;
} else if(!(val > citizensForBuilding1)) {
citizensForBuilding1 = val;
}
medicalLimitUsedPerType[medicalBuilding1.get_medicalTypeID()] += citizensForBuilding1;
this.healthCapacityByType[medicalBuilding1.get_medicalTypeID()] += citizensForBuilding1;
thisMedicalPart += citizensForBuilding1 * medicalBuilding1.get_medicalQuality();
amountOfCitizensLeft1 -= citizensForBuilding1;
if(amountOfCitizensLeft1 <= 0) {
break;
}
}
this.medicalHappiness += thisMedicalPart / this.simulation.citizens.length;
}
this.entertainmentHappiness = Math.min(100,this.entertainmentHappiness + 0.01);
this.medicalHappiness = Math.min(100,this.medicalHappiness + 0.01);
var newHappiness = this.homeHappiness * 0.4 + this.entertainmentHappiness * 0.3 + this.schoolHappiness * 0.1 + this.medicalHappiness * 0.1 + this.purposeHappiness * 0.1;
newHappiness = Math.min(100,newHappiness + 0.01);
this.actionSpeedModifierWithoutPenalties = newHappiness <= 50 ? 0.25 + newHappiness / 50 * 0.75 : 1 + (newHappiness - 50) / 50;
var foodShortage = this.simulation.eating.foodShortage;
if(foodShortage > 0) {
this.foodRationingUnhappiness = 0;
if(this.actionSpeedModifierWithoutPenalties < 1) {
this.actionSpeedModifierWithoutPenalties = 1;
}
if(foodShortage >= 10) {
this.foodShortageUnhappiness = newHappiness;
newHappiness = 0;
} else if(newHappiness > 10) {
this.foodShortageUnhappiness = newHappiness - 10;
newHappiness = 10;
} else {
this.foodShortageUnhappiness = 0;
}
} else {
this.foodShortageUnhappiness = 0;
this.foodRationingUnhappiness = 0;
if(newHappiness > 10) {
if(this.city.simulation.eating.foodRationing) {
var newHappinessAfterRationing = Math.max(10,newHappiness * 0.67);
this.foodRationingUnhappiness = newHappiness - newHappinessAfterRationing;
newHappiness = newHappinessAfterRationing;
}
}
}
if(this.city.policies.vars.workTimeChange > 0) {
this.lastOvertime = this.city.simulation.time.timeSinceStart / 1440;
this.overtimeUnhappinessActual = Math.max(this.overtimeUnhappinessActual,5);
if(this.lastOvertimeDay == -1) {
this.lastOvertimeDay = this.lastOvertime;
} else if(this.city.simulation.time.timeSinceStart / 1440 > this.lastOvertimeDay + 1) {
this.lastOvertimeDay = this.city.simulation.time.timeSinceStart / 1440;
this.overtimeUnhappinessActual = Math.min(this.overtimeUnhappinessActual + 5,50);
}
this.lastRestoreTime = -1;
} else if(this.city.simulation.time.timeSinceStart / 1440 > this.lastOvertimeDay + 1) {
if(this.lastRestoreTime == -1) {
this.lastRestoreTime = this.city.simulation.time.timeSinceStart / 1440;
} else {
var reduceOvertimeBy = (this.city.simulation.time.timeSinceStart / 1440 - this.lastRestoreTime) * 10;
this.lastRestoreTime = this.city.simulation.time.timeSinceStart / 1440;
this.overtimeUnhappinessActual = Math.max(0,this.overtimeUnhappinessActual - reduceOvertimeBy);
}
this.lastOvertimeDay = -1;
}
this.overtimeUnhappinessShown = 0;
if(this.overtimeUnhappinessActual > 0) {
this.overtimeUnhappinessShown = Math.min(this.overtimeUnhappinessActual,newHappiness);
newHappiness -= this.overtimeUnhappinessShown;
}
if(newHappiness < this.happinessEnthusiasmLevel) {
this.enthusiasmHappiness = this.happinessEnthusiasmLevel - newHappiness;
newHappiness = this.happinessEnthusiasmLevel;
} else {
this.enthusiasmHappiness = 0;
}
var _g = 0;
var _g1 = this.happinessBoosts;
while(_g < _g1.length) {
var boost = _g1[_g];
++_g;
if(!boost.canGoOverMax) {
newHappiness = Math.min(100,newHappiness + boost.boost);
}
}
var _g = 0;
var _g1 = this.happinessBoosts;
while(_g < _g1.length) {
var boost = _g1[_g];
++_g;
if(boost.canGoOverMax) {
newHappiness += boost.boost;
}
}
return newHappiness;
}
,addBoost: function(boost) {
this.happinessBoosts.push(boost);
}
,save: function(queue) {
this.saveBasics(queue);
var value = this.happinessBoosts.length;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var _g = 0;
var _g1 = this.happinessBoosts;
while(_g < _g1.length) {
var boost = _g1[_g];
++_g;
boost.save(queue);
}
}
,load: function(queue) {
this.loadBasics(queue);
if(queue.version >= 20) {
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var happinessBoostsLen = intToRead;
var _g = 0;
var _g1 = happinessBoostsLen;
while(_g < _g1) {
var i = _g++;
var boost = new simulation_HappinessBoost(0,0,"");
boost.load(queue);
this.happinessBoosts.push(boost);
}
}
}
,saveBasics: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
if(shouldSaveDefinition) {
queue.addString(simulation_Happiness.saveDefinition);
}
var value = this.happiness;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.homeHappiness;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.purposeHappiness;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.entertainmentHappiness;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.schoolHappiness;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.medicalHappiness;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.fullHappinessTime;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.overtimeUnhappinessActual;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.overtimeStarted;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.lastOvertime;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.lastOvertimeDay;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.lastRestoreTime;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.actualHappiness;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.happinessEnthusiasmLevel;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.lastShownVeryUnhappyWarning;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.veryUnhappyFromDay;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
,loadBasics: function(queue,definition) {
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"happiness")) {
this.set_happiness(loadMap.h["happiness"]);
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"homeHappiness")) {
this.homeHappiness = loadMap.h["homeHappiness"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"purposeHappiness")) {
this.purposeHappiness = loadMap.h["purposeHappiness"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"entertainmentHappiness")) {
this.entertainmentHappiness = loadMap.h["entertainmentHappiness"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"schoolHappiness")) {
this.schoolHappiness = loadMap.h["schoolHappiness"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"medicalHappiness")) {
this.medicalHappiness = loadMap.h["medicalHappiness"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"fullHappinessTime")) {
this.fullHappinessTime = loadMap.h["fullHappinessTime"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"overtimeUnhappinessActual")) {
this.overtimeUnhappinessActual = loadMap.h["overtimeUnhappinessActual"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"overtimeStarted")) {
this.overtimeStarted = loadMap.h["overtimeStarted"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"lastOvertime")) {
this.lastOvertime = loadMap.h["lastOvertime"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"lastOvertimeDay")) {
this.lastOvertimeDay = loadMap.h["lastOvertimeDay"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"lastRestoreTime")) {
this.lastRestoreTime = loadMap.h["lastRestoreTime"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"actualHappiness")) {
this.actualHappiness = loadMap.h["actualHappiness"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"happinessEnthusiasmLevel")) {
this.happinessEnthusiasmLevel = loadMap.h["happinessEnthusiasmLevel"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"lastShownVeryUnhappyWarning")) {
this.lastShownVeryUnhappyWarning = loadMap.h["lastShownVeryUnhappyWarning"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"veryUnhappyFromDay")) {
this.veryUnhappyFromDay = loadMap.h["veryUnhappyFromDay"];
}
}
,__class__: simulation_Happiness
};
var simulation_HappinessBoost = function(boostUntil,boost,text) {
this.canGoOverMax = true;
this.boostUntil = boostUntil;
this.boost = boost;
this.text = text;
};
$hxClasses["simulation.HappinessBoost"] = simulation_HappinessBoost;
simulation_HappinessBoost.__name__ = "simulation.HappinessBoost";
simulation_HappinessBoost.withDuration = function(cityTime,duration,boost,text) {
return new simulation_HappinessBoost(cityTime.timeSinceStart + duration,boost,text);
};
simulation_HappinessBoost.prototype = {
hasPassed: function(cityTime) {
return cityTime.timeSinceStart > this.boostUntil;
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
if(shouldSaveDefinition) {
queue.addString(simulation_HappinessBoost.saveDefinition);
}
var value = this.boostUntil;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.boost;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
queue.addString(this.text);
var value = this.canGoOverMax;
if(queue.size + 1 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 1) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.b[queue.size] = value ? 1 : 0;
queue.size += 1;
}
,load: function(queue,definition) {
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"boostUntil")) {
this.boostUntil = loadMap.h["boostUntil"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"boost")) {
this.boost = loadMap.h["boost"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"text")) {
this.text = loadMap.h["text"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"canGoOverMax")) {
this.canGoOverMax = loadMap.h["canGoOverMax"];
}
}
,__class__: simulation_HappinessBoost
};
var simulation_HouseAssigner = function(city,simulation) {
this.shouldUpdateHouses = true;
this.city = city;
this.simulation = simulation;
var _g = [];
var _g1 = 0;
while(_g1 < 101) {
var i = _g1++;
_g.push(0);
}
this.peoplePerHomeQuality = _g;
var _g = [];
var _g1 = 0;
while(_g1 < 101) {
var i = _g1++;
_g.push(0);
}
this.emptyPlacesPerHomeQuality = _g;
var _g = [];
var _g1 = 0;
while(_g1 < 101) {
var i = _g1++;
_g.push(0);
}
this.transferFrom = _g;
this.citizensWithFixedHomes = [];
};
$hxClasses["simulation.HouseAssigner"] = simulation_HouseAssigner;
simulation_HouseAssigner.__name__ = "simulation.HouseAssigner";
simulation_HouseAssigner.prototype = {
assignHouses: function() {
if(!this.shouldUpdateHouses) {
return;
}
var _g = [];
var _g1 = 0;
var _g2 = this.city.connections.numberOfWorldGroups;
while(_g1 < _g2) {
var i = _g1++;
_g.push(false);
}
var doneWorldGroup = _g;
var _g = [];
var _g1 = 0;
var _g2 = this.city.connections.numberOfWorldGroups;
while(_g1 < _g2) {
var i = _g1++;
_g.push(0);
}
simulation_HouseAssigner.privateTeleportersLeft = _g;
var _g = 0;
var _g1 = this.city.worlds;
while(_g < _g1.length) {
var world = _g1[_g];
++_g;
if(doneWorldGroup[world.worldGroup]) {
continue;
}
var _g2 = 0;
while(_g2 < 101) {
var i = _g2++;
this.peoplePerHomeQuality[i] = 0;
}
var _g3 = 0;
while(_g3 < 101) {
var i1 = _g3++;
this.emptyPlacesPerHomeQuality[i1] = 0;
}
var _g4 = 0;
while(_g4 < 101) {
var i2 = _g4++;
this.transferFrom[i2] = 0;
}
simulation_HouseAssigner.privateTeleportersLeft[world.worldGroup] = 0;
var _g5 = 0;
var _g6 = this.city.worlds;
while(_g5 < _g6.length) {
var w = _g6[_g5];
++_g5;
if(world.worldGroup != w.worldGroup) {
continue;
}
var _g7 = 0;
var _g8 = w.permanents;
while(_g7 < _g8.length) {
var ps = _g8[_g7];
++_g7;
var _g9 = 0;
while(_g9 < ps.length) {
var p = ps[_g9];
++_g9;
if(p != null && p.is(buildings_House)) {
var thisHome = p;
var val = thisHome.get_attractiveness();
var quality = (val < 0 ? 0 : val > 100 ? 100 : val) | 0;
if(!p.is(buildings_WorkWithHome)) {
if(thisHome.get_hasPrivateTeleporter() && thisHome.get_remainingCapacity() > 0) {
simulation_HouseAssigner.privateTeleportersLeft[world.worldGroup] += 1;
}
var _g10 = 0;
var _g11 = thisHome.residents;
while(_g10 < _g11.length) {
var res = _g11[_g10];
++_g10;
if(!res.isForcedHome) {
this.peoplePerHomeQuality[quality] += 1;
}
}
this.emptyPlacesPerHomeQuality[quality] += thisHome.get_remainingCapacity();
}
}
}
}
}
var checkingPeople = 0;
var checkingPlaces = 100;
while(checkingPeople < checkingPlaces) {
while(checkingPeople < checkingPlaces && this.peoplePerHomeQuality[checkingPeople] > 0) {
var val1 = this.emptyPlacesPerHomeQuality[checkingPlaces];
var val2 = this.peoplePerHomeQuality[checkingPeople];
var transferNum = val2 < val1 ? val2 : val1;
this.transferFrom[checkingPeople] += transferNum;
this.emptyPlacesPerHomeQuality[checkingPlaces] -= transferNum;
this.peoplePerHomeQuality[checkingPeople] -= transferNum;
--checkingPlaces;
}
++checkingPeople;
}
var _g12 = 0;
var _g13 = this.city.worlds;
while(_g12 < _g13.length) {
var w1 = _g13[_g12];
++_g12;
if(world.worldGroup != w1.worldGroup) {
continue;
}
var _g14 = 0;
var _g15 = w1.permanents;
while(_g14 < _g15.length) {
var ps1 = _g15[_g14];
++_g14;
var _g16 = 0;
while(_g16 < ps1.length) {
var p1 = ps1[_g16];
++_g16;
if(p1 != null && p1.is(buildings_House)) {
var thisHome1 = p1;
var val3 = thisHome1.get_attractiveness();
var quality1 = (val3 < 0 ? 0 : val3 > 100 ? 100 : val3) | 0;
if(this.transferFrom[quality1] > 0) {
var c = thisHome1.residents.length;
while(--c >= 0) {
var citizen = thisHome1.residents[c];
if(this.transferFrom[quality1] > 0 && !citizen.isForcedHome) {
citizen.evictFromHome();
this.transferFrom[quality1]--;
}
}
}
}
}
}
}
doneWorldGroup[world.worldGroup] = true;
}
var _g = [];
var _g1 = 0;
var _g2 = this.city.connections.numberOfWorldGroups;
while(_g1 < _g2) {
var i = _g1++;
_g.push(false);
}
var worldGroupIsImpossible = _g;
var _g = 0;
var _g1 = this.simulation.citizens;
while(_g < _g1.length) {
var citizen = _g1[_g];
++_g;
if(!worldGroupIsImpossible[citizen.onWorld.worldGroup]) {
var citizen1 = [citizen];
var isHouseWithCapacityOnReachableWorld = [(function() {
return function(c,pm) {
var pm1 = pm;
if(pm1.is(buildings_House) && pm1.get_remainingCapacity() > 0 && (pm1.get_fixedCapacityForWorkers() == 0 || Lambda.count(pm1.workers,(function() {
return function(w) {
return w.job == pm1;
};
})()) >= pm1.get_fixedCapacityForWorkers())) {
return c.onWorld.worldGroup == pm.world.worldGroup;
} else {
return false;
}
};
})()];
var isHouseWithCapacityOnReachableWorldFromBuilding = [(function() {
return function(building,pm) {
var pm1 = pm;
if(pm1.is(buildings_House) && pm1.get_remainingCapacity() > 0 && (pm1.get_fixedCapacityForWorkers() == 0 || Lambda.count(pm1.workers,(function() {
return function(w) {
return w.job == pm1;
};
})()) >= pm1.get_fixedCapacityForWorkers())) {
return building.world.worldGroup == pm.world.worldGroup;
} else {
return false;
}
};
})()];
var isHouseWithCapacityOnReachableWorldOrTeleporter = [(function() {
return function(c,pm) {
var pm1 = pm;
if(!(pm1.is(buildings_House) && pm1.get_remainingCapacity() > 0 && (pm1.get_fixedCapacityForWorkers() == 0 || Lambda.count(pm1.workers,(function() {
return function(w) {
return w.job == pm1;
};
})()) >= pm1.get_fixedCapacityForWorkers()) && c.onWorld.worldGroup == pm.world.worldGroup)) {
return pm.is(buildings_Teleporter);
} else {
return true;
}
};
})()];
var isHouseWithCapacityOnReachableWorldFromBuildingOrTeleporter = [(function() {
return function(building,pm) {
var pm1 = pm;
if(!(pm1.is(buildings_House) && pm1.get_remainingCapacity() > 0 && (pm1.get_fixedCapacityForWorkers() == 0 || Lambda.count(pm1.workers,(function() {
return function(w) {
return w.job == pm1;
};
})()) >= pm1.get_fixedCapacityForWorkers()) && building.world.worldGroup == pm.world.worldGroup)) {
return pm.is(buildings_Teleporter);
} else {
return true;
}
};
})()];
if(citizen1[0].home == null) {
var newHome = null;
if(simulation_HouseAssigner.privateTeleportersLeft[citizen1[0].onWorld.worldGroup] > 0) {
if(citizen1[0].job != null) {
var newHome1 = this.simulation.permanentFinder;
var citizen2 = citizen1[0].job;
var newHome2 = (function(building,isHouseWithCapacityOnReachableWorldFromBuildingOrTeleporter) {
return function(pm) {
return isHouseWithCapacityOnReachableWorldFromBuildingOrTeleporter[0](building[0],pm);
};
})([citizen1[0].job],isHouseWithCapacityOnReachableWorldFromBuildingOrTeleporter);
var getAttractiveness = (function() {
return function(house) {
if(house.is(buildings_Teleporter)) {
return 100;
} else {
return house.get_baseAttractiveness() + house.bonusAttractiveness;
}
};
})();
newHome = newHome1.query(citizen2,newHome2,getAttractiveness,null,99.999999);
} else {
var newHome3 = this.city.permanents;
var newHome4 = (function(c,isHouseWithCapacityOnReachableWorldOrTeleporter) {
return function(pm) {
return isHouseWithCapacityOnReachableWorldOrTeleporter[0](c[0],pm);
};
})([citizen1[0]],isHouseWithCapacityOnReachableWorldOrTeleporter);
var getAttractiveness1 = (function() {
return function(house) {
if(house.is(buildings_Teleporter)) {
return 100;
} else {
return house.get_baseAttractiveness() + house.bonusAttractiveness;
}
};
})();
newHome = common_ArrayExtensions.whereMax(newHome3,newHome4,getAttractiveness1);
}
if(newHome != null && newHome.is(buildings_Teleporter)) {
newHome = Lambda.find(this.city.permanents,(function(citizen) {
return function(pm) {
if(pm.is(buildings_House) && citizen[0].onWorld.worldGroup == pm.world.worldGroup) {
var thisHouse = pm;
if(thisHouse.get_hasPrivateTeleporter()) {
var pm1 = pm;
if(pm1.is(buildings_House) && pm1.get_remainingCapacity() > 0) {
if(pm1.get_fixedCapacityForWorkers() != 0) {
return Lambda.count(pm1.workers,(function() {
return function(w) {
return w.job == pm1;
};
})()) >= pm1.get_fixedCapacityForWorkers();
} else {
return true;
}
} else {
return false;
}
}
}
return false;
};
})(citizen1));
}
} else if(citizen1[0].job != null) {
var newHome5 = this.simulation.permanentFinder;
var citizen3 = citizen1[0].job;
var newHome6 = (function(building,isHouseWithCapacityOnReachableWorldFromBuilding) {
return function(pm) {
return isHouseWithCapacityOnReachableWorldFromBuilding[0](building[0],pm);
};
})([citizen1[0].job],isHouseWithCapacityOnReachableWorldFromBuilding);
var getAttractiveness2 = (function() {
return function(house) {
return house.get_baseAttractiveness() + house.bonusAttractiveness;
};
})();
newHome = newHome5.query(citizen3,newHome6,getAttractiveness2,null,99.999999);
} else {
var newHome7 = this.city.permanents;
var newHome8 = (function(c,isHouseWithCapacityOnReachableWorld) {
return function(pm) {
return isHouseWithCapacityOnReachableWorld[0](c[0],pm);
};
})([citizen1[0]],isHouseWithCapacityOnReachableWorld);
var getAttractiveness3 = (function() {
return function(house) {
return house.get_baseAttractiveness() + house.bonusAttractiveness;
};
})();
newHome = common_ArrayExtensions.whereMax(newHome7,newHome8,getAttractiveness3);
}
if(newHome != null) {
citizen1[0].home = newHome;
newHome.residents.push(citizen1[0]);
if(newHome.get_hasPrivateTeleporter()) {
simulation_HouseAssigner.privateTeleportersLeft[citizen1[0].onWorld.worldGroup]--;
}
}
}
if(citizen.home == null) {
worldGroupIsImpossible[citizen.onWorld.worldGroup] = true;
}
}
}
this.shouldUpdateHouses = false;
}
,load: function(queue) {
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var numberOfCitizensWithFixedHomes = intToRead;
this.citizensWithFixedHomes = [];
var _g = 0;
var _g1 = numberOfCitizensWithFixedHomes;
while(_g < _g1) {
var i = _g++;
var theCitizen = this.simulation.citizens;
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var theCitizen1 = theCitizen[intToRead];
theCitizen1.isForcedHome = true;
this.citizensWithFixedHomes.push(theCitizen1);
}
}
,save: function(queue) {
var value = this.citizensWithFixedHomes.length;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
if(this.citizensWithFixedHomes.length >= 10) {
var _g = 0;
var _g1 = this.simulation.citizens;
while(_g < _g1.length) {
var citizen = _g1[_g];
++_g;
if(citizen.isForcedHome) {
var value = this.simulation.citizens.indexOf(citizen);
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
}
} else {
var _g = 0;
var _g1 = this.citizensWithFixedHomes;
while(_g < _g1.length) {
var citizen = _g1[_g];
++_g;
var value = this.simulation.citizens.indexOf(citizen);
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
}
}
,__class__: simulation_HouseAssigner
};
var simulation_JobAssigner = function(city,simulation) {
this.availableClassesForJob = [];
this.citizensWithoutJob = [];
this.buildingsHaveWork = true;
this.city = city;
this.simulation = simulation;
this.priorityJobs = new haxe_ds_StringMap();
};
$hxClasses["simulation.JobAssigner"] = simulation_JobAssigner;
simulation_JobAssigner.__name__ = "simulation.JobAssigner";
simulation_JobAssigner.prototype = {
assignJobs: function() {
if(this.buildingsHaveWork) {
var buildingsWithJob = [];
var _g = [];
var _g1 = 0;
var _g2 = PermanentMetaHelper.getClassIDLength();
while(_g1 < _g2) {
var i = _g1++;
_g.push(0);
}
var workersShortPerBuildingType = _g;
var _g = [];
var _g1 = 0;
var _g2 = PermanentMetaHelper.getClassIDLength();
while(_g1 < _g2) {
var i = _g1++;
_g.push(false);
}
var isMaxPrio = _g;
var prioJob = haxe_ds_StringMap.keysIterator(this.priorityJobs.h);
while(prioJob.hasNext()) {
var prioJob1 = prioJob.next();
var classID = PermanentMetaHelper.getClassID(prioJob1);
var priorityJobs = Object.prototype.hasOwnProperty.call(this.priorityJobs.h,prioJob1) ? this.priorityJobs.h[prioJob1] : 0;
isMaxPrio[classID] = priorityJobs == 1000000;
workersShortPerBuildingType[classID] = isMaxPrio[classID] ? 0 : priorityJobs;
}
var _g = 0;
var _g1 = this.city.workBuildings;
while(_g < _g1.length) {
var thisWork = _g1[_g];
++_g;
if(thisWork.workers.length < thisWork.get_jobs()) {
buildingsWithJob.push(thisWork);
}
if(isMaxPrio[thisWork.classID]) {
workersShortPerBuildingType[thisWork.classID] += thisWork.get_jobs();
}
workersShortPerBuildingType[thisWork.classID] -= thisWork.workers.length;
}
var isHandlingPriorityJobs = false;
var priorityJobShortTypes = 0;
var _g = 0;
while(_g < workersShortPerBuildingType.length) {
var w = workersShortPerBuildingType[_g];
++_g;
if(w > 0) {
isHandlingPriorityJobs = true;
++priorityJobShortTypes;
}
}
if(!isHandlingPriorityJobs && this.citizensWithoutJob.length == 0 && this.availableClassesForJob.length == 0) {
this.buildingsHaveWork = false;
return;
}
var buildingsWithJobNeedSort = true;
var anyJobHadResult = true;
var _g = [];
var _g1 = 0;
var _g2 = this.city.connections.numberOfWorldGroups;
while(_g1 < _g2) {
var i = _g1++;
_g.push(false);
}
var worldGroupNoOptions = _g;
while(anyJobHadResult) {
anyJobHadResult = false;
if(buildingsWithJobNeedSort) {
buildingsWithJob.sort((function() {
return function(b1,b2) {
if(b1.workers.length > b2.workers.length) {
return 1;
} else if(b1.workers.length < b2.workers.length) {
return -1;
} else {
return 0;
}
};
})());
buildingsWithJobNeedSort = false;
}
var _g = 0;
while(_g < buildingsWithJob.length) {
var building = [buildingsWithJob[_g]];
++_g;
if(building[0].workers.length == building[0].get_jobs()) {
continue;
}
if(isHandlingPriorityJobs && workersShortPerBuildingType[building[0].classID] <= 0) {
continue;
}
var bestCitizen = Lambda.find(this.citizensWithoutJob,(function(building) {
return function(c) {
if(c.onWorld.worldGroup != building[0].world.worldGroup) {
if(c.home != null && c.home.get_hasPrivateTeleporter() && building[0].world.hasTeleporterOnGroup) {
return !building[0].is(buildings_House);
} else {
return false;
}
} else {
return true;
}
};
})(building));
if(isHandlingPriorityJobs && bestCitizen == null) {
if(!worldGroupNoOptions[building[0].world.worldGroup]) {
var bestFoundBuildingToFireFrom = null;
var bestFoundBuildingToFireFromWorkers = 0;
var _g1 = 0;
var _g2 = this.city.workBuildings;
while(_g1 < _g2.length) {
var thisWork = _g2[_g1];
++_g1;
if(building[0].world.worldGroup == thisWork.world.worldGroup && thisWork.workers.length > bestFoundBuildingToFireFromWorkers && workersShortPerBuildingType[thisWork.classID] < 0) {
bestFoundBuildingToFireFrom = thisWork;
bestFoundBuildingToFireFromWorkers = thisWork.workers.length;
}
}
if(bestFoundBuildingToFireFrom != null && bestFoundBuildingToFireFrom.workers.length > 0) {
bestCitizen = bestFoundBuildingToFireFrom.workers[bestFoundBuildingToFireFrom.workers.length - 1];
bestCitizen.loseJob(true);
workersShortPerBuildingType[bestFoundBuildingToFireFrom.classID] += 1;
} else {
worldGroupNoOptions[building[0].world.worldGroup] = true;
}
}
} else if(this.availableClassesForJob.length > 0 && bestCitizen == null) {
var bestFoundBuildingToFireFrom1 = null;
var bestFoundBuildingToFireFromWorkers1 = 0;
var _this = this.availableClassesForJob;
var result = new Array(_this.length);
var _g3 = 0;
var _g4 = _this.length;
while(_g3 < _g4) {
var i = _g3++;
result[i] = _this[i].classType;
}
var availableClassesForJobClasses = result;
var _g5 = 0;
var _g6 = this.city.workBuildings;
while(_g5 < _g6.length) {
var thisWork1 = _g6[_g5];
++_g5;
if(building[0].world.worldGroup == thisWork1.world.worldGroup && thisWork1.workers.length > bestFoundBuildingToFireFromWorkers1 && workersShortPerBuildingType[thisWork1.classID] < 0 && availableClassesForJobClasses.indexOf(thisWork1.classID) != -1) {
bestFoundBuildingToFireFrom1 = thisWork1;
bestFoundBuildingToFireFromWorkers1 = thisWork1.workers.length;
}
}
if(bestFoundBuildingToFireFrom1 != null) {
var _g7 = 0;
var _g8 = this.availableClassesForJob.length;
while(_g7 < _g8) {
var i1 = _g7++;
if(this.availableClassesForJob[i1].classType == building[0].classID) {
this.availableClassesForJob[i1].number -= 1;
if(this.availableClassesForJob[i1].number <= 0) {
this.availableClassesForJob.splice(i1,1);
}
break;
}
}
if(bestFoundBuildingToFireFrom1 != building[0]) {
bestCitizen = bestFoundBuildingToFireFrom1.workers[bestFoundBuildingToFireFrom1.workers.length - 1];
bestCitizen.loseJob(true);
workersShortPerBuildingType[bestFoundBuildingToFireFrom1.classID] += 1;
}
}
}
if(bestCitizen != null) {
anyJobHadResult = true;
workersShortPerBuildingType[building[0].classID] -= 1;
HxOverrides.remove(this.citizensWithoutJob,bestCitizen);
building[0].workers.push(bestCitizen);
bestCitizen.job = building[0];
building[0].afterGiveJob(bestCitizen);
if(bestCitizen.onWorld.worldGroup == building[0].world.worldGroup) {
bestCitizen.evictFromHome();
var hasAssignedHome = false;
if(building[0].is(buildings_House) && building[0].get_remainingCapacity() > 0) {
var home = building[0];
bestCitizen.home = home;
home.residents.push(bestCitizen);
hasAssignedHome = true;
}
if(!hasAssignedHome || bestCitizen.home == null) {
var _this1 = this.simulation.houseAssigner;
var citizen = [bestCitizen];
var isHouseWithCapacityOnReachableWorld = [(function() {
return function(c,pm) {
var pm1 = pm;
if(pm1.is(buildings_House) && pm1.get_remainingCapacity() > 0 && (pm1.get_fixedCapacityForWorkers() == 0 || Lambda.count(pm1.workers,(function() {
return function(w) {
return w.job == pm1;
};
})()) >= pm1.get_fixedCapacityForWorkers())) {
return c.onWorld.worldGroup == pm.world.worldGroup;
} else {
return false;
}
};
})()];
var isHouseWithCapacityOnReachableWorldFromBuilding = [(function() {
return function(building,pm) {
var pm1 = pm;
if(pm1.is(buildings_House) && pm1.get_remainingCapacity() > 0 && (pm1.get_fixedCapacityForWorkers() == 0 || Lambda.count(pm1.workers,(function() {
return function(w) {
return w.job == pm1;
};
})()) >= pm1.get_fixedCapacityForWorkers())) {
return building.world.worldGroup == pm.world.worldGroup;
} else {
return false;
}
};
})()];
var isHouseWithCapacityOnReachableWorldOrTeleporter = [(function() {
return function(c,pm) {
var pm1 = pm;
if(!(pm1.is(buildings_House) && pm1.get_remainingCapacity() > 0 && (pm1.get_fixedCapacityForWorkers() == 0 || Lambda.count(pm1.workers,(function() {
return function(w) {
return w.job == pm1;
};
})()) >= pm1.get_fixedCapacityForWorkers()) && c.onWorld.worldGroup == pm.world.worldGroup)) {
return pm.is(buildings_Teleporter);
} else {
return true;
}
};
})()];
var isHouseWithCapacityOnReachableWorldFromBuildingOrTeleporter = [(function() {
return function(building,pm) {
var pm1 = pm;
if(!(pm1.is(buildings_House) && pm1.get_remainingCapacity() > 0 && (pm1.get_fixedCapacityForWorkers() == 0 || Lambda.count(pm1.workers,(function() {
return function(w) {
return w.job == pm1;
};
})()) >= pm1.get_fixedCapacityForWorkers()) && building.world.worldGroup == pm.world.worldGroup)) {
return pm.is(buildings_Teleporter);
} else {
return true;
}
};
})()];
if(citizen[0].home == null) {
var newHome = null;
if(simulation_HouseAssigner.privateTeleportersLeft[citizen[0].onWorld.worldGroup] > 0) {
if(citizen[0].job != null) {
var _this2 = _this1.simulation.permanentFinder;
var citizen1 = citizen[0].job;
var newHome1 = (function(building,isHouseWithCapacityOnReachableWorldFromBuildingOrTeleporter) {
return function(pm) {
return isHouseWithCapacityOnReachableWorldFromBuildingOrTeleporter[0](building[0],pm);
};
})([citizen[0].job],isHouseWithCapacityOnReachableWorldFromBuildingOrTeleporter);
var getAttractiveness = (function() {
return function(house) {
if(house.is(buildings_Teleporter)) {
return 100;
} else {
return house.get_baseAttractiveness() + house.bonusAttractiveness;
}
};
})();
newHome = _this2.query(citizen1,newHome1,getAttractiveness,null,99.999999);
} else {
var _this3 = _this1.city.permanents;
var newHome2 = (function(c,isHouseWithCapacityOnReachableWorldOrTeleporter) {
return function(pm) {
return isHouseWithCapacityOnReachableWorldOrTeleporter[0](c[0],pm);
};
})([citizen[0]],isHouseWithCapacityOnReachableWorldOrTeleporter);
var getAttractiveness1 = (function() {
return function(house) {
if(house.is(buildings_Teleporter)) {
return 100;
} else {
return house.get_baseAttractiveness() + house.bonusAttractiveness;
}
};
})();
newHome = common_ArrayExtensions.whereMax(_this3,newHome2,getAttractiveness1);
}
if(newHome != null && newHome.is(buildings_Teleporter)) {
newHome = Lambda.find(_this1.city.permanents,(function(citizen) {
return function(pm) {
if(pm.is(buildings_House) && citizen[0].onWorld.worldGroup == pm.world.worldGroup) {
var thisHouse = pm;
if(thisHouse.get_hasPrivateTeleporter()) {
var pm1 = pm;
if(pm1.is(buildings_House) && pm1.get_remainingCapacity() > 0) {
if(pm1.get_fixedCapacityForWorkers() != 0) {
return Lambda.count(pm1.workers,(function() {
return function(w) {
return w.job == pm1;
};
})()) >= pm1.get_fixedCapacityForWorkers();
} else {
return true;
}
} else {
return false;
}
}
}
return false;
};
})(citizen));
}
} else if(citizen[0].job != null) {
var _this4 = _this1.simulation.permanentFinder;
var citizen2 = citizen[0].job;
var newHome3 = (function(building,isHouseWithCapacityOnReachableWorldFromBuilding) {
return function(pm) {
return isHouseWithCapacityOnReachableWorldFromBuilding[0](building[0],pm);
};
})([citizen[0].job],isHouseWithCapacityOnReachableWorldFromBuilding);
var getAttractiveness2 = (function() {
return function(house) {
return house.get_baseAttractiveness() + house.bonusAttractiveness;
};
})();
newHome = _this4.query(citizen2,newHome3,getAttractiveness2,null,99.999999);
} else {
var _this5 = _this1.city.permanents;
var newHome4 = (function(c,isHouseWithCapacityOnReachableWorld) {
return function(pm) {
return isHouseWithCapacityOnReachableWorld[0](c[0],pm);
};
})([citizen[0]],isHouseWithCapacityOnReachableWorld);
var getAttractiveness3 = (function() {
return function(house) {
return house.get_baseAttractiveness() + house.bonusAttractiveness;
};
})();
newHome = common_ArrayExtensions.whereMax(_this5,newHome4,getAttractiveness3);
}
if(newHome != null) {
citizen[0].home = newHome;
newHome.residents.push(citizen[0]);
if(newHome.get_hasPrivateTeleporter()) {
simulation_HouseAssigner.privateTeleportersLeft[citizen[0].onWorld.worldGroup]--;
}
}
}
}
}
if(this.citizensWithoutJob.length == 0 && !isHandlingPriorityJobs) {
this.availableClassesForJob = [];
return;
}
if(workersShortPerBuildingType[building[0].classID] <= 0) {
--priorityJobShortTypes;
if(priorityJobShortTypes <= 0) {
isHandlingPriorityJobs = false;
buildingsWithJobNeedSort = true;
break;
}
}
}
}
if(!anyJobHadResult && isHandlingPriorityJobs) {
anyJobHadResult = true;
isHandlingPriorityJobs = false;
buildingsWithJobNeedSort = true;
}
}
this.buildingsHaveWork = false;
this.availableClassesForJob = [];
}
}
,giveCitizenJob: function(citizen,work) {
if(this.citizensWithoutJob.indexOf(citizen) != -1) {
HxOverrides.remove(this.citizensWithoutJob,citizen);
}
work.workers.push(citizen);
citizen.job = work;
work.afterGiveJob(citizen);
}
,save: function(queue) {
var value = Lambda.count(this.priorityJobs);
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var pj = haxe_ds_StringMap.keysIterator(this.priorityJobs.h);
while(pj.hasNext()) {
var pj1 = pj.next();
queue.addString(pj1);
var value = this.priorityJobs.h[pj1];
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
}
,load: function(queue) {
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var num = intToRead;
var _g = 0;
var _g1 = num;
while(_g < _g1) {
var i = _g++;
var key = queue.readString();
var this1 = this.priorityJobs;
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var v = intToRead;
this1.h[key] = v;
}
}
,__class__: simulation_JobAssigner
};
var simulation_ResourcePriorityManager = function(city) {
this.priorities = [];
this.city = city;
};
$hxClasses["simulation.ResourcePriorityManager"] = simulation_ResourcePriorityManager;
simulation_ResourcePriorityManager.__name__ = "simulation.ResourcePriorityManager";
simulation_ResourcePriorityManager.prototype = {
prioritize: function(worldResource) {
if(this.priorities.indexOf(worldResource) == -1) {
this.priorities.push(worldResource);
}
this.invalidatePathfindingAfterPrioritizeChange(worldResource);
}
,invalidatePathfindingAfterPrioritizeChange: function(worldResource) {
if(worldResource.is(worldResources_Rock)) {
var _g = 0;
var _g1 = this.city.permanents;
while(_g < _g1.length) {
var pm = _g1[_g];
++_g;
if(pm.is(buildings_StoneMine)) {
pm.invalidatePathfindingRelatedInfo();
}
}
}
if(worldResource.is(worldResources_Forest)) {
var _g = 0;
var _g1 = this.city.permanents;
while(_g < _g1.length) {
var pm = _g1[_g];
++_g;
if(pm.is(buildings_WoodcuttingCentre)) {
pm.invalidatePathfindingRelatedInfo();
}
}
}
}
,hasResourcePrioritiesFor: function(type) {
return common_ArrayExtensions.any(this.priorities,function(p) {
return p.is(type);
});
}
,deprioritize: function(worldResource) {
if(this.priorities.indexOf(worldResource) != -1) {
this.invalidatePathfindingAfterPrioritizeChange(worldResource);
HxOverrides.remove(this.priorities,worldResource);
}
}
,isPrioritized: function(worldResource) {
return this.priorities.indexOf(worldResource) != -1;
}
,load: function(queue) {
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var numberOfStonePriorities = intToRead;
this.priorities = [];
var _g = 0;
var _g1 = numberOfStonePriorities;
while(_g < _g1) {
var i = _g++;
var this1 = this.city.permanentsByID;
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var pm = this1.h[intToRead];
if(pm != null) {
this.priorities.push(pm);
}
}
}
,save: function(queue) {
var value = this.priorities.length;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var _g = 0;
var _g1 = this.priorities;
while(_g < _g1.length) {
var sp = _g1[_g];
++_g;
var value = sp.id;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
}
}
,__class__: simulation_ResourcePriorityManager
};
var simulation_SchoolAssigner = function(city,simulation) {
this.schoolsShouldBeUpdated = false;
this.city = city;
this.simulation = simulation;
};
$hxClasses["simulation.SchoolAssigner"] = simulation_SchoolAssigner;
simulation_SchoolAssigner.__name__ = "simulation.SchoolAssigner";
simulation_SchoolAssigner.prototype = {
assignSchools: function() {
if(this.schoolsShouldBeUpdated) {
var _g = [];
var _g1 = 0;
var _g2 = this.city.permanents;
while(_g1 < _g2.length) {
var v = _g2[_g1];
++_g1;
var schoolsThatAcceptStudents;
if(!v.is(buildings_School)) {
schoolsThatAcceptStudents = false;
} else {
var schoolP = v;
schoolsThatAcceptStudents = schoolP.students.length < schoolP.get_studentCapacity() && schoolP.workers.length > 0;
}
if(schoolsThatAcceptStudents) {
_g.push(v);
}
}
var schoolsThatAcceptStudents = _g;
if(schoolsThatAcceptStudents.length >= 0) {
schoolsThatAcceptStudents.sort(function(s1,s2) {
return s1.students.length - s2.students.length;
});
var _g = [];
var _g1 = 0;
var _g2 = this.city.simulation.citizens;
while(_g1 < _g2.length) {
var v = _g2[_g1];
++_g1;
if(v.get_age() < 16 && v.school == null) {
_g.push(v);
}
}
var possibleStudents = _g;
var anyAssigned = true;
while(possibleStudents.length > 0 && anyAssigned) {
anyAssigned = false;
var i = schoolsThatAcceptStudents.length;
while(--i >= 0) {
var school = [schoolsThatAcceptStudents[i]];
var correctStudent = Lambda.find(possibleStudents,(function(school) {
return function(s) {
if(s.onWorld.worldGroup != school[0].world.worldGroup) {
if(s.home != null && s.home.get_hasPrivateTeleporter()) {
return school[0].world.hasTeleporterOnGroup;
} else {
return false;
}
} else {
return true;
}
};
})(school));
if(correctStudent != null) {
anyAssigned = true;
HxOverrides.remove(possibleStudents,correctStudent);
correctStudent.school = school[0];
school[0].students.push(correctStudent);
if(school[0].students.length >= school[0].get_studentCapacity()) {
schoolsThatAcceptStudents.splice(i,1);
}
}
if(possibleStudents.length == 0) {
break;
}
}
}
}
this.schoolsShouldBeUpdated = false;
}
}
,__class__: simulation_SchoolAssigner
};
var simulation_SpawnFlyingSaucer = function(simulation,stage,toWorld,spawn,toXIndex) {
this.stage = stage;
this.simulation = simulation;
this.toWorld = toWorld;
this.spawn = spawn;
if(toXIndex == null) {
var bestFoundQuality = -5;
var xIndexOptions = [];
var _g = 0;
var _g1 = toWorld.permanents.length;
while(_g < _g1) {
var x = _g++;
var q = -1;
var permanentStack = toWorld.permanents[x];
if(permanentStack.length == 0) {
q = 1;
} else if(permanentStack[0] != null && permanentStack[0].is(Building) && !permanentStack[0].isRooftopBuilding) {
q = 0;
}
if(q > bestFoundQuality) {
bestFoundQuality = q;
xIndexOptions = [];
}
if(q >= bestFoundQuality) {
xIndexOptions.push(x);
}
}
toXIndex = random_Random.fromArray(xIndexOptions);
}
this.toXIndex = toXIndex;
this.yPositionAboveWorld = 1000 + toWorld.permanents[toXIndex].length * 20;
this.sprite = Resources.makeSprite("spr_flyingsaucer");
this.setSpritePosition();
stage.addChild(this.sprite);
};
$hxClasses["simulation.SpawnFlyingSaucer"] = simulation_SpawnFlyingSaucer;
simulation_SpawnFlyingSaucer.__name__ = "simulation.SpawnFlyingSaucer";
simulation_SpawnFlyingSaucer.fromLoad = function(queue,simulation,stage) {
var simulation1 = simulation.city.worlds;
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var world = simulation1[intToRead];
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var toXIndex = intToRead;
var floatToRead = queue.bytes.getDouble(queue.readStart);
queue.readStart += 8;
var yPositionAboveWorld = floatToRead;
var spawn = queue.readJSON();
var newFlyingSaucer = new simulation_SpawnFlyingSaucer(simulation,stage,world,spawn,toXIndex);
newFlyingSaucer.yPositionAboveWorld = yPositionAboveWorld;
return newFlyingSaucer;
};
simulation_SpawnFlyingSaucer.prototype = {
update: function(timeMod) {
this.yPositionAboveWorld -= timeMod * 3;
this.setSpritePosition();
if(this.yPositionAboveWorld <= this.toWorld.permanents[this.toXIndex].length * 20) {
this.spawnCitizens();
this.destroy();
}
}
,spawnCitizens: function() {
var startPermanent = null;
var startX = null;
var permanentsArray = this.toWorld.permanents[this.toXIndex];
if(permanentsArray.length == 0) {
startX = this.toXIndex * 20;
} else {
startPermanent = permanentsArray[permanentsArray.length - 1];
}
var _g = 0;
var _g1 = this.spawn.amount;
while(_g < _g1) {
var i = _g++;
var age = this.spawn.ageRangeMin;
if(this.spawn.ageRangeMin != this.spawn.ageRangeMax) {
age = random_Random.getFloat(this.spawn.ageRangeMin,this.spawn.ageRangeMax);
}
this.simulation.createCitizen(this.toWorld,age,startPermanent,startX);
}
}
,setSpritePosition: function() {
this.sprite.position.set(this.toWorld.rect.x + this.toXIndex * 20,this.toWorld.rect.y - this.yPositionAboveWorld - 20 + 1);
}
,destroy: function() {
this.stage.removeChild(this.sprite);
HxOverrides.remove(this.simulation.citizenSpawners,this);
}
,save: function(queue) {
var value = this.simulation.city.worlds.indexOf(this.toWorld);
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.toXIndex;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var value = this.yPositionAboveWorld;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
queue.addJSON(this.spawn);
}
,__class__: simulation_SpawnFlyingSaucer
};
var simulation_Stats = function(city,simulation) {
this.peopleWorkingAtLabs = 0;
this.people = 0;
this.jobs = 0;
this.houseCapacity = 0;
this.peopleWithHome = 0;
this.peopleWithAJob = 0;
this.children = 0;
this.laborForce = 0;
this.shouldUpdateIn = -1;
this.city = city;
this.simulation = simulation;
this.materialProduction = [];
this.materialUsed = [];
this.materialProduction.push([0,0,0,0,0,0,0]);
this.materialProduction.push([0,0,0,0,0,0,0]);
this.materialProduction.push([0,0,0,0,0,0,0]);
this.materialProduction.push([0,0,0,0,0,0,0]);
this.materialProduction.push([0,0,0,0,0,0,0]);
this.materialProduction.push([0,0,0,0,0,0,0]);
this.materialProduction.push([0,0,0,0,0,0,0]);
this.materialProduction.push([0,0,0,0,0,0,0]);
var _g = 0;
var _g1 = MaterialsHelper.modMaterials;
while(_g < _g1.length) {
var modMaterial = _g1[_g];
++_g;
var currentMaterial = modMaterial.variableName;
this.materialProduction.push([0,0,0,0,0,0,0]);
}
this.materialProduction.push([0,0,0,0,0,0,0]);
this.materialUsed.push([0,0,0,0,0,0,0]);
this.materialUsed.push([0,0,0,0,0,0,0]);
this.materialUsed.push([0,0,0,0,0,0,0]);
this.materialUsed.push([0,0,0,0,0,0,0]);
this.materialUsed.push([0,0,0,0,0,0,0]);
this.materialUsed.push([0,0,0,0,0,0,0]);
this.materialUsed.push([0,0,0,0,0,0,0]);
this.materialUsed.push([0,0,0,0,0,0,0]);
var _g = 0;
var _g1 = MaterialsHelper.modMaterials;
while(_g < _g1.length) {
var modMaterial = _g1[_g];
++_g;
var currentMaterial = modMaterial.variableName;
this.materialUsed.push([0,0,0,0,0,0,0]);
}
this.materialUsed.push([0,0,0,0,0,0,0]);
};
$hxClasses["simulation.Stats"] = simulation_Stats;
simulation_Stats.__name__ = "simulation.Stats";
simulation_Stats.prototype = {
save: function(queue) {
this.saveBasics(queue);
var value = this.materialProduction.length;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var _g = 0;
var _g1 = this.materialProduction.length;
while(_g < _g1) {
var i = _g++;
queue.addString(MaterialsHelper.findMaterialName(i));
var value = this.materialProduction[i].length;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var _g2 = 0;
var _g3 = this.materialProduction[i];
while(_g2 < _g3.length) {
var prod = _g3[_g2];
++_g2;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes1 = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes1,0,queue.size);
}
queue.bytes.setDouble(queue.size,prod);
queue.size += 8;
}
}
var value = this.materialUsed.length;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var _g = 0;
var _g1 = this.materialUsed.length;
while(_g < _g1) {
var i = _g++;
queue.addString(MaterialsHelper.findMaterialName(i));
var value = this.materialUsed[i].length;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var _g2 = 0;
var _g3 = this.materialUsed[i];
while(_g2 < _g3.length) {
var prod = _g3[_g2];
++_g2;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes1 = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes1,0,queue.size);
}
queue.bytes.setDouble(queue.size,prod);
queue.size += 8;
}
}
}
,load: function(queue) {
this.loadBasics(queue);
if(queue.version >= 5) {
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var numberOfSavedMaterialArrays = intToRead;
var _g = 0;
var _g1 = numberOfSavedMaterialArrays;
while(_g < _g1) {
var i = _g++;
var index = MaterialsHelper.findMaterialIndex(queue.readString());
if(index == -1) {
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var historyLength = intToRead;
var _g2 = 0;
var _g3 = historyLength;
while(_g2 < _g3) {
var j = _g2++;
var floatToRead = queue.bytes.getDouble(queue.readStart);
queue.readStart += 8;
}
continue;
}
var intToRead1 = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var historyLength1 = intToRead1;
var _g4 = 0;
var _g5 = historyLength1;
while(_g4 < _g5) {
var j1 = _g4++;
var floatToRead1 = queue.bytes.getDouble(queue.readStart);
queue.readStart += 8;
var prod = floatToRead1;
if(this.materialProduction[index].length <= j1) {
this.materialProduction[index].push(prod);
} else {
this.materialProduction[index][j1] = prod;
}
}
}
}
if(queue.version >= 11) {
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var numberOfSavedMaterialArrays = intToRead;
var _g = 0;
var _g1 = numberOfSavedMaterialArrays;
while(_g < _g1) {
var i = _g++;
var index = MaterialsHelper.findMaterialIndex(queue.readString());
if(index == -1) {
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var historyLength = intToRead;
var _g2 = 0;
var _g3 = historyLength;
while(_g2 < _g3) {
var j = _g2++;
var floatToRead = queue.bytes.getDouble(queue.readStart);
queue.readStart += 8;
}
continue;
}
var intToRead1 = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var historyLength1 = intToRead1;
var _g4 = 0;
var _g5 = historyLength1;
while(_g4 < _g5) {
var j1 = _g4++;
var floatToRead1 = queue.bytes.getDouble(queue.readStart);
queue.readStart += 8;
var cons = floatToRead1;
if(this.materialUsed[index].length <= j1) {
this.materialUsed[index].push(cons);
} else {
this.materialUsed[index][j1] = cons;
}
}
}
}
}
,update: function(timeMod) {
if(this.shouldUpdateIn <= 0) {
this.laborForce = 0;
this.peopleWithAJob = 0;
this.peopleWithHome = 0;
this.children = 0;
this.houseCapacity = 0;
this.peopleWorkingAtLabs = 0;
this.people = this.simulation.citizens.length;
this.jobs = 0;
this.simulation.eating.herbsCap = 0;
var _g = 0;
var _g1 = this.simulation.citizens;
while(_g < _g1.length) {
var citizen = _g1[_g];
++_g;
if(citizen.lastInfrequentUpdateAge >= 16) {
this.laborForce += 1;
if(citizen.job != null) {
this.peopleWithAJob += 1;
if(citizen.job.is(buildings_Laboratory) || citizen.job.is(buildings_ExperimentationLab)) {
this.peopleWorkingAtLabs += 1;
}
}
} else {
this.children += 1;
}
if(citizen.home != null) {
this.peopleWithHome += 1;
}
}
var _g = 0;
var _g1 = this.city.permanents;
while(_g < _g1.length) {
var permanent = _g1[_g];
++_g;
if(permanent.is(buildings_House)) {
this.houseCapacity += permanent.get_residentCapacity();
}
if(permanent.is(buildings_Work)) {
this.jobs += permanent.get_jobs();
}
if(permanent.is(buildings_HerbGarden)) {
this.simulation.eating.herbsCap += permanent.getHerbCapacity();
}
}
this.shouldUpdateIn += 20;
this.city.progress.unlocks.checkStatRelatedUnlocks();
} else {
this.shouldUpdateIn -= Math.max(1,timeMod);
}
}
,midnightUpdate: function() {
var _g = 0;
var _g1 = this.materialProduction;
while(_g < _g1.length) {
var singleMaterialProduction = _g1[_g];
++_g;
var i = singleMaterialProduction.length;
while(--i >= 1) singleMaterialProduction[i] = singleMaterialProduction[i - 1];
singleMaterialProduction[0] = 0;
}
var _g = 0;
var _g1 = this.materialUsed;
while(_g < _g1.length) {
var singleMaterialUse = _g1[_g];
++_g;
var i = singleMaterialUse.length;
while(--i >= 1) singleMaterialUse[i] = singleMaterialUse[i - 1];
singleMaterialUse[0] = 0;
}
}
,amountOfBuildingsOfType: function(type) {
var count = 0;
var _g = 0;
var _g1 = this.city.permanents;
while(_g < _g1.length) {
var pm = _g1[_g];
++_g;
if(pm.is(type)) {
++count;
}
}
return count;
}
,saveBasics: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
if(shouldSaveDefinition) {
queue.addString(simulation_Stats.saveDefinition);
}
}
,loadBasics: function(queue,definition) {
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
}
,__class__: simulation_Stats
};
var simulation_citizenSpecialActions_ClimbIntoTree = function(citizen) {
simulation_CitizenSpecialAction.call(this,citizen);
};
$hxClasses["simulation.citizenSpecialActions.ClimbIntoTree"] = simulation_citizenSpecialActions_ClimbIntoTree;
simulation_citizenSpecialActions_ClimbIntoTree.__name__ = "simulation.citizenSpecialActions.ClimbIntoTree";
simulation_citizenSpecialActions_ClimbIntoTree.__super__ = simulation_CitizenSpecialAction;
simulation_citizenSpecialActions_ClimbIntoTree.prototype = $extend(simulation_CitizenSpecialAction.prototype,{
update: function(timeMod) {
if(this.citizen.inPermanent != null && this.citizen.inPermanent.is(worldResources_Forest)) {
var inForest = this.citizen.inPermanent;
if(((this.time.timeSinceStart | 0) / 60 | 0) % 24 == 4 && (this.time.timeSinceStart | 0) % 60 > 45) {
if(this.citizen.relativeY != 0) {
var tmp = this.citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 9;
arr[1] = 0;
tmp.setPath(arr,0,2);
}
} else if(this.citizen.relativeY == 0) {
var tmp = this.citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[4].length > 0 ? pool[4].splice(pool[4].length - 1,1)[0] : new Int32Array(4);
arr[0] = 4;
arr[1] = inForest.get_treeClimbX();
arr[2] = 9;
arr[3] = inForest.get_treeClimbY();
tmp.setPath(arr,0,4);
}
} else {
var nearestForest = null;
var nearestForestDist = 100000.0;
var _g = 0;
var _g1 = this.citizen.onWorld.permanents;
while(_g < _g1.length) {
var stack = _g1[_g];
++_g;
if(stack.length >= 1 && stack[0] != null && stack[0].is(worldResources_Forest)) {
var thisForest = stack[0];
if(thisForest.materialsLeft == thisForest.initialMaterials) {
var dist = thisForest.worldPosition.x * 20 - this.citizen.get_worldX();
if(dist < nearestForestDist) {
nearestForest = thisForest;
nearestForestDist = dist;
}
}
}
}
if(nearestForest != null) {
var _this = this.citizen;
_this.simulation.pathfinder.findPath(_this,nearestForest);
_this.pathOnFail = null;
}
}
}
,isActive: function() {
if(((this.time.timeSinceStart | 0) / 60 | 0) % 24 >= 0) {
return ((this.time.timeSinceStart | 0) / 60 | 0) % 24 <= 4;
} else {
return false;
}
}
,__class__: simulation_citizenSpecialActions_ClimbIntoTree
});
var simulation_citizenSpecialActions_ClimbOntoRuins = function(citizen) {
this.cancelAction = false;
simulation_CitizenSpecialAction.call(this,citizen);
};
$hxClasses["simulation.citizenSpecialActions.ClimbOntoRuins"] = simulation_citizenSpecialActions_ClimbOntoRuins;
simulation_citizenSpecialActions_ClimbOntoRuins.__name__ = "simulation.citizenSpecialActions.ClimbOntoRuins";
simulation_citizenSpecialActions_ClimbOntoRuins.__super__ = simulation_CitizenSpecialAction;
simulation_citizenSpecialActions_ClimbOntoRuins.prototype = $extend(simulation_CitizenSpecialAction.prototype,{
update: function(timeMod) {
if(this.cancelAction) {
return;
}
if(this.citizen.inPermanent != null && this.citizen.inPermanent.is(worldResources_AlienRuins)) {
var inAlienRuins = this.citizen.inPermanent;
if(((this.time.timeSinceStart | 0) / 60 | 0) % 24 == 4.5 && (this.time.timeSinceStart | 0) % 60 > 45) {
if(this.citizen.relativeY != 0) {
var tmp = this.citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 9;
arr[1] = 0;
tmp.setPath(arr,0,2);
}
} else if(this.citizen.relativeY == 0) {
var tmp = this.citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[4].length > 0 ? pool[4].splice(pool[4].length - 1,1)[0] : new Int32Array(4);
arr[0] = 4;
arr[1] = inAlienRuins.get_climbX();
arr[2] = 9;
arr[3] = inAlienRuins.get_climbY();
tmp.setPath(arr,0,4);
}
} else {
var nearestRuins = null;
var nearestRuinsDist = 100000.0;
var _g = 0;
var _g1 = this.citizen.onWorld.permanents;
while(_g < _g1.length) {
var stack = _g1[_g];
++_g;
if(stack.length >= 1 && stack[0] != null && stack[0].is(worldResources_AlienRuins)) {
var thisRuins = stack[0];
var dist = thisRuins.worldPosition.x * 20 - this.citizen.get_worldX();
if(dist < nearestRuinsDist) {
nearestRuins = thisRuins;
nearestRuinsDist = dist;
}
}
}
if(nearestRuins != null) {
var _this = this.citizen;
_this.simulation.pathfinder.findPath(_this,nearestRuins);
_this.pathOnFail = null;
} else {
this.cancelAction = true;
}
}
}
,isActive: function() {
if(((this.time.timeSinceStart | 0) / 60 | 0) % 24 >= 0.5 && ((this.time.timeSinceStart | 0) / 60 | 0) % 24 <= 4.5) {
return !this.cancelAction;
} else {
return false;
}
}
,__class__: simulation_citizenSpecialActions_ClimbOntoRuins
});
var simulation_citizenSpecialActions_DanceOnBall = function(citizen) {
this.goIntoDirection = 1;
this.currentSprite = null;
simulation_CitizenSpecialAction.call(this,citizen);
};
$hxClasses["simulation.citizenSpecialActions.DanceOnBall"] = simulation_citizenSpecialActions_DanceOnBall;
simulation_citizenSpecialActions_DanceOnBall.__name__ = "simulation.citizenSpecialActions.DanceOnBall";
simulation_citizenSpecialActions_DanceOnBall.__super__ = simulation_CitizenSpecialAction;
simulation_citizenSpecialActions_DanceOnBall.prototype = $extend(simulation_CitizenSpecialAction.prototype,{
update: function(timeMod) {
if(((this.time.timeSinceStart | 0) / 60 | 0) % 24 >= 1 && ((this.time.timeSinceStart | 0) / 60 | 0) % 24 <= 5) {
if(this.citizen.inPermanent != null) {
this.citizen.goDownTowardsWorldSurface(timeMod);
} else {
this.citizen.setRelativeY(4);
if(this.currentSprite == null) {
this.goIntoDirection = random_Random.fromArray([-1,1]);
this.currentSprite = new PIXI.Sprite(Resources.getTexture("spr_citizen_ball"));
this.currentSprite.position.y = this.citizen.onWorld.rect.y - 4;
this.citizen.onWorld.city.farForegroundStage.addChild(this.currentSprite);
}
this.citizen.setRelativeX(this.citizen.relativeX + timeMod * 0.5 * this.goIntoDirection);
if(this.goIntoDirection == 1 && this.citizen.relativeX >= this.citizen.onWorld.rect.width - 2 || this.goIntoDirection == -1 && this.citizen.relativeX <= 0) {
this.goIntoDirection = -this.goIntoDirection;
}
this.currentSprite.position.x = this.citizen.onWorld.rect.x + this.citizen.relativeX - 1;
}
} else if(this.currentSprite != null) {
this.citizen.onWorld.city.farForegroundStage.removeChild(this.currentSprite);
var _this = this.citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = 5;
_this.setPath(arr,0,2,true);
_this.pathEndFunction = null;
_this.pathOnlyRelatedTo = _this.inPermanent;
this.currentSprite = null;
this.citizen.setRelativeY(0);
}
}
,isActive: function() {
if(!(((this.time.timeSinceStart | 0) / 60 | 0) % 24 >= 1 && ((this.time.timeSinceStart | 0) / 60 | 0) % 24 <= 5)) {
return this.currentSprite != null;
} else {
return true;
}
}
,onDie: function() {
simulation_CitizenSpecialAction.prototype.onDie.call(this);
if(this.currentSprite != null) {
this.citizen.onWorld.city.farForegroundStage.removeChild(this.currentSprite);
}
}
,__class__: simulation_citizenSpecialActions_DanceOnBall
});
var simulation_citizenSpecialActions_MoveToEdge = function(citizen) {
simulation_CitizenSpecialAction.call(this,citizen);
};
$hxClasses["simulation.citizenSpecialActions.MoveToEdge"] = simulation_citizenSpecialActions_MoveToEdge;
simulation_citizenSpecialActions_MoveToEdge.__name__ = "simulation.citizenSpecialActions.MoveToEdge";
simulation_citizenSpecialActions_MoveToEdge.__super__ = simulation_CitizenSpecialAction;
simulation_citizenSpecialActions_MoveToEdge.prototype = $extend(simulation_CitizenSpecialAction.prototype,{
update: function(timeMod) {
var citizenMaxX = this.citizen.onWorld.rect.width - 2;
if(this.citizen.inPermanent != null || this.citizen.relativeX > 0 && this.citizen.relativeX < citizenMaxX) {
if(this.citizen.inPermanent == null) {
var _this = this.citizen;
var x = this.citizen.relativeX < citizenMaxX / 2 ? 0 : citizenMaxX;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = x;
_this.setPath(arr,0,2,true);
_this.pathEndFunction = null;
_this.pathOnlyRelatedTo = _this.inPermanent;
} else {
this.citizen.goDownTowardsWorldSurface(timeMod);
}
}
}
,isActive: function() {
var this1 = this.time.timeSinceStart / 60 % 24;
if(!(this1 >= 23)) {
return this1 < 5;
} else {
return true;
}
}
,__class__: simulation_citizenSpecialActions_MoveToEdge
});
var simulation_citizenSpecialActions_Protester = function(citizen) {
this.goingIntoThisDirection = 0;
this.goIntoDirection = 1;
this.currentSprite = null;
simulation_CitizenSpecialAction.call(this,citizen);
};
$hxClasses["simulation.citizenSpecialActions.Protester"] = simulation_citizenSpecialActions_Protester;
simulation_citizenSpecialActions_Protester.__name__ = "simulation.citizenSpecialActions.Protester";
simulation_citizenSpecialActions_Protester.__super__ = simulation_CitizenSpecialAction;
simulation_citizenSpecialActions_Protester.prototype = $extend(simulation_CitizenSpecialAction.prototype,{
update: function(timeMod) {
if(((this.time.timeSinceStart | 0) / 60 | 0) % 24 >= 0 && ((this.time.timeSinceStart | 0) / 60 | 0) % 24 <= 4 && (this.citizensAreVeryHappy() || this.citizensAreVeryUnhappy())) {
if(this.citizen.inPermanent != null) {
this.citizen.goDownTowardsWorldSurface(timeMod);
} else {
if(this.currentSprite == null) {
this.goIntoDirection = random_Random.fromArray([-1,1]);
if(this.citizensAreVeryHappy()) {
this.currentSprite = new PIXI.Sprite(Resources.getTexture("spr_protestsign_happy"));
} else {
this.currentSprite = new PIXI.Sprite(Resources.getTexture("spr_protestsign_sad"));
}
this.currentSprite.position.y = this.citizen.onWorld.rect.y - this.currentSprite.height;
this.citizen.onWorld.city.farForegroundStage.addChild(this.currentSprite);
}
this.citizen.setRelativeX(this.citizen.relativeX + timeMod * 0.66666666666666663 * this.goIntoDirection);
if(this.goIntoDirection == 1 && this.citizen.relativeX >= this.citizen.onWorld.rect.width - 2 || this.goIntoDirection == -1 && this.citizen.relativeX <= 0) {
this.goIntoDirection = -this.goIntoDirection;
} else if(this.goingIntoThisDirection > 150 && random_Random.getInt(90) == 1) {
this.goIntoDirection = -this.goIntoDirection;
this.goingIntoThisDirection = 0;
} else {
this.goingIntoThisDirection += timeMod;
}
this.currentSprite.position.x = this.citizen.onWorld.rect.x + this.citizen.relativeX - (this.goIntoDirection == 1 ? 2 : 5);
}
} else if(this.currentSprite != null) {
this.citizen.onWorld.city.farForegroundStage.removeChild(this.currentSprite);
var _this = this.citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = 5;
_this.setPath(arr,0,2,true);
_this.pathEndFunction = null;
_this.pathOnlyRelatedTo = _this.inPermanent;
this.currentSprite = null;
}
}
,isActive: function() {
if(!(((this.time.timeSinceStart | 0) / 60 | 0) % 24 >= 0 && ((this.time.timeSinceStart | 0) / 60 | 0) % 24 <= 4 && (this.citizensAreVeryHappy() || this.citizensAreVeryUnhappy()))) {
return this.currentSprite != null;
} else {
return true;
}
}
,citizensAreVeryHappy: function() {
return this.simulation.happiness.happiness >= 99.99;
}
,citizensAreVeryUnhappy: function() {
return this.simulation.happiness.happiness <= 10.01;
}
,onDie: function() {
simulation_CitizenSpecialAction.prototype.onDie.call(this);
if(this.currentSprite != null) {
this.citizen.onWorld.city.farForegroundStage.removeChild(this.currentSprite);
}
}
,__class__: simulation_citizenSpecialActions_Protester
});
var simulation_citizenSpecialActions_WatchStars = function(citizen) {
this.currentSprite = null;
simulation_CitizenSpecialAction.call(this,citizen);
};
$hxClasses["simulation.citizenSpecialActions.WatchStars"] = simulation_citizenSpecialActions_WatchStars;
simulation_citizenSpecialActions_WatchStars.__name__ = "simulation.citizenSpecialActions.WatchStars";
simulation_citizenSpecialActions_WatchStars.__super__ = simulation_CitizenSpecialAction;
simulation_citizenSpecialActions_WatchStars.prototype = $extend(simulation_CitizenSpecialAction.prototype,{
update: function(timeMod) {
var _gthis = this;
if(((this.time.timeSinceStart | 0) / 60 | 0) % 24 >= 0 && ((this.time.timeSinceStart | 0) / 60 | 0) % 24 <= 4) {
if(this.currentSprite == null) {
if(this.citizen.inPermanent != null) {
this.citizen.goDownTowardsWorldSurface(timeMod);
} else {
var telescopeWidth = 4;
var telescopeHeight = 5;
var bestPosition = pathfinder_PathfindingTools.findNearestBestBuildingStack(this.citizen,function(stack) {
if(stack.length == 0 || stack[0] == null) {
return 1000;
}
if(stack[0].is(worldResources_Forest)) {
return 999;
}
return 0;
}) * 20 + random_Random.getInt(telescopeWidth,18 - telescopeWidth);
var _this = this.citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 4;
arr[1] = bestPosition;
_this.setPath(arr,0,2,true);
_this.pathEndFunction = function() {
var tmp = Resources.getTexture("spr_telescope");
_gthis.currentSprite = new PIXI.Sprite(tmp);
_gthis.currentSprite.position.y = _gthis.citizen.onWorld.rect.y - telescopeHeight;
if(random_Random.getInt(2) == 0) {
_gthis.currentSprite.position.x = _gthis.citizen.onWorld.rect.x + bestPosition - telescopeWidth;
} else {
_gthis.currentSprite.position.x = _gthis.citizen.onWorld.rect.x + bestPosition + 2 + telescopeWidth;
_gthis.currentSprite.scale.x = -1;
}
_gthis.citizen.onWorld.city.farForegroundStage.addChild(_gthis.currentSprite);
};
_this.pathOnlyRelatedTo = _this.inPermanent;
}
}
} else if(this.currentSprite != null) {
this.citizen.onWorld.city.farForegroundStage.removeChild(this.currentSprite);
var _this = this.citizen;
var pool = pooling_Int32ArrayPool.pool;
var arr = pool[2].length > 0 ? pool[2].splice(pool[2].length - 1,1)[0] : new Int32Array(2);
arr[0] = 8;
arr[1] = 5;
_this.setPath(arr,0,2,true);
_this.pathEndFunction = null;
_this.pathOnlyRelatedTo = _this.inPermanent;
this.currentSprite = null;
}
}
,isActive: function() {
if(!(((this.time.timeSinceStart | 0) / 60 | 0) % 24 >= 0 && ((this.time.timeSinceStart | 0) / 60 | 0) % 24 <= 4)) {
return this.currentSprite != null;
} else {
return true;
}
}
,onDie: function() {
simulation_CitizenSpecialAction.prototype.onDie.call(this);
if(this.currentSprite != null) {
this.citizen.onWorld.city.farForegroundStage.removeChild(this.currentSprite);
}
}
,__class__: simulation_citizenSpecialActions_WatchStars
});
var simulation_festival_Festival = function(city,simulation,manager,centerBuilding) {
this.started = false;
this.city = city;
this.simulation = simulation;
this.manager = manager;
this.centerBuilding = centerBuilding;
};
$hxClasses["simulation.festival.Festival"] = simulation_festival_Festival;
simulation_festival_Festival.__name__ = "simulation.festival.Festival";
simulation_festival_Festival.prototype = {
get_normalDuration: function() {
return 1440;
}
,plan: function() {
var dayStart = (1 + ((this.city.simulation.time.timeSinceStart | 0) / 1440 | 0) + 1) * 24 * 60;
this.timeStart = this.city.simulation.time.timeSinceStart;
this.timeEnd = this.timeStart + this.get_normalDuration();
}
,isNow: function() {
return this.city.simulation.time.timeSinceStart >= this.timeStart;
}
,getText: function() {
return "Now having a festival!";
}
,end: function() {
this.manager.endFestival(this);
var _g = 0;
var _g1 = this.city.permanents;
while(_g < _g1.length) {
var pm = _g1[_g];
++_g;
if(js_Boot.__implements(pm,buildings_IBuildingWithFestivalSpecials)) {
var festivalPM = pm;
festivalPM.stopFestival();
}
}
}
,update: function(timeMod) {
if(this.city.simulation.time.timeSinceStart > this.timeEnd) {
this.end();
} else if(this.isNow()) {
if(!this.started) {
this.startFestival();
this.started = true;
}
this.updateFestival(timeMod);
}
}
,updateFestival: function(timeMod) {
}
,startFestival: function() {
}
,doStartRepeatables: function() {
var _g = 0;
var _g1 = this.city.permanents;
while(_g < _g1.length) {
var pm = _g1[_g];
++_g;
if(js_Boot.__implements(pm,buildings_IBuildingWithFestivalSpecials)) {
var festivalPM = pm;
festivalPM.initFestival();
}
}
}
,isInvolvedWithFestival: function(citizen) {
return true;
}
,citizenFestivalUpdate: function(citizen,timeMod) {
}
,updateFestivalCitizen: function(citizen,timeMod) {
if(this.isInvolvedWithFestival(citizen)) {
if(!citizen.fullyBeingControlled) {
Citizen.shouldUpdateDraw = false;
if(citizen.delayCanViewSelfInBuilding) {
citizen.delayCanViewSelfInBuilding = false;
Citizen.shouldUpdateDraw = true;
}
citizen.updatePath(timeMod);
if(citizen.path == null && !citizen.isRequestingPath) {
var _g = $bind(this,this.citizenFestivalUpdate);
var citizen1 = citizen;
(function(timeMod) {
_g(citizen1,timeMod);
})(timeMod);
}
if(Citizen.shouldUpdateDraw) {
citizen.actuallyUpdateDraw();
}
}
} else {
citizen.update(timeMod);
}
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
if(shouldSaveDefinition) {
queue.addString(simulation_festival_Festival.saveDefinition);
}
var value = this.timeStart;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.timeEnd;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.started;
if(queue.size + 1 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 1) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.b[queue.size] = value ? 1 : 0;
queue.size += 1;
}
,load: function(queue,definition) {
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"timeStart")) {
this.timeStart = loadMap.h["timeStart"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"timeEnd")) {
this.timeEnd = loadMap.h["timeEnd"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"started")) {
this.started = loadMap.h["started"];
}
}
,__class__: simulation_festival_Festival
};
var simulation_festival_FestivalManager = function(city,simulation) {
this.festivalCoolDown = 0;
this.city = city;
this.simulation = simulation;
this.festivals = [];
var _g = [];
_g.push(false);
_g.push(false);
_g.push(false);
_g.push(false);
_g.push(false);
_g.push(false);
_g.push(false);
this.wasFestivalOnDay = _g;
};
$hxClasses["simulation.festival.FestivalManager"] = simulation_festival_FestivalManager;
simulation_festival_FestivalManager.__name__ = "simulation.festival.FestivalManager";
simulation_festival_FestivalManager.prototype = {
addFestival: function(festival) {
this.festivals.push(festival);
}
,hasNoPlannedFestival: function() {
return this.festivals.length == 0;
}
,plannedFestival: function() {
var _g = 0;
var _g1 = this.festivals;
while(_g < _g1.length) {
var festival = _g1[_g];
++_g;
if(!festival.started) {
return festival;
}
}
return null;
}
,hasFestival: function() {
return common_ArrayExtensions.any(this.festivals,function(f) {
return f.isNow();
});
}
,updateFestivalCitizens: function(timeMod) {
var _g = 0;
var _g1 = this.festivals;
while(_g < _g1.length) {
var f = _g1[_g];
++_g;
var _g2 = 0;
var _g3 = this.simulation.citizens;
while(_g2 < _g3.length) {
var citizen = _g3[_g2];
++_g2;
f.updateFestivalCitizen(citizen,timeMod);
}
}
}
,currentFestival: function() {
var _g = 0;
var _g1 = this.festivals;
while(_g < _g1.length) {
var festival = _g1[_g];
++_g;
if(festival.isNow()) {
return festival;
}
}
return null;
}
,update: function(timeMod) {
var curr = this.currentFestival();
if(curr != null) {
curr.update(timeMod);
this.wasFestivalOnDay[0] = true;
}
if(this.festivalCoolDown > -1) {
this.festivalCoolDown -= timeMod * this.city.simulation.time.minutesPerTick;
}
}
,endFestival: function(fest) {
HxOverrides.remove(this.festivals,fest);
}
,save: function(queue) {
var value = this.festivals.length;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var _g = 0;
var _g1 = this.festivals;
while(_g < _g1.length) {
var festival = _g1[_g];
++_g;
var c = js_Boot.getClass(festival);
queue.addString(c.__name__);
var value = festival.centerBuilding.id;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
festival.save(queue);
}
var value = this.wasFestivalOnDay.length;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var _g = 0;
var _g1 = this.wasFestivalOnDay.length;
while(_g < _g1) {
var i = _g++;
var value = this.wasFestivalOnDay[i];
if(queue.size + 1 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 1) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.b[queue.size] = value ? 1 : 0;
queue.size += 1;
}
var value = this.festivalCoolDown;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
}
,load: function(queue) {
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var len = intToRead;
var _g = 0;
var _g1 = len;
while(_g < _g1) {
var i = _g++;
var className = queue.readString();
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var centerBuilding = intToRead;
var fes = Type.createInstance($hxClasses[className],[this.city,this.simulation,this,this.city.findPermanentByID(centerBuilding)]);
fes.load(queue);
this.festivals.push(fes);
}
if(queue.version >= 28) {
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var fesLen = intToRead;
var _g = 0;
var _g1 = fesLen;
while(_g < _g1) {
var i = _g++;
var byteToRead = queue.bytes.b[queue.readStart];
queue.readStart += 1;
this.wasFestivalOnDay[i] = byteToRead > 0;
}
}
if(queue.version >= 30) {
var floatToRead = queue.bytes.getDouble(queue.readStart);
queue.readStart += 8;
this.festivalCoolDown = floatToRead;
}
}
,afterLoad: function() {
var _g = 0;
var _g1 = this.festivals;
while(_g < _g1.length) {
var fes = _g1[_g];
++_g;
if(fes.started) {
fes.doStartRepeatables();
}
}
}
,__class__: simulation_festival_FestivalManager
};
var simulation_festival_MusicFestival = function(city,simulation,manager,centerBuilding) {
simulation_festival_Festival.call(this,city,simulation,manager,centerBuilding);
};
$hxClasses["simulation.festival.MusicFestival"] = simulation_festival_MusicFestival;
simulation_festival_MusicFestival.__name__ = "simulation.festival.MusicFestival";
simulation_festival_MusicFestival.involvedCitizens = function(simulation) {
var _g = [];
var _g1 = 0;
var _g2 = simulation.citizens;
while(_g1 < _g2.length) {
var v = _g2[_g1];
++_g1;
if(v.get_age() > 18 && (v.job == null || !v.job.is(buildings_School))) {
_g.push(v);
}
}
return _g;
};
simulation_festival_MusicFestival.canDo = function(city,simulation,centerBuilding) {
var involvedCitizenNum = simulation_festival_MusicFestival.involvedCitizens(simulation).length;
var relevantBuildingNum = simulation_festival_MusicFestival.relevantBuildings(simulation,centerBuilding).length;
if(involvedCitizenNum > simulation_festival_MusicFestival.minCitizens) {
return relevantBuildingNum > (involvedCitizenNum / 100 | 0);
} else {
return false;
}
};
simulation_festival_MusicFestival.relevantBuildings = function(simulation,centerBuilding) {
var relevants = [];
simulation.permanentFinder.query(centerBuilding,function(pm) {
if(pm.isBuilding) {
var bld = pm;
if(bld.isEntertainment) {
var ent = bld;
if(ent.get_entertainmentType() == 3 || ent.get_entertainmentType() == 0 || ent.get_entertainmentType() == 1) {
if(bld.couldStandHere() && !bld.is(buildings_EcoFarm)) {
relevants.push(ent);
}
}
}
}
return false;
});
return relevants;
};
simulation_festival_MusicFestival.__super__ = simulation_festival_Festival;
simulation_festival_MusicFestival.prototype = $extend(simulation_festival_Festival.prototype,{
isInvolvedWithFestival: function(citizen) {
if(citizen.get_age() > 18) {
if(citizen.job != null) {
return !citizen.job.is(buildings_School);
} else {
return true;
}
} else {
return false;
}
}
,updateFestival: function(timeMod) {
}
,doStartRepeatables: function() {
simulation_festival_Festival.prototype.doStartRepeatables.call(this);
var involvedCitizens = simulation_festival_MusicFestival.involvedCitizens(this.simulation);
var involvedCitizensNum = involvedCitizens.length;
var desiredNumberOfVenues = involvedCitizensNum / simulation_festival_MusicFestival.citizensPerVenue | 0;
var nonConsideredVenues = [];
this.currentFestivalVenues = simulation_festival_MusicFestival.relevantBuildings(this.simulation,this.centerBuilding);
if(this.currentFestivalVenues.length > desiredNumberOfVenues) {
nonConsideredVenues = this.currentFestivalVenues.splice(desiredNumberOfVenues,this.currentFestivalVenues.length - desiredNumberOfVenues);
}
var len = this.currentFestivalVenues.length;
var _g = 0;
var _g1 = len;
while(_g < _g1) {
var i = _g++;
var bld = this.currentFestivalVenues[i];
while(bld.leftBuilding != null && nonConsideredVenues.indexOf(bld.leftBuilding) != -1) {
HxOverrides.remove(nonConsideredVenues,bld.leftBuilding);
this.currentFestivalVenues.push(bld.leftBuilding);
bld = bld.leftBuilding;
}
bld = this.currentFestivalVenues[i];
while(bld.rightBuilding != null && nonConsideredVenues.indexOf(bld.rightBuilding) != -1) {
HxOverrides.remove(nonConsideredVenues,bld.rightBuilding);
this.currentFestivalVenues.push(bld.rightBuilding);
bld = bld.rightBuilding;
}
}
this.currentFestivalVenuesSet = new haxe_ds_ObjectMap();
this.currentTempWorkers = new haxe_ds_ObjectMap();
var _g = 0;
var _g1 = this.currentFestivalVenues;
while(_g < _g1.length) {
var bld = _g1[_g];
++_g;
this.currentFestivalVenuesSet.set(bld,true);
var v = [];
this.currentTempWorkers.set(bld,v);
}
}
,startFestival: function() {
this.doStartRepeatables();
this.simulation.happiness.addBoost(simulation_HappinessBoost.withDuration(this.simulation.time,simulation_festival_MusicFestival.happinessBoostDuration,simulation_festival_MusicFestival.happinessBoostGiven,"Music Festival Boost"));
}
,citizenFestivalUpdate: function(citizen,timeMod) {
var busy = false;
if(!citizen.tryFinishWork(timeMod)) {
return;
}
if((citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null) != null && this.currentFestivalVenuesSet.h.__keys__[(citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null).__id__] != null) {
var tempWorkers = this.currentTempWorkers.h[(citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null).__id__];
var isWorkBuilding = (citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null).is(buildings_Work);
var workBuilding = citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null;
var buildingAsFestivalWorkHaver = null;
var buildingIsFestivalWorkHaver = false;
if(js_Boot.__implements(citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null,buildings_IBuildingWithFestivalSpecials)) {
buildingAsFestivalWorkHaver = citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null;
buildingIsFestivalWorkHaver = true;
}
var citizenIsInvolvedWithFestival = false;
var i = tempWorkers.length;
var citizenID = 0;
while(--i >= 0) {
var tw = tempWorkers[i];
if(tw.hasDied || !this.isInvolvedWithFestival(tw)) {
tempWorkers.splice(i,1);
} else if(tw == citizen) {
citizenID = i;
citizenIsInvolvedWithFestival = true;
}
}
if(!buildingIsFestivalWorkHaver && isWorkBuilding && tempWorkers.length < workBuilding.get_jobs() || buildingIsFestivalWorkHaver && tempWorkers.length < buildingAsFestivalWorkHaver.festivalJobs) {
if(!citizenIsInvolvedWithFestival) {
citizenIsInvolvedWithFestival = true;
tempWorkers.push(citizen);
}
}
if(citizenIsInvolvedWithFestival) {
busy = true;
if(buildingIsFestivalWorkHaver) {
buildingAsFestivalWorkHaver.doFestivalWork(this,citizen,timeMod,citizenID);
} else {
workBuilding.work(citizen,timeMod,false);
}
} else {
var _this = citizen.entertainment;
var _gthis = _this;
var busy1 = true;
var entertainmentBuilding = _this.citizen.inPermanent;
var timeSinceStart = _this.citizen.simulation.time.timeSinceStart;
if(!_this.entertainmentInited) {
var currentEntertainmentDesirability = 1.0;
if(_this.citizen.job == null && _this.citizen.school == null) {
currentEntertainmentDesirability = 0.75;
}
_this.entertainmentFinishedTime = timeSinceStart + 60 * random_Random.getFloat(entertainmentBuilding.get_minimumNormalTimeToSpend(),entertainmentBuilding.get_maximumNormalTimeToSpend());
_this.recentEntertainmentTypes[entertainmentBuilding.get_entertainmentType()] = timeSinceStart + 1440 * random_Random.getFloat(entertainmentBuilding.get_minimumEntertainmentGroupSatisfy(),entertainmentBuilding.get_maximumEntertainmentGroupSatisfy()) * currentEntertainmentDesirability;
_this.entertainmentInited = true;
}
if(timeSinceStart >= _this.entertainmentFinishedTime) {
if(entertainmentBuilding.finishEntertainment(_this.citizen,timeMod)) {
busy1 = false;
_this.entertainmentInited = false;
} else if(buildingIsFestivalWorkHaver) {
var _this = _gthis.citizen;
var buildingAsFestivalWorkHaver = _this.inPermanent != null && _this.inPermanent.isBuilding ? _this.inPermanent : null;
buildingAsFestivalWorkHaver.beEntertainedFestival(this,_gthis.citizen,timeMod);
} else {
entertainmentBuilding.beEntertained(_gthis.citizen,timeMod);
}
} else if(buildingIsFestivalWorkHaver) {
var _this = _gthis.citizen;
var buildingAsFestivalWorkHaver = _this.inPermanent != null && _this.inPermanent.isBuilding ? _this.inPermanent : null;
buildingAsFestivalWorkHaver.beEntertainedFestival(this,_gthis.citizen,timeMod);
} else {
entertainmentBuilding.beEntertained(_gthis.citizen,timeMod);
}
busy = busy1;
citizen.dynamicUnsavedVars.searchingFestivalBuilding = null;
}
citizen.canViewSelfInBuilding = true;
}
if(!busy) {
if(citizen.dynamicUnsavedVars.searchingFestivalBuilding != null && !citizen.dynamicUnsavedVars.searchingFestivalBuilding.destroyed) {
citizen.simulation.pathfinder.findPath(citizen,citizen.dynamicUnsavedVars.searchingFestivalBuilding);
citizen.pathOnFail = null;
} else {
var newVenue = random_Random.fromArray(this.currentFestivalVenues);
if(!newVenue.destroyed) {
citizen.simulation.pathfinder.findPath(citizen,newVenue);
citizen.pathOnFail = null;
citizen.dynamicUnsavedVars.searchingFestivalBuilding = newVenue;
}
}
}
}
,getText: function() {
if(!this.isNow()) {
return "You planned an awesome Music Festival!";
}
return "Now entertaining your citizens with a great Music Festival!";
}
,end: function() {
var _g = 0;
var _g1 = this.city.simulation.citizens;
while(_g < _g1.length) {
var citizen = _g1[_g];
++_g;
if((citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null) == null) {
continue;
}
var tempWorkersInBuilding = this.currentTempWorkers.h[(citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null).__id__];
if(tempWorkersInBuilding != null && tempWorkersInBuilding.indexOf(citizen) != -1) {
var buildingAsFestivalWorkHaver = null;
var buildingIsFestivalWorkHaver = false;
var workBuilding = citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null;
if(js_Boot.__implements(citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null,buildings_IBuildingWithFestivalSpecials)) {
buildingAsFestivalWorkHaver = citizen.inPermanent != null && citizen.inPermanent.isBuilding ? citizen.inPermanent : null;
buildingIsFestivalWorkHaver = true;
}
if(buildingIsFestivalWorkHaver) {
buildingAsFestivalWorkHaver.endFestivalWork(this,citizen);
} else {
workBuilding.work(citizen,0,true);
}
}
}
simulation_festival_Festival.prototype.end.call(this);
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
simulation_festival_Festival.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(simulation_festival_MusicFestival.saveDefinition);
}
}
,load: function(queue,definition) {
simulation_festival_Festival.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
}
,__class__: simulation_festival_MusicFestival
});
var thx_Floats = function() { };
$hxClasses["thx.Floats"] = thx_Floats;
thx_Floats.__name__ = "thx.Floats";
thx_Floats.wrapCircular = function(v,max) {
v %= max;
if(v < 0) {
v += max;
}
return v;
};
var thx_color_Hsl = {};
thx_color_Hsl.toRgb = function(this1) {
return thx_color_Rgbx.toRgb(thx_color_Hsl.toRgbx(this1));
};
thx_color_Hsl.toRgbx = function(this1) {
var this2 = [thx_color_Hsl._c(this1[0] + 120,this1[1],this1[2]),thx_color_Hsl._c(this1[0],this1[1],this1[2]),thx_color_Hsl._c(this1[0] - 120,this1[1],this1[2])];
return this2;
};
thx_color_Hsl._c = function(d,s,l) {
var m2 = l <= 0.5 ? l * (1 + s) : l + s - l * s;
var m1 = 2 * l - m2;
d = thx_Floats.wrapCircular(d,360);
if(d < 60) {
return m1 + (m2 - m1) * d / 60;
} else if(d < 180) {
return m2;
} else if(d < 240) {
return m1 + (m2 - m1) * (240 - d) / 60;
} else {
return m1;
}
};
var thx_color_Hsv = {};
thx_color_Hsv.toRgb = function(this1) {
return thx_color_Rgbx.toRgb(thx_color_Hsv.toRgbx(this1));
};
thx_color_Hsv.toRgbx = function(this1) {
if(this1[1] == 0) {
var this2 = [this1[2],this1[2],this1[2]];
return this2;
}
var r;
var g;
var b;
var h = this1[0] / 60;
var i = Math.floor(h);
var f = h - i;
var p = this1[2] * (1 - this1[1]);
var q = this1[2] * (1 - f * this1[1]);
var t = this1[2] * (1 - (1 - f) * this1[1]);
switch(i) {
case 0:
r = this1[2];
g = t;
b = p;
break;
case 1:
r = q;
g = this1[2];
b = p;
break;
case 2:
r = p;
g = this1[2];
b = t;
break;
case 3:
r = p;
g = q;
b = this1[2];
break;
case 4:
r = t;
g = p;
b = this1[2];
break;
default:
r = this1[2];
g = p;
b = q;
}
var this1 = [r,g,b];
return this1;
};
var thx_color_Rgb = {};
thx_color_Rgb.toInt = function(this1) {
return this1;
};
thx_color_Rgb.get_red = function(this1) {
return this1 >> 16 & 255;
};
thx_color_Rgb.get_green = function(this1) {
return this1 >> 8 & 255;
};
thx_color_Rgb.get_blue = function(this1) {
return this1 & 255;
};
var thx_color_Rgbx = {};
thx_color_Rgbx.toRgb = function(this1) {
var this2 = (Math.round(this1[0] * 255) & 255) << 16 | (Math.round(this1[1] * 255) & 255) << 8 | Math.round(this1[2] * 255) & 255;
return this2;
};
var worldResources_AlienRuins = function(game,id,city,world,position,worldPosition,stage,spriteName) {
this.standingPlaces = [];
this.spriteName = "";
this.bonusesAwarded = 0;
this.explored = 0;
this.spriteName = spriteName == null ? random_Random.fromArray(["spr_alienruins","spr_alienruins_2"]) : spriteName;
WorldResource.call(this,game,id,city,world,position,worldPosition,stage,Resources.getTexture(this.spriteName));
this.standingPlaces = [2,3,8,9,10,15,16];
this.bonusesAwarded = 0;
this.myAwardedBonuses = [];
};
$hxClasses["worldResources.AlienRuins"] = worldResources_AlienRuins;
worldResources_AlienRuins.__name__ = "worldResources.AlienRuins";
worldResources_AlienRuins.__super__ = WorldResource;
worldResources_AlienRuins.prototype = $extend(WorldResource.prototype,{
get_name: function() {
return "Alien Ruins";
}
,get_climbX: function() {
if(this.spriteName == "spr_alienruins") {
return 9;
} else {
return 15;
}
}
,get_climbY: function() {
if(this.spriteName == "spr_alienruins") {
return 17;
} else {
return 16;
}
}
,getBonuses: function(bonusNumber) {
var _gthis = this;
var createBonus = function(name,description,onGet) {
return { name : name, description : description, onGet : onGet};
};
var createMatBonus = function(name,description,mat) {
return { name : name, description : description, onGet : function() {
_gthis.city.materials.add(mat);
mat.addToProduction(_gthis.city.simulation.stats);
}};
};
switch(bonusNumber) {
case 0:
return [createMatBonus("Overgrown","Your explorers chopped some roots for 20 wood.",new Materials(20)),createMatBonus("Big Rock","Your explorers found a big rock containing 25 stone.",new Materials(0,25)),createMatBonus("Small Pebbles","Your explorers almost tripped over a huge heap of small pebbles. They gathered them for 22 stone.",new Materials(0,22)),createMatBonus("Alien Refrigerator","Your explorers found an alien refrigerator with 12 food in it. They then dismantled it for 5 machine parts.",new Materials(0,0,12,5))];
case 1:
return [createMatBonus("Purple Wood","Your explorers found a hidden supply of 40 strange purple wood.",new Materials(40)),createMatBonus("Huge Pillar","Your explorers cut down a huge pillar that stood in their way. It contained 35 stone.",new Materials(0,35)),createMatBonus("Beeping Device","Your explorers dismantled a weird beeping device and gained 20 machine parts.",new Materials(0,0,0,20)),createMatBonus("Canned Food","Your explorers found a pile of cans with sweet-tasting luminous plants in it. The plants turned out to be quite nutritious, so your citizens can eat them for 42 food.",new Materials(0,0,42,0))];
case 2:
return [createMatBonus("Box with Wires","Your explorers found a wooden box filled with wires. The box was made of 10 wood and the wires work as 5 machine parts.",new Materials(10,0,0,5)),createMatBonus("Pile of Wood","Your explorers found a large pile with 17 wood.",new Materials(17)),createMatBonus("Large Stone Door","Your explorers cut down a large stone door and gained 15 stone.",new Materials(0,15)),createMatBonus("Berry Bushes","Your explorers found some berry bushes containing 22 food.",new Materials(0,0,22))];
case 3:
return [createBonus("Farming Rock Paintings","Your explorers found some paintings on a rock of a better way to farm. Farmers now get 5 more food from each harvest.",function() {
_gthis.city.simulation.bonuses.extraFoodFromFarms += 5;
}),createBonus("Alien Housing Blueprint","Your explorers found a blueprint to build an alien house.",function() {
_gthis.city.progress.unlocks.unlock(buildings_AlienHouse);
_gthis.city.progress.unlocks.unlock(cityUpgrades_SlimyLiving);
}),createBonus("Alien Factories Information","Your explorers found a book containing information about alien factories. With this knowledge, machine parts factories now work 10% faster.",function() {
_gthis.city.simulation.bonuses.machinePartsFactorySpeed *= 1.1;
}),createBonus("Alien Brain","Your explorers found a perfectly preserved alien brain in a jar. With knowledge about its structure, researchers in labs understand the human brain better and can gather knowledge 5% faster.",function() {
_gthis.city.simulation.bonuses.labSpeed *= 1.05;
})];
default:
return [];
}
}
,addWindowInfoLines: function() {
var _gthis = this;
WorldResource.prototype.addWindowInfoLines.call(this);
var gui = this.city.gui;
var $window = gui.windowInner;
gui.windowAddInfoText(null,function() {
return "" + (_gthis.explored | 0) + "% explored.";
});
$window.addChild(new gui_TextElement($window,gui.innerWindowStage,"Findings",null,"Arial15",{ left : 0, right : 0, top : 3, bottom : 0}));
if(this.myAwardedBonuses.length == 0) {
gui.windowAddInfoText("Your explorers haven't found anything here yet!");
} else {
var _g = 0;
var _g1 = this.myAwardedBonuses;
while(_g < _g1.length) {
var bonus = _g1[_g];
++_g;
gui.windowAddInfoText("" + bonus.name + ": " + bonus.description);
}
}
}
,createWindowAddBottomButtons: function() {
var _gthis = this;
if(this.explored >= 100) {
this.city.gui.windowAddBottomButtons([{ text : "Move", action : function() {
_gthis.city.createWorldResourceBuilderMove(_gthis);
}}]);
}
}
,awardAnyBonuses: function() {
if(this.bonusesAwarded < ((this.explored | 0) / 25 | 0) && this.explored >= 25 * (this.bonusesAwarded + 1)) {
var newBonus;
var possibleBonuses = this.getBonuses(this.bonusesAwarded);
var _g = [];
var _g1 = 0;
var _g2 = possibleBonuses;
while(_g1 < _g2.length) {
var v = _g2[_g1];
++_g1;
if(worldResources_AlienRuins.alreadyFoundBonuses.indexOf(v.name) == -1) {
_g.push(v);
}
}
possibleBonuses = Lambda.array(_g);
if(possibleBonuses.length > 0) {
newBonus = random_Random.fromArray(possibleBonuses);
var alienHousingBonus = Lambda.find(possibleBonuses,function(pb) {
return pb.name == "Alien Housing Blueprint";
});
if(Lambda.count(this.city.permanents,function(pm) {
return pm.is(worldResources_AlienRuins);
}) < 4 && alienHousingBonus != null) {
newBonus = alienHousingBonus;
}
newBonus.onGet();
this.myAwardedBonuses.push(newBonus);
worldResources_AlienRuins.alreadyFoundBonuses.push(newBonus.name);
if(this.city.gui.windowRelatedTo == this) {
this.reloadWindow();
}
}
this.bonusesAwarded += 1;
}
}
,createBonusWindow: function(newBonus) {
this.city.gui.showSimpleWindow(newBonus.description,"Alien Ruins Exploration Update",true);
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = false;
}
WorldResource.prototype.save.call(this,queue);
this.saveBasics(queue);
var value = this.myAwardedBonuses.length;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
var _g = 0;
var _g1 = this.myAwardedBonuses;
while(_g < _g1.length) {
var awardedBonus = _g1[_g];
++_g;
queue.addString(awardedBonus.name);
queue.addString(awardedBonus.description);
}
}
,load: function(queue,definition) {
WorldResource.prototype.load.call(this,queue);
this.loadBasics(queue);
var intToRead = queue.bytes.getInt32(queue.readStart);
queue.readStart += 4;
var len = intToRead;
var _g = 0;
var _g1 = len;
while(_g < _g1) {
var i = _g++;
var bonus = { name : queue.readString(), description : queue.readString()};
this.myAwardedBonuses.push(bonus);
worldResources_AlienRuins.alreadyFoundBonuses.push(bonus.name);
}
}
,postLoad: function() {
this.sprite.texture = Resources.getTexture(this.spriteName);
}
,saveBasics: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
if(shouldSaveDefinition) {
queue.addString(worldResources_AlienRuins.saveDefinition);
}
var value = this.explored;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.bonusesAwarded;
if(queue.size + 4 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 4) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setInt32(queue.size,value);
queue.size += 4;
queue.addString(this.spriteName);
}
,loadBasics: function(queue,definition) {
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"explored")) {
this.explored = loadMap.h["explored"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"bonusesAwarded")) {
this.bonusesAwarded = loadMap.h["bonusesAwarded"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"spriteName")) {
this.spriteName = loadMap.h["spriteName"];
}
this.postLoad();
}
,__class__: worldResources_AlienRuins
});
var worldResources_LimitedWorldResource = function(game,id,city,world,position,worldPosition,stage,texturesName,initialMaterials,regrowTexturesName) {
this.maxCitizenX = 17;
this.minCitizenX = 1;
this.regrowProgress = 0;
this.textures = Resources.getTexturesByWidth(texturesName,20);
this.regrowTextures = regrowTexturesName == null ? null : Resources.getTexturesByWidth(regrowTexturesName,20);
this.initialMaterials = initialMaterials;
this.materialsLeft = initialMaterials;
WorldResource.call(this,game,id,city,world,position,worldPosition,stage,this.textures[0]);
};
$hxClasses["worldResources.LimitedWorldResource"] = worldResources_LimitedWorldResource;
worldResources_LimitedWorldResource.__name__ = "worldResources.LimitedWorldResource";
worldResources_LimitedWorldResource.__interfaces__ = [worldResources_ILimitedMaterialGatherPlace];
worldResources_LimitedWorldResource.updateTextureOfLimitedResourceSprite = function(materialsLeft,initialMaterials,regrowProgress,textures,regrowTextures,sprite) {
if(materialsLeft <= 0.0000001) {
sprite.texture = regrowTextures != null ? regrowTextures[regrowProgress / 100 * regrowTextures.length | 0] : textures[textures.length - 1];
} else {
var i = Math.floor((initialMaterials - materialsLeft) / initialMaterials * textures.length);
if(initialMaterials != materialsLeft && i == 0 && textures.length > 1) {
i = 1;
}
sprite.texture = textures[i];
}
};
worldResources_LimitedWorldResource.updateRegrow = function(target,timeMod,city) {
if(target.materialsLeft <= 0) {
var this1 = city.simulation.time.timeSinceStart / 60 % 24;
var start = 7;
var end = 20;
if(start < end ? this1 >= start && this1 < end : this1 >= start || this1 < end) {
target.regrowProgress += target.get_regrowSpeed() * timeMod;
} else {
var this1 = city.simulation.time.timeSinceStart / 60 % 24;
var start = 7 - 1;
var end = 20 + 1;
if(start < end ? this1 >= start && this1 < end : this1 >= start || this1 < end) {
target.regrowProgress += target.get_regrowSpeed() * timeMod * 0.5;
}
}
if(target.regrowProgress >= 100) {
target.materialsLeft = target.initialMaterials;
target.regrowProgress = 0;
}
target.updateTexture();
}
};
worldResources_LimitedWorldResource.__super__ = WorldResource;
worldResources_LimitedWorldResource.prototype = $extend(WorldResource.prototype,{
get_destroyedOnEmpty: function() {
return true;
}
,get_doNotGather: function() {
return false;
}
,get_resourceName: function() {
return "";
}
,get_regrowSpeed: function() {
return 0.0;
}
,get_stayIfEmpty: function() {
return false;
}
,postLoad: function() {
this.updateTexture();
}
,update: function(timeMod) {
WorldResource.prototype.update.call(this,timeMod);
var city = this.city;
if(this.materialsLeft <= 0) {
var this1 = city.simulation.time.timeSinceStart / 60 % 24;
var start = 7;
var end = 20;
if(start < end ? this1 >= start && this1 < end : this1 >= start || this1 < end) {
this.regrowProgress += this.get_regrowSpeed() * timeMod;
} else {
var this1 = city.simulation.time.timeSinceStart / 60 % 24;
var start = 7 - 1;
var end = 20 + 1;
if(start < end ? this1 >= start && this1 < end : this1 >= start || this1 < end) {
this.regrowProgress += this.get_regrowSpeed() * timeMod * 0.5;
}
}
if(this.regrowProgress >= 100) {
this.materialsLeft = this.initialMaterials;
this.regrowProgress = 0;
}
this.updateTexture();
}
}
,updateTexture: function() {
var materialsLeft = this.materialsLeft;
var initialMaterials = this.initialMaterials;
var textures = this.textures;
var regrowTextures = this.regrowTextures;
var sprite = this.sprite;
if(materialsLeft <= 0.0000001) {
sprite.texture = regrowTextures != null ? regrowTextures[this.regrowProgress / 100 * regrowTextures.length | 0] : textures[textures.length - 1];
} else {
var i = Math.floor((initialMaterials - materialsLeft) / initialMaterials * textures.length);
if(initialMaterials != materialsLeft && i == 0 && textures.length > 1) {
i = 1;
}
sprite.texture = textures[i];
}
}
,addWindowInfoLines: function() {
var _gthis = this;
WorldResource.prototype.addWindowInfoLines.call(this);
this.city.gui.windowAddInfoText(null,function() {
if(_gthis.materialsLeft <= 0) {
return "" + (_gthis.regrowProgress | 0) + "% grown.";
} else {
return "" + (_gthis.materialsLeft | 0) + "/" + _gthis.initialMaterials + " " + _gthis.get_resourceName() + " left.";
}
});
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
WorldResource.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(worldResources_LimitedWorldResource.saveDefinition);
}
var value = this.materialsLeft;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
var value = this.regrowProgress;
if(queue.size + 8 > queue.bytes.length) {
var oldBytes = queue.bytes;
queue.bytes = new haxe_io_Bytes(new ArrayBuffer((queue.size + 8) * 2));
queue.bytes.blit(0,oldBytes,0,queue.size);
}
queue.bytes.setDouble(queue.size,value);
queue.size += 8;
}
,load: function(queue,definition) {
WorldResource.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"materialsLeft")) {
this.materialsLeft = loadMap.h["materialsLeft"];
}
if(Object.prototype.hasOwnProperty.call(loadMap.h,"regrowProgress")) {
this.regrowProgress = loadMap.h["regrowProgress"];
}
this.postLoad();
}
,__class__: worldResources_LimitedWorldResource
});
var worldResources_Forest = function(game,id,city,world,position,worldPosition,stage,texture,amountOfWood,regrowTexture) {
if(regrowTexture == null) {
regrowTexture = "spr_forest_grow";
}
if(amountOfWood == null) {
amountOfWood = 200;
}
if(texture == null) {
texture = "spr_forest";
}
worldResources_LimitedWorldResource.call(this,game,id,city,world,position,worldPosition,stage,texture,amountOfWood,regrowTexture);
this.managementMode = worldResources_ForestManagementMode.CutDownAndRegrow;
};
$hxClasses["worldResources.Forest"] = worldResources_Forest;
worldResources_Forest.__name__ = "worldResources.Forest";
worldResources_Forest.__super__ = worldResources_LimitedWorldResource;
worldResources_Forest.prototype = $extend(worldResources_LimitedWorldResource.prototype,{
get_name: function() {
return "Forest";
}
,get_resourceName: function() {
return "wood";
}
,get_regrowSpeed: function() {
return 0.003;
}
,get_destroyedOnEmpty: function() {
return this.managementMode == worldResources_ForestManagementMode.CutDownAndUproot;
}
,get_doNotGather: function() {
return this.managementMode == worldResources_ForestManagementMode.Protect;
}
,get_treeClimbX: function() {
return 7;
}
,get_treeClimbY: function() {
return 13;
}
,setManagementMode: function(mode,noRecursion) {
if(noRecursion == null) {
noRecursion = false;
}
this.managementMode = mode;
if(!noRecursion && gui_UpgradeWindowParts.hasMultiUpgradeModeOn) {
var _g = 0;
var _g1 = this.city.permanents;
while(_g < _g1.length) {
var permanent = _g1[_g];
++_g;
if(permanent.is(worldResources_Forest)) {
permanent.setManagementMode(mode,true);
}
}
}
}
,createMainWindowPart: function() {
var _gthis = this;
var gui = this.city.gui;
worldResources_LimitedWorldResource.prototype.createMainWindowPart.call(this);
gui.window.minWidth = 235;
var titleContainer = gui_UpgradeWindowParts.createHeader(gui,"Forest Management");
gui_UpgradeWindowParts.addOneAndMaxButtons(gui,titleContainer,function() {
gui_UpgradeWindowParts.hasMultiUpgradeModeOn = false;
_gthis.reloadWindow();
},function() {
gui_UpgradeWindowParts.hasMultiUpgradeModeOn = true;
_gthis.reloadWindow();
},"Only set the management mode for this forest.",function() {
return "---";
},function() {
return "Set the management mode for all forests (" + _gthis.city.simulation.stats.amountOfBuildingsOfType(worldResources_Forest) + ").";
},false);
gui.windowAddInfoText(gui_UpgradeWindowParts.hasMultiUpgradeModeOn ? "What should woodcutters do with all forests?" : "What should woodcutters do with this forest?");
gui_UpgradeWindowParts.createActivatableButton(gui,this.managementMode == worldResources_ForestManagementMode.CutDownAndRegrow,function() {
_gthis.setManagementMode(worldResources_ForestManagementMode.CutDownAndRegrow);
_gthis.reloadWindow();
},"Cut Down and Regrow",gui_UpgradeWindowParts.hasMultiUpgradeModeOn ? "Cut them down, then let them regrow." : "Cut it down, then let it regrow.");
gui_UpgradeWindowParts.createActivatableButton(gui,this.managementMode == worldResources_ForestManagementMode.Protect,function() {
_gthis.setManagementMode(worldResources_ForestManagementMode.Protect);
_gthis.reloadWindow();
},"Protect",gui_UpgradeWindowParts.hasMultiUpgradeModeOn ? "Don't cut them down." : "Don't cut it down.");
gui_UpgradeWindowParts.createActivatableButton(gui,this.managementMode == worldResources_ForestManagementMode.CutDownAndUproot,function() {
_gthis.setManagementMode(worldResources_ForestManagementMode.CutDownAndUproot);
_gthis.reloadWindow();
},"Cut Down and Uproot",gui_UpgradeWindowParts.hasMultiUpgradeModeOn ? "Cut them down to make room for other things." : "Cut it down to make room for other things.");
gui.windowInner.addChild(new gui_GUISpacing(gui.windowInner,new common_Point(2,4)));
}
,createWindowAddBottomButtons: function() {
var _gthis = this;
var prioritizeButton = null;
var isConfirmButton = false;
prioritizeButton = this.city.gui.windowAddBottomButtons([{ text : this.materialsLeft <= 0 ? "Uproot" : this.city.simulation.resourcePriorityManager.isPrioritized(this) ? "Prioritized" : "Prioritize", onHover : function() {
if(_gthis.materialsLeft <= 0) {
if(!isConfirmButton) {
_gthis.city.gui.tooltip.setText(_gthis,"Instantly destroy this forest.");
}
} else if(_gthis.city.simulation.resourcePriorityManager.isPrioritized(_gthis)) {
_gthis.city.gui.tooltip.setText(_gthis,"Woodcutters will cut this forest first. " + _gthis.game.textHelper.clickOrTap() + " to disable.","Prioritized");
} else {
_gthis.city.gui.tooltip.setText(_gthis,"When prioritized, woodcutters will cut this forest first.","Prioritize");
}
}, action : function() {
if(_gthis.materialsLeft <= 0) {
if(isConfirmButton) {
_gthis.city.gui.closeWindow();
_gthis.destroy();
_gthis.materialsLeft = 0;
} else {
prioritizeButton.setText("Really Uproot?");
isConfirmButton = true;
}
} else if(_gthis.city.simulation.resourcePriorityManager.isPrioritized(_gthis)) {
_gthis.city.simulation.resourcePriorityManager.deprioritize(_gthis);
prioritizeButton.setText("Prioritize");
} else {
_gthis.city.simulation.resourcePriorityManager.prioritize(_gthis);
prioritizeButton.setText("Prioritized");
}
}}])[0];
var wereMaterialsLeft = this.materialsLeft <= 0;
prioritizeButton.onUpdate = function() {
if(_gthis.materialsLeft <= 0 != wereMaterialsLeft) {
if(_gthis.materialsLeft <= 0) {
isConfirmButton = false;
prioritizeButton.setText("Uproot");
} else if(_gthis.city.simulation.resourcePriorityManager.isPrioritized(_gthis)) {
prioritizeButton.setText("Prioritize");
} else {
prioritizeButton.setText("Prioritized");
}
wereMaterialsLeft = _gthis.materialsLeft <= 0;
}
};
}
,save: function(queue,shouldSaveDefinition) {
if(shouldSaveDefinition == null) {
shouldSaveDefinition = true;
}
worldResources_LimitedWorldResource.prototype.save.call(this,queue);
if(shouldSaveDefinition) {
queue.addString(worldResources_Forest.saveDefinition);
}
var e = this.managementMode;
queue.addString($hxEnums[e.__enum__].__constructs__[e._hx_index]);
}
,load: function(queue,definition) {
worldResources_LimitedWorldResource.prototype.load.call(this,queue);
if(definition == null) {
definition = queue.readString();
}
var loadMap = gamesave_GameSaveHelper.makeLoadMap(definition,queue);
if(Object.prototype.hasOwnProperty.call(loadMap.h,"managementMode")) {
this.managementMode = loadMap.h["managementMode"];
}
}
,__class__: worldResources_Forest
});
var worldResources_BirchForest = function(game,id,city,world,position,worldPosition,stage) {
worldResources_Forest.call(this,game,id,city,world,position,worldPosition,stage,"spr_birchforest",120,"spr_pineforest_grow");
};
$hxClasses["worldResources.BirchForest"] = worldResources_BirchForest;
worldResources_BirchForest.__name__ = "worldResources.BirchForest";
worldResources_BirchForest.__super__ = worldResources_Forest;
worldResources_BirchForest.prototype = $extend(worldResources_Forest.prototype,{
get_name: function() {
return "Pine Forest";
}
,get_regrowSpeed: function() {
return 0.01;
}
,get_treeClimbX: function() {
return 12;
}
,get_treeClimbY: function() {
return 13;
}
,__class__: worldResources_BirchForest
});
var worldResources_ComputerAlienRuins = function(game,id,city,world,position,worldPosition,stage) {
worldResources_AlienRuins.call(this,game,id,city,world,position,worldPosition,stage,"spr_alienruins_3");
};
$hxClasses["worldResources.ComputerAlienRuins"] = worldResources_ComputerAlienRuins;
worldResources_ComputerAlienRuins.__name__ = "worldResources.ComputerAlienRuins";
worldResources_ComputerAlienRuins.__super__ = worldResources_AlienRuins;
worldResources_ComputerAlienRuins.prototype = $extend(worldResources_AlienRuins.prototype,{
get_climbX: function() {
return 9;
}
,get_climbY: function() {
return 15;
}
,getBonuses: function(bonusNumber) {
var _gthis = this;
var createBonus = function(name,description,onGet) {
return { name : name, description : description, onGet : onGet};
};
var createMatBonus = function(name,description,mat) {
return { name : name, description : description, onGet : function() {
_gthis.city.materials.add(mat);
mat.addToProduction(_gthis.city.simulation.stats);
}};
};
switch(bonusNumber) {
case 0:
return [createMatBonus("Orange Rocks","Your explorers laid eye on some orange rocks. They are good for 35 stone.",new Materials(0,35))];
case 1:
return [createMatBonus("Mushrooms","Your explorers found some suspicious mushrooms. Very carefully, they tasted a bit. To everyone's surprise, they actually taste pretty good and you got 55 food.",new Materials(0,0,55))];
case 2:
return [createMatBonus("Gears","Your explorers found a pile of gears. They work as seven machine parts.",new Materials(0,0,0,7))];
case 3:
return [createBonus("Strange Device","Your explorers found a small device, that may have something to do with the inaccessible worlds.",function() {
})];
default:
return [];
}
}
,__class__: worldResources_ComputerAlienRuins
});
var worldResources_ForestManagementMode = $hxEnums["worldResources.ForestManagementMode"] = { __ename__ : "worldResources.ForestManagementMode", __constructs__ : ["CutDownAndRegrow","Protect","CutDownAndUproot"]
,CutDownAndRegrow: {_hx_index:0,__enum__:"worldResources.ForestManagementMode",toString:$estr}
,Protect: {_hx_index:1,__enum__:"worldResources.ForestManagementMode",toString:$estr}
,CutDownAndUproot: {_hx_index:2,__enum__:"worldResources.ForestManagementMode",toString:$estr}
};
var worldResources_PineForest = function(game,id,city,world,position,worldPosition,stage) {
worldResources_Forest.call(this,game,id,city,world,position,worldPosition,stage,"spr_pineforest",200,"spr_pineforest_grow");
};
$hxClasses["worldResources.PineForest"] = worldResources_PineForest;
worldResources_PineForest.__name__ = "worldResources.PineForest";
worldResources_PineForest.__super__ = worldResources_Forest;
worldResources_PineForest.prototype = $extend(worldResources_Forest.prototype,{
get_name: function() {
return "Pine Forest";
}
,get_regrowSpeed: function() {
return 0.005;
}
,get_treeClimbX: function() {
return 15;
}
,get_treeClimbY: function() {
return 3;
}
,__class__: worldResources_PineForest
});
var worldResources_Rock = function(game,id,city,world,position,worldPosition,stage) {
worldResources_LimitedWorldResource.call(this,game,id,city,world,position,worldPosition,stage,"spr_rock",250);
};
$hxClasses["worldResources.Rock"] = worldResources_Rock;
worldResources_Rock.__name__ = "worldResources.Rock";
worldResources_Rock.__super__ = worldResources_LimitedWorldResource;
worldResources_Rock.prototype = $extend(worldResources_LimitedWorldResource.prototype,{
get_name: function() {
return "Rock";
}
,get_resourceName: function() {
return "stone";
}
,createWindowAddBottomButtons: function() {
var _gthis = this;
var prioritizeButton = null;
prioritizeButton = this.city.gui.windowAddBottomButtons([{ text : this.city.simulation.resourcePriorityManager.isPrioritized(this) ? "Prioritized" : "Prioritize", onHover : function() {
if(_gthis.city.simulation.resourcePriorityManager.isPrioritized(_gthis)) {
_gthis.city.gui.tooltip.setText(_gthis,"Stone miners will mine this rock first. " + _gthis.game.textHelper.clickOrTap() + " to disable.","Prioritized");
} else {
_gthis.city.gui.tooltip.setText(_gthis,"When prioritized, stone miners will mine this rock first.","Prioritize");
}
}, action : function() {
if(_gthis.city.simulation.resourcePriorityManager.isPrioritized(_gthis)) {
_gthis.city.simulation.resourcePriorityManager.deprioritize(_gthis);
prioritizeButton.setText("Prioritize");
} else {
_gthis.city.simulation.resourcePriorityManager.prioritize(_gthis);
prioritizeButton.setText("Prioritized");
}
}}])[0];
}
,__class__: worldResources_Rock
});
function $getIterator(o) { if( o instanceof Array ) return new haxe_iterators_ArrayIterator(o); else return o.iterator(); }
function $bind(o,m) { if( m == null ) return null; if( m.__id__ == null ) m.__id__ = $global.$haxeUID++; var f; if( o.hx__closures__ == null ) o.hx__closures__ = {}; else f = o.hx__closures__[m.__id__]; if( f == null ) { f = m.bind(o); o.hx__closures__[m.__id__] = f; } return f; }
$global.$haxeUID |= 0;
if(typeof(performance) != "undefined" ? typeof(performance.now) == "function" : false) {
HxOverrides.now = performance.now.bind(performance);
}
$hxClasses["Math"] = Math;
if( String.fromCodePoint == null ) String.fromCodePoint = function(c) { return c < 0x10000 ? String.fromCharCode(c) : String.fromCharCode((c>>10)+0xD7C0)+String.fromCharCode((c&0x3FF)+0xDC00); }
String.prototype.__class__ = $hxClasses["String"] = String;
String.__name__ = "String";
$hxClasses["Array"] = Array;
Array.__name__ = "Array";
Date.prototype.__class__ = $hxClasses["Date"] = Date;
Date.__name__ = "Date";
var Int = { };
var Dynamic = { };
var Float = Number;
var Bool = Boolean;
var Class = { };
var Enum = { };
haxe_ds_ObjectMap.count = 0;
js_Boot.__toStr = ({ }).toString;
Analytics.enabled = true;
Analytics.ready = false;
Analytics.useAltEarlyGame = false;
Analytics.sessionTime = 0;
Analytics.reportedLongPlaytime = false;
Analytics.didABTest = false;
Analytics.capturedErrors = [];
Analytics.errorsReported = 0;
Permanent.width = 20;
Permanent.height = 20;
Permanent.destroyingForReplacement = false;
Permanent.destroyingDisableMoveDown = false;
Permanent.saveDefinition = "";
Building.spriteName = "";
BuildingUpgrade.saveDefinition = "spriteIndex$Int";
Citizen.spriteCitizens = new haxe_ds_ObjectMap();
Citizen.shouldUpdateDraw = false;
Citizen.saveDefinition = "hasBuildingInited$Bool|spriteIndex$Int|relativeX$Float|bornOn$Float|actualWorkTimePreference$Float|currentAction$LifeAction|hasWorkTools$Bool|lastInfrequentUpdateAge$Float|dieAgeModifier$Float|educationLevel$Float";
City.saveDefinition = "maxPermanentID$Int|viewPos$FPoint|zoomScale$Float|cityName$String";
CityTime.saveDefinition = "timeSinceStart$Float";
Config.enableCheats = false;
Config.earlyGameFix1 = false;
Config.earlyGameFix2 = false;
Config.isLimitedDemo = false;
Config.mailingListURL = "http://eepurl.com/gweDy9";
Config.splashScreenDone = false;
Config.siteLockUrls = 2 == 4 ? ["coolmathgames.com","coolmath-games.com","wagtailgames.com","florianvanstrien.nl","localhost","127.0.0.1","192.168.178."] : null;
Config.hasFullscreen = true;
Config.canBeMobile = true;
Config.forceMobile = 2 == 8 ? true : false;
Config.noInputYet = true;
Config.hadFullStepWithInput = false;
Config.lastInput = 0;
Config.allowUnlimitedResources = 2 == 5 ? !Config.isLimitedDemo : false;
Config.cheatSpeedEnabled = false;
GUI.closeButtonEnabled = true;
Game.isLoading = false;
Keyboard.mobileBackPressed = false;
Main.isMobile = false;
Main.isLargeMobile = false;
Main.isCanvasRenderer = false;
Materials.saveDefinition = "wood$Float|stone$Float|food$Float|machineParts$Float|knowledge$Float|refinedMetal$Float|computerChips$Float|cacao$Float|chocolate$Float";
MaterialsHelper.materialNames = ["food","wood","stone","machineParts","refinedMetal","computerChips","cacao","chocolate","knowledge"];
MaterialsHelper.modMaterials = [];
Perf.MEASUREMENT_INTERVAL = 1000;
Perf.FONT_FAMILY = "Helvetica,Arial";
Perf.FPS_BG_CLR = "#00FF00";
Perf.FPS_WARN_BG_CLR = "#FF8000";
Perf.FPS_PROB_BG_CLR = "#FF0000";
Perf.MS_BG_CLR = "#FFFF00";
Perf.MEM_BG_CLR = "#086A87";
Perf.INFO_BG_CLR = "#00FFFF";
Perf.FPS_TXT_CLR = "#000000";
Perf.MS_TXT_CLR = "#000000";
Perf.MEM_TXT_CLR = "#FFFFFF";
Perf.INFO_TXT_CLR = "#000000";
Perf.TOP_LEFT = "TL";
Perf.TOP_RIGHT = "TR";
Perf.BOTTOM_LEFT = "BL";
Perf.BOTTOM_RIGHT = "BR";
Perf.DELAY_TIME = 4000;
PermanentMetaHelper.buildingClassesNumber = 0;
PermanentMetaHelper.registeredClassNames = new haxe_ds_StringMap();
Resources.storiesInfo = new haxe_ds_StringMap();
Resources.singleTextureCache = new haxe_ds_StringMap();
Resources.multiTextureCache = new haxe_ds_StringMap();
Resources.multiTextureCache2 = new haxe_ds_StringMap();
Resources.citizenNames = [];
Settings.settingsLoaded = false;
Settings.musicOn = true;
Settings.soundOn = true;
Settings.fullscreen = false;
Settings.secretCodesEnabled = [];
Settings.pathfindingWorkers = -1;
buildingUpgrades_AIMining.stoneBoost = 0.3;
buildingUpgrades_BetterLightShow.entertainmentBoost = 40;
buildingUpgrades_BetterPickaxes.stoneBoost = 0.2;
buildingUpgrades_DieShrink.efficiencyMod = 2;
buildingUpgrades_DieShrink.extraChipsPerStepPerWorker = 0.00005;
buildingUpgrades_FarmingResearch.extraFoodPerHarvest = 10;
buildingUpgrades_FossilScanner.stoneBoost = 0.3;
buildingUpgrades_MachinePartsFactoryEfficiency.efficiencyMod = 1;
buildingUpgrades_MachinePartsFactoryTurbo.efficiencyMod = 2;
buildingUpgrades_MachinePartsFactoryTurbo.extraMachinePartsMadePerStepPerWorker = 0.0015;
buildingUpgrades_ModernHomePlant.extraYearsPerYear = 0.05;
buildingUpgrades_PickaxeTech.stoneBoost = 0.3;
buildingUpgrades_RefinedMetalsFactoryHack.efficiencyMod = 1;
buildingUpgrades_RefinedMetalsFactoryHack.extraRefinedMetalsMadePerWorker = 0.0005;
buildingUpgrades_TreePlantationResearch.growthSpeedBoost = 0.2;
buildingUpgrades_UltimateScrewdriver.efficiencyMod = 0.058;
buildings_AlienDecryptor.spriteName = "spr_aliendecryptor";
buildings_AlienDecryptor.saveDefinition = "timeWorking$Float";
buildings_AlienHouse.spriteName = "spr_alienhouse";
buildings_Aquarium.spriteName = "spr_aquarium";
buildings_Aquarium.gardenTextureSets = [2];
buildings_Aquarium.openTime = 6.0;
buildings_Aquarium.closeTime = 23;
buildings_Aquarium.saveDefinition = "currentTexture$Int";
buildings_Arcade.spriteName = "spr_arcade";
buildings_Arcade.closeTime = 23;
buildings_Arcade.saveDefinition = "";
buildings_ArtColony.spriteName = "spr_artcolony";
buildings_ArtColony.progressPerStep = 0.00002;
buildings_ArtColony.unlockNewWorkAfter = [4,7,8,10,13,13];
buildings_ArtColony.openTime = 15.0;
buildings_ArtColony.closeTime = 21.5;
buildings_ArtColony.saveDefinition = "currentTexture$Int|currentWorkProgress$Float";
buildings_Beacon.spriteName = "spr_beacon";
buildings_Beacon.saveDefinition = "";
buildings_BlossomHippieHQ.spriteName = "spr_blossomhippiehq";
buildings_BlossomHippieHQ.lastMission = 8;
buildings_BlossomHippieHQ.saveDefinition = "lastEventDoneOnDay$Int|doingEvent$Int|eventPhase$Int|currentMission$Int";
buildings_BlossomHut.spriteName = "spr_bloomrestaurant";
buildings_BlossomRestaurant.spriteName = "spr_bloomrestaurant";
buildings_BlossomRestaurant.closeTime = 0.5;
buildings_BlueCollarWork.workToolsX = 4;
buildings_BlueCollarWork.workToolsTime = 20;
buildings_BoardGameStore.spriteName = "spr_boardgamestore";
buildings_BoardGameStore.closeTime = 23;
buildings_BoardGameStore.firstFloorChairs = [4,12];
buildings_BoardGameStore.saveDefinition = "";
buildings_BotanicalGardens.spriteName = "spr_botanicalgardens";
buildings_BotanicalGardens.gardenTextureSets = [2,3,2,4,2,2];
buildings_BotanicalGardens.mainTextures = ["spr_botanicalgardens","spr_indoorpark","spr_indoorpark_alt1"];
buildings_BotanicalGardens.openTime = 6.0;
buildings_BotanicalGardens.closeTime = 22;
buildings_BotanicalGardens.saveDefinition = "currentMainTexture$Int|currentTexture$Int";
buildings_CacaoFarm.spriteName = "spr_cacaofarm";
buildings_CacaoFarm.foodPerHarvest = 35;
buildings_CacaoFarm.growSpeed = 0.75;
buildings_CacaoFarm.harvestAmount = 0.025;
buildings_CacaoFarm.passiveGrowSpeed = 0.012;
buildings_CacaoFarm.passiveGrowSpeedBadLight = 0.006;
buildings_CacaoFarm.saveDefinition = "farmStage$buildings.CacaoFarmStage|percentGrown$Float|foodLeft$Float|percentCleaned$Float";
buildings_Factory.timePerFrame = 4;
buildings_MaterialConvertingFactory.saveDefinition = "totalMaterialUsed$Float|materialMade$Float";
buildings_ChocolateFactory.spriteName = "spr_chocolatefactory";
buildings_ChocolateFactory.saveDefinition = "";
buildings_CityHall.spriteName = "spr_cityhall";
buildings_CityHall.saveDefinition = "";
buildings_ComputerChipFactory.spriteName = "spr_computerchipfactory";
buildings_ComputerChipFactory.saveDefinition = "";
buildings_ComputerResearchCenter.spriteName = "spr_computerresearchcenter";
buildings_ComputerResearchCenter.knowledgePerStep = 0.0014;
buildings_ComputerResearchCenter.saveDefinition = "totalKnowledgeGenerated$Float";
buildings_CuttingEdgeHome.spriteName = "spr_cuttingedgehome";
buildings_EcoFarm.spriteName = "spr_ecofarm";
buildings_EcoFarm.openTime = 12.0;
buildings_EcoFarm.closeTime = 20.5;
buildings_EcoFarm.crop2Sprites = ["spr_ecofarm_crop2","spr_ecofarm_crop2_alt","spr_ecofarm_crop2_alt2"];
buildings_EcoFarm.crop3Sprites = ["spr_ecofarm_crop3","spr_ecofarm_crop3_alt"];
buildings_EcoFarm.saveDefinition = "openDay$Int|crop2Sprite$Int|crop3Sprite$Int";
buildings_EscapeRoom.spriteName = "spr_labescaperoom";
buildings_EscapeRoom.closeTime = 23.99;
buildings_EscapeRoom.maxVisitors = 10;
buildings_EscapeRoom.saveDefinition = "";
buildings_ExperimentalFarm.spriteName = "spr_experimentalfarm";
buildings_ExperimentalFarm.indoorFarmSpeedIncrease = 0.1;
buildings_ExperimentalFarm.saveDefinition = "";
buildings_ExperimentationLab.spriteName = "spr_experimentationlab";
buildings_ExperimentationLab.saveDefinition = "";
buildings_ExplorationCentre.spriteName = "spr_explorationcentre";
buildings_ExplorationCentre.explorePerAction = 0.25;
buildings_ExplorationCentre.knowledgePerExploreAction = 0.25;
buildings_ExplorationCentre.knowledgePerStep = 0.001;
buildings_RefinedMetalFactory.spriteName = "spr_refinedmetalfactory";
buildings_RefinedMetalFactory.originalEfficiency = 5.0;
buildings_RefinedMetalFactory.origMaterialsMadePerStepPerWorker = 0.001;
buildings_RefinedMetalFactory.saveDefinition = "";
buildings_FactoryPub.spriteName = "spr_refinedmetalfactorypub";
buildings_FactoryPub.closeTime = 4.5;
buildings_FactoryPub.saveDefinition = "";
buildings_FarmByProductProcessor.spriteName = "spr_farmbyproductprocessor";
buildings_FarmByProductProcessor.woodPerFarm = 0.0014;
buildings_FarmByProductProcessor.saveDefinition = "woodMade$Float";
buildings_FarmGrowArea.saveDefinition = "farmStage$buildings.FarmStage|percentGrown$Float|foodLeft$Float|originalFoodLeft$Float|percentCleaned$Float";
buildings_FarmHouse.spriteName = "spr_farmhouse";
buildings_FarmHouse.saveDefinition = "stageProgress$Float|materialPhase$Int|totalMaterialsProduced$Float";
buildings_FestivalHQ.spriteName = "spr_festivalhq";
buildings_FestivalHQ.saveDefinition = "festivalCoolDown$Float";
buildings_FlowerPenthouse.spriteName = "spr_flowerpenthouse";
buildings_FlowerPenthouse.saveDefinition = "mirrored$Bool";
buildings_FossilMuseum.spriteName = "spr_fossilmuseum";
buildings_FossilMuseum.knowledgePerStepPerFossil = 0.001;
buildings_FossilMuseum.closeTime = 23;
buildings_FossilMuseum.educationPerDay = 0.035;
buildings_FossilMuseum.educationCap = 1.61;
buildings_FossilMuseum.saveDefinition = "totalKnowledgeGenerated$Float";
buildings_HackerHQ.spriteName = "spr_hackerhq";
buildings_HackerHQ.lastMission = 11;
buildings_HackerHQ.walkAroundPositions = [3,9,12,13];
buildings_HackerHQ.saveDefinition = "lastEventDoneOnDay$Int|doingEvent$Int|eventPhase$Int|currentMission$Int";
buildings_HerbGarden.spriteName = "spr_herbgarden";
buildings_HerbGarden.saveDefinition = "currentTexture$Int";
buildings_HighTechNightClub.spriteName = "spr_tech_nightclub";
buildings_HighTechNightClub.closeTime = 6;
buildings_HighTechNightClub.saveDefinition = "";
buildings_HoloGameHall.spriteName = "spr_hologamehall";
buildings_HoloGameHall.openTime = 12;
buildings_HoloGameHall.closeTime = 2;
buildings_HoloGameHall.monsterSize = 14;
buildings_HoloGameHall.boosterSpriteSize = 9;
buildings_HyperElevator.spriteName = "spr_hyperelevator";
buildings_HyperElevator.closeDoorSpeed = 0.5;
buildings_HyperElevator.openDoorSpeed = 0.5;
buildings_HyperElevator.doorOpenTime = 45;
buildings_HyperElevator.saveDefinition = "timesUsed$Int|timesUsedTo$Int";
buildings_IndoorFarm.spriteName = "spr_indoorfarm";
buildings_IndoorFarm.foodPerHarvest = 25;
buildings_IndoorFarm.growSpeed = 1.15;
buildings_IndoorFarm.harvestAmount = 0.25;
buildings_IndoorFarm.cleanSpeed = 5;
buildings_IndoorFarm.passiveGrowSpeed = 0.018;
buildings_IndoorFarm.passiveGrowSpeedBadLight = 0.009;
buildings_IndoorFarm.saveDefinition = "farmStage$buildings.FarmStage|percentGrown$Float|foodLeft$Float|percentCleaned$Float";
buildings_Laboratory.spriteName = "spr_laboratory";
buildings_Laboratory.knowledgePerStep = 0.00125;
buildings_Laboratory.firstScientistX = 5;
buildings_Laboratory.secondScientistX = 13;
buildings_Laboratory.scientistY = 9;
buildings_Laboratory.saveDefinition = "totalKnowledgeGenerated$Float";
buildings_LandedExplorationShip.spriteName = "spr_explorationship";
buildings_LandedExplorationShip.saveDefinition = "";
buildings_LandingSite.spriteName = "spr_landingplace";
buildings_LandingSite.flyingSpeed = 3;
buildings_LandingSite.flyingSpeedForPathCalculations = 1.5;
buildings_LandingSite.gettingNewFlyingSaucerStageNumber = 16;
buildings_LandingSite.yChangePerNewGetStep = 0.25;
buildings_LandingSite.maxTimeUntilCanGetNewFlyingSaucer = 30;
buildings_LandingSite.numberOfFlyingSaucerTypes = 6;
buildings_LandingSite.saveDefinition = "timesUsed$Int|timesUsedTo$Int|timesUsedStopOver$Int|saucerType$Int";
buildings_Library.spriteName = "spr_library";
buildings_Library.closeTime = 22;
buildings_Library.educationPerDay = 0.025;
buildings_Library.educationCap = 1.5;
buildings_Library.saveDefinition = "";
buildings_LivingResearchCenter.spriteName = "spr_livingresearchcenter";
buildings_LivingResearchCenter.knowledgePerWalk = 0.10799999999999998;
buildings_LivingResearchCenter.saveDefinition = "totalKnowledgeGenerated$Float";
buildings_MachinePartsFactory.spriteName = "spr_machinepartsfactory";
buildings_MachinePartsFactory.saveDefinition = "";
buildings_MechanicalHouse.spriteName = "spr_mechanicalhouse";
buildings_MechanicalHouse.ifMachinePartsFactoryBonus = 50;
buildings_MedicalClinic.spriteName = "spr_medicalclinic";
buildings_Misdirector.spriteName = "spr_misdirector";
buildings_Misdirector.normalKnowledgeProduction = 0.5;
buildings_Misdirector.reducedKnowledgeProduction = 0.05;
buildings_Misdirector.saveDefinition = "knowledgeGenerated$Float|timesUsedTo$Int";
buildings_ModernArtMuseum.spriteName = "spr_modernartmuseum";
buildings_ModernArtMuseum.closeTime = 21.5;
buildings_ModernArtMuseum.saveDefinition = "currentTexture$Int";
buildings_ModernRusticHome.spriteName = "spr_modernrustichome";
buildings_NightClub.spriteName = "spr_nightclub";
buildings_NightClub.laserMinXWithLeft = 1;
buildings_NightClub.laserMinX = 6;
buildings_NightClub.laserMaxX = 18;
buildings_NightClub.laserMaxY = 18;
buildings_NightClub.closeTime = 6;
buildings_NightClub.nightClubColorOptions = 5;
buildings_NightClub.saveDefinition = "nightClubColor$Int";
buildings_NormalHouse.spriteName = "spr_normalhouse";
buildings_NormalHouse.saveDefinition = "doorMainTexture$Int";
buildings_Observatory.spriteName = "spr_observatory";
buildings_Observatory.knowledgePerStep = 0.002;
buildings_Observatory.starDatabaseUpgradeAmount = 1.5;
buildings_Observatory.starDatabaseAndUniverseDBUpgradeAmount = 6;
buildings_Observatory.saveDefinition = "totalKnowledgeGenerated$Float";
buildings_OutpostHouse.spriteName = "spr_outposthouse";
buildings_Park.spriteName = "spr_botanicalgardens";
buildings_Park.mainTextures = ["spr_botanicalgardens","spr_indoorpark","spr_indoorpark_alt1"];
buildings_Park.openTime = 6.0;
buildings_Park.closeTime = 22;
buildings_Park.saveDefinition = "currentTexture$Int|currentMainTexture$Int";
buildings_ParkPod.spriteName = "spr_botanicalgardens";
buildings_ParkPod.mainTextures = ["spr_botanicalgardens","spr_indoorpark","spr_indoorpark_alt1"];
buildings_ParkPod.saveDefinition = "currentTexture$Int|currentMainTexture$Int";
buildings_Pub.spriteName = "spr_pub";
buildings_Pub.closeTime = 4.5;
buildings_Pub.saveDefinition = "markingTexture$String";
buildings_Restaurant.spriteName = "spr_restaurant";
buildings_Restaurant.closeTime = 0.5;
buildings_School.spriteName = "spr_school";
buildings_ScrapyardNightClub.spriteName = "spr_scrapyardnightclub";
buildings_ScrapyardNightClub.closeTime = 6;
buildings_ScrapyardNightClub.saveDefinition = "mainTextureLeft$Int|mainTextureOther$Int";
buildings_SecretSocietyHouse.spriteName = "spr_secretsocietyhouse";
buildings_SecretSocietyHouse.lastMission = 8;
buildings_SecretSocietyHouse.saveDefinition = "lastEventDoneOnDay$Int|doingEvent$Int|eventPhase$Int|currentMission$Int";
buildings_ShadyHome.spriteName = "spr_shadyhouse";
buildings_SpaciousHouse.spriteName = "spr_spacioushouse";
buildings_StatueGarden.spriteName = "spr_botanicalgardens";
buildings_StatueGarden.saveDefinition = "";
buildings_StatueOfHappiness.spriteName = "spr_botanicalgardens";
buildings_StatueOfHappiness.openTime = 0.0;
buildings_StatueOfHappiness.closeTime = 23.5;
buildings_StatueOfHappiness.saveDefinition = "";
buildings_StatueOfTheKey.spriteName = "spr_botanicalgardens";
buildings_StatueOfTheKey.openTime = 0.0;
buildings_StatueOfTheKey.closeTime = 23.5;
buildings_StatueOfTheKey.saveDefinition = "";
buildings_StoneMine.spriteName = "spr_stonemine";
buildings_StoneMine.normalStoneMinedPerAction = 0.2;
buildings_StoneMine.stoneMineTimeMin = 90;
buildings_StoneMine.stoneMineTimeMax = 120;
buildings_StoneResearchCenter.spriteName = "spr_stoneresearchcentre";
buildings_StoneResearchCenter.bonusDivider = 200;
buildings_StoneResearchCenter.bonusMultiplier = 0.075;
buildings_StoneResearchCenter.bonusMultiplierStart = 0.15;
buildings_StoneResearchCenter.bonusLogFactor = 2;
buildings_StoneResearchCenter.bonusDividerPT = 195;
buildings_StoneResearchCenter.bonusMultiplierPT = 0.1;
buildings_StoneResearchCenter.bonusLogFactorPT = 1.65;
buildings_StoneResearchCenter.linearBonusFactorPT = 2.5e-005;
buildings_StoneResearchCenter.saveDefinition = "totalKnowledgeGenerated$Float";
buildings_StoneTeleporter.spriteName = "spr_stoneteleporter";
buildings_StoneTeleporter.bigStoneInitialMaterials = 150;
buildings_StoneTeleporter.fossilChancePerIM = 0.00001;
buildings_StoneTeleporter.saveDefinition = "regrowProgress$Float|materialsLeft$Float|hasBigStone$Bool";
buildings_Supercomputer.spriteName = "spr_supercomputer";
buildings_Supercomputer.knowledgePerDayPerEmployee = 2;
buildings_Supercomputer.saveDefinition = "knowledgeSoFar$Float";
buildings_Teleporter.spriteName = "spr_teleporter";
buildings_Teleporter.saveDefinition = "timesUsed$Int|timesUsedTo$Int";
buildings_TheContraption.spriteName = "spr_contraption";
buildings_TheMachine.spriteName = "spr_secretsocietymachine";
buildings_TheMachine.saveDefinition = "animProgress$Float|lastDayReward$Int|thisDayMaterialReward$ds|totalMaterialReward$ds";
buildings_TinkerersHome.spriteName = "spr_tinkerershouse";
buildings_TinkerersHome.educationPerDay = 0.01;
buildings_TinkerersHome.educationCap = 1.25;
buildings_TinkerersHome.saveDefinition = "frontTextureUsed$Int|backTextureUsed$Int";
buildings_TreeHuggerBase.spriteName = "spr_bloomrestaurant";
buildings_TreePlantation.spriteName = "spr_treeplantation";
buildings_TreePlantation.workerRegrowBoost = 0.5;
buildings_TreePlantation.growWaitTimeMin = 120;
buildings_TreePlantation.growWaitTimeMax = 180;
buildings_TreePlantation.saveDefinition = "regrowProgress$Float|materialsLeft$Float";
buildings_UnknownBuilding.spriteName = "spr_unknownbuilding";
buildings_Villa.spriteName = "spr_villa";
buildings_Villa.saveDefinition = "timesUsed$Int|timesUsedTo$Int";
buildings_WoodcuttingCentre.spriteName = "spr_woodcuttingcentre";
buildings_WoodcuttingCentre.woodCutPerAction = 0.2;
buildings_WoodcuttingCentre.woodCutTimeMin = 60;
buildings_WoodcuttingCentre.woodCutTimeMax = 90;
buildings_Workshop.spriteName = "spr_workshop";
buildings_Workshop.materialsMadePerWalkPerWorker = 0.075;
buildings_Workshop.woodToMachinePartsEfficiency = 2;
buildings_Workshop.knowledgePerWalk = 0.15;
buildings_Workshop.machinePartsFactorySpeedIncrease = 1.25;
buildings_Workshop.saveDefinition = "materialMade$Float|totalMaterialUsed$Float|totalKnowledgeGenerated$Float";
cityUpgrades_CityUpgrade.saveDefinition = "";
common_AdHelper.adExpireTime = 18000;
common_AdHelper.adExpireTimeRewarded = 0;
common_AdHelper.adCapRemaining = 1000000;
common_AdHelper.minTimeBetweenRewarded = 18000;
common_AdHelper.standardAdExpireTime = 18000;
common_KongTools.highestHappinessReported = 0;
common_KongTools.highestHappinessKnown = 0;
common_KongTools.statTimeout = 0;
common_KongTools.kongJSLoaded = false;
common_Performance.frameTimeValues = [];
common_Performance.previousTime = 0;
common_Performance.isDrawingFPSCurrently = false;
common_PokiHelpers.isAdBlockEnabled = false;
common_Storage.knowsSupport = false;
common_Storage.hasSupport = false;
graphics_Particle.pool = [];
gui_GameMenu.canUndoReset = false;
gui_NinePatch.ninePatchTextureCache = new haxe_ds_ObjectMap();
haxe_Serializer.USE_CACHE = false;
haxe_Serializer.USE_ENUM_INDEX = false;
haxe_Serializer.BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:";
haxe_Unserializer.DEFAULT_RESOLVER = new haxe__$Unserializer_DefaultResolver();
haxe_Unserializer.BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:";
haxe_crypto_Base64.CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
haxe_crypto_Base64.BYTES = haxe_io_Bytes.ofString(haxe_crypto_Base64.CHARS);
modding_ModTools.onGlobalSaveFuncs = [];
modding_ModTools.onGlobalSaveFuncsEarly = [];
pathfinder_PermanentPrioritizable.pool = [];
policies_Policy.saveDefinition = "";
pooling_Int32ArrayPool.maxSize = 20;
pooling_Int32ArrayPool.maxPoolAmount = 10000;
pooling_Int32ArrayPool.pool = (function($this) {
var $r;
var _g = [];
{
_g.push([]);
_g.push([]);
_g.push([]);
_g.push([]);
_g.push([]);
_g.push([]);
_g.push([]);
_g.push([]);
_g.push([]);
_g.push([]);
_g.push([]);
_g.push([]);
_g.push([]);
_g.push([]);
_g.push([]);
_g.push([]);
_g.push([]);
_g.push([]);
_g.push([]);
_g.push([]);
}
$r = _g;
return $r;
}(this));
pooling_PooledSprite.pool = new haxe_ds_ObjectMap();
progress_SandboxHelper.saveDefinition = "unlimitedResources$Bool|everPlayedWithUnlimitedResources$Bool";
progress_ScriptedStoryPart.saveDefinition = "";
progress_Story.saveDefinition = "storyName$String|disableDying$Bool|disableDestroy$Bool|hiddenBoost$Bool";
progress_Unlocks.saveDefinition = "unlockState$ds|explicityLocked$ds|unlockedDecorationTab$Bool|unlockedBuildingModeButton$Bool|unlockedManagementOptions$Bool|numberOfModernArtMuseumArtworksUnlocked$Int";
progress_scriptedStoryParts_AlienInvasion.saveDefinition = "timeUntilInvasion$Float|invasionProgress$Float|isInvasion$Bool|isInvasionFinished$Bool";
progress_scriptedStoryParts_SpawnCitizensRegularly.saveDefinition = "spawnNumber$Int|nextSpawn$Float|groupSizeMin$Int|groupSizeMax$Int|ageRangeMin$Int|ageRangeMax$Int|worldID$Int|timeBetweenMin$Int|timeBetweenMax$Int|afterDoneMessage$String";
simulation_BabyMaker.saveDefinition = "softPopLimit$Int|mode$ds|targetPopAmount$Int";
simulation_BonusResults.saveDefinition = "extraFoodFromFarms$Int|machinePartsFactorySpeed$Float|labSpeed$Float|indoorFarmSpeed$Float|fossilsCollected$Int";
simulation_BoostManager.enableExtraReward = 2 != 6 ? 2 == 8 : true;
simulation_BoostManager.saveDefinition = "boostLeft$Float|maxBoost$Float|normalMaxBoost$Float";
simulation_Eating.saveDefinition = "foodShortage$Float";
simulation_EntertainmentTypeHelpers.entertainmentTypeNumber = 6;
simulation_Fish.saveDefinition = "type$Int|relativeX$Float|relativeY$Float";
simulation_Happiness.saveDefinition = "happiness$Float|homeHappiness$Float|purposeHappiness$Float|entertainmentHappiness$Float|schoolHappiness$Float|medicalHappiness$Float|fullHappinessTime$Float|overtimeUnhappinessActual$Float|overtimeStarted$Float|lastOvertime$Float|lastOvertimeDay$Float|lastRestoreTime$Float|actualHappiness$Float|happinessEnthusiasmLevel$Int|lastShownVeryUnhappyWarning$Int|veryUnhappyFromDay$Int";
simulation_HappinessBoost.saveDefinition = "boostUntil$Float|boost$Float|text$String|canGoOverMax$Bool";
simulation_HouseAssigner.privateTeleportersLeft = [];
simulation_Stats.saveDefinition = "";
simulation_citizenSpecialActions_ClimbIntoTree.fromHour = 0;
simulation_citizenSpecialActions_ClimbIntoTree.toHour = 4;
simulation_citizenSpecialActions_ClimbOntoRuins.fromHour = 0.5;
simulation_citizenSpecialActions_ClimbOntoRuins.toHour = 4.5;
simulation_citizenSpecialActions_DanceOnBall.fromHour = 1;
simulation_citizenSpecialActions_DanceOnBall.toHour = 5;
simulation_citizenSpecialActions_DanceOnBall.moveSpeed = 0.5;
simulation_citizenSpecialActions_MoveToEdge.fromHour = 23;
simulation_citizenSpecialActions_MoveToEdge.toHour = 5;
simulation_citizenSpecialActions_Protester.fromHour = 0;
simulation_citizenSpecialActions_Protester.toHour = 4;
simulation_citizenSpecialActions_Protester.moveSpeed = 0.66666666666666663;
simulation_citizenSpecialActions_WatchStars.fromHour = 0;
simulation_citizenSpecialActions_WatchStars.toHour = 4;
simulation_festival_Festival.saveDefinition = "timeStart$Float|timeEnd$Float|started$Bool";
simulation_festival_MusicFestival.minCitizens = 100;
simulation_festival_MusicFestival.happinessBoostDuration = 10080;
simulation_festival_MusicFestival.happinessBoostGiven = 25;
simulation_festival_MusicFestival.citizensPerVenue = 20;
simulation_festival_MusicFestival.saveDefinition = "";
worldResources_AlienRuins.saveDefinition = "explored$Float|bonusesAwarded$Int|spriteName$String";
worldResources_LimitedWorldResource.saveDefinition = "materialsLeft$Float|regrowProgress$Float";
worldResources_Forest.saveDefinition = "managementMode$worldResources.ForestManagementMode";
Main.main();
})(typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this, typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this);