(function (factory) {
if (typeof define === 'function' && define.amd)
define(['exports', './kyd-kyd-core.js', './kotlin-kotlin-stdlib.js', './glok-glok-model.js', './glok-glok-core.js'], factory);
else if (typeof exports === 'object')
factory(module.exports, require('./kyd-kyd-core.js'), require('./kotlin-kotlin-stdlib.js'), require('./glok-glok-model.js'), require('./glok-glok-core.js'));
else {
if (typeof globalThis['kyd-kyd-core'] === 'undefined') {
throw new Error("Error loading module 'cavernQuest2'. Its dependency 'kyd-kyd-core' was not found. Please, check whether 'kyd-kyd-core' is loaded prior to 'cavernQuest2'.");
}
if (typeof globalThis['kotlin-kotlin-stdlib'] === 'undefined') {
throw new Error("Error loading module 'cavernQuest2'. Its dependency 'kotlin-kotlin-stdlib' was not found. Please, check whether 'kotlin-kotlin-stdlib' is loaded prior to 'cavernQuest2'.");
}
if (typeof globalThis['glok-glok-model'] === 'undefined') {
throw new Error("Error loading module 'cavernQuest2'. Its dependency 'glok-glok-model' was not found. Please, check whether 'glok-glok-model' is loaded prior to 'cavernQuest2'.");
}
if (typeof globalThis['glok-glok-core'] === 'undefined') {
throw new Error("Error loading module 'cavernQuest2'. Its dependency 'glok-glok-core' was not found. Please, check whether 'glok-glok-core' is loaded prior to 'cavernQuest2'.");
}
globalThis.cavernQuest2 = factory(typeof cavernQuest2 === 'undefined' ? {} : cavernQuest2, globalThis['kyd-kyd-core'], globalThis['kotlin-kotlin-stdlib'], globalThis['glok-glok-model'], globalThis['glok-glok-core']);
}
}(function (_, kotlin_uk_co_nickthecoder_kyd_core, kotlin_kotlin, kotlin_uk_co_nickthecoder_glok_model, kotlin_uk_co_nickthecoder_glok_core) {
'use strict';
//region block: imports
var imul = Math.imul;
var Label = kotlin_uk_co_nickthecoder_kyd_core.$_$.h;
var Unit_instance = kotlin_kotlin.$_$.o1;
var intProperty = kotlin_uk_co_nickthecoder_glok_model.$_$.p;
var protoOf = kotlin_kotlin.$_$.d5;
var onActStarted = kotlin_uk_co_nickthecoder_kyd_core.$_$.r;
var onExitedStage = kotlin_uk_co_nickthecoder_kyd_core.$_$.s;
var customProperties = kotlin_uk_co_nickthecoder_kyd_core.$_$.u;
var tick = kotlin_uk_co_nickthecoder_kyd_core.$_$.f1;
var Behaviour = kotlin_uk_co_nickthecoder_kyd_core.$_$.t;
var initMetadataForClass = kotlin_kotlin.$_$.q4;
var VOID = kotlin_kotlin.$_$.c;
var KProperty1 = kotlin_kotlin.$_$.l5;
var getPropertyCallableRef = kotlin_kotlin.$_$.n4;
var KMutableProperty1 = kotlin_kotlin.$_$.k5;
var throwUninitializedPropertyAccessException = kotlin_kotlin.$_$.x6;
var initMetadataForCompanion = kotlin_kotlin.$_$.r4;
var Management = kotlin_uk_co_nickthecoder_kyd_core.$_$.d1;
var GridSnapping_init_$Create$ = kotlin_uk_co_nickthecoder_kyd_core.$_$.a;
var booleanProperty = kotlin_uk_co_nickthecoder_glok_model.$_$.m;
var ArrayList_init_$Create$ = kotlin_kotlin.$_$.f;
var round = kotlin_kotlin.$_$.h5;
var numberToInt = kotlin_kotlin.$_$.a5;
var Pair = kotlin_kotlin.$_$.l6;
var get_log = kotlin_uk_co_nickthecoder_glok_core.$_$.c1;
var toString = kotlin_kotlin.$_$.f5;
var Companion_getInstance = kotlin_uk_co_nickthecoder_glok_core.$_$.j;
var Vector2 = kotlin_uk_co_nickthecoder_kyd_core.$_$.n;
var Companion_instance = kotlin_uk_co_nickthecoder_kyd_core.$_$.f;
var onActStarting = kotlin_uk_co_nickthecoder_kyd_core.$_$.x;
var onActEnded = kotlin_uk_co_nickthecoder_kyd_core.$_$.v;
var preTick = kotlin_uk_co_nickthecoder_kyd_core.$_$.a1;
var postTick = kotlin_uk_co_nickthecoder_kyd_core.$_$.z;
var onKeyReleased = kotlin_uk_co_nickthecoder_kyd_core.$_$.y;
var Director = kotlin_uk_co_nickthecoder_kyd_core.$_$.b1;
var enumEntries = kotlin_kotlin.$_$.y3;
var Enum = kotlin_kotlin.$_$.g6;
var Enumerable = kotlin_uk_co_nickthecoder_kyd_core.$_$.c1;
var isInterface = kotlin_kotlin.$_$.v4;
var page = kotlin_uk_co_nickthecoder_kyd_core.$_$.m;
var property = kotlin_uk_co_nickthecoder_glok_model.$_$.h1;
var listOf = kotlin_kotlin.$_$.i2;
var THROW_CCE = kotlin_kotlin.$_$.n6;
var AppearanceResource = kotlin_uk_co_nickthecoder_kyd_core.$_$.g;
var flipBook = kotlin_uk_co_nickthecoder_kyd_core.$_$.l;
var Ticks = kotlin_uk_co_nickthecoder_kyd_core.$_$.g1;
var noWhenBranchMatchedException = kotlin_kotlin.$_$.v6;
var Companion_instance_0 = kotlin_uk_co_nickthecoder_kyd_core.$_$.b;
var listOf_0 = kotlin_kotlin.$_$.j2;
var Default_getInstance = kotlin_kotlin.$_$.l1;
var Role = kotlin_uk_co_nickthecoder_kyd_core.$_$.e1;
var println = kotlin_kotlin.$_$.z3;
var Actor = kotlin_uk_co_nickthecoder_kyd_core.$_$.q;
var createScreenshot = kotlin_uk_co_nickthecoder_kyd_core.$_$.o;
var createThumbnail = kotlin_uk_co_nickthecoder_kyd_core.$_$.p;
var Companion_getInstance_0 = kotlin_uk_co_nickthecoder_kyd_core.$_$.c;
var onActStarted_0 = kotlin_uk_co_nickthecoder_kyd_core.$_$.w;
var Key_DOWN_getInstance = kotlin_uk_co_nickthecoder_glok_core.$_$.a;
var Key_UP_getInstance = kotlin_uk_co_nickthecoder_glok_core.$_$.d;
var Key_RIGHT_getInstance = kotlin_uk_co_nickthecoder_glok_core.$_$.c;
var Key_LEFT_getInstance = kotlin_uk_co_nickthecoder_glok_core.$_$.b;
var initMetadataForInterface = kotlin_kotlin.$_$.s4;
var flipBookAnimation = kotlin_uk_co_nickthecoder_kyd_core.$_$.j;
var WithAppearance = kotlin_uk_co_nickthecoder_kyd_core.$_$.i;
var flipBookAnimation_0 = kotlin_uk_co_nickthecoder_kyd_core.$_$.k;
var Application = kotlin_uk_co_nickthecoder_glok_core.$_$.l;
var endsWith = kotlin_kotlin.$_$.q5;
var Launcher_instance = kotlin_uk_co_nickthecoder_kyd_core.$_$.e;
var getKClass = kotlin_kotlin.$_$.b;
var launchInContainer = kotlin_uk_co_nickthecoder_glok_core.$_$.n;
var KydTypeRegistry_getInstance = kotlin_uk_co_nickthecoder_kyd_core.$_$.d;
//endregion
//region block: pre-declaration
initMetadataForClass(BlastsCounter, 'BlastsCounter', BlastsCounter, VOID, [Behaviour]);
initMetadataForCompanion(Companion);
initMetadataForClass(CavernQuest, 'CavernQuest', VOID, Management);
initMetadataForClass(Item, 'Item', VOID, VOID, [Behaviour]);
initMetadataForClass(Collectable, 'Collectable', VOID, Item);
initMetadataForClass(Dynamite, 'Dynamite', Dynamite, Collectable);
initMetadataForClass(Fuel, 'Fuel', Fuel, Collectable);
initMetadataForClass(FuelStatus, 'FuelStatus', FuelStatus, VOID, [Behaviour]);
initMetadataForClass(Granite, 'Granite', Granite, Item);
initMetadataForClass(Column, 'Column', Column);
initMetadataForClass(Grid, 'Grid');
initMetadataForClass(MenuDirector, 'MenuDirector', MenuDirector, VOID, [Director]);
initMetadataForClass(MonsterMovement, 'MonsterMovement', VOID, Enum, [Enumerable, Enum]);
initMetadataForInterface(Killable, 'Killable');
initMetadataForClass(Monster, 'Monster', Monster, Item, [Item, Killable]);
initMetadataForCompanion(Companion_0);
initMetadataForClass(PlayDirector, 'PlayDirector', PlayDirector, VOID, [Director]);
initMetadataForClass(Player, 'Player', Player, Item, [Item, Killable]);
initMetadataForClass(Rock, 'Rock', Rock, Item);
initMetadataForClass(Ship, 'Ship', Ship, Item);
initMetadataForClass(Soil, 'Soil', Soil, Item);
initMetadataForClass(SpawnPoint, 'SpawnPoint', SpawnPoint, VOID, [Behaviour]);
initMetadataForClass(Main, 'Main', Main, Application);
//endregion
function updateCounter($this, actor) {
var tmp = actor.n3u();
var tmp0_safe_receiver = tmp instanceof Label ? tmp : null;
if (tmp0_safe_receiver == null)
null;
else {
// Inline function 'kotlin.let' call
// Inline function 'BlastsCounter.updateCounter.<anonymous>' call
tmp0_safe_receiver.oy('Blasts : ' + $this.l58());
}
}
function BlastsCounter$onEnteredStage$lambda(this$0, $actor) {
return function (it) {
updateCounter(this$0, $actor);
return Unit_instance;
};
}
function BlastsCounter() {
this.j58_1 = intProperty(0);
this.k58_1 = this.m58();
}
protoOf(BlastsCounter).m58 = function () {
return this.j58_1.ik(this, blastsProperty$factory());
};
protoOf(BlastsCounter).n58 = function (_set____db54di) {
return this.k58_1.cm(this, blasts$factory(), _set____db54di);
};
protoOf(BlastsCounter).l58 = function () {
return this.k58_1.ik(this, blasts$factory_0());
};
protoOf(BlastsCounter).b3w = function (actor) {
Companion_instance_2.s17().b59(this);
updateCounter(this, actor);
var tmp = this.m58();
tmp.wh(BlastsCounter$onEnteredStage$lambda(this, actor));
};
function blastsProperty$factory() {
return getPropertyCallableRef('blastsProperty', 1, KProperty1, function (receiver) {
return receiver.m58();
}, null);
}
function blasts$factory() {
return getPropertyCallableRef('blasts', 1, KMutableProperty1, function (receiver) {
return receiver.l58();
}, function (receiver, value) {
return receiver.n58(value);
});
}
function blasts$factory_0() {
return getPropertyCallableRef('blasts', 1, KMutableProperty1, function (receiver) {
return receiver.l58();
}, function (receiver, value) {
return receiver.n58(value);
});
}
function Companion() {
}
protoOf(Companion).s17 = function () {
var tmp = this.c59_1;
if (!(tmp == null))
return tmp;
else {
throwUninitializedPropertyAccessException('instance');
}
};
var Companion_instance_1;
function Companion_getInstance_1() {
return Companion_instance_1;
}
function CavernQuest(game) {
Management.call(this, game);
this.k59_1 = 25;
this.l59_1 = 1000;
this.m59_1 = false;
this.n59_1 = true;
this.o59_1 = GridSnapping_init_$Create$(36.0);
Companion_instance_1.c59_1 = this;
}
function Collectable() {
Item.call(this);
}
protoOf(Collectable).r59 = function (collectedActor) {
collectedActor.b3t_1.d3v(collectedActor);
Companion_instance_2.s17().v58_1.k(this.s59_1).z59(this.t59_1, null);
};
function Dynamite() {
Collectable.call(this);
}
protoOf(Dynamite).r59 = function (collectedActor) {
protoOf(Collectable).r59.call(this, collectedActor);
var tmp = collectedActor.n3u();
var label = tmp instanceof Label ? tmp : null;
var tmp1_safe_receiver = label == null ? null : label.py();
var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : tmp1_safe_receiver.length;
var amount = tmp2_elvis_lhs == null ? 1 : tmp2_elvis_lhs;
Companion_instance_2.s17().e5a(amount);
};
function Fuel() {
Collectable.call(this);
}
protoOf(Fuel).r59 = function (collectedActor) {
protoOf(Collectable).r59.call(this, collectedActor);
Companion_instance_2.s17().h5a();
};
function updateText($this, actor) {
var tmp = actor.n3u();
var tmp0_safe_receiver = tmp instanceof Label ? tmp : null;
if (tmp0_safe_receiver == null)
null;
else {
// Inline function 'kotlin.let' call
// Inline function 'FuelStatus.updateText.<anonymous>' call
tmp0_safe_receiver.oy($this.k5a() ? 'Ready to Take Off' : 'No Fuel');
}
}
function FuelStatus$onEnteredStage$lambda(this$0, $actor) {
return function (it) {
updateText(this$0, $actor);
return Unit_instance;
};
}
function FuelStatus() {
this.i5a_1 = booleanProperty(false);
this.j5a_1 = this.l5a();
}
protoOf(FuelStatus).l5a = function () {
return this.i5a_1.ik(this, fueledProperty$factory());
};
protoOf(FuelStatus).m5a = function (_set____db54di) {
return this.j5a_1.cm(this, fueled$factory(), _set____db54di);
};
protoOf(FuelStatus).k5a = function () {
return this.j5a_1.ik(this, fueled$factory_0());
};
protoOf(FuelStatus).b3w = function (actor) {
Companion_instance_2.s17().n5a(this);
updateText(this, actor);
var tmp = this.l5a();
tmp.wh(FuelStatus$onEnteredStage$lambda(this, actor));
};
function fueledProperty$factory() {
return getPropertyCallableRef('fueledProperty', 1, KProperty1, function (receiver) {
return receiver.l5a();
}, null);
}
function fueled$factory() {
return getPropertyCallableRef('fueled', 1, KMutableProperty1, function (receiver) {
return receiver.k5a();
}, function (receiver, value) {
return receiver.m5a(value);
});
}
function fueled$factory_0() {
return getPropertyCallableRef('fueled', 1, KMutableProperty1, function (receiver) {
return receiver.k5a();
}, function (receiver, value) {
return receiver.m5a(value);
});
}
function Granite() {
Item.call(this);
}
function rowIndex($this, rowReference) {
if (rowReference < $this.y59_1) {
var extra = $this.y59_1 - rowReference | 0;
var inductionVariable = 0;
if (inductionVariable < extra)
do {
var i = inductionVariable;
inductionVariable = inductionVariable + 1 | 0;
$this.x59_1.t3(0, null);
}
while (inductionVariable < extra);
$this.y59_1 = rowReference;
}
if (rowReference >= ($this.x59_1.j() + $this.y59_1 | 0)) {
var extra_0 = ((rowReference - $this.x59_1.j() | 0) - $this.y59_1 | 0) + 1 | 0;
var inductionVariable_0 = 0;
if (inductionVariable_0 < extra_0)
do {
var i_0 = inductionVariable_0;
inductionVariable_0 = inductionVariable_0 + 1 | 0;
$this.x59_1.e(null);
}
while (inductionVariable_0 < extra_0);
}
return rowReference - $this.y59_1 | 0;
}
function Column() {
var tmp = this;
// Inline function 'kotlin.collections.mutableListOf' call
tmp.x59_1 = ArrayList_init_$Create$();
this.y59_1 = 0;
}
protoOf(Column).k = function (rowReference) {
return this.x59_1.k(rowIndex(this, rowReference));
};
protoOf(Column).z59 = function (index, actor) {
this.x59_1.w2(rowIndex(this, index), actor);
};
function columnIndex($this, columnReference) {
if (columnReference < $this.w59_1) {
var extra = $this.w59_1 - columnReference | 0;
var inductionVariable = 0;
if (inductionVariable < extra)
do {
var i = inductionVariable;
inductionVariable = inductionVariable + 1 | 0;
$this.v59_1.t3(0, new Column());
}
while (inductionVariable < extra);
$this.w59_1 = columnReference;
}
if (columnReference >= ($this.v59_1.j() + $this.w59_1 | 0)) {
var extra_0 = ((columnReference - $this.v59_1.j() | 0) - $this.w59_1 | 0) + 1 | 0;
var inductionVariable_0 = 0;
if (inductionVariable_0 < extra_0)
do {
var i_0 = inductionVariable_0;
inductionVariable_0 = inductionVariable_0 + 1 | 0;
$this.v59_1.e(new Column());
}
while (inductionVariable_0 < extra_0);
}
return columnReference - $this.w59_1 | 0;
}
function Grid(gridSize) {
this.u59_1 = gridSize;
var tmp = this;
// Inline function 'kotlin.collections.mutableListOf' call
tmp.v59_1 = ArrayList_init_$Create$();
this.w59_1 = 0;
}
protoOf(Grid).k = function (columnReference) {
return this.v59_1.k(columnIndex(this, columnReference));
};
protoOf(Grid).o5a = function (world) {
// Inline function 'kotlin.math.round' call
var x = world.x3s_1 / this.u59_1;
var tmp$ret$0 = round(x);
var gridX = numberToInt(tmp$ret$0);
// Inline function 'kotlin.math.round' call
var x_0 = world.y3s_1 / this.u59_1;
var tmp$ret$1 = round(x_0);
var gridY = numberToInt(tmp$ret$1);
return this.k(gridX).k(gridY);
};
protoOf(Grid).p5a = function (world, actor) {
// Inline function 'kotlin.math.round' call
var x = world.x3s_1 / this.u59_1;
var tmp$ret$0 = round(x);
var gridX = numberToInt(tmp$ret$0);
// Inline function 'kotlin.math.round' call
var x_0 = world.y3s_1 / this.u59_1;
var tmp$ret$1 = round(x_0);
var gridY = numberToInt(tmp$ret$1);
this.k(gridX).z59(gridY, actor);
return new Pair(gridX, gridY);
};
function Item() {
this.s59_1 = 0;
this.t59_1 = 0;
}
protoOf(Item).a5a = function () {
return false;
};
protoOf(Item).b5a = function () {
return false;
};
protoOf(Item).b3w = function (actor) {
var existing = Companion_instance_2.s17().v58_1.o5a(actor.t3u());
if (!(existing == null)) {
get_log().q2t('Two items @ ' + actor.t3u().toString() + ' : ' + toString(existing.p3u()) + ' and ' + toString(this));
actor.n3u().j4a(Companion_getInstance().a1h_1);
existing.n3u().j4a(Companion_getInstance().n1e_1);
}
var _destruct__k2r9zo = Companion_instance_2.s17().v58_1.p5a(actor.t3u(), actor);
var x = _destruct__k2r9zo.lc();
var y = _destruct__k2r9zo.mc();
this.s59_1 = x;
this.t59_1 = y;
};
protoOf(Item).q5a = function (dx, dy) {
return Companion_instance_2.s17().v58_1.k(this.s59_1 + dx | 0).k(this.t59_1 + dy | 0);
};
protoOf(Item).r5a = function (actor, dx, dy) {
var grid = Companion_instance_2.s17().v58_1;
var otherActor = grid.k(this.s59_1 + dx | 0).k(this.t59_1 + dy | 0);
if (isEmpty(otherActor)) {
grid.k(this.s59_1).z59(this.t59_1, null);
actor.s3u(actor.t3u().e55(new Vector2(dx * grid.u59_1, dy * grid.u59_1)));
this.s59_1 = this.s59_1 + dx | 0;
this.t59_1 = this.t59_1 + dy | 0;
grid.k(this.s59_1).z59(this.t59_1, actor);
return true;
}
return false;
};
function isEmpty(_this__u8e3s4) {
if (_this__u8e3s4 == null)
return true;
var tmp = _this__u8e3s4.p3u();
var tmp0_elvis_lhs = tmp instanceof Item ? tmp : null;
var tmp_0;
if (tmp0_elvis_lhs == null) {
return true;
} else {
tmp_0 = tmp0_elvis_lhs;
}
var item = tmp_0;
return item.b5a();
}
function isWall(_this__u8e3s4) {
if (_this__u8e3s4 == null)
return false;
var tmp = _this__u8e3s4.p3u();
return !(tmp instanceof Monster);
}
function isSoil(_this__u8e3s4) {
if (_this__u8e3s4 == null)
return false;
var tmp = _this__u8e3s4.p3u();
var tmp0_elvis_lhs = tmp instanceof Item ? tmp : null;
var tmp_0;
if (tmp0_elvis_lhs == null) {
return false;
} else {
tmp_0 = tmp0_elvis_lhs;
}
var item = tmp_0;
return item.a5a();
}
function _get_modeAppearance__w8qxdo($this) {
var tmp = $this.s5a_1;
if (!(tmp == null))
return tmp;
else {
throwUninitializedPropertyAccessException('modeAppearance');
}
}
function MenuDirector() {
}
protoOf(MenuDirector).p3w = function (act) {
var tmp0_safe_receiver = Companion_instance.s17().z41();
var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.q3r_1;
var tmp;
if (tmp1_safe_receiver == null) {
tmp = null;
} else {
var tmp$ret$1;
$l$block: {
// Inline function 'kotlin.collections.firstOrNull' call
var _iterator__ex2g4s = tmp1_safe_receiver.g();
while (_iterator__ex2g4s.h()) {
var element = _iterator__ex2g4s.i();
// Inline function 'MenuDirector.onActStarted.<anonymous>' call
if (element.c3s_1 === 'glass') {
tmp$ret$1 = element;
break $l$block;
}
}
tmp$ret$1 = null;
}
tmp = tmp$ret$1;
}
var tmp2_safe_receiver = tmp;
var tmp3_safe_receiver = tmp2_safe_receiver == null ? null : tmp2_safe_receiver.f3s();
var tmp_0;
if (tmp3_safe_receiver == null) {
tmp_0 = null;
} else {
var tmp$ret$3;
$l$block_0: {
// Inline function 'kotlin.collections.firstOrNull' call
var _iterator__ex2g4s_0 = tmp3_safe_receiver.g();
while (_iterator__ex2g4s_0.h()) {
var element_0 = _iterator__ex2g4s_0.i();
// Inline function 'MenuDirector.onActStarted.<anonymous>' call
if (element_0.i2b() === 'mode') {
tmp$ret$3 = element_0;
break $l$block_0;
}
}
tmp$ret$3 = null;
}
tmp_0 = tmp$ret$3;
}
var tmp4_safe_receiver = tmp_0;
var tmp_1 = tmp4_safe_receiver == null ? null : tmp4_safe_receiver.n3u();
var tmp5_safe_receiver = tmp_1 instanceof Label ? tmp_1 : null;
if (tmp5_safe_receiver == null)
null;
else {
// Inline function 'kotlin.let' call
// Inline function 'MenuDirector.onActStarted.<anonymous>' call
this.s5a_1 = tmp5_safe_receiver;
}
};
protoOf(MenuDirector).t3w = function (keyEvent) {
switch (keyEvent.wy_1.c2_1) {
case 7:
Companion_instance.s17().z45('/play');
break;
case 8:
_get_modeAppearance__w8qxdo(this).oy('*');
// Inline function 'kotlin.with' call
// Inline function 'MenuDirector.onKeyPressed.<anonymous>' call
var $this$with = Companion_instance_1.s17();
$this$with.l59_1 = 1000;
$this$with.k59_1 = 50;
$this$with.m59_1 = true;
$this$with.n59_1 = true;
break;
case 9:
_get_modeAppearance__w8qxdo(this).oy('\n*');
// Inline function 'kotlin.with' call
// Inline function 'MenuDirector.onKeyPressed.<anonymous>' call
var $this$with_0 = Companion_instance_1.s17();
$this$with_0.l59_1 = 1000;
$this$with_0.k59_1 = 25;
$this$with_0.m59_1 = false;
$this$with_0.n59_1 = true;
break;
case 10:
_get_modeAppearance__w8qxdo(this).oy('\n\n*');
// Inline function 'kotlin.with' call
// Inline function 'MenuDirector.onKeyPressed.<anonymous>' call
var $this$with_1 = Companion_instance_1.s17();
$this$with_1.l59_1 = 50;
$this$with_1.k59_1 = 10;
$this$with_1.m59_1 = false;
$this$with_1.n59_1 = false;
break;
case 15:
Companion_instance.s17().p46();
break;
default:
break;
}
};
var MonsterMovement_ATTACK_STICK_HORIZONTAL_instance;
var MonsterMovement_ATTACK_STICK_VERTICAL_instance;
var MonsterMovement_ATTACK_STICK_BOTH_instance;
var MonsterMovement_ATTACK_STICK_NONE_instance;
function values() {
return [MonsterMovement_ATTACK_STICK_HORIZONTAL_getInstance(), MonsterMovement_ATTACK_STICK_VERTICAL_getInstance(), MonsterMovement_ATTACK_STICK_BOTH_getInstance(), MonsterMovement_ATTACK_STICK_NONE_getInstance()];
}
function get_entries() {
if ($ENTRIES == null)
$ENTRIES = enumEntries(values());
return $ENTRIES;
}
var MonsterMovement_entriesInitialized;
function MonsterMovement_initEntries() {
if (MonsterMovement_entriesInitialized)
return Unit_instance;
MonsterMovement_entriesInitialized = true;
MonsterMovement_ATTACK_STICK_HORIZONTAL_instance = new MonsterMovement('ATTACK_STICK_HORIZONTAL', 0);
MonsterMovement_ATTACK_STICK_VERTICAL_instance = new MonsterMovement('ATTACK_STICK_VERTICAL', 1);
MonsterMovement_ATTACK_STICK_BOTH_instance = new MonsterMovement('ATTACK_STICK_BOTH', 2);
MonsterMovement_ATTACK_STICK_NONE_instance = new MonsterMovement('ATTACK_STICK_NONE', 3);
}
var $ENTRIES;
function MonsterMovement(name, ordinal) {
Enum.call(this, name, ordinal);
}
protoOf(MonsterMovement).v3w = function () {
return get_entries();
};
function _get_walkingAnimation__thpu5c($this) {
var tmp = $this.c5b_1;
if (!(tmp == null))
return tmp;
else {
throwUninitializedPropertyAccessException('walkingAnimation');
}
}
function _get_idleAnimation__wievgh($this) {
var tmp = $this.d5b_1;
if (!(tmp == null))
return tmp;
else {
throwUninitializedPropertyAccessException('idleAnimation');
}
}
function oppositeDirection($this, direction) {
return (direction + 2 | 0) % 4 | 0;
}
function turnLeft($this, direction) {
return (direction + 1 | 0) % 4 | 0;
}
function attack($this, actor, stickHorizontal, stickVertical) {
var tmp0_elvis_lhs = Companion_instance_2.s17().w58_1;
var tmp;
if (tmp0_elvis_lhs == null) {
return Unit_instance;
} else {
tmp = tmp0_elvis_lhs;
}
var player = tmp;
var deltaX = player.s59_1 - $this.s59_1 | 0;
var deltaY = player.t59_1 - $this.t59_1 | 0;
var newDirection;
if (deltaY === 0) {
newDirection = deltaX > 0 ? 0 : 2;
if (stickHorizontal) {
$this.b5b_1 = !(isWall($this.q5a(0, -1)) && isWall($this.q5a(0, 1)));
}
} else if (deltaX === 0) {
newDirection = deltaY > 0 ? 1 : 3;
if (stickVertical) {
$this.b5b_1 = !(isWall($this.q5a(-1, 0)) && isWall($this.q5a(1, 0)));
}
} else {
newDirection = turnLeft($this, $this.y5a_1);
if (attack$headingAway($this, deltaX, deltaY, newDirection)) {
newDirection = oppositeDirection($this, newDirection);
}
if (!canMove($this, newDirection)) {
newDirection = oppositeDirection($this, newDirection);
if (!canMove($this, newDirection)) {
if (canMove($this, $this.y5a_1)) {
newDirection = $this.y5a_1;
} else {
if ($this.b5b_1) {
newDirection = oppositeDirection($this, $this.y5a_1);
}
}
}
}
}
if (canMove($this, newDirection)) {
$this.y5a_1 = newDirection;
move($this, actor, $this.y5a_1);
$this.b5b_1 = true;
}
}
function attack$default($this, actor, stickHorizontal, stickVertical, $super) {
stickHorizontal = stickHorizontal === VOID ? true : stickHorizontal;
stickVertical = stickVertical === VOID ? false : stickVertical;
return attack($this, actor, stickHorizontal, stickVertical);
}
function directionToDeltaXY($this, direction) {
switch (direction) {
case 0:
return new Pair(1, 0);
case 2:
return new Pair(-1, 0);
case 3:
return new Pair(0, -1);
default:
return new Pair(0, 1);
}
}
function canMove($this, direction) {
var _destruct__k2r9zo = directionToDeltaXY($this, direction);
var dx = _destruct__k2r9zo.lc();
var dy = _destruct__k2r9zo.mc();
var look = $this.q5a(dx, dy);
var tmp;
if (Companion_instance_1.s17().m59_1) {
var tmp_0;
if (isEmpty(look)) {
var tmp_1 = look == null ? null : look.p3u();
tmp_0 = !(tmp_1 instanceof Player);
} else {
tmp_0 = false;
}
tmp = tmp_0;
} else {
tmp = isEmpty(look);
}
return tmp;
}
function move($this, actor, direction) {
var _destruct__k2r9zo = directionToDeltaXY($this, direction);
var dx = _destruct__k2r9zo.lc();
var dy = _destruct__k2r9zo.mc();
var hit = $this.q5a(dx, dy);
if ($this.r5a(actor, dx, dy)) {
$this.x5a_1 = false;
_get_walkingAnimation__thpu5c($this).f48(actor);
var tmp = hit == null ? null : hit.p3u();
var tmp1_safe_receiver = (!(tmp == null) ? isInterface(tmp, Killable) : false) ? tmp : null;
if (tmp1_safe_receiver == null)
null;
else {
tmp1_safe_receiver.e5b(actor, hit);
}
}
}
function attack$headingAway(this$0, deltaX, deltaY, direction) {
var _destruct__k2r9zo = directionToDeltaXY(this$0, direction);
var dx = _destruct__k2r9zo.lc();
var dy = _destruct__k2r9zo.mc();
if (imul(dx, deltaX) > 0)
return false;
if (imul(dy, deltaY) > 0)
return false;
return true;
}
function Monster$onEnteredStage$lambda($a, $b) {
return function ($this$flipBook) {
page($this$flipBook, $a, 0.2);
page($this$flipBook, $b, 0.2);
return Unit_instance;
};
}
function Monster$onEnteredStage$lambda$lambda(this$0, $actor) {
return function (it) {
this$0.x5a_1 = true;
_get_idleAnimation__wievgh(this$0).f48($actor);
return Unit_instance;
};
}
function Monster$onEnteredStage$lambda_0($a, $b, this$0, $actor) {
return function ($this$flipBook) {
var pageCount = 2;
$this$flipBook.v4a_1 = 1;
page($this$flipBook, $a, 0.15 / $this$flipBook.v4a_1 / pageCount);
page($this$flipBook, $b, 0.15 / $this$flipBook.v4a_1 / pageCount);
$this$flipBook.y4a(Monster$onEnteredStage$lambda$lambda(this$0, $actor));
return Unit_instance;
};
}
function Monster() {
Item.call(this);
this.x5a_1 = true;
this.y5a_1 = 1;
this.z5a_1 = property(MonsterMovement_ATTACK_STICK_HORIZONTAL_getInstance());
this.a5b_1 = this.f5b();
this.b5b_1 = true;
}
protoOf(Monster).f5b = function () {
return this.z5a_1.ik(this, movementTypeProperty$factory());
};
protoOf(Monster).g5b = function (_set____db54di) {
return this.a5b_1.cm(this, movementType$factory(), _set____db54di);
};
protoOf(Monster).h5b = function () {
return this.a5b_1.ik(this, movementType$factory_0());
};
protoOf(Monster).e3w = function () {
return listOf(this.f5b());
};
protoOf(Monster).b3w = function (actor) {
protoOf(Item).b3w.call(this, actor);
if (!Companion_instance_1.s17().n59_1) {
if (this.h5b().equals(MonsterMovement_ATTACK_STICK_HORIZONTAL_getInstance()) || this.h5b().equals(MonsterMovement_ATTACK_STICK_VERTICAL_getInstance()) || this.h5b().equals(MonsterMovement_ATTACK_STICK_BOTH_getInstance())) {
this.g5b(MonsterMovement_ATTACK_STICK_NONE_getInstance());
}
}
var tmp0_elvis_lhs = actor.r3u();
var tmp;
if (tmp0_elvis_lhs == null) {
return Unit_instance;
} else {
tmp = tmp0_elvis_lhs;
}
var role = tmp;
var tmp_0 = role.w3s('a');
var a = (!(tmp_0 == null) ? isInterface(tmp_0, AppearanceResource) : false) ? tmp_0 : THROW_CCE();
var tmp_1 = role.w3s('b');
var b = (!(tmp_1 == null) ? isInterface(tmp_1, AppearanceResource) : false) ? tmp_1 : THROW_CCE();
var tmp_2 = this;
tmp_2.d5b_1 = flipBook(Monster$onEnteredStage$lambda(a, b));
var tmp_3 = this;
tmp_3.c5b_1 = flipBook(Monster$onEnteredStage$lambda_0(a, b, this, actor));
_get_idleAnimation__wievgh(this).f48(actor);
};
protoOf(Monster).f3w = function (actor, seconds) {
var tmp = actor.n3u();
var tmp0_safe_receiver = isInterface(tmp, Ticks) ? tmp : null;
if (tmp0_safe_receiver == null)
null;
else {
tmp0_safe_receiver.f3w(actor, seconds);
}
if (this.x5a_1) {
switch (this.h5b().c2_1) {
case 0:
attack$default(this, actor);
break;
case 1:
attack(this, actor, false, true);
break;
case 2:
attack(this, actor, true, true);
break;
case 3:
attack(this, actor, false, false);
break;
default:
noWhenBranchMatchedException();
break;
}
}
};
protoOf(Monster).e5b = function (killer, victim) {
};
function MonsterMovement_ATTACK_STICK_HORIZONTAL_getInstance() {
MonsterMovement_initEntries();
return MonsterMovement_ATTACK_STICK_HORIZONTAL_instance;
}
function MonsterMovement_ATTACK_STICK_VERTICAL_getInstance() {
MonsterMovement_initEntries();
return MonsterMovement_ATTACK_STICK_VERTICAL_instance;
}
function MonsterMovement_ATTACK_STICK_BOTH_getInstance() {
MonsterMovement_initEntries();
return MonsterMovement_ATTACK_STICK_BOTH_instance;
}
function MonsterMovement_ATTACK_STICK_NONE_getInstance() {
MonsterMovement_initEntries();
return MonsterMovement_ATTACK_STICK_NONE_instance;
}
function movementTypeProperty$factory() {
return getPropertyCallableRef('movementTypeProperty', 1, KProperty1, function (receiver) {
return receiver.f5b();
}, null);
}
function movementType$factory() {
return getPropertyCallableRef('movementType', 1, KMutableProperty1, function (receiver) {
return receiver.h5b();
}, function (receiver, value) {
return receiver.g5b(value);
});
}
function movementType$factory_0() {
return getPropertyCallableRef('movementType', 1, KMutableProperty1, function (receiver) {
return receiver.h5b();
}, function (receiver, value) {
return receiver.g5b(value);
});
}
function unstickMonsters($this) {
var tmp0_safe_receiver = Companion_instance_0.s17().z41();
var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.q3r_1;
var tmp;
if (tmp1_safe_receiver == null) {
tmp = null;
} else {
var tmp$ret$1;
$l$block: {
// Inline function 'kotlin.collections.firstOrNull' call
var _iterator__ex2g4s = tmp1_safe_receiver.g();
while (_iterator__ex2g4s.h()) {
var element = _iterator__ex2g4s.i();
// Inline function 'PlayDirector.unstickMonsters.<anonymous>' call
if (element.c3s_1 === 'main') {
tmp$ret$1 = element;
break $l$block;
}
}
tmp$ret$1 = null;
}
tmp = tmp$ret$1;
}
var tmp2_elvis_lhs = tmp;
var tmp_0;
if (tmp2_elvis_lhs == null) {
return Unit_instance;
} else {
tmp_0 = tmp2_elvis_lhs;
}
var mainStage = tmp_0;
var _iterator__ex2g4s_0 = mainStage.f3s().g();
while (_iterator__ex2g4s_0.h()) {
var actor = _iterator__ex2g4s_0.i();
var tmp_1 = actor.p3u();
var tmp3_safe_receiver = tmp_1 instanceof Monster ? tmp_1 : null;
if (tmp3_safe_receiver == null)
null;
else {
tmp3_safe_receiver.b5b_1 = true;
}
}
}
function Companion_0() {
}
protoOf(Companion_0).s17 = function () {
var tmp = this.o58_1;
if (!(tmp == null))
return tmp;
else {
throwUninitializedPropertyAccessException('instance');
}
};
var Companion_instance_2;
function Companion_getInstance_2() {
return Companion_instance_2;
}
function PlayDirector() {
this.p58_1 = intProperty(99);
this.q58_1 = this.m58();
this.r58_1 = booleanProperty(false);
this.s58_1 = this.i5b();
this.t58_1 = 36.0 * 4;
this.u58_1 = 36.0 * 3;
this.v58_1 = new Grid(36.0);
this.w58_1 = null;
this.x58_1 = null;
this.y58_1 = booleanProperty(false);
this.z58_1 = this.l5a();
var tmp = this;
// Inline function 'kotlin.collections.mutableListOf' call
tmp.a59_1 = ArrayList_init_$Create$();
Companion_instance_2.o58_1 = this;
}
protoOf(PlayDirector).m58 = function () {
return this.p58_1.ik(this, blastsProperty$factory_0());
};
protoOf(PlayDirector).n58 = function (_set____db54di) {
return this.q58_1.cm(this, blasts$factory_1(), _set____db54di);
};
protoOf(PlayDirector).l58 = function () {
return this.q58_1.ik(this, blasts$factory_2());
};
protoOf(PlayDirector).i5b = function () {
return this.r58_1.ik(this, unstickMonstersProperty$factory());
};
protoOf(PlayDirector).j5b = function (_set____db54di) {
return this.s58_1.cm(this, unstickMonsters$factory(), _set____db54di);
};
protoOf(PlayDirector).k5b = function () {
return this.s58_1.ik(this, unstickMonsters$factory_0());
};
protoOf(PlayDirector).l5a = function () {
return this.y58_1.ik(this, fueledProperty$factory_0());
};
protoOf(PlayDirector).m5a = function (_set____db54di) {
return this.z58_1.cm(this, fueled$factory_1(), _set____db54di);
};
protoOf(PlayDirector).k5a = function () {
return this.z58_1.ik(this, fueled$factory_2());
};
protoOf(PlayDirector).e3w = function () {
return listOf_0([this.m58(), this.i5b()]);
};
protoOf(PlayDirector).l5b = function (actor, player) {
this.x58_1 = actor;
this.w58_1 = player;
player.m58().km(this.m58());
};
protoOf(PlayDirector).b59 = function (blastsCounter) {
blastsCounter.m58().km(this.m58());
};
protoOf(PlayDirector).n5a = function (fuelStatus) {
fuelStatus.l5a().km(this.l5a());
};
protoOf(PlayDirector).u5b = function (point) {
this.a59_1.e(point);
};
protoOf(PlayDirector).e5a = function (amount) {
var tmp0 = Companion_instance_1.s17().l59_1;
// Inline function 'kotlin.math.min' call
var b = this.l58() + imul(amount, Companion_instance_1.s17().k59_1) | 0;
var tmp$ret$0 = Math.min(tmp0, b);
this.n58(tmp$ret$0);
};
protoOf(PlayDirector).h5a = function () {
this.m5a(true);
if (this.k5b()) {
unstickMonsters(this);
}
};
protoOf(PlayDirector).v5b = function (shipActor) {
unstickMonsters(this);
};
protoOf(PlayDirector).w5b = function () {
unstickMonsters(this);
};
protoOf(PlayDirector).x5b = function () {
if (this.a59_1.l())
return Unit_instance;
var tmp0_safe_receiver = Companion_instance_0.s17().z41();
var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.q3r_1;
var tmp;
if (tmp1_safe_receiver == null) {
tmp = null;
} else {
var tmp$ret$1;
$l$block: {
// Inline function 'kotlin.collections.firstOrNull' call
var _iterator__ex2g4s = tmp1_safe_receiver.g();
while (_iterator__ex2g4s.h()) {
var element = _iterator__ex2g4s.i();
// Inline function 'PlayDirector.spawnNewMonster.<anonymous>' call
if (element.c3s_1 === 'main') {
tmp$ret$1 = element;
break $l$block;
}
}
tmp$ret$1 = null;
}
tmp = tmp$ret$1;
}
var tmp2_elvis_lhs = tmp;
var tmp_0;
if (tmp2_elvis_lhs == null) {
return Unit_instance;
} else {
tmp_0 = tmp2_elvis_lhs;
}
var mainStage = tmp_0;
var inductionVariable = 0;
if (inductionVariable < 10)
do {
var attempt = inductionVariable;
inductionVariable = inductionVariable + 1 | 0;
var index = Default_getInstance().pd(this.a59_1.j());
var point = this.a59_1.k(index);
if (this.v58_1.o5a(point) == null) {
var tmp_1 = Companion_instance_0.s17().s41_1.w3s('/roles/monster');
var monster = tmp_1 instanceof Role ? tmp_1 : null;
if (monster == null) {
println('Monster Role not found. Not spawning');
return Unit_instance;
}
// Inline function 'kotlin.apply' call
var this_0 = new Actor(mainStage);
// Inline function 'PlayDirector.spawnNewMonster.<anonymous>' call
this_0.o3u(new Monster());
this_0.q3u(monster);
this_0.s3u(point);
var newActor = this_0;
mainStage.x3v(newActor);
return Unit_instance;
}
}
while (inductionVariable < 10);
};
protoOf(PlayDirector).t3w = function (keyEvent) {
switch (keyEvent.wy_1.c2_1) {
case 73:
Companion_instance.s17().q46();
break;
case 50:
Companion_instance.s17().z45('/menu');
break;
case 67:
if (keyEvent.q2k()) {
createScreenshot('screenshot.png');
createThumbnail('thumbnail.png');
}
break;
default:
break;
}
};
protoOf(PlayDirector).s3w = function (seconds) {
var actView = Companion_instance_0.s17();
var tmp0_safe_receiver = this.x58_1;
if (tmp0_safe_receiver == null)
null;
else {
// Inline function 'kotlin.let' call
// Inline function 'PlayDirector.postTick.<anonymous>' call
var scenePosition = tmp0_safe_receiver.t3u().p3g(actView.k4k());
var tmp;
if (scenePosition.x3s_1 < actView.i2d() + this.t58_1) {
tmp = actView.g4k().x3s_1 - 36.0;
} else if (scenePosition.x3s_1 + this.t58_1 > actView.i2d() + actView.e1j()) {
tmp = actView.g4k().x3s_1 + 36.0;
} else {
tmp = actView.g4k().x3s_1;
}
var reqX = tmp;
var tmp_0;
if (this.k5a()) {
tmp_0 = tmp0_safe_receiver.t3u().y3s_1;
} else {
var tmp_1;
if (scenePosition.y3s_1 < actView.k2d() + this.u58_1) {
tmp_1 = actView.g4k().y3s_1 + 36.0;
} else if (scenePosition.y3s_1 + this.u58_1 > actView.k2d() + actView.f1j()) {
tmp_1 = actView.g4k().y3s_1 - 36.0;
} else {
tmp_1 = actView.g4k().y3s_1;
}
tmp_0 = tmp_1;
}
var reqY = tmp_0;
if (this.k5a()) {
var speed = new Vector2(0.1, 0.02);
actView.r4j(actView.g4k().e55((new Vector2(reqX, reqY)).c56(speed)).d56(Companion_getInstance_0().a3t_1.e55(speed)));
} else {
actView.r4j(new Vector2(reqX, reqY));
}
}
};
function blastsProperty$factory_0() {
return getPropertyCallableRef('blastsProperty', 1, KProperty1, function (receiver) {
return receiver.m58();
}, null);
}
function blasts$factory_1() {
return getPropertyCallableRef('blasts', 1, KMutableProperty1, function (receiver) {
return receiver.l58();
}, function (receiver, value) {
return receiver.n58(value);
});
}
function blasts$factory_2() {
return getPropertyCallableRef('blasts', 1, KMutableProperty1, function (receiver) {
return receiver.l58();
}, function (receiver, value) {
return receiver.n58(value);
});
}
function unstickMonstersProperty$factory() {
return getPropertyCallableRef('unstickMonstersProperty', 1, KProperty1, function (receiver) {
return receiver.i5b();
}, null);
}
function unstickMonsters$factory() {
return getPropertyCallableRef('unstickMonsters', 1, KMutableProperty1, function (receiver) {
return receiver.k5b();
}, function (receiver, value) {
return receiver.j5b(value);
});
}
function unstickMonsters$factory_0() {
return getPropertyCallableRef('unstickMonsters', 1, KMutableProperty1, function (receiver) {
return receiver.k5b();
}, function (receiver, value) {
return receiver.j5b(value);
});
}
function fueledProperty$factory_0() {
return getPropertyCallableRef('fueledProperty', 1, KProperty1, function (receiver) {
return receiver.l5a();
}, null);
}
function fueled$factory_1() {
return getPropertyCallableRef('fueled', 1, KMutableProperty1, function (receiver) {
return receiver.k5a();
}, function (receiver, value) {
return receiver.m5a(value);
});
}
function fueled$factory_2() {
return getPropertyCallableRef('fueled', 1, KMutableProperty1, function (receiver) {
return receiver.k5a();
}, function (receiver, value) {
return receiver.m5a(value);
});
}
function _get_idleAnimation__wievgh_0($this) {
var tmp = $this.r5b_1;
if (!(tmp == null))
return tmp;
else {
throwUninitializedPropertyAccessException('idleAnimation');
}
}
function _get_walkingAnimation__thpu5c_0($this) {
var tmp = $this.s5b_1;
if (!(tmp == null))
return tmp;
else {
throwUninitializedPropertyAccessException('walkingAnimation');
}
}
function _get_blastingAnimation__q7n8dl($this) {
var tmp = $this.t5b_1;
if (!(tmp == null))
return tmp;
else {
throwUninitializedPropertyAccessException('blastingAnimation');
}
}
function tryBlast($this, actor, dx, dy) {
if ($this.l58() > 0) {
var otherActor = $this.q5a(dx, dy);
if (isSoil(otherActor)) {
var tmp = otherActor == null ? null : otherActor.p3u();
var tmp1_safe_receiver = tmp instanceof Soil ? tmp : null;
if (tmp1_safe_receiver == null)
null;
else {
// Inline function 'kotlin.let' call
tmp1_safe_receiver.b5c(otherActor);
var _unary__edvuaz = $this.l58();
$this.n58(_unary__edvuaz - 1 | 0);
$this.q5b_1 = false;
_get_blastingAnimation__q7n8dl($this).f48(actor);
return true;
}
}
}
return false;
}
function walking($this, actor) {
$this.q5b_1 = false;
_get_walkingAnimation__thpu5c_0($this).f48(actor);
}
function Player$onEnteredStage$lambda($a, $b) {
return function ($this$flipBook) {
page($this$flipBook, $a, 0.3);
page($this$flipBook, $b, 0.3);
return Unit_instance;
};
}
function Player$onEnteredStage$lambda$lambda(this$0, $actor) {
return function (it) {
this$0.q5b_1 = true;
_get_idleAnimation__wievgh_0(this$0).f48($actor);
return Unit_instance;
};
}
function Player$onEnteredStage$lambda_0($a, this$0, $actor) {
return function ($this$flipBook) {
$this$flipBook.v4a_1 = 1;
page($this$flipBook, $a, 0.15);
$this$flipBook.y4a(Player$onEnteredStage$lambda$lambda(this$0, $actor));
return Unit_instance;
};
}
function Player$onEnteredStage$lambda$lambda_0(this$0, $actor) {
return function (it) {
this$0.q5b_1 = true;
_get_idleAnimation__wievgh_0(this$0).f48($actor);
return Unit_instance;
};
}
function Player$onEnteredStage$lambda_1($a, $b, this$0, $actor) {
return function ($this$flipBook) {
$this$flipBook.v4a_1 = 3;
var pageCount = 2;
page($this$flipBook, $a, 0.2 / $this$flipBook.v4a_1 / pageCount);
page($this$flipBook, $b, 0.2 / $this$flipBook.v4a_1 / pageCount);
$this$flipBook.y4a(Player$onEnteredStage$lambda$lambda_0(this$0, $actor));
return Unit_instance;
};
}
function Player() {
Item.call(this);
this.o5b_1 = intProperty(0);
this.p5b_1 = this.m58();
this.q5b_1 = true;
}
protoOf(Player).m58 = function () {
return this.o5b_1.ik(this, blastsProperty$factory_1());
};
protoOf(Player).n58 = function (_set____db54di) {
return this.p5b_1.cm(this, blasts$factory_3(), _set____db54di);
};
protoOf(Player).l58 = function () {
return this.p5b_1.ik(this, blasts$factory_4());
};
protoOf(Player).b5a = function () {
return true;
};
protoOf(Player).b3w = function (actor) {
protoOf(Item).b3w.call(this, actor);
Companion_instance_2.s17().l5b(actor, this);
var tmp0_elvis_lhs = actor.r3u();
var tmp;
if (tmp0_elvis_lhs == null) {
return Unit_instance;
} else {
tmp = tmp0_elvis_lhs;
}
var role = tmp;
var a = role.q47('a');
var b = role.q47('b');
var tmp_0 = this;
tmp_0.r5b_1 = flipBook(Player$onEnteredStage$lambda(a, b));
var tmp_1 = this;
tmp_1.s5b_1 = flipBook(Player$onEnteredStage$lambda_0(a, this, actor));
var tmp_2 = this;
tmp_2.t5b_1 = flipBook(Player$onEnteredStage$lambda_1(a, b, this, actor));
_get_idleAnimation__wievgh_0(this).f48(actor);
};
protoOf(Player).f3w = function (actor, seconds) {
var tmp = actor.n3u();
var tmp0_safe_receiver = isInterface(tmp, Ticks) ? tmp : null;
if (tmp0_safe_receiver == null)
null;
else {
tmp0_safe_receiver.f3w(actor, seconds);
}
if (this.q5b_1) {
var view = Companion_instance_0.s17();
var dx = 0;
var dy = 0;
if (view.q4v(Key_LEFT_getInstance())) {
dx = -1;
} else if (view.q4v(Key_RIGHT_getInstance())) {
dx = 1;
} else if (view.q4v(Key_UP_getInstance())) {
dy = 1;
} else if (view.q4v(Key_DOWN_getInstance())) {
dy = -1;
}
if (!(dx === 0) || !(dy === 0)) {
var otherActor = this.q5a(dx, dy);
var tmp_0 = otherActor == null ? null : otherActor.p3u();
var tmp2_safe_receiver = tmp_0 instanceof Collectable ? tmp_0 : null;
if (tmp2_safe_receiver == null)
null;
else {
tmp2_safe_receiver.r59(otherActor);
}
var tmp_1 = otherActor == null ? null : otherActor.p3u();
var tmp4_safe_receiver = tmp_1 instanceof Ship ? tmp_1 : null;
if (tmp4_safe_receiver == null)
null;
else {
// Inline function 'kotlin.let' call
// Inline function 'Player.tick.<anonymous>' call
if (Companion_instance_2.s17().k5a()) {
tmp4_safe_receiver.v5b(otherActor);
Companion_instance_2.s17().v5b(otherActor);
actor.b3t_1.d3v(actor);
return Unit_instance;
}
}
if (this.r5a(actor, dx, dy)) {
walking(this, actor);
} else {
tryBlast(this, actor, dx, dy);
}
}
}
};
protoOf(Player).e5b = function (killer, victim) {
victim.b3t_1.d3v(victim);
Companion_instance_2.s17().w5b();
};
function blastsProperty$factory_1() {
return getPropertyCallableRef('blastsProperty', 1, KProperty1, function (receiver) {
return receiver.m58();
}, null);
}
function blasts$factory_3() {
return getPropertyCallableRef('blasts', 1, KMutableProperty1, function (receiver) {
return receiver.l58();
}, function (receiver, value) {
return receiver.n58(value);
});
}
function blasts$factory_4() {
return getPropertyCallableRef('blasts', 1, KMutableProperty1, function (receiver) {
return receiver.l58();
}, function (receiver, value) {
return receiver.n58(value);
});
}
function Killable() {
}
function Rock$soilRemoved$lambda$lambda(this$0) {
return function (it) {
this$0.g5c_1 = null;
return Unit_instance;
};
}
function Rock$soilRemoved$lambda(this$0) {
return function ($this$flipBookAnimation) {
$this$flipBookAnimation.v4a_1 = 1;
page($this$flipBookAnimation, null, 0.51);
$this$flipBookAnimation.y4a(Rock$soilRemoved$lambda$lambda(this$0));
return Unit_instance;
};
}
function Rock() {
Item.call(this);
this.g5c_1 = null;
}
protoOf(Rock).f3w = function (actor, seconds) {
// Inline function 'kotlin.let' call
// Inline function 'Rock.tick.<anonymous>' call
var delay = this.g5c_1;
if (delay == null) {
var belowActor = this.q5a(0, -1);
var belowBehaviour = belowActor == null ? null : belowActor.p3u();
if (belowBehaviour instanceof Monster) {
belowActor.o3u(new Soil());
var tmp = Companion_instance_0.s17().s41_1.w3s('/graphics/soil');
((!(tmp == null) ? isInterface(tmp, AppearanceResource) : false) ? tmp : THROW_CCE()).f48(belowActor);
Companion_instance_2.s17().x5b();
} else {
if (isEmpty(belowActor)) {
this.r5a(actor, 0, -1);
var tmp_0 = belowActor == null ? null : belowActor.p3u();
var tmp2_safe_receiver = (!(tmp_0 == null) ? isInterface(tmp_0, Killable) : false) ? tmp_0 : null;
if (tmp2_safe_receiver == null)
null;
else {
tmp2_safe_receiver.e5b(actor, belowActor);
}
}
}
} else {
delay.f3w(actor, seconds);
}
};
protoOf(Rock).h5c = function () {
var tmp = this;
tmp.g5c_1 = flipBookAnimation(Rock$soilRemoved$lambda(this));
};
function Ship$blastOff$lambda$lambda$lambda($speed) {
return function (actor, seconds) {
actor.s3u(actor.t3u().e55(new Vector2(0.0, $speed._v * seconds)));
$speed._v = $speed._v + 3.0;
return Unit_instance;
};
}
function Ship$blastOff$lambda$lambda($speed) {
return function ($this$page) {
$this$page.l4b(Ship$blastOff$lambda$lambda$lambda($speed));
return Unit_instance;
};
}
function Ship$blastOff$lambda$lambda_0(it) {
println('Congratulations');
Companion_instance.s17().z45('/menu');
return Unit_instance;
}
function Ship$blastOff$lambda($speed) {
return function ($this$flipBook) {
$this$flipBook.v4a_1 = 1;
page($this$flipBook, null, 6.0, Ship$blastOff$lambda$lambda($speed));
$this$flipBook.y4a(Ship$blastOff$lambda$lambda_0);
return Unit_instance;
};
}
function Ship() {
Item.call(this);
}
protoOf(Ship).b3w = function (actor) {
protoOf(Item).b3w.call(this, actor);
var grid = Companion_instance_2.s17().v58_1;
grid.k(this.s59_1 - 1 | 0).z59(this.t59_1 - 1 | 0, actor);
grid.k(this.s59_1 + 1 | 0).z59(this.t59_1 - 1 | 0, actor);
};
protoOf(Ship).f3w = function (actor, seconds) {
var tmp = actor.n3u();
var tmp0_safe_receiver = isInterface(tmp, Ticks) ? tmp : null;
if (tmp0_safe_receiver == null)
null;
else {
tmp0_safe_receiver.f3w(actor, seconds);
}
};
protoOf(Ship).v5b = function (myActor) {
var speed = {_v: 10.0};
flipBook(Ship$blastOff$lambda(speed)).f48(myActor);
};
function Soil$blast$lambda$lambda(this$0, $actor) {
return function (it) {
var actorAbove = this$0.q5a(0, 1);
var tmp = actorAbove == null ? null : actorAbove.p3u();
var tmp1_safe_receiver = tmp instanceof Rock ? tmp : null;
if (tmp1_safe_receiver == null)
null;
else {
tmp1_safe_receiver.h5c();
}
$actor.b3t_1.d3v($actor);
Companion_instance_2.s17().v58_1.k(this$0.s59_1).z59(this$0.t59_1, null);
return Unit_instance;
};
}
function Soil$blast$lambda($a, $b, this$0, $actor) {
return function ($this$flipBookAnimation) {
$this$flipBookAnimation.v4a_1 = 3;
var pageCount = 2;
page($this$flipBookAnimation, $a, 0.2 / $this$flipBookAnimation.v4a_1 / pageCount);
page($this$flipBookAnimation, $b, 0.2 / $this$flipBookAnimation.v4a_1 / pageCount);
$this$flipBookAnimation.y4a(Soil$blast$lambda$lambda(this$0, $actor));
return Unit_instance;
};
}
function Soil() {
Item.call(this);
this.a5c_1 = true;
}
protoOf(Soil).a5a = function () {
return this.a5c_1;
};
protoOf(Soil).f3w = function (actor, seconds) {
var tmp = actor.n3u();
var tmp0_safe_receiver = isInterface(tmp, Ticks) ? tmp : null;
if (tmp0_safe_receiver == null)
null;
else {
tmp0_safe_receiver.f3w(actor, seconds);
}
};
protoOf(Soil).b5c = function (actor) {
this.a5c_1 = false;
var tmp0_elvis_lhs = actor.r3u();
var tmp;
if (tmp0_elvis_lhs == null) {
return Unit_instance;
} else {
tmp = tmp0_elvis_lhs;
}
var role = tmp;
var a = actor.n3u();
var tmp_0 = role.w3s('/graphics/empty');
var b = (!(tmp_0 == null) ? isInterface(tmp_0, WithAppearance) : false) ? tmp_0 : THROW_CCE();
actor.m3u(flipBookAnimation_0(actor, Soil$blast$lambda(a, b, this, actor)));
};
function SpawnPoint() {
}
protoOf(SpawnPoint).b3w = function (actor) {
Companion_instance_2.s17().u5b(actor.t3u());
actor.b3t_1.d3v(actor);
};
function Main() {
Application.call(this);
}
protoOf(Main).p18 = function (primaryStage) {
var base = toString(window.location);
if (endsWith(base, '/index.html')) {
var tmp0 = base;
// Inline function 'kotlin.text.substring' call
var endIndex = base.length - 11 | 0;
// Inline function 'kotlin.js.asDynamic' call
base = tmp0.substring(0, endIndex);
} else if (endsWith(base, '/')) {
var tmp3 = base;
// Inline function 'kotlin.text.substring' call
var endIndex_0 = base.length - 1 | 0;
// Inline function 'kotlin.js.asDynamic' call
base = tmp3.substring(0, endIndex_0);
}
var kydPath = base + '/cavernQuest2.kyd';
println("Kyd file '" + kydPath + "'");
registerTypes();
Launcher_instance.b46(primaryStage, kydPath);
};
function main() {
var tmp = window;
tmp.onload = main$lambda;
}
function main$lambda(it) {
launchInContainer(getKClass(Main), 'glokContainer');
return Unit_instance;
}
function mainWrapper() {
main();
}
function registerTypes() {
// Inline function 'kotlin.with' call
// Inline function 'registerTypes.<anonymous>' call
var $this$with = KydTypeRegistry_getInstance();
$this$with.x3x('CavernQuest', registerTypes$lambda);
$this$with.y3x('MenuDirector', registerTypes$lambda_0);
$this$with.y3x('PlayDirector', registerTypes$lambda_1);
$this$with.a3y('BlastsCounter', registerTypes$lambda_2);
$this$with.a3y('Dynamite', registerTypes$lambda_3);
$this$with.a3y('Fuel', registerTypes$lambda_4);
$this$with.a3y('FuelStatus', registerTypes$lambda_5);
$this$with.a3y('Granite', registerTypes$lambda_6);
$this$with.a3y('Monster', registerTypes$lambda_7);
$this$with.a3y('Player', registerTypes$lambda_8);
$this$with.a3y('Rock', registerTypes$lambda_9);
$this$with.a3y('Ship', registerTypes$lambda_10);
$this$with.a3y('Soil', registerTypes$lambda_11);
$this$with.a3y('SpawnPoint', registerTypes$lambda_12);
}
function registerTypes$lambda(game) {
return new CavernQuest(game);
}
function registerTypes$lambda_0() {
return new MenuDirector();
}
function registerTypes$lambda_1() {
return new PlayDirector();
}
function registerTypes$lambda_2() {
return new BlastsCounter();
}
function registerTypes$lambda_3() {
return new Dynamite();
}
function registerTypes$lambda_4() {
return new Fuel();
}
function registerTypes$lambda_5() {
return new FuelStatus();
}
function registerTypes$lambda_6() {
return new Granite();
}
function registerTypes$lambda_7() {
return new Monster();
}
function registerTypes$lambda_8() {
return new Player();
}
function registerTypes$lambda_9() {
return new Rock();
}
function registerTypes$lambda_10() {
return new Ship();
}
function registerTypes$lambda_11() {
return new Soil();
}
function registerTypes$lambda_12() {
return new SpawnPoint();
}
//region block: post-declaration
protoOf(BlastsCounter).c3w = onActStarted;
protoOf(BlastsCounter).d3w = onExitedStage;
protoOf(BlastsCounter).e3w = customProperties;
protoOf(BlastsCounter).f3w = tick;
protoOf(Item).c3w = onActStarted;
protoOf(Item).d3w = onExitedStage;
protoOf(Item).e3w = customProperties;
protoOf(Item).f3w = tick;
protoOf(FuelStatus).c3w = onActStarted;
protoOf(FuelStatus).d3w = onExitedStage;
protoOf(FuelStatus).e3w = customProperties;
protoOf(FuelStatus).f3w = tick;
protoOf(MenuDirector).o3w = onActStarting;
protoOf(MenuDirector).q3w = onActEnded;
protoOf(MenuDirector).r3w = preTick;
protoOf(MenuDirector).s3w = postTick;
protoOf(MenuDirector).u3w = onKeyReleased;
protoOf(MenuDirector).e3w = customProperties;
protoOf(PlayDirector).o3w = onActStarting;
protoOf(PlayDirector).p3w = onActStarted_0;
protoOf(PlayDirector).q3w = onActEnded;
protoOf(PlayDirector).r3w = preTick;
protoOf(PlayDirector).u3w = onKeyReleased;
protoOf(SpawnPoint).c3w = onActStarted;
protoOf(SpawnPoint).d3w = onExitedStage;
protoOf(SpawnPoint).e3w = customProperties;
protoOf(SpawnPoint).f3w = tick;
//endregion
//region block: init
Companion_instance_1 = new Companion();
Companion_instance_2 = new Companion_0();
//endregion
mainWrapper();
return _;
}));
//# sourceMappingURL=cavernQuest2.js.map