diff --git a/frontend/assets/scenes/offline_map.fire b/frontend/assets/scenes/offline_map.fire index fd546c5..ed46f5b 100644 --- a/frontend/assets/scenes/offline_map.fire +++ b/frontend/assets/scenes/offline_map.fire @@ -518,7 +518,7 @@ "array": [ 0, 0, - 210.4441731196186, + 213.2214270007204, 0, 0, 0, diff --git a/frontend/assets/scripts/AttackingCharacter.js b/frontend/assets/scripts/AttackingCharacter.js index 68fe127..4f3b7b9 100644 --- a/frontend/assets/scripts/AttackingCharacter.js +++ b/frontend/assets/scripts/AttackingCharacter.js @@ -64,9 +64,6 @@ cc.Class({ ctor() { this.speciesName = null; - this.hp = 100; - this.maxHp = 100; - this.inAir = true; }, setSpecies(speciesName) { @@ -116,7 +113,6 @@ cc.Class({ playingAnimName = (!underlyingAnimationCtrl ? null : underlyingAnimationCtrl.name); //} - // It turns out that "prevRdfPlayer.CharacterState" is not useful in this function :) if (newAnimName == playingAnimName && window.ATK_CHARACTER_STATE_INTERRUPT_WAIVE_SET.has(newCharacterState)) { // No need to interrupt // console.warn(`JoinIndex=${rdfPlayer.joinIndex}, not interrupting ${newAnimName} while the playing anim is also ${playingAnimName}, player rdf changed from: ${null == prevRdfPlayer ? null : JSON.stringify(prevRdfPlayer)}, to: ${JSON.stringify(rdfPlayer)}`); diff --git a/frontend/assets/scripts/CameraTracker.js b/frontend/assets/scripts/CameraTracker.js index 3b37f85..0fa83db 100644 --- a/frontend/assets/scripts/CameraTracker.js +++ b/frontend/assets/scripts/CameraTracker.js @@ -25,7 +25,7 @@ cc.Class({ if (!self.mapScriptIns) return; if (!self.mapScriptIns.selfPlayerInfo) return; if (!self.mapScriptIns.playerRichInfoDict) return; - const selfPlayerRichInfo = self.mapScriptIns.playerRichInfoDict.get(self.mapScriptIns.selfPlayerInfo.Id); + const selfPlayerRichInfo = self.mapScriptIns.playerRichInfoDict.get(self.mapScriptIns.selfPlayerInfo.id); if (!selfPlayerRichInfo) return; const selfPlayerNode = selfPlayerRichInfo.node; if (!selfPlayerNode) return; diff --git a/frontend/assets/scripts/Login.js b/frontend/assets/scripts/Login.js index 4001b8c..9722978 100644 --- a/frontend/assets/scripts/Login.js +++ b/frontend/assets/scripts/Login.js @@ -337,6 +337,7 @@ cc.Class({ const date = Number(res.expiresAt); const selfPlayer = { expiresAt: date, + id: res.playerId, playerId: res.playerId, intAuthToken: res.intAuthToken, avatar: res.avatar, diff --git a/frontend/assets/scripts/Map.js b/frontend/assets/scripts/Map.js index 5c97873..ba35683 100644 --- a/frontend/assets/scripts/Map.js +++ b/frontend/assets/scripts/Map.js @@ -44,7 +44,7 @@ window.onUdpMessage = (args) => { if (req.act && window.UPSYNC_MSG_ACT_PLAYER_CMD == req.act) { let effCnt = 0; const peerJoinIndex = req.joinIndex; - if (peerJoinIndex == self.selfPlayerInfo.JoinIndex) return; + if (peerJoinIndex == self.selfPlayerInfo.joinIndex) return; const batch = req.inputFrameUpsyncBatch; self.onPeerInputFrameUpsync(peerJoinIndex, batch, true); } @@ -156,7 +156,7 @@ cc.Class({ let previousSelfInput = null, currSelfInput = null; - const joinIndex = self.selfPlayerInfo.JoinIndex; + const joinIndex = self.selfPlayerInfo.joinIndex; const selfJoinIndexMask = (1 << (joinIndex - 1)); const existingInputFrame = self.recentInputCache.GetByFrameId(inputFrameId); const previousInputFrameDownsync = self.recentInputCache.GetByFrameId(inputFrameId - 1); @@ -195,11 +195,11 @@ cc.Class({ } currSelfInput = self.ctrl.getEncodedInput(); // When "null == existingInputFrame", it'd be safe to say that the realtime "self.ctrl.getEncodedInput()" is for the requested "inputFrameId" prefabbedInputList[(joinIndex - 1)] = currSelfInput; - while (self.recentInputCache.EdFrameId <= inputFrameId) { + while (self.recentInputCache.GetEdFrameId() <= inputFrameId) { // Fill the gap // [WARNING] Do not blindly use "selfJoinIndexMask" here, as the "actuallyUsedInput for self" couldn't be confirmed while prefabbing, otherwise we'd have confirmed a wrong self input by "_markConfirmationIfApplicable()"! - const prefabbedInputFrameDownsync = gopkgs.NewInputFrameDownsync(self.recentInputCache.EdFrameId, prefabbedInputList.slice(), initConfirmedList); - // console.log(`Prefabbed inputFrameId=${prefabbedInputFrameDownsync.InputFrameId}`); + const prefabbedInputFrameDownsync = gopkgs.NewInputFrameDownsync(self.recentInputCache.GetEdFrameId(), prefabbedInputList.slice(), initConfirmedList); + // console.log(`Prefabbed inputFrameId=${prefabbedInputFrameDownsync.GetInputFrameId()}`); self.recentInputCache.Put(prefabbedInputFrameDownsync); } @@ -223,9 +223,9 @@ cc.Class({ const self = this; let inputFrameUpsyncBatch = []; let batchInputFrameIdSt = self.lastUpsyncInputFrameId + 1; - if (batchInputFrameIdSt < self.recentInputCache.StFrameId) { + if (batchInputFrameIdSt < self.recentInputCache.GetStFrameId()) { // Upon resync, "self.lastUpsyncInputFrameId" might not have been updated properly. - batchInputFrameIdSt = self.recentInputCache.StFrameId; + batchInputFrameIdSt = self.recentInputCache.GetStFrameId(); } self.networkDoctor.logSending(batchInputFrameIdSt, latestLocalInputFrameId); for (let i = batchInputFrameIdSt; i <= latestLocalInputFrameId; ++i) { @@ -235,7 +235,7 @@ cc.Class({ } else { const inputFrameUpsync = { inputFrameId: i, - encoded: inputFrameDownsync.InputList[self.selfPlayerInfo.JoinIndex - 1], + encoded: inputFrameDownsync.InputList[self.selfPlayerInfo.joinIndex - 1], }; inputFrameUpsyncBatch.push(inputFrameUpsync); } @@ -244,19 +244,19 @@ cc.Class({ // console.info(`inputFrameUpsyncBatch: ${JSON.stringify(inputFrameUpsyncBatch)}`); const reqData = window.pb.protos.WsReq.encode({ msgId: Date.now(), - playerId: self.selfPlayerInfo.Id, + playerId: self.selfPlayerInfo.id, act: window.UPSYNC_MSG_ACT_PLAYER_CMD, - joinIndex: self.selfPlayerInfo.JoinIndex, + joinIndex: self.selfPlayerInfo.joinIndex, ackingInputFrameId: self.lastAllConfirmedInputFrameId, inputFrameUpsyncBatch: inputFrameUpsyncBatch, authKey: self.selfPlayerInfo.udpTunnelAuthKey, }).finish(); if (cc.sys.isNative) { - DelayNoMore.UdpSession.broadcastInputFrameUpsync(reqData, window.boundRoomCapacity, self.selfPlayerInfo.JoinIndex); + DelayNoMore.UdpSession.broadcastInputFrameUpsync(reqData, window.boundRoomCapacity, self.selfPlayerInfo.joinIndex); } window.sendSafely(reqData); self.lastUpsyncInputFrameId = latestLocalInputFrameId; - if (self.lastUpsyncInputFrameId >= self.recentInputCache.EdFrameId) { + if (self.lastUpsyncInputFrameId >= self.recentInputCache.GetEdFrameId()) { throw `noDelayInputFrameId=${self.lastUpsyncInputFrameId} == latestLocalInputFrameId=${latestLocalInputFrameId} seems not properly dumped #2: recentInputCache=${self._stringifyRecentInputCache(false)}`; } }, @@ -408,9 +408,9 @@ cc.Class({ for (let k in collisionSpaceObjs) { const body = collisionSpaceObjs[k]; let padding = 0; - if (null != body.Data && null != body.Data.JoinIndex) { + if (null != body.GetData() && null != body.GetData().JoinIndex) { // character - if (1 == body.Data.JoinIndex) { + if (1 == body.GetData().JoinIndex) { g1.strokeColor = cc.Color.BLUE; } else { g1.strokeColor = cc.Color.RED; @@ -420,8 +420,9 @@ cc.Class({ // barrier g1.strokeColor = cc.Color.WHITE; } - const points = body.Shape.Points; - const wpos = [body.X - self.spaceOffsetX, body.Y - self.spaceOffsetY]; + const points = body.GetShape().Points; + const [bodyX, bodyY] = body.Position(); + const wpos = [bodyX - self.spaceOffsetX, bodyY - self.spaceOffsetY]; g1.moveTo(wpos[0], wpos[1]); const cnt = points.length; for (let j = 0; j < cnt; j += 1) { @@ -568,7 +569,6 @@ cc.Class({ const newBarrierCollider = gopkgs.GenerateConvexPolygonColliderJs(gopkgsBoundary, self.spaceOffsetX, self.spaceOffsetY, gopkgsBarrier, "Barrier"); self.gopkgsCollisionSys.Add(newBarrierCollider); - // console.log("Created barrier: ", newBarrierCollider); ++barrierIdCounter; const collisionBarrierIndex = (self.collisionBarrierIndexPrefix + barrierIdCounter); self.gopkgsCollisionSysMap[collisionBarrierIndex] = newBarrierCollider; @@ -672,14 +672,14 @@ cc.Class({ if (ALL_BATTLE_STATES.IN_SETTLEMENT == self.battleState) { return; } - const shouldForceDumping1 = (window.MAGIC_ROOM_DOWNSYNC_FRAME_ID.BATTLE_START == rdf.Id); - let shouldForceDumping2 = (rdf.Id >= self.renderFrameId + self.renderFrameIdLagTolerance); + const shouldForceDumping1 = (window.MAGIC_ROOM_DOWNSYNC_FRAME_ID.BATTLE_START == rdf.GetId()); + let shouldForceDumping2 = (rdf.GetId() >= self.renderFrameId + self.renderFrameIdLagTolerance); let shouldForceResync = pbRdf.shouldForceResync; - const notSelfUnconfirmed = (0 == (pbRdf.backendUnconfirmedMask & (1 << (self.selfPlayerInfo.JoinIndex - 1)))); + const notSelfUnconfirmed = (0 == (pbRdf.backendUnconfirmedMask & (1 << (self.selfPlayerInfo.joinIndex - 1)))); if (notSelfUnconfirmed) { shouldForceDumping2 = false; shouldForceResync = false; - self.othersForcedDownsyncRenderFrameDict.set(rdf.Id, rdf); + self.othersForcedDownsyncRenderFrameDict.set(rdf.GetId(), rdf); } /* TODO @@ -687,7 +687,7 @@ cc.Class({ If "BackendUnconfirmedMask" is non-all-1 and contains the current player, show a label/button to hint manual reconnection. Note that the continuity of "recentInputCache" is not a good indicator, because due to network delay upon a [type#1 forceConfirmation] a player might just lag in upsync networking and have all consecutive inputFrameIds locally. */ - const [dumpRenderCacheRet, oldStRenderFrameId, oldEdRenderFrameId] = (shouldForceDumping1 || shouldForceDumping2 || shouldForceResync) ? self.recentRenderCache.setByFrameId(rdf, rdf.Id) : [window.RING_BUFF_CONSECUTIVE_SET, null, null]; + const [dumpRenderCacheRet, oldStRenderFrameId, oldEdRenderFrameId] = (shouldForceDumping1 || shouldForceDumping2 || shouldForceResync) ? self.recentRenderCache.setByFrameId(rdf, rdf.GetId()) : [window.RING_BUFF_CONSECUTIVE_SET, null, null]; if (window.RING_BUFF_FAILED_TO_SET == dumpRenderCacheRet) { throw `Failed to dump render cache#1 (maybe recentRenderCache too small)! rdf.id=${rdf.id}, lastAllConfirmedInputFrameId=${self.lastAllConfirmedInputFrameId}; recentRenderCache=${self._stringifyRecentRenderCache(false)}, recentInputCache=${self._stringifyRecentInputCache(false)}`; } @@ -704,22 +704,22 @@ cc.Class({ console.error(`pbRdf.speciesIdList is required for starting or resyncing battle!`); } self.chConfigsOrderedByJoinIndex = gopkgs.GetCharacterConfigsOrderedByJoinIndex(pbRdf.speciesIdList); - self._initPlayerRichInfoDict(rdf.PlayersArr); + self._initPlayerRichInfoDict(rdf.GetPlayersArr()); if (shouldForceDumping1 || shouldForceDumping2 || shouldForceResync) { // In fact, not having "window.RING_BUFF_CONSECUTIVE_SET == dumpRenderCacheRet" should already imply that "self.renderFrameId <= rdf.id", but here we double check and log the anomaly - if (window.MAGIC_ROOM_DOWNSYNC_FRAME_ID.BATTLE_START == rdf.Id) { - console.log('On battle started! renderFrameId=', rdf.Id); + if (window.MAGIC_ROOM_DOWNSYNC_FRAME_ID.BATTLE_START == rdf.GetId()) { + console.log('On battle started! renderFrameId=', rdf.GetId()); } else { self.hideFindingPlayersGUI(); - console.warn('On battle resynced! renderFrameId=', rdf.Id); + console.warn('On battle resynced! renderFrameId=', rdf.GetId()); } - self.renderFrameId = rdf.Id; + self.renderFrameId = rdf.GetId(); self.lastRenderFrameIdTriggeredAt = performance.now(); // In this case it must be true that "rdf.id > chaserRenderFrameId". - self.chaserRenderFrameId = rdf.Id; + self.chaserRenderFrameId = rdf.GetId(); self.networkDoctor.logRollbackFrames(0); const canvasNode = self.canvasNode; @@ -727,7 +727,7 @@ cc.Class({ self.enableInputControls(); self.transitToState(ALL_MAP_STATES.VISUAL); - const selfPlayerRichInfo = self.playerRichInfoDict.get(self.selfPlayerInfo.Id); + const selfPlayerRichInfo = self.playerRichInfoDict.get(self.selfPlayerInfo.id); const newMapPos = cc.v2().sub(selfPlayerRichInfo.node.position); self.node.setPosition(newMapPos); self.battleState = ALL_BATTLE_STATES.IN_BATTLE; @@ -771,6 +771,7 @@ cc.Class({ if (lhs.MaxHp != rhs.MaxHp) return false; if (lhs.CharacterState != rhs.CharacterState) return false; if (lhs.InAir != rhs.InAir) return false; + if (lhs.OnWall != rhs.OnWall) return false; if (lhs.FramesToRecover != rhs.FramesToRecover) return false; if (lhs.FramesInChState != rhs.FramesInChState) return false; return true; @@ -794,8 +795,8 @@ cc.Class({ if (lhs.BattleAttr.OffenderJoinIndex != rhs.BattleAttr.OffenderJoinIndex) return false; if (lhs.BattleAttr.OriginatedRenderFrameId != rhs.BattleAttr.OriginatedRenderFrameId) return false; - if (lhs.VirtualGridX != rhs.Bullet.VirtualGridX) return false; - if (lhs.VirtualGridY != rhs.Bullet.VirtualGridY) return false; + if (lhs.VirtualGridX != rhs.VirtualGridX) return false; + if (lhs.VirtualGridY != rhs.VirtualGridY) return false; if (lhs.DirX != rhs.DirX) return false; if (lhs.DirY != rhs.DirY) return false; if (lhs.VelX != rhs.VelX) return false; @@ -807,14 +808,14 @@ cc.Class({ equalRoomDownsyncFrames(lhs, rhs) { if (null == lhs || null == rhs) return false; - for (let k in lhs.PlayersArr) { - if (!this.equalPlayers(lhs.PlayersArr[k], rhs.PlayersArr[k])) return false; + for (let k in lhs.GetPlayersArr()) { + if (!this.equalPlayers(lhs.GetPlayersArr()[k], rhs.GetPlayersArr()[k])) return false; } - for (let k in lhs.MeleeBullets) { - if (!this.equalMeleeBullets(lhs.MeleeBullets[k], rhs.MeleeBullets[k])) return false; + for (let k in lhs.GetMeleeBullets()) { + if (!this.equalMeleeBullets(lhs.GetMeleeBullets()[k], rhs.GetMeleeBullets()[k])) return false; } - for (let k in lhs.fireballBullet) { - if (!this.equalFireballBullets(lhs.FireballBullets[k], rhs.FireballBullets[k])) return false; + for (let k in lhs.GetFireballBullets()) { + if (!this.equalFireballBullets(lhs.GetFireballBullets()[k], rhs.GetFireballBullets()[k])) return false; } return true; }, @@ -822,7 +823,7 @@ cc.Class({ _markConfirmationIfApplicable() { const self = this; let newAllConfirmedCnt = 0; - while (self.recentInputCache.StFrameId <= self.lastAllConfirmedInputFrameId && self.lastAllConfirmedInputFrameId < self.recentInputCache.EdFrameId) { + while (self.recentInputCache.GetStFrameId() <= self.lastAllConfirmedInputFrameId && self.lastAllConfirmedInputFrameId < self.recentInputCache.GetEdFrameId()) { const inputFrameDownsync = self.recentInputCache.GetByFrameId(self.lastAllConfirmedInputFrameId); if (null == inputFrameDownsync) break; if (self._allConfirmed(inputFrameDownsync.ConfirmedList)) break; @@ -1019,7 +1020,7 @@ fromUDP=${fromUDP}`); const newPlayerNode = cc.instantiate(self.controlledCharacterPrefab) const playerScriptIns = newPlayerNode.getComponent("ControlledCharacter"); const chConfig = self.chConfigsOrderedByJoinIndex[joinIndex - 1]; - playerScriptIns.setSpecies(chConfig.SpeciesName); + playerScriptIns.setSpecies(chConfig.GetSpeciesName()); if (1 == joinIndex) { newPlayerNode.color = cc.Color.RED; @@ -1112,15 +1113,15 @@ fromUDP=${fromUDP}`); } */ // [WARNING] Don't try to get "prevRdf(i.e. renderFrameId == latest-1)" by "self.recentRenderCache.getByFrameId(...)" here, as the cache might have been updated by asynchronous "onRoomDownsyncFrame(...)" calls! - if (self.othersForcedDownsyncRenderFrameDict.has(rdf.Id)) { - const delayedInputFrameId = gopkgs.ConvertToDelayedInputFrameId(rdf.Id); - const othersForcedDownsyncRenderFrame = self.othersForcedDownsyncRenderFrameDict.get(rdf.Id); + if (self.othersForcedDownsyncRenderFrameDict.has(rdf.GetId())) { + const delayedInputFrameId = gopkgs.ConvertToDelayedInputFrameId(rdf.GetId()); + const othersForcedDownsyncRenderFrame = self.othersForcedDownsyncRenderFrameDict.get(rdf.GetId()); if (self.lastAllConfirmedInputFrameId >= delayedInputFrameId && !self.equalRoomDownsyncFrames(othersForcedDownsyncRenderFrame, rdf)) { - console.warn(`Mismatched render frame@rdf.id=${rdf.Id} w/ inputFrameId=${delayedInputFrameId}: + console.warn(`Mismatched render frame@rdf.id=${rdf.GetId()} w/ inputFrameId=${delayedInputFrameId}: rdf=${JSON.stringify(rdf)} othersForcedDownsyncRenderFrame=${JSON.stringify(othersForcedDownsyncRenderFrame)}`); rdf = othersForcedDownsyncRenderFrame; - self.othersForcedDownsyncRenderFrameDict.delete(rdf.Id); + self.othersForcedDownsyncRenderFrameDict.delete(rdf.GetId()); } } self.applyRoomDownsyncFrameDynamics(rdf, prevRdf); @@ -1267,11 +1268,11 @@ othersForcedDownsyncRenderFrame=${JSON.stringify(othersForcedDownsyncRenderFrame applyRoomDownsyncFrameDynamics(rdf, prevRdf) { const self = this; - const playersArr = rdf.PlayersArr; + const playersArr = rdf.GetPlayersArr(); for (let k in playersArr) { const currPlayerDownsync = playersArr[k]; const chConfig = self.chConfigsOrderedByJoinIndex[k]; - const prevRdfPlayer = (null == prevRdf ? null : prevRdf.PlayersArr[k]); + const prevRdfPlayer = (null == prevRdf ? null : prevRdf.GetPlayersArr()[k]); const [wx, wy] = gopkgs.VirtualGridToWorldPos(currPlayerDownsync.VirtualGridX, currPlayerDownsync.VirtualGridY); const playerRichInfo = self.playerRichInfoArr[k]; playerRichInfo.node.setPosition(wx, wy); @@ -1286,15 +1287,16 @@ othersForcedDownsyncRenderFrame=${JSON.stringify(othersForcedDownsyncRenderFrame const fireball = pqNode.value; fireball.node.setPosition(cc.v2(Number.MAX_VALUE, Number.MAX_VALUE)); } - for (let k in rdf.MeleeBullets) { - const meleeBullet = rdf.MeleeBullets[k]; + const meleeBullets = rdf.GetMeleeBullets(); + for (let k in meleeBullets) { + const meleeBullet = meleeBullets[k]; const isExploding = (window.BULLET_STATE.Exploding == meleeBullet.BlState && meleeBullet.FramesInBlState < meleeBullet.Bullet.ExplosionFrames); if (isExploding) { let pqNode = self.cachedFireballs.popAny(meleeBullet.BattleAttr.BulletLocalId); let speciesName = `MeleeExplosion`; let animName = `MeleeExplosion${meleeBullet.Bullet.SpeciesId}`; - const offender = rdf.PlayersArr[meleeBullet.BattleAttr.OffenderJoinIndex - 1]; + const offender = playersArr[meleeBullet.BattleAttr.OffenderJoinIndex - 1]; let xfac = 1; // By now, straight Punch offset doesn't respect "y-axis" if (0 > offender.DirX) { xfac = -1; @@ -1303,9 +1305,9 @@ othersForcedDownsyncRenderFrame=${JSON.stringify(othersForcedDownsyncRenderFrame if (null == pqNode) { pqNode = self.cachedFireballs.pop(); - //console.log(`@rdf.Id=${rdf.Id}, origRdfId=${meleeBullet.BattleAttr.OriginatedRenderFrameId}, startupFrames=${meleeBullet.Bullet.StartupFrames}, using a new fireball node for rendering for bulletLocalId=${meleeBullet.BattleAttr.BulletLocalId} at wpos=(${wx},${wy})`); + //console.log(`@rdf.Id=${rdf.GetId()}, origRdfId=${meleeBullet.BattleAttr.OriginatedRenderFrameId}, startupFrames=${meleeBullet.Bullet.StartupFrames}, using a new fireball node for rendering for bulletLocalId=${meleeBullet.BattleAttr.BulletLocalId} at wpos=(${wx},${wy})`); } else { - //console.log(`@rdf.Id=${rdf.Id}, origRdfId=${meleeBullet.BattleAttr.OriginatedRenderFrameId}, startupFrames=${meleeBullet.Bullet.StartupFrames}, using a cached fireball node for rendering for bulletLocalId=${meleeBullet.BattleAttr.BulletLocalId} at wpos=(${wx},${wy})`); + //console.log(`@rdf.Id=${rdf.GetId()}, origRdfId=${meleeBullet.BattleAttr.OriginatedRenderFrameId}, startupFrames=${meleeBullet.Bullet.StartupFrames}, using a cached fireball node for rendering for bulletLocalId=${meleeBullet.BattleAttr.BulletLocalId} at wpos=(${wx},${wy})`); } const cachedFireball = pqNode.value; cachedFireball.setSpecies(speciesName, meleeBullet, rdf); @@ -1317,13 +1319,14 @@ othersForcedDownsyncRenderFrame=${JSON.stringify(othersForcedDownsyncRenderFrame self.cachedFireballs.push(cachedFireball.lastUsed, cachedFireball, meleeBullet.BattleAttr.BulletLocalId); } else { - //console.log(`@rdf.Id=${rdf.Id}, origRdfId=${meleeBullet.BattleAttr.OriginatedRenderFrameId}, startupFrames=${meleeBullet.Bullet.StartupFrames}, activeFrames=${meleeBullet.Bullet.ActiveFrames}, not rendering melee node for bulletLocalId=${meleeBullet.BattleAttr.BulletLocalId}`); + //console.log(`@rdf.Id=${rdf.GetId()}, origRdfId=${meleeBullet.BattleAttr.OriginatedRenderFrameId}, startupFrames=${meleeBullet.Bullet.StartupFrames}, activeFrames=${meleeBullet.Bullet.ActiveFrames}, not rendering melee node for bulletLocalId=${meleeBullet.BattleAttr.BulletLocalId}`); } } - for (let k in rdf.FireballBullets) { - const fireballBullet = rdf.FireballBullets[k]; + const fireballBullets = rdf.GetFireballBullets(); + for (let k in fireballBullets) { + const fireballBullet = fireballBullets[k]; const isExploding = (window.BULLET_STATE.Exploding == fireballBullet.BlState); - if (gopkgs.IsFireballBulletActive(fireballBullet, rdf) || isExploding) { + if (gopkgs.IsGeneralBulletActive(fireballBullet.BlState, fireballBullet.BattleAttr.OriginatedRenderFrameId, fireballBullet.Bullet.StartupFrames, fireballBullet.Bullet.ActiveFrames, rdf.GetId()) || isExploding) { let pqNode = self.cachedFireballs.popAny(fireballBullet.BattleAttr.BulletLocalId); let speciesName = `Fireball${fireballBullet.Bullet.SpeciesId}`; let animName = (BULLET_STATE.Exploding == fireballBullet.BlState ? `Fireball${fireballBullet.Bullet.SpeciesId}Explosion` : speciesName); @@ -1332,9 +1335,9 @@ othersForcedDownsyncRenderFrame=${JSON.stringify(othersForcedDownsyncRenderFrame if (null == pqNode) { pqNode = self.cachedFireballs.pop(); - //console.log(`@rdf.Id=${rdf.Id}, origRdfId=${fireballBullet.BattleAttr.OriginatedRenderFrameId}, startupFrames=${fireballBullet.Bullet.StartupFrames}, using a new fireball node for rendering for bulletLocalId=${fireballBullet.BattleAttr.BulletLocalId} at wpos=(${wx},${wy})`); + //console.log(`@rdf.Id=${rdf.GetId()}, origRdfId=${fireballBullet.BattleAttr.OriginatedRenderFrameId}, startupFrames=${fireballBullet.Bullet.StartupFrames}, using a new fireball node for rendering for bulletLocalId=${fireballBullet.BattleAttr.BulletLocalId} at wpos=(${wx},${wy})`); } else { - //console.log(`@rdf.Id=${rdf.Id}, origRdfId=${fireballBullet.BattleAttr.OriginatedRenderFrameId}, startupFrames=${fireballBullet.Bullet.StartupFrames}, using a cached fireball node for rendering for bulletLocalId=${fireballBullet.BattleAttr.BulletLocalId} at wpos=(${wx},${wy})`); + //console.log(`@rdf.Id=${rdf.GetId()}, origRdfId=${fireballBullet.BattleAttr.OriginatedRenderFrameId}, startupFrames=${fireballBullet.Bullet.StartupFrames}, using a cached fireball node for rendering for bulletLocalId=${fireballBullet.BattleAttr.BulletLocalId} at wpos=(${wx},${wy})`); } const cachedFireball = pqNode.value; cachedFireball.setSpecies(speciesName, fireballBullet, rdf); @@ -1347,7 +1350,7 @@ othersForcedDownsyncRenderFrame=${JSON.stringify(othersForcedDownsyncRenderFrame self.cachedFireballs.push(cachedFireball.lastUsed, cachedFireball, fireballBullet.BattleAttr.BulletLocalId); } else { - //console.log(`@rdf.Id=${rdf.Id}, origRdfId=${fireballBullet.BattleAttr.OriginatedRenderFrameId}, startupFrames=${fireballBullet.Bullet.StartupFrames}, activeFrames=${fireballBullet.Bullet.ActiveFrames}, not rendering fireball node for bulletLocalId=${fireballBullet.BattleAttr.BulletLocalId}`); + //console.log(`@rdf.Id=${rdf.GetId()}, origRdfId=${fireballBullet.BattleAttr.OriginatedRenderFrameId}, startupFrames=${fireballBullet.Bullet.StartupFrames}, activeFrames=${fireballBullet.Bullet.ActiveFrames}, not rendering fireball node for bulletLocalId=${fireballBullet.BattleAttr.BulletLocalId}`); } } @@ -1377,17 +1380,17 @@ othersForcedDownsyncRenderFrame=${JSON.stringify(othersForcedDownsyncRenderFrame inputList: actuallyUsedInputClone, confirmedList: delayedInputFrame.ConfirmedList, }; - self.rdfIdToActuallyUsedInput.set(currRdf.Id, inputFrameDownsyncClone); + self.rdfIdToActuallyUsedInput.set(currRdf.GetId(), inputFrameDownsyncClone); } const nextRdf = gopkgs.ApplyInputFrameDownsyncDynamicsOnSingleRenderFrameJs(self.recentInputCache, currRdf, collisionSys, collisionSysMap, self.spaceOffsetX, self.spaceOffsetY, self.chConfigsOrderedByJoinIndex); if (true == isChasing) { // [WARNING] Move the cursor "self.chaserRenderFrameId" when "true == isChasing", keep in mind that "self.chaserRenderFrameId" is not monotonic! - self.chaserRenderFrameId = nextRdf.Id; - } else if (nextRdf.Id == self.chaserRenderFrameId + 1) { - self.chaserRenderFrameId = nextRdf.Id; // To avoid redundant calculation + self.chaserRenderFrameId = nextRdf.GetId(); + } else if (nextRdf.GetId() == self.chaserRenderFrameId + 1) { + self.chaserRenderFrameId = nextRdf.GetId(); // To avoid redundant calculation } - self.recentRenderCache.setByFrameId(nextRdf, nextRdf.Id); + self.recentRenderCache.setByFrameId(nextRdf, nextRdf.GetId()); prevLatestRdf = currRdf; latestRdf = nextRdf; } @@ -1402,9 +1405,9 @@ othersForcedDownsyncRenderFrame=${JSON.stringify(othersForcedDownsyncRenderFrame const playerId = immediatePlayerInfo.Id; if (self.playerRichInfoDict.has(playerId)) continue; // Skip already put keys self.playerRichInfoDict.set(playerId, immediatePlayerInfo); - const joinIndex = immediatePlayerInfo.joinIndex || immediatePlayerInfo.JoinIndex; - const vx = immediatePlayerInfo.virtualGridX || immediatePlayerInfo.VirtualGridX; - const vy = immediatePlayerInfo.virtualGridY || immediatePlayerInfo.VirtualGridY; + const joinIndex = immediatePlayerInfo.JoinIndex; + const vx = immediatePlayerInfo.VirtualGridX; + const vy = immediatePlayerInfo.VirtualGridY; const nodeAndScriptIns = self.spawnPlayerNode(joinIndex, vx, vy, immediatePlayerInfo); Object.assign(self.playerRichInfoDict.get(playerId), { @@ -1412,9 +1415,9 @@ othersForcedDownsyncRenderFrame=${JSON.stringify(othersForcedDownsyncRenderFrame scriptIns: nodeAndScriptIns[1], }); - const selfPlayerId = self.selfPlayerInfo.Id; + const selfPlayerId = self.selfPlayerInfo.id; if (selfPlayerId == playerId) { - self.selfPlayerInfo.JoinIndex = immediatePlayerInfo.JoinIndex; // Update here in case of any change during WAITING phase + self.selfPlayerInfo.joinIndex = immediatePlayerInfo.JoinIndex; // Update here in case of any change during WAITING phase nodeAndScriptIns[1].showArrowTipNode(); } } @@ -1428,22 +1431,22 @@ othersForcedDownsyncRenderFrame=${JSON.stringify(othersForcedDownsyncRenderFrame const self = this; if (true == usefullOutput) { let s = []; - for (let i = self.recentInputCache.StFrameId; i < self.recentInputCache.EdFrameId; ++i) { + for (let i = self.recentInputCache.GetStFrameId(); i < self.recentInputCache.GetEdFrameId(); ++i) { s.push(JSON.stringify(self.recentInputCache.GetByFrameId(i))); } return s.join('\n'); } - return `[stInputFrameId=${self.recentInputCache.StFrameId}, edInputFrameId=${self.recentInputCache.EdFrameId})`; + return `[stInputFrameId=${self.recentInputCache.GetStFrameId()}, edInputFrameId=${self.recentInputCache.GetEdFrameId()})`; }, _stringifyGopkgRoomDownsyncFrame(rdf) { let s = []; s.push(`{`); - s.push(` id: ${rdf.Id}`); + s.push(` id: ${rdf.GetId()}`); s.push(` players: [`); - for (let k in rdf.PlayersArr) { - const player = rdf.PlayersArr[k]; + for (let k in rdf.GetPlayersArr()) { + const player = rdf.GetPlayersArr()[k]; s.push(` {joinIndex: ${player.JoinIndex}, id: ${player.Id}, vx: ${player.VirtualGridX}, vy: ${player.VirtualGridY}, velX: ${player.VelX}, velY: ${player.VelY}}`); } s.push(` ]`); @@ -1513,12 +1516,12 @@ othersForcedDownsyncRenderFrame=${JSON.stringify(othersForcedDownsyncRenderFrame const actuallyUsedInputClone = self.rdfIdToActuallyUsedInput.get(i); const rdf = self.recentRenderCache.getByFrameId(i); const playersStrBldr = []; - for (let k in rdf.PlayersArr) { - playersStrBldr.push(self.playerDownsyncStr(rdf.PlayersArr[k])); + for (let k in rdf.GetPlayersArr()) { + playersStrBldr.push(self.playerDownsyncStr(rdf.GetPlayersArr()[k])); } const fireballsStrBldr = []; - for (let k in rdf.FireballBullets) { - fireballsStrBldr.push(self.fireballDownsyncStr(rdf.FireballBullets[k])); + for (let k in rdf.GetFireballBullets()) { + fireballsStrBldr.push(self.fireballDownsyncStr(rdf.GetFireballBullets()[k])); } s.push(`rdfId:${i} players:[${playersStrBldr.join(',')}] @@ -1544,8 +1547,9 @@ actuallyUsedinputList:{${self.inputFrameDownsyncStr(actuallyUsedInputClone)}}`); let g2 = self.g2; g2.clear(); - for (let k in rdf.PlayersArr) { - const player = rdf.PlayersArr[k]; + const playersArr = rdf.GetPlayersArr(); + for (let k in playersArr) { + const player = playersArr[k]; if (1 == player.JoinIndex) { g2.strokeColor = cc.Color.BLUE; } else { @@ -1579,10 +1583,11 @@ actuallyUsedinputList:{${self.inputFrameDownsyncStr(actuallyUsedInputClone)}}`); g2.stroke(); } - for (let k in rdf.MeleeBullets) { - const meleeBullet = rdf.MeleeBullets[k]; - if (gopkgs.IsMeleeBulletActive(meleeBullet, rdf)) { - const offender = rdf.PlayersArr[meleeBullet.BattleAttr.OffenderJoinIndex - 1]; + const meleeBullets = rdf.GetMeleeBullets(); + for (let k in meleeBullets) { + const meleeBullet = meleeBullets[k]; + if (gopkgs.IsGeneralBulletActive(meleeBullet.BlState, meleeBullet.BattleAttr.OriginatedRenderFrameId, meleeBullet.Bullet.StartupFrames, meleeBullet.Bullet.ActiveFrames, rdf.GetId())) { + const offender = playersArr[meleeBullet.BattleAttr.OffenderJoinIndex - 1]; if (1 == offender.JoinIndex) { g2.strokeColor = cc.Color.BLUE; } else { @@ -1607,10 +1612,11 @@ actuallyUsedinputList:{${self.inputFrameDownsyncStr(actuallyUsedInputClone)}}`); } } - for (let k in rdf.FireballBullets) { - const fireballBullet = rdf.FireballBullets[k]; - if (gopkgs.IsFireballBulletActive(fireballBullet, rdf)) { - const offender = rdf.PlayersArr[fireballBullet.BattleAttr.OffenderJoinIndex - 1]; + const fireballBullets = rdf.GetFireballBullets(); + for (let k in fireballBullets) { + const fireballBullet = fireballBullets[k]; + if (gopkgs.IsGeneralBulletActive(fireballBullet.BlState, fireballBullet.BattleAttr.OriginatedRenderFrameId, fireballBullet.Bullet.StartupFrames, fireballBullet.Bullet.ActiveFrames, rdf.GetId())) { + const offender = playersArr[fireballBullet.BattleAttr.OffenderJoinIndex - 1]; if (1 == offender.JoinIndex) { g2.strokeColor = cc.Color.BLUE; } else { diff --git a/frontend/assets/scripts/OfflineMap.js b/frontend/assets/scripts/OfflineMap.js index 168ab45..b04bb74 100644 --- a/frontend/assets/scripts/OfflineMap.js +++ b/frontend/assets/scripts/OfflineMap.js @@ -111,7 +111,7 @@ cc.Class({ virtualGridY: p1Vpos[1], revivalVirtualGridX: p1Vpos[0], revivalVirtualGridY: p1Vpos[1], - speed: chConfigsOrderedByJoinIndex[0].Speed, + speed: chConfigsOrderedByJoinIndex[0].GetSpeed(), colliderRadius: colliderRadiusV[0], characterState: window.ATK_CHARACTER_STATE.InAirIdle1NoJump[0], framesToRecover: 0, @@ -131,7 +131,7 @@ cc.Class({ virtualGridY: p2Vpos[1], revivalVirtualGridX: p2Vpos[0], revivalVirtualGridY: p2Vpos[1], - speed: chConfigsOrderedByJoinIndex[1].Speed, + speed: chConfigsOrderedByJoinIndex[1].GetSpeed(), colliderRadius: colliderRadiusV[0], characterState: window.ATK_CHARACTER_STATE.InAirIdle1NoJump[0], framesToRecover: 0, @@ -149,8 +149,8 @@ cc.Class({ }); self.selfPlayerInfo = { - Id: 10, - JoinIndex: 1, + id: 10, + joinIndex: 1, }; if (cc.sys.isNative) { window.onUdpMessage = (args) => { @@ -163,7 +163,7 @@ cc.Class({ const echoed = window.pb.protos.HolePunchUpsync.decode(ui8Arr); cc.log(`#2 Js called back by CPP: onUdpMessage: ${JSON.stringify(echoed)}`); }; - const res1 = DelayNoMore.UdpSession.openUdpSession(8888 + self.selfPlayerInfo.JoinIndex); + const res1 = DelayNoMore.UdpSession.openUdpSession(8888 + self.selfPlayerInfo.joinIndex); const holePunchData = window.pb.protos.HolePunchUpsync.encode({ boundRoomId: 22, intAuthToken: "foobar", diff --git a/frontend/assets/scripts/WsSessionMgr.js b/frontend/assets/scripts/WsSessionMgr.js index 715f312..e302af4 100644 --- a/frontend/assets/scripts/WsSessionMgr.js +++ b/frontend/assets/scripts/WsSessionMgr.js @@ -87,8 +87,8 @@ window.handleHbRequirements = function(resp) { if (constants.RET_CODE.OK != resp.ret) return; // The assignment of "window.mapIns" is inside "Map.onLoad", which precedes "initPersistentSessionClient". window.mapIns.selfPlayerInfo = JSON.parse(cc.sys.localStorage.getItem('selfPlayer')); // This field is kept for distinguishing "self" and "others". - window.mapIns.selfPlayerInfo.Id = window.mapIns.selfPlayerInfo.playerId; - window.mapIns.selfPlayerInfo.JoinIndex = resp.peerJoinIndex; + window.mapIns.selfPlayerInfo.id = window.mapIns.selfPlayerInfo.playerId; + window.mapIns.selfPlayerInfo.joinIndex = resp.peerJoinIndex; console.log(`Handle hb requirements #2`); if (null == window.boundRoomId || null == window.boundRoomCapacity) { window.boundRoomId = resp.bciFrame.boundRoomId; @@ -109,7 +109,7 @@ window.handleHbRequirements = function(resp) { window.initSecondarySession(null, window.boundRoomId); } else { console.log(`Handle hb requirements #5, native, bciFrame.battleUdpTunnel=${resp.bciFrame.battleUdpTunnel}, selfPlayerInfo=${JSON.stringify(window.mapIns.selfPlayerInfo)}`); - const res1 = DelayNoMore.UdpSession.openUdpSession(8888 + window.mapIns.selfPlayerInfo.JoinIndex); + const res1 = DelayNoMore.UdpSession.openUdpSession(8888 + window.mapIns.selfPlayerInfo.joinIndex); window.mapIns.selfPlayerInfo.udpTunnelAuthKey = resp.bciFrame.battleUdpTunnel.authKey; const intAuthToken = window.mapIns.selfPlayerInfo.intAuthToken; const authKey = Math.floor(Math.random() * 65535); @@ -121,7 +121,7 @@ window.handleHbRequirements = function(resp) { }).finish(); const udpTunnelHolePunchData = window.pb.protos.WsReq.encode({ msgId: Date.now(), - playerId: window.mapIns.selfPlayerInfo.Id, + playerId: window.mapIns.selfPlayerInfo.id, act: window.UPSYNC_MSG_ACT_PLAYER_CMD, authKey: resp.bciFrame.battleUdpTunnel.authKey, }).finish(); @@ -250,7 +250,7 @@ window.initPersistentSessionClient = function(onopenCb, expectedRoomId) { console.log(`Got DOWNSYNC_MSG_ACT_PEER_UDP_ADDR peerAddrList=${JSON.stringify(peerAddrList)}; boundRoomCapacity=${window.boundRoomCapacity}`); for (let j = 0; j < 3; ++j) { setTimeout(() => { - DelayNoMore.UdpSession.upsertPeerUdpAddr(peerAddrList, window.boundRoomCapacity, window.mapIns.selfPlayerInfo.JoinIndex); // In C++ impl it actually broadcasts the peer-punching message to all known peers within "window.boundRoomCapacity" + DelayNoMore.UdpSession.upsertPeerUdpAddr(peerAddrList, window.boundRoomCapacity, window.mapIns.selfPlayerInfo.joinIndex); // In C++ impl it actually broadcasts the peer-punching message to all known peers within "window.boundRoomCapacity" }, j * 500); } } diff --git a/frontend/assets/scripts/modules/jsexport.js b/frontend/assets/scripts/modules/jsexport.js index 98dcd77..a963db5 100644 --- a/frontend/assets/scripts/modules/jsexport.js +++ b/frontend/assets/scripts/modules/jsexport.js @@ -2,15 +2,7211 @@ (function() { var $goVersion = "go1.18.6"; -Error.stackTraceLimit=1/0;var $global,$module,$NaN=NaN;if("undefined"!=typeof window?$global=window:"undefined"!=typeof self?$global=self:"undefined"!=typeof global?($global=global).require=require:$global=this,void 0===$global||void 0===$global.Array)throw new Error("no global object found");if("undefined"!=typeof module&&($module=module),!$global.fs&&$global.require)try{var fs=$global.require("fs");"object"==typeof fs&&null!==fs&&0!==Object.keys(fs).length&&($global.fs=fs)}catch(e){}if(!$global.fs){var outputBuf="",decoder=new TextDecoder("utf-8");$global.fs={constants:{O_WRONLY:-1,O_RDWR:-1,O_CREAT:-1,O_TRUNC:-1,O_APPEND:-1,O_EXCL:-1},writeSync:function(e,n){var r=(outputBuf+=decoder.decode(n)).lastIndexOf("\n");return-1!=r&&(console.log(outputBuf.substr(0,r)),outputBuf=outputBuf.substr(r+1)),n.length},write:function(e,n,r,t,i,a){0===r&&t===n.length&&null===i?a(null,this.writeSync(e,n)):a(enosys())}}}var $throwRuntimeError,$linknames={},$packages={},$idCounter=0,$keys=function(e){return e?Object.keys(e):[]},$flushConsole=function(){},$throwNilPointerError=function(){$throwRuntimeError("invalid memory address or nil pointer dereference")},$call=function(e,n,r){return e.apply(n,r)},$makeFunc=function(e){return function(){return $externalize(e(this,new($sliceType($jsObjectPtr))($global.Array.prototype.slice.call(arguments,[]))),$emptyInterface)}},$unused=function(e){},$print=console.log;if(void 0!==$global.process&&$global.require)try{var util=$global.require("util");$print=function(){$global.process.stderr.write(util.format.apply(this,arguments))}}catch(e){}var $println=console.log,$initAllLinknames=function(){for(var e=$keys($packages),n=0;ne.$capacity||t>e.$capacity)&&$throwRuntimeError("slice bounds out of range"),e===e.constructor.nil)return e;var i=new e.constructor(e.$array);return i.$offset=e.$offset+n,i.$length=r-n,i.$capacity=t-n,i},$substring=function(e,n,r){return(n<0||re.length)&&$throwRuntimeError("slice bounds out of range"),e.substring(n,r)},$sliceToNativeArray=function(e){return e.$array.constructor!==Array?e.$array.subarray(e.$offset,e.$offset+e.$length):e.$array.slice(e.$offset,e.$offset+e.$length)},$sliceToGoArray=function(e,n){var r=n.elem;return void 0!==r&&e.$length1114111||55296<=e&&e<=57343)&&(e=65533),e<=127?String.fromCharCode(e):e<=2047?String.fromCharCode(192|e>>6,128|63&e):e<=65535?String.fromCharCode(224|e>>12,128|e>>6&63,128|63&e):String.fromCharCode(240|e>>18,128|e>>12&63,128|e>>6&63,128|63&e)},$stringToBytes=function(e){for(var n=new Uint8Array(e.length),r=0;rt){for(var o=i-1;o>=0;o--)a.copy(e[r+o],n[t+o]);return}for(o=0;ot)for(o=i-1;o>=0;o--)e[r+o]=n[t+o];else for(o=0;oc)if(a=0,c=Math.max(o,e.$capacity<1024?2*e.$capacity:Math.floor(5*e.$capacity/4)),e.$array.constructor===Array){(i=e.$array.slice(e.$offset,e.$offset+e.$length)).length=c;for(var $=e.constructor.elem.zero,u=e.$length;u>>16&65535)*t+r*(n>>>16&65535)<<16>>>0)>>0},$floatKey=function(e){return e!=e?"NaN$"+ ++$idCounter:String(e)},$flatten64=function(e){return 4294967296*e.$high+e.$low},$shiftLeft64=function(e,n){return 0===n?e:n<32?new e.constructor(e.$high<>>32-n,e.$low<>>0):n<64?new e.constructor(e.$low<>n,(e.$low>>>n|e.$high<<32-n)>>>0):n<64?new e.constructor(e.$high>>31,e.$high>>n-32>>>0):e.$high<0?new e.constructor(-1,4294967295):new e.constructor(0,0)},$shiftRightUint64=function(e,n){return 0===n?e:n<32?new e.constructor(e.$high>>>n,(e.$low>>>n|e.$high<<32-n)>>>0):n<64?new e.constructor(0,e.$high>>>n-32):new e.constructor(0,0)},$mul64=function(e,n){var r=e.$high>>>16,t=65535&e.$high,i=e.$low>>>16,a=65535&e.$low,o=n.$high>>>16,c=65535&n.$high,$=n.$low>>>16,u=65535&n.$low,l=0,s=0,f=0,d=0;f+=(d+=a*u)>>>16,s+=(f+=i*u)>>>16,f&=65535,s+=(f+=a*$)>>>16,l+=(s+=t*u)>>>16,s&=65535,l+=(s+=i*$)>>>16,s&=65535,l+=(s+=a*c)>>>16,l+=r*u+t*$+i*c+a*o;var p=((l&=65535)<<16|(s&=65535))>>>0,h=((f&=65535)<<16|(d&=65535))>>>0;return new e.constructor(p,h)},$div64=function(e,n,r){0===n.$high&&0===n.$low&&$throwRuntimeError("integer divide by zero");var t=1,i=1,a=e.$high,o=e.$low;a<0&&(t=-1,i=-1,a=-a,0!==o&&(a--,o=4294967296-o));var c=n.$high,$=n.$low;n.$high<0&&(t*=-1,c=-c,0!==$&&(c--,$=4294967296-$));for(var u=0,l=0,s=0;c<2147483648&&(a>c||a===c&&o>$);)c=(c<<1|$>>>31)>>>0,$=$<<1>>>0,s++;for(var f=0;f<=s;f++)u=u<<1|l>>>31,l=l<<1>>>0,(a>c||a===c&&o>=$)&&(a-=c,(o-=$)<0&&(a--,o+=4294967296),4294967296===++l&&(u++,l=0)),$=($>>>1|c<<31)>>>0,c>>>=1;return r?new e.constructor(a*i,o*i):new e.constructor(u*t,l*t)},$divComplex=function(e,n){var r=e.$real===1/0||e.$real===-1/0||e.$imag===1/0||e.$imag===-1/0,t=n.$real===1/0||n.$real===-1/0||n.$imag===1/0||n.$imag===-1/0,i=!r&&(e.$real!=e.$real||e.$imag!=e.$imag),a=!t&&(n.$real!=n.$real||n.$imag!=n.$imag);if(i||a)return new e.constructor(NaN,NaN);if(r&&!t)return new e.constructor(1/0,1/0);if(!r&&t)return new e.constructor(0,0);if(0===n.$real&&0===n.$imag)return 0===e.$real&&0===e.$imag?new e.constructor(NaN,NaN):new e.constructor(1/0,1/0);if(Math.abs(n.$real)<=Math.abs(n.$imag)){var o=n.$real/n.$imag,c=n.$real*o+n.$imag;return new e.constructor((e.$real*o+e.$imag)/c,(e.$imag*o-e.$real)/c)}o=n.$imag/n.$real,c=n.$imag*o+n.$real;return new e.constructor((e.$imag*o+e.$real)/c,(e.$imag-e.$real*o)/c)},$kindBool=1,$kindInt=2,$kindInt8=3,$kindInt16=4,$kindInt32=5,$kindInt64=6,$kindUint=7,$kindUint8=8,$kindUint16=9,$kindUint32=10,$kindUint64=11,$kindUintptr=12,$kindFloat32=13,$kindFloat64=14,$kindComplex64=15,$kindComplex128=16,$kindArray=17,$kindChan=18,$kindFunc=19,$kindInterface=20,$kindMap=21,$kindPtr=22,$kindSlice=23,$kindString=24,$kindStruct=25,$kindUnsafePointer=26,$methodSynthesizers=[],$addMethodSynthesizer=function(e){null!==$methodSynthesizers?$methodSynthesizers.push(e):e()},$synthesizeMethods=function(){$methodSynthesizers.forEach(function(e){e()}),$methodSynthesizers=null},$ifaceKeyFor=function(e){if(e===$ifaceNil)return"nil";var n=e.constructor;return n.string+"$"+n.keyFor(e.$val)},$identity=function(e){return e},$typeIDCounter=0,$idKey=function(e){return void 0===e.$id&&($idCounter++,e.$id=$idCounter),String(e.$id)},$arrayPtrCtor=function(){return function(e){this.$get=function(){return e},this.$set=function(e){typ.copy(this,e)},this.$val=e}},$newType=function(e,n,r,t,i,a,o){var c;switch(n){case $kindBool:case $kindInt:case $kindInt8:case $kindInt16:case $kindInt32:case $kindUint:case $kindUint8:case $kindUint16:case $kindUint32:case $kindUintptr:case $kindUnsafePointer:(c=function(e){this.$val=e}).wrapped=!0,c.keyFor=$identity;break;case $kindString:(c=function(e){this.$val=e}).wrapped=!0,c.keyFor=function(e){return"$"+e};break;case $kindFloat32:case $kindFloat64:(c=function(e){this.$val=e}).wrapped=!0,c.keyFor=function(e){return $floatKey(e)};break;case $kindInt64:(c=function(e,n){this.$high=e+Math.floor(Math.ceil(n)/4294967296)>>0,this.$low=n>>>0,this.$val=this}).keyFor=function(e){return e.$high+"$"+e.$low};break;case $kindUint64:(c=function(e,n){this.$high=e+Math.floor(Math.ceil(n)/4294967296)>>>0,this.$low=n>>>0,this.$val=this}).keyFor=function(e){return e.$high+"$"+e.$low};break;case $kindComplex64:(c=function(e,n){this.$real=$fround(e),this.$imag=$fround(n),this.$val=this}).keyFor=function(e){return e.$real+"$"+e.$imag};break;case $kindComplex128:(c=function(e,n){this.$real=e,this.$imag=n,this.$val=this}).keyFor=function(e){return e.$real+"$"+e.$imag};break;case $kindArray:(c=function(e){this.$val=e}).wrapped=!0,c.ptr=$newType(4,$kindPtr,"*"+r,!1,"",!1,$arrayPtrCtor()),c.init=function(e,n){c.elem=e,c.len=n,c.comparable=e.comparable,c.keyFor=function(n){return Array.prototype.join.call($mapArray(n,function(n){return String(e.keyFor(n)).replace(/\\/g,"\\\\").replace(/\$/g,"\\$")}),"$")},c.copy=function(n,r){$copyArray(n,r,0,0,r.length,e)},c.ptr.init(c),Object.defineProperty(c.ptr.nil,"nilCheck",{get:$throwNilPointerError})};break;case $kindChan:(c=function(e){this.$val=e}).wrapped=!0,c.keyFor=$idKey,c.init=function(e,n,r){c.elem=e,c.sendOnly=n,c.recvOnly=r};break;case $kindFunc:(c=function(e){this.$val=e}).wrapped=!0,c.init=function(e,n,r){c.params=e,c.results=n,c.variadic=r,c.comparable=!1};break;case $kindInterface:(c={implementedBy:{},missingMethodFor:{}}).keyFor=$ifaceKeyFor,c.init=function(e){c.methods=e,e.forEach(function(e){$ifaceNil[e.prop]=$throwNilPointerError})};break;case $kindMap:(c=function(e){this.$val=e}).wrapped=!0,c.init=function(e,n){c.key=e,c.elem=n,c.comparable=!1};break;case $kindPtr:(c=o||function(e,n,r){this.$get=e,this.$set=n,this.$target=r,this.$val=this}).keyFor=$idKey,c.init=function(e){c.elem=e,c.wrapped=e.kind===$kindArray,c.nil=new c($throwNilPointerError,$throwNilPointerError)};break;case $kindSlice:(c=function(e){e.constructor!==c.nativeArray&&(e=new c.nativeArray(e)),this.$array=e,this.$offset=0,this.$length=e.length,this.$capacity=e.length,this.$val=this}).init=function(e){c.elem=e,c.comparable=!1,c.nativeArray=$nativeArray(e.kind),c.nil=new c([])};break;case $kindStruct:(c=function(e){this.$val=e}).wrapped=!0,c.ptr=$newType(4,$kindPtr,"*"+r,!1,i,a,o),c.ptr.elem=c,c.ptr.prototype.$get=function(){return this},c.ptr.prototype.$set=function(e){c.copy(this,e)},c.init=function(e,n){c.pkgPath=e,c.fields=n,n.forEach(function(e){e.typ.comparable||(c.comparable=!1)}),c.keyFor=function(e){var r=e.$val;return $mapArray(n,function(e){return String(e.typ.keyFor(r[e.prop])).replace(/\\/g,"\\\\").replace(/\$/g,"\\$")}).join("$")},c.copy=function(e,r){for(var t=0;t0;){var a=[],o=[];t.forEach(function(e){if(!i[e.typ.string])switch(i[e.typ.string]=!0,e.typ.named&&(o=o.concat(e.typ.methods),e.indirect&&(o=o.concat($ptrType(e.typ).methods))),e.typ.kind){case $kindStruct:e.typ.fields.forEach(function(n){if(n.embedded){var r=n.typ,t=r.kind===$kindPtr;a.push({typ:t?r.elem:r,indirect:e.indirect||t})}});break;case $kindInterface:o=o.concat(e.typ.methods)}}),o.forEach(function(e){void 0===n[e.name]&&(n[e.name]=e)}),t=a}return e.methodSetCache=[],Object.keys(n).sort().forEach(function(r){e.methodSetCache.push(n[r])}),e.methodSetCache},$Bool=$newType(1,$kindBool,"bool",!0,"",!1,null),$Int=$newType(4,$kindInt,"int",!0,"",!1,null),$Int8=$newType(1,$kindInt8,"int8",!0,"",!1,null),$Int16=$newType(2,$kindInt16,"int16",!0,"",!1,null),$Int32=$newType(4,$kindInt32,"int32",!0,"",!1,null),$Int64=$newType(8,$kindInt64,"int64",!0,"",!1,null),$Uint=$newType(4,$kindUint,"uint",!0,"",!1,null),$Uint8=$newType(1,$kindUint8,"uint8",!0,"",!1,null),$Uint16=$newType(2,$kindUint16,"uint16",!0,"",!1,null),$Uint32=$newType(4,$kindUint32,"uint32",!0,"",!1,null),$Uint64=$newType(8,$kindUint64,"uint64",!0,"",!1,null),$Uintptr=$newType(4,$kindUintptr,"uintptr",!0,"",!1,null),$Float32=$newType(4,$kindFloat32,"float32",!0,"",!1,null),$Float64=$newType(8,$kindFloat64,"float64",!0,"",!1,null),$Complex64=$newType(8,$kindComplex64,"complex64",!0,"",!1,null),$Complex128=$newType(16,$kindComplex128,"complex128",!0,"",!1,null),$String=$newType(8,$kindString,"string",!0,"",!1,null),$UnsafePointer=$newType(4,$kindUnsafePointer,"unsafe.Pointer",!0,"unsafe",!1,null),$nativeArray=function(e){switch(e){case $kindInt:return Int32Array;case $kindInt8:return Int8Array;case $kindInt16:return Int16Array;case $kindInt32:return Int32Array;case $kindUint:return Uint32Array;case $kindUint8:return Uint8Array;case $kindUint16:return Uint16Array;case $kindUint32:case $kindUintptr:return Uint32Array;case $kindFloat32:return Float32Array;case $kindFloat64:return Float64Array;default:return Array}},$toNativeArray=function(e,n){var r=$nativeArray(e);return r===Array?n:new r(n)},$arrayTypes={},$arrayType=function(e,n){var r=e.id+"$"+n,t=$arrayTypes[r];return void 0===t&&(t=$newType(12,$kindArray,"["+n+"]"+e.string,!1,"",!1,null),$arrayTypes[r]=t,t.init(e,n)),t},$chanType=function(e,n,r){var t=(r?"<-":"")+"chan"+(n?"<- ":" ");n||r||"<"!=e.string[0]?t+=e.string:t+="("+e.string+")";var i=n?"SendChan":r?"RecvChan":"Chan",a=e[i];return void 0===a&&(a=$newType(4,$kindChan,t,!1,"",!1,null),e[i]=a,a.init(e,n,r)),a},$Chan=function(e,n){(n<0||n>2147483647)&&$throwRuntimeError("makechan: size out of range"),this.$elem=e,this.$capacity=n,this.$buffer=[],this.$sendQueue=[],this.$recvQueue=[],this.$closed=!1},$chanNil=new $Chan(null,0);$chanNil.$sendQueue=$chanNil.$recvQueue={length:0,push:function(){},shift:function(){},indexOf:function(){return-1}};var $funcTypes={},$funcType=function(e,n,r){var t=$mapArray(e,function(e){return e.id}).join(",")+"$"+$mapArray(n,function(e){return e.id}).join(",")+"$"+r,i=$funcTypes[t];if(void 0===i){var a=$mapArray(e,function(e){return e.string});r&&(a[a.length-1]="..."+a[a.length-1].substr(2));var o="func("+a.join(", ")+")";1===n.length?o+=" "+n[0].string:n.length>1&&(o+=" ("+$mapArray(n,function(e){return e.string}).join(", ")+")"),i=$newType(4,$kindFunc,o,!1,"",!1,null),$funcTypes[t]=i,i.init(e,n,r)}return i},$interfaceTypes={},$interfaceType=function(e){var n=$mapArray(e,function(e){return e.pkg+","+e.name+","+e.typ.id}).join("$"),r=$interfaceTypes[n];if(void 0===r){var t="interface {}";0!==e.length&&(t="interface { "+$mapArray(e,function(e){return(""!==e.pkg?e.pkg+".":"")+e.name+e.typ.string.substr(4)}).join("; ")+" }"),r=$newType(8,$kindInterface,t,!1,"",!1,null),$interfaceTypes[n]=r,r.init(e)}return r},$emptyInterface=$interfaceType([]),$ifaceNil={},$error=$newType(8,$kindInterface,"error",!0,"",!1,null);$error.init([{prop:"Error",name:"Error",pkg:"",typ:$funcType([],[$String],!1)}]);var $panicValue,$jsObjectPtr,$jsErrorPtr,$mapTypes={},$mapType=function(e,n){var r=e.id+"$"+n.id,t=$mapTypes[r];return void 0===t&&(t=$newType(4,$kindMap,"map["+e.string+"]"+n.string,!1,"",!1,null),$mapTypes[r]=t,t.init(e,n)),t},$makeMap=function(e,n){for(var r={},t=0;t2147483647)&&$throwRuntimeError("makeslice: len out of range"),(r<0||r2147483647)&&$throwRuntimeError("makeslice: cap out of range");var t=new e.nativeArray(r);if(e.nativeArray===Array)for(var i=0;i4||t<0)break}}finally{0==$scheduled.length&&clearTimeout(e)}},$schedule=function(e){e.asleep&&(e.asleep=!1,$awakeGoroutines++),$scheduled.push(e),$curGoroutine===$noGoroutine&&$runScheduled()},$setTimeout=function(e,n){return $awakeGoroutines++,setTimeout(function(){$awakeGoroutines--,e()},n)},$block=function(){$curGoroutine===$noGoroutine&&$throwRuntimeError("cannot block in JavaScript callback, fix by wrapping code in goroutine"),$curGoroutine.asleep=!0},$restore=function(e,n){return void 0!==e&&void 0!==e.$blk?e:n},$send=function(e,n){e.$closed&&$throwRuntimeError("send on closed channel");var r=e.$recvQueue.shift();if(void 0===r){if(!(e.$buffer.length65535){var l=Math.floor((u-65536)/1024)+55296,s=(u-65536)%1024+56320;$+=String.fromCharCode(l,s)}else $+=String.fromCharCode(u)}return $;case $kindStruct:var f=$packages.time;if(void 0!==f&&e.constructor===f.Time.ptr){var d=$div64(e.UnixNano(),new $Int64(0,1e6));return new Date($flatten64(d))}var p={},h=function(e,n){if(n===$jsObjectPtr)return e;switch(n.kind){case $kindPtr:return e===n.nil?p:h(e.$get(),n.elem);case $kindStruct:var r=n.fields[0];return h(e[r.prop],r.typ);case $kindInterface:return h(e.$val,e.constructor);default:return p}},k=h(e,n);if(k!==p)return k;if(void 0!==r)return r(e);k={};for(a=0;a>24;case $kindInt16:return parseInt(e)<<16>>16;case $kindInt32:return parseInt(e)>>0;case $kindUint:return parseInt(e);case $kindUint8:return parseInt(e)<<24>>>24;case $kindUint16:return parseInt(e)<<16>>>16;case $kindUint32:case $kindUintptr:return parseInt(e)>>>0;case $kindInt64:case $kindUint64:return new n(0,e);case $kindFloat32:case $kindFloat64:return parseFloat(e);case $kindArray:return e.length!==n.len&&$throwRuntimeError("got array with wrong size from JavaScript native"),$mapArray(e,function(e){return $internalize(e,n.elem,i)});case $kindFunc:return function(){for(var t=[],a=0;a=128)return!1;return!0}; +Error.stackTraceLimit = Infinity; -$packages["github.com/gopherjs/gopherjs/js"]=(function(){var $pkg={},$init,A,B,J,K,M,O,P,Q,R,S,T,G,H,L;A=$pkg.Object=$newType(0,$kindStruct,"js.Object",true,"github.com/gopherjs/gopherjs/js",true,function(object_){this.$val=this;if(arguments.length===0){this.object=null;return;}this.object=object_;});B=$pkg.Error=$newType(0,$kindStruct,"js.Error",true,"github.com/gopherjs/gopherjs/js",true,function(Object_){this.$val=this;if(arguments.length===0){this.Object=null;return;}this.Object=Object_;});J=$pkg.M=$newType(4,$kindMap,"js.M",true,"github.com/gopherjs/gopherjs/js",true,null);K=$pkg.S=$newType(12,$kindSlice,"js.S",true,"github.com/gopherjs/gopherjs/js",true,null);M=$sliceType($emptyInterface);O=$ptrType(A);P=$sliceType(O);Q=$funcType([P],[O],true);R=$funcType([],[O],false);S=$funcType([O],[],false);T=$ptrType(B);A.ptr.prototype.Get=function(a){var a,b;b=this;return b.object[$externalize(a,$String)];};A.prototype.Get=function(a){return this.$val.Get(a);};A.ptr.prototype.Set=function(a,b){var a,b,c;c=this;c.object[$externalize(a,$String)]=$externalize(b,$emptyInterface);};A.prototype.Set=function(a,b){return this.$val.Set(a,b);};A.ptr.prototype.Delete=function(a){var a,b;b=this;delete b.object[$externalize(a,$String)];};A.prototype.Delete=function(a){return this.$val.Delete(a);};A.ptr.prototype.Length=function(){var a;a=this;return $parseInt(a.object.length);};A.prototype.Length=function(){return this.$val.Length();};A.ptr.prototype.Index=function(a){var a,b;b=this;return b.object[a];};A.prototype.Index=function(a){return this.$val.Index(a);};A.ptr.prototype.SetIndex=function(a,b){var a,b,c;c=this;c.object[a]=$externalize(b,$emptyInterface);};A.prototype.SetIndex=function(a,b){return this.$val.SetIndex(a,b);};A.ptr.prototype.Call=function(a,b){var a,b,c,d;c=this;return(d=c.object,d[$externalize(a,$String)].apply(d,$externalize(b,M)));};A.prototype.Call=function(a,b){return this.$val.Call(a,b);};A.ptr.prototype.Invoke=function(a){var a,b;b=this;return b.object.apply(undefined,$externalize(a,M));};A.prototype.Invoke=function(a){return this.$val.Invoke(a);};A.ptr.prototype.New=function(a){var a,b;b=this;return new($global.Function.prototype.bind.apply(b.object,[undefined].concat($externalize(a,M))));};A.prototype.New=function(a){return this.$val.New(a);};A.ptr.prototype.Bool=function(){var a;a=this;return!!(a.object);};A.prototype.Bool=function(){return this.$val.Bool();};A.ptr.prototype.String=function(){var a;a=this;return $internalize(a.object,$String);};A.prototype.String=function(){return this.$val.String();};A.ptr.prototype.Int=function(){var a;a=this;return $parseInt(a.object)>>0;};A.prototype.Int=function(){return this.$val.Int();};A.ptr.prototype.Int64=function(){var a;a=this;return $internalize(a.object,$Int64);};A.prototype.Int64=function(){return this.$val.Int64();};A.ptr.prototype.Uint64=function(){var a;a=this;return $internalize(a.object,$Uint64);};A.prototype.Uint64=function(){return this.$val.Uint64();};A.ptr.prototype.Float=function(){var a;a=this;return $parseFloat(a.object);};A.prototype.Float=function(){return this.$val.Float();};A.ptr.prototype.Interface=function(){var a;a=this;return $internalize(a.object,$emptyInterface);};A.prototype.Interface=function(){return this.$val.Interface();};A.ptr.prototype.Unsafe=function(){var a;a=this;return a.object;};A.prototype.Unsafe=function(){return this.$val.Unsafe();};B.ptr.prototype.Error=function(){var a;a=this;return"JavaScript error: "+$internalize(a.Object.message,$String);};B.prototype.Error=function(){return this.$val.Error();};B.ptr.prototype.Stack=function(){var a;a=this;return $internalize(a.Object.stack,$String);};B.prototype.Stack=function(){return this.$val.Stack();};G=function(a){var a,b,c,d,e,f;b=a;c=new($global.Object)();c.__internal_object__=b;d=b.constructor.methods;e=0;while(true){if(!(e<$parseInt(d.length))){break;}f=[f];f[0]=d[e];if(!($internalize(f[0].pkg,$String)==="")){e=e+(1)>>0;continue;}c[$externalize($internalize(f[0].name,$String),$String)]=$externalize((function(f){return function(g){var g;return $externalizeFunction(b[$externalize($internalize(f[0].prop,$String),$String)],f[0].typ,$externalize(true,$Bool)).apply(b,$externalize(g,P));};})(f),Q);e=e+(1)>>0;}return c;};$pkg.MakeWrapper=G;H=function(a){var{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,$s,$r,$c}=$restore(this,{a});$s=$s||0;s:while(true){switch($s){case 0:b=[b];c=[c];b[0]=a;d=b[0].constructor;c[0]=new($global.Object)();e=(function(b,c){return function(e,f){var e,f;$global.Object.defineProperty(c[0],$externalize(e,$String),$externalize(f,J));};})(b,c);$r=e("__internal_object__",$makeMap($String.keyFor,[{k:"value",v:new $jsObjectPtr(b[0])}]));$s=1;case 1:if($c){$c=false;$r=$r.$blk();}if($r&&$r.$blk!==undefined){break s;}f=$internalize(d.string,$String);g=$internalize(d.pkg,$String);h="";if(f.charCodeAt(0)===42){h="*";}i=0;while(true){if(!(i>0));break;}i=i+(1)>>0;}j=g+"."+h+f;$r=e("$type",$makeMap($String.keyFor,[{k:"value",v:new $String(j)}]));$s=2;case 2:if($c){$c=false;$r=$r.$blk();}if($r&&$r.$blk!==undefined){break s;}k=null;l=new($global.Array)();m=d.methods;if(!(m===undefined)){l=l.concat(m);}n=d.elem;if(!(n===undefined)){k=n.fields;l=l.concat(n.methods);}else{k=d.fields;}o=0;case 3:if(!(o<$parseInt(l.length))){$s=4;continue;}p=[p];p[0]=l[o];if(!($internalize(p[0].pkg,$String)==="")){o=o+(1)>>0;$s=3;continue;}$r=e($internalize(p[0].prop,$String),$makeMap($String.keyFor,[{k:"value",v:new Q((function(b,c,p){return function(q){var q;return $externalizeFunction(b[0][$externalize($internalize(p[0].prop,$String),$String)],p[0].typ,$externalize(true,$Bool),H).apply(b[0],$externalize(q,P));};})(b,c,p))}]));$s=5;case 5:if($c){$c=false;$r=$r.$blk();}if($r&&$r.$blk!==undefined){break s;}o=o+(1)>>0;$s=3;continue;case 4:if(!(k===undefined)){$s=6;continue;}$s=7;continue;case 6:q=0;case 8:if(!(q<$parseInt(k.length))){$s=9;continue;}r=[r];r[0]=k[q];if(!!!(r[0].exported)){q=q+(1)>>0;$s=8;continue;}$r=e($internalize(r[0].prop,$String),$makeMap($String.keyFor,[{k:"get",v:new R((function(b,c,r){return function(){var s;s=$copyIfRequired(b[0].$val[$externalize($internalize(r[0].prop,$String),$String)],r[0].typ);return $externalize(s,r[0].typ,H);};})(b,c,r))},{k:"set",v:new S((function(b,c,r){return function(s){var s,t;t=$internalize(s,r[0].typ,H);b[0].$val[$externalize($internalize(r[0].prop,$String),$String)]=t;};})(b,c,r))}]));$s=10;case 10:if($c){$c=false;$r=$r.$blk();}if($r&&$r.$blk!==undefined){break s;}q=q+(1)>>0;$s=8;continue;case 9:case 7:$s=-1;return c[0];}return;}var $f={$blk:H,$c:true,$r,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,$s};return $f;};$pkg.MakeFullWrapper=H;L=function(){var a;a=new B.ptr(null);$unused(a);};O.methods=[{prop:"Get",name:"Get",pkg:"",typ:$funcType([$String],[O],false)},{prop:"Set",name:"Set",pkg:"",typ:$funcType([$String,$emptyInterface],[],false)},{prop:"Delete",name:"Delete",pkg:"",typ:$funcType([$String],[],false)},{prop:"Length",name:"Length",pkg:"",typ:$funcType([],[$Int],false)},{prop:"Index",name:"Index",pkg:"",typ:$funcType([$Int],[O],false)},{prop:"SetIndex",name:"SetIndex",pkg:"",typ:$funcType([$Int,$emptyInterface],[],false)},{prop:"Call",name:"Call",pkg:"",typ:$funcType([$String,M],[O],true)},{prop:"Invoke",name:"Invoke",pkg:"",typ:$funcType([M],[O],true)},{prop:"New",name:"New",pkg:"",typ:$funcType([M],[O],true)},{prop:"Bool",name:"Bool",pkg:"",typ:$funcType([],[$Bool],false)},{prop:"String",name:"String",pkg:"",typ:$funcType([],[$String],false)},{prop:"Int",name:"Int",pkg:"",typ:$funcType([],[$Int],false)},{prop:"Int64",name:"Int64",pkg:"",typ:$funcType([],[$Int64],false)},{prop:"Uint64",name:"Uint64",pkg:"",typ:$funcType([],[$Uint64],false)},{prop:"Float",name:"Float",pkg:"",typ:$funcType([],[$Float64],false)},{prop:"Interface",name:"Interface",pkg:"",typ:$funcType([],[$emptyInterface],false)},{prop:"Unsafe",name:"Unsafe",pkg:"",typ:$funcType([],[$Uintptr],false)}];T.methods=[{prop:"Error",name:"Error",pkg:"",typ:$funcType([],[$String],false)},{prop:"Stack",name:"Stack",pkg:"",typ:$funcType([],[$String],false)}];A.init("github.com/gopherjs/gopherjs/js",[{prop:"object",name:"object",embedded:false,exported:false,typ:O,tag:""}]);B.init("",[{prop:"Object",name:"Object",embedded:true,exported:true,typ:O,tag:""}]);J.init($String,$emptyInterface);K.init($emptyInterface);$init=function(){$pkg.$init=function(){};var $f,$c=false,$s=0,$r;if(this!==undefined&&this.$blk!==undefined){$f=this;$c=true;$s=$f.$s;$r=$f.$r;}s:while(true){switch($s){case 0:L();}return;}if($f===undefined){$f={$blk:$init};}$f.$s=$s;$f.$r=$r;return $f;};$pkg.$init=$init;return $pkg;})(); -$packages["runtime"]=(function(){var $pkg={},$init,A,C,D,AT,AZ,BD,AM,E,AU;A=$packages["github.com/gopherjs/gopherjs/js"];C=$pkg._type=$newType(0,$kindStruct,"runtime._type",true,"runtime",false,function(str_){this.$val=this;if(arguments.length===0){this.str="";return;}this.str=str_;});D=$pkg.TypeAssertionError=$newType(0,$kindStruct,"runtime.TypeAssertionError",true,"runtime",true,function(_interface_,concrete_,asserted_,missingMethod_){this.$val=this;if(arguments.length===0){this._interface=AZ.nil;this.concrete=AZ.nil;this.asserted=AZ.nil;this.missingMethod="";return;}this._interface=_interface_;this.concrete=concrete_;this.asserted=asserted_;this.missingMethod=missingMethod_;});AT=$pkg.errorString=$newType(8,$kindString,"runtime.errorString",true,"runtime",false,null);AZ=$ptrType(C);BD=$ptrType(D);C.ptr.prototype.string=function(){var a;a=this;return a.str;};C.prototype.string=function(){return this.$val.string();};C.ptr.prototype.pkgpath=function(){var a;a=this;return"";};C.prototype.pkgpath=function(){return this.$val.pkgpath();};D.ptr.prototype.RuntimeError=function(){};D.prototype.RuntimeError=function(){return this.$val.RuntimeError();};D.ptr.prototype.Error=function(){var a,b,c,d,e;a=this;b="interface";if(!(a._interface===AZ.nil)){b=a._interface.string();}c=a.asserted.string();if(a.concrete===AZ.nil){return"interface conversion: "+b+" is nil, not "+c;}d=a.concrete.string();if(a.missingMethod===""){e="interface conversion: "+b+" is "+d+", not "+c;if(d===c){if(!(a.concrete.pkgpath()===a.asserted.pkgpath())){e=e+(" (types from different packages)");}else{e=e+(" (types from different scopes)");}}return e;}return"interface conversion: "+d+" is not "+c+": missing method "+a.missingMethod;};D.prototype.Error=function(){return this.$val.Error();};E=function(){var a,b;a=$packages[$externalize("github.com/gopherjs/gopherjs/js",$String)];$jsObjectPtr=a.Object.ptr;$jsErrorPtr=a.Error.ptr;$throwRuntimeError=AU;AM=$internalize($goVersion,$String);b=$ifaceNil;b=new D.ptr(AZ.nil,AZ.nil,AZ.nil,"");$unused(b);};AT.prototype.RuntimeError=function(){var a;a=this.$val;};$ptrType(AT).prototype.RuntimeError=function(){return new AT(this.$get()).RuntimeError();};AT.prototype.Error=function(){var a;a=this.$val;return"runtime error: "+(a);};$ptrType(AT).prototype.Error=function(){return new AT(this.$get()).Error();};AU=function(a){var a;$panic(new AT((a)));};AZ.methods=[{prop:"string",name:"string",pkg:"runtime",typ:$funcType([],[$String],false)},{prop:"pkgpath",name:"pkgpath",pkg:"runtime",typ:$funcType([],[$String],false)}];BD.methods=[{prop:"RuntimeError",name:"RuntimeError",pkg:"",typ:$funcType([],[],false)},{prop:"Error",name:"Error",pkg:"",typ:$funcType([],[$String],false)}];AT.methods=[{prop:"RuntimeError",name:"RuntimeError",pkg:"",typ:$funcType([],[],false)},{prop:"Error",name:"Error",pkg:"",typ:$funcType([],[$String],false)}];C.init("runtime",[{prop:"str",name:"str",embedded:false,exported:false,typ:$String,tag:""}]);D.init("runtime",[{prop:"_interface",name:"_interface",embedded:false,exported:false,typ:AZ,tag:""},{prop:"concrete",name:"concrete",embedded:false,exported:false,typ:AZ,tag:""},{prop:"asserted",name:"asserted",embedded:false,exported:false,typ:AZ,tag:""},{prop:"missingMethod",name:"missingMethod",embedded:false,exported:false,typ:$String,tag:""}]);$init=function(){$pkg.$init=function(){};var $f,$c=false,$s=0,$r;if(this!==undefined&&this.$blk!==undefined){$f=this;$c=true;$s=$f.$s;$r=$f.$r;}s:while(true){switch($s){case 0:$r=A.$init();$s=1;case 1:if($c){$c=false;$r=$r.$blk();}if($r&&$r.$blk!==undefined){break s;}AM="";E();}return;}if($f===undefined){$f={$blk:$init};}$f.$s=$s;$f.$r=$r;return $f;};$pkg.$init=$init;return $pkg;})(); -$packages["math/bits"]=(function(){var $pkg={},$init;$init=function(){$pkg.$init=function(){};var $f,$c=false,$s=0,$r;if(this!==undefined&&this.$blk!==undefined){$f=this;$c=true;$s=$f.$s;$r=$f.$r;}s:while(true){switch($s){case 0:}return;}if($f===undefined){$f={$blk:$init};}$f.$s=$s;$f.$r=$r;return $f;};$pkg.$init=$init;return $pkg;})(); -$packages["math"]=(function(){var $pkg={},$init,B,A,IT,IU,IV,IW,FL,FM,FN,FO,FP,HH,EI,EX,EY,FK,GA,GH,GK,GL,GM,GS,GT,GW,GX,GZ,HA,HD,HI,HL,HM;B=$packages["github.com/gopherjs/gopherjs/js"];A=$packages["math/bits"];IT=$arrayType($Uint32,2);IU=$arrayType($Float32,2);IV=$arrayType($Float64,1);IW=$structType("math",[{prop:"uint32array",name:"uint32array",embedded:false,exported:false,typ:IT,tag:""},{prop:"float32array",name:"float32array",embedded:false,exported:false,typ:IU,tag:""},{prop:"float64array",name:"float64array",embedded:false,exported:false,typ:IV,tag:""}]);EI=function(av){var av,aw,ax,ay,az,ba,bb;aw=HL(av);ax=((($shiftRightUint64(aw,52).$low>>>0))&2047)>>>0;if(ax<1023){aw=(ay=new $Uint64(2147483648,0),new $Uint64(aw.$high&ay.$high,(aw.$low&ay.$low)>>>0));if(ax===1022){aw=(az=new $Uint64(1072693248,0),new $Uint64(aw.$high|az.$high,(aw.$low|az.$low)>>>0));}}else if(ax<1075){ax=ax-(1023)>>>0;aw=(ba=$shiftRightUint64(new $Uint64(524288,0),ax),new $Uint64(aw.$high+ba.$high,aw.$low+ba.$low));aw=(bb=$shiftRightUint64(new $Uint64(1048575,4294967295),ax),new $Uint64(aw.$high&~bb.$high,(aw.$low&~bb.$low)>>>0));}return HM(aw);};$pkg.Round=EI;EX=function(av,aw){var av,aw;if(GL(av,1)||GL(aw,1)){return GK(1);}else if(GM(av)||GM(aw)){return GW();}else if((av===0)&&(av===aw)){if(GZ(av)){return aw;}return av;}if(av>aw){return av;}return aw;};EY=function(av,aw){var av,aw;if(GL(av,-1)||GL(aw,-1)){return GK(-1);}else if(GM(av)||GM(aw)){return GW();}else if((av===0)&&(av===aw)){if(GZ(av)){return av;}return aw;}if(av>>0)));};$pkg.Abs=FK;GA=function(av){var av;return $parseFloat(FL.cos(av));};$pkg.Cos=GA;GH=function(av){var av;return $parseFloat(FL.floor(av));};$pkg.Floor=GH;GK=function(av){var av;if(av>=0){return FN;}else{return FO;}};$pkg.Inf=GK;GL=function(av,aw){var av,aw;if(av===FN){return aw>=0;}if(av===FO){return aw<=0;}return false;};$pkg.IsInf=GL;GM=function(av){var av,aw;aw=false;aw=!((av===av));return aw;};$pkg.IsNaN=GM;GS=function(av,aw){var av,aw;return EX(av,aw);};$pkg.Max=GS;GT=function(av,aw){var av,aw;return EY(av,aw);};$pkg.Min=GT;GW=function(){return FP;};$pkg.NaN=GW;GX=function(av,aw){var av,aw;if((av===1)||((av===-1)&&((aw===FN)||(aw===FO)))){return 1;}return $parseFloat(FL.pow(av,aw));};$pkg.Pow=GX;GZ=function(av){var av;return av<0||(1/av===FO);};$pkg.Signbit=GZ;HA=function(av){var av;return $parseFloat(FL.sin(av));};$pkg.Sin=HA;HD=function(av){var av;return $parseFloat(FL.sqrt(av));};$pkg.Sqrt=HD;HI=function(){var av;av=new($global.ArrayBuffer)(8);HH.uint32array=new($global.Uint32Array)(av);HH.float32array=new($global.Float32Array)(av);HH.float64array=new($global.Float64Array)(av);};HL=function(av){var av,aw,ax;HH.float64array[0]=av;return(aw=$shiftLeft64((new $Uint64(0,HH.uint32array[1])),32),ax=(new $Uint64(0,HH.uint32array[0])),new $Uint64(aw.$high+ax.$high,aw.$low+ax.$low));};$pkg.Float64bits=HL;HM=function(av){var av;HH.uint32array[0]=((av.$low>>>0));HH.uint32array[1]=(($shiftRightUint64(av,32).$low>>>0));return HH.float64array[0];};$pkg.Float64frombits=HM;$init=function(){$pkg.$init=function(){};var $f,$c=false,$s=0,$r;if(this!==undefined&&this.$blk!==undefined){$f=this;$c=true;$s=$f.$s;$r=$f.$r;}s:while(true){switch($s){case 0:$r=B.$init();$s=1;case 1:if($c){$c=false;$r=$r.$blk();}if($r&&$r.$blk!==undefined){break s;}$r=A.$init();$s=2;case 2:if($c){$c=false;$r=$r.$blk();}if($r&&$r.$blk!==undefined){break s;}HH=new IW.ptr(IT.zero(),IU.zero(),IV.zero());FL=$global.Math;FM=0;FN=1/FM;FO=-1/FM;FP=$parseFloat($NaN);HI();}return;}if($f===undefined){$f={$blk:$init};}$f.$s=$s;$f.$r=$r;return $f;};$pkg.$init=$init;return $pkg;})(); -$packages["resolv"]=(function(){var $pkg={},$init,A,B,C,N,P,Q,S,U,X,Z,AA,AC,AH,AJ,AL,AM,AN,AO,AP,AQ,AR,AS,AT,AU,AV,AW,AX,AY,AZ,BA,BB,BC,BD,K,O,R,T,V,W,Y,AB,AD,AE,AF,AG,AI,AK;A=$packages["math"];B=$pkg.Vector=$newType(12,$kindSlice,"resolv.Vector",true,"resolv",true,null);C=$pkg.Axis=$newType(4,$kindInt,"resolv.Axis",true,"resolv",true,null);N=$pkg.Space=$newType(0,$kindStruct,"resolv.Space",true,"resolv",true,function(Cells_,CellWidth_,CellHeight_){this.$val=this;if(arguments.length===0){this.Cells=AO.nil;this.CellWidth=0;this.CellHeight=0;return;}this.Cells=Cells_;this.CellWidth=CellWidth_;this.CellHeight=CellHeight_;});P=$pkg.Shape=$newType(8,$kindInterface,"resolv.Shape",true,"resolv",true,null);Q=$pkg.Line=$newType(0,$kindStruct,"resolv.Line",true,"resolv",true,function(Start_,End_){this.$val=this;if(arguments.length===0){this.Start=B.nil;this.End=B.nil;return;}this.Start=Start_;this.End=End_;});S=$pkg.ConvexPolygon=$newType(0,$kindStruct,"resolv.ConvexPolygon",true,"resolv",true,function(Points_,X_,Y_,Closed_){this.$val=this;if(arguments.length===0){this.Points=AS.nil;this.X=0;this.Y=0;this.Closed=false;return;}this.Points=Points_;this.X=X_;this.Y=Y_;this.Closed=Closed_;});U=$pkg.ContactSet=$newType(0,$kindStruct,"resolv.ContactSet",true,"resolv",true,function(Points_,MTV_,Center_){this.$val=this;if(arguments.length===0){this.Points=AS.nil;this.MTV=B.nil;this.Center=B.nil;return;}this.Points=Points_;this.MTV=MTV_;this.Center=Center_;});X=$pkg.Circle=$newType(0,$kindStruct,"resolv.Circle",true,"resolv",true,function(X_,Y_,Radius_){this.$val=this;if(arguments.length===0){this.X=0;this.Y=0;this.Radius=0;return;}this.X=X_;this.Y=Y_;this.Radius=Radius_;});Z=$pkg.Projection=$newType(0,$kindStruct,"resolv.Projection",true,"resolv",true,function(Min_,Max_){this.$val=this;if(arguments.length===0){this.Min=0;this.Max=0;return;}this.Min=Min_;this.Max=Max_;});AA=$pkg.RingBuffer=$newType(0,$kindStruct,"resolv.RingBuffer",true,"resolv",true,function(Ed_,St_,EdFrameId_,StFrameId_,N_,Cnt_,Eles_){this.$val=this;if(arguments.length===0){this.Ed=0;this.St=0;this.EdFrameId=0;this.StFrameId=0;this.N=0;this.Cnt=0;this.Eles=AY.nil;return;}this.Ed=Ed_;this.St=St_;this.EdFrameId=EdFrameId_;this.StFrameId=StFrameId_;this.N=N_;this.Cnt=Cnt_;this.Eles=Eles_;});AC=$pkg.Object=$newType(0,$kindStruct,"resolv.Object",true,"resolv",true,function(Shape_,Space_,X_,Y_,W_,H_,TouchingCells_,Data_,ignoreList_,tags_){this.$val=this;if(arguments.length===0){this.Shape=$ifaceNil;this.Space=AP.nil;this.X=0;this.Y=0;this.W=0;this.H=0;this.TouchingCells=AZ.nil;this.Data=$ifaceNil;this.ignoreList=false;this.tags=BA.nil;return;}this.Shape=Shape_;this.Space=Space_;this.X=X_;this.Y=Y_;this.W=W_;this.H=H_;this.TouchingCells=TouchingCells_;this.Data=Data_;this.ignoreList=ignoreList_;this.tags=tags_;});AH=$pkg.Collision=$newType(0,$kindStruct,"resolv.Collision",true,"resolv",true,function(checkingObject_,dx_,dy_,Objects_,Cells_){this.$val=this;if(arguments.length===0){this.checkingObject=AQ.nil;this.dx=0;this.dy=0;this.Objects=AZ.nil;this.Cells=AZ.nil;return;}this.checkingObject=checkingObject_;this.dx=dx_;this.dy=dy_;this.Objects=Objects_;this.Cells=Cells_;});AJ=$pkg.Cell=$newType(0,$kindStruct,"resolv.Cell",true,"resolv",true,function(X_,Y_,Objects_){this.$val=this;if(arguments.length===0){this.X=0;this.Y=0;this.Objects=AZ.nil;return;}this.X=X_;this.Y=Y_;this.Objects=Objects_;});AL=$sliceType($Float64);AM=$ptrType(AJ);AN=$sliceType(AM);AO=$sliceType(AN);AP=$ptrType(N);AQ=$ptrType(AC);AR=$sliceType(AQ);AS=$sliceType(B);AT=$ptrType(Q);AU=$sliceType(AT);AV=$ptrType(X);AW=$ptrType(S);AX=$ptrType(U);AY=$sliceType($emptyInterface);AZ=$ptrType(AA);BA=$sliceType($String);BB=$sliceType(C);BC=$ptrType(AH);BD=$mapType(AQ,$Bool);B.prototype.Clone=function(){var a,b;a=this;b=$makeSlice(B,a.$length);$copySlice(b,a);return b;};$ptrType(B).prototype.Clone=function(){return this.$get().Clone();};B.prototype.Add=function(a){var a,b,c,d,e,f;b=this;c=b.$length;d=a;e=0;while(true){if(!(e=a.$length)?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+f]).$length>c){AF($convertSliceType(b,AL),1,$convertSliceType(b,AL),$convertSliceType($subslice(((f<0||f>=a.$length)?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+f]),0,c),AL));}else{AF($convertSliceType(b,AL),1,$convertSliceType(b,AL),$convertSliceType(((f<0||f>=a.$length)?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+f]),AL));}e++;}return b;};$ptrType(B).prototype.Add=function(a){return this.$get().Add(a);};B.prototype.Sub=function(a){var a,b,c,d,e,f;b=this;c=b.$length;d=a;e=0;while(true){if(!(e=a.$length)?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+f]).$length>c){AF($convertSliceType(b,AL),-1,$convertSliceType($subslice(((f<0||f>=a.$length)?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+f]),0,c),AL),$convertSliceType(b,AL));}else{AF($convertSliceType(b,AL),-1,$convertSliceType(((f<0||f>=a.$length)?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+f]),AL),$convertSliceType(b,AL));}e++;}return b;};$ptrType(B).prototype.Sub=function(a){return this.$get().Sub(a);};B.prototype.Scale=function(a){var a,b;b=this;AG($convertSliceType(b,AL),a,$convertSliceType(b,AL));return b;};$ptrType(B).prototype.Scale=function(a){return this.$get().Scale(a);};B.prototype.Equal=function(a){var a,b,c,d,e;b=this;if(!((b.$length===a.$length))){return false;}c=b;d=0;while(true){if(!(d=b.$length)?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+e])-((e<0||e>=a.$length)?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+e]))>1e-08){return false;}d++;}return true;};$ptrType(B).prototype.Equal=function(a){return this.$get().Equal(a);};B.prototype.Magnitude=function(){var a;a=this;return A.Sqrt(a.Magnitude2());};$ptrType(B).prototype.Magnitude=function(){return this.$get().Magnitude();};B.prototype.Magnitude2=function(){var a,b,c,d,e;a=this;b=0;c=a;d=0;while(true){if(!(d=c.$length)?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+d]);b=b+(e*e);d++;}return b;};$ptrType(B).prototype.Magnitude2=function(){return this.$get().Magnitude2();};B.prototype.Unit=function(){var a,b,c,d,e;a=this;b=a.Magnitude();if(b<1e-08){return a;}c=a;d=0;while(true){if(!(d=a.$length)?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+e]=((e<0||e>=a.$length)?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+e])/b);d++;}return a;};$ptrType(B).prototype.Unit=function(){return this.$get().Unit();};K=function(a,b){var a,b,c,d,e,f,g,h,i,j,k;c=0;d=a.$length;e=b.$length;f=c;g=d;h=e;if(g>h){b=$appendSlice(b,$convertSliceType($makeSlice(B,(g-h>>0)),AL));}if(g>0)),AL));}i=a;j=0;while(true){if(!(j=a.$length)?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+k])*((k<0||k>=b.$length)?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+k]));j++;}return f;};$pkg.Dot=K;B.prototype.Dot=function(a){var a,b;b=this;return K(b,a);};$ptrType(B).prototype.Dot=function(a){return this.$get().Dot(a);};B.prototype.Cross=function(a){var a,b;b=this;if(!((b.$length===3))||!((a.$length===3))){return B.nil;}return new B([(1>=b.$length?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+1])*(2>=a.$length?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+2])-(2>=b.$length?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+2])*(1>=a.$length?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+1]),(2>=b.$length?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+2])*(0>=a.$length?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+0])-(0>=b.$length?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+0])*(2>=a.$length?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+2]),(0>=b.$length?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+0])*(2>=a.$length?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+2])-(2>=b.$length?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+2])*(0>=a.$length?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+0])]);};$ptrType(B).prototype.Cross=function(a){return this.$get().Cross(a);};B.prototype.Rotate=function(a,b){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;c=this;d=2;e=c.$length;f=d;g=e;if(g===0){return c;}if(b.$length>0){f=(0>=b.$length?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+0]);}if((g===1)&&!((f===2))){c=$append(c,0,0);}if((g<2&&(f===2))||((g===2)&&!((f===2)))){c=$append(c,0);}h=(0>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+0]);i=(1>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+1]);j=h;k=i;l=A.Cos(a);m=A.Sin(a);n=l;o=m;p=f;if(p===(0)){q=(2>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+2]);(1>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+1]=k*n-q*o);(2>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+2]=k*o+q*n);}else if(p===(1)){r=(2>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+2]);(0>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+0]=j*n+r*o);(2>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+2]=-j*o+r*n);}else if(p===(2)){(0>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+0]=j*n-k*o);(1>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+1]=j*o+k*n);}if(g>3){return $subslice(c,0,3);}return c;};$ptrType(B).prototype.Rotate=function(a,b){return this.$get().Rotate(a,b);};B.prototype.X=function(){var a;a=this;if(a.$length<1){return 0;}return(0>=a.$length?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+0]);};$ptrType(B).prototype.X=function(){return this.$get().X();};B.prototype.Y=function(){var a;a=this;if(a.$length<2){return 0;}return(1>=a.$length?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+1]);};$ptrType(B).prototype.Y=function(){return this.$get().Y();};B.prototype.Z=function(){var a;a=this;if(a.$length<3){return 0;}return(2>=a.$length?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+2]);};$ptrType(B).prototype.Z=function(){return this.$get().Z();};O=function(a,b,c,d){var a,b,c,d,e,f,g;e=new N.ptr(AO.nil,c,d);e.Resize((f=a/c,(f===f&&f!==1/0&&f!==-1/0)?f>>0:$throwRuntimeError("integer divide by zero")),(g=b/d,(g===g&&g!==1/0&&g!==-1/0)?g>>0:$throwRuntimeError("integer divide by zero")));return e;};$pkg.NewSpace=O;N.ptr.prototype.AddSingle=function(a){var{a,b,$s,$r,$c}=$restore(this,{a});$s=$s||0;s:while(true){switch($s){case 0:b=this;if(b===AP.nil){$panic(new $String("ERROR: space is nil"));}a.Space=b;$r=a.Update();$s=1;case 1:if($c){$c=false;$r=$r.$blk();}if($r&&$r.$blk!==undefined){break s;}$s=-1;return;}return;}var $f={$blk:N.ptr.prototype.AddSingle,$c:true,$r,a,b,$s};return $f;};N.prototype.AddSingle=function(a){return this.$val.AddSingle(a);};N.ptr.prototype.Add=function(a){var{a,b,c,d,e,$s,$r,$c}=$restore(this,{a});$s=$s||0;s:while(true){switch($s){case 0:b=this;if(b===AP.nil){$panic(new $String("ERROR: space is nil"));}c=a;d=0;case 1:if(!(d=c.$length)?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+d]);e.Space=b;$r=e.Update();$s=3;case 3:if($c){$c=false;$r=$r.$blk();}if($r&&$r.$blk!==undefined){break s;}d++;$s=1;continue;case 2:$s=-1;return;}return;}var $f={$blk:N.ptr.prototype.Add,$c:true,$r,a,b,c,d,e,$s};return $f;};N.prototype.Add=function(a){return this.$val.Add(a);};N.ptr.prototype.RemoveSingle=function(a){var a,b,c;b=this;if(b===AP.nil){$panic(new $String("ERROR: space is nil"));}while(true){if(!(0=c.$length)?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+d]);while(true){if(!(0=h.$length)?($throwRuntimeError("index out of range"),undefined):h.$array[h.$offset+f]));i=0;while(true){if(!(i=l.$length)?($throwRuntimeError("index out of range"),undefined):l.$array[l.$offset+f])),((j<0||j>=k.$length)?($throwRuntimeError("index out of range"),undefined):k.$array[k.$offset+j])).Objects;n=m.StFrameId;while(true){if(!(n>0;}i++;}e++;}return c;};N.prototype.Objects=function(){return this.$val.Objects();};N.ptr.prototype.Resize=function(a,b){var a,b,c,d,e,f,g,h;c=this;c.Cells=$makeSlice(AO,b);d=0;while(true){if(!(d=e.$length)?($throwRuntimeError("index out of range"),undefined):e.$array[e.$offset+d]=$makeSlice(AN,a)));f=0;while(true){if(!(f=h.$length)?($throwRuntimeError("index out of range"),undefined):h.$array[h.$offset+d])),((f<0||f>=g.$length)?($throwRuntimeError("index out of range"),undefined):g.$array[g.$offset+f]=AK(f,d)));f=f+(1)>>0;}d=d+(1)>>0;}};N.prototype.Resize=function(a,b){return this.$val.Resize(a,b);};N.ptr.prototype.Cell=function(a,b){var a,b,c,d,e,f;c=this;if(b>=0&&b=0&&a<(d=c.Cells,((b<0||b>=d.$length)?($throwRuntimeError("index out of range"),undefined):d.$array[d.$offset+b])).$length){return(e=(f=c.Cells,((b<0||b>=f.$length)?($throwRuntimeError("index out of range"),undefined):f.$array[f.$offset+b])),((a<0||a>=e.$length)?($throwRuntimeError("index out of range"),undefined):e.$array[e.$offset+a]));}return AM.nil;};N.prototype.Cell=function(a,b){return this.$val.Cell(a,b);};N.ptr.prototype.CheckCells=function(a,b,c,d,e){var a,b,c,d,e,f,g,h,i,j,k,l;f=this;g=a;while(true){if(!(g<(a+c>>0))){break;}h=b;while(true){if(!(h<(b+d>>0))){break;}i=f.Cell(g,h);if(!(i===AM.nil)){j=i.Objects;if(e.$length>0){if(i.ContainsTags(e)){k=j.StFrameId;while(true){if(!(k>0;}}}else if(i.Occupied()){return $assertType(j.GetByFrameId(j.StFrameId),AQ);}}h=h+(1)>>0;}g=g+(1)>>0;}return AQ.nil;};N.prototype.CheckCells=function(a,b,c,d,e){return this.$val.CheckCells(a,b,c,d,e);};N.ptr.prototype.CheckCellsWorld=function(a,b,c,d,e){var a,b,c,d,e,f,g,h,i,j,k,l;f=this;g=f.WorldToSpace(a,b);h=g[0];i=g[1];j=f.WorldToSpace(c,d);k=j[0];l=j[1];return f.CheckCells(h,i,k,l,e);};N.prototype.CheckCellsWorld=function(a,b,c,d,e){return this.$val.CheckCellsWorld(a,b,c,d,e);};N.ptr.prototype.UnregisterAllObjects=function(){var a,b,c,d,e,f,g,h,i,j;a=this;b=0;while(true){if(!(b=d.$length)?($throwRuntimeError("index out of range"),undefined):d.$array[d.$offset+b])).$length)){break;}g=(e=(f=a.Cells,((b<0||b>=f.$length)?($throwRuntimeError("index out of range"),undefined):f.$array[f.$offset+b])),((c<0||c>=e.$length)?($throwRuntimeError("index out of range"),undefined):e.$array[e.$offset+c]));h=g.Objects;i=h.StFrameId;while(true){if(!(i>0;}c=c+(1)>>0;}b=b+(1)>>0;}};N.prototype.UnregisterAllObjects=function(){return this.$val.UnregisterAllObjects();};N.ptr.prototype.WorldToSpace=function(a,b){var a,b,c,d,e;c=this;d=((A.Floor(a/(c.CellWidth))>>0));e=((A.Floor(b/(c.CellHeight))>>0));return[d,e];};N.prototype.WorldToSpace=function(a,b){return this.$val.WorldToSpace(a,b);};N.ptr.prototype.SpaceToWorld=function(a,b){var a,b,c,d,e;c=this;d=(($imul(a,c.CellWidth)));e=(($imul(b,c.CellHeight)));return[d,e];};N.prototype.SpaceToWorld=function(a,b){return this.$val.SpaceToWorld(a,b);};N.ptr.prototype.Height=function(){var a;a=this;return a.Cells.$length;};N.prototype.Height=function(){return this.$val.Height();};N.ptr.prototype.Width=function(){var a,b;a=this;if(a.Cells.$length>0){return(b=a.Cells,(0>=b.$length?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+0])).$length;}return 0;};N.prototype.Width=function(){return this.$val.Width();};N.ptr.prototype.CellsInLine=function(a,b,c,d){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v;e=this;f=new AN([]);g=e.Cell(a,b);h=e.Cell(c,d);if(!(g===AM.nil)&&!(h===AM.nil)){i=new B([((c-a>>0)),((d-b>>0))]).Unit();(0>=i.$length?($throwRuntimeError("index out of range"),undefined):i.$array[i.$offset+0]=(0>=i.$length?($throwRuntimeError("index out of range"),undefined):i.$array[i.$offset+0])*(((j=e.CellWidth/2,(j===j&&j!==1/0&&j!==-1/0)?j>>0:$throwRuntimeError("integer divide by zero")))));(1>=i.$length?($throwRuntimeError("index out of range"),undefined):i.$array[i.$offset+1]=(1>=i.$length?($throwRuntimeError("index out of range"),undefined):i.$array[i.$offset+1])*(((k=e.CellHeight/2,(k===k&&k!==1/0&&k!==-1/0)?k>>0:$throwRuntimeError("integer divide by zero")))));l=e.SpaceToWorld(a,b);m=l[0];n=l[1];q=new B([m+((o=e.CellWidth/2,(o===o&&o!==1/0&&o!==-1/0)?o>>0:$throwRuntimeError("integer divide by zero"))),n+((p=e.CellHeight/2,(p===p&&p!==1/0&&p!==-1/0)?p>>0:$throwRuntimeError("integer divide by zero")))]);r=false;while(true){if(!(!(g===AM.nil))){break;}if(g===h){f=$append(f,g);break;}f=$append(f,g);if(r){(1>=q.$length?($throwRuntimeError("index out of range"),undefined):q.$array[q.$offset+1]=(1>=q.$length?($throwRuntimeError("index out of range"),undefined):q.$array[q.$offset+1])+((1>=i.$length?($throwRuntimeError("index out of range"),undefined):i.$array[i.$offset+1])));}else{(0>=q.$length?($throwRuntimeError("index out of range"),undefined):q.$array[q.$offset+0]=(0>=q.$length?($throwRuntimeError("index out of range"),undefined):q.$array[q.$offset+0])+((0>=i.$length?($throwRuntimeError("index out of range"),undefined):i.$array[i.$offset+0])));}s=e.WorldToSpace((0>=q.$length?($throwRuntimeError("index out of range"),undefined):q.$array[q.$offset+0]),(1>=q.$length?($throwRuntimeError("index out of range"),undefined):q.$array[q.$offset+1]));t=s[0];u=s[1];v=e.Cell(t,u);if(!(v===g)){g=v;}r=!r;}}return f;};N.prototype.CellsInLine=function(a,b,c,d){return this.$val.CellsInLine(a,b,c,d);};R=function(a,b,c,d){var a,b,c,d;return new Q.ptr(new B([a,b]),new B([c,d]));};$pkg.NewLine=R;Q.ptr.prototype.Project=function(a){var a,b;b=this;return b.Vector().Scale(a.Dot(b.Start.Sub(new AS([b.End]))));};Q.prototype.Project=function(a){return this.$val.Project(a);};Q.ptr.prototype.Normal=function(){var a,b,c,d,e,f,g;a=this;d=(b=a.End,(1>=b.$length?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+1]))-(c=a.Start,(1>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+1]));g=(e=a.End,(0>=e.$length?($throwRuntimeError("index out of range"),undefined):e.$array[e.$offset+0]))-(f=a.Start,(0>=f.$length?($throwRuntimeError("index out of range"),undefined):f.$array[f.$offset+0]));return new B([d,-g]).Unit();};Q.prototype.Normal=function(){return this.$val.Normal();};Q.ptr.prototype.Vector=function(){var a;a=this;return a.End.Clone().Sub(new AS([a.Start])).Unit();};Q.prototype.Vector=function(){return this.$val.Vector();};Q.ptr.prototype.IntersectionPointsLine=function(a){var a,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;b=this;k=((c=b.End,(0>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+0]))-(d=b.Start,(0>=d.$length?($throwRuntimeError("index out of range"),undefined):d.$array[d.$offset+0])))*((e=a.End,(1>=e.$length?($throwRuntimeError("index out of range"),undefined):e.$array[e.$offset+1]))-(f=a.Start,(1>=f.$length?($throwRuntimeError("index out of range"),undefined):f.$array[f.$offset+1])))-((g=a.End,(0>=g.$length?($throwRuntimeError("index out of range"),undefined):g.$array[g.$offset+0]))-(h=a.Start,(0>=h.$length?($throwRuntimeError("index out of range"),undefined):h.$array[h.$offset+0])))*((i=b.End,(1>=i.$length?($throwRuntimeError("index out of range"),undefined):i.$array[i.$offset+1]))-(j=b.Start,(1>=j.$length?($throwRuntimeError("index out of range"),undefined):j.$array[j.$offset+1])));if(!((k===0))){t=((((l=b.Start,(1>=l.$length?($throwRuntimeError("index out of range"),undefined):l.$array[l.$offset+1]))-(m=a.Start,(1>=m.$length?($throwRuntimeError("index out of range"),undefined):m.$array[m.$offset+1])))*((n=a.End,(0>=n.$length?($throwRuntimeError("index out of range"),undefined):n.$array[n.$offset+0]))-(o=a.Start,(0>=o.$length?($throwRuntimeError("index out of range"),undefined):o.$array[o.$offset+0]))))-(((p=b.Start,(0>=p.$length?($throwRuntimeError("index out of range"),undefined):p.$array[p.$offset+0]))-(q=a.Start,(0>=q.$length?($throwRuntimeError("index out of range"),undefined):q.$array[q.$offset+0])))*((r=a.End,(1>=r.$length?($throwRuntimeError("index out of range"),undefined):r.$array[r.$offset+1]))-(s=a.Start,(1>=s.$length?($throwRuntimeError("index out of range"),undefined):s.$array[s.$offset+1]))))+1)/k;ac=((((u=b.Start,(1>=u.$length?($throwRuntimeError("index out of range"),undefined):u.$array[u.$offset+1]))-(v=a.Start,(1>=v.$length?($throwRuntimeError("index out of range"),undefined):v.$array[v.$offset+1])))*((w=b.End,(0>=w.$length?($throwRuntimeError("index out of range"),undefined):w.$array[w.$offset+0]))-(x=b.Start,(0>=x.$length?($throwRuntimeError("index out of range"),undefined):x.$array[x.$offset+0]))))-(((y=b.Start,(0>=y.$length?($throwRuntimeError("index out of range"),undefined):y.$array[y.$offset+0]))-(z=a.Start,(0>=z.$length?($throwRuntimeError("index out of range"),undefined):z.$array[z.$offset+0])))*((aa=b.End,(1>=aa.$length?($throwRuntimeError("index out of range"),undefined):aa.$array[aa.$offset+1]))-(ab=b.Start,(1>=ab.$length?($throwRuntimeError("index out of range"),undefined):ab.$array[ab.$offset+1]))))+1)/k;if((0=ad.$length?($throwRuntimeError("index out of range"),undefined):ad.$array[ad.$offset+0]))-(ae=b.Start,(0>=ae.$length?($throwRuntimeError("index out of range"),undefined):ae.$array[ae.$offset+0]));ai=(ag=b.End,(1>=ag.$length?($throwRuntimeError("index out of range"),undefined):ag.$array[ag.$offset+1]))-(ah=b.Start,(1>=ah.$length?($throwRuntimeError("index out of range"),undefined):ah.$array[ah.$offset+1]));return new B([(aj=b.Start,(0>=aj.$length?($throwRuntimeError("index out of range"),undefined):aj.$array[aj.$offset+0]))+(t*af),(ak=b.Start,(1>=ak.$length?($throwRuntimeError("index out of range"),undefined):ak.$array[ak.$offset+1]))+(t*ai)]);}}return B.nil;};Q.prototype.IntersectionPointsLine=function(a){return this.$val.IntersectionPointsLine(a);};Q.ptr.prototype.IntersectionPointsCircle=function(a){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;b=this;c=new AS([]);d=new B([a.X,a.Y]);e=b.Start.Sub(new AS([d]));f=b.End.Sub(new AS([d]));g=f.Sub(new AS([e]));h=(0>=g.$length?($throwRuntimeError("index out of range"),undefined):g.$array[g.$offset+0])*(0>=g.$length?($throwRuntimeError("index out of range"),undefined):g.$array[g.$offset+0])+(1>=g.$length?($throwRuntimeError("index out of range"),undefined):g.$array[g.$offset+1])*(1>=g.$length?($throwRuntimeError("index out of range"),undefined):g.$array[g.$offset+1]);i=2*(((0>=g.$length?($throwRuntimeError("index out of range"),undefined):g.$array[g.$offset+0])*(0>=e.$length?($throwRuntimeError("index out of range"),undefined):e.$array[e.$offset+0]))+((1>=g.$length?($throwRuntimeError("index out of range"),undefined):g.$array[g.$offset+1])*(1>=e.$length?($throwRuntimeError("index out of range"),undefined):e.$array[e.$offset+1])));j=((0>=e.$length?($throwRuntimeError("index out of range"),undefined):e.$array[e.$offset+0])*(0>=e.$length?($throwRuntimeError("index out of range"),undefined):e.$array[e.$offset+0]))+((1>=e.$length?($throwRuntimeError("index out of range"),undefined):e.$array[e.$offset+1])*(1>=e.$length?($throwRuntimeError("index out of range"),undefined):e.$array[e.$offset+1]))-(a.Radius*a.Radius);k=i*i-(4*h*j);if(k<0){}else if(k===0){l=-i/(2*h);if(l>=0&&l<=1){c=$append(c,new B([(m=b.Start,(0>=m.$length?($throwRuntimeError("index out of range"),undefined):m.$array[m.$offset+0]))+l*(0>=g.$length?($throwRuntimeError("index out of range"),undefined):g.$array[g.$offset+0]),(n=b.Start,(1>=n.$length?($throwRuntimeError("index out of range"),undefined):n.$array[n.$offset+1]))+l*(1>=g.$length?($throwRuntimeError("index out of range"),undefined):g.$array[g.$offset+1])]));}}else{o=(-i+A.Sqrt(k))/(2*h);if(o>=0&&o<=1){c=$append(c,new B([(p=b.Start,(0>=p.$length?($throwRuntimeError("index out of range"),undefined):p.$array[p.$offset+0]))+o*(0>=g.$length?($throwRuntimeError("index out of range"),undefined):g.$array[g.$offset+0]),(q=b.Start,(1>=q.$length?($throwRuntimeError("index out of range"),undefined):q.$array[q.$offset+1]))+o*(1>=g.$length?($throwRuntimeError("index out of range"),undefined):g.$array[g.$offset+1])]));}o=(-i-A.Sqrt(k))/(2*h);if(o>=0&&o<=1){c=$append(c,new B([(r=b.Start,(0>=r.$length?($throwRuntimeError("index out of range"),undefined):r.$array[r.$offset+0]))+o*(0>=g.$length?($throwRuntimeError("index out of range"),undefined):g.$array[g.$offset+0]),(s=b.Start,(1>=s.$length?($throwRuntimeError("index out of range"),undefined):s.$array[s.$offset+1]))+o*(1>=g.$length?($throwRuntimeError("index out of range"),undefined):g.$array[g.$offset+1])]));}}return c;};Q.prototype.IntersectionPointsCircle=function(a){return this.$val.IntersectionPointsCircle(a);};T=function(a){var a,b;b=new S.ptr(new AS([]),0,0,true);b.AddPoints(a);return b;};$pkg.NewConvexPolygon=T;S.ptr.prototype.Clone=function(){var a,b,c,d,e,f;a=this;b=new AS([]);c=a.Points;d=0;while(true){if(!(d=c.$length)?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+d]);b=$append(b,e.Clone());d++;}f=T(AL.nil);f.X=a.X;f.Y=a.Y;f.AddPointsVec(b);f.Closed=a.Closed;return f;};S.prototype.Clone=function(){return this.$val.Clone();};S.ptr.prototype.AddPointsVec=function(a){var a,b;b=this;b.Points=$appendSlice(b.Points,a);};S.prototype.AddPointsVec=function(a){return this.$val.AddPointsVec(a);};S.ptr.prototype.AddPoints=function(a){var a,b,c,d;b=this;c=0;while(true){if(!(c=a.$length)?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+c]),(d=c+1>>0,((d<0||d>=a.$length)?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+d]))]));c=c+(2)>>0;}};S.prototype.AddPoints=function(a){return this.$val.AddPoints(a);};S.ptr.prototype.Lines=function(){var a,b,c,d,e,f,g,h,i,j,k;a=this;b=a.Transformed();c=b.$length;if(!a.Closed){c=c-(1)>>0;}d=$makeSlice(AU,c);e=0;while(true){if(!(e=b.$length)?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+e]);g=(0>=b.$length?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+0]);h=f;i=g;if(e<(b.$length-1>>0)){i=(j=e+1>>0,((j<0||j>=b.$length)?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+j]));}k=R((0>=h.$length?($throwRuntimeError("index out of range"),undefined):h.$array[h.$offset+0]),(1>=h.$length?($throwRuntimeError("index out of range"),undefined):h.$array[h.$offset+1]),(0>=i.$length?($throwRuntimeError("index out of range"),undefined):i.$array[i.$offset+0]),(1>=i.$length?($throwRuntimeError("index out of range"),undefined):i.$array[i.$offset+1]));((e<0||e>=d.$length)?($throwRuntimeError("index out of range"),undefined):d.$array[d.$offset+e]=k);e=e+(1)>>0;}return d;};S.prototype.Lines=function(){return this.$val.Lines();};S.ptr.prototype.Transformed=function(){var a,b,c,d,e,f;a=this;b=$makeSlice(AS,a.Points.$length);c=a.Points;d=0;while(true){if(!(d=c.$length)?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+d]);((e<0||e>=b.$length)?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+e]=new B([(0>=f.$length?($throwRuntimeError("index out of range"),undefined):f.$array[f.$offset+0])+a.X,(1>=f.$length?($throwRuntimeError("index out of range"),undefined):f.$array[f.$offset+1])+a.Y]));d++;}return b;};S.prototype.Transformed=function(){return this.$val.Transformed();};S.ptr.prototype.Bounds=function(){var a,b,c,d,e,f,g,h;a=this;b=a.Transformed();e=new B([(c=(0>=b.$length?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+0]),(0>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+0])),(d=(0>=b.$length?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+0]),(1>=d.$length?($throwRuntimeError("index out of range"),undefined):d.$array[d.$offset+1]))]);f=e.Clone();g=0;while(true){if(!(g=b.$length)?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+g]);if((0>=h.$length?($throwRuntimeError("index out of range"),undefined):h.$array[h.$offset+0])<(0>=e.$length?($throwRuntimeError("index out of range"),undefined):e.$array[e.$offset+0])){(0>=e.$length?($throwRuntimeError("index out of range"),undefined):e.$array[e.$offset+0]=(0>=h.$length?($throwRuntimeError("index out of range"),undefined):h.$array[h.$offset+0]));}else if((0>=h.$length?($throwRuntimeError("index out of range"),undefined):h.$array[h.$offset+0])>(0>=f.$length?($throwRuntimeError("index out of range"),undefined):f.$array[f.$offset+0])){(0>=f.$length?($throwRuntimeError("index out of range"),undefined):f.$array[f.$offset+0]=(0>=h.$length?($throwRuntimeError("index out of range"),undefined):h.$array[h.$offset+0]));}if((1>=h.$length?($throwRuntimeError("index out of range"),undefined):h.$array[h.$offset+1])<(1>=e.$length?($throwRuntimeError("index out of range"),undefined):e.$array[e.$offset+1])){(1>=e.$length?($throwRuntimeError("index out of range"),undefined):e.$array[e.$offset+1]=(1>=h.$length?($throwRuntimeError("index out of range"),undefined):h.$array[h.$offset+1]));}else if((1>=h.$length?($throwRuntimeError("index out of range"),undefined):h.$array[h.$offset+1])>(1>=f.$length?($throwRuntimeError("index out of range"),undefined):f.$array[f.$offset+1])){(1>=f.$length?($throwRuntimeError("index out of range"),undefined):f.$array[f.$offset+1]=(1>=h.$length?($throwRuntimeError("index out of range"),undefined):h.$array[h.$offset+1]));}g=g+(1)>>0;}return[e,f];};S.prototype.Bounds=function(){return this.$val.Bounds();};S.ptr.prototype.Position=function(){var a;a=this;return[a.X,a.Y];};S.prototype.Position=function(){return this.$val.Position();};S.ptr.prototype.SetPosition=function(a,b){var a,b,c;c=this;c.X=a;c.Y=b;};S.prototype.SetPosition=function(a,b){return this.$val.SetPosition(a,b);};S.ptr.prototype.SetPositionVec=function(a){var a,b;b=this;b.X=a.X();b.Y=a.Y();};S.prototype.SetPositionVec=function(a){return this.$val.SetPositionVec(a);};S.ptr.prototype.Move=function(a,b){var a,b,c;c=this;c.X=c.X+(a);c.Y=c.Y+(b);};S.prototype.Move=function(a,b){return this.$val.Move(a,b);};S.ptr.prototype.MoveVec=function(a){var a,b;b=this;b.X=b.X+(a.X());b.Y=b.Y+(a.Y());};S.prototype.MoveVec=function(a){return this.$val.MoveVec(a);};S.ptr.prototype.Center=function(){var a,b,c,d,e,f,g;a=this;b=new B([0,0]);c=a.Transformed();d=c;e=0;while(true){if(!(e=d.$length)?($throwRuntimeError("index out of range"),undefined):d.$array[d.$offset+e]);b.Add(new AS([f]));e++;}g=(c.$length);(0>=b.$length?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+0]=(0>=b.$length?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+0])/(g));(1>=b.$length?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+1]=(1>=b.$length?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+1])/(g));return b;};S.prototype.Center=function(){return this.$val.Center();};S.ptr.prototype.Project=function(a){var a,b,c,d,e,f,g,h,i,j,k;b=this;a=a.Unit();c=b.Transformed();f=a.Dot(new B([(d=(0>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+0]),(0>=d.$length?($throwRuntimeError("index out of range"),undefined):d.$array[d.$offset+0])),(e=(0>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+0]),(1>=e.$length?($throwRuntimeError("index out of range"),undefined):e.$array[e.$offset+1]))]));g=f;h=1;while(true){if(!(h=c.$length)?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+h]),(0>=i.$length?($throwRuntimeError("index out of range"),undefined):i.$array[i.$offset+0])),(j=((h<0||h>=c.$length)?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+h]),(1>=j.$length?($throwRuntimeError("index out of range"),undefined):j.$array[j.$offset+1]))]));if(kg){g=k;}h=h+(1)>>0;}return new Z.ptr(f,g);};S.prototype.Project=function(a){return this.$val.Project(a);};S.ptr.prototype.SATAxes=function(){var a,b,c,d,e,f,g;a=this;b=a.Lines();c=$makeSlice(AS,b.$length);d=b;e=0;while(true){if(!(e=d.$length)?($throwRuntimeError("index out of range"),undefined):d.$array[d.$offset+e]);((f<0||f>=c.$length)?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+f]=g.Normal());e++;}return c;};S.prototype.SATAxes=function(){return this.$val.SATAxes();};S.ptr.prototype.PointInside=function(a){var a,b,c,d,e,f,g;b=this;c=R((0>=a.$length?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+0]),(1>=a.$length?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+1]),(0>=a.$length?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+0])+9.99999999999e+11,(1>=a.$length?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+1]));d=0;e=b.Lines();f=0;while(true){if(!(f=e.$length)?($throwRuntimeError("index out of range"),undefined):e.$array[e.$offset+f]);if(!(g.IntersectionPointsLine(c)===B.nil)){d=d+(1)>>0;}f++;}return d===1;};S.prototype.PointInside=function(a){return this.$val.PointInside(a);};V=function(){return new U.ptr(new AS([]),new B([0,0]),new B([0,0]));};$pkg.NewContactSet=V;U.ptr.prototype.LeftmostPoint=function(){var a,b,c,d,e;a=this;b=B.nil;c=a.Points;d=0;while(true){if(!(d=c.$length)?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+d]);if(b===B.nil||(0>=e.$length?($throwRuntimeError("index out of range"),undefined):e.$array[e.$offset+0])<(0>=b.$length?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+0])){b=e;}d++;}return b;};U.prototype.LeftmostPoint=function(){return this.$val.LeftmostPoint();};U.ptr.prototype.RightmostPoint=function(){var a,b,c,d,e;a=this;b=B.nil;c=a.Points;d=0;while(true){if(!(d=c.$length)?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+d]);if(b===B.nil||(0>=e.$length?($throwRuntimeError("index out of range"),undefined):e.$array[e.$offset+0])>(0>=b.$length?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+0])){b=e;}d++;}return b;};U.prototype.RightmostPoint=function(){return this.$val.RightmostPoint();};U.ptr.prototype.TopmostPoint=function(){var a,b,c,d,e;a=this;b=B.nil;c=a.Points;d=0;while(true){if(!(d=c.$length)?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+d]);if(b===B.nil||(1>=e.$length?($throwRuntimeError("index out of range"),undefined):e.$array[e.$offset+1])<(1>=b.$length?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+1])){b=e;}d++;}return b;};U.prototype.TopmostPoint=function(){return this.$val.TopmostPoint();};U.ptr.prototype.BottommostPoint=function(){var a,b,c,d,e;a=this;b=B.nil;c=a.Points;d=0;while(true){if(!(d=c.$length)?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+d]);if(b===B.nil||(1>=e.$length?($throwRuntimeError("index out of range"),undefined):e.$array[e.$offset+1])>(1>=b.$length?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+1])){b=e;}d++;}return b;};U.prototype.BottommostPoint=function(){return this.$val.BottommostPoint();};S.ptr.prototype.Intersection=function(a,b,c){var a,aa,ab,ac,ad,ae,af,ag,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;d=this;e=V();f=d.X;g=d.Y;d.X=d.X+(a);d.Y=d.Y+(b);h=$assertType(c,AV,true);i=h[0];j=h[1];if(j){k=d.Lines();l=0;while(true){if(!(l=k.$length)?($throwRuntimeError("index out of range"),undefined):k.$array[k.$offset+l]);e.Points=$appendSlice(e.Points,m.IntersectionPointsCircle(i));l++;}}else{n=$assertType(c,AW,true);o=n[0];p=n[1];if(p){q=d.Lines();r=0;while(true){if(!(r=q.$length)?($throwRuntimeError("index out of range"),undefined):q.$array[q.$offset+r]);t=o.Lines();u=0;while(true){if(!(u=t.$length)?($throwRuntimeError("index out of range"),undefined):t.$array[t.$offset+u]);w=s.IntersectionPointsLine(v);if(!(w===B.nil)){e.Points=$append(e.Points,w);}u++;}r++;}}}if(e.Points.$length>0){x=e.Points;y=0;while(true){if(!(y=x.$length)?($throwRuntimeError("index out of range"),undefined):x.$array[x.$offset+y]);e.Center=e.Center.Add(new AS([z]));y++;}(ab=e.Center,(0>=ab.$length?($throwRuntimeError("index out of range"),undefined):ab.$array[ab.$offset+0]=(aa=e.Center,(0>=aa.$length?($throwRuntimeError("index out of range"),undefined):aa.$array[aa.$offset+0]))/((e.Points.$length))));(ad=e.Center,(1>=ad.$length?($throwRuntimeError("index out of range"),undefined):ad.$array[ad.$offset+1]=(ac=e.Center,(1>=ac.$length?($throwRuntimeError("index out of range"),undefined):ac.$array[ac.$offset+1]))/((e.Points.$length))));ae=d.calculateMTV(e,c);if(!(ae===B.nil)){e.MTV=ae;}}else{e=AX.nil;}if(!(e===AX.nil)&&(!((a===0))||!((b===0)))){af=new B([a,b]).Magnitude();ag=e.MTV.Magnitude();e.MTV=e.MTV.Unit().Scale(ag-af);}d.X=f;d.Y=g;return e;};S.prototype.Intersection=function(a,b,c){return this.$val.Intersection(a,b,c);};S.ptr.prototype.calculateMTV=function(a,b){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o;c=this;d=new B([0,0]);e=new B([1.7976931348623157e+308,0]);f=b;if($assertType(f,AW,true)[1]){g=f.$val;h=c.SATAxes();i=0;while(true){if(!(i=h.$length)?($throwRuntimeError("index out of range"),undefined):h.$array[h.$offset+i]);if(!$clone(c.Project(j),Z).Overlapping($clone(g.Project(j),Z))){return B.nil;}k=$clone(c.Project(j),Z).Overlap($clone(g.Project(j),Z));if(e.Magnitude()>k){e=j.Scale(k);}i++;}l=g.SATAxes();m=0;while(true){if(!(m=l.$length)?($throwRuntimeError("index out of range"),undefined):l.$array[l.$offset+m]);if(!$clone(c.Project(n),Z).Overlapping($clone(g.Project(n),Z))){return B.nil;}o=$clone(c.Project(n),Z).Overlap($clone(g.Project(n),Z));if(e.Magnitude()>o){e=n.Scale(o);}m++;}}(0>=d.$length?($throwRuntimeError("index out of range"),undefined):d.$array[d.$offset+0]=(0>=e.$length?($throwRuntimeError("index out of range"),undefined):e.$array[e.$offset+0]));(1>=d.$length?($throwRuntimeError("index out of range"),undefined):d.$array[d.$offset+1]=(1>=e.$length?($throwRuntimeError("index out of range"),undefined):e.$array[e.$offset+1]));return d;};S.prototype.calculateMTV=function(a,b){return this.$val.calculateMTV(a,b);};S.ptr.prototype.ContainedBy=function(a){var a,b,c,d,e,f,g,h,i,j;b=this;c=a;if($assertType(c,AW,true)[1]){d=c.$val;e=b.SATAxes();f=0;while(true){if(!(f=e.$length)?($throwRuntimeError("index out of range"),undefined):e.$array[e.$offset+f]);if(!$clone(b.Project(g),Z).IsInside($clone(d.Project(g),Z))){return false;}f++;}h=d.SATAxes();i=0;while(true){if(!(i=h.$length)?($throwRuntimeError("index out of range"),undefined):h.$array[h.$offset+i]);if(!$clone(b.Project(j),Z).IsInside($clone(d.Project(j),Z))){return false;}i++;}}return true;};S.prototype.ContainedBy=function(a){return this.$val.ContainedBy(a);};S.ptr.prototype.FlipH=function(){var a,b,c,d;a=this;b=a.Points;c=0;while(true){if(!(c=b.$length)?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+c]);(0>=d.$length?($throwRuntimeError("index out of range"),undefined):d.$array[d.$offset+0]=-(0>=d.$length?($throwRuntimeError("index out of range"),undefined):d.$array[d.$offset+0]));c++;}a.ReverseVertexOrder();};S.prototype.FlipH=function(){return this.$val.FlipH();};S.ptr.prototype.FlipV=function(){var a,b,c,d;a=this;b=a.Points;c=0;while(true){if(!(c=b.$length)?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+c]);(1>=d.$length?($throwRuntimeError("index out of range"),undefined):d.$array[d.$offset+1]=-(1>=d.$length?($throwRuntimeError("index out of range"),undefined):d.$array[d.$offset+1]));c++;}a.ReverseVertexOrder();};S.prototype.FlipV=function(){return this.$val.FlipV();};S.ptr.prototype.ReverseVertexOrder=function(){var a,b,c,d,e;a=this;c=new AS([(b=a.Points,(0>=b.$length?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+0]))]);d=a.Points.$length-1>>0;while(true){if(!(d>=1)){break;}c=$append(c,(e=a.Points,((d<0||d>=e.$length)?($throwRuntimeError("index out of range"),undefined):e.$array[e.$offset+d])));d=d-(1)>>0;}a.Points=c;};S.prototype.ReverseVertexOrder=function(){return this.$val.ReverseVertexOrder();};W=function(a,b,c,d){var a,b,c,d;return T(new AL([a,b,a+c,b,a+c,b+d,a,b+d]));};$pkg.NewRectangle=W;Y=function(a,b,c){var a,b,c,d;d=new X.ptr(a,b,c);return d;};$pkg.NewCircle=Y;X.ptr.prototype.Clone=function(){var a;a=this;return Y(a.X,a.Y,a.Radius);};X.prototype.Clone=function(){return this.$val.Clone();};X.ptr.prototype.Bounds=function(){var a;a=this;return[new B([a.X-a.Radius,a.Y-a.Radius]),new B([a.X+a.Radius,a.Y+a.Radius])];};X.prototype.Bounds=function(){return this.$val.Bounds();};X.ptr.prototype.Intersection=function(a,b,c){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;d=this;e=AX.nil;f=d.X;g=d.Y;d.X=d.X+(a);d.Y=d.Y+(b);h=c;if($assertType(h,AW,true)[1]){i=h.$val;e=i.Intersection(-a,-b,d);if(!(e===AX.nil)){e.MTV=e.MTV.Scale(-1);}}else if($assertType(h,AV,true)[1]){j=h.$val;e=V();e.Points=d.IntersectionPointsCircle(j);if(e.Points.$length===0){return AX.nil;}e.MTV=new B([d.X-j.X,d.Y-j.Y]);k=e.MTV.Magnitude();e.MTV=e.MTV.Unit().Scale(d.Radius+j.Radius-k);l=e.Points;m=0;while(true){if(!(m=l.$length)?($throwRuntimeError("index out of range"),undefined):l.$array[l.$offset+m]);e.Center=e.Center.Add(new AS([n]));m++;}(p=e.Center,(0>=p.$length?($throwRuntimeError("index out of range"),undefined):p.$array[p.$offset+0]=(o=e.Center,(0>=o.$length?($throwRuntimeError("index out of range"),undefined):o.$array[o.$offset+0]))/((e.Points.$length))));(r=e.Center,(1>=r.$length?($throwRuntimeError("index out of range"),undefined):r.$array[r.$offset+1]=(q=e.Center,(1>=q.$length?($throwRuntimeError("index out of range"),undefined):q.$array[q.$offset+1]))/((e.Points.$length))));}d.X=f;d.Y=g;return e;};X.prototype.Intersection=function(a,b,c){return this.$val.Intersection(a,b,c);};X.ptr.prototype.Move=function(a,b){var a,b,c;c=this;c.X=c.X+(a);c.Y=c.Y+(b);};X.prototype.Move=function(a,b){return this.$val.Move(a,b);};X.ptr.prototype.MoveVec=function(a){var a,b;b=this;b.X=b.X+(a.X());b.Y=b.Y+(a.Y());};X.prototype.MoveVec=function(a){return this.$val.MoveVec(a);};X.ptr.prototype.SetPosition=function(a,b){var a,b,c;c=this;c.X=a;c.Y=b;};X.prototype.SetPosition=function(a,b){return this.$val.SetPosition(a,b);};X.ptr.prototype.SetPositionVec=function(a){var a,b;b=this;b.X=a.X();b.Y=a.Y();};X.prototype.SetPositionVec=function(a){return this.$val.SetPositionVec(a);};X.ptr.prototype.Position=function(){var a;a=this;return[a.X,a.Y];};X.prototype.Position=function(){return this.$val.Position();};X.ptr.prototype.PointInside=function(a){var a,b;b=this;return a.Sub(new AS([new B([b.X,b.Y])])).Magnitude()<=b.Radius;};X.prototype.PointInside=function(a){return this.$val.PointInside(a);};X.ptr.prototype.IntersectionPointsCircle=function(a){var a,b,c,d,e,f,g;b=this;c=A.Sqrt(A.Pow(a.X-b.X,2)+A.Pow(a.Y-b.Y,2));if(c>b.Radius+a.Radius||c0;};Z.prototype.Overlapping=function(a){return this.$val.Overlapping(a);};Z.ptr.prototype.Overlap=function(a){var a,b;b=this;return A.Min(b.Max,a.Max)-A.Max(b.Min,a.Min);};Z.prototype.Overlap=function(a){return this.$val.Overlap(a);};Z.ptr.prototype.IsInside=function(a){var a,b;b=this;return b.Min>=a.Min&&b.Max<=a.Max;};Z.prototype.IsInside=function(a){return this.$val.IsInside(a);};AB=function(a){var a;return new AA.ptr(0,0,0,0,a,0,$makeSlice(AY,a));};$pkg.NewRingBuffer=AB;AA.ptr.prototype.Put=function(a){var a,b,c,d;b=this;while(true){if(!(0=b.N)){break;}b.Pop();}(c=b.Eles,d=b.Ed,((d<0||d>=c.$length)?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+d]=a));b.EdFrameId=b.EdFrameId+(1)>>0;b.Cnt=b.Cnt+(1)>>0;b.Ed=b.Ed+(1)>>0;if(b.Ed>=b.N){b.Ed=b.Ed-(b.N)>>0;}};AA.prototype.Put=function(a){return this.$val.Put(a);};AA.ptr.prototype.Pop=function(){var a,b,c,d;a=this;if(0===a.Cnt){return $ifaceNil;}d=(b=a.Eles,c=a.St,((c<0||c>=b.$length)?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+c]));a.StFrameId=a.StFrameId+(1)>>0;a.Cnt=a.Cnt-(1)>>0;a.St=a.St+(1)>>0;if(a.St>=a.N){a.St=a.St-(a.N)>>0;}return d;};AA.prototype.Pop=function(){return this.$val.Pop();};AA.ptr.prototype.GetArrIdxByOffset=function(a){var a,b,c;b=this;if((0===b.Cnt)||0>a){return-1;}c=b.St+a>>0;if(b.St=b.N){c=c-(b.N)>>0;}if(c>=b.St||c=d.$length)?($throwRuntimeError("index out of range"),undefined):d.$array[d.$offset+c]));};AA.prototype.GetByOffset=function(a){return this.$val.GetByOffset(a);};AA.ptr.prototype.GetByFrameId=function(a){var a,b;b=this;if(a>=b.EdFrameId||a>0);};AA.prototype.GetByFrameId=function(a){return this.$val.GetByFrameId(a);};AA.ptr.prototype.SetByFrameId=function(a,b){var a,b,c,d,e,f,g,h,i,j,k,l,m,n;c=this;d=c.StFrameId;e=c.EdFrameId;f=d;g=e;if(bb){h=c.GetArrIdxByOffset(b-c.StFrameId>>0);if(!((-1===h))){(i=c.Eles,((h<0||h>=i.$length)?($throwRuntimeError("index out of range"),undefined):i.$array[i.$offset+h]=a));return[0,f,g];}}j=0;if(g0){f.AddTags(e);}return f;};$pkg.NewObject=AE;AC.ptr.prototype.Clone=function(){var{a,b,c,d,e,f,g,h,$s,$r,$c}=$restore(this,{});$s=$s||0;s:while(true){switch($s){case 0:a=this;b=AE(a.X,a.Y,a.W,a.H,a.Tags());b.Data=a.Data;if(!($interfaceIsEqual(a.Shape,$ifaceNil))){$s=1;continue;}$s=2;continue;case 1:c=a.Shape.Clone();$s=3;case 3:if($c){$c=false;c=c.$blk();}if(c&&c.$blk!==undefined){break s;}$r=b.SetShape(c);$s=4;case 4:if($c){$c=false;$r=$r.$blk();}if($r&&$r.$blk!==undefined){break s;}case 2:d=a.ignoreList;e=0;f=$keys(d);while(true){if(!(e>0;}h=h+(1)>>0;}}if(!($interfaceIsEqual(a.Shape,$ifaceNil))){$s=1;continue;}$s=2;continue;case 1:$r=a.Shape.SetPosition(a.X,a.Y);$s=3;case 3:if($c){$c=false;$r=$r.$blk();}if($r&&$r.$blk!==undefined){break s;}case 2:$s=-1;return;}return;}var $f={$blk:AC.ptr.prototype.Update,$c:true,$r,a,b,c,d,e,f,g,h,i,j,$s};return $f;};AC.prototype.Update=function(){return this.$val.Update();};AC.ptr.prototype.AddTags=function(a){var a,b;b=this;b.tags=$appendSlice(b.tags,a);};AC.prototype.AddTags=function(a){return this.$val.AddTags(a);};AC.ptr.prototype.RemoveTags=function(a){var a,b,c,d,e,f,g,h,i;b=this;c=a;d=0;while(true){if(!(d=c.$length)?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+d]);f=b.tags;g=0;while(true){if(!(g=f.$length)?($throwRuntimeError("index out of range"),undefined):f.$array[f.$offset+g]);if(i===e){b.tags=$appendSlice($subslice(b.tags,0,h),$subslice(b.tags,(h+1>>0)));break;}g++;}d++;}};AC.prototype.RemoveTags=function(a){return this.$val.RemoveTags(a);};AC.ptr.prototype.HasTags=function(a){var a,b,c,d,e,f,g,h;b=this;c=a;d=0;while(true){if(!(d=c.$length)?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+d]);f=b.tags;g=0;while(true){if(!(g=f.$length)?($throwRuntimeError("index out of range"),undefined):f.$array[f.$offset+g]);if(h===e){return true;}g++;}d++;}return false;};AC.prototype.HasTags=function(a){return this.$val.HasTags(a);};AC.ptr.prototype.Tags=function(){var a;a=this;return $appendSlice(new BA([]),a.tags);};AC.prototype.Tags=function(){return this.$val.Tags();};AC.ptr.prototype.SetShape=function(a){var{a,b,$s,$r,$c}=$restore(this,{a});$s=$s||0;s:while(true){switch($s){case 0:b=this;if(!($interfaceIsEqual(b.Shape,a))){$s=1;continue;}$s=2;continue;case 1:b.Shape=a;$r=b.Update();$s=3;case 3:if($c){$c=false;$r=$r.$blk();}if($r&&$r.$blk!==undefined){break s;}case 2:$s=-1;return;}return;}var $f={$blk:AC.ptr.prototype.SetShape,$c:true,$r,a,b,$s};return $f;};AC.prototype.SetShape=function(a){return this.$val.SetShape(a);};AC.ptr.prototype.BoundsToSpace=function(a,b){var a,b,c,d,e,f,g,h,i;c=this;d=c.Space.WorldToSpace(c.X+a,c.Y+b);e=d[0];f=d[1];g=c.Space.WorldToSpace(c.X+c.W+a-1,c.Y+c.H+b-1);h=g[0];i=g[1];return[e,f,h,i];};AC.prototype.BoundsToSpace=function(a,b){return this.$val.BoundsToSpace(a,b);};AC.ptr.prototype.SharesCells=function(a){var a,b,c,d,e;b=this;c=b.TouchingCells;d=c.StFrameId;while(true){if(!(d>0;}return false;};AC.prototype.SharesCells=function(a){return this.$val.SharesCells(a);};AC.ptr.prototype.SharesCellsTags=function(a){var a,b,c,d,e;b=this;c=b.TouchingCells;d=c.StFrameId;while(true){if(!(d>0;}return false;};AC.prototype.SharesCellsTags=function(a){return this.$val.SharesCellsTags(a);};AC.ptr.prototype.Center=function(){var a;a=this;return[a.X+(a.W/2),a.Y+(a.H/2)];};AC.prototype.Center=function(){return this.$val.Center();};AC.ptr.prototype.SetCenter=function(a,b){var a,b,c;c=this;c.X=a-(c.W/2);c.Y=b-(c.H/2);};AC.prototype.SetCenter=function(a,b){return this.$val.SetCenter(a,b);};AC.ptr.prototype.CellPosition=function(){var a,b;a=this;b=a.Center();return a.Space.WorldToSpace(b[0],b[1]);};AC.prototype.CellPosition=function(){return this.$val.CellPosition();};AC.ptr.prototype.SetRight=function(a){var a,b;b=this;b.X=a-b.W;};AC.prototype.SetRight=function(a){return this.$val.SetRight(a);};AC.ptr.prototype.SetBottom=function(a){var a,b;b=this;b.Y=a-b.H;};AC.prototype.SetBottom=function(a){return this.$val.SetBottom(a);};AC.ptr.prototype.Bottom=function(){var a;a=this;return a.Y+a.H;};AC.prototype.Bottom=function(){return this.$val.Bottom();};AC.ptr.prototype.Right=function(){var a;a=this;return a.X+a.W;};AC.prototype.Right=function(){return this.$val.Right();};AC.ptr.prototype.SetBounds=function(a,b){var a,b,c;c=this;c.X=(0>=a.$length?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+0]);c.Y=(1>=a.$length?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+1]);c.W=(0>=b.$length?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+0])-c.X;c.H=(1>=b.$length?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+1])-c.Y;};AC.prototype.SetBounds=function(a,b){return this.$val.SetBounds(a,b);};AC.ptr.prototype.CheckAllWithHolder=function(a,b,c){var a,aa,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;d=this;if(d.Space===AP.nil){return false;}c.checkingObject=d;if(a<0){a=A.Min(a,-1);}else if(a>0){a=A.Max(a,1);}if(b<0){b=A.Min(b,-1);}else if(b>0){b=A.Max(b,1);}c.dx=a;c.dy=b;e=d.BoundsToSpace(a,b);f=e[0];g=e[1];h=e[2];i=e[3];j=$makeMap(AQ.keyFor,[]);k=$makeMap(AM.keyFor,[]);l=g;while(true){if(!(l<=i)){break;}m=f;while(true){if(!(m<=h)){break;}n=d.Space.Cell(m,l);if(!(n===AM.nil)){o=n.Objects;p=o.StFrameId;while(true){if(!(p>0;continue;}t=(u=j[AQ.keyFor(q)],u!==undefined?[u.v,true]:[false,false]);v=t[1];if(!v){c.Objects.Put(q);w=q;(j||$throwRuntimeError("assignment to entry in nil map"))[AQ.keyFor(w)]={k:w,v:true};x=(y=k[AM.keyFor(n)],y!==undefined?[y.v,true]:[false,false]);z=x[1];if(!z){c.Cells.Put(n);aa=n;(k||$throwRuntimeError("assignment to entry in nil map"))[AM.keyFor(aa)]={k:aa,v:true};}p=p+(1)>>0;continue;}p=p+(1)>>0;}}m=m+(1)>>0;}l=l+(1)>>0;}if(0>=c.Objects.Cnt){return false;}return true;};AC.prototype.CheckAllWithHolder=function(a,b,c){return this.$val.CheckAllWithHolder(a,b,c);};AC.ptr.prototype.Overlaps=function(a){var a,b;b=this;return a.X<=b.X+b.W&&a.X+a.W>=b.X&&a.Y<=b.Y+b.H&&a.Y+a.H>=b.Y;};AC.prototype.Overlaps=function(a){return this.$val.Overlaps(a);};AC.ptr.prototype.AddToIgnoreList=function(a){var a,b,c;b=this;c=a;(b.ignoreList||$throwRuntimeError("assignment to entry in nil map"))[AQ.keyFor(c)]={k:c,v:true};};AC.prototype.AddToIgnoreList=function(a){return this.$val.AddToIgnoreList(a);};AC.ptr.prototype.RemoveFromIgnoreList=function(a){var a,b;b=this;delete b.ignoreList[AQ.keyFor(a)];};AC.prototype.RemoveFromIgnoreList=function(a){return this.$val.RemoveFromIgnoreList(a);};AF=function(a,b,c,d){var a,b,c,d,e,f,g,h,i;e=d.$length;f=c;g=0;while(true){if(!(g=f.$length)?($throwRuntimeError("index out of range"),undefined):f.$array[f.$offset+g]);if(h===e){return;}((h<0||h>=a.$length)?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+h]=b*i+((h<0||h>=d.$length)?($throwRuntimeError("index out of range"),undefined):d.$array[d.$offset+h]));g++;}};AG=function(a,b,c){var a,b,c,d,e,f;d=c;e=0;while(true){if(!(e=a.$length)?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+f]=((f<0||f>=a.$length)?($throwRuntimeError("index out of range"),undefined):a.$array[a.$offset+f])*(b));e++;}};AI=function(){return new AH.ptr(AQ.nil,0,0,AB(16),AB(16));};$pkg.NewCollision=AI;AH.ptr.prototype.Clear=function(){var a;a=this;a.checkingObject=AQ.nil;a.dx=0;a.dy=0;a.Objects.Clear();a.Cells.Clear();};AH.prototype.Clear=function(){return this.$val.Clear();};AH.ptr.prototype.FirstCollidedObject=function(){var a;a=this;if(0>=a.Objects.Cnt){return AQ.nil;}return $assertType(a.Objects.Pop(),AQ);};AH.prototype.FirstCollidedObject=function(){return this.$val.FirstCollidedObject();};AH.ptr.prototype.HasTags=function(a){var a,b,c,d,e;b=this;c=b.Objects;d=c.StFrameId;while(true){if(!(d>0;continue;}if(e.HasTags(a)){return true;}d=d+(1)>>0;}return false;};AH.prototype.HasTags=function(a){return this.$val.HasTags(a);};AH.ptr.prototype.ObjectsByTags=function(a){var a,b,c,d,e,f;b=this;c=new AR([]);d=b.Objects;e=d.StFrameId;while(true){if(!(e>0;continue;}if(f.HasTags(a)){c=$append(c,f);}e=e+(1)>>0;}return c;};AH.prototype.ObjectsByTags=function(a){return this.$val.ObjectsByTags(a);};AH.ptr.prototype.ContactWithObject=function(a){var a,b,c;b=this;c=new B([0,0]);if(b.dx<0){(0>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+0]=a.X+a.W-b.checkingObject.X);}else if(b.dx>0){(0>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+0]=a.X-b.checkingObject.W-b.checkingObject.X);}if(b.dy<0){(1>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+1]=a.Y+a.H-b.checkingObject.Y);}else if(b.dy>0){(1>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+1]=a.Y-b.checkingObject.H-b.checkingObject.Y);}return c;};AH.prototype.ContactWithObject=function(a){return this.$val.ContactWithObject(a);};AH.ptr.prototype.ContactWithCell=function(a){var a,b,c,d,e;b=this;c=new B([0,0]);d=(($imul(a.X,b.checkingObject.Space.CellWidth)));e=(($imul(a.Y,b.checkingObject.Space.CellHeight)));if(b.dx<0){(0>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+0]=d+(b.checkingObject.Space.CellWidth)-b.checkingObject.X);}else if(b.dx>0){(0>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+0]=d-b.checkingObject.W-b.checkingObject.X);}if(b.dy<0){(1>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+1]=e+(b.checkingObject.Space.CellHeight)-b.checkingObject.Y);}else if(b.dy>0){(1>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+1]=e-b.checkingObject.H-b.checkingObject.Y);}return c;};AH.prototype.ContactWithCell=function(a){return this.$val.ContactWithCell(a);};AH.ptr.prototype.SlideAgainstCell=function(a,b){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t;c=this;d=c.checkingObject.Space;e=$assertType(c.Cells.GetByFrameId(c.Cells.StFrameId),AM);f=d.SpaceToWorld(e.X,e.Y);g=f[0];h=f[1];i=(d.CellWidth)/2;j=(d.CellHeight)/2;g=g+(i);h=h+(j);k=c.checkingObject.Center();l=k[0];m=k[1];n=l-g;o=m-h;p=d.Cell(e.X-1>>0,e.Y);q=d.Cell(e.X+1>>0,e.Y);r=d.Cell(e.X,e.Y-1>>0);s=d.Cell(e.X,e.Y+1>>0);t=new B([0,0]);if(!((c.dy===0))){if(n>0&&(q===AM.nil||!q.ContainsTags(b))){(0>=t.$length?($throwRuntimeError("index out of range"),undefined):t.$array[t.$offset+0]=g+i-c.checkingObject.X);}else if(n<0&&(p===AM.nil||!p.ContainsTags(b))){(0>=t.$length?($throwRuntimeError("index out of range"),undefined):t.$array[t.$offset+0]=g-i-(c.checkingObject.X+c.checkingObject.W));}else{return B.nil;}}if(!((c.dx===0))){if(o>0&&(s===AM.nil||!s.ContainsTags(b))){(1>=t.$length?($throwRuntimeError("index out of range"),undefined):t.$array[t.$offset+1]=h+j-c.checkingObject.Y);}else if(o<0&&(r===AM.nil||!r.ContainsTags(b))){(1>=t.$length?($throwRuntimeError("index out of range"),undefined):t.$array[t.$offset+1]=h-j-(c.checkingObject.Y+c.checkingObject.H));}else{return B.nil;}}return t;};AH.prototype.SlideAgainstCell=function(a,b){return this.$val.SlideAgainstCell(a,b);};AK=function(a,b){var a,b;return new AJ.ptr(a,b,AB(16));};AJ.ptr.prototype.register=function(a){var a,b;b=this;if(!b.Contains(a)){b.Objects.Put(a);}};AJ.prototype.register=function(a){return this.$val.register(a);};AJ.ptr.prototype.unregister=function(a){var a,b,c,d,e;b=this;c=b.Objects;d=c.StFrameId;while(true){if(!(d>0;}};AJ.prototype.unregister=function(a){return this.$val.unregister(a);};AJ.ptr.prototype.Contains=function(a){var a,b,c,d,e;b=this;c=b.Objects;d=c.StFrameId;while(true){if(!(d>0;}return false;};AJ.prototype.Contains=function(a){return this.$val.Contains(a);};AJ.ptr.prototype.ContainsTags=function(a){var a,b,c,d,e;b=this;c=b.Objects;d=c.StFrameId;while(true){if(!(d>0;}return false;};AJ.prototype.ContainsTags=function(a){return this.$val.ContainsTags(a);};AJ.ptr.prototype.Occupied=function(){var a;a=this;return 0>0))>>2>>0);};$pkg.ConvertToDelayedInputFrameId=AC;AD=function(a){var a;return(a>>2>>0);};$pkg.ConvertToNoDelayInputFrameId=AD;AE=function(a){var a;return(((a<<2>>0))+6>>0);};$pkg.ConvertToFirstUsedRenderFrameId=AE;AF=function(a){var a;return(((((a<<2>>0))+6>>0)+4>>0)-1>>0);};$pkg.ConvertToLastUsedRenderFrameId=AF;AG=function(a){var a,b,c,d,e,f,g,h;b=new $Uint64(a.$high&0,(a.$low&15)>>>0);d=(((c=$shiftRightUint64(a,4),new $Uint64(c.$high&0,(c.$low&1)>>>0)).$low>>0));f=(((e=$shiftRightUint64(a,5),new $Uint64(e.$high&0,(e.$low&1)>>>0)).$low>>0));return new F.ptr((g=(($flatten64(b)<0||$flatten64(b)>=$pkg.DIRECTION_DECODER.$length)?($throwRuntimeError("index out of range"),undefined):$pkg.DIRECTION_DECODER.$array[$pkg.DIRECTION_DECODER.$offset+$flatten64(b)]),(0>=g.$length?($throwRuntimeError("index out of range"),undefined):g.$array[g.$offset+0])),(h=(($flatten64(b)<0||$flatten64(b)>=$pkg.DIRECTION_DECODER.$length)?($throwRuntimeError("index out of range"),undefined):$pkg.DIRECTION_DECODER.$array[$pkg.DIRECTION_DECODER.$offset+$flatten64(b)]),(1>=h.$length?($throwRuntimeError("index out of range"),undefined):h.$array[h.$offset+1])),d,f);};AI=function(a,b,c,d){var{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,$s,$deferred,$r,$c}=$restore(this,{a,b,c,d});$s=$s||0;var $err=null;try{s:while(true){switch($s){case 0:$deferred=[];$curGoroutine.deferStack.push($deferred);c=[c];e=[e];f=[f];g=c[0].Position();e[0]=g[0];f[0]=g[1];$deferred.push([(function(c,e,f){return function(){c[0].SetPosition(e[0],f[0]);};})(c,e,f),[]]);c[0].SetPosition(e[0]+a,f[0]+b);h=new AH.ptr(0,0,0,true,true,new A.Vector([0,0]));i=AJ(c[0],d,h);if(i){$s=1;continue;}$s=2;continue;case 1:j=h.Overlap*h.OverlapX;k=h.Overlap*h.OverlapY;l=j;m=k;n=[true,l,m,h];$s=4;case 4:return n;case 2:o=[false,0,0,h];$s=5;case 5:return o;case 3:$s=-1;return[false,0,0,BS.nil];}return;}}catch(err){$err=err;$s=-1;return[false,0,0,BS.nil];}finally{$callDeferred($deferred,$err);if($curGoroutine.asleep){var $f={$blk:AI,$c:true,$r,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,$s,$deferred};return $f;}}};AJ=function(a,b,c){var a,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an,ao,ap,aq,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;d=a.Points.$length;e=b.Points.$length;f=d;g=e;if((1===f)&&(1===g)){if(!(BS.nil===c)){c.Overlap=0;}return((h=(i=a.Points,(0>=i.$length?($throwRuntimeError("index out of range"),undefined):i.$array[i.$offset+0])),(0>=h.$length?($throwRuntimeError("index out of range"),undefined):h.$array[h.$offset+0]))===(j=(k=b.Points,(0>=k.$length?($throwRuntimeError("index out of range"),undefined):k.$array[k.$offset+0])),(0>=j.$length?($throwRuntimeError("index out of range"),undefined):j.$array[j.$offset+0])))&&((l=(m=a.Points,(0>=m.$length?($throwRuntimeError("index out of range"),undefined):m.$array[m.$offset+0])),(1>=l.$length?($throwRuntimeError("index out of range"),undefined):l.$array[l.$offset+1]))===(n=(o=b.Points,(0>=o.$length?($throwRuntimeError("index out of range"),undefined):o.$array[o.$offset+0])),(1>=n.$length?($throwRuntimeError("index out of range"),undefined):n.$array[n.$offset+1])));}if(1=t.$length)?($throwRuntimeError("index out of range"),undefined):t.$array[t.$offset+r]));u=(v=a.Points,(0>=v.$length?($throwRuntimeError("index out of range"),undefined):v.$array[v.$offset+0]));w=s;x=u;if(!((r===(a.Points.$length-1>>0)))){x=(y=a.Points,z=r+1>>0,((z<0||z>=y.$length)?($throwRuntimeError("index out of range"),undefined):y.$array[y.$offset+z]));}aa=(1>=x.$length?($throwRuntimeError("index out of range"),undefined):x.$array[x.$offset+1])-(1>=w.$length?($throwRuntimeError("index out of range"),undefined):w.$array[w.$offset+1]);ab=(0>=x.$length?($throwRuntimeError("index out of range"),undefined):x.$array[x.$offset+0])-(0>=w.$length?($throwRuntimeError("index out of range"),undefined):w.$array[w.$offset+0]);ac=new A.Vector([aa,-ab]).Unit();if(AO(a,b,ac,c)){return false;}q++;}}if(1=ah.$length)?($throwRuntimeError("index out of range"),undefined):ah.$array[ah.$offset+af]));ai=(aj=b.Points,(0>=aj.$length?($throwRuntimeError("index out of range"),undefined):aj.$array[aj.$offset+0]));ak=ag;al=ai;if(!((af===(b.Points.$length-1>>0)))){al=(am=b.Points,an=af+1>>0,((an<0||an>=am.$length)?($throwRuntimeError("index out of range"),undefined):am.$array[am.$offset+an]));}ao=(1>=al.$length?($throwRuntimeError("index out of range"),undefined):al.$array[al.$offset+1])-(1>=ak.$length?($throwRuntimeError("index out of range"),undefined):ak.$array[ak.$offset+1]);ap=(0>=al.$length?($throwRuntimeError("index out of range"),undefined):al.$array[al.$offset+0])-(0>=ak.$length?($throwRuntimeError("index out of range"),undefined):ak.$array[ak.$offset+0]);aq=new A.Vector([ao,-ap]).Unit();if(AO(a,b,aq,c)){return false;}ae++;}}return true;};AK=function(a,b){var a,b;if(2===a.BlState){return false;}return((a.BattleAttr.OriginatedRenderFrameId+a.Bullet.StartupFrames>>0)<=b.Id)&&(((a.BattleAttr.OriginatedRenderFrameId+a.Bullet.StartupFrames>>0)+a.Bullet.ActiveFrames>>0)>b.Id);};$pkg.IsMeleeBulletActive=AK;AL=function(a,b){var a,b;if(2===a.BlState){return a.FramesInBlState>0)+a.Bullet.ActiveFrames>>0)>b.Id;};$pkg.IsMeleeBulletAlive=AL;AM=function(a,b){var a,b;if(2===a.BlState){return false;}return((a.BattleAttr.OriginatedRenderFrameId+a.Bullet.StartupFrames>>0)>0)+a.Bullet.ActiveFrames>>0)>b.Id);};$pkg.IsFireballBulletActive=AM;AN=function(a,b){var a,b;if(2===a.BlState){return a.FramesInBlState>0)+a.Bullet.ActiveFrames>>0)>b.Id;};$pkg.IsFireballBulletAlive=AN;AO=function(a,b,c,d){var a,aa,ab,ac,ad,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;e=1.7e+308;f=-1.7e+308;g=1.7e+308;h=-1.7e+308;i=e;j=f;k=g;l=h;m=a.Points;n=0;while(true){if(!(n=m.$length)?($throwRuntimeError("index out of range"),undefined):m.$array[m.$offset+n]);p=((0>=o.$length?($throwRuntimeError("index out of range"),undefined):o.$array[o.$offset+0])+a.X)*(0>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+0])+((1>=o.$length?($throwRuntimeError("index out of range"),undefined):o.$array[o.$offset+1])+a.Y)*(1>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+1]);if(i>p){i=p;}if(j=q.$length)?($throwRuntimeError("index out of range"),undefined):q.$array[q.$offset+r]);t=((0>=s.$length?($throwRuntimeError("index out of range"),undefined):s.$array[s.$offset+0])+b.X)*(0>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+0])+((1>=s.$length?($throwRuntimeError("index out of range"),undefined):s.$array[s.$offset+1])+b.Y)*(1>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+1]);if(k>t){k=t;}if(ll||jl){u=i-l;d.AContainedInB=false;}else{x=j-k;y=l-i;if(x=ab.$length?($throwRuntimeError("index out of range"),undefined):ab.$array[ab.$offset+0])))&&(0===(ac=d.Axis,(1>=ac.$length?($throwRuntimeError("index out of range"),undefined):ac.$array[ac.$offset+1]))))||z>aa){ad=1;if(u<0){ad=-1;}d.Overlap=aa;d.OverlapX=(0>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+0])*ad;d.OverlapY=(1>=c.$length?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+1])*ad;}d.Axis=c;}return false;};AP=function(a,b){var a,b,c,d;c=((B.Round(a*10)>>0));d=((B.Round(b*10)>>0));return[c,d];};$pkg.WorldToVirtualGridPos=AP;AQ=function(a,b){var a,b,c,d;c=(a)*0.1;d=(b)*0.1;return[c,d];};$pkg.VirtualGridToWorldPos=AQ;AR=function(a,b,c,d,e,f,g,h,i,j){var a,b,c,d,e,f,g,h,i,j;return[a-c-g+i,b-d-f+j];};$pkg.WorldToPolygonColliderBLPos=AR;AS=function(a,b,c,d,e,f,g,h,i,j){var a,b,c,d,e,f,g,h,i,j;return[a+c+g-i,b+d+f-j];};$pkg.PolygonColliderBLToWorldPos=AS;AT=function(a,b,c,d,e,f,g,h,i,j){var a,b,c,d,e,f,g,h,i,j,k,l,m;k=AS(a,b,c,d,e,f,g,h,i,j);l=k[0];m=k[1];return AP(l,m);};$pkg.PolygonColliderBLToVirtualGridPos=AT;AV=function(a,b,c,d,e,f,g,h,i){var{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,$s,$r,$c}=$restore(this,{a,b,c,d,e,f,g,h,i});$s=$s||0;s:while(true){switch($s){case 0:j=0;if((16===b.CharacterState)&&(0===c.VelX)&&(b.DirX===c.DirX)){k=1;if(0>c.DirX){k=-k;}j=k*(b.Speed)*0.1;}l=0;m=d.CheckAllWithHolder(j,0,i);if(!m){$s=-1;return l;}case 1:n=i.FirstCollidedObject();if(BT.nil===n){$s=2;continue;}o=false;p=n.Data;if($assertType(p,BU,true)[1]||$assertType(p,BQ,true)[1]||$assertType(p,BV,true)[1]){}else{o=true;}if(!o){$s=1;continue;}q=$assertType(n.Shape,BW);s=AI(0,0,e,q);$s=3;case 3:if($c){$c=false;s=s.$blk();}if(s&&s.$blk!==undefined){break s;}r=s;t=r[0];u=r[1];v=r[2];w=r[3];if(!t){$s=1;continue;}x=(w.Overlap-f)*w.OverlapX;y=(w.Overlap-f)*w.OverlapY;u=x;v=y;C.copy((z=h.$get(),((l<0||l>=z.$length)?($throwRuntimeError("index out of range"),undefined):z.$array[z.$offset+l])),new C.ptr(w.OverlapX,w.OverlapY));g.X=g.X+(u);g.Y=g.Y+(v);l=l+(1)>>0;$s=1;continue;case 2:$s=-1;return l;}return;}var $f={$blk:AV,$c:true,$r,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,$s};return $f;};AW=function(a,b,c,d,e){var a,aa,ab,ac,ad,ae,af,ag,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;f=AC(c.Id);g=AC(c.Id-1>>0);if(0>=f){return[-2,false,0,0];}h=(i=W[$Int32.keyFor(a.CharacterState)],i!==undefined?[i.v,true]:[false,false]);j=h[1];if(j){return[-2,false,0,0];}k=$assertType(e.GetByFrameId(f),BX).InputList;l=BY.nil;if(0>0,((o<0||o>=k.$length)?($throwRuntimeError("index out of range"),undefined):k.$array[k.$offset+o])));q=0;r=0;s=q;t=r;u=0;v=0;w=u;x=v;if(!(BY.nil===l)){z=AG((y=n-1>>0,((y<0||y>=l.$length)?($throwRuntimeError("index out of range"),undefined):l.$array[l.$offset+y])));w=z.BtnALevel;x=z.BtnBLevel;}if(0===a.FramesToRecover){aa=p.Dx;ab=p.Dy;s=aa;t=ab;}ac=-1;ad=a.CapturedByInertia&&(((d.InertiaFramesToRecover>>1>>0))>a.FramesToRecover);if((0===a.FramesToRecover)||ad){if(p.BtnBLevel>x){if(d.DashingEnabled&&0>p.Dy&&!((15===a.CharacterState))){ac=5;}else{ae=(af=V[$Int32.keyFor(a.CharacterState)],af!==undefined?[af.v,true]:[false,false]);ag=ae[1];if(!ag){m=true;}else if(16===a.CharacterState){m=true;}}}}if(-1===ac){if(0w){if(0>p.Dy){ac=3;}else if(0=k.$length)?($throwRuntimeError("index out of range"),undefined):k.$array[k.$offset+l]);((m<0||m>=j.$length)?($throwRuntimeError("index out of range"),undefined):j.$array[j.$offset+m]=new E.ptr(n.Id,n.VirtualGridX,n.VirtualGridY,n.DirX,n.DirY,n.VelX,n.VelY,n.Speed,n.BattleState,n.JoinIndex,n.ColliderRadius,n.Removed,n.Score,0,n.FramesToRecover-1>>0,n.FramesInChState+1>>0,n.Hp,n.MaxHp,n.CharacterState,true,false,n.OnWallNormX,n.OnWallNormY,n.CapturedByInertia,n.ActiveSkillId,n.ActiveSkillHit,n.FramesInvinsible-1>>0,n.BulletTeamId,n.ChCollisionTeamId,n.RevivalVirtualGridX,n.RevivalVirtualGridY));if(((m<0||m>=j.$length)?($throwRuntimeError("index out of range"),undefined):j.$array[j.$offset+m]).FramesToRecover<0){((m<0||m>=j.$length)?($throwRuntimeError("index out of range"),undefined):j.$array[j.$offset+m]).FramesToRecover=0;}if(((m<0||m>=j.$length)?($throwRuntimeError("index out of range"),undefined):j.$array[j.$offset+m]).FramesInvinsible<0){((m<0||m>=j.$length)?($throwRuntimeError("index out of range"),undefined):j.$array[j.$offset+m]).FramesInvinsible=0;}l++;}o=$makeSlice(CA,0,b.MeleeBullets.$length);p=$makeSlice(CB,0,b.FireballBullets.$length);q=$makeSlice(CC,i);r=$makeSlice(CD,i);s=b.PlayersArr;t=0;while(true){if(!(t=r.$length)?($throwRuntimeError("index out of range"),undefined):r.$array[r.$offset+u]=$makeSlice(CC,5));t++;}v=$makeSlice(CE,i);w=b.BulletLocalIdCounter;x=b.PlayersArr;y=0;case 1:if(!(y=x.$length)?($throwRuntimeError("index out of range"),undefined):x.$array[x.$offset+y]);ad=((ab<0||ab>=g.$length)?($throwRuntimeError("index out of range"),undefined):g.$array[g.$offset+ab]);ae=((ab<0||ab>=j.$length)?($throwRuntimeError("index out of range"),undefined):j.$array[j.$offset+ab]);af=AW(ac,ae,b,ad,a);ag=af[0];ah=af[1];ai=af[2];aj=af[3];((ab<0||ab>=v.$length)?($throwRuntimeError("index out of range"),undefined):v.$array[v.$offset+ab]=ah);ak=ac.JoinIndex;al=ad.SkillMapper(ag,ac);$s=3;case 3:if($c){$c=false;al=al.$blk();}if(al&&al.$blk!==undefined){break s;}am=al;an=(ao=U[$Int.keyFor(am)],ao!==undefined?[ao.v,true]:[BP.nil,false]);ap=an[0];aq=an[1];if(aq){ae.ActiveSkillId=((am>>0));ae.ActiveSkillHit=0;ae.FramesToRecover=ap.RecoveryFrames;ar=1;if(0>ae.DirX){ar=-ar;}as=false;at=(au=ap.Hits,av=ae.ActiveSkillHit,((av<0||av>=au.$length)?($throwRuntimeError("index out of range"),undefined):au.$array[au.$offset+av]));if($assertType(at,BQ,true)[1]){aw=at.$val;z[0]=$clone(aw,K);z[0].BattleAttr=new J.ptr(w,b.Id,ak,ac.BulletTeamId);w=w+(1)>>0;z[0].BlState=0;o=$append(o,z[0]);if(!((-1===aw.Bullet.SelfLockVelX))){as=true;ae.VelX=$imul(ar,aw.Bullet.SelfLockVelX);}if(!((-1===aw.Bullet.SelfLockVelY))){as=true;ae.VelY=aw.Bullet.SelfLockVelY;}}else if($assertType(at,BV,true)[1]){ax=at.$val;aa[0]=$clone(ax,L);aa[0].BattleAttr=new J.ptr(w,b.Id,ak,ac.BulletTeamId);w=w+(1)>>0;ay=ac.VirtualGridX+($imul(ar,aa[0].Bullet.HitboxOffsetX))>>0;az=ac.VirtualGridY+aa[0].Bullet.HitboxOffsetY>>0;aa[0].VirtualGridX=ay;aa[0].VirtualGridY=az;aa[0].DirX=ar;aa[0].DirY=0;aa[0].VelX=$imul(aa[0].Speed,ar);aa[0].VelY=0;aa[0].BlState=0;p=$append(p,aa[0]);if(!((-1===ax.Bullet.SelfLockVelX))){as=true;ae.VelX=$imul(ar,ax.Bullet.SelfLockVelX);}if(!((-1===ax.Bullet.SelfLockVelY))){as=true;ae.VelY=ax.Bullet.SelfLockVelY;}}if(false===as&&false===ac.InAir){ae.VelX=0;}ae.CharacterState=ap.BoundChState;y++;$s=1;continue;}if(0===ac.FramesToRecover){ba=ac.CapturedByInertia;bb=ad.OnWallEnabled&&(ad.WallJumpingInitVelX===Z(ac.VelX));bc=true;bd=false;be=false;if(!((0===ai))&&(0===ae.VelX)){bc=false;}else if((0===ai)&&!((0===ae.VelX))){bc=false;be=true;}else if(0>($imul(ai,ae.VelX))){bc=false;bd=true;}if(!ah&&!bb&&!ba&&!bc){ae.CapturedByInertia=true;if(bd){ae.CharacterState=17;ae.FramesToRecover=ad.InertiaFramesToRecover;}else if(be){ae.FramesToRecover=ad.InertiaFramesToRecover;}else{ae.FramesToRecover=(((ad.InertiaFramesToRecover>>1>>0))+((ad.InertiaFramesToRecover>>2>>0))>>0);}}else{ae.CapturedByInertia=false;if(!((0===ai))){bf=1;if(0>ai){bf=-bf;}ae.DirX=ai;ae.DirY=aj;if(bb){ae.VelX=$imul(bf,Z(ac.VelX));}else{ae.VelX=$imul(bf,ac.Speed);}ae.CharacterState=1;}else{ae.CharacterState=0;ae.VelX=0;}}}y++;$s=1;continue;case 2:bg=$makeSlice(CF,b.PlayersArr.$length,b.PlayersArr.$length);bh=b.PlayersArr;bi=0;case 4:if(!(bi=bh.$length)?($throwRuntimeError("index out of range"),undefined):bh.$array[bh.$offset+bi]);bl=bk.JoinIndex;bm=0;bn=0;(bo=bl-1>>0,((bo<0||bo>=q.$length)?($throwRuntimeError("index out of range"),undefined):q.$array[q.$offset+bo])).X=bm;(bp=bl-1>>0,((bp<0||bp>=q.$length)?($throwRuntimeError("index out of range"),undefined):q.$array[q.$offset+bp])).Y=bn;bq=((bj<0||bj>=j.$length)?($throwRuntimeError("index out of range"),undefined):j.$array[j.$offset+bj]);br=((bj<0||bj>=g.$length)?($throwRuntimeError("index out of range"),undefined):g.$array[g.$offset+bj]);bs=bk.VirtualGridX+bk.VelX>>0;bt=bk.VirtualGridY+bk.VelY>>0;bu=bs;bv=bt;if(0>=bq.Hp&&(0===bq.FramesToRecover)){bw=bk.RevivalVirtualGridX;bx=bk.RevivalVirtualGridY;bu=bw;bv=bx;bq.CharacterState=10;bq.FramesInChState=10;bq.FramesToRecover=br.GetUpFramesToRecover;bq.FramesInvinsible=br.GetUpInvinsibleFrames;bq.Hp=bk.MaxHp;if(0===((by=bq.JoinIndex%2,by===by?by:$throwRuntimeError("integer divide by zero")))){bq.DirX=-2;bq.DirY=0;}else{bq.DirX=2;bq.DirY=0;}}if(((bj<0||bj>=v.$length)?($throwRuntimeError("index out of range"),undefined):v.$array[v.$offset+bj])){if(16===bk.CharacterState){if(0<($imul(bk.VelX,bk.OnWallNormX))){bu=bu-(bk.VelX)>>0;}bz=-1;if(0>bk.OnWallNormX){bz=-bz;}bu=bu+(($imul(bz,br.WallJumpingInitVelX)))>>0;bv=bv+(br.WallJumpingInitVelY)>>0;bq.VelX=(($imul(bz,br.WallJumpingInitVelX)));bq.VelY=(br.WallJumpingInitVelY);bq.FramesToRecover=br.WallJumpingFramesToRecover;}else{bq.VelY=(br.JumpingInitVelY);bv=bv+(br.JumpingInitVelY)>>0;}}ca=AQ(bu,bv);cb=ca[0];cc=ca[1];cd=$imul(bk.ColliderRadius,2);ce=$imul(bk.ColliderRadius,4);cf=cd;cg=ce;ch=bk.CharacterState;if(ch===(9)){ci=$imul(bk.ColliderRadius,4);cj=$imul(bk.ColliderRadius,2);cf=ci;cg=cj;}else if((ch===(8))||(ch===(4))||(ch===(5))||(ch===(16))){ck=$imul(bk.ColliderRadius,2);cl=$imul(bk.ColliderRadius,2);cf=ck;cg=cl;}cm=AQ(cf,cg);cn=cm[0];co=cm[1];cp=AY(cb,cc,cn,co,0.1,0.1,0.1,0.1,e,f,bk,"Player");$s=6;case 6:if($c){$c=false;cp=cp.$blk();}if(cp&&cp.$blk!==undefined){break s;}cq=cp;((bj<0||bj>=bg.$length)?($throwRuntimeError("index out of range"),undefined):bg.$array[bg.$offset+bj]=cq);$r=c.AddSingle(cq);$s=7;case 7:if($c){$c=false;$r=$r.$blk();}if($r&&$r.$blk!==undefined){break s;}if(bk.InAir){if((16===bk.CharacterState)&&!((bj<0||bj>=v.$length)?($throwRuntimeError("index out of range"),undefined):v.$array[v.$offset+bj])){bq.VelX=bq.VelX+(0)>>0;bq.VelY=br.WallSlidingVelY;}else if(15===bk.CharacterState){bq.VelX=bq.VelX+(0)>>0;}else{bq.VelX=bq.VelX+(0)>>0;bq.VelY=bq.VelY+(-5)>>0;}}bi++;$s=4;continue;case 5:cr=$makeSlice(CF,0,((((b.MeleeBullets.$length+b.FireballBullets.$length>>0))<<1>>0)));cs=b.FireballBullets;ct=0;case 8:if(!(ct=cs.$length)?($throwRuntimeError("index out of range"),undefined):cs.$array[cs.$offset+ct]);cv=new L.ptr(cu.VirtualGridX,cu.VirtualGridY,cu.DirX,cu.DirY,cu.VelX,cu.VelY,cu.Speed,cu.BlState,cu.FramesInBlState+1>>0,cu.BattleAttr,cu.Bullet);if(AN(cv,b)){$s=10;continue;}$s=11;continue;case 10:if(AM(cv,b)){$s=12;continue;}$s=13;continue;case 12:cw=AQ(cv.VirtualGridX,cv.VirtualGridY);cx=cw[0];cy=cw[1];cz=AQ(cv.Bullet.HitboxSizeX,cv.Bullet.HitboxSizeY);da=cz[0];db=cz[1];dc=AY(cx,cy,da,db,0.1,0.1,0.1,0.1,e,f,cv,"FireballBullet");$s=15;case 15:if($c){$c=false;dc=dc.$blk();}if(dc&&dc.$blk!==undefined){break s;}dd=dc;$r=c.AddSingle(dd);$s=16;case 16:if($c){$c=false;$r=$r.$blk();}if($r&&$r.$blk!==undefined){break s;}cr=$append(cr,dd);cv.BlState=1;if(!((cv.BlState===cu.BlState))){cv.FramesInBlState=0;}de=cv.VirtualGridX+cv.VelX>>0;df=cv.VirtualGridY+cv.VelY>>0;cv.VirtualGridX=de;cv.VirtualGridY=df;$s=14;continue;case 13:di=(dg=b.PlayersArr,dh=cv.BattleAttr.OffenderJoinIndex-1>>0,((dh<0||dh>=dg.$length)?($throwRuntimeError("index out of range"),undefined):dg.$array[dg.$offset+dh]));dj=(dk=W[$Int32.keyFor(di.CharacterState)],dk!==undefined?[dk.v,true]:[false,false]);dl=dj[1];if(dl){ct++;$s=8;continue;}case 14:p=$append(p,cv);case 11:ct++;$s=8;continue;case 9:dm=b.MeleeBullets;dn=0;case 17:if(!(dn=dm.$length)?($throwRuntimeError("index out of range"),undefined):dm.$array[dm.$offset+dn]);dq=new K.ptr(dp.BlState,dp.FramesInBlState+1>>0,dp.BattleAttr,dp.Bullet);if(AL(dq,b)){$s=19;continue;}$s=20;continue;case 19:dt=(dr=b.PlayersArr,ds=dq.BattleAttr.OffenderJoinIndex-1>>0,((ds<0||ds>=dr.$length)?($throwRuntimeError("index out of range"),undefined):dr.$array[dr.$offset+ds]));du=(dv=W[$Int32.keyFor(dt.CharacterState)],dv!==undefined?[dv.v,true]:[false,false]);dw=du[1];if(dw){dn++;$s=17;continue;}if(AK(dq,b)){$s=21;continue;}$s=22;continue;case 21:dx=1;if(0>dt.DirX){dx=-dx;}dy=AQ(dt.VirtualGridX+($imul(dx,dq.Bullet.HitboxOffsetX))>>0,dt.VirtualGridY);dz=dy[0];ea=dy[1];eb=AQ(dq.Bullet.HitboxSizeX,dq.Bullet.HitboxSizeY);ec=eb[0];ed=eb[1];ee=AY(dz,ea,ec,ed,0.1,0.1,0.1,0.1,e,f,dq,"MeleeBullet");$s=23;case 23:if($c){$c=false;ee=ee.$blk();}if(ee&&ee.$blk!==undefined){break s;}ef=ee;$r=c.AddSingle(ef);$s=24;case 24:if($c){$c=false;$r=$r.$blk();}if($r&&$r.$blk!==undefined){break s;}cr=$append(cr,ef);dq.BlState=1;if(!((dq.BlState===dp.BlState))){dq.FramesInBlState=0;}case 22:o=$append(o,dq);case 20:dn++;$s=17;continue;case 18:eg=b.PlayersArr;eh=0;case 25:if(!(eh=eg.$length)?($throwRuntimeError("index out of range"),undefined):eg.$array[eg.$offset+eh]);ek=ej.JoinIndex;el=((ei<0||ei>=bg.$length)?($throwRuntimeError("index out of range"),undefined):bg.$array[bg.$offset+ei]);em=$assertType(el.Shape,BW);en=((ei<0||ei>=j.$length)?($throwRuntimeError("index out of range"),undefined):j.$array[j.$offset+ei]);ep=AV(ek,ej,en,el,em,0.1,(eo=ek-1>>0,((eo<0||eo>=q.$length)?($throwRuntimeError("index out of range"),undefined):q.$array[q.$offset+eo])),$indexPtr(r.$array,r.$offset+(ek-1>>0),CG),h);$s=27;case 27:if($c){$c=false;ep=ep.$blk();}if(ep&&ep.$blk!==undefined){break s;}eq=ep;er=((ei<0||ei>=g.$length)?($throwRuntimeError("index out of range"),undefined):g.$array[g.$offset+ei]);es=false;et=el.CheckAllWithHolder(0,0,h);if(et){$s=28;continue;}$s=29;continue;case 28:case 30:eu=h.FirstCollidedObject();if(BT.nil===eu){$s=31;continue;}ev=false;ew=false;ex=false;ey=ev;ez=ew;fa=ex;fb=eu.Data;if($assertType(fb,BU,true)[1]){fc=fb.$val;if(18===fc.CharacterState){$s=30;continue;}ez=true;}else if($assertType(fb,BQ,true)[1]||$assertType(fb,BV,true)[1]){fd=fb;fa=true;}else{fe=fb;ey=true;}if(fa){$s=30;continue;}ff=$assertType(eu.Shape,BW);fh=AI(0,0,em,ff);$s=32;case 32:if($c){$c=false;fh=fh.$blk();}if(fh&&fh.$blk!==undefined){break s;}fg=fh;fi=fg[0];fj=fg[1];fk=fg[2];fl=fg[3];if(!fi){$s=30;continue;}fm=fl.OverlapX*0+fl.OverlapY*-1;if(ez){fn=(fl.Overlap-0.2)*fl.OverlapX;fo=(fl.Overlap-0.2)*fl.OverlapY;fj=fn;fk=fo;}if(0>0,((fr<0||fr>=r.$length)?($throwRuntimeError("index out of range"),undefined):r.$array[r.$offset+fr])),((fp<0||fp>=fq.$length)?($throwRuntimeError("index out of range"),undefined):fq.$array[fq.$offset+fp])),C);ft=fj*fs.X+fk*fs.Y;if(ey||(ez&&0>ft)){fj=fj-(ft*fs.X);fk=fk-(ft*fs.Y);}fp=fp+(1)>>0;}}fu=ek-1>>0;((fu<0||fu>=q.$length)?($throwRuntimeError("index out of range"),undefined):q.$array[q.$offset+fu]).X=((fu<0||fu>=q.$length)?($throwRuntimeError("index out of range"),undefined):q.$array[q.$offset+fu]).X+(fj);fv=ek-1>>0;((fv<0||fv>=q.$length)?($throwRuntimeError("index out of range"),undefined):q.$array[q.$offset+fv]).Y=((fv<0||fv>=q.$length)?($throwRuntimeError("index out of range"),undefined):q.$array[q.$offset+fv]).Y+(fk);if(0.5=ej.VelY;if(fw){en.VelY=0;en.VelX=0;if(18===en.CharacterState){}else if(8===en.CharacterState){en.CharacterState=9;en.FramesToRecover=er.LayDownFramesToRecover;}else{fx=ej.CharacterState;if((fx===(8))||(fx===(4))||(fx===(5))||(fx===(16))){fy=0;fz=ej.ColliderRadius;ga=fy;gb=fz;gc=AQ(ga,gb);gd=gc[1];ge=ek-1>>0;((ge<0||ge>=q.$length)?($throwRuntimeError("index out of range"),undefined):q.$array[q.$offset+ge]).Y=((ge<0||ge>=q.$length)?($throwRuntimeError("index out of range"),undefined):q.$array[q.$offset+ge]).Y-(gd);}en.CharacterState=0;en.FramesToRecover=0;}}else{gf=(gg=Y[$Int32.keyFor(en.CharacterState)],gg!==undefined?[gg.v,true]:[false,false]);gh=gf[1];if(gh){if(18===en.CharacterState){}else if(9===en.CharacterState){if(0===en.FramesToRecover){en.CharacterState=10;en.FramesToRecover=er.GetUpFramesToRecover;}}else if(10===en.CharacterState){if(0===en.FramesToRecover){en.CharacterState=0;en.FramesInvinsible=er.GetUpInvinsibleFrames;}}}}}if(er.OnWallEnabled){if(en.InAir){gi=(gj=W[$Int32.keyFor(ej.CharacterState)],gj!==undefined?[gj.v,true]:[false,false]);gk=gi[1];if(!gk&&0>0,((gn<0||gn>=r.$length)?($throwRuntimeError("index out of range"),undefined):r.$array[r.$offset+gn])),((gl<0||gl>=gm.$length)?($throwRuntimeError("index out of range"),undefined):gm.$array[gm.$offset+gl])),C);gp=go.X*1+go.Y*0;gq=go.X*-1+go.Y*0;if(0.9>0));gs=((go.Y>>0));en.OnWallNormX=gr;en.OnWallNormY=gs;break;}if(0.9>0));gu=((go.Y>>0));en.OnWallNormX=gt;en.OnWallNormY=gu;break;}gl=gl+(1)>>0;}}}if(!en.OnWall){gv=0;gw=0;en.OnWallNormX=gv;en.OnWallNormY=gw;}}eh++;$s=25;continue;case 26:gx=cr;gy=0;case 33:if(!(gy=gx.$length)?($throwRuntimeError("index out of range"),undefined):gx.$array[gx.$offset+gy]);ha=gz.CheckAllWithHolder(0,0,h);gz.Space.RemoveSingle(gz);if(!ha){gy++;$s=33;continue;}hb=false;hc=false;hd=BO.nil;he=BN.nil;hf=gz.Data;if($assertType(hf,BQ,true)[1]){hg=hf.$val;hd=hg.Bullet;he=hg.BattleAttr;}else if($assertType(hf,BV,true)[1]){hh=hf.$val;hd=hh.Bullet;he=hh.BattleAttr;}hi=$assertType(gz.Shape,BW);hl=(hj=b.PlayersArr,hk=he.OffenderJoinIndex-1>>0,((hk<0||hk>=hj.$length)?($throwRuntimeError("index out of range"),undefined):hj.$array[hj.$offset+hk]));case 35:hm=h.FirstCollidedObject();if(BT.nil===hm){$s=36;continue;}hn=$assertType(hm.Shape,BW);ho=hm.Data;if($assertType(ho,BU,true)[1]){$s=37;continue;}$s=38;continue;case 37:hp=ho.$val;if(he.OffenderJoinIndex===hp.JoinIndex){$s=35;continue;}hs=AI(0,0,hi,hn);$s=40;case 40:if($c){$c=false;hs=hs.$blk();}if(hs&&hs.$blk!==undefined){break s;}hr=hs;ht=hr[0];if(!ht){$s=35;continue;}hu=(hv=X[$Int32.keyFor(hp.CharacterState)],hv!==undefined?[hv.v,true]:[false,false]);hw=hu[1];if(hw){$s=35;continue;}if(0hl.DirX){hx=-hx;}hz=(hy=hp.JoinIndex-1>>0,((hy<0||hy>=j.$length)?($throwRuntimeError("index out of range"),undefined):j.$array[j.$offset+hy]));hz.Hp=hz.Hp-(hd.Damage)>>0;if(0>=hz.Hp){hz.Hp=0;hz.CharacterState=18;hz.FramesToRecover=60;}else{ia=$imul(hx,hd.PushbackVelX);ib=hd.PushbackVelY;ic=ia;id=ib;hz.VelX=ic;hz.VelY=id;if(hd.BlowUp){hz.CharacterState=8;}else{hz.CharacterState=3;}ig=(ie=hp.JoinIndex-1>>0,((ie<0||ie>=j.$length)?($throwRuntimeError("index out of range"),undefined):j.$array[j.$offset+ie])).FramesToRecover;if(hd.HitStunFrames>ig){hz.FramesToRecover=hd.HitStunFrames;}}$s=39;continue;case 38:hq=ho;hb=true;case 39:$s=35;continue;case 36:if(hb){ih=gz.Data;if($assertType(ih,BQ,true)[1]){ii=ih.$val;ii.BlState=2;if(hc){ii.FramesInBlState=0;}else{ii.FramesInBlState=ii.Bullet.ExplosionFrames+1>>0;}}else if($assertType(ih,BV,true)[1]){ij=ih.$val;ij.BlState=2;ij.FramesInBlState=0;}}gy++;$s=33;continue;case 34:ik=b.PlayersArr;il=0;while(true){if(!(il=ik.$length)?($throwRuntimeError("index out of range"),undefined):ik.$array[ik.$offset+il]);ip=io.JoinIndex;iq=((im<0||im>=bg.$length)?($throwRuntimeError("index out of range"),undefined):bg.$array[bg.$offset+im]);ir=((im<0||im>=j.$length)?($throwRuntimeError("index out of range"),undefined):j.$array[j.$offset+im]);is=AT(iq.X-(it=ip-1>>0,((it<0||it>=q.$length)?($throwRuntimeError("index out of range"),undefined):q.$array[q.$offset+it])).X,iq.Y-(iu=ip-1>>0,((iu<0||iu>=q.$length)?($throwRuntimeError("index out of range"),undefined):q.$array[q.$offset+iu])).Y,iq.W*0.5,iq.H*0.5,0,0,0,0,e,f);ir.VirtualGridX=is[0];ir.VirtualGridY=is[1];if(ir.InAir){iv=ir.CharacterState;iw=iv;if((iw===(0))||(iw===(1))||(iw===(17))){if(((im<0||im>=v.$length)?($throwRuntimeError("index out of range"),undefined):v.$array[v.$offset+im])||(5===io.CharacterState)){ir.CharacterState=5;}else{ir.CharacterState=4;}}else if(iw===(2)){ir.CharacterState=6;}else if(iw===(3)){ir.CharacterState=7;}}if(ir.OnWall){ix=ir.CharacterState;if((ix===(1))||(ix===(5))||(ix===(4))){iy=(16===io.CharacterState);iz=io.OnWall&&12<=ir.FramesInChState;if(iy||iz){ir.CharacterState=16;}}}if(!((ir.CharacterState===io.CharacterState))){ir.FramesInChState=0;}ja=(jb=Y[$Int32.keyFor(ir.CharacterState)],jb!==undefined?[jb.v,true]:[false,false]);jc=ja[1];if(jc){ir.ActiveSkillId=-1;ir.ActiveSkillHit=-1;}il++;}jd=bg;je=0;while(true){if(!(je=jd.$length)?($throwRuntimeError("index out of range"),undefined):jd.$array[jd.$offset+je]);jf.Space.RemoveSingle(jf);je++;}$s=-1;return new N.ptr(b.Id+1>>0,j,new $Int64(0,0),o,p,new $Uint64(0,0),false,w);}return;}var $f={$blk:AX,$c:true,$r,a,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an,ao,ap,aq,ar,as,at,au,av,aw,ax,ay,az,b,ba,bb,bc,bd,be,bf,bg,bh,bi,bj,bk,bl,bm,bn,bo,bp,bq,br,bs,bt,bu,bv,bw,bx,by,bz,c,ca,cb,cc,cd,ce,cf,cg,ch,ci,cj,ck,cl,cm,cn,co,cp,cq,cr,cs,ct,cu,cv,cw,cx,cy,cz,d,da,db,dc,dd,de,df,dg,dh,di,dj,dk,dl,dm,dn,dp,dq,dr,ds,dt,du,dv,dw,dx,dy,dz,e,ea,eb,ec,ed,ee,ef,eg,eh,ei,ej,ek,el,em,en,eo,ep,eq,er,es,et,eu,ev,ew,ex,ey,ez,f,fa,fb,fc,fd,fe,ff,fg,fh,fi,fj,fk,fl,fm,fn,fo,fp,fq,fr,fs,ft,fu,fv,fw,fx,fy,fz,g,ga,gb,gc,gd,ge,gf,gg,gh,gi,gj,gk,gl,gm,gn,go,gp,gq,gr,gs,gt,gu,gv,gw,gx,gy,gz,h,ha,hb,hc,hd,he,hf,hg,hh,hi,hj,hk,hl,hm,hn,ho,hp,hq,hr,hs,ht,hu,hv,hw,hx,hy,hz,i,ia,ib,ic,id,ie,ig,ih,ii,ij,ik,il,im,io,ip,iq,ir,is,it,iu,iv,iw,ix,iy,iz,j,ja,jb,jc,jd,je,jf,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,$s};return $f;};$pkg.ApplyInputFrameDownsyncDynamicsOnSingleRenderFrame=AX;AY=function(a,b,c,d,e,f,g,h,i,j,k,l){var{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,$s,$r,$c}=$restore(this,{a,b,c,d,e,f,g,h,i,j,k,l});$s=$s||0;s:while(true){switch($s){case 0:m=AR(a,b,c*0.5,d*0.5,e,f,g,h,i,j);n=m[0];o=m[1];p=AZ(n,o,g+c+h,f+d+e,k,l);$s=1;case 1:if($c){$c=false;p=p.$blk();}if(p&&p.$blk!==undefined){break s;}q=p;$s=2;case 2:return q;}return;}var $f={$blk:AY,$c:true,$r,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,$s};return $f;};$pkg.GenerateRectCollider=AY;AZ=function(a,b,c,d,e,f){var{a,b,c,d,e,f,g,h,$s,$r,$c}=$restore(this,{a,b,c,d,e,f});$s=$s||0;s:while(true){switch($s){case 0:g=A.NewObjectSingleTag(a,b,c,d,f);h=A.NewRectangle(0,0,c,d);$r=g.SetShape(h);$s=1;case 1:if($c){$c=false;$r=$r.$blk();}if($r&&$r.$blk!==undefined){break s;}g.Data=e;$s=-1;return g;}return;}var $f={$blk:AZ,$c:true,$r,a,b,c,d,e,f,g,h,$s};return $f;};BA=function(a,b,c,d,e){var{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,$s,$r,$c}=$restore(this,{a,b,c,d,e});$s=$s||0;s:while(true){switch($s){case 0:f=BB(a);g=0;h=0;i=g;j=h;k=A.NewConvexPolygon(CH.nil);l=f.Points;m=0;while(true){if(!(m=l.$length)?($throwRuntimeError("index out of range"),undefined):l.$array[l.$offset+m]);p=f.Points;q=0;while(true){if(!(q=p.$length)?($throwRuntimeError("index out of range"),undefined):p.$array[p.$offset+q]);if(n===r){q++;continue;}if(B.Abs(s.X-o.X)>i){i=B.Abs(s.X-o.X);}if(B.Abs(s.Y-o.Y)>j){j=B.Abs(s.Y-o.Y);}q++;}m++;}t=0;while(true){if(!(t=u.$length)?($throwRuntimeError("index out of range"),undefined):u.$array[u.$offset+t]));k.AddPoints(new CH([v.X,v.Y]));t=t+(1)>>0;}w=A.NewObject(f.Anchor.X+b,f.Anchor.Y+c,i,j,new CI([e]));$r=w.SetShape(k);$s=1;case 1:if($c){$c=false;$r=$r.$blk();}if($r&&$r.$blk!==undefined){break s;}w.Data=d;$s=-1;return w;}return;}var $f={$blk:BA,$c:true,$r,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,$s};return $f;};$pkg.GenerateConvexPolygonCollider=BA;BB=function(a){var a,b,c,d,e,f,g,h,i,j,k;b=new C.ptr(1.7e+308,1.7e+308);c=a.Points;d=0;while(true){if(!(d=c.$length)?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+d]);if(e.X=g.$length)?($throwRuntimeError("index out of range"),undefined):g.$array[g.$offset+h]);(k=f.Points,((i<0||i>=k.$length)?($throwRuntimeError("index out of range"),undefined):k.$array[k.$offset+i]=new C.ptr(j.X-b.X,j.Y-b.Y)));h++;}return f;};$pkg.AlignPolygon2DToBoundingBox=BB;BC=function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x;return new K.ptr(u,v,new J.ptr(a,b,c,t),new I.ptr(d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,w,x,false));};$pkg.NewMeleeBullet=BC;BD=function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,ab,ac,ad,ae){var a,aa,ab,ac,ad,ae,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;return new L.ptr(u,v,w,x,y,z,aa,ab,ac,new J.ptr(a,b,c,t),new I.ptr(d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,ad,ae,false));};$pkg.NewFireballBullet=BD;BE=function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,ab){var a,aa,ab,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;return new E.ptr(a,b,c,d,e,f,g,m,n,p,s,false,0,0,h,i,q,r,o,t,u,v,w,x,j,k,l,y,z,aa,ab);};$pkg.NewPlayerDownsync=BE;C.init("",[{prop:"X",name:"X",embedded:false,exported:true,typ:$Float64,tag:""},{prop:"Y",name:"Y",embedded:false,exported:true,typ:$Float64,tag:""}]);D.init("",[{prop:"Anchor",name:"Anchor",embedded:false,exported:true,typ:CJ,tag:""},{prop:"Points",name:"Points",embedded:false,exported:true,typ:CK,tag:""}]);E.init("",[{prop:"Id",name:"Id",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"VirtualGridX",name:"VirtualGridX",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"VirtualGridY",name:"VirtualGridY",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"DirX",name:"DirX",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"DirY",name:"DirY",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"VelX",name:"VelX",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"VelY",name:"VelY",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"Speed",name:"Speed",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"BattleState",name:"BattleState",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"JoinIndex",name:"JoinIndex",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"ColliderRadius",name:"ColliderRadius",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"Removed",name:"Removed",embedded:false,exported:true,typ:$Bool,tag:""},{prop:"Score",name:"Score",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"LastMoveGmtMillis",name:"LastMoveGmtMillis",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"FramesToRecover",name:"FramesToRecover",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"FramesInChState",name:"FramesInChState",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"Hp",name:"Hp",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"MaxHp",name:"MaxHp",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"CharacterState",name:"CharacterState",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"InAir",name:"InAir",embedded:false,exported:true,typ:$Bool,tag:""},{prop:"OnWall",name:"OnWall",embedded:false,exported:true,typ:$Bool,tag:""},{prop:"OnWallNormX",name:"OnWallNormX",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"OnWallNormY",name:"OnWallNormY",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"CapturedByInertia",name:"CapturedByInertia",embedded:false,exported:true,typ:$Bool,tag:""},{prop:"ActiveSkillId",name:"ActiveSkillId",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"ActiveSkillHit",name:"ActiveSkillHit",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"FramesInvinsible",name:"FramesInvinsible",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"BulletTeamId",name:"BulletTeamId",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"ChCollisionTeamId",name:"ChCollisionTeamId",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"RevivalVirtualGridX",name:"RevivalVirtualGridX",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"RevivalVirtualGridY",name:"RevivalVirtualGridY",embedded:false,exported:true,typ:$Int32,tag:""}]);F.init("",[{prop:"Dx",name:"Dx",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"Dy",name:"Dy",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"BtnALevel",name:"BtnALevel",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"BtnBLevel",name:"BtnBLevel",embedded:false,exported:true,typ:$Int32,tag:""}]);H.init("",[{prop:"Boundary",name:"Boundary",embedded:false,exported:true,typ:CL,tag:""}]);I.init("",[{prop:"StartupFrames",name:"StartupFrames",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"CancellableStFrame",name:"CancellableStFrame",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"CancellableEdFrame",name:"CancellableEdFrame",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"ActiveFrames",name:"ActiveFrames",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"HitStunFrames",name:"HitStunFrames",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"BlockStunFrames",name:"BlockStunFrames",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"PushbackVelX",name:"PushbackVelX",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"PushbackVelY",name:"PushbackVelY",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"Damage",name:"Damage",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"SelfLockVelX",name:"SelfLockVelX",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"SelfLockVelY",name:"SelfLockVelY",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"HitboxOffsetX",name:"HitboxOffsetX",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"HitboxOffsetY",name:"HitboxOffsetY",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"HitboxSizeX",name:"HitboxSizeX",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"HitboxSizeY",name:"HitboxSizeY",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"BlowUp",name:"BlowUp",embedded:false,exported:true,typ:$Bool,tag:""},{prop:"ExplosionFrames",name:"ExplosionFrames",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"SpeciesId",name:"SpeciesId",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"CancelTransit",name:"CancelTransit",embedded:false,exported:true,typ:CM,tag:""}]);J.init("",[{prop:"BulletLocalId",name:"BulletLocalId",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"OriginatedRenderFrameId",name:"OriginatedRenderFrameId",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"OffenderJoinIndex",name:"OffenderJoinIndex",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"TeamId",name:"TeamId",embedded:false,exported:true,typ:$Int32,tag:""}]);K.init("",[{prop:"BlState",name:"BlState",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"FramesInBlState",name:"FramesInBlState",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"BattleAttr",name:"BattleAttr",embedded:false,exported:true,typ:BN,tag:""},{prop:"Bullet",name:"Bullet",embedded:false,exported:true,typ:BO,tag:""}]);L.init("",[{prop:"VirtualGridX",name:"VirtualGridX",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"VirtualGridY",name:"VirtualGridY",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"DirX",name:"DirX",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"DirY",name:"DirY",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"VelX",name:"VelX",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"VelY",name:"VelY",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"Speed",name:"Speed",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"BlState",name:"BlState",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"FramesInBlState",name:"FramesInBlState",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"BattleAttr",name:"BattleAttr",embedded:false,exported:true,typ:BN,tag:""},{prop:"Bullet",name:"Bullet",embedded:false,exported:true,typ:BO,tag:""}]);M.init("",[{prop:"BattleLocalId",name:"BattleLocalId",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"RecoveryFrames",name:"RecoveryFrames",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"RecoveryFramesOnBlock",name:"RecoveryFramesOnBlock",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"RecoveryFramesOnHit",name:"RecoveryFramesOnHit",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"ReleaseTriggerType",name:"ReleaseTriggerType",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"BoundChState",name:"BoundChState",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"Hits",name:"Hits",embedded:false,exported:true,typ:BM,tag:""}]);N.init("",[{prop:"Id",name:"Id",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"PlayersArr",name:"PlayersArr",embedded:false,exported:true,typ:BZ,tag:""},{prop:"CountdownNanos",name:"CountdownNanos",embedded:false,exported:true,typ:$Int64,tag:""},{prop:"MeleeBullets",name:"MeleeBullets",embedded:false,exported:true,typ:CA,tag:""},{prop:"FireballBullets",name:"FireballBullets",embedded:false,exported:true,typ:CB,tag:""},{prop:"BackendUnconfirmedMask",name:"BackendUnconfirmedMask",embedded:false,exported:true,typ:$Uint64,tag:""},{prop:"ShouldForceResync",name:"ShouldForceResync",embedded:false,exported:true,typ:$Bool,tag:""},{prop:"BulletLocalIdCounter",name:"BulletLocalIdCounter",embedded:false,exported:true,typ:$Int32,tag:""}]);O.init("",[{prop:"InputFrameId",name:"InputFrameId",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"InputList",name:"InputList",embedded:false,exported:true,typ:BY,tag:""},{prop:"ConfirmedList",name:"ConfirmedList",embedded:false,exported:true,typ:$Uint64,tag:""}]);P.init("",[{prop:"FlAct",name:"FlAct",embedded:false,exported:true,typ:$Uint64,tag:""},{prop:"FrAct",name:"FrAct",embedded:false,exported:true,typ:$Uint64,tag:""},{prop:"X",name:"X",embedded:false,exported:true,typ:$Float64,tag:""},{prop:"Y",name:"Y",embedded:false,exported:true,typ:$Float64,tag:""}]);S.init([$Int,BU],[$Int],false);T.init("",[{prop:"SpeciesId",name:"SpeciesId",embedded:false,exported:true,typ:$Int,tag:""},{prop:"SpeciesName",name:"SpeciesName",embedded:false,exported:true,typ:$String,tag:""},{prop:"InAirIdleFrameIdxTurningPoint",name:"InAirIdleFrameIdxTurningPoint",embedded:false,exported:true,typ:$Int,tag:""},{prop:"InAirIdleFrameIdxTurnedCycle",name:"InAirIdleFrameIdxTurnedCycle",embedded:false,exported:true,typ:$Int,tag:""},{prop:"LayDownFrames",name:"LayDownFrames",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"LayDownFramesToRecover",name:"LayDownFramesToRecover",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"GetUpInvinsibleFrames",name:"GetUpInvinsibleFrames",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"GetUpFramesToRecover",name:"GetUpFramesToRecover",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"Speed",name:"Speed",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"JumpingInitVelY",name:"JumpingInitVelY",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"JumpingFramesToRecover",name:"JumpingFramesToRecover",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"DashingEnabled",name:"DashingEnabled",embedded:false,exported:true,typ:$Bool,tag:""},{prop:"OnWallEnabled",name:"OnWallEnabled",embedded:false,exported:true,typ:$Bool,tag:""},{prop:"WallJumpingFramesToRecover",name:"WallJumpingFramesToRecover",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"WallJumpingInitVelX",name:"WallJumpingInitVelX",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"WallJumpingInitVelY",name:"WallJumpingInitVelY",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"WallSlidingVelY",name:"WallSlidingVelY",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"InertiaFramesToRecover",name:"InertiaFramesToRecover",embedded:false,exported:true,typ:$Int32,tag:""},{prop:"SkillMapper",name:"SkillMapper",embedded:false,exported:true,typ:S,tag:""}]);AH.init("",[{prop:"Overlap",name:"Overlap",embedded:false,exported:true,typ:$Float64,tag:""},{prop:"OverlapX",name:"OverlapX",embedded:false,exported:true,typ:$Float64,tag:""},{prop:"OverlapY",name:"OverlapY",embedded:false,exported:true,typ:$Float64,tag:""},{prop:"AContainedInB",name:"AContainedInB",embedded:false,exported:true,typ:$Bool,tag:""},{prop:"BContainedInA",name:"BContainedInA",embedded:false,exported:true,typ:$Bool,tag:""},{prop:"Axis",name:"Axis",embedded:false,exported:true,typ:A.Vector,tag:""}]);$init=function(){$pkg.$init=function(){};var $f,$c=false,$s=0,$r;if(this!==undefined&&this.$blk!==undefined){$f=this;$c=true;$s=$f.$s;$r=$f.$r;}s:while(true){switch($s){case 0:$r=B.$init();$s=1;case 1:if($c){$c=false;$r=$r.$blk();}if($r&&$r.$blk!==undefined){break s;}$r=A.$init();$s=2;case 2:if($c){$c=false;$r=$r.$blk();}if($r&&$r.$blk!==undefined){break s;}$pkg.DIRECTION_DECODER=new BL([new BK([0,0]),new BK([0,2]),new BK([0,-2]),new BK([2,0]),new BK([-2,0]),new BK([1,1]),new BK([-1,-1]),new BK([1,-1]),new BK([-1,1])]);U=$makeMap($Int.keyFor,[{k:1,v:new M.ptr(0,30,30,30,1,2,new BM([new K.ptr(0,0,BN.nil,new I.ptr(7,13,30,22,13,9,5,0,5,1,-1,120,0,240,320,false,9,1,$makeMap($Int.keyFor,[{k:1,v:2}])))]))},{k:2,v:new M.ptr(0,36,36,36,1,11,new BM([new K.ptr(0,0,BN.nil,new I.ptr(18,22,36,18,18,9,5,0,5,1,-1,180,0,240,320,false,9,1,$makeMap($Int.keyFor,[{k:1,v:3}])))]))},{k:3,v:new M.ptr(0,50,50,50,1,12,new BM([new K.ptr(0,0,BN.nil,new I.ptr(8,0,0,30,999999999,9,20,70,10,5,50,160,80,320,320,true,9,1,false))]))},{k:4,v:new M.ptr(0,30,30,30,1,2,new BM([new K.ptr(0,0,BN.nil,new I.ptr(7,13,30,22,13,9,5,0,5,1,-1,120,0,240,320,false,15,2,$makeMap($Int.keyFor,[{k:1,v:5}])))]))},{k:5,v:new M.ptr(0,36,36,36,1,11,new BM([new K.ptr(0,0,BN.nil,new I.ptr(18,23,36,18,18,9,5,0,5,1,-1,180,0,240,320,false,15,2,$makeMap($Int.keyFor,[{k:1,v:6}])))]))},{k:6,v:new M.ptr(0,45,45,45,1,12,new BM([new K.ptr(0,0,BN.nil,new I.ptr(8,0,0,28,999999999,9,20,30,10,-1,-1,240,0,320,320,true,15,2,false))]))},{k:7,v:new M.ptr(0,30,30,30,1,2,new BM([new K.ptr(0,0,BN.nil,new I.ptr(7,13,30,22,13,9,5,0,5,-1,-1,120,0,240,320,false,9,1,$makeMap($Int.keyFor,[{k:1,v:8}])))]))},{k:8,v:new M.ptr(0,36,36,36,1,11,new BM([new K.ptr(0,0,BN.nil,new I.ptr(18,22,36,18,18,9,5,0,5,1,-1,180,0,240,320,false,9,1,$makeMap($Int.keyFor,[{k:1,v:9}])))]))},{k:9,v:new M.ptr(0,40,40,40,1,12,new BM([new K.ptr(0,0,BN.nil,new I.ptr(7,0,0,30,999999999,9,20,40,10,10,-1,100,0,320,320,true,9,1,false))]))},{k:10,v:new M.ptr(0,38,38,38,1,13,new BM([new L.ptr(0,0,0,0,0,0,60,0,0,BN.nil,new I.ptr(10,0,0,999999999,15,9,20,0,22,-1,-1,320,100,640,480,false,30,1,false))]))},{k:11,v:new M.ptr(0,60,60,60,1,14,new BM([new K.ptr(0,0,BN.nil,new I.ptr(3,0,0,25,999999999,9,20,70,35,10,80,80,0,400,640,true,15,3,false))]))},{k:12,v:new M.ptr(0,10,10,10,1,15,new BM([new K.ptr(0,0,BN.nil,new I.ptr(3,0,0,0,0,0,-1,-1,0,60,0,0,0,0,0,false,0,0,false))]))},{k:13,v:new M.ptr(0,12,12,12,1,15,new BM([new K.ptr(0,0,BN.nil,new I.ptr(3,0,0,0,0,0,-1,-1,0,80,0,0,0,0,0,false,0,0,false))]))},{k:14,v:new M.ptr(0,8,8,8,1,15,new BM([new K.ptr(0,0,BN.nil,new I.ptr(4,0,0,0,999999999,0,-1,-1,0,50,0,0,0,0,0,false,0,0,false))]))},{k:15,v:new M.ptr(0,48,48,48,1,13,new BM([new L.ptr(0,0,0,0,0,0,40,0,0,BN.nil,new I.ptr(12,0,0,999999999,15,9,30,0,18,-1,-1,240,80,480,320,false,30,2,false))]))},{k:16,v:new M.ptr(0,60,60,60,1,13,new BM([new L.ptr(0,0,0,0,0,0,40,0,0,BN.nil,new I.ptr(16,0,0,999999999,999999999,9,30,70,30,-1,-1,240,80,480,320,true,30,3,false))]))},{k:255,v:new M.ptr(0,30,30,30,1,6,new BM([new K.ptr(0,0,BN.nil,new I.ptr(3,0,0,20,18,9,5,0,5,-1,-1,120,0,320,240,false,9,1,false))]))},{k:256,v:new M.ptr(0,20,20,20,1,6,new BM([new K.ptr(0,0,BN.nil,new I.ptr(3,0,0,10,15,9,5,0,5,-1,-1,120,0,320,240,false,15,2,false))]))},{k:257,v:new M.ptr(0,30,30,30,1,6,new BM([new K.ptr(0,0,BN.nil,new I.ptr(4,0,0,20,9,5,5,0,5,-1,-1,120,0,320,240,false,9,1,false))]))}]);$pkg.Characters=$makeMap($Int.keyFor,[{k:0,v:new T.ptr(0,"MonkGirl",11,1,16,16,10,27,21,80,2,true,true,8,28,70,-10,9,(function(a,b){var a,b,c,d,e,f,g,h,i,j,k,l,m,n;if(1===a){if(0===b.FramesToRecover){if(b.InAir){return 255;}else{return 1;}}else{c=(d=U[$Int.keyFor(((b.ActiveSkillId>>0)))],d!==undefined?[d.v,true]:[BP.nil,false]);e=c[0];f=c[1];if(f){g=(h=e.Hits,i=b.ActiveSkillHit,((i<0||i>=h.$length)?($throwRuntimeError("index out of range"),undefined):h.$array[h.$offset+i]));if($assertType(g,BQ,true)[1]){j=g.$val;if(j.Bullet.CancellableStFrame<=b.FramesInChState&&b.FramesInChState>0)))],d!==undefined?[d.v,true]:[BP.nil,false]);e=c[0];f=c[1];if(f){g=(h=e.Hits,i=b.ActiveSkillHit,((i<0||i>=h.$length)?($throwRuntimeError("index out of range"),undefined):h.$array[h.$offset+i]));if($assertType(g,BQ,true)[1]){j=g.$val;if(j.Bullet.CancellableStFrame<=b.FramesInChState&&b.FramesInChState>0)))],d!==undefined?[d.v,true]:[BP.nil,false]);e=c[0];f=c[1];if(f){g=(h=e.Hits,i=b.ActiveSkillHit,((i<0||i>=h.$length)?($throwRuntimeError("index out of range"),undefined):h.$array[h.$offset+i]));if($assertType(g,BQ,true)[1]){j=g.$val;if(j.Bullet.CancellableStFrame<=b.FramesInChState&&b.FramesInChState=d.$length)?($throwRuntimeError("index out of range"),undefined):d.$array[d.$offset+e]);g=A.MakeFullWrapper(f);$s=3;case 3:if($c){$c=false;g=g.$blk();}if(g&&g.$blk!==undefined){break s;}c=$append(c,g);e++;$s=1;continue;case 2:$s=-1;return c;}return;}var $f={$blk:O,$c:true,$r,a,b,c,d,e,f,g,$s};return $f;};$pkg.GetCollisionSpaceObjsJs=O;P=function(a,b,c,d,e,f,g,h){var{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,$s,$r,$c}=$restore(this,{a,b,c,d,e,f,g,h});$s=$s||0;s:while(true){switch($s){case 0:i=0.1;j=0.1;k=0.1;l=0.1;m=i;n=j;o=k;p=l;q=B.GenerateRectCollider(a,b,c,d,m,n,o,p,e,f,g,h);$s=1;case 1:if($c){$c=false;q=q.$blk();}if(q&&q.$blk!==undefined){break s;}r=A.MakeFullWrapper(q);$s=2;case 2:if($c){$c=false;r=r.$blk();}if(r&&r.$blk!==undefined){break s;}s=r;$s=3;case 3:return s;}return;}var $f={$blk:P,$c:true,$r,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,$s};return $f;};$pkg.GenerateRectColliderJs=P;Q=function(a,b,c,d,e){var{a,b,c,d,e,f,g,h,$s,$r,$c}=$restore(this,{a,b,c,d,e});$s=$s||0;s:while(true){switch($s){case 0:f=B.GenerateConvexPolygonCollider(a,b,c,d,e);$s=1;case 1:if($c){$c=false;f=f.$blk();}if(f&&f.$blk!==undefined){break s;}g=A.MakeFullWrapper(f);$s=2;case 2:if($c){$c=false;g=g.$blk();}if(g&&g.$blk!==undefined){break s;}h=g;$s=3;case 3:return h;}return;}var $f={$blk:Q,$c:true,$r,a,b,c,d,e,f,g,h,$s};return $f;};$pkg.GenerateConvexPolygonColliderJs=Q;R=function(a){var{a,b,c,d,e,f,g,h,$s,$r,$c}=$restore(this,{a});$s=$s||0;s:while(true){switch($s){case 0:b=$makeSlice(AF,a.$length,a.$length);c=a;d=0;case 1:if(!(d=c.$length)?($throwRuntimeError("index out of range"),undefined):c.$array[c.$offset+d]);h=A.MakeFullWrapper((g=B.Characters[$Int.keyFor(f)],g!==undefined?g.v:AG.nil));$s=3;case 3:if($c){$c=false;h=h.$blk();}if(h&&h.$blk!==undefined){break s;}((e<0||e>=b.$length)?($throwRuntimeError("index out of range"),undefined):b.$array[b.$offset+e]=h);d++;$s=1;continue;case 2:$s=-1;return b;}return;}var $f={$blk:R,$c:true,$r,a,b,c,d,e,f,g,h,$s};return $f;};$pkg.GetCharacterConfigsOrderedByJoinIndex=R;S=function(a,b,c,d,e,f,g){var{a,b,c,d,e,f,g,h,i,j,$s,$r,$c}=$restore(this,{a,b,c,d,e,f,g});$s=$s||0;s:while(true){switch($s){case 0:h=B.ApplyInputFrameDownsyncDynamicsOnSingleRenderFrame(a,b,c,d,e,f,g);$s=1;case 1:if($c){$c=false;h=h.$blk();}if(h&&h.$blk!==undefined){break s;}i=A.MakeFullWrapper(h);$s=2;case 2:if($c){$c=false;i=i.$blk();}if(i&&i.$blk!==undefined){break s;}j=i;$s=3;case 3:return j;}return;}var $f={$blk:S,$c:true,$r,a,b,c,d,e,f,g,h,i,j,$s};return $f;};$pkg.ApplyInputFrameDownsyncDynamicsOnSingleRenderFrameJs=S;T=function(){$global.gopkgs=$externalize($makeMap($String.keyFor,[{k:"NewVec2DJs",v:new AH(G)},{k:"NewPolygon2DJs",v:new AI(H)},{k:"NewBarrierJs",v:new AJ(I)},{k:"NewPlayerDownsyncJs",v:new AK(J)},{k:"NewMeleeBulletJs",v:new AL(K)},{k:"NewFireballBulletJs",v:new AM(L)},{k:"NewNpcPatrolCue",v:new AN(M)},{k:"NewRoomDownsyncFrameJs",v:new AO(N)},{k:"NewCollisionSpaceJs",v:new AP(F)},{k:"NewInputFrameDownsync",v:new AQ(D)},{k:"NewRingBufferJs",v:new AR(E)},{k:"GenerateRectColliderJs",v:new AS(P)},{k:"GenerateConvexPolygonColliderJs",v:new AT(Q)},{k:"GetCollisionSpaceObjsJs",v:new AV(O)},{k:"WorldToPolygonColliderBLPos",v:new AW(B.WorldToPolygonColliderBLPos)},{k:"PolygonColliderBLToWorldPos",v:new AW(B.PolygonColliderBLToWorldPos)},{k:"WorldToVirtualGridPos",v:new AX(B.WorldToVirtualGridPos)},{k:"VirtualGridToWorldPos",v:new AY(B.VirtualGridToWorldPos)},{k:"GetCharacterConfigsOrderedByJoinIndex",v:new BA(R)},{k:"ApplyInputFrameDownsyncDynamicsOnSingleRenderFrameJs",v:new BG(S)},{k:"ConvertToDelayedInputFrameId",v:new BH(B.ConvertToDelayedInputFrameId)},{k:"ConvertToNoDelayInputFrameId",v:new BH(B.ConvertToNoDelayInputFrameId)},{k:"ConvertToFirstUsedRenderFrameId",v:new BH(B.ConvertToFirstUsedRenderFrameId)},{k:"ConvertToLastUsedRenderFrameId",v:new BH(B.ConvertToLastUsedRenderFrameId)},{k:"ShouldGenerateInputFrameUpsync",v:new BI(B.ShouldGenerateInputFrameUpsync)},{k:"IsMeleeBulletActive",v:new BJ(B.IsMeleeBulletActive)},{k:"IsMeleeBulletAlive",v:new BJ(B.IsMeleeBulletAlive)},{k:"IsFireballBulletActive",v:new BK(B.IsFireballBulletActive)},{k:"IsFireballBulletAlive",v:new BK(B.IsFireballBulletAlive)}]),BL);};$init=function(){$pkg.$init=function(){};var $f,$c=false,$s=0,$r;if(this!==undefined&&this.$blk!==undefined){$f=this;$c=true;$s=$f.$s;$r=$f.$r;}s:while(true){switch($s){case 0:$r=A.$init();$s=1;case 1:if($c){$c=false;$r=$r.$blk();}if($r&&$r.$blk!==undefined){break s;}$r=B.$init();$s=2;case 2:if($c){$c=false;$r=$r.$blk();}if($r&&$r.$blk!==undefined){break s;}$r=C.$init();$s=3;case 3:if($c){$c=false;$r=$r.$blk();}if($r&&$r.$blk!==undefined){break s;}if($pkg===$mainPkg){T();$mainFinished=true;}}return;}if($f===undefined){$f={$blk:$init};}$f.$s=$s;$f.$r=$r;return $f;};$pkg.$init=$init;return $pkg;})(); +var $NaN = NaN; +var $global, $module; +if (typeof window !== "undefined") { /* web page */ + $global = window; +} else if (typeof self !== "undefined") { /* web worker */ + $global = self; +} else if (typeof global !== "undefined") { /* Node.js */ + $global = global; + $global.require = require; +} else { /* others (e.g. Nashorn) */ + $global = this; +} + +if ($global === undefined || $global.Array === undefined) { + throw new Error("no global object found"); +} +if (typeof module !== "undefined") { + $module = module; +} + +if (!$global.fs && $global.require) { + try { + var fs = $global.require('fs'); + if (typeof fs === "object" && fs !== null && Object.keys(fs).length !== 0) { + $global.fs = fs; + } + } catch(e) { /* Ignore if the module couldn't be loaded. */ } +} + +if (!$global.fs) { + var outputBuf = ""; + var decoder = new TextDecoder("utf-8"); + $global.fs = { + constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1 }, // unused + writeSync: function writeSync(fd, buf) { + outputBuf += decoder.decode(buf); + var nl = outputBuf.lastIndexOf("\n"); + if (nl != -1) { + console.log(outputBuf.substr(0, nl)); + outputBuf = outputBuf.substr(nl + 1); + } + return buf.length; + }, + write: function write(fd, buf, offset, length, position, callback) { + if (offset !== 0 || length !== buf.length || position !== null) { + callback(enosys()); + return; + } + var n = this.writeSync(fd, buf); + callback(null, n); + } + }; +} + +var $linknames = {} // Collection of functions referenced by a go:linkname directive. +var $packages = {}, $idCounter = 0; +var $keys = function(m) { return m ? Object.keys(m) : []; }; +var $flushConsole = function() {}; +var $throwRuntimeError; /* set by package "runtime" */ +var $throwNilPointerError = function() { $throwRuntimeError("invalid memory address or nil pointer dereference"); }; +var $call = function(fn, rcvr, args) { return fn.apply(rcvr, args); }; +var $makeFunc = function(fn) { return function() { return $externalize(fn(this, new ($sliceType($jsObjectPtr))($global.Array.prototype.slice.call(arguments, []))), $emptyInterface); }; }; +var $unused = function(v) {}; +var $print = console.log; +// Under Node we can emulate print() more closely by avoiding a newline. +if (($global.process !== undefined) && $global.require) { + try { + var util = $global.require('util'); + $print = function() { $global.process.stderr.write(util.format.apply(this, arguments)); }; + } catch (e) { + // Failed to require util module, keep using console.log(). + } +} +var $println = console.log + +var $initAllLinknames = function() { + var names = $keys($packages); + for (var i = 0; i < names.length; i++) { + var f = $packages[names[i]]["$initLinknames"]; + if (typeof f == 'function') { + f(); + } + } +} + +var $mapArray = function(array, f) { + var newArray = new array.constructor(array.length); + for (var i = 0; i < array.length; i++) { + newArray[i] = f(array[i]); + } + return newArray; +}; + +// Returns a method bound to the receiver instance, safe to invoke as a +// standalone function. Bound function is cached for later reuse. +var $methodVal = function(recv, name) { + var vals = recv.$methodVals || {}; + recv.$methodVals = vals; /* noop for primitives */ + var f = vals[name]; + if (f !== undefined) { + return f; + } + var method = recv[name]; + f = method.bind(recv); + vals[name] = f; + return f; +}; + +var $methodExpr = function(typ, name) { + var method = typ.prototype[name]; + if (method.$expr === undefined) { + method.$expr = function() { + $stackDepthOffset--; + try { + if (typ.wrapped) { + arguments[0] = new typ(arguments[0]); + } + return Function.call.apply(method, arguments); + } finally { + $stackDepthOffset++; + } + }; + } + return method.$expr; +}; + +var $ifaceMethodExprs = {}; +var $ifaceMethodExpr = function(name) { + var expr = $ifaceMethodExprs["$" + name]; + if (expr === undefined) { + expr = $ifaceMethodExprs["$" + name] = function() { + $stackDepthOffset--; + try { + return Function.call.apply(arguments[0][name], arguments); + } finally { + $stackDepthOffset++; + } + }; + } + return expr; +}; + +var $subslice = function(slice, low, high, max) { + if (high === undefined) { + high = slice.$length; + } + if (max === undefined) { + max = slice.$capacity; + } + if (low < 0 || high < low || max < high || high > slice.$capacity || max > slice.$capacity) { + $throwRuntimeError("slice bounds out of range"); + } + if (slice === slice.constructor.nil) { + return slice; + } + var s = new slice.constructor(slice.$array); + s.$offset = slice.$offset + low; + s.$length = high - low; + s.$capacity = max - low; + return s; +}; + +var $substring = function(str, low, high) { + if (low < 0 || high < low || high > str.length) { + $throwRuntimeError("slice bounds out of range"); + } + return str.substring(low, high); +}; + +// Convert Go slice to an equivalent JS array type. +var $sliceToNativeArray = function(slice) { + if (slice.$array.constructor !== Array) { + return slice.$array.subarray(slice.$offset, slice.$offset + slice.$length); + } + return slice.$array.slice(slice.$offset, slice.$offset + slice.$length); +}; + +// Convert Go slice to a pointer to an underlying Go array. +// +// Note that an array pointer can be represented by an "unwrapped" native array +// type, and it will be wrapped back into its Go type when necessary. +var $sliceToGoArray = function(slice, arrayPtrType) { + var arrayType = arrayPtrType.elem; + if (arrayType !== undefined && slice.$length < arrayType.len) { + $throwRuntimeError("cannot convert slice with length " + slice.$length + " to pointer to array with length " + arrayType.len); + } + if (slice == slice.constructor.nil) { + return arrayPtrType.nil; // Nil slice converts to nil array pointer. + } + if (slice.$array.constructor !== Array) { + return slice.$array.subarray(slice.$offset, slice.$offset + arrayType.len); + } + if (slice.$offset == 0 && slice.$length == slice.$capacity && slice.$length == arrayType.len) { + return slice.$array; + } + if (arrayType.len == 0) { + return new arrayType([]); + } + + // Array.slice (unlike TypedArray.subarray) returns a copy of an array range, + // which is not sharing memory with the original one, which violates the spec + // for slice to array conversion. This is incompatible with the Go spec, in + // particular that the assignments to the array elements would be visible in + // the slice. Prefer to fail explicitly instead of creating subtle bugs. + $throwRuntimeError("gopherjs: non-numeric slice to underlying array conversion is not supported for subslices"); +}; + +// Convert between compatible slice types (e.g. native and names). +var $convertSliceType = function(slice, desiredType) { + if (slice == slice.constructor.nil) { + return desiredType.nil; // Preserve nil value. + } + + return $subslice(new desiredType(slice.$array), slice.$offset, slice.$offset + slice.$length); +} + +var $decodeRune = function(str, pos) { + var c0 = str.charCodeAt(pos); + + if (c0 < 0x80) { + return [c0, 1]; + } + + if (c0 !== c0 || c0 < 0xC0) { + return [0xFFFD, 1]; + } + + var c1 = str.charCodeAt(pos + 1); + if (c1 !== c1 || c1 < 0x80 || 0xC0 <= c1) { + return [0xFFFD, 1]; + } + + if (c0 < 0xE0) { + var r = (c0 & 0x1F) << 6 | (c1 & 0x3F); + if (r <= 0x7F) { + return [0xFFFD, 1]; + } + return [r, 2]; + } + + var c2 = str.charCodeAt(pos + 2); + if (c2 !== c2 || c2 < 0x80 || 0xC0 <= c2) { + return [0xFFFD, 1]; + } + + if (c0 < 0xF0) { + var r = (c0 & 0x0F) << 12 | (c1 & 0x3F) << 6 | (c2 & 0x3F); + if (r <= 0x7FF) { + return [0xFFFD, 1]; + } + if (0xD800 <= r && r <= 0xDFFF) { + return [0xFFFD, 1]; + } + return [r, 3]; + } + + var c3 = str.charCodeAt(pos + 3); + if (c3 !== c3 || c3 < 0x80 || 0xC0 <= c3) { + return [0xFFFD, 1]; + } + + if (c0 < 0xF8) { + var r = (c0 & 0x07) << 18 | (c1 & 0x3F) << 12 | (c2 & 0x3F) << 6 | (c3 & 0x3F); + if (r <= 0xFFFF || 0x10FFFF < r) { + return [0xFFFD, 1]; + } + return [r, 4]; + } + + return [0xFFFD, 1]; +}; + +var $encodeRune = function(r) { + if (r < 0 || r > 0x10FFFF || (0xD800 <= r && r <= 0xDFFF)) { + r = 0xFFFD; + } + if (r <= 0x7F) { + return String.fromCharCode(r); + } + if (r <= 0x7FF) { + return String.fromCharCode(0xC0 | r >> 6, 0x80 | (r & 0x3F)); + } + if (r <= 0xFFFF) { + return String.fromCharCode(0xE0 | r >> 12, 0x80 | (r >> 6 & 0x3F), 0x80 | (r & 0x3F)); + } + return String.fromCharCode(0xF0 | r >> 18, 0x80 | (r >> 12 & 0x3F), 0x80 | (r >> 6 & 0x3F), 0x80 | (r & 0x3F)); +}; + +var $stringToBytes = function(str) { + var array = new Uint8Array(str.length); + for (var i = 0; i < str.length; i++) { + array[i] = str.charCodeAt(i); + } + return array; +}; + +var $bytesToString = function(slice) { + if (slice.$length === 0) { + return ""; + } + var str = ""; + for (var i = 0; i < slice.$length; i += 10000) { + str += String.fromCharCode.apply(undefined, slice.$array.subarray(slice.$offset + i, slice.$offset + Math.min(slice.$length, i + 10000))); + } + return str; +}; + +var $stringToRunes = function(str) { + var array = new Int32Array(str.length); + var rune, j = 0; + for (var i = 0; i < str.length; i += rune[1], j++) { + rune = $decodeRune(str, i); + array[j] = rune[0]; + } + return array.subarray(0, j); +}; + +var $runesToString = function(slice) { + if (slice.$length === 0) { + return ""; + } + var str = ""; + for (var i = 0; i < slice.$length; i++) { + str += $encodeRune(slice.$array[slice.$offset + i]); + } + return str; +}; + +var $copyString = function(dst, src) { + var n = Math.min(src.length, dst.$length); + for (var i = 0; i < n; i++) { + dst.$array[dst.$offset + i] = src.charCodeAt(i); + } + return n; +}; + +var $copySlice = function(dst, src) { + var n = Math.min(src.$length, dst.$length); + $copyArray(dst.$array, src.$array, dst.$offset, src.$offset, n, dst.constructor.elem); + return n; +}; + +var $copyArray = function(dst, src, dstOffset, srcOffset, n, elem) { + if (n === 0 || (dst === src && dstOffset === srcOffset)) { + return; + } + + if (src.subarray) { + dst.set(src.subarray(srcOffset, srcOffset + n), dstOffset); + return; + } + + switch (elem.kind) { + case $kindArray: + case $kindStruct: + if (dst === src && dstOffset > srcOffset) { + for (var i = n - 1; i >= 0; i--) { + elem.copy(dst[dstOffset + i], src[srcOffset + i]); + } + return; + } + for (var i = 0; i < n; i++) { + elem.copy(dst[dstOffset + i], src[srcOffset + i]); + } + return; + } + + if (dst === src && dstOffset > srcOffset) { + for (var i = n - 1; i >= 0; i--) { + dst[dstOffset + i] = src[srcOffset + i]; + } + return; + } + for (var i = 0; i < n; i++) { + dst[dstOffset + i] = src[srcOffset + i]; + } +}; + +var $clone = function(src, type) { + var clone = type.zero(); + type.copy(clone, src); + return clone; +}; + +var $pointerOfStructConversion = function(obj, type) { + if(obj.$proxies === undefined) { + obj.$proxies = {}; + obj.$proxies[obj.constructor.string] = obj; + } + var proxy = obj.$proxies[type.string]; + if (proxy === undefined) { + var properties = {}; + for (var i = 0; i < type.elem.fields.length; i++) { + (function(fieldProp) { + properties[fieldProp] = { + get: function() { return obj[fieldProp]; }, + set: function(value) { obj[fieldProp] = value; } + }; + })(type.elem.fields[i].prop); + } + proxy = Object.create(type.prototype, properties); + proxy.$val = proxy; + obj.$proxies[type.string] = proxy; + proxy.$proxies = obj.$proxies; + } + return proxy; +}; + +var $append = function(slice) { + return $internalAppend(slice, arguments, 1, arguments.length - 1); +}; + +var $appendSlice = function(slice, toAppend) { + if (toAppend.constructor === String) { + var bytes = $stringToBytes(toAppend); + return $internalAppend(slice, bytes, 0, bytes.length); + } + return $internalAppend(slice, toAppend.$array, toAppend.$offset, toAppend.$length); +}; + +var $internalAppend = function(slice, array, offset, length) { + if (length === 0) { + return slice; + } + + var newArray = slice.$array; + var newOffset = slice.$offset; + var newLength = slice.$length + length; + var newCapacity = slice.$capacity; + + if (newLength > newCapacity) { + newOffset = 0; + newCapacity = Math.max(newLength, slice.$capacity < 1024 ? slice.$capacity * 2 : Math.floor(slice.$capacity * 5 / 4)); + + if (slice.$array.constructor === Array) { + newArray = slice.$array.slice(slice.$offset, slice.$offset + slice.$length); + newArray.length = newCapacity; + var zero = slice.constructor.elem.zero; + for (var i = slice.$length; i < newCapacity; i++) { + newArray[i] = zero(); + } + } else { + newArray = new slice.$array.constructor(newCapacity); + newArray.set(slice.$array.subarray(slice.$offset, slice.$offset + slice.$length)); + } + } + + $copyArray(newArray, array, newOffset + slice.$length, offset, length, slice.constructor.elem); + + var newSlice = new slice.constructor(newArray); + newSlice.$offset = newOffset; + newSlice.$length = newLength; + newSlice.$capacity = newCapacity; + return newSlice; +}; + +var $equal = function(a, b, type) { + if (type === $jsObjectPtr) { + return a === b; + } + switch (type.kind) { + case $kindComplex64: + case $kindComplex128: + return a.$real === b.$real && a.$imag === b.$imag; + case $kindInt64: + case $kindUint64: + return a.$high === b.$high && a.$low === b.$low; + case $kindArray: + if (a.length !== b.length) { + return false; + } + for (var i = 0; i < a.length; i++) { + if (!$equal(a[i], b[i], type.elem)) { + return false; + } + } + return true; + case $kindStruct: + for (var i = 0; i < type.fields.length; i++) { + var f = type.fields[i]; + if (!$equal(a[f.prop], b[f.prop], f.typ)) { + return false; + } + } + return true; + case $kindInterface: + return $interfaceIsEqual(a, b); + default: + return a === b; + } +}; + +var $interfaceIsEqual = function(a, b) { + if (a === $ifaceNil || b === $ifaceNil) { + return a === b; + } + if (a.constructor !== b.constructor) { + return false; + } + if (a.constructor === $jsObjectPtr) { + return a.object === b.object; + } + if (!a.constructor.comparable) { + $throwRuntimeError("comparing uncomparable type " + a.constructor.string); + } + return $equal(a.$val, b.$val, a.constructor); +}; + +var $min = Math.min; +var $mod = function(x, y) { return x % y; }; +var $parseInt = parseInt; +var $parseFloat = function(f) { + if (f !== undefined && f !== null && f.constructor === Number) { + return f; + } + return parseFloat(f); +}; + +var $froundBuf = new Float32Array(1); +var $fround = Math.fround || function(f) { + $froundBuf[0] = f; + return $froundBuf[0]; +}; + +var $imul = Math.imul || function(a, b) { + var ah = (a >>> 16) & 0xffff; + var al = a & 0xffff; + var bh = (b >>> 16) & 0xffff; + var bl = b & 0xffff; + return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0) >> 0); +}; + +var $floatKey = function(f) { + if (f !== f) { + $idCounter++; + return "NaN$" + $idCounter; + } + return String(f); +}; + +var $flatten64 = function(x) { + return x.$high * 4294967296 + x.$low; +}; + +var $shiftLeft64 = function(x, y) { + if (y === 0) { + return x; + } + if (y < 32) { + return new x.constructor(x.$high << y | x.$low >>> (32 - y), (x.$low << y) >>> 0); + } + if (y < 64) { + return new x.constructor(x.$low << (y - 32), 0); + } + return new x.constructor(0, 0); +}; + +var $shiftRightInt64 = function(x, y) { + if (y === 0) { + return x; + } + if (y < 32) { + return new x.constructor(x.$high >> y, (x.$low >>> y | x.$high << (32 - y)) >>> 0); + } + if (y < 64) { + return new x.constructor(x.$high >> 31, (x.$high >> (y - 32)) >>> 0); + } + if (x.$high < 0) { + return new x.constructor(-1, 4294967295); + } + return new x.constructor(0, 0); +}; + +var $shiftRightUint64 = function(x, y) { + if (y === 0) { + return x; + } + if (y < 32) { + return new x.constructor(x.$high >>> y, (x.$low >>> y | x.$high << (32 - y)) >>> 0); + } + if (y < 64) { + return new x.constructor(0, x.$high >>> (y - 32)); + } + return new x.constructor(0, 0); +}; + +var $mul64 = function(x, y) { + var x48 = x.$high >>> 16; + var x32 = x.$high & 0xFFFF; + var x16 = x.$low >>> 16; + var x00 = x.$low & 0xFFFF; + + var y48 = y.$high >>> 16; + var y32 = y.$high & 0xFFFF; + var y16 = y.$low >>> 16; + var y00 = y.$low & 0xFFFF; + + var z48 = 0, z32 = 0, z16 = 0, z00 = 0; + z00 += x00 * y00; + z16 += z00 >>> 16; + z00 &= 0xFFFF; + z16 += x16 * y00; + z32 += z16 >>> 16; + z16 &= 0xFFFF; + z16 += x00 * y16; + z32 += z16 >>> 16; + z16 &= 0xFFFF; + z32 += x32 * y00; + z48 += z32 >>> 16; + z32 &= 0xFFFF; + z32 += x16 * y16; + z48 += z32 >>> 16; + z32 &= 0xFFFF; + z32 += x00 * y32; + z48 += z32 >>> 16; + z32 &= 0xFFFF; + z48 += x48 * y00 + x32 * y16 + x16 * y32 + x00 * y48; + z48 &= 0xFFFF; + + var hi = ((z48 << 16) | z32) >>> 0; + var lo = ((z16 << 16) | z00) >>> 0; + + var r = new x.constructor(hi, lo); + return r; +}; + +var $div64 = function(x, y, returnRemainder) { + if (y.$high === 0 && y.$low === 0) { + $throwRuntimeError("integer divide by zero"); + } + + var s = 1; + var rs = 1; + + var xHigh = x.$high; + var xLow = x.$low; + if (xHigh < 0) { + s = -1; + rs = -1; + xHigh = -xHigh; + if (xLow !== 0) { + xHigh--; + xLow = 4294967296 - xLow; + } + } + + var yHigh = y.$high; + var yLow = y.$low; + if (y.$high < 0) { + s *= -1; + yHigh = -yHigh; + if (yLow !== 0) { + yHigh--; + yLow = 4294967296 - yLow; + } + } + + var high = 0, low = 0, n = 0; + while (yHigh < 2147483648 && ((xHigh > yHigh) || (xHigh === yHigh && xLow > yLow))) { + yHigh = (yHigh << 1 | yLow >>> 31) >>> 0; + yLow = (yLow << 1) >>> 0; + n++; + } + for (var i = 0; i <= n; i++) { + high = high << 1 | low >>> 31; + low = (low << 1) >>> 0; + if ((xHigh > yHigh) || (xHigh === yHigh && xLow >= yLow)) { + xHigh = xHigh - yHigh; + xLow = xLow - yLow; + if (xLow < 0) { + xHigh--; + xLow += 4294967296; + } + low++; + if (low === 4294967296) { + high++; + low = 0; + } + } + yLow = (yLow >>> 1 | yHigh << (32 - 1)) >>> 0; + yHigh = yHigh >>> 1; + } + + if (returnRemainder) { + return new x.constructor(xHigh * rs, xLow * rs); + } + return new x.constructor(high * s, low * s); +}; + +var $divComplex = function(n, d) { + var ninf = n.$real === Infinity || n.$real === -Infinity || n.$imag === Infinity || n.$imag === -Infinity; + var dinf = d.$real === Infinity || d.$real === -Infinity || d.$imag === Infinity || d.$imag === -Infinity; + var nnan = !ninf && (n.$real !== n.$real || n.$imag !== n.$imag); + var dnan = !dinf && (d.$real !== d.$real || d.$imag !== d.$imag); + if(nnan || dnan) { + return new n.constructor(NaN, NaN); + } + if (ninf && !dinf) { + return new n.constructor(Infinity, Infinity); + } + if (!ninf && dinf) { + return new n.constructor(0, 0); + } + if (d.$real === 0 && d.$imag === 0) { + if (n.$real === 0 && n.$imag === 0) { + return new n.constructor(NaN, NaN); + } + return new n.constructor(Infinity, Infinity); + } + var a = Math.abs(d.$real); + var b = Math.abs(d.$imag); + if (a <= b) { + var ratio = d.$real / d.$imag; + var denom = d.$real * ratio + d.$imag; + return new n.constructor((n.$real * ratio + n.$imag) / denom, (n.$imag * ratio - n.$real) / denom); + } + var ratio = d.$imag / d.$real; + var denom = d.$imag * ratio + d.$real; + return new n.constructor((n.$imag * ratio + n.$real) / denom, (n.$imag - n.$real * ratio) / denom); +}; + +var $kindBool = 1; +var $kindInt = 2; +var $kindInt8 = 3; +var $kindInt16 = 4; +var $kindInt32 = 5; +var $kindInt64 = 6; +var $kindUint = 7; +var $kindUint8 = 8; +var $kindUint16 = 9; +var $kindUint32 = 10; +var $kindUint64 = 11; +var $kindUintptr = 12; +var $kindFloat32 = 13; +var $kindFloat64 = 14; +var $kindComplex64 = 15; +var $kindComplex128 = 16; +var $kindArray = 17; +var $kindChan = 18; +var $kindFunc = 19; +var $kindInterface = 20; +var $kindMap = 21; +var $kindPtr = 22; +var $kindSlice = 23; +var $kindString = 24; +var $kindStruct = 25; +var $kindUnsafePointer = 26; + +var $methodSynthesizers = []; +var $addMethodSynthesizer = function(f) { + if ($methodSynthesizers === null) { + f(); + return; + } + $methodSynthesizers.push(f); +}; +var $synthesizeMethods = function() { + $methodSynthesizers.forEach(function(f) { f(); }); + $methodSynthesizers = null; +}; + +var $ifaceKeyFor = function(x) { + if (x === $ifaceNil) { + return 'nil'; + } + var c = x.constructor; + return c.string + '$' + c.keyFor(x.$val); +}; + +var $identity = function(x) { return x; }; + +var $typeIDCounter = 0; + +var $idKey = function(x) { + if (x.$id === undefined) { + $idCounter++; + x.$id = $idCounter; + } + return String(x.$id); +}; + +// Creates constructor functions for array pointer types. Returns a new function +// instace each time to make sure each type is independent of the other. +var $arrayPtrCtor = function() { + return function(array) { + this.$get = function() { return array; }; + this.$set = function(v) { typ.copy(this, v); }; + this.$val = array; + } +} + +var $newType = function(size, kind, string, named, pkg, exported, constructor) { + var typ; + switch(kind) { + case $kindBool: + case $kindInt: + case $kindInt8: + case $kindInt16: + case $kindInt32: + case $kindUint: + case $kindUint8: + case $kindUint16: + case $kindUint32: + case $kindUintptr: + case $kindUnsafePointer: + typ = function(v) { this.$val = v; }; + typ.wrapped = true; + typ.keyFor = $identity; + break; + + case $kindString: + typ = function(v) { this.$val = v; }; + typ.wrapped = true; + typ.keyFor = function(x) { return "$" + x; }; + break; + + case $kindFloat32: + case $kindFloat64: + typ = function(v) { this.$val = v; }; + typ.wrapped = true; + typ.keyFor = function(x) { return $floatKey(x); }; + break; + + case $kindInt64: + typ = function(high, low) { + this.$high = (high + Math.floor(Math.ceil(low) / 4294967296)) >> 0; + this.$low = low >>> 0; + this.$val = this; + }; + typ.keyFor = function(x) { return x.$high + "$" + x.$low; }; + break; + + case $kindUint64: + typ = function(high, low) { + this.$high = (high + Math.floor(Math.ceil(low) / 4294967296)) >>> 0; + this.$low = low >>> 0; + this.$val = this; + }; + typ.keyFor = function(x) { return x.$high + "$" + x.$low; }; + break; + + case $kindComplex64: + typ = function(real, imag) { + this.$real = $fround(real); + this.$imag = $fround(imag); + this.$val = this; + }; + typ.keyFor = function(x) { return x.$real + "$" + x.$imag; }; + break; + + case $kindComplex128: + typ = function(real, imag) { + this.$real = real; + this.$imag = imag; + this.$val = this; + }; + typ.keyFor = function(x) { return x.$real + "$" + x.$imag; }; + break; + + case $kindArray: + typ = function(v) { this.$val = v; }; + typ.wrapped = true; + typ.ptr = $newType(4, $kindPtr, "*" + string, false, "", false, $arrayPtrCtor()); + typ.init = function(elem, len) { + typ.elem = elem; + typ.len = len; + typ.comparable = elem.comparable; + typ.keyFor = function(x) { + return Array.prototype.join.call($mapArray(x, function(e) { + return String(elem.keyFor(e)).replace(/\\/g, "\\\\").replace(/\$/g, "\\$"); + }), "$"); + }; + typ.copy = function(dst, src) { + $copyArray(dst, src, 0, 0, src.length, elem); + }; + typ.ptr.init(typ); + Object.defineProperty(typ.ptr.nil, "nilCheck", { get: $throwNilPointerError }); + }; + break; + + case $kindChan: + typ = function(v) { this.$val = v; }; + typ.wrapped = true; + typ.keyFor = $idKey; + typ.init = function(elem, sendOnly, recvOnly) { + typ.elem = elem; + typ.sendOnly = sendOnly; + typ.recvOnly = recvOnly; + }; + break; + + case $kindFunc: + typ = function(v) { this.$val = v; }; + typ.wrapped = true; + typ.init = function(params, results, variadic) { + typ.params = params; + typ.results = results; + typ.variadic = variadic; + typ.comparable = false; + }; + break; + + case $kindInterface: + typ = { implementedBy: {}, missingMethodFor: {} }; + typ.keyFor = $ifaceKeyFor; + typ.init = function(methods) { + typ.methods = methods; + methods.forEach(function(m) { + $ifaceNil[m.prop] = $throwNilPointerError; + }); + }; + break; + + case $kindMap: + typ = function(v) { this.$val = v; }; + typ.wrapped = true; + typ.init = function(key, elem) { + typ.key = key; + typ.elem = elem; + typ.comparable = false; + }; + break; + + case $kindPtr: + typ = constructor || function(getter, setter, target) { + this.$get = getter; + this.$set = setter; + this.$target = target; + this.$val = this; + }; + typ.keyFor = $idKey; + typ.init = function(elem) { + typ.elem = elem; + typ.wrapped = (elem.kind === $kindArray); + typ.nil = new typ($throwNilPointerError, $throwNilPointerError); + }; + break; + + case $kindSlice: + typ = function(array) { + if (array.constructor !== typ.nativeArray) { + array = new typ.nativeArray(array); + } + this.$array = array; + this.$offset = 0; + this.$length = array.length; + this.$capacity = array.length; + this.$val = this; + }; + typ.init = function(elem) { + typ.elem = elem; + typ.comparable = false; + typ.nativeArray = $nativeArray(elem.kind); + typ.nil = new typ([]); + }; + break; + + case $kindStruct: + typ = function(v) { this.$val = v; }; + typ.wrapped = true; + typ.ptr = $newType(4, $kindPtr, "*" + string, false, pkg, exported, constructor); + typ.ptr.elem = typ; + typ.ptr.prototype.$get = function() { return this; }; + typ.ptr.prototype.$set = function(v) { typ.copy(this, v); }; + typ.init = function(pkgPath, fields) { + typ.pkgPath = pkgPath; + typ.fields = fields; + fields.forEach(function(f) { + if (!f.typ.comparable) { + typ.comparable = false; + } + }); + typ.keyFor = function(x) { + var val = x.$val; + return $mapArray(fields, function(f) { + return String(f.typ.keyFor(val[f.prop])).replace(/\\/g, "\\\\").replace(/\$/g, "\\$"); + }).join("$"); + }; + typ.copy = function(dst, src) { + for (var i = 0; i < fields.length; i++) { + var f = fields[i]; + switch (f.typ.kind) { + case $kindArray: + case $kindStruct: + f.typ.copy(dst[f.prop], src[f.prop]); + continue; + default: + dst[f.prop] = src[f.prop]; + continue; + } + } + }; + /* nil value */ + var properties = {}; + fields.forEach(function(f) { + properties[f.prop] = { get: $throwNilPointerError, set: $throwNilPointerError }; + }); + typ.ptr.nil = Object.create(constructor.prototype, properties); + typ.ptr.nil.$val = typ.ptr.nil; + /* methods for embedded fields */ + $addMethodSynthesizer(function() { + var synthesizeMethod = function(target, m, f) { + if (target.prototype[m.prop] !== undefined) { return; } + target.prototype[m.prop] = function() { + var v = this.$val[f.prop]; + if (f.typ === $jsObjectPtr) { + v = new $jsObjectPtr(v); + } + if (v.$val === undefined) { + v = new f.typ(v); + } + return v[m.prop].apply(v, arguments); + }; + }; + fields.forEach(function(f) { + if (f.embedded) { + $methodSet(f.typ).forEach(function(m) { + synthesizeMethod(typ, m, f); + synthesizeMethod(typ.ptr, m, f); + }); + $methodSet($ptrType(f.typ)).forEach(function(m) { + synthesizeMethod(typ.ptr, m, f); + }); + } + }); + }); + }; + break; + + default: + $panic(new $String("invalid kind: " + kind)); + } + + switch (kind) { + case $kindBool: + case $kindMap: + typ.zero = function() { return false; }; + break; + + case $kindInt: + case $kindInt8: + case $kindInt16: + case $kindInt32: + case $kindUint: + case $kindUint8 : + case $kindUint16: + case $kindUint32: + case $kindUintptr: + case $kindUnsafePointer: + case $kindFloat32: + case $kindFloat64: + typ.zero = function() { return 0; }; + break; + + case $kindString: + typ.zero = function() { return ""; }; + break; + + case $kindInt64: + case $kindUint64: + case $kindComplex64: + case $kindComplex128: + var zero = new typ(0, 0); + typ.zero = function() { return zero; }; + break; + + case $kindPtr: + case $kindSlice: + typ.zero = function() { return typ.nil; }; + break; + + case $kindChan: + typ.zero = function() { return $chanNil; }; + break; + + case $kindFunc: + typ.zero = function() { return $throwNilPointerError; }; + break; + + case $kindInterface: + typ.zero = function() { return $ifaceNil; }; + break; + + case $kindArray: + typ.zero = function() { + var arrayClass = $nativeArray(typ.elem.kind); + if (arrayClass !== Array) { + return new arrayClass(typ.len); + } + var array = new Array(typ.len); + for (var i = 0; i < typ.len; i++) { + array[i] = typ.elem.zero(); + } + return array; + }; + break; + + case $kindStruct: + typ.zero = function() { return new typ.ptr(); }; + break; + + default: + $panic(new $String("invalid kind: " + kind)); + } + + typ.id = $typeIDCounter; + $typeIDCounter++; + typ.size = size; + typ.kind = kind; + typ.string = string; + typ.named = named; + typ.pkg = pkg; + typ.exported = exported; + typ.methods = []; + typ.methodSetCache = null; + typ.comparable = true; + return typ; +}; + +var $methodSet = function(typ) { + if (typ.methodSetCache !== null) { + return typ.methodSetCache; + } + var base = {}; + + var isPtr = (typ.kind === $kindPtr); + if (isPtr && typ.elem.kind === $kindInterface) { + typ.methodSetCache = []; + return []; + } + + var current = [{typ: isPtr ? typ.elem : typ, indirect: isPtr}]; + + var seen = {}; + + while (current.length > 0) { + var next = []; + var mset = []; + + current.forEach(function(e) { + if (seen[e.typ.string]) { + return; + } + seen[e.typ.string] = true; + + if (e.typ.named) { + mset = mset.concat(e.typ.methods); + if (e.indirect) { + mset = mset.concat($ptrType(e.typ).methods); + } + } + + switch (e.typ.kind) { + case $kindStruct: + e.typ.fields.forEach(function(f) { + if (f.embedded) { + var fTyp = f.typ; + var fIsPtr = (fTyp.kind === $kindPtr); + next.push({typ: fIsPtr ? fTyp.elem : fTyp, indirect: e.indirect || fIsPtr}); + } + }); + break; + + case $kindInterface: + mset = mset.concat(e.typ.methods); + break; + } + }); + + mset.forEach(function(m) { + if (base[m.name] === undefined) { + base[m.name] = m; + } + }); + + current = next; + } + + typ.methodSetCache = []; + Object.keys(base).sort().forEach(function(name) { + typ.methodSetCache.push(base[name]); + }); + return typ.methodSetCache; +}; + +var $Bool = $newType( 1, $kindBool, "bool", true, "", false, null); +var $Int = $newType( 4, $kindInt, "int", true, "", false, null); +var $Int8 = $newType( 1, $kindInt8, "int8", true, "", false, null); +var $Int16 = $newType( 2, $kindInt16, "int16", true, "", false, null); +var $Int32 = $newType( 4, $kindInt32, "int32", true, "", false, null); +var $Int64 = $newType( 8, $kindInt64, "int64", true, "", false, null); +var $Uint = $newType( 4, $kindUint, "uint", true, "", false, null); +var $Uint8 = $newType( 1, $kindUint8, "uint8", true, "", false, null); +var $Uint16 = $newType( 2, $kindUint16, "uint16", true, "", false, null); +var $Uint32 = $newType( 4, $kindUint32, "uint32", true, "", false, null); +var $Uint64 = $newType( 8, $kindUint64, "uint64", true, "", false, null); +var $Uintptr = $newType( 4, $kindUintptr, "uintptr", true, "", false, null); +var $Float32 = $newType( 4, $kindFloat32, "float32", true, "", false, null); +var $Float64 = $newType( 8, $kindFloat64, "float64", true, "", false, null); +var $Complex64 = $newType( 8, $kindComplex64, "complex64", true, "", false, null); +var $Complex128 = $newType(16, $kindComplex128, "complex128", true, "", false, null); +var $String = $newType( 8, $kindString, "string", true, "", false, null); +var $UnsafePointer = $newType( 4, $kindUnsafePointer, "unsafe.Pointer", true, "unsafe", false, null); + +var $nativeArray = function(elemKind) { + switch (elemKind) { + case $kindInt: + return Int32Array; + case $kindInt8: + return Int8Array; + case $kindInt16: + return Int16Array; + case $kindInt32: + return Int32Array; + case $kindUint: + return Uint32Array; + case $kindUint8: + return Uint8Array; + case $kindUint16: + return Uint16Array; + case $kindUint32: + return Uint32Array; + case $kindUintptr: + return Uint32Array; + case $kindFloat32: + return Float32Array; + case $kindFloat64: + return Float64Array; + default: + return Array; + } +}; +var $toNativeArray = function(elemKind, array) { + var nativeArray = $nativeArray(elemKind); + if (nativeArray === Array) { + return array; + } + return new nativeArray(array); +}; +var $arrayTypes = {}; +var $arrayType = function(elem, len) { + var typeKey = elem.id + "$" + len; + var typ = $arrayTypes[typeKey]; + if (typ === undefined) { + typ = $newType(12, $kindArray, "[" + len + "]" + elem.string, false, "", false, null); + $arrayTypes[typeKey] = typ; + typ.init(elem, len); + } + return typ; +}; + +var $chanType = function(elem, sendOnly, recvOnly) { + var string = (recvOnly ? "<-" : "") + "chan" + (sendOnly ? "<- " : " "); + if (!sendOnly && !recvOnly && (elem.string[0] == "<")) { + string += "(" + elem.string + ")"; + } else { + string += elem.string; + } + var field = sendOnly ? "SendChan" : (recvOnly ? "RecvChan" : "Chan"); + var typ = elem[field]; + if (typ === undefined) { + typ = $newType(4, $kindChan, string, false, "", false, null); + elem[field] = typ; + typ.init(elem, sendOnly, recvOnly); + } + return typ; +}; +var $Chan = function(elem, capacity) { + if (capacity < 0 || capacity > 2147483647) { + $throwRuntimeError("makechan: size out of range"); + } + this.$elem = elem; + this.$capacity = capacity; + this.$buffer = []; + this.$sendQueue = []; + this.$recvQueue = []; + this.$closed = false; +}; +var $chanNil = new $Chan(null, 0); +$chanNil.$sendQueue = $chanNil.$recvQueue = { length: 0, push: function() {}, shift: function() { return undefined; }, indexOf: function() { return -1; } }; + +var $funcTypes = {}; +var $funcType = function(params, results, variadic) { + var typeKey = $mapArray(params, function(p) { return p.id; }).join(",") + "$" + $mapArray(results, function(r) { return r.id; }).join(",") + "$" + variadic; + var typ = $funcTypes[typeKey]; + if (typ === undefined) { + var paramTypes = $mapArray(params, function(p) { return p.string; }); + if (variadic) { + paramTypes[paramTypes.length - 1] = "..." + paramTypes[paramTypes.length - 1].substr(2); + } + var string = "func(" + paramTypes.join(", ") + ")"; + if (results.length === 1) { + string += " " + results[0].string; + } else if (results.length > 1) { + string += " (" + $mapArray(results, function(r) { return r.string; }).join(", ") + ")"; + } + typ = $newType(4, $kindFunc, string, false, "", false, null); + $funcTypes[typeKey] = typ; + typ.init(params, results, variadic); + } + return typ; +}; + +var $interfaceTypes = {}; +var $interfaceType = function(methods) { + var typeKey = $mapArray(methods, function(m) { return m.pkg + "," + m.name + "," + m.typ.id; }).join("$"); + var typ = $interfaceTypes[typeKey]; + if (typ === undefined) { + var string = "interface {}"; + if (methods.length !== 0) { + string = "interface { " + $mapArray(methods, function(m) { + return (m.pkg !== "" ? m.pkg + "." : "") + m.name + m.typ.string.substr(4); + }).join("; ") + " }"; + } + typ = $newType(8, $kindInterface, string, false, "", false, null); + $interfaceTypes[typeKey] = typ; + typ.init(methods); + } + return typ; +}; +var $emptyInterface = $interfaceType([]); +var $ifaceNil = {}; +var $error = $newType(8, $kindInterface, "error", true, "", false, null); +$error.init([{prop: "Error", name: "Error", pkg: "", typ: $funcType([], [$String], false)}]); + +var $mapTypes = {}; +var $mapType = function(key, elem) { + var typeKey = key.id + "$" + elem.id; + var typ = $mapTypes[typeKey]; + if (typ === undefined) { + typ = $newType(4, $kindMap, "map[" + key.string + "]" + elem.string, false, "", false, null); + $mapTypes[typeKey] = typ; + typ.init(key, elem); + } + return typ; +}; +var $makeMap = function(keyForFunc, entries) { + var m = {}; + for (var i = 0; i < entries.length; i++) { + var e = entries[i]; + m[keyForFunc(e.k)] = e; + } + return m; +}; + +var $ptrType = function(elem) { + var typ = elem.ptr; + if (typ === undefined) { + typ = $newType(4, $kindPtr, "*" + elem.string, false, "", elem.exported, null); + elem.ptr = typ; + typ.init(elem); + } + return typ; +}; + +var $newDataPointer = function(data, constructor) { + if (constructor.elem.kind === $kindStruct) { + return data; + } + return new constructor(function() { return data; }, function(v) { data = v; }); +}; + +var $indexPtr = function(array, index, constructor) { + if (array.buffer) { + // Pointers to the same underlying ArrayBuffer share cache. + var cache = array.buffer.$ptr = array.buffer.$ptr || {}; + // Pointers of different primitive types are non-comparable and stored in different caches. + var typeCache = cache[array.name] = cache[array.name] || {}; + var cacheIdx = array.BYTES_PER_ELEMENT * index + array.byteOffset; + return typeCache[cacheIdx] || (typeCache[cacheIdx] = new constructor(function() { return array[index]; }, function(v) { array[index] = v; })); + } else { + array.$ptr = array.$ptr || {}; + return array.$ptr[index] || (array.$ptr[index] = new constructor(function() { return array[index]; }, function(v) { array[index] = v; })); + } +}; + +var $sliceType = function(elem) { + var typ = elem.slice; + if (typ === undefined) { + typ = $newType(12, $kindSlice, "[]" + elem.string, false, "", false, null); + elem.slice = typ; + typ.init(elem); + } + return typ; +}; +var $makeSlice = function(typ, length, capacity) { + capacity = capacity || length; + if (length < 0 || length > 2147483647) { + $throwRuntimeError("makeslice: len out of range"); + } + if (capacity < 0 || capacity < length || capacity > 2147483647) { + $throwRuntimeError("makeslice: cap out of range"); + } + var array = new typ.nativeArray(capacity); + if (typ.nativeArray === Array) { + for (var i = 0; i < capacity; i++) { + array[i] = typ.elem.zero(); + } + } + var slice = new typ(array); + slice.$length = length; + return slice; +}; + +var $structTypes = {}; +var $structType = function(pkgPath, fields) { + var typeKey = $mapArray(fields, function(f) { return f.name + "," + f.typ.id + "," + f.tag; }).join("$"); + var typ = $structTypes[typeKey]; + if (typ === undefined) { + var string = "struct { " + $mapArray(fields, function(f) { + var str = f.typ.string + (f.tag !== "" ? (" \"" + f.tag.replace(/\\/g, "\\\\").replace(/"/g, "\\\"") + "\"") : ""); + if (f.embedded) { + return str; + } + return f.name + " " + str; + }).join("; ") + " }"; + if (fields.length === 0) { + string = "struct {}"; + } + typ = $newType(0, $kindStruct, string, false, "", false, function() { + this.$val = this; + for (var i = 0; i < fields.length; i++) { + var f = fields[i]; + if (f.name == '_') { + continue; + } + var arg = arguments[i]; + this[f.prop] = arg !== undefined ? arg : f.typ.zero(); + } + }); + $structTypes[typeKey] = typ; + typ.init(pkgPath, fields); + } + return typ; +}; + +var $assertType = function(value, type, returnTuple) { + var isInterface = (type.kind === $kindInterface), ok, missingMethod = ""; + if (value === $ifaceNil) { + ok = false; + } else if (!isInterface) { + ok = value.constructor === type; + } else { + var valueTypeString = value.constructor.string; + ok = type.implementedBy[valueTypeString]; + if (ok === undefined) { + ok = true; + var valueMethodSet = $methodSet(value.constructor); + var interfaceMethods = type.methods; + for (var i = 0; i < interfaceMethods.length; i++) { + var tm = interfaceMethods[i]; + var found = false; + for (var j = 0; j < valueMethodSet.length; j++) { + var vm = valueMethodSet[j]; + if (vm.name === tm.name && vm.pkg === tm.pkg && vm.typ === tm.typ) { + found = true; + break; + } + } + if (!found) { + ok = false; + type.missingMethodFor[valueTypeString] = tm.name; + break; + } + } + type.implementedBy[valueTypeString] = ok; + } + if (!ok) { + missingMethod = type.missingMethodFor[valueTypeString]; + } + } + + if (!ok) { + if (returnTuple) { + return [type.zero(), false]; + } + $panic(new $packages["runtime"].TypeAssertionError.ptr( + $packages["runtime"]._type.ptr.nil, + (value === $ifaceNil ? $packages["runtime"]._type.ptr.nil : new $packages["runtime"]._type.ptr(value.constructor.string)), + new $packages["runtime"]._type.ptr(type.string), + missingMethod)); + } + + if (!isInterface) { + value = value.$val; + } + if (type === $jsObjectPtr) { + value = value.object; + } + return returnTuple ? [value, true] : value; +}; + +var $stackDepthOffset = 0; +var $getStackDepth = function() { + var err = new Error(); + if (err.stack === undefined) { + return undefined; + } + return $stackDepthOffset + err.stack.split("\n").length; +}; + +var $panicStackDepth = null, $panicValue; +var $callDeferred = function(deferred, jsErr, fromPanic) { + if (!fromPanic && deferred !== null && $curGoroutine.deferStack.indexOf(deferred) == -1) { + throw jsErr; + } + if (jsErr !== null) { + var newErr = null; + try { + $panic(new $jsErrorPtr(jsErr)); + } catch (err) { + newErr = err; + } + $callDeferred(deferred, newErr); + return; + } + if ($curGoroutine.asleep) { + return; + } + + $stackDepthOffset--; + var outerPanicStackDepth = $panicStackDepth; + var outerPanicValue = $panicValue; + + var localPanicValue = $curGoroutine.panicStack.pop(); + if (localPanicValue !== undefined) { + $panicStackDepth = $getStackDepth(); + $panicValue = localPanicValue; + } + + try { + while (true) { + if (deferred === null) { + deferred = $curGoroutine.deferStack[$curGoroutine.deferStack.length - 1]; + if (deferred === undefined) { + /* The panic reached the top of the stack. Clear it and throw it as a JavaScript error. */ + $panicStackDepth = null; + if (localPanicValue.Object instanceof Error) { + throw localPanicValue.Object; + } + var msg; + if (localPanicValue.constructor === $String) { + msg = localPanicValue.$val; + } else if (localPanicValue.Error !== undefined) { + msg = localPanicValue.Error(); + } else if (localPanicValue.String !== undefined) { + msg = localPanicValue.String(); + } else { + msg = localPanicValue; + } + throw new Error(msg); + } + } + var call = deferred.pop(); + if (call === undefined) { + $curGoroutine.deferStack.pop(); + if (localPanicValue !== undefined) { + deferred = null; + continue; + } + return; + } + var r = call[0].apply(call[2], call[1]); + if (r && r.$blk !== undefined) { + deferred.push([r.$blk, [], r]); + if (fromPanic) { + throw null; + } + return; + } + + if (localPanicValue !== undefined && $panicStackDepth === null) { + /* error was recovered */ + if (fromPanic) { + throw null; + } + return; + } + } + } catch(e) { + // Deferred function threw a JavaScript exception or tries to unwind stack + // to the point where a panic was handled. + if (fromPanic) { + // Re-throw the exception to reach deferral execution call at the end + // of the function. + throw e; + } + // We are at the end of the function, handle the error or re-throw to + // continue unwinding if necessary, or simply stop unwinding if we got far + // enough. + $callDeferred(deferred, e, fromPanic); + } finally { + if (localPanicValue !== undefined) { + if ($panicStackDepth !== null) { + $curGoroutine.panicStack.push(localPanicValue); + } + $panicStackDepth = outerPanicStackDepth; + $panicValue = outerPanicValue; + } + $stackDepthOffset++; + } +}; + +var $panic = function(value) { + $curGoroutine.panicStack.push(value); + $callDeferred(null, null, true); +}; +var $recover = function() { + if ($panicStackDepth === null || ($panicStackDepth !== undefined && $panicStackDepth !== $getStackDepth() - 2)) { + return $ifaceNil; + } + $panicStackDepth = null; + return $panicValue; +}; +var $throw = function(err) { throw err; }; + +var $noGoroutine = { asleep: false, exit: false, deferStack: [], panicStack: [] }; +var $curGoroutine = $noGoroutine, $totalGoroutines = 0, $awakeGoroutines = 0, $checkForDeadlock = true, $exportedFunctions = 0; +var $mainFinished = false; +var $go = function(fun, args) { + $totalGoroutines++; + $awakeGoroutines++; + var $goroutine = function() { + try { + $curGoroutine = $goroutine; + var r = fun.apply(undefined, args); + if (r && r.$blk !== undefined) { + fun = function() { return r.$blk(); }; + args = []; + return; + } + $goroutine.exit = true; + } catch (err) { + if (!$goroutine.exit) { + throw err; + } + } finally { + $curGoroutine = $noGoroutine; + if ($goroutine.exit) { /* also set by runtime.Goexit() */ + $totalGoroutines--; + $goroutine.asleep = true; + } + if ($goroutine.asleep) { + $awakeGoroutines--; + if (!$mainFinished && $awakeGoroutines === 0 && $checkForDeadlock && $exportedFunctions === 0) { + console.error("fatal error: all goroutines are asleep - deadlock!"); + if ($global.process !== undefined) { + $global.process.exit(2); + } + } + } + } + }; + $goroutine.asleep = false; + $goroutine.exit = false; + $goroutine.deferStack = []; + $goroutine.panicStack = []; + $schedule($goroutine); +}; + +var $scheduled = []; +var $runScheduled = function() { + // For nested setTimeout calls browsers enforce 4ms minimum delay. We minimize + // the effect of this penalty by queueing the timer preemptively before we run + // the goroutines, and later cancelling it if it turns out unneeded. See: + // https://developer.mozilla.org/en-US/docs/Web/API/setTimeout#nested_timeouts + var nextRun = setTimeout($runScheduled); + try { + var start = Date.now(); + var r; + while ((r = $scheduled.shift()) !== undefined) { + r(); + // We need to interrupt this loop in order to allow the event loop to + // process timers, IO, etc. However, invoking scheduling through + // setTimeout is ~1000 times more expensive, so we amortize this cost by + // looping until the 4ms minimal delay has elapsed (assuming there are + // scheduled goroutines to run), and then yield to the event loop. + var elapsed = Date.now() - start; + if (elapsed > 4 || elapsed < 0) { break; } + } + } finally { + if ($scheduled.length == 0) { + // Cancel scheduling pass if there's nothing to run. + clearTimeout(nextRun); + } + } +}; + +var $schedule = function(goroutine) { + if (goroutine.asleep) { + goroutine.asleep = false; + $awakeGoroutines++; + } + $scheduled.push(goroutine); + if ($curGoroutine === $noGoroutine) { + $runScheduled(); + } +}; + +var $setTimeout = function(f, t) { + $awakeGoroutines++; + return setTimeout(function() { + $awakeGoroutines--; + f(); + }, t); +}; + +var $block = function() { + if ($curGoroutine === $noGoroutine) { + $throwRuntimeError("cannot block in JavaScript callback, fix by wrapping code in goroutine"); + } + $curGoroutine.asleep = true; +}; + +var $restore = function(context, params) { + if (context !== undefined && context.$blk !== undefined) { + return context; + } + return params; +} + +var $send = function(chan, value) { + if (chan.$closed) { + $throwRuntimeError("send on closed channel"); + } + var queuedRecv = chan.$recvQueue.shift(); + if (queuedRecv !== undefined) { + queuedRecv([value, true]); + return; + } + if (chan.$buffer.length < chan.$capacity) { + chan.$buffer.push(value); + return; + } + + var thisGoroutine = $curGoroutine; + var closedDuringSend; + chan.$sendQueue.push(function(closed) { + closedDuringSend = closed; + $schedule(thisGoroutine); + return value; + }); + $block(); + return { + $blk: function() { + if (closedDuringSend) { + $throwRuntimeError("send on closed channel"); + } + } + }; +}; +var $recv = function(chan) { + var queuedSend = chan.$sendQueue.shift(); + if (queuedSend !== undefined) { + chan.$buffer.push(queuedSend(false)); + } + var bufferedValue = chan.$buffer.shift(); + if (bufferedValue !== undefined) { + return [bufferedValue, true]; + } + if (chan.$closed) { + return [chan.$elem.zero(), false]; + } + + var thisGoroutine = $curGoroutine; + var f = { $blk: function() { return this.value; } }; + var queueEntry = function(v) { + f.value = v; + $schedule(thisGoroutine); + }; + chan.$recvQueue.push(queueEntry); + $block(); + return f; +}; +var $close = function(chan) { + if (chan.$closed) { + $throwRuntimeError("close of closed channel"); + } + chan.$closed = true; + while (true) { + var queuedSend = chan.$sendQueue.shift(); + if (queuedSend === undefined) { + break; + } + queuedSend(true); /* will panic */ + } + while (true) { + var queuedRecv = chan.$recvQueue.shift(); + if (queuedRecv === undefined) { + break; + } + queuedRecv([chan.$elem.zero(), false]); + } +}; +var $select = function(comms) { + var ready = []; + var selection = -1; + for (var i = 0; i < comms.length; i++) { + var comm = comms[i]; + var chan = comm[0]; + switch (comm.length) { + case 0: /* default */ + selection = i; + break; + case 1: /* recv */ + if (chan.$sendQueue.length !== 0 || chan.$buffer.length !== 0 || chan.$closed) { + ready.push(i); + } + break; + case 2: /* send */ + if (chan.$closed) { + $throwRuntimeError("send on closed channel"); + } + if (chan.$recvQueue.length !== 0 || chan.$buffer.length < chan.$capacity) { + ready.push(i); + } + break; + } + } + + if (ready.length !== 0) { + selection = ready[Math.floor(Math.random() * ready.length)]; + } + if (selection !== -1) { + var comm = comms[selection]; + switch (comm.length) { + case 0: /* default */ + return [selection]; + case 1: /* recv */ + return [selection, $recv(comm[0])]; + case 2: /* send */ + $send(comm[0], comm[1]); + return [selection]; + } + } + + var entries = []; + var thisGoroutine = $curGoroutine; + var f = { $blk: function() { return this.selection; } }; + var removeFromQueues = function() { + for (var i = 0; i < entries.length; i++) { + var entry = entries[i]; + var queue = entry[0]; + var index = queue.indexOf(entry[1]); + if (index !== -1) { + queue.splice(index, 1); + } + } + }; + for (var i = 0; i < comms.length; i++) { + (function(i) { + var comm = comms[i]; + switch (comm.length) { + case 1: /* recv */ + var queueEntry = function(value) { + f.selection = [i, value]; + removeFromQueues(); + $schedule(thisGoroutine); + }; + entries.push([comm[0].$recvQueue, queueEntry]); + comm[0].$recvQueue.push(queueEntry); + break; + case 2: /* send */ + var queueEntry = function() { + if (comm[0].$closed) { + $throwRuntimeError("send on closed channel"); + } + f.selection = [i]; + removeFromQueues(); + $schedule(thisGoroutine); + return comm[1]; + }; + entries.push([comm[0].$sendQueue, queueEntry]); + comm[0].$sendQueue.push(queueEntry); + break; + } + })(i); + } + $block(); + return f; +}; + +var $jsObjectPtr, $jsErrorPtr; + +var $needsExternalization = function(t) { + switch (t.kind) { + case $kindBool: + case $kindInt: + case $kindInt8: + case $kindInt16: + case $kindInt32: + case $kindUint: + case $kindUint8: + case $kindUint16: + case $kindUint32: + case $kindUintptr: + case $kindFloat32: + case $kindFloat64: + return false; + default: + return t !== $jsObjectPtr; + } +}; + +var $externalize = function(v, t, makeWrapper) { + if (t === $jsObjectPtr) { + return v; + } + switch (t.kind) { + case $kindBool: + case $kindInt: + case $kindInt8: + case $kindInt16: + case $kindInt32: + case $kindUint: + case $kindUint8: + case $kindUint16: + case $kindUint32: + case $kindUintptr: + case $kindFloat32: + case $kindFloat64: + return v; + case $kindInt64: + case $kindUint64: + return $flatten64(v); + case $kindArray: + if ($needsExternalization(t.elem)) { + return $mapArray(v, function(e) { return $externalize(e, t.elem, makeWrapper); }); + } + return v; + case $kindFunc: + return $externalizeFunction(v, t, false, makeWrapper); + case $kindInterface: + if (v === $ifaceNil) { + return null; + } + if (v.constructor === $jsObjectPtr) { + return v.$val.object; + } + return $externalize(v.$val, v.constructor, makeWrapper); + case $kindMap: + var m = {}; + var keys = $keys(v); + for (var i = 0; i < keys.length; i++) { + var entry = v[keys[i]]; + m[$externalize(entry.k, t.key, makeWrapper)] = $externalize(entry.v, t.elem, makeWrapper); + } + return m; + case $kindPtr: + if (v === t.nil) { + return null; + } + return $externalize(v.$get(), t.elem, makeWrapper); + case $kindSlice: + if ($needsExternalization(t.elem)) { + return $mapArray($sliceToNativeArray(v), function(e) { return $externalize(e, t.elem, makeWrapper); }); + } + return $sliceToNativeArray(v); + case $kindString: + if ($isASCII(v)) { + return v; + } + var s = "", r; + for (var i = 0; i < v.length; i += r[1]) { + r = $decodeRune(v, i); + var c = r[0]; + if (c > 0xFFFF) { + var h = Math.floor((c - 0x10000) / 0x400) + 0xD800; + var l = (c - 0x10000) % 0x400 + 0xDC00; + s += String.fromCharCode(h, l); + continue; + } + s += String.fromCharCode(c); + } + return s; + case $kindStruct: + var timePkg = $packages["time"]; + if (timePkg !== undefined && v.constructor === timePkg.Time.ptr) { + var milli = $div64(v.UnixNano(), new $Int64(0, 1000000)); + return new Date($flatten64(milli)); + } + + var noJsObject = {}; + var searchJsObject = function(v, t) { + if (t === $jsObjectPtr) { + return v; + } + switch (t.kind) { + case $kindPtr: + if (v === t.nil) { + return noJsObject; + } + return searchJsObject(v.$get(), t.elem); + case $kindStruct: + var f = t.fields[0]; + return searchJsObject(v[f.prop], f.typ); + case $kindInterface: + return searchJsObject(v.$val, v.constructor); + default: + return noJsObject; + } + }; + var o = searchJsObject(v, t); + if (o !== noJsObject) { + return o; + } + + if (makeWrapper !== undefined) { + return makeWrapper(v); + } + + o = {}; + for (var i = 0; i < t.fields.length; i++) { + var f = t.fields[i]; + if (!f.exported) { + continue; + } + o[f.name] = $externalize(v[f.prop], f.typ, makeWrapper); + } + return o; + } + $throwRuntimeError("cannot externalize " + t.string); +}; + +var $externalizeFunction = function(v, t, passThis, makeWrapper) { + if (v === $throwNilPointerError) { + return null; + } + if (v.$externalizeWrapper === undefined) { + $checkForDeadlock = false; + v.$externalizeWrapper = function() { + var args = []; + for (var i = 0; i < t.params.length; i++) { + if (t.variadic && i === t.params.length - 1) { + var vt = t.params[i].elem, varargs = []; + for (var j = i; j < arguments.length; j++) { + varargs.push($internalize(arguments[j], vt, makeWrapper)); + } + args.push(new (t.params[i])(varargs)); + break; + } + args.push($internalize(arguments[i], t.params[i], makeWrapper)); + } + var result = v.apply(passThis ? this : undefined, args); + switch (t.results.length) { + case 0: + return; + case 1: + return $externalize($copyIfRequired(result, t.results[0]), t.results[0], makeWrapper); + default: + for (var i = 0; i < t.results.length; i++) { + result[i] = $externalize($copyIfRequired(result[i], t.results[i]), t.results[i], makeWrapper); + } + return result; + } + }; + } + return v.$externalizeWrapper; +}; + +var $internalize = function(v, t, recv, seen, makeWrapper) { + if (t === $jsObjectPtr) { + return v; + } + if (t === $jsObjectPtr.elem) { + $throwRuntimeError("cannot internalize js.Object, use *js.Object instead"); + } + if (v && v.__internal_object__ !== undefined) { + return $assertType(v.__internal_object__, t, false); + } + var timePkg = $packages["time"]; + if (timePkg !== undefined && t === timePkg.Time) { + if (!(v !== null && v !== undefined && v.constructor === Date)) { + $throwRuntimeError("cannot internalize time.Time from " + typeof v + ", must be Date"); + } + return timePkg.Unix(new $Int64(0, 0), new $Int64(0, v.getTime() * 1000000)); + } + + // Cache for values we've already internalized in order to deal with circular + // references. + if (seen === undefined) { seen = new Map(); } + if (!seen.has(t)) { seen.set(t, new Map()); } + if (seen.get(t).has(v)) { return seen.get(t).get(v); } + + switch (t.kind) { + case $kindBool: + return !!v; + case $kindInt: + return parseInt(v); + case $kindInt8: + return parseInt(v) << 24 >> 24; + case $kindInt16: + return parseInt(v) << 16 >> 16; + case $kindInt32: + return parseInt(v) >> 0; + case $kindUint: + return parseInt(v); + case $kindUint8: + return parseInt(v) << 24 >>> 24; + case $kindUint16: + return parseInt(v) << 16 >>> 16; + case $kindUint32: + case $kindUintptr: + return parseInt(v) >>> 0; + case $kindInt64: + case $kindUint64: + return new t(0, v); + case $kindFloat32: + case $kindFloat64: + return parseFloat(v); + case $kindArray: + if (v.length !== t.len) { + $throwRuntimeError("got array with wrong size from JavaScript native"); + } + return $mapArray(v, function(e) { return $internalize(e, t.elem, makeWrapper); }); + case $kindFunc: + return function() { + var args = []; + for (var i = 0; i < t.params.length; i++) { + if (t.variadic && i === t.params.length - 1) { + var vt = t.params[i].elem, varargs = arguments[i]; + for (var j = 0; j < varargs.$length; j++) { + args.push($externalize(varargs.$array[varargs.$offset + j], vt, makeWrapper)); + } + break; + } + args.push($externalize(arguments[i], t.params[i], makeWrapper)); + } + var result = v.apply(recv, args); + switch (t.results.length) { + case 0: + return; + case 1: + return $internalize(result, t.results[0], makeWrapper); + default: + for (var i = 0; i < t.results.length; i++) { + result[i] = $internalize(result[i], t.results[i], makeWrapper); + } + return result; + } + }; + case $kindInterface: + if (t.methods.length !== 0) { + $throwRuntimeError("cannot internalize " + t.string); + } + if (v === null) { + return $ifaceNil; + } + if (v === undefined) { + return new $jsObjectPtr(undefined); + } + switch (v.constructor) { + case Int8Array: + return new ($sliceType($Int8))(v); + case Int16Array: + return new ($sliceType($Int16))(v); + case Int32Array: + return new ($sliceType($Int))(v); + case Uint8Array: + return new ($sliceType($Uint8))(v); + case Uint16Array: + return new ($sliceType($Uint16))(v); + case Uint32Array: + return new ($sliceType($Uint))(v); + case Float32Array: + return new ($sliceType($Float32))(v); + case Float64Array: + return new ($sliceType($Float64))(v); + case Array: + return $internalize(v, $sliceType($emptyInterface), makeWrapper); + case Boolean: + return new $Bool(!!v); + case Date: + if (timePkg === undefined) { + /* time package is not present, internalize as &js.Object{Date} so it can be externalized into original Date. */ + return new $jsObjectPtr(v); + } + return new timePkg.Time($internalize(v, timePkg.Time, makeWrapper)); + case (function () { }).constructor: // is usually Function, but in Chrome extensions it is something else + var funcType = $funcType([$sliceType($emptyInterface)], [$jsObjectPtr], true); + return new funcType($internalize(v, funcType, makeWrapper)); + case Number: + return new $Float64(parseFloat(v)); + case String: + return new $String($internalize(v, $String, makeWrapper)); + default: + if ($global.Node && v instanceof $global.Node) { + return new $jsObjectPtr(v); + } + var mapType = $mapType($String, $emptyInterface); + return new mapType($internalize(v, mapType, recv, seen, makeWrapper)); + } + case $kindMap: + var m = {}; + seen.get(t).set(v, m); + var keys = $keys(v); + for (var i = 0; i < keys.length; i++) { + var k = $internalize(keys[i], t.key, recv, seen, makeWrapper); + m[t.key.keyFor(k)] = { k: k, v: $internalize(v[keys[i]], t.elem, recv, seen, makeWrapper) }; + } + return m; + case $kindPtr: + if (t.elem.kind === $kindStruct) { + return $internalize(v, t.elem, makeWrapper); + } + case $kindSlice: + return new t($mapArray(v, function(e) { return $internalize(e, t.elem, makeWrapper); })); + case $kindString: + v = String(v); + if ($isASCII(v)) { + return v; + } + var s = ""; + var i = 0; + while (i < v.length) { + var h = v.charCodeAt(i); + if (0xD800 <= h && h <= 0xDBFF) { + var l = v.charCodeAt(i + 1); + var c = (h - 0xD800) * 0x400 + l - 0xDC00 + 0x10000; + s += $encodeRune(c); + i += 2; + continue; + } + s += $encodeRune(h); + i++; + } + return s; + case $kindStruct: + var noJsObject = {}; + var searchJsObject = function(t) { + if (t === $jsObjectPtr) { + return v; + } + if (t === $jsObjectPtr.elem) { + $throwRuntimeError("cannot internalize js.Object, use *js.Object instead"); + } + switch (t.kind) { + case $kindPtr: + return searchJsObject(t.elem); + case $kindStruct: + var f = t.fields[0]; + var o = searchJsObject(f.typ); + if (o !== noJsObject) { + var n = new t.ptr(); + n[f.prop] = o; + return n; + } + return noJsObject; + default: + return noJsObject; + } + }; + var o = searchJsObject(t); + if (o !== noJsObject) { + return o; + } + } + $throwRuntimeError("cannot internalize " + t.string); +}; + +var $copyIfRequired = function(v, typ) { + // interface values + if (v && v.constructor && v.constructor.copy) { + return new v.constructor($clone(v.$val, v.constructor)) + } + // array and struct values + if (typ.copy) { + var clone = typ.zero(); + typ.copy(clone, v); + return clone; + } + return v; +} + +/* $isASCII reports whether string s contains only ASCII characters. */ +var $isASCII = function(s) { + for (var i = 0; i < s.length; i++) { + if (s.charCodeAt(i) >= 128) { + return false; + } + } + return true; +}; + +$packages["github.com/gopherjs/gopherjs/js"] = (function() { + var $pkg = {}, $init, Object, Error, sliceType, ptrType, sliceType$2, funcType, ptrType$1, MakeWrapper, init; + Object = $pkg.Object = $newType(0, $kindStruct, "js.Object", true, "github.com/gopherjs/gopherjs/js", true, function(object_) { + this.$val = this; + if (arguments.length === 0) { + this.object = null; + return; + } + this.object = object_; + }); + Error = $pkg.Error = $newType(0, $kindStruct, "js.Error", true, "github.com/gopherjs/gopherjs/js", true, function(Object_) { + this.$val = this; + if (arguments.length === 0) { + this.Object = null; + return; + } + this.Object = Object_; + }); + sliceType = $sliceType($emptyInterface); + ptrType = $ptrType(Object); + sliceType$2 = $sliceType(ptrType); + funcType = $funcType([sliceType$2], [ptrType], true); + ptrType$1 = $ptrType(Error); + Object.ptr.prototype.Get = function(key) { + var key, o; + o = this; + return o.object[$externalize(key, $String)]; + }; + Object.prototype.Get = function(key) { return this.$val.Get(key); }; + Object.ptr.prototype.Set = function(key, value) { + var key, o, value; + o = this; + o.object[$externalize(key, $String)] = $externalize(value, $emptyInterface); + }; + Object.prototype.Set = function(key, value) { return this.$val.Set(key, value); }; + Object.ptr.prototype.Delete = function(key) { + var key, o; + o = this; + delete o.object[$externalize(key, $String)]; + }; + Object.prototype.Delete = function(key) { return this.$val.Delete(key); }; + Object.ptr.prototype.Length = function() { + var o; + o = this; + return $parseInt(o.object.length); + }; + Object.prototype.Length = function() { return this.$val.Length(); }; + Object.ptr.prototype.Index = function(i) { + var i, o; + o = this; + return o.object[i]; + }; + Object.prototype.Index = function(i) { return this.$val.Index(i); }; + Object.ptr.prototype.SetIndex = function(i, value) { + var i, o, value; + o = this; + o.object[i] = $externalize(value, $emptyInterface); + }; + Object.prototype.SetIndex = function(i, value) { return this.$val.SetIndex(i, value); }; + Object.ptr.prototype.Call = function(name, args) { + var args, name, o, obj; + o = this; + return (obj = o.object, obj[$externalize(name, $String)].apply(obj, $externalize(args, sliceType))); + }; + Object.prototype.Call = function(name, args) { return this.$val.Call(name, args); }; + Object.ptr.prototype.Invoke = function(args) { + var args, o; + o = this; + return o.object.apply(undefined, $externalize(args, sliceType)); + }; + Object.prototype.Invoke = function(args) { return this.$val.Invoke(args); }; + Object.ptr.prototype.New = function(args) { + var args, o; + o = this; + return new ($global.Function.prototype.bind.apply(o.object, [undefined].concat($externalize(args, sliceType)))); + }; + Object.prototype.New = function(args) { return this.$val.New(args); }; + Object.ptr.prototype.Bool = function() { + var o; + o = this; + return !!(o.object); + }; + Object.prototype.Bool = function() { return this.$val.Bool(); }; + Object.ptr.prototype.String = function() { + var o; + o = this; + return $internalize(o.object, $String); + }; + Object.prototype.String = function() { return this.$val.String(); }; + Object.ptr.prototype.Int = function() { + var o; + o = this; + return $parseInt(o.object) >> 0; + }; + Object.prototype.Int = function() { return this.$val.Int(); }; + Object.ptr.prototype.Int64 = function() { + var o; + o = this; + return $internalize(o.object, $Int64); + }; + Object.prototype.Int64 = function() { return this.$val.Int64(); }; + Object.ptr.prototype.Uint64 = function() { + var o; + o = this; + return $internalize(o.object, $Uint64); + }; + Object.prototype.Uint64 = function() { return this.$val.Uint64(); }; + Object.ptr.prototype.Float = function() { + var o; + o = this; + return $parseFloat(o.object); + }; + Object.prototype.Float = function() { return this.$val.Float(); }; + Object.ptr.prototype.Interface = function() { + var o; + o = this; + return $internalize(o.object, $emptyInterface); + }; + Object.prototype.Interface = function() { return this.$val.Interface(); }; + Object.ptr.prototype.Unsafe = function() { + var o; + o = this; + return o.object; + }; + Object.prototype.Unsafe = function() { return this.$val.Unsafe(); }; + Error.ptr.prototype.Error = function() { + var err; + err = this; + return "JavaScript error: " + $internalize(err.Object.message, $String); + }; + Error.prototype.Error = function() { return this.$val.Error(); }; + Error.ptr.prototype.Stack = function() { + var err; + err = this; + return $internalize(err.Object.stack, $String); + }; + Error.prototype.Stack = function() { return this.$val.Stack(); }; + MakeWrapper = function(i) { + var i, i$1, m, methods, o, v; + v = i; + o = new ($global.Object)(); + o.__internal_object__ = v; + methods = v.constructor.methods; + i$1 = 0; + while (true) { + if (!(i$1 < $parseInt(methods.length))) { break; } + m = [m]; + m[0] = methods[i$1]; + if (!($internalize(m[0].pkg, $String) === "")) { + i$1 = i$1 + (1) >> 0; + continue; + } + o[$externalize($internalize(m[0].name, $String), $String)] = $externalize((function(m) { return function(args) { + var args; + return $externalizeFunction(v[$externalize($internalize(m[0].prop, $String), $String)], m[0].typ, $externalize(true, $Bool)).apply(v, $externalize(args, sliceType$2)); + }; })(m), funcType); + i$1 = i$1 + (1) >> 0; + } + return o; + }; + $pkg.MakeWrapper = MakeWrapper; + init = function() { + var e; + e = new Error.ptr(null); + $unused(e); + }; + ptrType.methods = [{prop: "Get", name: "Get", pkg: "", typ: $funcType([$String], [ptrType], false)}, {prop: "Set", name: "Set", pkg: "", typ: $funcType([$String, $emptyInterface], [], false)}, {prop: "Delete", name: "Delete", pkg: "", typ: $funcType([$String], [], false)}, {prop: "Length", name: "Length", pkg: "", typ: $funcType([], [$Int], false)}, {prop: "Index", name: "Index", pkg: "", typ: $funcType([$Int], [ptrType], false)}, {prop: "SetIndex", name: "SetIndex", pkg: "", typ: $funcType([$Int, $emptyInterface], [], false)}, {prop: "Call", name: "Call", pkg: "", typ: $funcType([$String, sliceType], [ptrType], true)}, {prop: "Invoke", name: "Invoke", pkg: "", typ: $funcType([sliceType], [ptrType], true)}, {prop: "New", name: "New", pkg: "", typ: $funcType([sliceType], [ptrType], true)}, {prop: "Bool", name: "Bool", pkg: "", typ: $funcType([], [$Bool], false)}, {prop: "String", name: "String", pkg: "", typ: $funcType([], [$String], false)}, {prop: "Int", name: "Int", pkg: "", typ: $funcType([], [$Int], false)}, {prop: "Int64", name: "Int64", pkg: "", typ: $funcType([], [$Int64], false)}, {prop: "Uint64", name: "Uint64", pkg: "", typ: $funcType([], [$Uint64], false)}, {prop: "Float", name: "Float", pkg: "", typ: $funcType([], [$Float64], false)}, {prop: "Interface", name: "Interface", pkg: "", typ: $funcType([], [$emptyInterface], false)}, {prop: "Unsafe", name: "Unsafe", pkg: "", typ: $funcType([], [$Uintptr], false)}]; + ptrType$1.methods = [{prop: "Error", name: "Error", pkg: "", typ: $funcType([], [$String], false)}, {prop: "Stack", name: "Stack", pkg: "", typ: $funcType([], [$String], false)}]; + Object.init("github.com/gopherjs/gopherjs/js", [{prop: "object", name: "object", embedded: false, exported: false, typ: ptrType, tag: ""}]); + Error.init("", [{prop: "Object", name: "Object", embedded: true, exported: true, typ: ptrType, tag: ""}]); + $init = function() { + $pkg.$init = function() {}; + /* */ var $f, $c = false, $s = 0, $r; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0: + init(); + /* */ } return; } if ($f === undefined) { $f = { $blk: $init }; } $f.$s = $s; $f.$r = $r; return $f; + }; + $pkg.$init = $init; + return $pkg; +})(); +$packages["runtime"] = (function() { + var $pkg = {}, $init, js, _type, TypeAssertionError, errorString, ptrType$1, ptrType$2, buildVersion, init, throw$1; + js = $packages["github.com/gopherjs/gopherjs/js"]; + _type = $pkg._type = $newType(0, $kindStruct, "runtime._type", true, "runtime", false, function(str_) { + this.$val = this; + if (arguments.length === 0) { + this.str = ""; + return; + } + this.str = str_; + }); + TypeAssertionError = $pkg.TypeAssertionError = $newType(0, $kindStruct, "runtime.TypeAssertionError", true, "runtime", true, function(_interface_, concrete_, asserted_, missingMethod_) { + this.$val = this; + if (arguments.length === 0) { + this._interface = ptrType$1.nil; + this.concrete = ptrType$1.nil; + this.asserted = ptrType$1.nil; + this.missingMethod = ""; + return; + } + this._interface = _interface_; + this.concrete = concrete_; + this.asserted = asserted_; + this.missingMethod = missingMethod_; + }); + errorString = $pkg.errorString = $newType(8, $kindString, "runtime.errorString", true, "runtime", false, null); + ptrType$1 = $ptrType(_type); + ptrType$2 = $ptrType(TypeAssertionError); + _type.ptr.prototype.string = function() { + var t; + t = this; + return t.str; + }; + _type.prototype.string = function() { return this.$val.string(); }; + _type.ptr.prototype.pkgpath = function() { + var t; + t = this; + return ""; + }; + _type.prototype.pkgpath = function() { return this.$val.pkgpath(); }; + TypeAssertionError.ptr.prototype.RuntimeError = function() { + }; + TypeAssertionError.prototype.RuntimeError = function() { return this.$val.RuntimeError(); }; + TypeAssertionError.ptr.prototype.Error = function() { + var as, cs, e, inter, msg; + e = this; + inter = "interface"; + if (!(e._interface === ptrType$1.nil)) { + inter = e._interface.string(); + } + as = e.asserted.string(); + if (e.concrete === ptrType$1.nil) { + return "interface conversion: " + inter + " is nil, not " + as; + } + cs = e.concrete.string(); + if (e.missingMethod === "") { + msg = "interface conversion: " + inter + " is " + cs + ", not " + as; + if (cs === as) { + if (!(e.concrete.pkgpath() === e.asserted.pkgpath())) { + msg = msg + (" (types from different packages)"); + } else { + msg = msg + (" (types from different scopes)"); + } + } + return msg; + } + return "interface conversion: " + cs + " is not " + as + ": missing method " + e.missingMethod; + }; + TypeAssertionError.prototype.Error = function() { return this.$val.Error(); }; + init = function() { + var e, jsPkg; + jsPkg = $packages[$externalize("github.com/gopherjs/gopherjs/js", $String)]; + $jsObjectPtr = jsPkg.Object.ptr; + $jsErrorPtr = jsPkg.Error.ptr; + $throwRuntimeError = throw$1; + buildVersion = $internalize($goVersion, $String); + e = $ifaceNil; + e = new TypeAssertionError.ptr(ptrType$1.nil, ptrType$1.nil, ptrType$1.nil, ""); + $unused(e); + }; + errorString.prototype.RuntimeError = function() { + var e; + e = this.$val; + }; + $ptrType(errorString).prototype.RuntimeError = function() { return new errorString(this.$get()).RuntimeError(); }; + errorString.prototype.Error = function() { + var e; + e = this.$val; + return "runtime error: " + (e); + }; + $ptrType(errorString).prototype.Error = function() { return new errorString(this.$get()).Error(); }; + throw$1 = function(s) { + var s; + $panic(new errorString((s))); + }; + ptrType$1.methods = [{prop: "string", name: "string", pkg: "runtime", typ: $funcType([], [$String], false)}, {prop: "pkgpath", name: "pkgpath", pkg: "runtime", typ: $funcType([], [$String], false)}]; + ptrType$2.methods = [{prop: "RuntimeError", name: "RuntimeError", pkg: "", typ: $funcType([], [], false)}, {prop: "Error", name: "Error", pkg: "", typ: $funcType([], [$String], false)}]; + errorString.methods = [{prop: "RuntimeError", name: "RuntimeError", pkg: "", typ: $funcType([], [], false)}, {prop: "Error", name: "Error", pkg: "", typ: $funcType([], [$String], false)}]; + _type.init("runtime", [{prop: "str", name: "str", embedded: false, exported: false, typ: $String, tag: ""}]); + TypeAssertionError.init("runtime", [{prop: "_interface", name: "_interface", embedded: false, exported: false, typ: ptrType$1, tag: ""}, {prop: "concrete", name: "concrete", embedded: false, exported: false, typ: ptrType$1, tag: ""}, {prop: "asserted", name: "asserted", embedded: false, exported: false, typ: ptrType$1, tag: ""}, {prop: "missingMethod", name: "missingMethod", embedded: false, exported: false, typ: $String, tag: ""}]); + $init = function() { + $pkg.$init = function() {}; + /* */ var $f, $c = false, $s = 0, $r; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0: + $r = js.$init(); /* */ $s = 1; case 1: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; } + buildVersion = ""; + init(); + /* */ } return; } if ($f === undefined) { $f = { $blk: $init }; } $f.$s = $s; $f.$r = $r; return $f; + }; + $pkg.$init = $init; + return $pkg; +})(); +$packages["math/bits"] = (function() { + var $pkg = {}, $init; + $init = function() { + $pkg.$init = function() {}; + /* */ var $f, $c = false, $s = 0, $r; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0: + /* */ } return; } if ($f === undefined) { $f = { $blk: $init }; } $f.$s = $s; $f.$r = $r; return $f; + }; + $pkg.$init = $init; + return $pkg; +})(); +$packages["math"] = (function() { + var $pkg = {}, $init, js, bits, arrayType, arrayType$1, arrayType$2, structType, math, _zero, posInf, negInf, nan, buf, Round, max, min, Abs, Cos, Floor, Inf, IsInf, IsNaN, Max, Min, NaN, Pow, Signbit, Sin, Sqrt, init, Float64bits, Float64frombits; + js = $packages["github.com/gopherjs/gopherjs/js"]; + bits = $packages["math/bits"]; + arrayType = $arrayType($Uint32, 2); + arrayType$1 = $arrayType($Float32, 2); + arrayType$2 = $arrayType($Float64, 1); + structType = $structType("math", [{prop: "uint32array", name: "uint32array", embedded: false, exported: false, typ: arrayType, tag: ""}, {prop: "float32array", name: "float32array", embedded: false, exported: false, typ: arrayType$1, tag: ""}, {prop: "float64array", name: "float64array", embedded: false, exported: false, typ: arrayType$2, tag: ""}]); + Round = function(x) { + var bits$1, e, x, x$1, x$2, x$3, x$4; + bits$1 = Float64bits(x); + e = ((($shiftRightUint64(bits$1, 52).$low >>> 0)) & 2047) >>> 0; + if (e < 1023) { + bits$1 = (x$1 = new $Uint64(2147483648, 0), new $Uint64(bits$1.$high & x$1.$high, (bits$1.$low & x$1.$low) >>> 0)); + if (e === 1022) { + bits$1 = (x$2 = new $Uint64(1072693248, 0), new $Uint64(bits$1.$high | x$2.$high, (bits$1.$low | x$2.$low) >>> 0)); + } + } else if (e < 1075) { + e = e - (1023) >>> 0; + bits$1 = (x$3 = $shiftRightUint64(new $Uint64(524288, 0), e), new $Uint64(bits$1.$high + x$3.$high, bits$1.$low + x$3.$low)); + bits$1 = (x$4 = $shiftRightUint64(new $Uint64(1048575, 4294967295), e), new $Uint64(bits$1.$high & ~x$4.$high, (bits$1.$low & ~x$4.$low) >>> 0)); + } + return Float64frombits(bits$1); + }; + $pkg.Round = Round; + max = function(x, y) { + var x, y; + if (IsInf(x, 1) || IsInf(y, 1)) { + return Inf(1); + } else if (IsNaN(x) || IsNaN(y)) { + return NaN(); + } else if ((x === 0) && (x === y)) { + if (Signbit(x)) { + return y; + } + return x; + } + if (x > y) { + return x; + } + return y; + }; + min = function(x, y) { + var x, y; + if (IsInf(x, -1) || IsInf(y, -1)) { + return Inf(-1); + } else if (IsNaN(x) || IsNaN(y)) { + return NaN(); + } else if ((x === 0) && (x === y)) { + if (Signbit(x)) { + return x; + } + return y; + } + if (x < y) { + return x; + } + return y; + }; + Abs = function(x) { + var x, x$1; + return Float64frombits((x$1 = Float64bits(x), new $Uint64(x$1.$high & ~2147483648, (x$1.$low & ~0) >>> 0))); + }; + $pkg.Abs = Abs; + Cos = function(x) { + var x; + return $parseFloat(math.cos(x)); + }; + $pkg.Cos = Cos; + Floor = function(x) { + var x; + return $parseFloat(math.floor(x)); + }; + $pkg.Floor = Floor; + Inf = function(sign) { + var sign; + if (sign >= 0) { + return posInf; + } else { + return negInf; + } + }; + $pkg.Inf = Inf; + IsInf = function(f, sign) { + var f, sign; + if (f === posInf) { + return sign >= 0; + } + if (f === negInf) { + return sign <= 0; + } + return false; + }; + $pkg.IsInf = IsInf; + IsNaN = function(f) { + var f, is; + is = false; + is = !((f === f)); + return is; + }; + $pkg.IsNaN = IsNaN; + Max = function(x, y) { + var x, y; + return max(x, y); + }; + $pkg.Max = Max; + Min = function(x, y) { + var x, y; + return min(x, y); + }; + $pkg.Min = Min; + NaN = function() { + return nan; + }; + $pkg.NaN = NaN; + Pow = function(x, y) { + var x, y; + if ((x === 1) || ((x === -1) && ((y === posInf) || (y === negInf)))) { + return 1; + } + return $parseFloat(math.pow(x, y)); + }; + $pkg.Pow = Pow; + Signbit = function(x) { + var x; + return x < 0 || (1 / x === negInf); + }; + $pkg.Signbit = Signbit; + Sin = function(x) { + var x; + return $parseFloat(math.sin(x)); + }; + $pkg.Sin = Sin; + Sqrt = function(x) { + var x; + return $parseFloat(math.sqrt(x)); + }; + $pkg.Sqrt = Sqrt; + init = function() { + var ab; + ab = new ($global.ArrayBuffer)(8); + buf.uint32array = new ($global.Uint32Array)(ab); + buf.float32array = new ($global.Float32Array)(ab); + buf.float64array = new ($global.Float64Array)(ab); + }; + Float64bits = function(f) { + var f, x, x$1; + buf.float64array[0] = f; + return (x = $shiftLeft64((new $Uint64(0, buf.uint32array[1])), 32), x$1 = (new $Uint64(0, buf.uint32array[0])), new $Uint64(x.$high + x$1.$high, x.$low + x$1.$low)); + }; + $pkg.Float64bits = Float64bits; + Float64frombits = function(b) { + var b; + buf.uint32array[0] = ((b.$low >>> 0)); + buf.uint32array[1] = (($shiftRightUint64(b, 32).$low >>> 0)); + return buf.float64array[0]; + }; + $pkg.Float64frombits = Float64frombits; + $init = function() { + $pkg.$init = function() {}; + /* */ var $f, $c = false, $s = 0, $r; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0: + $r = js.$init(); /* */ $s = 1; case 1: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; } + $r = bits.$init(); /* */ $s = 2; case 2: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; } + buf = new structType.ptr(arrayType.zero(), arrayType$1.zero(), arrayType$2.zero()); + math = $global.Math; + _zero = 0; + posInf = 1 / _zero; + negInf = -1 / _zero; + nan = $parseFloat($NaN); + init(); + /* */ } return; } if ($f === undefined) { $f = { $blk: $init }; } $f.$s = $s; $f.$r = $r; return $f; + }; + $pkg.$init = $init; + return $pkg; +})(); +$packages["resolv"] = (function() { + var $pkg = {}, $init, math, Vector, Axis, Space, Shape, Line, ConvexPolygon, ContactSet, Circle, Projection, RingBuffer, Object, Collision, Cell, sliceType, ptrType, sliceType$1, sliceType$2, ptrType$1, ptrType$2, sliceType$3, sliceType$4, ptrType$3, sliceType$5, ptrType$4, ptrType$5, ptrType$6, sliceType$6, ptrType$7, sliceType$7, ptrType$8, sliceType$8, ptrType$9, mapType, Dot, NewSpace, NewLine, NewConvexPolygon, NewContactSet, NewRectangle, NewCircle, NewRingBuffer, NewObjectSingleTag, NewObject, axpyUnitaryTo, scalUnitaryTo, NewCollision, newCell; + math = $packages["math"]; + Vector = $pkg.Vector = $newType(12, $kindSlice, "resolv.Vector", true, "resolv", true, null); + Axis = $pkg.Axis = $newType(4, $kindInt, "resolv.Axis", true, "resolv", true, null); + Space = $pkg.Space = $newType(0, $kindStruct, "resolv.Space", true, "resolv", true, function(Cells_, CellWidth_, CellHeight_) { + this.$val = this; + if (arguments.length === 0) { + this.Cells = sliceType$2.nil; + this.CellWidth = 0; + this.CellHeight = 0; + return; + } + this.Cells = Cells_; + this.CellWidth = CellWidth_; + this.CellHeight = CellHeight_; + }); + Shape = $pkg.Shape = $newType(8, $kindInterface, "resolv.Shape", true, "resolv", true, null); + Line = $pkg.Line = $newType(0, $kindStruct, "resolv.Line", true, "resolv", true, function(Start_, End_) { + this.$val = this; + if (arguments.length === 0) { + this.Start = Vector.nil; + this.End = Vector.nil; + return; + } + this.Start = Start_; + this.End = End_; + }); + ConvexPolygon = $pkg.ConvexPolygon = $newType(0, $kindStruct, "resolv.ConvexPolygon", true, "resolv", true, function(Points_, X_, Y_, Closed_) { + this.$val = this; + if (arguments.length === 0) { + this.Points = sliceType$4.nil; + this.X = 0; + this.Y = 0; + this.Closed = false; + return; + } + this.Points = Points_; + this.X = X_; + this.Y = Y_; + this.Closed = Closed_; + }); + ContactSet = $pkg.ContactSet = $newType(0, $kindStruct, "resolv.ContactSet", true, "resolv", true, function(Points_, MTV_, Center_) { + this.$val = this; + if (arguments.length === 0) { + this.Points = sliceType$4.nil; + this.MTV = Vector.nil; + this.Center = Vector.nil; + return; + } + this.Points = Points_; + this.MTV = MTV_; + this.Center = Center_; + }); + Circle = $pkg.Circle = $newType(0, $kindStruct, "resolv.Circle", true, "resolv", true, function(X_, Y_, Radius_) { + this.$val = this; + if (arguments.length === 0) { + this.X = 0; + this.Y = 0; + this.Radius = 0; + return; + } + this.X = X_; + this.Y = Y_; + this.Radius = Radius_; + }); + Projection = $pkg.Projection = $newType(0, $kindStruct, "resolv.Projection", true, "resolv", true, function(Min_, Max_) { + this.$val = this; + if (arguments.length === 0) { + this.Min = 0; + this.Max = 0; + return; + } + this.Min = Min_; + this.Max = Max_; + }); + RingBuffer = $pkg.RingBuffer = $newType(0, $kindStruct, "resolv.RingBuffer", true, "resolv", true, function(Ed_, St_, EdFrameId_, StFrameId_, N_, Cnt_, Eles_) { + this.$val = this; + if (arguments.length === 0) { + this.Ed = 0; + this.St = 0; + this.EdFrameId = 0; + this.StFrameId = 0; + this.N = 0; + this.Cnt = 0; + this.Eles = sliceType$6.nil; + return; + } + this.Ed = Ed_; + this.St = St_; + this.EdFrameId = EdFrameId_; + this.StFrameId = StFrameId_; + this.N = N_; + this.Cnt = Cnt_; + this.Eles = Eles_; + }); + Object = $pkg.Object = $newType(0, $kindStruct, "resolv.Object", true, "resolv", true, function(Shape_, Space_, X_, Y_, W_, H_, TouchingCells_, Data_, ignoreList_, tags_) { + this.$val = this; + if (arguments.length === 0) { + this.Shape = $ifaceNil; + this.Space = ptrType$1.nil; + this.X = 0; + this.Y = 0; + this.W = 0; + this.H = 0; + this.TouchingCells = ptrType$7.nil; + this.Data = $ifaceNil; + this.ignoreList = false; + this.tags = sliceType$7.nil; + return; + } + this.Shape = Shape_; + this.Space = Space_; + this.X = X_; + this.Y = Y_; + this.W = W_; + this.H = H_; + this.TouchingCells = TouchingCells_; + this.Data = Data_; + this.ignoreList = ignoreList_; + this.tags = tags_; + }); + Collision = $pkg.Collision = $newType(0, $kindStruct, "resolv.Collision", true, "resolv", true, function(checkingObject_, dx_, dy_, Objects_, Cells_) { + this.$val = this; + if (arguments.length === 0) { + this.checkingObject = ptrType$2.nil; + this.dx = 0; + this.dy = 0; + this.Objects = ptrType$7.nil; + this.Cells = ptrType$7.nil; + return; + } + this.checkingObject = checkingObject_; + this.dx = dx_; + this.dy = dy_; + this.Objects = Objects_; + this.Cells = Cells_; + }); + Cell = $pkg.Cell = $newType(0, $kindStruct, "resolv.Cell", true, "resolv", true, function(X_, Y_, Objects_) { + this.$val = this; + if (arguments.length === 0) { + this.X = 0; + this.Y = 0; + this.Objects = ptrType$7.nil; + return; + } + this.X = X_; + this.Y = Y_; + this.Objects = Objects_; + }); + sliceType = $sliceType($Float64); + ptrType = $ptrType(Cell); + sliceType$1 = $sliceType(ptrType); + sliceType$2 = $sliceType(sliceType$1); + ptrType$1 = $ptrType(Space); + ptrType$2 = $ptrType(Object); + sliceType$3 = $sliceType(ptrType$2); + sliceType$4 = $sliceType(Vector); + ptrType$3 = $ptrType(Line); + sliceType$5 = $sliceType(ptrType$3); + ptrType$4 = $ptrType(Circle); + ptrType$5 = $ptrType(ConvexPolygon); + ptrType$6 = $ptrType(ContactSet); + sliceType$6 = $sliceType($emptyInterface); + ptrType$7 = $ptrType(RingBuffer); + sliceType$7 = $sliceType($String); + ptrType$8 = $ptrType(Shape); + sliceType$8 = $sliceType(Axis); + ptrType$9 = $ptrType(Collision); + mapType = $mapType(ptrType$2, $Bool); + Vector.prototype.Clone = function() { + var clone, v; + v = this; + clone = $makeSlice(Vector, v.$length); + $copySlice(clone, v); + return clone; + }; + $ptrType(Vector).prototype.Clone = function() { return this.$get().Clone(); }; + Vector.prototype.Add = function(vs) { + var _i, _ref, dim, i, v, vs; + v = this; + dim = v.$length; + _ref = vs; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + i = _i; + if (((i < 0 || i >= vs.$length) ? ($throwRuntimeError("index out of range"), undefined) : vs.$array[vs.$offset + i]).$length > dim) { + axpyUnitaryTo($convertSliceType(v, sliceType), 1, $convertSliceType(v, sliceType), $convertSliceType($subslice(((i < 0 || i >= vs.$length) ? ($throwRuntimeError("index out of range"), undefined) : vs.$array[vs.$offset + i]), 0, dim), sliceType)); + } else { + axpyUnitaryTo($convertSliceType(v, sliceType), 1, $convertSliceType(v, sliceType), $convertSliceType(((i < 0 || i >= vs.$length) ? ($throwRuntimeError("index out of range"), undefined) : vs.$array[vs.$offset + i]), sliceType)); + } + _i++; + } + return v; + }; + $ptrType(Vector).prototype.Add = function(vs) { return this.$get().Add(vs); }; + Vector.prototype.Sub = function(vs) { + var _i, _ref, dim, i, v, vs; + v = this; + dim = v.$length; + _ref = vs; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + i = _i; + if (((i < 0 || i >= vs.$length) ? ($throwRuntimeError("index out of range"), undefined) : vs.$array[vs.$offset + i]).$length > dim) { + axpyUnitaryTo($convertSliceType(v, sliceType), -1, $convertSliceType($subslice(((i < 0 || i >= vs.$length) ? ($throwRuntimeError("index out of range"), undefined) : vs.$array[vs.$offset + i]), 0, dim), sliceType), $convertSliceType(v, sliceType)); + } else { + axpyUnitaryTo($convertSliceType(v, sliceType), -1, $convertSliceType(((i < 0 || i >= vs.$length) ? ($throwRuntimeError("index out of range"), undefined) : vs.$array[vs.$offset + i]), sliceType), $convertSliceType(v, sliceType)); + } + _i++; + } + return v; + }; + $ptrType(Vector).prototype.Sub = function(vs) { return this.$get().Sub(vs); }; + Vector.prototype.Scale = function(size) { + var size, v; + v = this; + scalUnitaryTo($convertSliceType(v, sliceType), size, $convertSliceType(v, sliceType)); + return v; + }; + $ptrType(Vector).prototype.Scale = function(size) { return this.$get().Scale(size); }; + Vector.prototype.Equal = function(v2) { + var _i, _ref, i, v, v2; + v = this; + if (!((v.$length === v2.$length))) { + return false; + } + _ref = v; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + i = _i; + if (math.Abs(((i < 0 || i >= v.$length) ? ($throwRuntimeError("index out of range"), undefined) : v.$array[v.$offset + i]) - ((i < 0 || i >= v2.$length) ? ($throwRuntimeError("index out of range"), undefined) : v2.$array[v2.$offset + i])) > 1e-08) { + return false; + } + _i++; + } + return true; + }; + $ptrType(Vector).prototype.Equal = function(v2) { return this.$get().Equal(v2); }; + Vector.prototype.Magnitude = function() { + var v; + v = this; + return math.Sqrt(v.Magnitude2()); + }; + $ptrType(Vector).prototype.Magnitude = function() { return this.$get().Magnitude(); }; + Vector.prototype.Magnitude2 = function() { + var _i, _ref, result, scalar, v; + v = this; + result = 0; + _ref = v; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + scalar = ((_i < 0 || _i >= _ref.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref.$array[_ref.$offset + _i]); + result = result + (scalar * scalar); + _i++; + } + return result; + }; + $ptrType(Vector).prototype.Magnitude2 = function() { return this.$get().Magnitude2(); }; + Vector.prototype.Unit = function() { + var _i, _ref, i, l, v; + v = this; + l = v.Magnitude(); + if (l < 1e-08) { + return v; + } + _ref = v; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + i = _i; + ((i < 0 || i >= v.$length) ? ($throwRuntimeError("index out of range"), undefined) : v.$array[v.$offset + i] = ((i < 0 || i >= v.$length) ? ($throwRuntimeError("index out of range"), undefined) : v.$array[v.$offset + i]) / l); + _i++; + } + return v; + }; + $ptrType(Vector).prototype.Unit = function() { return this.$get().Unit(); }; + Dot = function(v1, v2) { + var _i, _ref, _tmp, _tmp$1, _tmp$2, dim1, dim2, i, result, v1, v2; + _tmp = 0; + _tmp$1 = v1.$length; + _tmp$2 = v2.$length; + result = _tmp; + dim1 = _tmp$1; + dim2 = _tmp$2; + if (dim1 > dim2) { + v2 = $appendSlice(v2, $convertSliceType($makeSlice(Vector, (dim1 - dim2 >> 0)), sliceType)); + } + if (dim1 < dim2) { + v1 = $appendSlice(v1, $convertSliceType($makeSlice(Vector, (dim2 - dim1 >> 0)), sliceType)); + } + _ref = v1; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + i = _i; + result = result + (((i < 0 || i >= v1.$length) ? ($throwRuntimeError("index out of range"), undefined) : v1.$array[v1.$offset + i]) * ((i < 0 || i >= v2.$length) ? ($throwRuntimeError("index out of range"), undefined) : v2.$array[v2.$offset + i])); + _i++; + } + return result; + }; + $pkg.Dot = Dot; + Vector.prototype.Dot = function(v2) { + var v, v2; + v = this; + return Dot(v, v2); + }; + $ptrType(Vector).prototype.Dot = function(v2) { return this.$get().Dot(v2); }; + Vector.prototype.Cross = function(v2) { + var v, v2; + v = this; + if (!((v.$length === 3)) || !((v2.$length === 3))) { + return Vector.nil; + } + return new Vector([(1 >= v.$length ? ($throwRuntimeError("index out of range"), undefined) : v.$array[v.$offset + 1]) * (2 >= v2.$length ? ($throwRuntimeError("index out of range"), undefined) : v2.$array[v2.$offset + 2]) - (2 >= v.$length ? ($throwRuntimeError("index out of range"), undefined) : v.$array[v.$offset + 2]) * (1 >= v2.$length ? ($throwRuntimeError("index out of range"), undefined) : v2.$array[v2.$offset + 1]), (2 >= v.$length ? ($throwRuntimeError("index out of range"), undefined) : v.$array[v.$offset + 2]) * (0 >= v2.$length ? ($throwRuntimeError("index out of range"), undefined) : v2.$array[v2.$offset + 0]) - (0 >= v.$length ? ($throwRuntimeError("index out of range"), undefined) : v.$array[v.$offset + 0]) * (2 >= v2.$length ? ($throwRuntimeError("index out of range"), undefined) : v2.$array[v2.$offset + 2]), (0 >= v.$length ? ($throwRuntimeError("index out of range"), undefined) : v.$array[v.$offset + 0]) * (2 >= v2.$length ? ($throwRuntimeError("index out of range"), undefined) : v2.$array[v2.$offset + 2]) - (2 >= v.$length ? ($throwRuntimeError("index out of range"), undefined) : v.$array[v.$offset + 2]) * (0 >= v2.$length ? ($throwRuntimeError("index out of range"), undefined) : v2.$array[v2.$offset + 0])]); + }; + $ptrType(Vector).prototype.Cross = function(v2) { return this.$get().Cross(v2); }; + Vector.prototype.Rotate = function(angle, as) { + var _1, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, angle, as, axis, cos, dim, sin, v, x, y, z, z$1; + v = this; + _tmp = 2; + _tmp$1 = v.$length; + axis = _tmp; + dim = _tmp$1; + if (dim === 0) { + return v; + } + if (as.$length > 0) { + axis = (0 >= as.$length ? ($throwRuntimeError("index out of range"), undefined) : as.$array[as.$offset + 0]); + } + if ((dim === 1) && !((axis === 2))) { + v = $append(v, 0, 0); + } + if ((dim < 2 && (axis === 2)) || ((dim === 2) && !((axis === 2)))) { + v = $append(v, 0); + } + _tmp$2 = (0 >= v.$length ? ($throwRuntimeError("index out of range"), undefined) : v.$array[v.$offset + 0]); + _tmp$3 = (1 >= v.$length ? ($throwRuntimeError("index out of range"), undefined) : v.$array[v.$offset + 1]); + x = _tmp$2; + y = _tmp$3; + _tmp$4 = math.Cos(angle); + _tmp$5 = math.Sin(angle); + cos = _tmp$4; + sin = _tmp$5; + _1 = axis; + if (_1 === (0)) { + z = (2 >= v.$length ? ($throwRuntimeError("index out of range"), undefined) : v.$array[v.$offset + 2]); + (1 >= v.$length ? ($throwRuntimeError("index out of range"), undefined) : v.$array[v.$offset + 1] = y * cos - z * sin); + (2 >= v.$length ? ($throwRuntimeError("index out of range"), undefined) : v.$array[v.$offset + 2] = y * sin + z * cos); + } else if (_1 === (1)) { + z$1 = (2 >= v.$length ? ($throwRuntimeError("index out of range"), undefined) : v.$array[v.$offset + 2]); + (0 >= v.$length ? ($throwRuntimeError("index out of range"), undefined) : v.$array[v.$offset + 0] = x * cos + z$1 * sin); + (2 >= v.$length ? ($throwRuntimeError("index out of range"), undefined) : v.$array[v.$offset + 2] = -x * sin + z$1 * cos); + } else if (_1 === (2)) { + (0 >= v.$length ? ($throwRuntimeError("index out of range"), undefined) : v.$array[v.$offset + 0] = x * cos - y * sin); + (1 >= v.$length ? ($throwRuntimeError("index out of range"), undefined) : v.$array[v.$offset + 1] = x * sin + y * cos); + } + if (dim > 3) { + return $subslice(v, 0, 3); + } + return v; + }; + $ptrType(Vector).prototype.Rotate = function(angle, as) { return this.$get().Rotate(angle, as); }; + Vector.prototype.X = function() { + var v; + v = this; + if (v.$length < 1) { + return 0; + } + return (0 >= v.$length ? ($throwRuntimeError("index out of range"), undefined) : v.$array[v.$offset + 0]); + }; + $ptrType(Vector).prototype.X = function() { return this.$get().X(); }; + Vector.prototype.Y = function() { + var v; + v = this; + if (v.$length < 2) { + return 0; + } + return (1 >= v.$length ? ($throwRuntimeError("index out of range"), undefined) : v.$array[v.$offset + 1]); + }; + $ptrType(Vector).prototype.Y = function() { return this.$get().Y(); }; + Vector.prototype.Z = function() { + var v; + v = this; + if (v.$length < 3) { + return 0; + } + return (2 >= v.$length ? ($throwRuntimeError("index out of range"), undefined) : v.$array[v.$offset + 2]); + }; + $ptrType(Vector).prototype.Z = function() { return this.$get().Z(); }; + NewSpace = function(spaceWidth, spaceHeight, cellWidth, cellHeight) { + var _q, _q$1, cellHeight, cellWidth, sp, spaceHeight, spaceWidth; + sp = new Space.ptr(sliceType$2.nil, cellWidth, cellHeight); + sp.Resize((_q = spaceWidth / cellWidth, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero")), (_q$1 = spaceHeight / cellHeight, (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >> 0 : $throwRuntimeError("integer divide by zero"))); + return sp; + }; + $pkg.NewSpace = NewSpace; + Space.ptr.prototype.AddSingle = function(obj) { + var {obj, sp, $s, $r, $c} = $restore(this, {obj}); + /* */ $s = $s || 0; s: while (true) { switch ($s) { case 0: + sp = this; + if (sp === ptrType$1.nil) { + $panic(new $String("ERROR: space is nil")); + } + obj.Space = sp; + $r = obj.Update(); /* */ $s = 1; case 1: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; } + $s = -1; return; + /* */ } return; } var $f = {$blk: Space.ptr.prototype.AddSingle, $c: true, $r, obj, sp, $s};return $f; + }; + Space.prototype.AddSingle = function(obj) { return this.$val.AddSingle(obj); }; + Space.ptr.prototype.Add = function(objects) { + var {_i, _ref, obj, objects, sp, $s, $r, $c} = $restore(this, {objects}); + /* */ $s = $s || 0; s: while (true) { switch ($s) { case 0: + sp = this; + if (sp === ptrType$1.nil) { + $panic(new $String("ERROR: space is nil")); + } + _ref = objects; + _i = 0; + /* while (true) { */ case 1: + /* if (!(_i < _ref.$length)) { break; } */ if(!(_i < _ref.$length)) { $s = 2; continue; } + obj = ((_i < 0 || _i >= _ref.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref.$array[_ref.$offset + _i]); + obj.Space = sp; + $r = obj.Update(); /* */ $s = 3; case 3: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; } + _i++; + $s = 1; continue; + case 2: + $s = -1; return; + /* */ } return; } var $f = {$blk: Space.ptr.prototype.Add, $c: true, $r, _i, _ref, obj, objects, sp, $s};return $f; + }; + Space.prototype.Add = function(objects) { return this.$val.Add(objects); }; + Space.ptr.prototype.RemoveSingle = function(obj) { + var cell, obj, sp; + sp = this; + if (sp === ptrType$1.nil) { + $panic(new $String("ERROR: space is nil")); + } + while (true) { + if (!(0 < obj.TouchingCells.Cnt)) { break; } + cell = $assertType(obj.TouchingCells.Pop(), ptrType); + cell.unregister(obj); + } + obj.Space = ptrType$1.nil; + }; + Space.prototype.RemoveSingle = function(obj) { return this.$val.RemoveSingle(obj); }; + Space.ptr.prototype.Remove = function(objects) { + var _i, _ref, cell, obj, objects, sp; + sp = this; + if (sp === ptrType$1.nil) { + $panic(new $String("ERROR: space is nil")); + } + _ref = objects; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + obj = ((_i < 0 || _i >= _ref.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref.$array[_ref.$offset + _i]); + while (true) { + if (!(0 < obj.TouchingCells.Cnt)) { break; } + cell = $assertType(obj.TouchingCells.Pop(), ptrType); + cell.unregister(obj); + } + obj.Space = ptrType$1.nil; + _i++; + } + }; + Space.prototype.Remove = function(objects) { return this.$val.Remove(objects); }; + Space.ptr.prototype.Objects = function() { + var _entry, _i, _i$1, _key, _ref, _ref$1, _tuple, added, cx, cy, i, o, objects, objectsAdded, rb, sp, x, x$1, x$2; + sp = this; + objectsAdded = $makeMap(ptrType$2.keyFor, []); + objects = new sliceType$3([]); + _ref = sp.Cells; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + cy = _i; + _ref$1 = (x = sp.Cells, ((cy < 0 || cy >= x.$length) ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + cy])); + _i$1 = 0; + while (true) { + if (!(_i$1 < _ref$1.$length)) { break; } + cx = _i$1; + rb = (x$1 = (x$2 = sp.Cells, ((cy < 0 || cy >= x$2.$length) ? ($throwRuntimeError("index out of range"), undefined) : x$2.$array[x$2.$offset + cy])), ((cx < 0 || cx >= x$1.$length) ? ($throwRuntimeError("index out of range"), undefined) : x$1.$array[x$1.$offset + cx])).Objects; + i = rb.StFrameId; + while (true) { + if (!(i < rb.EdFrameId)) { break; } + o = $assertType(rb.GetByFrameId(i), ptrType$2); + _tuple = (_entry = objectsAdded[ptrType$2.keyFor(o)], _entry !== undefined ? [_entry.v, true] : [false, false]); + added = _tuple[1]; + if (!added) { + objects = $append(objects, o); + _key = o; (objectsAdded || $throwRuntimeError("assignment to entry in nil map"))[ptrType$2.keyFor(_key)] = { k: _key, v: true }; + } + i = i + (1) >> 0; + } + _i$1++; + } + _i++; + } + return objects; + }; + Space.prototype.Objects = function() { return this.$val.Objects(); }; + Space.ptr.prototype.Resize = function(width, height) { + var height, sp, width, x, x$1, x$2, x$3, y; + sp = this; + sp.Cells = $makeSlice(sliceType$2, height); + y = 0; + while (true) { + if (!(y < height)) { break; } + (x = sp.Cells, ((y < 0 || y >= x.$length) ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + y] = $makeSlice(sliceType$1, width))); + x$1 = 0; + while (true) { + if (!(x$1 < width)) { break; } + (x$2 = (x$3 = sp.Cells, ((y < 0 || y >= x$3.$length) ? ($throwRuntimeError("index out of range"), undefined) : x$3.$array[x$3.$offset + y])), ((x$1 < 0 || x$1 >= x$2.$length) ? ($throwRuntimeError("index out of range"), undefined) : x$2.$array[x$2.$offset + x$1] = newCell(x$1, y))); + x$1 = x$1 + (1) >> 0; + } + y = y + (1) >> 0; + } + }; + Space.prototype.Resize = function(width, height) { return this.$val.Resize(width, height); }; + Space.ptr.prototype.Cell = function(x, y) { + var sp, x, x$1, x$2, x$3, y; + sp = this; + if (y >= 0 && y < sp.Cells.$length && x >= 0 && x < (x$1 = sp.Cells, ((y < 0 || y >= x$1.$length) ? ($throwRuntimeError("index out of range"), undefined) : x$1.$array[x$1.$offset + y])).$length) { + return (x$2 = (x$3 = sp.Cells, ((y < 0 || y >= x$3.$length) ? ($throwRuntimeError("index out of range"), undefined) : x$3.$array[x$3.$offset + y])), ((x < 0 || x >= x$2.$length) ? ($throwRuntimeError("index out of range"), undefined) : x$2.$array[x$2.$offset + x])); + } + return ptrType.nil; + }; + Space.prototype.Cell = function(x, y) { return this.$val.Cell(x, y); }; + Space.ptr.prototype.CheckCells = function(x, y, w, h, tags) { + var cell, h, i, ix, iy, obj, rb, sp, tags, w, x, y; + sp = this; + ix = x; + while (true) { + if (!(ix < (x + w >> 0))) { break; } + iy = y; + while (true) { + if (!(iy < (y + h >> 0))) { break; } + cell = sp.Cell(ix, iy); + if (!(cell === ptrType.nil)) { + rb = cell.Objects; + if (tags.$length > 0) { + if (cell.ContainsTags(tags)) { + i = rb.StFrameId; + while (true) { + if (!(i < rb.EdFrameId)) { break; } + obj = $assertType(rb.GetByFrameId(i), ptrType$2); + if (obj.HasTags(tags)) { + return obj; + } + i = i + (1) >> 0; + } + } + } else if (cell.Occupied()) { + return $assertType(rb.GetByFrameId(rb.StFrameId), ptrType$2); + } + } + iy = iy + (1) >> 0; + } + ix = ix + (1) >> 0; + } + return ptrType$2.nil; + }; + Space.prototype.CheckCells = function(x, y, w, h, tags) { return this.$val.CheckCells(x, y, w, h, tags); }; + Space.ptr.prototype.CheckCellsWorld = function(x, y, w, h, tags) { + var _tuple, _tuple$1, ch, cw, h, sp, sx, sy, tags, w, x, y; + sp = this; + _tuple = sp.WorldToSpace(x, y); + sx = _tuple[0]; + sy = _tuple[1]; + _tuple$1 = sp.WorldToSpace(w, h); + cw = _tuple$1[0]; + ch = _tuple$1[1]; + return sp.CheckCells(sx, sy, cw, ch, tags); + }; + Space.prototype.CheckCellsWorld = function(x, y, w, h, tags) { return this.$val.CheckCellsWorld(x, y, w, h, tags); }; + Space.ptr.prototype.UnregisterAllObjects = function() { + var cell, i, o, rb, sp, x, x$1, x$2, x$3, y; + sp = this; + y = 0; + while (true) { + if (!(y < sp.Cells.$length)) { break; } + x = 0; + while (true) { + if (!(x < (x$1 = sp.Cells, ((y < 0 || y >= x$1.$length) ? ($throwRuntimeError("index out of range"), undefined) : x$1.$array[x$1.$offset + y])).$length)) { break; } + cell = (x$2 = (x$3 = sp.Cells, ((y < 0 || y >= x$3.$length) ? ($throwRuntimeError("index out of range"), undefined) : x$3.$array[x$3.$offset + y])), ((x < 0 || x >= x$2.$length) ? ($throwRuntimeError("index out of range"), undefined) : x$2.$array[x$2.$offset + x])); + rb = cell.Objects; + i = rb.StFrameId; + while (true) { + if (!(i < rb.EdFrameId)) { break; } + o = $assertType(rb.GetByFrameId(i), ptrType$2); + sp.RemoveSingle(o); + i = i + (1) >> 0; + } + x = x + (1) >> 0; + } + y = y + (1) >> 0; + } + }; + Space.prototype.UnregisterAllObjects = function() { return this.$val.UnregisterAllObjects(); }; + Space.ptr.prototype.WorldToSpace = function(x, y) { + var fx, fy, sp, x, y; + sp = this; + fx = ((math.Floor(x / (sp.CellWidth)) >> 0)); + fy = ((math.Floor(y / (sp.CellHeight)) >> 0)); + return [fx, fy]; + }; + Space.prototype.WorldToSpace = function(x, y) { return this.$val.WorldToSpace(x, y); }; + Space.ptr.prototype.SpaceToWorld = function(x, y) { + var fx, fy, sp, x, y; + sp = this; + fx = (($imul(x, sp.CellWidth))); + fy = (($imul(y, sp.CellHeight))); + return [fx, fy]; + }; + Space.prototype.SpaceToWorld = function(x, y) { return this.$val.SpaceToWorld(x, y); }; + Space.ptr.prototype.Height = function() { + var sp; + sp = this; + return sp.Cells.$length; + }; + Space.prototype.Height = function() { return this.$val.Height(); }; + Space.ptr.prototype.Width = function() { + var sp, x; + sp = this; + if (sp.Cells.$length > 0) { + return (x = sp.Cells, (0 >= x.$length ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + 0])).$length; + } + return 0; + }; + Space.prototype.Width = function() { return this.$val.Width(); }; + Space.ptr.prototype.CellsInLine = function(startX, startY, endX, endY) { + var _q, _q$1, _q$2, _q$3, _tuple, _tuple$1, alternate, c, cell, cells, cx, cy, dv, endCell, endX, endY, p, pX, pY, sp, startX, startY; + sp = this; + cells = new sliceType$1([]); + cell = sp.Cell(startX, startY); + endCell = sp.Cell(endX, endY); + if (!(cell === ptrType.nil) && !(endCell === ptrType.nil)) { + dv = new Vector([((endX - startX >> 0)), ((endY - startY >> 0))]).Unit(); + (0 >= dv.$length ? ($throwRuntimeError("index out of range"), undefined) : dv.$array[dv.$offset + 0] = (0 >= dv.$length ? ($throwRuntimeError("index out of range"), undefined) : dv.$array[dv.$offset + 0]) * (((_q = sp.CellWidth / 2, (_q === _q && _q !== 1/0 && _q !== -1/0) ? _q >> 0 : $throwRuntimeError("integer divide by zero"))))); + (1 >= dv.$length ? ($throwRuntimeError("index out of range"), undefined) : dv.$array[dv.$offset + 1] = (1 >= dv.$length ? ($throwRuntimeError("index out of range"), undefined) : dv.$array[dv.$offset + 1]) * (((_q$1 = sp.CellHeight / 2, (_q$1 === _q$1 && _q$1 !== 1/0 && _q$1 !== -1/0) ? _q$1 >> 0 : $throwRuntimeError("integer divide by zero"))))); + _tuple = sp.SpaceToWorld(startX, startY); + pX = _tuple[0]; + pY = _tuple[1]; + p = new Vector([pX + ((_q$2 = sp.CellWidth / 2, (_q$2 === _q$2 && _q$2 !== 1/0 && _q$2 !== -1/0) ? _q$2 >> 0 : $throwRuntimeError("integer divide by zero"))), pY + ((_q$3 = sp.CellHeight / 2, (_q$3 === _q$3 && _q$3 !== 1/0 && _q$3 !== -1/0) ? _q$3 >> 0 : $throwRuntimeError("integer divide by zero")))]); + alternate = false; + while (true) { + if (!(!(cell === ptrType.nil))) { break; } + if (cell === endCell) { + cells = $append(cells, cell); + break; + } + cells = $append(cells, cell); + if (alternate) { + (1 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 1] = (1 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 1]) + ((1 >= dv.$length ? ($throwRuntimeError("index out of range"), undefined) : dv.$array[dv.$offset + 1]))); + } else { + (0 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 0] = (0 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 0]) + ((0 >= dv.$length ? ($throwRuntimeError("index out of range"), undefined) : dv.$array[dv.$offset + 0]))); + } + _tuple$1 = sp.WorldToSpace((0 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 0]), (1 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 1])); + cx = _tuple$1[0]; + cy = _tuple$1[1]; + c = sp.Cell(cx, cy); + if (!(c === cell)) { + cell = c; + } + alternate = !alternate; + } + } + return cells; + }; + Space.prototype.CellsInLine = function(startX, startY, endX, endY) { return this.$val.CellsInLine(startX, startY, endX, endY); }; + NewLine = function(x, y, x2, y2) { + var x, x2, y, y2; + return new Line.ptr(new Vector([x, y]), new Vector([x2, y2])); + }; + $pkg.NewLine = NewLine; + Line.ptr.prototype.Project = function(axis) { + var axis, line; + line = this; + return line.Vector().Scale(axis.Dot(line.Start.Sub(new sliceType$4([line.End])))); + }; + Line.prototype.Project = function(axis) { return this.$val.Project(axis); }; + Line.ptr.prototype.Normal = function() { + var dx, dy, line, x, x$1, x$2, x$3; + line = this; + dy = (x = line.End, (1 >= x.$length ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + 1])) - (x$1 = line.Start, (1 >= x$1.$length ? ($throwRuntimeError("index out of range"), undefined) : x$1.$array[x$1.$offset + 1])); + dx = (x$2 = line.End, (0 >= x$2.$length ? ($throwRuntimeError("index out of range"), undefined) : x$2.$array[x$2.$offset + 0])) - (x$3 = line.Start, (0 >= x$3.$length ? ($throwRuntimeError("index out of range"), undefined) : x$3.$array[x$3.$offset + 0])); + return new Vector([dy, -dx]).Unit(); + }; + Line.prototype.Normal = function() { return this.$val.Normal(); }; + Line.ptr.prototype.Vector = function() { + var line; + line = this; + return line.End.Clone().Sub(new sliceType$4([line.Start])).Unit(); + }; + Line.prototype.Vector = function() { return this.$val.Vector(); }; + Line.ptr.prototype.IntersectionPointsLine = function(other) { + var det, dx, dy, gamma, lambda, line, other, x, x$1, x$10, x$11, x$12, x$13, x$14, x$15, x$16, x$17, x$18, x$19, x$2, x$20, x$21, x$22, x$23, x$24, x$25, x$26, x$27, x$28, x$29, x$3, x$4, x$5, x$6, x$7, x$8, x$9; + line = this; + det = ((x = line.End, (0 >= x.$length ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + 0])) - (x$1 = line.Start, (0 >= x$1.$length ? ($throwRuntimeError("index out of range"), undefined) : x$1.$array[x$1.$offset + 0]))) * ((x$2 = other.End, (1 >= x$2.$length ? ($throwRuntimeError("index out of range"), undefined) : x$2.$array[x$2.$offset + 1])) - (x$3 = other.Start, (1 >= x$3.$length ? ($throwRuntimeError("index out of range"), undefined) : x$3.$array[x$3.$offset + 1]))) - ((x$4 = other.End, (0 >= x$4.$length ? ($throwRuntimeError("index out of range"), undefined) : x$4.$array[x$4.$offset + 0])) - (x$5 = other.Start, (0 >= x$5.$length ? ($throwRuntimeError("index out of range"), undefined) : x$5.$array[x$5.$offset + 0]))) * ((x$6 = line.End, (1 >= x$6.$length ? ($throwRuntimeError("index out of range"), undefined) : x$6.$array[x$6.$offset + 1])) - (x$7 = line.Start, (1 >= x$7.$length ? ($throwRuntimeError("index out of range"), undefined) : x$7.$array[x$7.$offset + 1]))); + if (!((det === 0))) { + lambda = ((((x$8 = line.Start, (1 >= x$8.$length ? ($throwRuntimeError("index out of range"), undefined) : x$8.$array[x$8.$offset + 1])) - (x$9 = other.Start, (1 >= x$9.$length ? ($throwRuntimeError("index out of range"), undefined) : x$9.$array[x$9.$offset + 1]))) * ((x$10 = other.End, (0 >= x$10.$length ? ($throwRuntimeError("index out of range"), undefined) : x$10.$array[x$10.$offset + 0])) - (x$11 = other.Start, (0 >= x$11.$length ? ($throwRuntimeError("index out of range"), undefined) : x$11.$array[x$11.$offset + 0])))) - (((x$12 = line.Start, (0 >= x$12.$length ? ($throwRuntimeError("index out of range"), undefined) : x$12.$array[x$12.$offset + 0])) - (x$13 = other.Start, (0 >= x$13.$length ? ($throwRuntimeError("index out of range"), undefined) : x$13.$array[x$13.$offset + 0]))) * ((x$14 = other.End, (1 >= x$14.$length ? ($throwRuntimeError("index out of range"), undefined) : x$14.$array[x$14.$offset + 1])) - (x$15 = other.Start, (1 >= x$15.$length ? ($throwRuntimeError("index out of range"), undefined) : x$15.$array[x$15.$offset + 1])))) + 1) / det; + gamma = ((((x$16 = line.Start, (1 >= x$16.$length ? ($throwRuntimeError("index out of range"), undefined) : x$16.$array[x$16.$offset + 1])) - (x$17 = other.Start, (1 >= x$17.$length ? ($throwRuntimeError("index out of range"), undefined) : x$17.$array[x$17.$offset + 1]))) * ((x$18 = line.End, (0 >= x$18.$length ? ($throwRuntimeError("index out of range"), undefined) : x$18.$array[x$18.$offset + 0])) - (x$19 = line.Start, (0 >= x$19.$length ? ($throwRuntimeError("index out of range"), undefined) : x$19.$array[x$19.$offset + 0])))) - (((x$20 = line.Start, (0 >= x$20.$length ? ($throwRuntimeError("index out of range"), undefined) : x$20.$array[x$20.$offset + 0])) - (x$21 = other.Start, (0 >= x$21.$length ? ($throwRuntimeError("index out of range"), undefined) : x$21.$array[x$21.$offset + 0]))) * ((x$22 = line.End, (1 >= x$22.$length ? ($throwRuntimeError("index out of range"), undefined) : x$22.$array[x$22.$offset + 1])) - (x$23 = line.Start, (1 >= x$23.$length ? ($throwRuntimeError("index out of range"), undefined) : x$23.$array[x$23.$offset + 1])))) + 1) / det; + if ((0 < lambda && lambda < 1) && (0 < gamma && gamma < 1)) { + dx = (x$24 = line.End, (0 >= x$24.$length ? ($throwRuntimeError("index out of range"), undefined) : x$24.$array[x$24.$offset + 0])) - (x$25 = line.Start, (0 >= x$25.$length ? ($throwRuntimeError("index out of range"), undefined) : x$25.$array[x$25.$offset + 0])); + dy = (x$26 = line.End, (1 >= x$26.$length ? ($throwRuntimeError("index out of range"), undefined) : x$26.$array[x$26.$offset + 1])) - (x$27 = line.Start, (1 >= x$27.$length ? ($throwRuntimeError("index out of range"), undefined) : x$27.$array[x$27.$offset + 1])); + return new Vector([(x$28 = line.Start, (0 >= x$28.$length ? ($throwRuntimeError("index out of range"), undefined) : x$28.$array[x$28.$offset + 0])) + (lambda * dx), (x$29 = line.Start, (1 >= x$29.$length ? ($throwRuntimeError("index out of range"), undefined) : x$29.$array[x$29.$offset + 1])) + (lambda * dy)]); + } + } + return Vector.nil; + }; + Line.prototype.IntersectionPointsLine = function(other) { return this.$val.IntersectionPointsLine(other); }; + Line.ptr.prototype.IntersectionPointsCircle = function(circle) { + var a, b, c, circle, cp, det, diff, lEnd, lStart, line, points, t, t$1, x, x$1, x$2, x$3, x$4, x$5; + line = this; + points = new sliceType$4([]); + cp = new Vector([circle.X, circle.Y]); + lStart = line.Start.Sub(new sliceType$4([cp])); + lEnd = line.End.Sub(new sliceType$4([cp])); + diff = lEnd.Sub(new sliceType$4([lStart])); + a = (0 >= diff.$length ? ($throwRuntimeError("index out of range"), undefined) : diff.$array[diff.$offset + 0]) * (0 >= diff.$length ? ($throwRuntimeError("index out of range"), undefined) : diff.$array[diff.$offset + 0]) + (1 >= diff.$length ? ($throwRuntimeError("index out of range"), undefined) : diff.$array[diff.$offset + 1]) * (1 >= diff.$length ? ($throwRuntimeError("index out of range"), undefined) : diff.$array[diff.$offset + 1]); + b = 2 * (((0 >= diff.$length ? ($throwRuntimeError("index out of range"), undefined) : diff.$array[diff.$offset + 0]) * (0 >= lStart.$length ? ($throwRuntimeError("index out of range"), undefined) : lStart.$array[lStart.$offset + 0])) + ((1 >= diff.$length ? ($throwRuntimeError("index out of range"), undefined) : diff.$array[diff.$offset + 1]) * (1 >= lStart.$length ? ($throwRuntimeError("index out of range"), undefined) : lStart.$array[lStart.$offset + 1]))); + c = ((0 >= lStart.$length ? ($throwRuntimeError("index out of range"), undefined) : lStart.$array[lStart.$offset + 0]) * (0 >= lStart.$length ? ($throwRuntimeError("index out of range"), undefined) : lStart.$array[lStart.$offset + 0])) + ((1 >= lStart.$length ? ($throwRuntimeError("index out of range"), undefined) : lStart.$array[lStart.$offset + 1]) * (1 >= lStart.$length ? ($throwRuntimeError("index out of range"), undefined) : lStart.$array[lStart.$offset + 1])) - (circle.Radius * circle.Radius); + det = b * b - (4 * a * c); + if (det < 0) { + } else if (det === 0) { + t = -b / (2 * a); + if (t >= 0 && t <= 1) { + points = $append(points, new Vector([(x = line.Start, (0 >= x.$length ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + 0])) + t * (0 >= diff.$length ? ($throwRuntimeError("index out of range"), undefined) : diff.$array[diff.$offset + 0]), (x$1 = line.Start, (1 >= x$1.$length ? ($throwRuntimeError("index out of range"), undefined) : x$1.$array[x$1.$offset + 1])) + t * (1 >= diff.$length ? ($throwRuntimeError("index out of range"), undefined) : diff.$array[diff.$offset + 1])])); + } + } else { + t$1 = (-b + math.Sqrt(det)) / (2 * a); + if (t$1 >= 0 && t$1 <= 1) { + points = $append(points, new Vector([(x$2 = line.Start, (0 >= x$2.$length ? ($throwRuntimeError("index out of range"), undefined) : x$2.$array[x$2.$offset + 0])) + t$1 * (0 >= diff.$length ? ($throwRuntimeError("index out of range"), undefined) : diff.$array[diff.$offset + 0]), (x$3 = line.Start, (1 >= x$3.$length ? ($throwRuntimeError("index out of range"), undefined) : x$3.$array[x$3.$offset + 1])) + t$1 * (1 >= diff.$length ? ($throwRuntimeError("index out of range"), undefined) : diff.$array[diff.$offset + 1])])); + } + t$1 = (-b - math.Sqrt(det)) / (2 * a); + if (t$1 >= 0 && t$1 <= 1) { + points = $append(points, new Vector([(x$4 = line.Start, (0 >= x$4.$length ? ($throwRuntimeError("index out of range"), undefined) : x$4.$array[x$4.$offset + 0])) + t$1 * (0 >= diff.$length ? ($throwRuntimeError("index out of range"), undefined) : diff.$array[diff.$offset + 0]), (x$5 = line.Start, (1 >= x$5.$length ? ($throwRuntimeError("index out of range"), undefined) : x$5.$array[x$5.$offset + 1])) + t$1 * (1 >= diff.$length ? ($throwRuntimeError("index out of range"), undefined) : diff.$array[diff.$offset + 1])])); + } + } + return points; + }; + Line.prototype.IntersectionPointsCircle = function(circle) { return this.$val.IntersectionPointsCircle(circle); }; + NewConvexPolygon = function(points) { + var cp, points; + cp = new ConvexPolygon.ptr(new sliceType$4([]), 0, 0, true); + cp.AddPoints(points); + return cp; + }; + $pkg.NewConvexPolygon = NewConvexPolygon; + ConvexPolygon.ptr.prototype.Clone = function() { + var _i, _ref, cp, newPoly, point, points; + cp = this; + points = new sliceType$4([]); + _ref = cp.Points; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + point = ((_i < 0 || _i >= _ref.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref.$array[_ref.$offset + _i]); + points = $append(points, point.Clone()); + _i++; + } + newPoly = NewConvexPolygon(sliceType.nil); + newPoly.X = cp.X; + newPoly.Y = cp.Y; + newPoly.AddPointsVec(points); + newPoly.Closed = cp.Closed; + return newPoly; + }; + ConvexPolygon.prototype.Clone = function() { return this.$val.Clone(); }; + ConvexPolygon.ptr.prototype.AddPointsVec = function(points) { + var cp, points; + cp = this; + cp.Points = $appendSlice(cp.Points, points); + }; + ConvexPolygon.prototype.AddPointsVec = function(points) { return this.$val.AddPointsVec(points); }; + ConvexPolygon.ptr.prototype.AddPoints = function(vertexPositions) { + var cp, v, vertexPositions, x; + cp = this; + v = 0; + while (true) { + if (!(v < vertexPositions.$length)) { break; } + cp.Points = $append(cp.Points, new Vector([((v < 0 || v >= vertexPositions.$length) ? ($throwRuntimeError("index out of range"), undefined) : vertexPositions.$array[vertexPositions.$offset + v]), (x = v + 1 >> 0, ((x < 0 || x >= vertexPositions.$length) ? ($throwRuntimeError("index out of range"), undefined) : vertexPositions.$array[vertexPositions.$offset + x]))])); + v = v + (2) >> 0; + } + }; + ConvexPolygon.prototype.AddPoints = function(vertexPositions) { return this.$val.AddPoints(vertexPositions); }; + ConvexPolygon.ptr.prototype.Lines = function() { + var _tmp, _tmp$1, cp, end, i, line, lines, linesCnt, start, vertices, x; + cp = this; + vertices = cp.Transformed(); + linesCnt = vertices.$length; + if (!cp.Closed) { + linesCnt = linesCnt - (1) >> 0; + } + lines = $makeSlice(sliceType$5, linesCnt); + i = 0; + while (true) { + if (!(i < linesCnt)) { break; } + _tmp = ((i < 0 || i >= vertices.$length) ? ($throwRuntimeError("index out of range"), undefined) : vertices.$array[vertices.$offset + i]); + _tmp$1 = (0 >= vertices.$length ? ($throwRuntimeError("index out of range"), undefined) : vertices.$array[vertices.$offset + 0]); + start = _tmp; + end = _tmp$1; + if (i < (vertices.$length - 1 >> 0)) { + end = (x = i + 1 >> 0, ((x < 0 || x >= vertices.$length) ? ($throwRuntimeError("index out of range"), undefined) : vertices.$array[vertices.$offset + x])); + } + line = NewLine((0 >= start.$length ? ($throwRuntimeError("index out of range"), undefined) : start.$array[start.$offset + 0]), (1 >= start.$length ? ($throwRuntimeError("index out of range"), undefined) : start.$array[start.$offset + 1]), (0 >= end.$length ? ($throwRuntimeError("index out of range"), undefined) : end.$array[end.$offset + 0]), (1 >= end.$length ? ($throwRuntimeError("index out of range"), undefined) : end.$array[end.$offset + 1])); + ((i < 0 || i >= lines.$length) ? ($throwRuntimeError("index out of range"), undefined) : lines.$array[lines.$offset + i] = line); + i = i + (1) >> 0; + } + return lines; + }; + ConvexPolygon.prototype.Lines = function() { return this.$val.Lines(); }; + ConvexPolygon.ptr.prototype.Transformed = function() { + var _i, _ref, cp, i, point, transformed; + cp = this; + transformed = $makeSlice(sliceType$4, cp.Points.$length); + _ref = cp.Points; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + i = _i; + point = ((_i < 0 || _i >= _ref.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref.$array[_ref.$offset + _i]); + ((i < 0 || i >= transformed.$length) ? ($throwRuntimeError("index out of range"), undefined) : transformed.$array[transformed.$offset + i] = new Vector([(0 >= point.$length ? ($throwRuntimeError("index out of range"), undefined) : point.$array[point.$offset + 0]) + cp.X, (1 >= point.$length ? ($throwRuntimeError("index out of range"), undefined) : point.$array[point.$offset + 1]) + cp.Y])); + _i++; + } + return transformed; + }; + ConvexPolygon.prototype.Transformed = function() { return this.$val.Transformed(); }; + ConvexPolygon.ptr.prototype.Bounds = function() { + var bottomRight, cp, i, point, topLeft, transformed, x, x$1; + cp = this; + transformed = cp.Transformed(); + topLeft = new Vector([(x = (0 >= transformed.$length ? ($throwRuntimeError("index out of range"), undefined) : transformed.$array[transformed.$offset + 0]), (0 >= x.$length ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + 0])), (x$1 = (0 >= transformed.$length ? ($throwRuntimeError("index out of range"), undefined) : transformed.$array[transformed.$offset + 0]), (1 >= x$1.$length ? ($throwRuntimeError("index out of range"), undefined) : x$1.$array[x$1.$offset + 1]))]); + bottomRight = topLeft.Clone(); + i = 0; + while (true) { + if (!(i < transformed.$length)) { break; } + point = ((i < 0 || i >= transformed.$length) ? ($throwRuntimeError("index out of range"), undefined) : transformed.$array[transformed.$offset + i]); + if ((0 >= point.$length ? ($throwRuntimeError("index out of range"), undefined) : point.$array[point.$offset + 0]) < (0 >= topLeft.$length ? ($throwRuntimeError("index out of range"), undefined) : topLeft.$array[topLeft.$offset + 0])) { + (0 >= topLeft.$length ? ($throwRuntimeError("index out of range"), undefined) : topLeft.$array[topLeft.$offset + 0] = (0 >= point.$length ? ($throwRuntimeError("index out of range"), undefined) : point.$array[point.$offset + 0])); + } else if ((0 >= point.$length ? ($throwRuntimeError("index out of range"), undefined) : point.$array[point.$offset + 0]) > (0 >= bottomRight.$length ? ($throwRuntimeError("index out of range"), undefined) : bottomRight.$array[bottomRight.$offset + 0])) { + (0 >= bottomRight.$length ? ($throwRuntimeError("index out of range"), undefined) : bottomRight.$array[bottomRight.$offset + 0] = (0 >= point.$length ? ($throwRuntimeError("index out of range"), undefined) : point.$array[point.$offset + 0])); + } + if ((1 >= point.$length ? ($throwRuntimeError("index out of range"), undefined) : point.$array[point.$offset + 1]) < (1 >= topLeft.$length ? ($throwRuntimeError("index out of range"), undefined) : topLeft.$array[topLeft.$offset + 1])) { + (1 >= topLeft.$length ? ($throwRuntimeError("index out of range"), undefined) : topLeft.$array[topLeft.$offset + 1] = (1 >= point.$length ? ($throwRuntimeError("index out of range"), undefined) : point.$array[point.$offset + 1])); + } else if ((1 >= point.$length ? ($throwRuntimeError("index out of range"), undefined) : point.$array[point.$offset + 1]) > (1 >= bottomRight.$length ? ($throwRuntimeError("index out of range"), undefined) : bottomRight.$array[bottomRight.$offset + 1])) { + (1 >= bottomRight.$length ? ($throwRuntimeError("index out of range"), undefined) : bottomRight.$array[bottomRight.$offset + 1] = (1 >= point.$length ? ($throwRuntimeError("index out of range"), undefined) : point.$array[point.$offset + 1])); + } + i = i + (1) >> 0; + } + return [topLeft, bottomRight]; + }; + ConvexPolygon.prototype.Bounds = function() { return this.$val.Bounds(); }; + ConvexPolygon.ptr.prototype.Position = function() { + var cp; + cp = this; + return [cp.X, cp.Y]; + }; + ConvexPolygon.prototype.Position = function() { return this.$val.Position(); }; + ConvexPolygon.ptr.prototype.SetPosition = function(x, y) { + var cp, x, y; + cp = this; + cp.X = x; + cp.Y = y; + }; + ConvexPolygon.prototype.SetPosition = function(x, y) { return this.$val.SetPosition(x, y); }; + ConvexPolygon.ptr.prototype.SetPositionVec = function(vec) { + var cp, vec; + cp = this; + cp.X = vec.X(); + cp.Y = vec.Y(); + }; + ConvexPolygon.prototype.SetPositionVec = function(vec) { return this.$val.SetPositionVec(vec); }; + ConvexPolygon.ptr.prototype.Move = function(x, y) { + var cp, x, y; + cp = this; + cp.X = cp.X + (x); + cp.Y = cp.Y + (y); + }; + ConvexPolygon.prototype.Move = function(x, y) { return this.$val.Move(x, y); }; + ConvexPolygon.ptr.prototype.MoveVec = function(vec) { + var cp, vec; + cp = this; + cp.X = cp.X + (vec.X()); + cp.Y = cp.Y + (vec.Y()); + }; + ConvexPolygon.prototype.MoveVec = function(vec) { return this.$val.MoveVec(vec); }; + ConvexPolygon.ptr.prototype.Center = function() { + var _i, _ref, cp, denom, pos, v, vertices; + cp = this; + pos = new Vector([0, 0]); + vertices = cp.Transformed(); + _ref = vertices; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + v = ((_i < 0 || _i >= _ref.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref.$array[_ref.$offset + _i]); + pos.Add(new sliceType$4([v])); + _i++; + } + denom = (vertices.$length); + (0 >= pos.$length ? ($throwRuntimeError("index out of range"), undefined) : pos.$array[pos.$offset + 0] = (0 >= pos.$length ? ($throwRuntimeError("index out of range"), undefined) : pos.$array[pos.$offset + 0]) / (denom)); + (1 >= pos.$length ? ($throwRuntimeError("index out of range"), undefined) : pos.$array[pos.$offset + 1] = (1 >= pos.$length ? ($throwRuntimeError("index out of range"), undefined) : pos.$array[pos.$offset + 1]) / (denom)); + return pos; + }; + ConvexPolygon.prototype.Center = function() { return this.$val.Center(); }; + ConvexPolygon.ptr.prototype.Project = function(axis) { + var axis, cp, i, max, min, p, vertices, x, x$1, x$2, x$3; + cp = this; + axis = axis.Unit(); + vertices = cp.Transformed(); + min = axis.Dot(new Vector([(x = (0 >= vertices.$length ? ($throwRuntimeError("index out of range"), undefined) : vertices.$array[vertices.$offset + 0]), (0 >= x.$length ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + 0])), (x$1 = (0 >= vertices.$length ? ($throwRuntimeError("index out of range"), undefined) : vertices.$array[vertices.$offset + 0]), (1 >= x$1.$length ? ($throwRuntimeError("index out of range"), undefined) : x$1.$array[x$1.$offset + 1]))])); + max = min; + i = 1; + while (true) { + if (!(i < vertices.$length)) { break; } + p = axis.Dot(new Vector([(x$2 = ((i < 0 || i >= vertices.$length) ? ($throwRuntimeError("index out of range"), undefined) : vertices.$array[vertices.$offset + i]), (0 >= x$2.$length ? ($throwRuntimeError("index out of range"), undefined) : x$2.$array[x$2.$offset + 0])), (x$3 = ((i < 0 || i >= vertices.$length) ? ($throwRuntimeError("index out of range"), undefined) : vertices.$array[vertices.$offset + i]), (1 >= x$3.$length ? ($throwRuntimeError("index out of range"), undefined) : x$3.$array[x$3.$offset + 1]))])); + if (p < min) { + min = p; + } else if (p > max) { + max = p; + } + i = i + (1) >> 0; + } + return new Projection.ptr(min, max); + }; + ConvexPolygon.prototype.Project = function(axis) { return this.$val.Project(axis); }; + ConvexPolygon.ptr.prototype.SATAxes = function() { + var _i, _ref, axes, cp, i, line, lines; + cp = this; + lines = cp.Lines(); + axes = $makeSlice(sliceType$4, lines.$length); + _ref = lines; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + i = _i; + line = ((_i < 0 || _i >= _ref.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref.$array[_ref.$offset + _i]); + ((i < 0 || i >= axes.$length) ? ($throwRuntimeError("index out of range"), undefined) : axes.$array[axes.$offset + i] = line.Normal()); + _i++; + } + return axes; + }; + ConvexPolygon.prototype.SATAxes = function() { return this.$val.SATAxes(); }; + ConvexPolygon.ptr.prototype.PointInside = function(point) { + var _i, _ref, contactCount, line, point, pointLine, polygon; + polygon = this; + pointLine = NewLine((0 >= point.$length ? ($throwRuntimeError("index out of range"), undefined) : point.$array[point.$offset + 0]), (1 >= point.$length ? ($throwRuntimeError("index out of range"), undefined) : point.$array[point.$offset + 1]), (0 >= point.$length ? ($throwRuntimeError("index out of range"), undefined) : point.$array[point.$offset + 0]) + 9.99999999999e+11, (1 >= point.$length ? ($throwRuntimeError("index out of range"), undefined) : point.$array[point.$offset + 1])); + contactCount = 0; + _ref = polygon.Lines(); + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + line = ((_i < 0 || _i >= _ref.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref.$array[_ref.$offset + _i]); + if (!(line.IntersectionPointsLine(pointLine) === Vector.nil)) { + contactCount = contactCount + (1) >> 0; + } + _i++; + } + return contactCount === 1; + }; + ConvexPolygon.prototype.PointInside = function(point) { return this.$val.PointInside(point); }; + ConvexPolygon.ptr.prototype.GetPoints = function() { + var polygon; + polygon = this; + return polygon.Points; + }; + ConvexPolygon.prototype.GetPoints = function() { return this.$val.GetPoints(); }; + NewContactSet = function() { + return new ContactSet.ptr(new sliceType$4([]), new Vector([0, 0]), new Vector([0, 0])); + }; + $pkg.NewContactSet = NewContactSet; + ContactSet.ptr.prototype.LeftmostPoint = function() { + var _i, _ref, cs, left, point; + cs = this; + left = Vector.nil; + _ref = cs.Points; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + point = ((_i < 0 || _i >= _ref.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref.$array[_ref.$offset + _i]); + if (left === Vector.nil || (0 >= point.$length ? ($throwRuntimeError("index out of range"), undefined) : point.$array[point.$offset + 0]) < (0 >= left.$length ? ($throwRuntimeError("index out of range"), undefined) : left.$array[left.$offset + 0])) { + left = point; + } + _i++; + } + return left; + }; + ContactSet.prototype.LeftmostPoint = function() { return this.$val.LeftmostPoint(); }; + ContactSet.ptr.prototype.RightmostPoint = function() { + var _i, _ref, cs, point, right; + cs = this; + right = Vector.nil; + _ref = cs.Points; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + point = ((_i < 0 || _i >= _ref.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref.$array[_ref.$offset + _i]); + if (right === Vector.nil || (0 >= point.$length ? ($throwRuntimeError("index out of range"), undefined) : point.$array[point.$offset + 0]) > (0 >= right.$length ? ($throwRuntimeError("index out of range"), undefined) : right.$array[right.$offset + 0])) { + right = point; + } + _i++; + } + return right; + }; + ContactSet.prototype.RightmostPoint = function() { return this.$val.RightmostPoint(); }; + ContactSet.ptr.prototype.TopmostPoint = function() { + var _i, _ref, cs, point, top; + cs = this; + top = Vector.nil; + _ref = cs.Points; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + point = ((_i < 0 || _i >= _ref.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref.$array[_ref.$offset + _i]); + if (top === Vector.nil || (1 >= point.$length ? ($throwRuntimeError("index out of range"), undefined) : point.$array[point.$offset + 1]) < (1 >= top.$length ? ($throwRuntimeError("index out of range"), undefined) : top.$array[top.$offset + 1])) { + top = point; + } + _i++; + } + return top; + }; + ContactSet.prototype.TopmostPoint = function() { return this.$val.TopmostPoint(); }; + ContactSet.ptr.prototype.BottommostPoint = function() { + var _i, _ref, bottom, cs, point; + cs = this; + bottom = Vector.nil; + _ref = cs.Points; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + point = ((_i < 0 || _i >= _ref.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref.$array[_ref.$offset + _i]); + if (bottom === Vector.nil || (1 >= point.$length ? ($throwRuntimeError("index out of range"), undefined) : point.$array[point.$offset + 1]) > (1 >= bottom.$length ? ($throwRuntimeError("index out of range"), undefined) : bottom.$array[bottom.$offset + 1])) { + bottom = point; + } + _i++; + } + return bottom; + }; + ContactSet.prototype.BottommostPoint = function() { return this.$val.BottommostPoint(); }; + ConvexPolygon.ptr.prototype.Intersection = function(dx, dy, other) { + var _i, _i$1, _i$2, _i$3, _ref, _ref$1, _ref$2, _ref$3, _tuple, _tuple$1, circle, contactSet, cp, deltaMagnitude, dx, dy, isCircle, isPoly, line, line$1, mtv, ogMagnitude, ogX, ogY, other, otherLine, point, point$1, poly, x, x$1, x$2, x$3; + cp = this; + contactSet = NewContactSet(); + ogX = cp.X; + ogY = cp.Y; + cp.X = cp.X + (dx); + cp.Y = cp.Y + (dy); + _tuple = $assertType(other, ptrType$4, true); + circle = _tuple[0]; + isCircle = _tuple[1]; + if (isCircle) { + _ref = cp.Lines(); + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + line = ((_i < 0 || _i >= _ref.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref.$array[_ref.$offset + _i]); + contactSet.Points = $appendSlice(contactSet.Points, line.IntersectionPointsCircle(circle)); + _i++; + } + } else { + _tuple$1 = $assertType(other, ptrType$5, true); + poly = _tuple$1[0]; + isPoly = _tuple$1[1]; + if (isPoly) { + _ref$1 = cp.Lines(); + _i$1 = 0; + while (true) { + if (!(_i$1 < _ref$1.$length)) { break; } + line$1 = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref$1.$array[_ref$1.$offset + _i$1]); + _ref$2 = poly.Lines(); + _i$2 = 0; + while (true) { + if (!(_i$2 < _ref$2.$length)) { break; } + otherLine = ((_i$2 < 0 || _i$2 >= _ref$2.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref$2.$array[_ref$2.$offset + _i$2]); + point = line$1.IntersectionPointsLine(otherLine); + if (!(point === Vector.nil)) { + contactSet.Points = $append(contactSet.Points, point); + } + _i$2++; + } + _i$1++; + } + } + } + if (contactSet.Points.$length > 0) { + _ref$3 = contactSet.Points; + _i$3 = 0; + while (true) { + if (!(_i$3 < _ref$3.$length)) { break; } + point$1 = ((_i$3 < 0 || _i$3 >= _ref$3.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref$3.$array[_ref$3.$offset + _i$3]); + contactSet.Center = contactSet.Center.Add(new sliceType$4([point$1])); + _i$3++; + } + (x$1 = contactSet.Center, (0 >= x$1.$length ? ($throwRuntimeError("index out of range"), undefined) : x$1.$array[x$1.$offset + 0] = (x = contactSet.Center, (0 >= x.$length ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + 0])) / ((contactSet.Points.$length)))); + (x$3 = contactSet.Center, (1 >= x$3.$length ? ($throwRuntimeError("index out of range"), undefined) : x$3.$array[x$3.$offset + 1] = (x$2 = contactSet.Center, (1 >= x$2.$length ? ($throwRuntimeError("index out of range"), undefined) : x$2.$array[x$2.$offset + 1])) / ((contactSet.Points.$length)))); + mtv = cp.calculateMTV(contactSet, other); + if (!(mtv === Vector.nil)) { + contactSet.MTV = mtv; + } + } else { + contactSet = ptrType$6.nil; + } + if (!(contactSet === ptrType$6.nil) && (!((dx === 0)) || !((dy === 0)))) { + deltaMagnitude = new Vector([dx, dy]).Magnitude(); + ogMagnitude = contactSet.MTV.Magnitude(); + contactSet.MTV = contactSet.MTV.Unit().Scale(ogMagnitude - deltaMagnitude); + } + cp.X = ogX; + cp.Y = ogY; + return contactSet; + }; + ConvexPolygon.prototype.Intersection = function(dx, dy, other) { return this.$val.Intersection(dx, dy, other); }; + ConvexPolygon.ptr.prototype.calculateMTV = function(contactSet, otherShape) { + var _i, _i$1, _ref, _ref$1, _ref$2, axis, axis$1, contactSet, cp, delta, other, otherShape, overlap, overlap$1, smallest; + cp = this; + delta = new Vector([0, 0]); + smallest = new Vector([1.7976931348623157e+308, 0]); + _ref = otherShape; + if ($assertType(_ref, ptrType$5, true)[1]) { + other = _ref.$val; + _ref$1 = cp.SATAxes(); + _i = 0; + while (true) { + if (!(_i < _ref$1.$length)) { break; } + axis = ((_i < 0 || _i >= _ref$1.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref$1.$array[_ref$1.$offset + _i]); + if (!$clone(cp.Project(axis), Projection).Overlapping($clone(other.Project(axis), Projection))) { + return Vector.nil; + } + overlap = $clone(cp.Project(axis), Projection).Overlap($clone(other.Project(axis), Projection)); + if (smallest.Magnitude() > overlap) { + smallest = axis.Scale(overlap); + } + _i++; + } + _ref$2 = other.SATAxes(); + _i$1 = 0; + while (true) { + if (!(_i$1 < _ref$2.$length)) { break; } + axis$1 = ((_i$1 < 0 || _i$1 >= _ref$2.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref$2.$array[_ref$2.$offset + _i$1]); + if (!$clone(cp.Project(axis$1), Projection).Overlapping($clone(other.Project(axis$1), Projection))) { + return Vector.nil; + } + overlap$1 = $clone(cp.Project(axis$1), Projection).Overlap($clone(other.Project(axis$1), Projection)); + if (smallest.Magnitude() > overlap$1) { + smallest = axis$1.Scale(overlap$1); + } + _i$1++; + } + } + (0 >= delta.$length ? ($throwRuntimeError("index out of range"), undefined) : delta.$array[delta.$offset + 0] = (0 >= smallest.$length ? ($throwRuntimeError("index out of range"), undefined) : smallest.$array[smallest.$offset + 0])); + (1 >= delta.$length ? ($throwRuntimeError("index out of range"), undefined) : delta.$array[delta.$offset + 1] = (1 >= smallest.$length ? ($throwRuntimeError("index out of range"), undefined) : smallest.$array[smallest.$offset + 1])); + return delta; + }; + ConvexPolygon.prototype.calculateMTV = function(contactSet, otherShape) { return this.$val.calculateMTV(contactSet, otherShape); }; + ConvexPolygon.ptr.prototype.ContainedBy = function(otherShape) { + var _i, _i$1, _ref, _ref$1, _ref$2, axis, axis$1, cp, other, otherShape; + cp = this; + _ref = otherShape; + if ($assertType(_ref, ptrType$5, true)[1]) { + other = _ref.$val; + _ref$1 = cp.SATAxes(); + _i = 0; + while (true) { + if (!(_i < _ref$1.$length)) { break; } + axis = ((_i < 0 || _i >= _ref$1.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref$1.$array[_ref$1.$offset + _i]); + if (!$clone(cp.Project(axis), Projection).IsInside($clone(other.Project(axis), Projection))) { + return false; + } + _i++; + } + _ref$2 = other.SATAxes(); + _i$1 = 0; + while (true) { + if (!(_i$1 < _ref$2.$length)) { break; } + axis$1 = ((_i$1 < 0 || _i$1 >= _ref$2.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref$2.$array[_ref$2.$offset + _i$1]); + if (!$clone(cp.Project(axis$1), Projection).IsInside($clone(other.Project(axis$1), Projection))) { + return false; + } + _i$1++; + } + } + return true; + }; + ConvexPolygon.prototype.ContainedBy = function(otherShape) { return this.$val.ContainedBy(otherShape); }; + ConvexPolygon.ptr.prototype.FlipH = function() { + var _i, _ref, cp, v; + cp = this; + _ref = cp.Points; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + v = ((_i < 0 || _i >= _ref.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref.$array[_ref.$offset + _i]); + (0 >= v.$length ? ($throwRuntimeError("index out of range"), undefined) : v.$array[v.$offset + 0] = -(0 >= v.$length ? ($throwRuntimeError("index out of range"), undefined) : v.$array[v.$offset + 0])); + _i++; + } + cp.ReverseVertexOrder(); + }; + ConvexPolygon.prototype.FlipH = function() { return this.$val.FlipH(); }; + ConvexPolygon.ptr.prototype.FlipV = function() { + var _i, _ref, cp, v; + cp = this; + _ref = cp.Points; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + v = ((_i < 0 || _i >= _ref.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref.$array[_ref.$offset + _i]); + (1 >= v.$length ? ($throwRuntimeError("index out of range"), undefined) : v.$array[v.$offset + 1] = -(1 >= v.$length ? ($throwRuntimeError("index out of range"), undefined) : v.$array[v.$offset + 1])); + _i++; + } + cp.ReverseVertexOrder(); + }; + ConvexPolygon.prototype.FlipV = function() { return this.$val.FlipV(); }; + ConvexPolygon.ptr.prototype.ReverseVertexOrder = function() { + var cp, i, verts, x, x$1; + cp = this; + verts = new sliceType$4([(x = cp.Points, (0 >= x.$length ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + 0]))]); + i = cp.Points.$length - 1 >> 0; + while (true) { + if (!(i >= 1)) { break; } + verts = $append(verts, (x$1 = cp.Points, ((i < 0 || i >= x$1.$length) ? ($throwRuntimeError("index out of range"), undefined) : x$1.$array[x$1.$offset + i]))); + i = i - (1) >> 0; + } + cp.Points = verts; + }; + ConvexPolygon.prototype.ReverseVertexOrder = function() { return this.$val.ReverseVertexOrder(); }; + NewRectangle = function(x, y, w, h) { + var h, w, x, y; + return NewConvexPolygon(new sliceType([x, y, x + w, y, x + w, y + h, x, y + h])); + }; + $pkg.NewRectangle = NewRectangle; + NewCircle = function(x, y, radius) { + var circle, radius, x, y; + circle = new Circle.ptr(x, y, radius); + return circle; + }; + $pkg.NewCircle = NewCircle; + Circle.ptr.prototype.Clone = function() { + var circle; + circle = this; + return NewCircle(circle.X, circle.Y, circle.Radius); + }; + Circle.prototype.Clone = function() { return this.$val.Clone(); }; + Circle.ptr.prototype.Bounds = function() { + var circle; + circle = this; + return [new Vector([circle.X - circle.Radius, circle.Y - circle.Radius]), new Vector([circle.X + circle.Radius, circle.Y + circle.Radius])]; + }; + Circle.prototype.Bounds = function() { return this.$val.Bounds(); }; + Circle.ptr.prototype.Intersection = function(dx, dy, other) { + var _i, _ref, _ref$1, circle, contactSet, dist, dx, dy, other, ox, oy, point, shape, shape$1, x, x$1, x$2, x$3; + circle = this; + contactSet = ptrType$6.nil; + ox = circle.X; + oy = circle.Y; + circle.X = circle.X + (dx); + circle.Y = circle.Y + (dy); + _ref = other; + if ($assertType(_ref, ptrType$5, true)[1]) { + shape = _ref.$val; + contactSet = shape.Intersection(-dx, -dy, circle); + if (!(contactSet === ptrType$6.nil)) { + contactSet.MTV = contactSet.MTV.Scale(-1); + } + } else if ($assertType(_ref, ptrType$4, true)[1]) { + shape$1 = _ref.$val; + contactSet = NewContactSet(); + contactSet.Points = circle.IntersectionPointsCircle(shape$1); + if (contactSet.Points.$length === 0) { + return ptrType$6.nil; + } + contactSet.MTV = new Vector([circle.X - shape$1.X, circle.Y - shape$1.Y]); + dist = contactSet.MTV.Magnitude(); + contactSet.MTV = contactSet.MTV.Unit().Scale(circle.Radius + shape$1.Radius - dist); + _ref$1 = contactSet.Points; + _i = 0; + while (true) { + if (!(_i < _ref$1.$length)) { break; } + point = ((_i < 0 || _i >= _ref$1.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref$1.$array[_ref$1.$offset + _i]); + contactSet.Center = contactSet.Center.Add(new sliceType$4([point])); + _i++; + } + (x$1 = contactSet.Center, (0 >= x$1.$length ? ($throwRuntimeError("index out of range"), undefined) : x$1.$array[x$1.$offset + 0] = (x = contactSet.Center, (0 >= x.$length ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + 0])) / ((contactSet.Points.$length)))); + (x$3 = contactSet.Center, (1 >= x$3.$length ? ($throwRuntimeError("index out of range"), undefined) : x$3.$array[x$3.$offset + 1] = (x$2 = contactSet.Center, (1 >= x$2.$length ? ($throwRuntimeError("index out of range"), undefined) : x$2.$array[x$2.$offset + 1])) / ((contactSet.Points.$length)))); + } + circle.X = ox; + circle.Y = oy; + return contactSet; + }; + Circle.prototype.Intersection = function(dx, dy, other) { return this.$val.Intersection(dx, dy, other); }; + Circle.ptr.prototype.Move = function(x, y) { + var circle, x, y; + circle = this; + circle.X = circle.X + (x); + circle.Y = circle.Y + (y); + }; + Circle.prototype.Move = function(x, y) { return this.$val.Move(x, y); }; + Circle.ptr.prototype.MoveVec = function(vec) { + var circle, vec; + circle = this; + circle.X = circle.X + (vec.X()); + circle.Y = circle.Y + (vec.Y()); + }; + Circle.prototype.MoveVec = function(vec) { return this.$val.MoveVec(vec); }; + Circle.ptr.prototype.SetPosition = function(x, y) { + var circle, x, y; + circle = this; + circle.X = x; + circle.Y = y; + }; + Circle.prototype.SetPosition = function(x, y) { return this.$val.SetPosition(x, y); }; + Circle.ptr.prototype.SetPositionVec = function(vec) { + var circle, vec; + circle = this; + circle.X = vec.X(); + circle.Y = vec.Y(); + }; + Circle.prototype.SetPositionVec = function(vec) { return this.$val.SetPositionVec(vec); }; + Circle.ptr.prototype.Position = function() { + var circle; + circle = this; + return [circle.X, circle.Y]; + }; + Circle.prototype.Position = function() { return this.$val.Position(); }; + Circle.ptr.prototype.PointInside = function(point) { + var circle, point; + circle = this; + return point.Sub(new sliceType$4([new Vector([circle.X, circle.Y])])).Magnitude() <= circle.Radius; + }; + Circle.prototype.PointInside = function(point) { return this.$val.PointInside(point); }; + Circle.ptr.prototype.IntersectionPointsCircle = function(other) { + var a, circle, d, h, other, x2, y2; + circle = this; + d = math.Sqrt(math.Pow(other.X - circle.X, 2) + math.Pow(other.Y - circle.Y, 2)); + if (d > circle.Radius + other.Radius || d < math.Abs(circle.Radius - other.Radius) || (d === 0) && (circle.Radius === other.Radius)) { + return sliceType$4.nil; + } + a = (math.Pow(circle.Radius, 2) - math.Pow(other.Radius, 2) + math.Pow(d, 2)) / (2 * d); + h = math.Sqrt(math.Pow(circle.Radius, 2) - math.Pow(a, 2)); + x2 = circle.X + a * (other.X - circle.X) / d; + y2 = circle.Y + a * (other.Y - circle.Y) / d; + return new sliceType$4([new Vector([x2 + h * (other.Y - circle.Y) / d, y2 - h * (other.X - circle.X) / d]), new Vector([x2 - h * (other.Y - circle.Y) / d, y2 + h * (other.X - circle.X) / d])]); + }; + Circle.prototype.IntersectionPointsCircle = function(other) { return this.$val.IntersectionPointsCircle(other); }; + Projection.ptr.prototype.Overlapping = function(other) { + var other, projection; + projection = this; + return $clone(projection, Projection).Overlap($clone(other, Projection)) > 0; + }; + Projection.prototype.Overlapping = function(other) { return this.$val.Overlapping(other); }; + Projection.ptr.prototype.Overlap = function(other) { + var other, projection; + projection = this; + return math.Min(projection.Max, other.Max) - math.Max(projection.Min, other.Min); + }; + Projection.prototype.Overlap = function(other) { return this.$val.Overlap(other); }; + Projection.ptr.prototype.IsInside = function(other) { + var other, projection; + projection = this; + return projection.Min >= other.Min && projection.Max <= other.Max; + }; + Projection.prototype.IsInside = function(other) { return this.$val.IsInside(other); }; + NewRingBuffer = function(n) { + var n; + return new RingBuffer.ptr(0, 0, 0, 0, n, 0, $makeSlice(sliceType$6, n)); + }; + $pkg.NewRingBuffer = NewRingBuffer; + RingBuffer.ptr.prototype.Put = function(pItem) { + var pItem, rb, x, x$1; + rb = this; + while (true) { + if (!(0 < rb.Cnt && rb.Cnt >= rb.N)) { break; } + rb.Pop(); + } + (x = rb.Eles, x$1 = rb.Ed, ((x$1 < 0 || x$1 >= x.$length) ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + x$1] = pItem)); + rb.EdFrameId = rb.EdFrameId + (1) >> 0; + rb.Cnt = rb.Cnt + (1) >> 0; + rb.Ed = rb.Ed + (1) >> 0; + if (rb.Ed >= rb.N) { + rb.Ed = rb.Ed - (rb.N) >> 0; + } + }; + RingBuffer.prototype.Put = function(pItem) { return this.$val.Put(pItem); }; + RingBuffer.ptr.prototype.Pop = function() { + var pItem, rb, x, x$1; + rb = this; + if (0 === rb.Cnt) { + return $ifaceNil; + } + pItem = (x = rb.Eles, x$1 = rb.St, ((x$1 < 0 || x$1 >= x.$length) ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + x$1])); + rb.StFrameId = rb.StFrameId + (1) >> 0; + rb.Cnt = rb.Cnt - (1) >> 0; + rb.St = rb.St + (1) >> 0; + if (rb.St >= rb.N) { + rb.St = rb.St - (rb.N) >> 0; + } + return pItem; + }; + RingBuffer.prototype.Pop = function() { return this.$val.Pop(); }; + RingBuffer.ptr.prototype.GetArrIdxByOffset = function(offsetFromSt) { + var arrIdx, offsetFromSt, rb; + rb = this; + if ((0 === rb.Cnt) || 0 > offsetFromSt) { + return -1; + } + arrIdx = rb.St + offsetFromSt >> 0; + if (rb.St < rb.Ed) { + if (rb.St <= arrIdx && arrIdx < rb.Ed) { + return arrIdx; + } + } else { + if (arrIdx >= rb.N) { + arrIdx = arrIdx - (rb.N) >> 0; + } + if (arrIdx >= rb.St || arrIdx < rb.Ed) { + return arrIdx; + } + } + return -1; + }; + RingBuffer.prototype.GetArrIdxByOffset = function(offsetFromSt) { return this.$val.GetArrIdxByOffset(offsetFromSt); }; + RingBuffer.ptr.prototype.GetByOffset = function(offsetFromSt) { + var arrIdx, offsetFromSt, rb, x; + rb = this; + arrIdx = rb.GetArrIdxByOffset(offsetFromSt); + if (-1 === arrIdx) { + return $ifaceNil; + } + return (x = rb.Eles, ((arrIdx < 0 || arrIdx >= x.$length) ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + arrIdx])); + }; + RingBuffer.prototype.GetByOffset = function(offsetFromSt) { return this.$val.GetByOffset(offsetFromSt); }; + RingBuffer.ptr.prototype.GetByFrameId = function(frameId) { + var frameId, rb; + rb = this; + if (frameId >= rb.EdFrameId || frameId < rb.StFrameId) { + return $ifaceNil; + } + return rb.GetByOffset(frameId - rb.StFrameId >> 0); + }; + RingBuffer.prototype.GetByFrameId = function(frameId) { return this.$val.GetByFrameId(frameId); }; + RingBuffer.ptr.prototype.SetByFrameId = function(pItem, frameId) { + var _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, arrIdx, frameId, oldEdFrameId, oldStFrameId, pItem, rb, ret, x; + rb = this; + _tmp = rb.StFrameId; + _tmp$1 = rb.EdFrameId; + oldStFrameId = _tmp; + oldEdFrameId = _tmp$1; + if (frameId < oldStFrameId) { + return [2, oldStFrameId, oldEdFrameId]; + } + if (oldEdFrameId > frameId) { + arrIdx = rb.GetArrIdxByOffset(frameId - rb.StFrameId >> 0); + if (!((-1 === arrIdx))) { + (x = rb.Eles, ((arrIdx < 0 || arrIdx >= x.$length) ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + arrIdx] = pItem)); + return [0, oldStFrameId, oldEdFrameId]; + } + } + ret = 0; + if (oldEdFrameId < frameId) { + _tmp$2 = 0; + _tmp$3 = 0; + rb.St = _tmp$2; + rb.Ed = _tmp$3; + _tmp$4 = frameId; + _tmp$5 = frameId; + rb.StFrameId = _tmp$4; + rb.EdFrameId = _tmp$5; + rb.Cnt = 0; + ret = 1; + } + rb.Put(pItem); + return [ret, oldStFrameId, oldEdFrameId]; + }; + RingBuffer.prototype.SetByFrameId = function(pItem, frameId) { return this.$val.SetByFrameId(pItem, frameId); }; + RingBuffer.ptr.prototype.Clear = function() { + var rb; + rb = this; + while (true) { + if (!(0 < rb.Cnt)) { break; } + rb.Pop(); + } + rb.St = 0; + rb.Ed = 0; + rb.StFrameId = 0; + rb.EdFrameId = 0; + }; + RingBuffer.prototype.Clear = function() { return this.$val.Clear(); }; + RingBuffer.ptr.prototype.GetStFrameId = function() { + var rb; + rb = this; + return rb.StFrameId; + }; + RingBuffer.prototype.GetStFrameId = function() { return this.$val.GetStFrameId(); }; + RingBuffer.ptr.prototype.GetEdFrameId = function() { + var rb; + rb = this; + return rb.EdFrameId; + }; + RingBuffer.prototype.GetEdFrameId = function() { return this.$val.GetEdFrameId(); }; + RingBuffer.ptr.prototype.GetCnt = function() { + var rb; + rb = this; + return rb.Cnt; + }; + RingBuffer.prototype.GetCnt = function() { return this.$val.GetCnt(); }; + NewObjectSingleTag = function(x, y, w, h, tag) { + var h, o, tag, w, x, y; + o = new Object.ptr($ifaceNil, ptrType$1.nil, x, y, w, h, NewRingBuffer(512), $ifaceNil, $makeMap(ptrType$2.keyFor, []), new sliceType$7([tag])); + return o; + }; + $pkg.NewObjectSingleTag = NewObjectSingleTag; + NewObject = function(x, y, w, h, tags) { + var h, o, tags, w, x, y; + o = new Object.ptr($ifaceNil, ptrType$1.nil, x, y, w, h, NewRingBuffer(512), $ifaceNil, $makeMap(ptrType$2.keyFor, []), new sliceType$7([])); + if (tags.$length > 0) { + o.AddTags(tags); + } + return o; + }; + $pkg.NewObject = NewObject; + Object.ptr.prototype.GetData = function() { + var obj; + obj = this; + return obj.Data; + }; + Object.prototype.GetData = function() { return this.$val.GetData(); }; + Object.ptr.prototype.GetShape = function() { + var obj; + obj = this; + return (obj.$ptr_Shape || (obj.$ptr_Shape = new ptrType$8(function() { return this.$target.Shape; }, function($v) { this.$target.Shape = $v; }, obj))); + }; + Object.prototype.GetShape = function() { return this.$val.GetShape(); }; + Object.ptr.prototype.Position = function() { + var obj; + obj = this; + return [obj.X, obj.Y]; + }; + Object.prototype.Position = function() { return this.$val.Position(); }; + Object.ptr.prototype.Clone = function() { + var {_entry, _i, _keys, _r, _ref, k, newObj, obj, $s, $r, $c} = $restore(this, {}); + /* */ $s = $s || 0; s: while (true) { switch ($s) { case 0: + obj = this; + newObj = NewObject(obj.X, obj.Y, obj.W, obj.H, obj.Tags()); + newObj.Data = obj.Data; + /* */ if (!($interfaceIsEqual(obj.Shape, $ifaceNil))) { $s = 1; continue; } + /* */ $s = 2; continue; + /* if (!($interfaceIsEqual(obj.Shape, $ifaceNil))) { */ case 1: + _r = obj.Shape.Clone(); /* */ $s = 3; case 3: if($c) { $c = false; _r = _r.$blk(); } if (_r && _r.$blk !== undefined) { break s; } + $r = newObj.SetShape(_r); /* */ $s = 4; case 4: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; } + /* } */ case 2: + _ref = obj.ignoreList; + _i = 0; + _keys = $keys(_ref); + while (true) { + if (!(_i < _keys.length)) { break; } + _entry = _ref[_keys[_i]]; + if (_entry === undefined) { + _i++; + continue; + } + k = _entry.k; + newObj.AddToIgnoreList(k); + _i++; + } + $s = -1; return newObj; + /* */ } return; } var $f = {$blk: Object.ptr.prototype.Clone, $c: true, $r, _entry, _i, _keys, _r, _ref, k, newObj, obj, $s};return $f; + }; + Object.prototype.Clone = function() { return this.$val.Clone(); }; + Object.ptr.prototype.Update = function() { + var {_tuple, c, cx, cy, ex, ey, obj, space, x, y, $s, $r, $c} = $restore(this, {}); + /* */ $s = $s || 0; s: while (true) { switch ($s) { case 0: + obj = this; + if (!(obj.Space === ptrType$1.nil)) { + space = obj.Space; + obj.Space.RemoveSingle(obj); + obj.Space = space; + _tuple = obj.BoundsToSpace(0, 0); + cx = _tuple[0]; + cy = _tuple[1]; + ex = _tuple[2]; + ey = _tuple[3]; + y = cy; + while (true) { + if (!(y <= ey)) { break; } + x = cx; + while (true) { + if (!(x <= ex)) { break; } + c = obj.Space.Cell(x, y); + if (!(c === ptrType.nil)) { + c.register(obj); + obj.TouchingCells.Put(c); + } + x = x + (1) >> 0; + } + y = y + (1) >> 0; + } + } + /* */ if (!($interfaceIsEqual(obj.Shape, $ifaceNil))) { $s = 1; continue; } + /* */ $s = 2; continue; + /* if (!($interfaceIsEqual(obj.Shape, $ifaceNil))) { */ case 1: + $r = obj.Shape.SetPosition(obj.X, obj.Y); /* */ $s = 3; case 3: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; } + /* } */ case 2: + $s = -1; return; + /* */ } return; } var $f = {$blk: Object.ptr.prototype.Update, $c: true, $r, _tuple, c, cx, cy, ex, ey, obj, space, x, y, $s};return $f; + }; + Object.prototype.Update = function() { return this.$val.Update(); }; + Object.ptr.prototype.AddTags = function(tags) { + var obj, tags; + obj = this; + obj.tags = $appendSlice(obj.tags, tags); + }; + Object.prototype.AddTags = function(tags) { return this.$val.AddTags(tags); }; + Object.ptr.prototype.RemoveTags = function(tags) { + var _i, _i$1, _ref, _ref$1, i, obj, t, tag, tags; + obj = this; + _ref = tags; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + tag = ((_i < 0 || _i >= _ref.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref.$array[_ref.$offset + _i]); + _ref$1 = obj.tags; + _i$1 = 0; + while (true) { + if (!(_i$1 < _ref$1.$length)) { break; } + i = _i$1; + t = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref$1.$array[_ref$1.$offset + _i$1]); + if (t === tag) { + obj.tags = $appendSlice($subslice(obj.tags, 0, i), $subslice(obj.tags, (i + 1 >> 0))); + break; + } + _i$1++; + } + _i++; + } + }; + Object.prototype.RemoveTags = function(tags) { return this.$val.RemoveTags(tags); }; + Object.ptr.prototype.HasTags = function(tags) { + var _i, _i$1, _ref, _ref$1, obj, t, tag, tags; + obj = this; + _ref = tags; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + tag = ((_i < 0 || _i >= _ref.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref.$array[_ref.$offset + _i]); + _ref$1 = obj.tags; + _i$1 = 0; + while (true) { + if (!(_i$1 < _ref$1.$length)) { break; } + t = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref$1.$array[_ref$1.$offset + _i$1]); + if (t === tag) { + return true; + } + _i$1++; + } + _i++; + } + return false; + }; + Object.prototype.HasTags = function(tags) { return this.$val.HasTags(tags); }; + Object.ptr.prototype.Tags = function() { + var obj; + obj = this; + return $appendSlice(new sliceType$7([]), obj.tags); + }; + Object.prototype.Tags = function() { return this.$val.Tags(); }; + Object.ptr.prototype.SetShape = function(shape) { + var {obj, shape, $s, $r, $c} = $restore(this, {shape}); + /* */ $s = $s || 0; s: while (true) { switch ($s) { case 0: + obj = this; + /* */ if (!($interfaceIsEqual(obj.Shape, shape))) { $s = 1; continue; } + /* */ $s = 2; continue; + /* if (!($interfaceIsEqual(obj.Shape, shape))) { */ case 1: + obj.Shape = shape; + $r = obj.Update(); /* */ $s = 3; case 3: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; } + /* } */ case 2: + $s = -1; return; + /* */ } return; } var $f = {$blk: Object.ptr.prototype.SetShape, $c: true, $r, obj, shape, $s};return $f; + }; + Object.prototype.SetShape = function(shape) { return this.$val.SetShape(shape); }; + Object.ptr.prototype.BoundsToSpace = function(dx, dy) { + var _tuple, _tuple$1, cx, cy, dx, dy, ex, ey, obj; + obj = this; + _tuple = obj.Space.WorldToSpace(obj.X + dx, obj.Y + dy); + cx = _tuple[0]; + cy = _tuple[1]; + _tuple$1 = obj.Space.WorldToSpace(obj.X + obj.W + dx - 1, obj.Y + obj.H + dy - 1); + ex = _tuple$1[0]; + ey = _tuple$1[1]; + return [cx, cy, ex, ey]; + }; + Object.prototype.BoundsToSpace = function(dx, dy) { return this.$val.BoundsToSpace(dx, dy); }; + Object.ptr.prototype.SharesCells = function(other) { + var cell, i, obj, other, rb; + obj = this; + rb = obj.TouchingCells; + i = rb.StFrameId; + while (true) { + if (!(i < rb.EdFrameId)) { break; } + cell = $assertType(rb.GetByFrameId(i), ptrType); + if (cell.Contains(other)) { + return true; + } + i = i + (1) >> 0; + } + return false; + }; + Object.prototype.SharesCells = function(other) { return this.$val.SharesCells(other); }; + Object.ptr.prototype.SharesCellsTags = function(tags) { + var cell, i, obj, rb, tags; + obj = this; + rb = obj.TouchingCells; + i = rb.StFrameId; + while (true) { + if (!(i < rb.EdFrameId)) { break; } + cell = $assertType(rb.GetByFrameId(i), ptrType); + if (cell.ContainsTags(tags)) { + return true; + } + i = i + (1) >> 0; + } + return false; + }; + Object.prototype.SharesCellsTags = function(tags) { return this.$val.SharesCellsTags(tags); }; + Object.ptr.prototype.Center = function() { + var obj; + obj = this; + return [obj.X + (obj.W / 2), obj.Y + (obj.H / 2)]; + }; + Object.prototype.Center = function() { return this.$val.Center(); }; + Object.ptr.prototype.SetCenter = function(x, y) { + var obj, x, y; + obj = this; + obj.X = x - (obj.W / 2); + obj.Y = y - (obj.H / 2); + }; + Object.prototype.SetCenter = function(x, y) { return this.$val.SetCenter(x, y); }; + Object.ptr.prototype.CellPosition = function() { + var _tuple, obj; + obj = this; + _tuple = obj.Center(); + return obj.Space.WorldToSpace(_tuple[0], _tuple[1]); + }; + Object.prototype.CellPosition = function() { return this.$val.CellPosition(); }; + Object.ptr.prototype.SetRight = function(x) { + var obj, x; + obj = this; + obj.X = x - obj.W; + }; + Object.prototype.SetRight = function(x) { return this.$val.SetRight(x); }; + Object.ptr.prototype.SetBottom = function(y) { + var obj, y; + obj = this; + obj.Y = y - obj.H; + }; + Object.prototype.SetBottom = function(y) { return this.$val.SetBottom(y); }; + Object.ptr.prototype.Bottom = function() { + var obj; + obj = this; + return obj.Y + obj.H; + }; + Object.prototype.Bottom = function() { return this.$val.Bottom(); }; + Object.ptr.prototype.Right = function() { + var obj; + obj = this; + return obj.X + obj.W; + }; + Object.prototype.Right = function() { return this.$val.Right(); }; + Object.ptr.prototype.SetBounds = function(topLeft, bottomRight) { + var bottomRight, obj, topLeft; + obj = this; + obj.X = (0 >= topLeft.$length ? ($throwRuntimeError("index out of range"), undefined) : topLeft.$array[topLeft.$offset + 0]); + obj.Y = (1 >= topLeft.$length ? ($throwRuntimeError("index out of range"), undefined) : topLeft.$array[topLeft.$offset + 1]); + obj.W = (0 >= bottomRight.$length ? ($throwRuntimeError("index out of range"), undefined) : bottomRight.$array[bottomRight.$offset + 0]) - obj.X; + obj.H = (1 >= bottomRight.$length ? ($throwRuntimeError("index out of range"), undefined) : bottomRight.$array[bottomRight.$offset + 1]) - obj.Y; + }; + Object.prototype.SetBounds = function(topLeft, bottomRight) { return this.$val.SetBounds(topLeft, bottomRight); }; + Object.ptr.prototype.CheckAllWithHolder = function(dx, dy, cc) { + var _entry, _entry$1, _entry$2, _key, _key$1, _tuple, _tuple$1, _tuple$2, added, added$1, c, cc, cellsAdded, cx, cy, dx, dy, ex, ey, i, ignored, o, obj, objectsAdded, rb, x, y; + obj = this; + if (obj.Space === ptrType$1.nil) { + return false; + } + cc.checkingObject = obj; + if (dx < 0) { + dx = math.Min(dx, -1); + } else if (dx > 0) { + dx = math.Max(dx, 1); + } + if (dy < 0) { + dy = math.Min(dy, -1); + } else if (dy > 0) { + dy = math.Max(dy, 1); + } + cc.dx = dx; + cc.dy = dy; + _tuple = obj.BoundsToSpace(dx, dy); + cx = _tuple[0]; + cy = _tuple[1]; + ex = _tuple[2]; + ey = _tuple[3]; + objectsAdded = $makeMap(ptrType$2.keyFor, []); + cellsAdded = $makeMap(ptrType.keyFor, []); + y = cy; + while (true) { + if (!(y <= ey)) { break; } + x = cx; + while (true) { + if (!(x <= ex)) { break; } + c = obj.Space.Cell(x, y); + if (!(c === ptrType.nil)) { + rb = c.Objects; + i = rb.StFrameId; + while (true) { + if (!(i < rb.EdFrameId)) { break; } + o = $assertType(rb.GetByFrameId(i), ptrType$2); + ignored = (_entry = obj.ignoreList[ptrType$2.keyFor(o)], _entry !== undefined ? _entry.v : false); + if (o === obj || ignored) { + i = i + (1) >> 0; + continue; + } + _tuple$1 = (_entry$1 = objectsAdded[ptrType$2.keyFor(o)], _entry$1 !== undefined ? [_entry$1.v, true] : [false, false]); + added = _tuple$1[1]; + if (!added) { + cc.Objects.Put(o); + _key = o; (objectsAdded || $throwRuntimeError("assignment to entry in nil map"))[ptrType$2.keyFor(_key)] = { k: _key, v: true }; + _tuple$2 = (_entry$2 = cellsAdded[ptrType.keyFor(c)], _entry$2 !== undefined ? [_entry$2.v, true] : [false, false]); + added$1 = _tuple$2[1]; + if (!added$1) { + cc.Cells.Put(c); + _key$1 = c; (cellsAdded || $throwRuntimeError("assignment to entry in nil map"))[ptrType.keyFor(_key$1)] = { k: _key$1, v: true }; + } + i = i + (1) >> 0; + continue; + } + i = i + (1) >> 0; + } + } + x = x + (1) >> 0; + } + y = y + (1) >> 0; + } + if (0 >= cc.Objects.Cnt) { + return false; + } + return true; + }; + Object.prototype.CheckAllWithHolder = function(dx, dy, cc) { return this.$val.CheckAllWithHolder(dx, dy, cc); }; + Object.ptr.prototype.Overlaps = function(other) { + var obj, other; + obj = this; + return other.X <= obj.X + obj.W && other.X + other.W >= obj.X && other.Y <= obj.Y + obj.H && other.Y + other.H >= obj.Y; + }; + Object.prototype.Overlaps = function(other) { return this.$val.Overlaps(other); }; + Object.ptr.prototype.AddToIgnoreList = function(ignoreObj) { + var _key, ignoreObj, obj; + obj = this; + _key = ignoreObj; (obj.ignoreList || $throwRuntimeError("assignment to entry in nil map"))[ptrType$2.keyFor(_key)] = { k: _key, v: true }; + }; + Object.prototype.AddToIgnoreList = function(ignoreObj) { return this.$val.AddToIgnoreList(ignoreObj); }; + Object.ptr.prototype.RemoveFromIgnoreList = function(ignoreObj) { + var ignoreObj, obj; + obj = this; + delete obj.ignoreList[ptrType$2.keyFor(ignoreObj)]; + }; + Object.prototype.RemoveFromIgnoreList = function(ignoreObj) { return this.$val.RemoveFromIgnoreList(ignoreObj); }; + axpyUnitaryTo = function(dst, alpha, x, y) { + var _i, _ref, alpha, dim, dst, i, v, x, y; + dim = y.$length; + _ref = x; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + i = _i; + v = ((_i < 0 || _i >= _ref.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref.$array[_ref.$offset + _i]); + if (i === dim) { + return; + } + ((i < 0 || i >= dst.$length) ? ($throwRuntimeError("index out of range"), undefined) : dst.$array[dst.$offset + i] = alpha * v + ((i < 0 || i >= y.$length) ? ($throwRuntimeError("index out of range"), undefined) : y.$array[y.$offset + i])); + _i++; + } + }; + scalUnitaryTo = function(dst, alpha, x) { + var _i, _ref, alpha, dst, i, x; + _ref = x; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + i = _i; + ((i < 0 || i >= dst.$length) ? ($throwRuntimeError("index out of range"), undefined) : dst.$array[dst.$offset + i] = ((i < 0 || i >= dst.$length) ? ($throwRuntimeError("index out of range"), undefined) : dst.$array[dst.$offset + i]) * (alpha)); + _i++; + } + }; + NewCollision = function() { + return new Collision.ptr(ptrType$2.nil, 0, 0, NewRingBuffer(16), NewRingBuffer(16)); + }; + $pkg.NewCollision = NewCollision; + Collision.ptr.prototype.Clear = function() { + var cc; + cc = this; + cc.checkingObject = ptrType$2.nil; + cc.dx = 0; + cc.dy = 0; + cc.Objects.Clear(); + cc.Cells.Clear(); + }; + Collision.prototype.Clear = function() { return this.$val.Clear(); }; + Collision.ptr.prototype.FirstCollidedObject = function() { + var cc; + cc = this; + if (0 >= cc.Objects.Cnt) { + return ptrType$2.nil; + } + return $assertType(cc.Objects.Pop(), ptrType$2); + }; + Collision.prototype.FirstCollidedObject = function() { return this.$val.FirstCollidedObject(); }; + Collision.ptr.prototype.HasTags = function(tags) { + var cc, i, o, rb, tags; + cc = this; + rb = cc.Objects; + i = rb.StFrameId; + while (true) { + if (!(i < rb.EdFrameId)) { break; } + o = $assertType(rb.GetByFrameId(i), ptrType$2); + if (o === cc.checkingObject) { + i = i + (1) >> 0; + continue; + } + if (o.HasTags(tags)) { + return true; + } + i = i + (1) >> 0; + } + return false; + }; + Collision.prototype.HasTags = function(tags) { return this.$val.HasTags(tags); }; + Collision.ptr.prototype.ObjectsByTags = function(tags) { + var cc, i, o, objects, rb, tags; + cc = this; + objects = new sliceType$3([]); + rb = cc.Objects; + i = rb.StFrameId; + while (true) { + if (!(i < rb.EdFrameId)) { break; } + o = $assertType(rb.GetByFrameId(i), ptrType$2); + if (o === cc.checkingObject) { + i = i + (1) >> 0; + continue; + } + if (o.HasTags(tags)) { + objects = $append(objects, o); + } + i = i + (1) >> 0; + } + return objects; + }; + Collision.prototype.ObjectsByTags = function(tags) { return this.$val.ObjectsByTags(tags); }; + Collision.ptr.prototype.ContactWithObject = function(object) { + var cc, delta, object; + cc = this; + delta = new Vector([0, 0]); + if (cc.dx < 0) { + (0 >= delta.$length ? ($throwRuntimeError("index out of range"), undefined) : delta.$array[delta.$offset + 0] = object.X + object.W - cc.checkingObject.X); + } else if (cc.dx > 0) { + (0 >= delta.$length ? ($throwRuntimeError("index out of range"), undefined) : delta.$array[delta.$offset + 0] = object.X - cc.checkingObject.W - cc.checkingObject.X); + } + if (cc.dy < 0) { + (1 >= delta.$length ? ($throwRuntimeError("index out of range"), undefined) : delta.$array[delta.$offset + 1] = object.Y + object.H - cc.checkingObject.Y); + } else if (cc.dy > 0) { + (1 >= delta.$length ? ($throwRuntimeError("index out of range"), undefined) : delta.$array[delta.$offset + 1] = object.Y - cc.checkingObject.H - cc.checkingObject.Y); + } + return delta; + }; + Collision.prototype.ContactWithObject = function(object) { return this.$val.ContactWithObject(object); }; + Collision.ptr.prototype.ContactWithCell = function(cell) { + var cc, cell, cx, cy, delta; + cc = this; + delta = new Vector([0, 0]); + cx = (($imul(cell.X, cc.checkingObject.Space.CellWidth))); + cy = (($imul(cell.Y, cc.checkingObject.Space.CellHeight))); + if (cc.dx < 0) { + (0 >= delta.$length ? ($throwRuntimeError("index out of range"), undefined) : delta.$array[delta.$offset + 0] = cx + (cc.checkingObject.Space.CellWidth) - cc.checkingObject.X); + } else if (cc.dx > 0) { + (0 >= delta.$length ? ($throwRuntimeError("index out of range"), undefined) : delta.$array[delta.$offset + 0] = cx - cc.checkingObject.W - cc.checkingObject.X); + } + if (cc.dy < 0) { + (1 >= delta.$length ? ($throwRuntimeError("index out of range"), undefined) : delta.$array[delta.$offset + 1] = cy + (cc.checkingObject.Space.CellHeight) - cc.checkingObject.Y); + } else if (cc.dy > 0) { + (1 >= delta.$length ? ($throwRuntimeError("index out of range"), undefined) : delta.$array[delta.$offset + 1] = cy - cc.checkingObject.H - cc.checkingObject.Y); + } + return delta; + }; + Collision.prototype.ContactWithCell = function(cell) { return this.$val.ContactWithCell(cell); }; + Collision.ptr.prototype.SlideAgainstCell = function(cell, avoidTags) { + var _tuple, _tuple$1, avoidTags, cc, ccX, ccY, cell, collidingCell, diffX, diffY, down, hX, hY, left, oX, oY, right, slide, sp, up; + cc = this; + sp = cc.checkingObject.Space; + collidingCell = $assertType(cc.Cells.GetByFrameId(cc.Cells.StFrameId), ptrType); + _tuple = sp.SpaceToWorld(collidingCell.X, collidingCell.Y); + ccX = _tuple[0]; + ccY = _tuple[1]; + hX = (sp.CellWidth) / 2; + hY = (sp.CellHeight) / 2; + ccX = ccX + (hX); + ccY = ccY + (hY); + _tuple$1 = cc.checkingObject.Center(); + oX = _tuple$1[0]; + oY = _tuple$1[1]; + diffX = oX - ccX; + diffY = oY - ccY; + left = sp.Cell(collidingCell.X - 1 >> 0, collidingCell.Y); + right = sp.Cell(collidingCell.X + 1 >> 0, collidingCell.Y); + up = sp.Cell(collidingCell.X, collidingCell.Y - 1 >> 0); + down = sp.Cell(collidingCell.X, collidingCell.Y + 1 >> 0); + slide = new Vector([0, 0]); + if (!((cc.dy === 0))) { + if (diffX > 0 && (right === ptrType.nil || !right.ContainsTags(avoidTags))) { + (0 >= slide.$length ? ($throwRuntimeError("index out of range"), undefined) : slide.$array[slide.$offset + 0] = ccX + hX - cc.checkingObject.X); + } else if (diffX < 0 && (left === ptrType.nil || !left.ContainsTags(avoidTags))) { + (0 >= slide.$length ? ($throwRuntimeError("index out of range"), undefined) : slide.$array[slide.$offset + 0] = ccX - hX - (cc.checkingObject.X + cc.checkingObject.W)); + } else { + return Vector.nil; + } + } + if (!((cc.dx === 0))) { + if (diffY > 0 && (down === ptrType.nil || !down.ContainsTags(avoidTags))) { + (1 >= slide.$length ? ($throwRuntimeError("index out of range"), undefined) : slide.$array[slide.$offset + 1] = ccY + hY - cc.checkingObject.Y); + } else if (diffY < 0 && (up === ptrType.nil || !up.ContainsTags(avoidTags))) { + (1 >= slide.$length ? ($throwRuntimeError("index out of range"), undefined) : slide.$array[slide.$offset + 1] = ccY - hY - (cc.checkingObject.Y + cc.checkingObject.H)); + } else { + return Vector.nil; + } + } + return slide; + }; + Collision.prototype.SlideAgainstCell = function(cell, avoidTags) { return this.$val.SlideAgainstCell(cell, avoidTags); }; + newCell = function(x, y) { + var x, y; + return new Cell.ptr(x, y, NewRingBuffer(16)); + }; + Cell.ptr.prototype.register = function(obj) { + var cell, obj; + cell = this; + if (!cell.Contains(obj)) { + cell.Objects.Put(obj); + } + }; + Cell.prototype.register = function(obj) { return this.$val.register(obj); }; + Cell.ptr.prototype.unregister = function(obj) { + var cell, i, o, obj, rb; + cell = this; + rb = cell.Objects; + i = rb.StFrameId; + while (true) { + if (!(i < rb.EdFrameId)) { break; } + o = $assertType(rb.GetByFrameId(i), ptrType$2); + if (o === obj) { + rb.SetByFrameId(rb.GetByFrameId(rb.StFrameId), i); + rb.Pop(); + break; + } + i = i + (1) >> 0; + } + }; + Cell.prototype.unregister = function(obj) { return this.$val.unregister(obj); }; + Cell.ptr.prototype.Contains = function(obj) { + var cell, i, o, obj, rb; + cell = this; + rb = cell.Objects; + i = rb.StFrameId; + while (true) { + if (!(i < rb.EdFrameId)) { break; } + o = $assertType(rb.GetByFrameId(i), ptrType$2); + if (o === obj) { + return true; + } + i = i + (1) >> 0; + } + return false; + }; + Cell.prototype.Contains = function(obj) { return this.$val.Contains(obj); }; + Cell.ptr.prototype.ContainsTags = function(tags) { + var cell, i, o, rb, tags; + cell = this; + rb = cell.Objects; + i = rb.StFrameId; + while (true) { + if (!(i < rb.EdFrameId)) { break; } + o = $assertType(rb.GetByFrameId(i), ptrType$2); + if (o.HasTags(tags)) { + return true; + } + i = i + (1) >> 0; + } + return false; + }; + Cell.prototype.ContainsTags = function(tags) { return this.$val.ContainsTags(tags); }; + Cell.ptr.prototype.Occupied = function() { + var cell; + cell = this; + return 0 < cell.Objects.Cnt; + }; + Cell.prototype.Occupied = function() { return this.$val.Occupied(); }; + Vector.methods = [{prop: "Clone", name: "Clone", pkg: "", typ: $funcType([], [Vector], false)}, {prop: "Add", name: "Add", pkg: "", typ: $funcType([sliceType$4], [Vector], true)}, {prop: "Sub", name: "Sub", pkg: "", typ: $funcType([sliceType$4], [Vector], true)}, {prop: "Scale", name: "Scale", pkg: "", typ: $funcType([$Float64], [Vector], false)}, {prop: "Equal", name: "Equal", pkg: "", typ: $funcType([Vector], [$Bool], false)}, {prop: "Magnitude", name: "Magnitude", pkg: "", typ: $funcType([], [$Float64], false)}, {prop: "Magnitude2", name: "Magnitude2", pkg: "", typ: $funcType([], [$Float64], false)}, {prop: "Unit", name: "Unit", pkg: "", typ: $funcType([], [Vector], false)}, {prop: "Dot", name: "Dot", pkg: "", typ: $funcType([Vector], [$Float64], false)}, {prop: "Cross", name: "Cross", pkg: "", typ: $funcType([Vector], [Vector], false)}, {prop: "Rotate", name: "Rotate", pkg: "", typ: $funcType([$Float64, sliceType$8], [Vector], true)}, {prop: "X", name: "X", pkg: "", typ: $funcType([], [$Float64], false)}, {prop: "Y", name: "Y", pkg: "", typ: $funcType([], [$Float64], false)}, {prop: "Z", name: "Z", pkg: "", typ: $funcType([], [$Float64], false)}]; + ptrType$1.methods = [{prop: "AddSingle", name: "AddSingle", pkg: "", typ: $funcType([ptrType$2], [], false)}, {prop: "Add", name: "Add", pkg: "", typ: $funcType([sliceType$3], [], true)}, {prop: "RemoveSingle", name: "RemoveSingle", pkg: "", typ: $funcType([ptrType$2], [], false)}, {prop: "Remove", name: "Remove", pkg: "", typ: $funcType([sliceType$3], [], true)}, {prop: "Objects", name: "Objects", pkg: "", typ: $funcType([], [sliceType$3], false)}, {prop: "Resize", name: "Resize", pkg: "", typ: $funcType([$Int, $Int], [], false)}, {prop: "Cell", name: "Cell", pkg: "", typ: $funcType([$Int, $Int], [ptrType], false)}, {prop: "CheckCells", name: "CheckCells", pkg: "", typ: $funcType([$Int, $Int, $Int, $Int, sliceType$7], [ptrType$2], true)}, {prop: "CheckCellsWorld", name: "CheckCellsWorld", pkg: "", typ: $funcType([$Float64, $Float64, $Float64, $Float64, sliceType$7], [ptrType$2], true)}, {prop: "UnregisterAllObjects", name: "UnregisterAllObjects", pkg: "", typ: $funcType([], [], false)}, {prop: "WorldToSpace", name: "WorldToSpace", pkg: "", typ: $funcType([$Float64, $Float64], [$Int, $Int], false)}, {prop: "SpaceToWorld", name: "SpaceToWorld", pkg: "", typ: $funcType([$Int, $Int], [$Float64, $Float64], false)}, {prop: "Height", name: "Height", pkg: "", typ: $funcType([], [$Int], false)}, {prop: "Width", name: "Width", pkg: "", typ: $funcType([], [$Int], false)}, {prop: "CellsInLine", name: "CellsInLine", pkg: "", typ: $funcType([$Int, $Int, $Int, $Int], [sliceType$1], false)}]; + ptrType$3.methods = [{prop: "Project", name: "Project", pkg: "", typ: $funcType([Vector], [Vector], false)}, {prop: "Normal", name: "Normal", pkg: "", typ: $funcType([], [Vector], false)}, {prop: "Vector", name: "Vector", pkg: "", typ: $funcType([], [Vector], false)}, {prop: "IntersectionPointsLine", name: "IntersectionPointsLine", pkg: "", typ: $funcType([ptrType$3], [Vector], false)}, {prop: "IntersectionPointsCircle", name: "IntersectionPointsCircle", pkg: "", typ: $funcType([ptrType$4], [sliceType$4], false)}]; + ptrType$5.methods = [{prop: "Clone", name: "Clone", pkg: "", typ: $funcType([], [Shape], false)}, {prop: "AddPointsVec", name: "AddPointsVec", pkg: "", typ: $funcType([sliceType$4], [], true)}, {prop: "AddPoints", name: "AddPoints", pkg: "", typ: $funcType([sliceType], [], true)}, {prop: "Lines", name: "Lines", pkg: "", typ: $funcType([], [sliceType$5], false)}, {prop: "Transformed", name: "Transformed", pkg: "", typ: $funcType([], [sliceType$4], false)}, {prop: "Bounds", name: "Bounds", pkg: "", typ: $funcType([], [Vector, Vector], false)}, {prop: "Position", name: "Position", pkg: "", typ: $funcType([], [$Float64, $Float64], false)}, {prop: "SetPosition", name: "SetPosition", pkg: "", typ: $funcType([$Float64, $Float64], [], false)}, {prop: "SetPositionVec", name: "SetPositionVec", pkg: "", typ: $funcType([Vector], [], false)}, {prop: "Move", name: "Move", pkg: "", typ: $funcType([$Float64, $Float64], [], false)}, {prop: "MoveVec", name: "MoveVec", pkg: "", typ: $funcType([Vector], [], false)}, {prop: "Center", name: "Center", pkg: "", typ: $funcType([], [Vector], false)}, {prop: "Project", name: "Project", pkg: "", typ: $funcType([Vector], [Projection], false)}, {prop: "SATAxes", name: "SATAxes", pkg: "", typ: $funcType([], [sliceType$4], false)}, {prop: "PointInside", name: "PointInside", pkg: "", typ: $funcType([Vector], [$Bool], false)}, {prop: "GetPoints", name: "GetPoints", pkg: "", typ: $funcType([], [sliceType$4], false)}, {prop: "Intersection", name: "Intersection", pkg: "", typ: $funcType([$Float64, $Float64, Shape], [ptrType$6], false)}, {prop: "calculateMTV", name: "calculateMTV", pkg: "resolv", typ: $funcType([ptrType$6, Shape], [Vector], false)}, {prop: "ContainedBy", name: "ContainedBy", pkg: "", typ: $funcType([Shape], [$Bool], false)}, {prop: "FlipH", name: "FlipH", pkg: "", typ: $funcType([], [], false)}, {prop: "FlipV", name: "FlipV", pkg: "", typ: $funcType([], [], false)}, {prop: "ReverseVertexOrder", name: "ReverseVertexOrder", pkg: "", typ: $funcType([], [], false)}]; + ptrType$6.methods = [{prop: "LeftmostPoint", name: "LeftmostPoint", pkg: "", typ: $funcType([], [Vector], false)}, {prop: "RightmostPoint", name: "RightmostPoint", pkg: "", typ: $funcType([], [Vector], false)}, {prop: "TopmostPoint", name: "TopmostPoint", pkg: "", typ: $funcType([], [Vector], false)}, {prop: "BottommostPoint", name: "BottommostPoint", pkg: "", typ: $funcType([], [Vector], false)}]; + ptrType$4.methods = [{prop: "Clone", name: "Clone", pkg: "", typ: $funcType([], [Shape], false)}, {prop: "Bounds", name: "Bounds", pkg: "", typ: $funcType([], [Vector, Vector], false)}, {prop: "Intersection", name: "Intersection", pkg: "", typ: $funcType([$Float64, $Float64, Shape], [ptrType$6], false)}, {prop: "Move", name: "Move", pkg: "", typ: $funcType([$Float64, $Float64], [], false)}, {prop: "MoveVec", name: "MoveVec", pkg: "", typ: $funcType([Vector], [], false)}, {prop: "SetPosition", name: "SetPosition", pkg: "", typ: $funcType([$Float64, $Float64], [], false)}, {prop: "SetPositionVec", name: "SetPositionVec", pkg: "", typ: $funcType([Vector], [], false)}, {prop: "Position", name: "Position", pkg: "", typ: $funcType([], [$Float64, $Float64], false)}, {prop: "PointInside", name: "PointInside", pkg: "", typ: $funcType([Vector], [$Bool], false)}, {prop: "IntersectionPointsCircle", name: "IntersectionPointsCircle", pkg: "", typ: $funcType([ptrType$4], [sliceType$4], false)}]; + Projection.methods = [{prop: "Overlapping", name: "Overlapping", pkg: "", typ: $funcType([Projection], [$Bool], false)}, {prop: "Overlap", name: "Overlap", pkg: "", typ: $funcType([Projection], [$Float64], false)}, {prop: "IsInside", name: "IsInside", pkg: "", typ: $funcType([Projection], [$Bool], false)}]; + ptrType$7.methods = [{prop: "Put", name: "Put", pkg: "", typ: $funcType([$emptyInterface], [], false)}, {prop: "Pop", name: "Pop", pkg: "", typ: $funcType([], [$emptyInterface], false)}, {prop: "GetArrIdxByOffset", name: "GetArrIdxByOffset", pkg: "", typ: $funcType([$Int32], [$Int32], false)}, {prop: "GetByOffset", name: "GetByOffset", pkg: "", typ: $funcType([$Int32], [$emptyInterface], false)}, {prop: "GetByFrameId", name: "GetByFrameId", pkg: "", typ: $funcType([$Int32], [$emptyInterface], false)}, {prop: "SetByFrameId", name: "SetByFrameId", pkg: "", typ: $funcType([$emptyInterface, $Int32], [$Int32, $Int32, $Int32], false)}, {prop: "Clear", name: "Clear", pkg: "", typ: $funcType([], [], false)}, {prop: "GetStFrameId", name: "GetStFrameId", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetEdFrameId", name: "GetEdFrameId", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetCnt", name: "GetCnt", pkg: "", typ: $funcType([], [$Int32], false)}]; + ptrType$2.methods = [{prop: "GetData", name: "GetData", pkg: "", typ: $funcType([], [$emptyInterface], false)}, {prop: "GetShape", name: "GetShape", pkg: "", typ: $funcType([], [ptrType$8], false)}, {prop: "Position", name: "Position", pkg: "", typ: $funcType([], [$Float64, $Float64], false)}, {prop: "Clone", name: "Clone", pkg: "", typ: $funcType([], [ptrType$2], false)}, {prop: "Update", name: "Update", pkg: "", typ: $funcType([], [], false)}, {prop: "AddTags", name: "AddTags", pkg: "", typ: $funcType([sliceType$7], [], true)}, {prop: "RemoveTags", name: "RemoveTags", pkg: "", typ: $funcType([sliceType$7], [], true)}, {prop: "HasTags", name: "HasTags", pkg: "", typ: $funcType([sliceType$7], [$Bool], true)}, {prop: "Tags", name: "Tags", pkg: "", typ: $funcType([], [sliceType$7], false)}, {prop: "SetShape", name: "SetShape", pkg: "", typ: $funcType([Shape], [], false)}, {prop: "BoundsToSpace", name: "BoundsToSpace", pkg: "", typ: $funcType([$Float64, $Float64], [$Int, $Int, $Int, $Int], false)}, {prop: "SharesCells", name: "SharesCells", pkg: "", typ: $funcType([ptrType$2], [$Bool], false)}, {prop: "SharesCellsTags", name: "SharesCellsTags", pkg: "", typ: $funcType([sliceType$7], [$Bool], true)}, {prop: "Center", name: "Center", pkg: "", typ: $funcType([], [$Float64, $Float64], false)}, {prop: "SetCenter", name: "SetCenter", pkg: "", typ: $funcType([$Float64, $Float64], [], false)}, {prop: "CellPosition", name: "CellPosition", pkg: "", typ: $funcType([], [$Int, $Int], false)}, {prop: "SetRight", name: "SetRight", pkg: "", typ: $funcType([$Float64], [], false)}, {prop: "SetBottom", name: "SetBottom", pkg: "", typ: $funcType([$Float64], [], false)}, {prop: "Bottom", name: "Bottom", pkg: "", typ: $funcType([], [$Float64], false)}, {prop: "Right", name: "Right", pkg: "", typ: $funcType([], [$Float64], false)}, {prop: "SetBounds", name: "SetBounds", pkg: "", typ: $funcType([Vector, Vector], [], false)}, {prop: "CheckAllWithHolder", name: "CheckAllWithHolder", pkg: "", typ: $funcType([$Float64, $Float64, ptrType$9], [$Bool], false)}, {prop: "Overlaps", name: "Overlaps", pkg: "", typ: $funcType([ptrType$2], [$Bool], false)}, {prop: "AddToIgnoreList", name: "AddToIgnoreList", pkg: "", typ: $funcType([ptrType$2], [], false)}, {prop: "RemoveFromIgnoreList", name: "RemoveFromIgnoreList", pkg: "", typ: $funcType([ptrType$2], [], false)}]; + ptrType$9.methods = [{prop: "Clear", name: "Clear", pkg: "", typ: $funcType([], [], false)}, {prop: "FirstCollidedObject", name: "FirstCollidedObject", pkg: "", typ: $funcType([], [ptrType$2], false)}, {prop: "HasTags", name: "HasTags", pkg: "", typ: $funcType([sliceType$7], [$Bool], true)}, {prop: "ObjectsByTags", name: "ObjectsByTags", pkg: "", typ: $funcType([sliceType$7], [sliceType$3], true)}, {prop: "ContactWithObject", name: "ContactWithObject", pkg: "", typ: $funcType([ptrType$2], [Vector], false)}, {prop: "ContactWithCell", name: "ContactWithCell", pkg: "", typ: $funcType([ptrType], [Vector], false)}, {prop: "SlideAgainstCell", name: "SlideAgainstCell", pkg: "", typ: $funcType([ptrType, sliceType$7], [Vector], true)}]; + ptrType.methods = [{prop: "register", name: "register", pkg: "resolv", typ: $funcType([ptrType$2], [], false)}, {prop: "unregister", name: "unregister", pkg: "resolv", typ: $funcType([ptrType$2], [], false)}, {prop: "Contains", name: "Contains", pkg: "", typ: $funcType([ptrType$2], [$Bool], false)}, {prop: "ContainsTags", name: "ContainsTags", pkg: "", typ: $funcType([sliceType$7], [$Bool], true)}, {prop: "Occupied", name: "Occupied", pkg: "", typ: $funcType([], [$Bool], false)}]; + Vector.init($Float64); + Space.init("", [{prop: "Cells", name: "Cells", embedded: false, exported: true, typ: sliceType$2, tag: ""}, {prop: "CellWidth", name: "CellWidth", embedded: false, exported: true, typ: $Int, tag: ""}, {prop: "CellHeight", name: "CellHeight", embedded: false, exported: true, typ: $Int, tag: ""}]); + Shape.init([{prop: "Bounds", name: "Bounds", pkg: "", typ: $funcType([], [Vector, Vector], false)}, {prop: "Clone", name: "Clone", pkg: "", typ: $funcType([], [Shape], false)}, {prop: "Intersection", name: "Intersection", pkg: "", typ: $funcType([$Float64, $Float64, Shape], [ptrType$6], false)}, {prop: "Position", name: "Position", pkg: "", typ: $funcType([], [$Float64, $Float64], false)}, {prop: "SetPosition", name: "SetPosition", pkg: "", typ: $funcType([$Float64, $Float64], [], false)}]); + Line.init("", [{prop: "Start", name: "Start", embedded: false, exported: true, typ: Vector, tag: ""}, {prop: "End", name: "End", embedded: false, exported: true, typ: Vector, tag: ""}]); + ConvexPolygon.init("", [{prop: "Points", name: "Points", embedded: false, exported: true, typ: sliceType$4, tag: ""}, {prop: "X", name: "X", embedded: false, exported: true, typ: $Float64, tag: ""}, {prop: "Y", name: "Y", embedded: false, exported: true, typ: $Float64, tag: ""}, {prop: "Closed", name: "Closed", embedded: false, exported: true, typ: $Bool, tag: ""}]); + ContactSet.init("", [{prop: "Points", name: "Points", embedded: false, exported: true, typ: sliceType$4, tag: ""}, {prop: "MTV", name: "MTV", embedded: false, exported: true, typ: Vector, tag: ""}, {prop: "Center", name: "Center", embedded: false, exported: true, typ: Vector, tag: ""}]); + Circle.init("", [{prop: "X", name: "X", embedded: false, exported: true, typ: $Float64, tag: ""}, {prop: "Y", name: "Y", embedded: false, exported: true, typ: $Float64, tag: ""}, {prop: "Radius", name: "Radius", embedded: false, exported: true, typ: $Float64, tag: ""}]); + Projection.init("", [{prop: "Min", name: "Min", embedded: false, exported: true, typ: $Float64, tag: ""}, {prop: "Max", name: "Max", embedded: false, exported: true, typ: $Float64, tag: ""}]); + RingBuffer.init("", [{prop: "Ed", name: "Ed", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "St", name: "St", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "EdFrameId", name: "EdFrameId", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "StFrameId", name: "StFrameId", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "N", name: "N", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "Cnt", name: "Cnt", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "Eles", name: "Eles", embedded: false, exported: true, typ: sliceType$6, tag: ""}]); + Object.init("resolv", [{prop: "Shape", name: "Shape", embedded: false, exported: true, typ: Shape, tag: ""}, {prop: "Space", name: "Space", embedded: false, exported: true, typ: ptrType$1, tag: ""}, {prop: "X", name: "X", embedded: false, exported: true, typ: $Float64, tag: ""}, {prop: "Y", name: "Y", embedded: false, exported: true, typ: $Float64, tag: ""}, {prop: "W", name: "W", embedded: false, exported: true, typ: $Float64, tag: ""}, {prop: "H", name: "H", embedded: false, exported: true, typ: $Float64, tag: ""}, {prop: "TouchingCells", name: "TouchingCells", embedded: false, exported: true, typ: ptrType$7, tag: ""}, {prop: "Data", name: "Data", embedded: false, exported: true, typ: $emptyInterface, tag: ""}, {prop: "ignoreList", name: "ignoreList", embedded: false, exported: false, typ: mapType, tag: ""}, {prop: "tags", name: "tags", embedded: false, exported: false, typ: sliceType$7, tag: ""}]); + Collision.init("resolv", [{prop: "checkingObject", name: "checkingObject", embedded: false, exported: false, typ: ptrType$2, tag: ""}, {prop: "dx", name: "dx", embedded: false, exported: false, typ: $Float64, tag: ""}, {prop: "dy", name: "dy", embedded: false, exported: false, typ: $Float64, tag: ""}, {prop: "Objects", name: "Objects", embedded: false, exported: true, typ: ptrType$7, tag: ""}, {prop: "Cells", name: "Cells", embedded: false, exported: true, typ: ptrType$7, tag: ""}]); + Cell.init("", [{prop: "X", name: "X", embedded: false, exported: true, typ: $Int, tag: ""}, {prop: "Y", name: "Y", embedded: false, exported: true, typ: $Int, tag: ""}, {prop: "Objects", name: "Objects", embedded: false, exported: true, typ: ptrType$7, tag: ""}]); + $init = function() { + $pkg.$init = function() {}; + /* */ var $f, $c = false, $s = 0, $r; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0: + $r = math.$init(); /* */ $s = 1; case 1: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; } + /* */ } return; } if ($f === undefined) { $f = { $blk: $init }; } $f.$s = $s; $f.$r = $r; return $f; + }; + $pkg.$init = $init; + return $pkg; +})(); +$packages["jsexport/battle"] = (function() { + var $pkg = {}, $init, math, resolv, Vec2D, Polygon2D, PlayerDownsync, InputFrameDecoded, Barrier, BulletConfig, BulletBattleAttr, MeleeBullet, FireballBullet, Skill, RoomDownsyncFrame, InputFrameDownsync, NpcPatrolCue, SkillMapperType, CharacterConfig, SatResult, sliceType, sliceType$1, sliceType$2, ptrType, ptrType$1, ptrType$2, ptrType$3, ptrType$4, ptrType$5, ptrType$6, ptrType$7, ptrType$8, ptrType$9, ptrType$10, sliceType$3, sliceType$4, sliceType$5, sliceType$6, sliceType$7, sliceType$8, sliceType$9, sliceType$10, ptrType$11, sliceType$11, sliceType$12, ptrType$12, sliceType$13, ptrType$13, mapType, ptrType$15, skills, inAirSet, noOpSet, invinsibleSet, nonAttackingSet, intAbs, ShouldGenerateInputFrameUpsync, ConvertToDelayedInputFrameId, ConvertToNoDelayInputFrameId, ConvertToFirstUsedRenderFrameId, ConvertToLastUsedRenderFrameId, decodeInput, calcPushbacks, isPolygonPairOverlapped, IsGeneralBulletActive, IsMeleeBulletActive, IsMeleeBulletAlive, IsFireballBulletActive, IsFireballBulletAlive, isPolygonPairSeparatedByDir, WorldToVirtualGridPos, VirtualGridToWorldPos, WorldToPolygonColliderBLPos, PolygonColliderBLToWorldPos, PolygonColliderBLToVirtualGridPos, calcHardPushbacksNorms, deriveOpPattern, ApplyInputFrameDownsyncDynamicsOnSingleRenderFrame, GenerateRectCollider, generateRectColliderInCollisionSpace, GenerateConvexPolygonCollider, AlignPolygon2DToBoundingBox, NewMeleeBullet, NewFireballBullet, NewPlayerDownsync; + math = $packages["math"]; + resolv = $packages["resolv"]; + Vec2D = $pkg.Vec2D = $newType(0, $kindStruct, "battle.Vec2D", true, "jsexport/battle", true, function(X_, Y_) { + this.$val = this; + if (arguments.length === 0) { + this.X = 0; + this.Y = 0; + return; + } + this.X = X_; + this.Y = Y_; + }); + Polygon2D = $pkg.Polygon2D = $newType(0, $kindStruct, "battle.Polygon2D", true, "jsexport/battle", true, function(Anchor_, Points_) { + this.$val = this; + if (arguments.length === 0) { + this.Anchor = ptrType$12.nil; + this.Points = sliceType$13.nil; + return; + } + this.Anchor = Anchor_; + this.Points = Points_; + }); + PlayerDownsync = $pkg.PlayerDownsync = $newType(0, $kindStruct, "battle.PlayerDownsync", true, "jsexport/battle", true, function(Id_, VirtualGridX_, VirtualGridY_, DirX_, DirY_, VelX_, VelY_, Speed_, BattleState_, JoinIndex_, ColliderRadius_, Removed_, Score_, LastMoveGmtMillis_, FramesToRecover_, FramesInChState_, Hp_, MaxHp_, CharacterState_, InAir_, OnWall_, OnWallNormX_, OnWallNormY_, CapturedByInertia_, ActiveSkillId_, ActiveSkillHit_, FramesInvinsible_, BulletTeamId_, ChCollisionTeamId_, RevivalVirtualGridX_, RevivalVirtualGridY_) { + this.$val = this; + if (arguments.length === 0) { + this.Id = 0; + this.VirtualGridX = 0; + this.VirtualGridY = 0; + this.DirX = 0; + this.DirY = 0; + this.VelX = 0; + this.VelY = 0; + this.Speed = 0; + this.BattleState = 0; + this.JoinIndex = 0; + this.ColliderRadius = 0; + this.Removed = false; + this.Score = 0; + this.LastMoveGmtMillis = 0; + this.FramesToRecover = 0; + this.FramesInChState = 0; + this.Hp = 0; + this.MaxHp = 0; + this.CharacterState = 0; + this.InAir = false; + this.OnWall = false; + this.OnWallNormX = 0; + this.OnWallNormY = 0; + this.CapturedByInertia = false; + this.ActiveSkillId = 0; + this.ActiveSkillHit = 0; + this.FramesInvinsible = 0; + this.BulletTeamId = 0; + this.ChCollisionTeamId = 0; + this.RevivalVirtualGridX = 0; + this.RevivalVirtualGridY = 0; + return; + } + this.Id = Id_; + this.VirtualGridX = VirtualGridX_; + this.VirtualGridY = VirtualGridY_; + this.DirX = DirX_; + this.DirY = DirY_; + this.VelX = VelX_; + this.VelY = VelY_; + this.Speed = Speed_; + this.BattleState = BattleState_; + this.JoinIndex = JoinIndex_; + this.ColliderRadius = ColliderRadius_; + this.Removed = Removed_; + this.Score = Score_; + this.LastMoveGmtMillis = LastMoveGmtMillis_; + this.FramesToRecover = FramesToRecover_; + this.FramesInChState = FramesInChState_; + this.Hp = Hp_; + this.MaxHp = MaxHp_; + this.CharacterState = CharacterState_; + this.InAir = InAir_; + this.OnWall = OnWall_; + this.OnWallNormX = OnWallNormX_; + this.OnWallNormY = OnWallNormY_; + this.CapturedByInertia = CapturedByInertia_; + this.ActiveSkillId = ActiveSkillId_; + this.ActiveSkillHit = ActiveSkillHit_; + this.FramesInvinsible = FramesInvinsible_; + this.BulletTeamId = BulletTeamId_; + this.ChCollisionTeamId = ChCollisionTeamId_; + this.RevivalVirtualGridX = RevivalVirtualGridX_; + this.RevivalVirtualGridY = RevivalVirtualGridY_; + }); + InputFrameDecoded = $pkg.InputFrameDecoded = $newType(0, $kindStruct, "battle.InputFrameDecoded", true, "jsexport/battle", true, function(Dx_, Dy_, BtnALevel_, BtnBLevel_) { + this.$val = this; + if (arguments.length === 0) { + this.Dx = 0; + this.Dy = 0; + this.BtnALevel = 0; + this.BtnBLevel = 0; + return; + } + this.Dx = Dx_; + this.Dy = Dy_; + this.BtnALevel = BtnALevel_; + this.BtnBLevel = BtnBLevel_; + }); + Barrier = $pkg.Barrier = $newType(0, $kindStruct, "battle.Barrier", true, "jsexport/battle", true, function(Boundary_) { + this.$val = this; + if (arguments.length === 0) { + this.Boundary = ptrType$13.nil; + return; + } + this.Boundary = Boundary_; + }); + BulletConfig = $pkg.BulletConfig = $newType(0, $kindStruct, "battle.BulletConfig", true, "jsexport/battle", true, function(StartupFrames_, CancellableStFrame_, CancellableEdFrame_, ActiveFrames_, HitStunFrames_, BlockStunFrames_, PushbackVelX_, PushbackVelY_, Damage_, SelfLockVelX_, SelfLockVelY_, HitboxOffsetX_, HitboxOffsetY_, HitboxSizeX_, HitboxSizeY_, BlowUp_, ExplosionFrames_, SpeciesId_, CancelTransit_) { + this.$val = this; + if (arguments.length === 0) { + this.StartupFrames = 0; + this.CancellableStFrame = 0; + this.CancellableEdFrame = 0; + this.ActiveFrames = 0; + this.HitStunFrames = 0; + this.BlockStunFrames = 0; + this.PushbackVelX = 0; + this.PushbackVelY = 0; + this.Damage = 0; + this.SelfLockVelX = 0; + this.SelfLockVelY = 0; + this.HitboxOffsetX = 0; + this.HitboxOffsetY = 0; + this.HitboxSizeX = 0; + this.HitboxSizeY = 0; + this.BlowUp = false; + this.ExplosionFrames = 0; + this.SpeciesId = 0; + this.CancelTransit = false; + return; + } + this.StartupFrames = StartupFrames_; + this.CancellableStFrame = CancellableStFrame_; + this.CancellableEdFrame = CancellableEdFrame_; + this.ActiveFrames = ActiveFrames_; + this.HitStunFrames = HitStunFrames_; + this.BlockStunFrames = BlockStunFrames_; + this.PushbackVelX = PushbackVelX_; + this.PushbackVelY = PushbackVelY_; + this.Damage = Damage_; + this.SelfLockVelX = SelfLockVelX_; + this.SelfLockVelY = SelfLockVelY_; + this.HitboxOffsetX = HitboxOffsetX_; + this.HitboxOffsetY = HitboxOffsetY_; + this.HitboxSizeX = HitboxSizeX_; + this.HitboxSizeY = HitboxSizeY_; + this.BlowUp = BlowUp_; + this.ExplosionFrames = ExplosionFrames_; + this.SpeciesId = SpeciesId_; + this.CancelTransit = CancelTransit_; + }); + BulletBattleAttr = $pkg.BulletBattleAttr = $newType(0, $kindStruct, "battle.BulletBattleAttr", true, "jsexport/battle", true, function(BulletLocalId_, OriginatedRenderFrameId_, OffenderJoinIndex_, TeamId_) { + this.$val = this; + if (arguments.length === 0) { + this.BulletLocalId = 0; + this.OriginatedRenderFrameId = 0; + this.OffenderJoinIndex = 0; + this.TeamId = 0; + return; + } + this.BulletLocalId = BulletLocalId_; + this.OriginatedRenderFrameId = OriginatedRenderFrameId_; + this.OffenderJoinIndex = OffenderJoinIndex_; + this.TeamId = TeamId_; + }); + MeleeBullet = $pkg.MeleeBullet = $newType(0, $kindStruct, "battle.MeleeBullet", true, "jsexport/battle", true, function(BlState_, FramesInBlState_, BattleAttr_, Bullet_) { + this.$val = this; + if (arguments.length === 0) { + this.BlState = 0; + this.FramesInBlState = 0; + this.BattleAttr = ptrType.nil; + this.Bullet = ptrType$1.nil; + return; + } + this.BlState = BlState_; + this.FramesInBlState = FramesInBlState_; + this.BattleAttr = BattleAttr_; + this.Bullet = Bullet_; + }); + FireballBullet = $pkg.FireballBullet = $newType(0, $kindStruct, "battle.FireballBullet", true, "jsexport/battle", true, function(VirtualGridX_, VirtualGridY_, DirX_, DirY_, VelX_, VelY_, Speed_, BlState_, FramesInBlState_, BattleAttr_, Bullet_) { + this.$val = this; + if (arguments.length === 0) { + this.VirtualGridX = 0; + this.VirtualGridY = 0; + this.DirX = 0; + this.DirY = 0; + this.VelX = 0; + this.VelY = 0; + this.Speed = 0; + this.BlState = 0; + this.FramesInBlState = 0; + this.BattleAttr = ptrType.nil; + this.Bullet = ptrType$1.nil; + return; + } + this.VirtualGridX = VirtualGridX_; + this.VirtualGridY = VirtualGridY_; + this.DirX = DirX_; + this.DirY = DirY_; + this.VelX = VelX_; + this.VelY = VelY_; + this.Speed = Speed_; + this.BlState = BlState_; + this.FramesInBlState = FramesInBlState_; + this.BattleAttr = BattleAttr_; + this.Bullet = Bullet_; + }); + Skill = $pkg.Skill = $newType(0, $kindStruct, "battle.Skill", true, "jsexport/battle", true, function(BattleLocalId_, RecoveryFrames_, RecoveryFramesOnBlock_, RecoveryFramesOnHit_, ReleaseTriggerType_, BoundChState_, Hits_) { + this.$val = this; + if (arguments.length === 0) { + this.BattleLocalId = 0; + this.RecoveryFrames = 0; + this.RecoveryFramesOnBlock = 0; + this.RecoveryFramesOnHit = 0; + this.ReleaseTriggerType = 0; + this.BoundChState = 0; + this.Hits = sliceType$2.nil; + return; + } + this.BattleLocalId = BattleLocalId_; + this.RecoveryFrames = RecoveryFrames_; + this.RecoveryFramesOnBlock = RecoveryFramesOnBlock_; + this.RecoveryFramesOnHit = RecoveryFramesOnHit_; + this.ReleaseTriggerType = ReleaseTriggerType_; + this.BoundChState = BoundChState_; + this.Hits = Hits_; + }); + RoomDownsyncFrame = $pkg.RoomDownsyncFrame = $newType(0, $kindStruct, "battle.RoomDownsyncFrame", true, "jsexport/battle", true, function(Id_, PlayersArr_, CountdownNanos_, MeleeBullets_, FireballBullets_, BackendUnconfirmedMask_, ShouldForceResync_, BulletLocalIdCounter_) { + this.$val = this; + if (arguments.length === 0) { + this.Id = 0; + this.PlayersArr = sliceType$4.nil; + this.CountdownNanos = new $Int64(0, 0); + this.MeleeBullets = sliceType$5.nil; + this.FireballBullets = sliceType$6.nil; + this.BackendUnconfirmedMask = new $Uint64(0, 0); + this.ShouldForceResync = false; + this.BulletLocalIdCounter = 0; + return; + } + this.Id = Id_; + this.PlayersArr = PlayersArr_; + this.CountdownNanos = CountdownNanos_; + this.MeleeBullets = MeleeBullets_; + this.FireballBullets = FireballBullets_; + this.BackendUnconfirmedMask = BackendUnconfirmedMask_; + this.ShouldForceResync = ShouldForceResync_; + this.BulletLocalIdCounter = BulletLocalIdCounter_; + }); + InputFrameDownsync = $pkg.InputFrameDownsync = $newType(0, $kindStruct, "battle.InputFrameDownsync", true, "jsexport/battle", true, function(InputFrameId_, InputList_, ConfirmedList_) { + this.$val = this; + if (arguments.length === 0) { + this.InputFrameId = 0; + this.InputList = sliceType$3.nil; + this.ConfirmedList = new $Uint64(0, 0); + return; + } + this.InputFrameId = InputFrameId_; + this.InputList = InputList_; + this.ConfirmedList = ConfirmedList_; + }); + NpcPatrolCue = $pkg.NpcPatrolCue = $newType(0, $kindStruct, "battle.NpcPatrolCue", true, "jsexport/battle", true, function(FlAct_, FrAct_, X_, Y_) { + this.$val = this; + if (arguments.length === 0) { + this.FlAct = new $Uint64(0, 0); + this.FrAct = new $Uint64(0, 0); + this.X = 0; + this.Y = 0; + return; + } + this.FlAct = FlAct_; + this.FrAct = FrAct_; + this.X = X_; + this.Y = Y_; + }); + SkillMapperType = $pkg.SkillMapperType = $newType(4, $kindFunc, "battle.SkillMapperType", true, "jsexport/battle", true, null); + CharacterConfig = $pkg.CharacterConfig = $newType(0, $kindStruct, "battle.CharacterConfig", true, "jsexport/battle", true, function(SpeciesId_, SpeciesName_, InAirIdleFrameIdxTurningPoint_, InAirIdleFrameIdxTurnedCycle_, LayDownFrames_, LayDownFramesToRecover_, GetUpInvinsibleFrames_, GetUpFramesToRecover_, Speed_, JumpingInitVelY_, JumpingFramesToRecover_, DashingEnabled_, OnWallEnabled_, WallJumpingFramesToRecover_, WallJumpingInitVelX_, WallJumpingInitVelY_, WallSlidingVelY_, InertiaFramesToRecover_, SkillMapper_) { + this.$val = this; + if (arguments.length === 0) { + this.SpeciesId = 0; + this.SpeciesName = ""; + this.InAirIdleFrameIdxTurningPoint = 0; + this.InAirIdleFrameIdxTurnedCycle = 0; + this.LayDownFrames = 0; + this.LayDownFramesToRecover = 0; + this.GetUpInvinsibleFrames = 0; + this.GetUpFramesToRecover = 0; + this.Speed = 0; + this.JumpingInitVelY = 0; + this.JumpingFramesToRecover = 0; + this.DashingEnabled = false; + this.OnWallEnabled = false; + this.WallJumpingFramesToRecover = 0; + this.WallJumpingInitVelX = 0; + this.WallJumpingInitVelY = 0; + this.WallSlidingVelY = 0; + this.InertiaFramesToRecover = 0; + this.SkillMapper = $throwNilPointerError; + return; + } + this.SpeciesId = SpeciesId_; + this.SpeciesName = SpeciesName_; + this.InAirIdleFrameIdxTurningPoint = InAirIdleFrameIdxTurningPoint_; + this.InAirIdleFrameIdxTurnedCycle = InAirIdleFrameIdxTurnedCycle_; + this.LayDownFrames = LayDownFrames_; + this.LayDownFramesToRecover = LayDownFramesToRecover_; + this.GetUpInvinsibleFrames = GetUpInvinsibleFrames_; + this.GetUpFramesToRecover = GetUpFramesToRecover_; + this.Speed = Speed_; + this.JumpingInitVelY = JumpingInitVelY_; + this.JumpingFramesToRecover = JumpingFramesToRecover_; + this.DashingEnabled = DashingEnabled_; + this.OnWallEnabled = OnWallEnabled_; + this.WallJumpingFramesToRecover = WallJumpingFramesToRecover_; + this.WallJumpingInitVelX = WallJumpingInitVelX_; + this.WallJumpingInitVelY = WallJumpingInitVelY_; + this.WallSlidingVelY = WallSlidingVelY_; + this.InertiaFramesToRecover = InertiaFramesToRecover_; + this.SkillMapper = SkillMapper_; + }); + SatResult = $pkg.SatResult = $newType(0, $kindStruct, "battle.SatResult", true, "jsexport/battle", true, function(Overlap_, OverlapX_, OverlapY_, AContainedInB_, BContainedInA_, Axis_) { + this.$val = this; + if (arguments.length === 0) { + this.Overlap = 0; + this.OverlapX = 0; + this.OverlapY = 0; + this.AContainedInB = false; + this.BContainedInA = false; + this.Axis = resolv.Vector.nil; + return; + } + this.Overlap = Overlap_; + this.OverlapX = OverlapX_; + this.OverlapY = OverlapY_; + this.AContainedInB = AContainedInB_; + this.BContainedInA = BContainedInA_; + this.Axis = Axis_; + }); + sliceType = $sliceType($Int32); + sliceType$1 = $sliceType(sliceType); + sliceType$2 = $sliceType($emptyInterface); + ptrType = $ptrType(BulletBattleAttr); + ptrType$1 = $ptrType(BulletConfig); + ptrType$2 = $ptrType(Skill); + ptrType$3 = $ptrType(MeleeBullet); + ptrType$4 = $ptrType(RoomDownsyncFrame); + ptrType$5 = $ptrType(SatResult); + ptrType$6 = $ptrType(resolv.Object); + ptrType$7 = $ptrType(PlayerDownsync); + ptrType$8 = $ptrType(FireballBullet); + ptrType$9 = $ptrType(resolv.ConvexPolygon); + ptrType$10 = $ptrType(InputFrameDownsync); + sliceType$3 = $sliceType($Uint64); + sliceType$4 = $sliceType(ptrType$7); + sliceType$5 = $sliceType(ptrType$3); + sliceType$6 = $sliceType(ptrType$8); + sliceType$7 = $sliceType(Vec2D); + sliceType$8 = $sliceType(sliceType$7); + sliceType$9 = $sliceType($Bool); + sliceType$10 = $sliceType(ptrType$6); + ptrType$11 = $ptrType(sliceType$7); + sliceType$11 = $sliceType($Float64); + sliceType$12 = $sliceType($String); + ptrType$12 = $ptrType(Vec2D); + sliceType$13 = $sliceType(ptrType$12); + ptrType$13 = $ptrType(Polygon2D); + mapType = $mapType($Int, $Int); + ptrType$15 = $ptrType(CharacterConfig); + CharacterConfig.ptr.prototype.GetSpeed = function() { + var c; + c = this; + return c.Speed; + }; + CharacterConfig.prototype.GetSpeed = function() { return this.$val.GetSpeed(); }; + CharacterConfig.ptr.prototype.GetSpeciesId = function() { + var c; + c = this; + return c.SpeciesId; + }; + CharacterConfig.prototype.GetSpeciesId = function() { return this.$val.GetSpeciesId(); }; + CharacterConfig.ptr.prototype.GetSpeciesName = function() { + var c; + c = this; + return c.SpeciesName; + }; + CharacterConfig.prototype.GetSpeciesName = function() { return this.$val.GetSpeciesName(); }; + InputFrameDownsync.ptr.prototype.GetInputFrameId = function() { + var ifd; + ifd = this; + return ifd.InputFrameId; + }; + InputFrameDownsync.prototype.GetInputFrameId = function() { return this.$val.GetInputFrameId(); }; + InputFrameDownsync.ptr.prototype.GetInputList = function() { + var ifd; + ifd = this; + return ifd.InputList; + }; + InputFrameDownsync.prototype.GetInputList = function() { return this.$val.GetInputList(); }; + InputFrameDownsync.ptr.prototype.GetConfirmedList = function() { + var ifd; + ifd = this; + return ifd.ConfirmedList; + }; + InputFrameDownsync.prototype.GetConfirmedList = function() { return this.$val.GetConfirmedList(); }; + PlayerDownsync.ptr.prototype.GetId = function() { + var p; + p = this; + return p.Id; + }; + PlayerDownsync.prototype.GetId = function() { return this.$val.GetId(); }; + PlayerDownsync.ptr.prototype.GetJoinIndex = function() { + var p; + p = this; + return p.JoinIndex; + }; + PlayerDownsync.prototype.GetJoinIndex = function() { return this.$val.GetJoinIndex(); }; + PlayerDownsync.ptr.prototype.GetVirtualGridX = function() { + var p; + p = this; + return p.VirtualGridX; + }; + PlayerDownsync.prototype.GetVirtualGridX = function() { return this.$val.GetVirtualGridX(); }; + PlayerDownsync.ptr.prototype.GetVirtualGridY = function() { + var p; + p = this; + return p.VirtualGridY; + }; + PlayerDownsync.prototype.GetVirtualGridY = function() { return this.$val.GetVirtualGridY(); }; + PlayerDownsync.ptr.prototype.GetDirX = function() { + var p; + p = this; + return p.DirX; + }; + PlayerDownsync.prototype.GetDirX = function() { return this.$val.GetDirX(); }; + PlayerDownsync.ptr.prototype.GetDirY = function() { + var p; + p = this; + return p.DirY; + }; + PlayerDownsync.prototype.GetDirY = function() { return this.$val.GetDirY(); }; + PlayerDownsync.ptr.prototype.GetVelX = function() { + var p; + p = this; + return p.VelX; + }; + PlayerDownsync.prototype.GetVelX = function() { return this.$val.GetVelX(); }; + PlayerDownsync.ptr.prototype.GetVelY = function() { + var p; + p = this; + return p.VelY; + }; + PlayerDownsync.prototype.GetVelY = function() { return this.$val.GetVelY(); }; + PlayerDownsync.ptr.prototype.GetSpeed = function() { + var p; + p = this; + return p.Speed; + }; + PlayerDownsync.prototype.GetSpeed = function() { return this.$val.GetSpeed(); }; + PlayerDownsync.ptr.prototype.GetHp = function() { + var p; + p = this; + return p.Hp; + }; + PlayerDownsync.prototype.GetHp = function() { return this.$val.GetHp(); }; + PlayerDownsync.ptr.prototype.GetMaxHp = function() { + var p; + p = this; + return p.MaxHp; + }; + PlayerDownsync.prototype.GetMaxHp = function() { return this.$val.GetMaxHp(); }; + PlayerDownsync.ptr.prototype.GetCharacterState = function() { + var p; + p = this; + return p.CharacterState; + }; + PlayerDownsync.prototype.GetCharacterState = function() { return this.$val.GetCharacterState(); }; + PlayerDownsync.ptr.prototype.GetFramesToRecover = function() { + var p; + p = this; + return p.FramesToRecover; + }; + PlayerDownsync.prototype.GetFramesToRecover = function() { return this.$val.GetFramesToRecover(); }; + PlayerDownsync.ptr.prototype.GetFramesInChState = function() { + var p; + p = this; + return p.FramesInChState; + }; + PlayerDownsync.prototype.GetFramesInChState = function() { return this.$val.GetFramesInChState(); }; + PlayerDownsync.ptr.prototype.GetInAir = function() { + var p; + p = this; + return p.InAir; + }; + PlayerDownsync.prototype.GetInAir = function() { return this.$val.GetInAir(); }; + PlayerDownsync.ptr.prototype.GetOnWall = function() { + var p; + p = this; + return p.OnWall; + }; + PlayerDownsync.prototype.GetOnWall = function() { return this.$val.GetOnWall(); }; + PlayerDownsync.ptr.prototype.GetOnWallNormX = function() { + var p; + p = this; + return p.OnWallNormX; + }; + PlayerDownsync.prototype.GetOnWallNormX = function() { return this.$val.GetOnWallNormX(); }; + PlayerDownsync.ptr.prototype.GetColliderRadius = function() { + var p; + p = this; + return p.ColliderRadius; + }; + PlayerDownsync.prototype.GetColliderRadius = function() { return this.$val.GetColliderRadius(); }; + MeleeBullet.ptr.prototype.GetBlState = function() { + var b; + b = this; + return b.BlState; + }; + MeleeBullet.prototype.GetBlState = function() { return this.$val.GetBlState(); }; + MeleeBullet.ptr.prototype.GetFramesInBlState = function() { + var b; + b = this; + return b.FramesInBlState; + }; + MeleeBullet.prototype.GetFramesInBlState = function() { return this.$val.GetFramesInBlState(); }; + MeleeBullet.ptr.prototype.GetBulletLocalId = function() { + var b; + b = this; + return b.BattleAttr.BulletLocalId; + }; + MeleeBullet.prototype.GetBulletLocalId = function() { return this.$val.GetBulletLocalId(); }; + MeleeBullet.ptr.prototype.GetOffenderJoinIndex = function() { + var b; + b = this; + return b.BattleAttr.OffenderJoinIndex; + }; + MeleeBullet.prototype.GetOffenderJoinIndex = function() { return this.$val.GetOffenderJoinIndex(); }; + MeleeBullet.ptr.prototype.GetOriginatedRenderFrameId = function() { + var b; + b = this; + return b.BattleAttr.OriginatedRenderFrameId; + }; + MeleeBullet.prototype.GetOriginatedRenderFrameId = function() { return this.$val.GetOriginatedRenderFrameId(); }; + MeleeBullet.ptr.prototype.GetStartupFrames = function() { + var b; + b = this; + return b.Bullet.StartupFrames; + }; + MeleeBullet.prototype.GetStartupFrames = function() { return this.$val.GetStartupFrames(); }; + MeleeBullet.ptr.prototype.GetActiveFrames = function() { + var b; + b = this; + return b.Bullet.ActiveFrames; + }; + MeleeBullet.prototype.GetActiveFrames = function() { return this.$val.GetActiveFrames(); }; + MeleeBullet.ptr.prototype.GetHitboxSizeX = function() { + var b; + b = this; + return b.Bullet.HitboxSizeX; + }; + MeleeBullet.prototype.GetHitboxSizeX = function() { return this.$val.GetHitboxSizeX(); }; + MeleeBullet.ptr.prototype.GetHitboxSizeY = function() { + var b; + b = this; + return b.Bullet.HitboxSizeY; + }; + MeleeBullet.prototype.GetHitboxSizeY = function() { return this.$val.GetHitboxSizeY(); }; + MeleeBullet.ptr.prototype.GetHitboxOffsetX = function() { + var b; + b = this; + return b.Bullet.HitboxOffsetX; + }; + MeleeBullet.prototype.GetHitboxOffsetX = function() { return this.$val.GetHitboxOffsetX(); }; + MeleeBullet.ptr.prototype.GetHitboxOffsetY = function() { + var b; + b = this; + return b.Bullet.HitboxOffsetY; + }; + MeleeBullet.prototype.GetHitboxOffsetY = function() { return this.$val.GetHitboxOffsetY(); }; + MeleeBullet.ptr.prototype.GetExplosionFrames = function() { + var b; + b = this; + return b.Bullet.ExplosionFrames; + }; + MeleeBullet.prototype.GetExplosionFrames = function() { return this.$val.GetExplosionFrames(); }; + MeleeBullet.ptr.prototype.GetSpeciesId = function() { + var b; + b = this; + return b.Bullet.SpeciesId; + }; + MeleeBullet.prototype.GetSpeciesId = function() { return this.$val.GetSpeciesId(); }; + FireballBullet.ptr.prototype.GetVirtualGridX = function() { + var p; + p = this; + return p.VirtualGridX; + }; + FireballBullet.prototype.GetVirtualGridX = function() { return this.$val.GetVirtualGridX(); }; + FireballBullet.ptr.prototype.GetVirtualGridY = function() { + var p; + p = this; + return p.VirtualGridY; + }; + FireballBullet.prototype.GetVirtualGridY = function() { return this.$val.GetVirtualGridY(); }; + FireballBullet.ptr.prototype.GetDirX = function() { + var p; + p = this; + return p.DirX; + }; + FireballBullet.prototype.GetDirX = function() { return this.$val.GetDirX(); }; + FireballBullet.ptr.prototype.GetDirY = function() { + var p; + p = this; + return p.DirY; + }; + FireballBullet.prototype.GetDirY = function() { return this.$val.GetDirY(); }; + FireballBullet.ptr.prototype.GetVelX = function() { + var p; + p = this; + return p.VelX; + }; + FireballBullet.prototype.GetVelX = function() { return this.$val.GetVelX(); }; + FireballBullet.ptr.prototype.GetVelY = function() { + var p; + p = this; + return p.VelY; + }; + FireballBullet.prototype.GetVelY = function() { return this.$val.GetVelY(); }; + FireballBullet.ptr.prototype.GetSpeed = function() { + var p; + p = this; + return p.Speed; + }; + FireballBullet.prototype.GetSpeed = function() { return this.$val.GetSpeed(); }; + FireballBullet.ptr.prototype.GetBlState = function() { + var b; + b = this; + return b.BlState; + }; + FireballBullet.prototype.GetBlState = function() { return this.$val.GetBlState(); }; + FireballBullet.ptr.prototype.GetFramesInBlState = function() { + var b; + b = this; + return b.FramesInBlState; + }; + FireballBullet.prototype.GetFramesInBlState = function() { return this.$val.GetFramesInBlState(); }; + FireballBullet.ptr.prototype.GetBulletLocalId = function() { + var b; + b = this; + return b.BattleAttr.BulletLocalId; + }; + FireballBullet.prototype.GetBulletLocalId = function() { return this.$val.GetBulletLocalId(); }; + FireballBullet.ptr.prototype.GetOffenderJoinIndex = function() { + var b; + b = this; + return b.BattleAttr.OffenderJoinIndex; + }; + FireballBullet.prototype.GetOffenderJoinIndex = function() { return this.$val.GetOffenderJoinIndex(); }; + FireballBullet.ptr.prototype.GetOriginatedRenderFrameId = function() { + var b; + b = this; + return b.BattleAttr.OriginatedRenderFrameId; + }; + FireballBullet.prototype.GetOriginatedRenderFrameId = function() { return this.$val.GetOriginatedRenderFrameId(); }; + FireballBullet.ptr.prototype.GetStartupFrames = function() { + var b; + b = this; + return b.Bullet.StartupFrames; + }; + FireballBullet.prototype.GetStartupFrames = function() { return this.$val.GetStartupFrames(); }; + FireballBullet.ptr.prototype.GetActiveFrames = function() { + var b; + b = this; + return b.Bullet.ActiveFrames; + }; + FireballBullet.prototype.GetActiveFrames = function() { return this.$val.GetActiveFrames(); }; + FireballBullet.ptr.prototype.GetHitboxSizeX = function() { + var b; + b = this; + return b.Bullet.HitboxSizeX; + }; + FireballBullet.prototype.GetHitboxSizeX = function() { return this.$val.GetHitboxSizeX(); }; + FireballBullet.ptr.prototype.GetHitboxSizeY = function() { + var b; + b = this; + return b.Bullet.HitboxSizeY; + }; + FireballBullet.prototype.GetHitboxSizeY = function() { return this.$val.GetHitboxSizeY(); }; + FireballBullet.ptr.prototype.GetHitboxOffsetX = function() { + var b; + b = this; + return b.Bullet.HitboxOffsetX; + }; + FireballBullet.prototype.GetHitboxOffsetX = function() { return this.$val.GetHitboxOffsetX(); }; + FireballBullet.ptr.prototype.GetHitboxOffsetY = function() { + var b; + b = this; + return b.Bullet.HitboxOffsetY; + }; + FireballBullet.prototype.GetHitboxOffsetY = function() { return this.$val.GetHitboxOffsetY(); }; + FireballBullet.ptr.prototype.GetExplosionFrames = function() { + var b; + b = this; + return b.Bullet.ExplosionFrames; + }; + FireballBullet.prototype.GetExplosionFrames = function() { return this.$val.GetExplosionFrames(); }; + FireballBullet.ptr.prototype.GetSpeciesId = function() { + var b; + b = this; + return b.Bullet.SpeciesId; + }; + FireballBullet.prototype.GetSpeciesId = function() { return this.$val.GetSpeciesId(); }; + RoomDownsyncFrame.ptr.prototype.GetId = function() { + var r; + r = this; + return r.Id; + }; + RoomDownsyncFrame.prototype.GetId = function() { return this.$val.GetId(); }; + RoomDownsyncFrame.ptr.prototype.GetCountdownNanos = function() { + var r; + r = this; + return r.CountdownNanos; + }; + RoomDownsyncFrame.prototype.GetCountdownNanos = function() { return this.$val.GetCountdownNanos(); }; + RoomDownsyncFrame.ptr.prototype.GetBackendUnconfirmedMask = function() { + var r; + r = this; + return r.BackendUnconfirmedMask; + }; + RoomDownsyncFrame.prototype.GetBackendUnconfirmedMask = function() { return this.$val.GetBackendUnconfirmedMask(); }; + RoomDownsyncFrame.ptr.prototype.GetBulletLocalIdCounter = function() { + var r; + r = this; + return r.BulletLocalIdCounter; + }; + RoomDownsyncFrame.prototype.GetBulletLocalIdCounter = function() { return this.$val.GetBulletLocalIdCounter(); }; + RoomDownsyncFrame.ptr.prototype.GetShouldForceResync = function() { + var r; + r = this; + return r.ShouldForceResync; + }; + RoomDownsyncFrame.prototype.GetShouldForceResync = function() { return this.$val.GetShouldForceResync(); }; + RoomDownsyncFrame.ptr.prototype.GetPlayersArr = function() { + var r; + r = this; + return r.PlayersArr; + }; + RoomDownsyncFrame.prototype.GetPlayersArr = function() { return this.$val.GetPlayersArr(); }; + RoomDownsyncFrame.ptr.prototype.GetMeleeBullets = function() { + var r; + r = this; + return r.MeleeBullets; + }; + RoomDownsyncFrame.prototype.GetMeleeBullets = function() { return this.$val.GetMeleeBullets(); }; + RoomDownsyncFrame.ptr.prototype.GetFireballBullets = function() { + var r; + r = this; + return r.FireballBullets; + }; + RoomDownsyncFrame.prototype.GetFireballBullets = function() { return this.$val.GetFireballBullets(); }; + intAbs = function(x) { + var x; + if (x < 0) { + return -x; + } + return x; + }; + ShouldGenerateInputFrameUpsync = function(renderFrameId) { + var renderFrameId; + return (((renderFrameId & 3)) === 0); + }; + $pkg.ShouldGenerateInputFrameUpsync = ShouldGenerateInputFrameUpsync; + ConvertToDelayedInputFrameId = function(renderFrameId) { + var renderFrameId; + if (renderFrameId < 6) { + return 0; + } + return (((renderFrameId - 6 >> 0)) >> 2 >> 0); + }; + $pkg.ConvertToDelayedInputFrameId = ConvertToDelayedInputFrameId; + ConvertToNoDelayInputFrameId = function(renderFrameId) { + var renderFrameId; + return (renderFrameId >> 2 >> 0); + }; + $pkg.ConvertToNoDelayInputFrameId = ConvertToNoDelayInputFrameId; + ConvertToFirstUsedRenderFrameId = function(inputFrameId) { + var inputFrameId; + return (((inputFrameId << 2 >> 0)) + 6 >> 0); + }; + $pkg.ConvertToFirstUsedRenderFrameId = ConvertToFirstUsedRenderFrameId; + ConvertToLastUsedRenderFrameId = function(inputFrameId) { + var inputFrameId; + return (((((inputFrameId << 2 >> 0)) + 6 >> 0) + 4 >> 0) - 1 >> 0); + }; + $pkg.ConvertToLastUsedRenderFrameId = ConvertToLastUsedRenderFrameId; + decodeInput = function(encodedInput) { + var btnALevel, btnBLevel, encodedDirection, encodedInput, x, x$1, x$2, x$3; + encodedDirection = new $Uint64(encodedInput.$high & 0, (encodedInput.$low & 15) >>> 0); + btnALevel = (((x = $shiftRightUint64(encodedInput, 4), new $Uint64(x.$high & 0, (x.$low & 1) >>> 0)).$low >> 0)); + btnBLevel = (((x$1 = $shiftRightUint64(encodedInput, 5), new $Uint64(x$1.$high & 0, (x$1.$low & 1) >>> 0)).$low >> 0)); + return new InputFrameDecoded.ptr((x$2 = (($flatten64(encodedDirection) < 0 || $flatten64(encodedDirection) >= $pkg.DIRECTION_DECODER.$length) ? ($throwRuntimeError("index out of range"), undefined) : $pkg.DIRECTION_DECODER.$array[$pkg.DIRECTION_DECODER.$offset + $flatten64(encodedDirection)]), (0 >= x$2.$length ? ($throwRuntimeError("index out of range"), undefined) : x$2.$array[x$2.$offset + 0])), (x$3 = (($flatten64(encodedDirection) < 0 || $flatten64(encodedDirection) >= $pkg.DIRECTION_DECODER.$length) ? ($throwRuntimeError("index out of range"), undefined) : $pkg.DIRECTION_DECODER.$array[$pkg.DIRECTION_DECODER.$offset + $flatten64(encodedDirection)]), (1 >= x$3.$length ? ($throwRuntimeError("index out of range"), undefined) : x$3.$array[x$3.$offset + 1])), btnALevel, btnBLevel); + }; + calcPushbacks = function(oldDx, oldDy, playerShape, barrierShape) { + var {$24r, $24r$1, _tmp, _tmp$1, _tuple, barrierShape, oldDx, oldDy, origX, origY, overlapResult, overlapped, playerShape, pushbackX, pushbackY, $s, $deferred, $r, $c} = $restore(this, {oldDx, oldDy, playerShape, barrierShape}); + /* */ $s = $s || 0; var $err = null; try { s: while (true) { switch ($s) { case 0: $deferred = []; $curGoroutine.deferStack.push($deferred); + origX = [origX]; + origY = [origY]; + playerShape = [playerShape]; + _tuple = playerShape[0].Position(); + origX[0] = _tuple[0]; + origY[0] = _tuple[1]; + $deferred.push([(function(origX, origY, playerShape) { return function() { + playerShape[0].SetPosition(origX[0], origY[0]); + }; })(origX, origY, playerShape), []]); + playerShape[0].SetPosition(origX[0] + oldDx, origY[0] + oldDy); + overlapResult = new SatResult.ptr(0, 0, 0, true, true, new resolv.Vector([0, 0])); + overlapped = isPolygonPairOverlapped(playerShape[0], barrierShape, overlapResult); + /* */ if (overlapped) { $s = 1; continue; } + /* */ $s = 2; continue; + /* if (overlapped) { */ case 1: + _tmp = overlapResult.Overlap * overlapResult.OverlapX; + _tmp$1 = overlapResult.Overlap * overlapResult.OverlapY; + pushbackX = _tmp; + pushbackY = _tmp$1; + $24r = [true, pushbackX, pushbackY, overlapResult]; + $s = 4; case 4: return $24r; + /* } else { */ case 2: + $24r$1 = [false, 0, 0, overlapResult]; + $s = 5; case 5: return $24r$1; + /* } */ case 3: + $s = -1; return [false, 0, 0, ptrType$5.nil]; + /* */ } return; } } catch(err) { $err = err; $s = -1; return [false, 0, 0, ptrType$5.nil]; } finally { $callDeferred($deferred, $err); if($curGoroutine.asleep) { var $f = {$blk: calcPushbacks, $c: true, $r, $24r, $24r$1, _tmp, _tmp$1, _tuple, barrierShape, oldDx, oldDy, origX, origY, overlapResult, overlapped, playerShape, pushbackX, pushbackY, $s, $deferred};return $f; } } + }; + isPolygonPairOverlapped = function(a, b, result) { + var _i, _i$1, _ref, _ref$1, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, a, aCnt, axis, axis$1, b, bCnt, dx, dx$1, dy, dy$1, i, i$1, result, u, u$1, v, v$1, x, x$1, x$10, x$11, x$12, x$13, x$14, x$15, x$2, x$3, x$4, x$5, x$6, x$7, x$8, x$9; + _tmp = a.Points.$length; + _tmp$1 = b.Points.$length; + aCnt = _tmp; + bCnt = _tmp$1; + if ((1 === aCnt) && (1 === bCnt)) { + if (!(ptrType$5.nil === result)) { + result.Overlap = 0; + } + return ((x = (x$1 = a.Points, (0 >= x$1.$length ? ($throwRuntimeError("index out of range"), undefined) : x$1.$array[x$1.$offset + 0])), (0 >= x.$length ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + 0])) === (x$2 = (x$3 = b.Points, (0 >= x$3.$length ? ($throwRuntimeError("index out of range"), undefined) : x$3.$array[x$3.$offset + 0])), (0 >= x$2.$length ? ($throwRuntimeError("index out of range"), undefined) : x$2.$array[x$2.$offset + 0]))) && ((x$4 = (x$5 = a.Points, (0 >= x$5.$length ? ($throwRuntimeError("index out of range"), undefined) : x$5.$array[x$5.$offset + 0])), (1 >= x$4.$length ? ($throwRuntimeError("index out of range"), undefined) : x$4.$array[x$4.$offset + 1])) === (x$6 = (x$7 = b.Points, (0 >= x$7.$length ? ($throwRuntimeError("index out of range"), undefined) : x$7.$array[x$7.$offset + 0])), (1 >= x$6.$length ? ($throwRuntimeError("index out of range"), undefined) : x$6.$array[x$6.$offset + 1]))); + } + if (1 < aCnt) { + _ref = a.Points; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + i = _i; + _tmp$2 = (x$8 = a.Points, ((i < 0 || i >= x$8.$length) ? ($throwRuntimeError("index out of range"), undefined) : x$8.$array[x$8.$offset + i])); + _tmp$3 = (x$9 = a.Points, (0 >= x$9.$length ? ($throwRuntimeError("index out of range"), undefined) : x$9.$array[x$9.$offset + 0])); + u = _tmp$2; + v = _tmp$3; + if (!((i === (a.Points.$length - 1 >> 0)))) { + v = (x$10 = a.Points, x$11 = i + 1 >> 0, ((x$11 < 0 || x$11 >= x$10.$length) ? ($throwRuntimeError("index out of range"), undefined) : x$10.$array[x$10.$offset + x$11])); + } + dy = (1 >= v.$length ? ($throwRuntimeError("index out of range"), undefined) : v.$array[v.$offset + 1]) - (1 >= u.$length ? ($throwRuntimeError("index out of range"), undefined) : u.$array[u.$offset + 1]); + dx = (0 >= v.$length ? ($throwRuntimeError("index out of range"), undefined) : v.$array[v.$offset + 0]) - (0 >= u.$length ? ($throwRuntimeError("index out of range"), undefined) : u.$array[u.$offset + 0]); + axis = new resolv.Vector([dy, -dx]).Unit(); + if (isPolygonPairSeparatedByDir(a, b, axis, result)) { + return false; + } + _i++; + } + } + if (1 < bCnt) { + _ref$1 = b.Points; + _i$1 = 0; + while (true) { + if (!(_i$1 < _ref$1.$length)) { break; } + i$1 = _i$1; + _tmp$4 = (x$12 = b.Points, ((i$1 < 0 || i$1 >= x$12.$length) ? ($throwRuntimeError("index out of range"), undefined) : x$12.$array[x$12.$offset + i$1])); + _tmp$5 = (x$13 = b.Points, (0 >= x$13.$length ? ($throwRuntimeError("index out of range"), undefined) : x$13.$array[x$13.$offset + 0])); + u$1 = _tmp$4; + v$1 = _tmp$5; + if (!((i$1 === (b.Points.$length - 1 >> 0)))) { + v$1 = (x$14 = b.Points, x$15 = i$1 + 1 >> 0, ((x$15 < 0 || x$15 >= x$14.$length) ? ($throwRuntimeError("index out of range"), undefined) : x$14.$array[x$14.$offset + x$15])); + } + dy$1 = (1 >= v$1.$length ? ($throwRuntimeError("index out of range"), undefined) : v$1.$array[v$1.$offset + 1]) - (1 >= u$1.$length ? ($throwRuntimeError("index out of range"), undefined) : u$1.$array[u$1.$offset + 1]); + dx$1 = (0 >= v$1.$length ? ($throwRuntimeError("index out of range"), undefined) : v$1.$array[v$1.$offset + 0]) - (0 >= u$1.$length ? ($throwRuntimeError("index out of range"), undefined) : u$1.$array[u$1.$offset + 0]); + axis$1 = new resolv.Vector([dy$1, -dx$1]).Unit(); + if (isPolygonPairSeparatedByDir(a, b, axis$1, result)) { + return false; + } + _i$1++; + } + } + return true; + }; + IsGeneralBulletActive = function(blState, originatedRenderFrameId, startupFrames, activeFrames, renderFrameId) { + var activeFrames, blState, originatedRenderFrameId, renderFrameId, startupFrames; + if (2 === blState) { + return false; + } + return ((originatedRenderFrameId + startupFrames >> 0) < renderFrameId) && (((originatedRenderFrameId + startupFrames >> 0) + activeFrames >> 0) > renderFrameId); + }; + $pkg.IsGeneralBulletActive = IsGeneralBulletActive; + IsMeleeBulletActive = function(meleeBullet, currRenderFrame) { + var currRenderFrame, meleeBullet; + return IsGeneralBulletActive(meleeBullet.BlState, meleeBullet.BattleAttr.OriginatedRenderFrameId, meleeBullet.Bullet.StartupFrames, meleeBullet.Bullet.ActiveFrames, currRenderFrame.Id); + }; + $pkg.IsMeleeBulletActive = IsMeleeBulletActive; + IsMeleeBulletAlive = function(meleeBullet, currRenderFrame) { + var currRenderFrame, meleeBullet; + if (2 === meleeBullet.BlState) { + return meleeBullet.FramesInBlState < meleeBullet.Bullet.ExplosionFrames; + } + return ((meleeBullet.BattleAttr.OriginatedRenderFrameId + meleeBullet.Bullet.StartupFrames >> 0) + meleeBullet.Bullet.ActiveFrames >> 0) > currRenderFrame.Id; + }; + $pkg.IsMeleeBulletAlive = IsMeleeBulletAlive; + IsFireballBulletActive = function(fireballBullet, currRenderFrame) { + var currRenderFrame, fireballBullet; + return IsGeneralBulletActive(fireballBullet.BlState, fireballBullet.BattleAttr.OriginatedRenderFrameId, fireballBullet.Bullet.StartupFrames, fireballBullet.Bullet.ActiveFrames, currRenderFrame.Id); + }; + $pkg.IsFireballBulletActive = IsFireballBulletActive; + IsFireballBulletAlive = function(fireballBullet, currRenderFrame) { + var currRenderFrame, fireballBullet; + if (2 === fireballBullet.BlState) { + return fireballBullet.FramesInBlState < fireballBullet.Bullet.ExplosionFrames; + } + return ((fireballBullet.BattleAttr.OriginatedRenderFrameId + fireballBullet.Bullet.StartupFrames >> 0) + fireballBullet.Bullet.ActiveFrames >> 0) > currRenderFrame.Id; + }; + $pkg.IsFireballBulletAlive = IsFireballBulletAlive; + isPolygonPairSeparatedByDir = function(a, b, e, result) { + var _i, _i$1, _ref, _ref$1, _tmp, _tmp$1, _tmp$2, _tmp$3, a, aEnd, aStart, absoluteOverlap, b, bEnd, bStart, currentOverlap, dot, dot$1, e, option1, option1$1, option2, option2$1, overlap, p, p$1, result, sign, x, x$1; + _tmp = 1.7e+308; + _tmp$1 = -1.7e+308; + _tmp$2 = 1.7e+308; + _tmp$3 = -1.7e+308; + aStart = _tmp; + aEnd = _tmp$1; + bStart = _tmp$2; + bEnd = _tmp$3; + _ref = a.Points; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + p = ((_i < 0 || _i >= _ref.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref.$array[_ref.$offset + _i]); + dot = ((0 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 0]) + a.X) * (0 >= e.$length ? ($throwRuntimeError("index out of range"), undefined) : e.$array[e.$offset + 0]) + ((1 >= p.$length ? ($throwRuntimeError("index out of range"), undefined) : p.$array[p.$offset + 1]) + a.Y) * (1 >= e.$length ? ($throwRuntimeError("index out of range"), undefined) : e.$array[e.$offset + 1]); + if (aStart > dot) { + aStart = dot; + } + if (aEnd < dot) { + aEnd = dot; + } + _i++; + } + _ref$1 = b.Points; + _i$1 = 0; + while (true) { + if (!(_i$1 < _ref$1.$length)) { break; } + p$1 = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref$1.$array[_ref$1.$offset + _i$1]); + dot$1 = ((0 >= p$1.$length ? ($throwRuntimeError("index out of range"), undefined) : p$1.$array[p$1.$offset + 0]) + b.X) * (0 >= e.$length ? ($throwRuntimeError("index out of range"), undefined) : e.$array[e.$offset + 0]) + ((1 >= p$1.$length ? ($throwRuntimeError("index out of range"), undefined) : p$1.$array[p$1.$offset + 1]) + b.Y) * (1 >= e.$length ? ($throwRuntimeError("index out of range"), undefined) : e.$array[e.$offset + 1]); + if (bStart > dot$1) { + bStart = dot$1; + } + if (bEnd < dot$1) { + bEnd = dot$1; + } + _i$1++; + } + if (aStart > bEnd || aEnd < bStart) { + return true; + } + if (!(ptrType$5.nil === result)) { + overlap = 0; + if (aStart < bStart) { + result.AContainedInB = false; + if (aEnd < bEnd) { + overlap = aEnd - bStart; + result.BContainedInA = false; + } else { + option1 = aEnd - bStart; + option2 = bEnd - aStart; + if (option1 < option2) { + overlap = option1; + } else { + overlap = -option2; + } + } + } else { + result.BContainedInA = false; + if (aEnd > bEnd) { + overlap = aStart - bEnd; + result.AContainedInB = false; + } else { + option1$1 = aEnd - bStart; + option2$1 = bEnd - aStart; + if (option1$1 < option2$1) { + overlap = option1$1; + } else { + overlap = -option2$1; + } + } + } + currentOverlap = result.Overlap; + absoluteOverlap = overlap; + if (overlap < 0) { + absoluteOverlap = -overlap; + } + if (((0 === (x = result.Axis, (0 >= x.$length ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + 0]))) && (0 === (x$1 = result.Axis, (1 >= x$1.$length ? ($throwRuntimeError("index out of range"), undefined) : x$1.$array[x$1.$offset + 1])))) || currentOverlap > absoluteOverlap) { + sign = 1; + if (overlap < 0) { + sign = -1; + } + result.Overlap = absoluteOverlap; + result.OverlapX = (0 >= e.$length ? ($throwRuntimeError("index out of range"), undefined) : e.$array[e.$offset + 0]) * sign; + result.OverlapY = (1 >= e.$length ? ($throwRuntimeError("index out of range"), undefined) : e.$array[e.$offset + 1]) * sign; + } + result.Axis = e; + } + return false; + }; + WorldToVirtualGridPos = function(wx, wy) { + var virtualGridX, virtualGridY, wx, wy; + virtualGridX = ((math.Round(wx * 10) >> 0)); + virtualGridY = ((math.Round(wy * 10) >> 0)); + return [virtualGridX, virtualGridY]; + }; + $pkg.WorldToVirtualGridPos = WorldToVirtualGridPos; + VirtualGridToWorldPos = function(vx, vy) { + var vx, vy, wx, wy; + wx = (vx) * 0.1; + wy = (vy) * 0.1; + return [wx, wy]; + }; + $pkg.VirtualGridToWorldPos = VirtualGridToWorldPos; + WorldToPolygonColliderBLPos = function(wx, wy, halfBoundingW, halfBoundingH, topPadding, bottomPadding, leftPadding, rightPadding, collisionSpaceOffsetX, collisionSpaceOffsetY) { + var bottomPadding, collisionSpaceOffsetX, collisionSpaceOffsetY, halfBoundingH, halfBoundingW, leftPadding, rightPadding, topPadding, wx, wy; + return [wx - halfBoundingW - leftPadding + collisionSpaceOffsetX, wy - halfBoundingH - bottomPadding + collisionSpaceOffsetY]; + }; + $pkg.WorldToPolygonColliderBLPos = WorldToPolygonColliderBLPos; + PolygonColliderBLToWorldPos = function(cx, cy, halfBoundingW, halfBoundingH, topPadding, bottomPadding, leftPadding, rightPadding, collisionSpaceOffsetX, collisionSpaceOffsetY) { + var bottomPadding, collisionSpaceOffsetX, collisionSpaceOffsetY, cx, cy, halfBoundingH, halfBoundingW, leftPadding, rightPadding, topPadding; + return [cx + halfBoundingW + leftPadding - collisionSpaceOffsetX, cy + halfBoundingH + bottomPadding - collisionSpaceOffsetY]; + }; + $pkg.PolygonColliderBLToWorldPos = PolygonColliderBLToWorldPos; + PolygonColliderBLToVirtualGridPos = function(cx, cy, halfBoundingW, halfBoundingH, topPadding, bottomPadding, leftPadding, rightPadding, collisionSpaceOffsetX, collisionSpaceOffsetY) { + var _tuple, bottomPadding, collisionSpaceOffsetX, collisionSpaceOffsetY, cx, cy, halfBoundingH, halfBoundingW, leftPadding, rightPadding, topPadding, wx, wy; + _tuple = PolygonColliderBLToWorldPos(cx, cy, halfBoundingW, halfBoundingH, topPadding, bottomPadding, leftPadding, rightPadding, collisionSpaceOffsetX, collisionSpaceOffsetY); + wx = _tuple[0]; + wy = _tuple[1]; + return WorldToVirtualGridPos(wx, wy); + }; + $pkg.PolygonColliderBLToVirtualGridPos = PolygonColliderBLToVirtualGridPos; + calcHardPushbacksNorms = function(joinIndex, currPlayerDownsync, thatPlayerInNextFrame, playerCollider, playerShape, snapIntoPlatformOverlap, pEffPushback, pHardPushback, collision) { + var {_r, _ref, _tmp, _tmp$1, _tuple, barrierShape, collided, collision, currPlayerDownsync, isBarrier, joinIndex, obj, overlapResult, overlapped, pEffPushback, pHardPushback, playerCollider, playerShape, pushbackX, pushbackY, retCnt, snapIntoPlatformOverlap, thatPlayerInNextFrame, virtualGripToWall, x, xfac, $s, $r, $c} = $restore(this, {joinIndex, currPlayerDownsync, thatPlayerInNextFrame, playerCollider, playerShape, snapIntoPlatformOverlap, pEffPushback, pHardPushback, collision}); + /* */ $s = $s || 0; s: while (true) { switch ($s) { case 0: + virtualGripToWall = 0; + if ((16 === currPlayerDownsync.CharacterState) && (0 === thatPlayerInNextFrame.VelX) && (currPlayerDownsync.DirX === thatPlayerInNextFrame.DirX)) { + xfac = 1; + if (0 > thatPlayerInNextFrame.DirX) { + xfac = -xfac; + } + virtualGripToWall = xfac * (currPlayerDownsync.Speed) * 0.1; + } + retCnt = 0; + collided = playerCollider.CheckAllWithHolder(virtualGripToWall, 0, collision); + if (!collided) { + $s = -1; return retCnt; + } + /* while (true) { */ case 1: + obj = collision.FirstCollidedObject(); + if (ptrType$6.nil === obj) { + /* break; */ $s = 2; continue; + } + isBarrier = false; + _ref = obj.Data; + if ($assertType(_ref, ptrType$7, true)[1] || $assertType(_ref, ptrType$3, true)[1] || $assertType(_ref, ptrType$8, true)[1]) { + } else { + isBarrier = true; + } + if (!isBarrier) { + /* continue; */ $s = 1; continue; + } + barrierShape = $assertType(obj.Shape, ptrType$9); + _r = calcPushbacks(0, 0, playerShape, barrierShape); /* */ $s = 3; case 3: if($c) { $c = false; _r = _r.$blk(); } if (_r && _r.$blk !== undefined) { break s; } + _tuple = _r; + overlapped = _tuple[0]; + pushbackX = _tuple[1]; + pushbackY = _tuple[2]; + overlapResult = _tuple[3]; + if (!overlapped) { + /* continue; */ $s = 1; continue; + } + _tmp = (overlapResult.Overlap - snapIntoPlatformOverlap) * overlapResult.OverlapX; + _tmp$1 = (overlapResult.Overlap - snapIntoPlatformOverlap) * overlapResult.OverlapY; + pushbackX = _tmp; + pushbackY = _tmp$1; + Vec2D.copy((x = pHardPushback.$get(), ((retCnt < 0 || retCnt >= x.$length) ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + retCnt])), new Vec2D.ptr(overlapResult.OverlapX, overlapResult.OverlapY)); + pEffPushback.X = pEffPushback.X + (pushbackX); + pEffPushback.Y = pEffPushback.Y + (pushbackY); + retCnt = retCnt + (1) >> 0; + $s = 1; continue; + case 2: + $s = -1; return retCnt; + /* */ } return; } var $f = {$blk: calcHardPushbacksNorms, $c: true, $r, _r, _ref, _tmp, _tmp$1, _tuple, barrierShape, collided, collision, currPlayerDownsync, isBarrier, joinIndex, obj, overlapResult, overlapped, pEffPushback, pHardPushback, playerCollider, playerShape, pushbackX, pushbackY, retCnt, snapIntoPlatformOverlap, thatPlayerInNextFrame, virtualGripToWall, x, xfac, $s};return $f; + }; + deriveOpPattern = function(currPlayerDownsync, thatPlayerInNextFrame, currRenderFrame, chConfig, inputsBuffer) { + var _entry, _entry$1, _tmp, _tmp$1, _tmp$2, _tmp$3, _tmp$4, _tmp$5, _tuple, _tuple$1, canJumpWithinInertia, chConfig, currPlayerDownsync, currRenderFrame, decodedInput, delayedInputFrameId, delayedInputFrameIdForPrevRdf, delayedInputList, delayedInputListForPrevRdf, effDx, effDy, existent, existent$1, inputsBuffer, joinIndex, jumpedOrNot, patternId, prevBtnALevel, prevBtnBLevel, prevDecodedInput, thatPlayerInNextFrame, x, x$1; + delayedInputFrameId = ConvertToDelayedInputFrameId(currRenderFrame.Id); + delayedInputFrameIdForPrevRdf = ConvertToDelayedInputFrameId(currRenderFrame.Id - 1 >> 0); + if (0 >= delayedInputFrameId) { + return [-2, false, 0, 0]; + } + _tuple = (_entry = noOpSet[$Int32.keyFor(currPlayerDownsync.CharacterState)], _entry !== undefined ? [_entry.v, true] : [false, false]); + existent = _tuple[1]; + if (existent) { + return [-2, false, 0, 0]; + } + delayedInputList = $assertType(inputsBuffer.GetByFrameId(delayedInputFrameId), ptrType$10).InputList; + delayedInputListForPrevRdf = sliceType$3.nil; + if (0 < delayedInputFrameIdForPrevRdf) { + delayedInputListForPrevRdf = $assertType(inputsBuffer.GetByFrameId(delayedInputFrameIdForPrevRdf), ptrType$10).InputList; + } + jumpedOrNot = false; + joinIndex = currPlayerDownsync.JoinIndex; + decodedInput = decodeInput((x = joinIndex - 1 >> 0, ((x < 0 || x >= delayedInputList.$length) ? ($throwRuntimeError("index out of range"), undefined) : delayedInputList.$array[delayedInputList.$offset + x]))); + _tmp = 0; + _tmp$1 = 0; + effDx = _tmp; + effDy = _tmp$1; + _tmp$2 = 0; + _tmp$3 = 0; + prevBtnALevel = _tmp$2; + prevBtnBLevel = _tmp$3; + if (!(sliceType$3.nil === delayedInputListForPrevRdf)) { + prevDecodedInput = decodeInput((x$1 = joinIndex - 1 >> 0, ((x$1 < 0 || x$1 >= delayedInputListForPrevRdf.$length) ? ($throwRuntimeError("index out of range"), undefined) : delayedInputListForPrevRdf.$array[delayedInputListForPrevRdf.$offset + x$1]))); + prevBtnALevel = prevDecodedInput.BtnALevel; + prevBtnBLevel = prevDecodedInput.BtnBLevel; + } + if (0 === currPlayerDownsync.FramesToRecover) { + _tmp$4 = decodedInput.Dx; + _tmp$5 = decodedInput.Dy; + effDx = _tmp$4; + effDy = _tmp$5; + } + patternId = -1; + canJumpWithinInertia = currPlayerDownsync.CapturedByInertia && (((chConfig.InertiaFramesToRecover >> 1 >> 0)) > currPlayerDownsync.FramesToRecover); + if ((0 === currPlayerDownsync.FramesToRecover) || canJumpWithinInertia) { + if (decodedInput.BtnBLevel > prevBtnBLevel) { + if (chConfig.DashingEnabled && 0 > decodedInput.Dy && !((15 === currPlayerDownsync.CharacterState))) { + patternId = 5; + } else { + _tuple$1 = (_entry$1 = inAirSet[$Int32.keyFor(currPlayerDownsync.CharacterState)], _entry$1 !== undefined ? [_entry$1.v, true] : [false, false]); + existent$1 = _tuple$1[1]; + if (!existent$1) { + jumpedOrNot = true; + } else if (16 === currPlayerDownsync.CharacterState) { + jumpedOrNot = true; + } + } + } + } + if (-1 === patternId) { + if (0 < decodedInput.BtnALevel) { + if (decodedInput.BtnALevel > prevBtnALevel) { + if (0 > decodedInput.Dy) { + patternId = 3; + } else if (0 < decodedInput.Dy) { + patternId = 2; + } else { + patternId = 1; + } + } else { + patternId = 4; + } + } + } + return [patternId, jumpedOrNot, effDx, effDy]; + }; + ApplyInputFrameDownsyncDynamicsOnSingleRenderFrame = function(inputsBuffer, currRenderFrame, collisionSys, collisionSysMap, collisionSpaceOffsetX, collisionSpaceOffsetY, chConfigsOrderedByJoinIndex) { + var {_1, _2, _3, _4, _entry, _entry$1, _entry$2, _entry$3, _entry$4, _entry$5, _entry$6, _i, _i$1, _i$2, _i$3, _i$4, _i$5, _i$6, _i$7, _i$8, _i$9, _index, _index$1, _index$2, _r, _r$1, _r$2, _r$3, _r$4, _r$5, _r$6, _r$7, _ref, _ref$1, _ref$10, _ref$11, _ref$12, _ref$13, _ref$14, _ref$2, _ref$3, _ref$4, _ref$5, _ref$6, _ref$7, _ref$8, _ref$9, _tmp, _tmp$1, _tmp$10, _tmp$11, _tmp$12, _tmp$13, _tmp$14, _tmp$15, _tmp$16, _tmp$17, _tmp$18, _tmp$19, _tmp$2, _tmp$20, _tmp$21, _tmp$22, _tmp$23, _tmp$24, _tmp$25, _tmp$26, _tmp$27, _tmp$28, _tmp$29, _tmp$3, _tmp$30, _tmp$4, _tmp$5, _tmp$6, _tmp$7, _tmp$8, _tmp$9, _tuple, _tuple$1, _tuple$10, _tuple$11, _tuple$12, _tuple$13, _tuple$14, _tuple$15, _tuple$16, _tuple$17, _tuple$2, _tuple$3, _tuple$4, _tuple$5, _tuple$6, _tuple$7, _tuple$8, _tuple$9, alignedWithInertia, atkedPlayerInNextFrame, bShape, bulletBattleAttr, bulletCollider, bulletColliders, bulletLocalId, bulletShape, bulletStaticAttr, bulletWx, bulletWx$1, bulletWy, bulletWy$1, chConfig, chConfig$1, chConfig$2, chConfigsOrderedByJoinIndex, collided, collided$1, colliderHeight, colliderWidth, colliderWorldHeight, colliderWorldWidth, collision, collisionSpaceOffsetX, collisionSpaceOffsetY, collisionSys, collisionSysMap, currPlayerDownsync, currPlayerDownsync$1, currPlayerDownsync$2, currPlayerDownsync$3, currPlayerDownsync$4, currRenderFrame, defenderShape, effDx, effDy, effPushbacks, exactTurningAround, existent, existent$1, existent$2, existent$3, existent$4, existent$5, existent$6, exploded, explodedOnAnotherPlayer, fallStopping, fireballBullet, halfColliderHeightDiff, halfColliderWidthDiff, halfColliderWorldHeightDiff, hardPushbackCnt, hardPushbackNorm, hardPushbackNorm$1, hardPushbackNorms, hasBeenOnWallChState, hasBeenOnWallCollisionResultForSameChState, hasLockVel, hitboxSizeWx, hitboxSizeWx$1, hitboxSizeWy, hitboxSizeWy$1, i, i$1, i$2, i$3, i$4, i$5, i$6, i$7, inputsBuffer, isAnotherPlayer, isBarrier, isBullet, isWallJumping, joinIndex, joinIndex$1, joinIndex$2, joinIndex$3, jumpedOrNot, jumpedOrNotList, landedOnGravityPushback, meleeBullet, newBullet, newBullet$1, newBulletCollider, newBulletCollider$1, newVx, newVy, nextRenderFrameFireballBullets, nextRenderFrameMeleeBullets, nextRenderFramePlayers, normAlignmentWithGravity, normAlignmentWithHorizon1, normAlignmentWithHorizon2, obj, obj$1, offender, offender$1, offender$2, oldFramesToRecover, oldNextCharacterState, overlapResult, overlapped, overlapped$1, patternId, playerCollider, playerCollider$1, playerCollider$2, playerCollider$3, playerColliders, playerShape, prevCapturedByInertia, prevFireball, prevMelee, projectedMagnitude, pushbackVelX, pushbackVelY, pushbackX, pushbackY, roomCapacity, skillConfig, skillId, stoppingFromWalking, t, t$1, thatPlayerInNextFrame, thatPlayerInNextFrame$1, thatPlayerInNextFrame$2, thatPlayerInNextFrame$3, v, v$1, v$2, v$3, v$4, v$5, v$6, v$7, v$8, wx, wy, x, x$1, x$10, x$11, x$12, x$13, x$14, x$15, x$16, x$17, x$18, x$2, x$3, x$4, x$5, x$6, x$7, x$8, x$9, xfac, xfac$1, xfac$2, xfac$3, xfac$4, $s, $r, $c} = $restore(this, {inputsBuffer, currRenderFrame, collisionSys, collisionSysMap, collisionSpaceOffsetX, collisionSpaceOffsetY, chConfigsOrderedByJoinIndex}); + /* */ $s = $s || 0; s: while (true) { switch ($s) { case 0: + collision = resolv.NewCollision(); + roomCapacity = currRenderFrame.PlayersArr.$length; + nextRenderFramePlayers = $makeSlice(sliceType$4, roomCapacity); + _ref = currRenderFrame.PlayersArr; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + i = _i; + currPlayerDownsync = ((_i < 0 || _i >= _ref.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref.$array[_ref.$offset + _i]); + ((i < 0 || i >= nextRenderFramePlayers.$length) ? ($throwRuntimeError("index out of range"), undefined) : nextRenderFramePlayers.$array[nextRenderFramePlayers.$offset + i] = new PlayerDownsync.ptr(currPlayerDownsync.Id, currPlayerDownsync.VirtualGridX, currPlayerDownsync.VirtualGridY, currPlayerDownsync.DirX, currPlayerDownsync.DirY, currPlayerDownsync.VelX, currPlayerDownsync.VelY, currPlayerDownsync.Speed, currPlayerDownsync.BattleState, currPlayerDownsync.JoinIndex, currPlayerDownsync.ColliderRadius, currPlayerDownsync.Removed, currPlayerDownsync.Score, 0, currPlayerDownsync.FramesToRecover - 1 >> 0, currPlayerDownsync.FramesInChState + 1 >> 0, currPlayerDownsync.Hp, currPlayerDownsync.MaxHp, currPlayerDownsync.CharacterState, true, false, currPlayerDownsync.OnWallNormX, currPlayerDownsync.OnWallNormY, currPlayerDownsync.CapturedByInertia, currPlayerDownsync.ActiveSkillId, currPlayerDownsync.ActiveSkillHit, currPlayerDownsync.FramesInvinsible - 1 >> 0, currPlayerDownsync.BulletTeamId, currPlayerDownsync.ChCollisionTeamId, currPlayerDownsync.RevivalVirtualGridX, currPlayerDownsync.RevivalVirtualGridY)); + if (((i < 0 || i >= nextRenderFramePlayers.$length) ? ($throwRuntimeError("index out of range"), undefined) : nextRenderFramePlayers.$array[nextRenderFramePlayers.$offset + i]).FramesToRecover < 0) { + ((i < 0 || i >= nextRenderFramePlayers.$length) ? ($throwRuntimeError("index out of range"), undefined) : nextRenderFramePlayers.$array[nextRenderFramePlayers.$offset + i]).FramesToRecover = 0; + } + if (((i < 0 || i >= nextRenderFramePlayers.$length) ? ($throwRuntimeError("index out of range"), undefined) : nextRenderFramePlayers.$array[nextRenderFramePlayers.$offset + i]).FramesInvinsible < 0) { + ((i < 0 || i >= nextRenderFramePlayers.$length) ? ($throwRuntimeError("index out of range"), undefined) : nextRenderFramePlayers.$array[nextRenderFramePlayers.$offset + i]).FramesInvinsible = 0; + } + _i++; + } + nextRenderFrameMeleeBullets = $makeSlice(sliceType$5, 0, currRenderFrame.MeleeBullets.$length); + nextRenderFrameFireballBullets = $makeSlice(sliceType$6, 0, currRenderFrame.FireballBullets.$length); + effPushbacks = $makeSlice(sliceType$7, roomCapacity); + hardPushbackNorms = $makeSlice(sliceType$8, roomCapacity); + _ref$1 = currRenderFrame.PlayersArr; + _i$1 = 0; + while (true) { + if (!(_i$1 < _ref$1.$length)) { break; } + i$1 = _i$1; + ((i$1 < 0 || i$1 >= hardPushbackNorms.$length) ? ($throwRuntimeError("index out of range"), undefined) : hardPushbackNorms.$array[hardPushbackNorms.$offset + i$1] = $makeSlice(sliceType$7, 5)); + _i$1++; + } + jumpedOrNotList = $makeSlice(sliceType$9, roomCapacity); + bulletLocalId = currRenderFrame.BulletLocalIdCounter; + _ref$2 = currRenderFrame.PlayersArr; + _i$2 = 0; + /* while (true) { */ case 1: + /* if (!(_i$2 < _ref$2.$length)) { break; } */ if(!(_i$2 < _ref$2.$length)) { $s = 2; continue; } + newBullet = [newBullet]; + newBullet$1 = [newBullet$1]; + i$2 = _i$2; + currPlayerDownsync$1 = ((_i$2 < 0 || _i$2 >= _ref$2.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref$2.$array[_ref$2.$offset + _i$2]); + chConfig = ((i$2 < 0 || i$2 >= chConfigsOrderedByJoinIndex.$length) ? ($throwRuntimeError("index out of range"), undefined) : chConfigsOrderedByJoinIndex.$array[chConfigsOrderedByJoinIndex.$offset + i$2]); + thatPlayerInNextFrame = ((i$2 < 0 || i$2 >= nextRenderFramePlayers.$length) ? ($throwRuntimeError("index out of range"), undefined) : nextRenderFramePlayers.$array[nextRenderFramePlayers.$offset + i$2]); + _tuple = deriveOpPattern(currPlayerDownsync$1, thatPlayerInNextFrame, currRenderFrame, chConfig, inputsBuffer); + patternId = _tuple[0]; + jumpedOrNot = _tuple[1]; + effDx = _tuple[2]; + effDy = _tuple[3]; + ((i$2 < 0 || i$2 >= jumpedOrNotList.$length) ? ($throwRuntimeError("index out of range"), undefined) : jumpedOrNotList.$array[jumpedOrNotList.$offset + i$2] = jumpedOrNot); + joinIndex = currPlayerDownsync$1.JoinIndex; + _r = chConfig.SkillMapper(patternId, currPlayerDownsync$1); /* */ $s = 3; case 3: if($c) { $c = false; _r = _r.$blk(); } if (_r && _r.$blk !== undefined) { break s; } + skillId = _r; + _tuple$1 = (_entry = skills[$Int.keyFor(skillId)], _entry !== undefined ? [_entry.v, true] : [ptrType$2.nil, false]); + skillConfig = _tuple$1[0]; + existent = _tuple$1[1]; + if (existent) { + thatPlayerInNextFrame.ActiveSkillId = ((skillId >> 0)); + thatPlayerInNextFrame.ActiveSkillHit = 0; + thatPlayerInNextFrame.FramesToRecover = skillConfig.RecoveryFrames; + xfac = 1; + if (0 > thatPlayerInNextFrame.DirX) { + xfac = -xfac; + } + hasLockVel = false; + _ref$3 = (x = skillConfig.Hits, x$1 = thatPlayerInNextFrame.ActiveSkillHit, ((x$1 < 0 || x$1 >= x.$length) ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + x$1])); + if ($assertType(_ref$3, ptrType$3, true)[1]) { + v = _ref$3.$val; + newBullet[0] = $clone(v, MeleeBullet); + newBullet[0].BattleAttr = new BulletBattleAttr.ptr(bulletLocalId, currRenderFrame.Id, joinIndex, currPlayerDownsync$1.BulletTeamId); + bulletLocalId = bulletLocalId + (1) >> 0; + newBullet[0].BlState = 0; + nextRenderFrameMeleeBullets = $append(nextRenderFrameMeleeBullets, newBullet[0]); + if (!((-1 === v.Bullet.SelfLockVelX))) { + hasLockVel = true; + thatPlayerInNextFrame.VelX = $imul(xfac, v.Bullet.SelfLockVelX); + } + if (!((-1 === v.Bullet.SelfLockVelY))) { + hasLockVel = true; + thatPlayerInNextFrame.VelY = v.Bullet.SelfLockVelY; + } + } else if ($assertType(_ref$3, ptrType$8, true)[1]) { + v$1 = _ref$3.$val; + newBullet$1[0] = $clone(v$1, FireballBullet); + newBullet$1[0].BattleAttr = new BulletBattleAttr.ptr(bulletLocalId, currRenderFrame.Id, joinIndex, currPlayerDownsync$1.BulletTeamId); + bulletLocalId = bulletLocalId + (1) >> 0; + _tmp = currPlayerDownsync$1.VirtualGridX + ($imul(xfac, newBullet$1[0].Bullet.HitboxOffsetX)) >> 0; + _tmp$1 = currPlayerDownsync$1.VirtualGridY + newBullet$1[0].Bullet.HitboxOffsetY >> 0; + newBullet$1[0].VirtualGridX = _tmp; + newBullet$1[0].VirtualGridY = _tmp$1; + newBullet$1[0].DirX = xfac; + newBullet$1[0].DirY = 0; + newBullet$1[0].VelX = $imul(newBullet$1[0].Speed, xfac); + newBullet$1[0].VelY = 0; + newBullet$1[0].BlState = 0; + nextRenderFrameFireballBullets = $append(nextRenderFrameFireballBullets, newBullet$1[0]); + if (!((-1 === v$1.Bullet.SelfLockVelX))) { + hasLockVel = true; + thatPlayerInNextFrame.VelX = $imul(xfac, v$1.Bullet.SelfLockVelX); + } + if (!((-1 === v$1.Bullet.SelfLockVelY))) { + hasLockVel = true; + thatPlayerInNextFrame.VelY = v$1.Bullet.SelfLockVelY; + } + } + if (false === hasLockVel && false === currPlayerDownsync$1.InAir) { + thatPlayerInNextFrame.VelX = 0; + } + thatPlayerInNextFrame.CharacterState = skillConfig.BoundChState; + _i$2++; + /* continue; */ $s = 1; continue; + } + if (0 === currPlayerDownsync$1.FramesToRecover) { + prevCapturedByInertia = currPlayerDownsync$1.CapturedByInertia; + isWallJumping = chConfig.OnWallEnabled && (chConfig.WallJumpingInitVelX === intAbs(currPlayerDownsync$1.VelX)); + alignedWithInertia = true; + exactTurningAround = false; + stoppingFromWalking = false; + if (!((0 === effDx)) && (0 === thatPlayerInNextFrame.VelX)) { + alignedWithInertia = false; + } else if ((0 === effDx) && !((0 === thatPlayerInNextFrame.VelX))) { + alignedWithInertia = false; + stoppingFromWalking = true; + } else if (0 > ($imul(effDx, thatPlayerInNextFrame.VelX))) { + alignedWithInertia = false; + exactTurningAround = true; + } + if (!jumpedOrNot && !isWallJumping && !prevCapturedByInertia && !alignedWithInertia) { + thatPlayerInNextFrame.CapturedByInertia = true; + if (exactTurningAround) { + thatPlayerInNextFrame.CharacterState = 17; + thatPlayerInNextFrame.FramesToRecover = chConfig.InertiaFramesToRecover; + } else if (stoppingFromWalking) { + thatPlayerInNextFrame.FramesToRecover = chConfig.InertiaFramesToRecover; + } else { + thatPlayerInNextFrame.FramesToRecover = (((chConfig.InertiaFramesToRecover >> 1 >> 0)) + ((chConfig.InertiaFramesToRecover >> 2 >> 0)) >> 0); + } + } else { + thatPlayerInNextFrame.CapturedByInertia = false; + if (!((0 === effDx))) { + xfac$1 = 1; + if (0 > effDx) { + xfac$1 = -xfac$1; + } + thatPlayerInNextFrame.DirX = effDx; + thatPlayerInNextFrame.DirY = effDy; + if (isWallJumping) { + thatPlayerInNextFrame.VelX = $imul(xfac$1, intAbs(currPlayerDownsync$1.VelX)); + } else { + thatPlayerInNextFrame.VelX = $imul(xfac$1, currPlayerDownsync$1.Speed); + } + thatPlayerInNextFrame.CharacterState = 1; + } else { + thatPlayerInNextFrame.CharacterState = 0; + thatPlayerInNextFrame.VelX = 0; + } + } + } + _i$2++; + $s = 1; continue; + case 2: + playerColliders = $makeSlice(sliceType$10, currRenderFrame.PlayersArr.$length, currRenderFrame.PlayersArr.$length); + _ref$4 = currRenderFrame.PlayersArr; + _i$3 = 0; + /* while (true) { */ case 4: + /* if (!(_i$3 < _ref$4.$length)) { break; } */ if(!(_i$3 < _ref$4.$length)) { $s = 5; continue; } + i$3 = _i$3; + currPlayerDownsync$2 = ((_i$3 < 0 || _i$3 >= _ref$4.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref$4.$array[_ref$4.$offset + _i$3]); + joinIndex$1 = currPlayerDownsync$2.JoinIndex; + _tmp$2 = 0; + _tmp$3 = 0; + (x$2 = joinIndex$1 - 1 >> 0, ((x$2 < 0 || x$2 >= effPushbacks.$length) ? ($throwRuntimeError("index out of range"), undefined) : effPushbacks.$array[effPushbacks.$offset + x$2])).X = _tmp$2; + (x$3 = joinIndex$1 - 1 >> 0, ((x$3 < 0 || x$3 >= effPushbacks.$length) ? ($throwRuntimeError("index out of range"), undefined) : effPushbacks.$array[effPushbacks.$offset + x$3])).Y = _tmp$3; + thatPlayerInNextFrame$1 = ((i$3 < 0 || i$3 >= nextRenderFramePlayers.$length) ? ($throwRuntimeError("index out of range"), undefined) : nextRenderFramePlayers.$array[nextRenderFramePlayers.$offset + i$3]); + chConfig$1 = ((i$3 < 0 || i$3 >= chConfigsOrderedByJoinIndex.$length) ? ($throwRuntimeError("index out of range"), undefined) : chConfigsOrderedByJoinIndex.$array[chConfigsOrderedByJoinIndex.$offset + i$3]); + _tmp$4 = currPlayerDownsync$2.VirtualGridX + currPlayerDownsync$2.VelX >> 0; + _tmp$5 = currPlayerDownsync$2.VirtualGridY + currPlayerDownsync$2.VelY >> 0; + newVx = _tmp$4; + newVy = _tmp$5; + if (0 >= thatPlayerInNextFrame$1.Hp && (0 === thatPlayerInNextFrame$1.FramesToRecover)) { + _tmp$6 = currPlayerDownsync$2.RevivalVirtualGridX; + _tmp$7 = currPlayerDownsync$2.RevivalVirtualGridY; + newVx = _tmp$6; + newVy = _tmp$7; + thatPlayerInNextFrame$1.CharacterState = 10; + thatPlayerInNextFrame$1.FramesInChState = 10; + thatPlayerInNextFrame$1.FramesToRecover = chConfig$1.GetUpFramesToRecover; + thatPlayerInNextFrame$1.FramesInvinsible = chConfig$1.GetUpInvinsibleFrames; + thatPlayerInNextFrame$1.Hp = currPlayerDownsync$2.MaxHp; + if (0 === ((_r$1 = thatPlayerInNextFrame$1.JoinIndex % 2, _r$1 === _r$1 ? _r$1 : $throwRuntimeError("integer divide by zero")))) { + thatPlayerInNextFrame$1.DirX = -2; + thatPlayerInNextFrame$1.DirY = 0; + } else { + thatPlayerInNextFrame$1.DirX = 2; + thatPlayerInNextFrame$1.DirY = 0; + } + } + if (((i$3 < 0 || i$3 >= jumpedOrNotList.$length) ? ($throwRuntimeError("index out of range"), undefined) : jumpedOrNotList.$array[jumpedOrNotList.$offset + i$3])) { + if (16 === currPlayerDownsync$2.CharacterState) { + if (0 < ($imul(currPlayerDownsync$2.VelX, currPlayerDownsync$2.OnWallNormX))) { + newVx = newVx - (currPlayerDownsync$2.VelX) >> 0; + } + xfac$2 = -1; + if (0 > currPlayerDownsync$2.OnWallNormX) { + xfac$2 = -xfac$2; + } + newVx = newVx + (($imul(xfac$2, chConfig$1.WallJumpingInitVelX))) >> 0; + newVy = newVy + (chConfig$1.WallJumpingInitVelY) >> 0; + thatPlayerInNextFrame$1.VelX = (($imul(xfac$2, chConfig$1.WallJumpingInitVelX))); + thatPlayerInNextFrame$1.VelY = (chConfig$1.WallJumpingInitVelY); + thatPlayerInNextFrame$1.FramesToRecover = chConfig$1.WallJumpingFramesToRecover; + } else { + thatPlayerInNextFrame$1.VelY = (chConfig$1.JumpingInitVelY); + newVy = newVy + (chConfig$1.JumpingInitVelY) >> 0; + } + } + _tuple$2 = VirtualGridToWorldPos(newVx, newVy); + wx = _tuple$2[0]; + wy = _tuple$2[1]; + _tmp$8 = $imul(currPlayerDownsync$2.ColliderRadius, 2); + _tmp$9 = $imul(currPlayerDownsync$2.ColliderRadius, 4); + colliderWidth = _tmp$8; + colliderHeight = _tmp$9; + _1 = currPlayerDownsync$2.CharacterState; + if (_1 === (9)) { + _tmp$10 = $imul(currPlayerDownsync$2.ColliderRadius, 4); + _tmp$11 = $imul(currPlayerDownsync$2.ColliderRadius, 2); + colliderWidth = _tmp$10; + colliderHeight = _tmp$11; + } else if ((_1 === (8)) || (_1 === (4)) || (_1 === (5)) || (_1 === (16))) { + _tmp$12 = $imul(currPlayerDownsync$2.ColliderRadius, 2); + _tmp$13 = $imul(currPlayerDownsync$2.ColliderRadius, 2); + colliderWidth = _tmp$12; + colliderHeight = _tmp$13; + } + _tuple$3 = VirtualGridToWorldPos(colliderWidth, colliderHeight); + colliderWorldWidth = _tuple$3[0]; + colliderWorldHeight = _tuple$3[1]; + _r$2 = GenerateRectCollider(wx, wy, colliderWorldWidth, colliderWorldHeight, 0.1, 0.1, 0.1, 0.1, collisionSpaceOffsetX, collisionSpaceOffsetY, currPlayerDownsync$2, "Player"); /* */ $s = 6; case 6: if($c) { $c = false; _r$2 = _r$2.$blk(); } if (_r$2 && _r$2.$blk !== undefined) { break s; } + playerCollider = _r$2; + ((i$3 < 0 || i$3 >= playerColliders.$length) ? ($throwRuntimeError("index out of range"), undefined) : playerColliders.$array[playerColliders.$offset + i$3] = playerCollider); + $r = collisionSys.AddSingle(playerCollider); /* */ $s = 7; case 7: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; } + if (currPlayerDownsync$2.InAir) { + if ((16 === currPlayerDownsync$2.CharacterState) && !((i$3 < 0 || i$3 >= jumpedOrNotList.$length) ? ($throwRuntimeError("index out of range"), undefined) : jumpedOrNotList.$array[jumpedOrNotList.$offset + i$3])) { + thatPlayerInNextFrame$1.VelX = thatPlayerInNextFrame$1.VelX + (0) >> 0; + thatPlayerInNextFrame$1.VelY = chConfig$1.WallSlidingVelY; + } else if (15 === currPlayerDownsync$2.CharacterState) { + thatPlayerInNextFrame$1.VelX = thatPlayerInNextFrame$1.VelX + (0) >> 0; + } else { + thatPlayerInNextFrame$1.VelX = thatPlayerInNextFrame$1.VelX + (0) >> 0; + thatPlayerInNextFrame$1.VelY = thatPlayerInNextFrame$1.VelY + (-5) >> 0; + } + } + _i$3++; + $s = 4; continue; + case 5: + bulletColliders = $makeSlice(sliceType$10, 0, ((((currRenderFrame.MeleeBullets.$length + currRenderFrame.FireballBullets.$length >> 0)) << 1 >> 0))); + _ref$5 = currRenderFrame.FireballBullets; + _i$4 = 0; + /* while (true) { */ case 8: + /* if (!(_i$4 < _ref$5.$length)) { break; } */ if(!(_i$4 < _ref$5.$length)) { $s = 9; continue; } + prevFireball = ((_i$4 < 0 || _i$4 >= _ref$5.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref$5.$array[_ref$5.$offset + _i$4]); + fireballBullet = new FireballBullet.ptr(prevFireball.VirtualGridX, prevFireball.VirtualGridY, prevFireball.DirX, prevFireball.DirY, prevFireball.VelX, prevFireball.VelY, prevFireball.Speed, prevFireball.BlState, prevFireball.FramesInBlState + 1 >> 0, prevFireball.BattleAttr, prevFireball.Bullet); + /* */ if (IsFireballBulletAlive(fireballBullet, currRenderFrame)) { $s = 10; continue; } + /* */ $s = 11; continue; + /* if (IsFireballBulletAlive(fireballBullet, currRenderFrame)) { */ case 10: + /* */ if (IsFireballBulletActive(fireballBullet, currRenderFrame)) { $s = 12; continue; } + /* */ $s = 13; continue; + /* if (IsFireballBulletActive(fireballBullet, currRenderFrame)) { */ case 12: + _tuple$4 = VirtualGridToWorldPos(fireballBullet.VirtualGridX, fireballBullet.VirtualGridY); + bulletWx = _tuple$4[0]; + bulletWy = _tuple$4[1]; + _tuple$5 = VirtualGridToWorldPos(fireballBullet.Bullet.HitboxSizeX, fireballBullet.Bullet.HitboxSizeY); + hitboxSizeWx = _tuple$5[0]; + hitboxSizeWy = _tuple$5[1]; + _r$3 = GenerateRectCollider(bulletWx, bulletWy, hitboxSizeWx, hitboxSizeWy, 0.1, 0.1, 0.1, 0.1, collisionSpaceOffsetX, collisionSpaceOffsetY, fireballBullet, "FireballBullet"); /* */ $s = 15; case 15: if($c) { $c = false; _r$3 = _r$3.$blk(); } if (_r$3 && _r$3.$blk !== undefined) { break s; } + newBulletCollider = _r$3; + $r = collisionSys.AddSingle(newBulletCollider); /* */ $s = 16; case 16: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; } + bulletColliders = $append(bulletColliders, newBulletCollider); + fireballBullet.BlState = 1; + if (!((fireballBullet.BlState === prevFireball.BlState))) { + fireballBullet.FramesInBlState = 0; + } + _tmp$14 = fireballBullet.VirtualGridX + fireballBullet.VelX >> 0; + _tmp$15 = fireballBullet.VirtualGridY + fireballBullet.VelY >> 0; + fireballBullet.VirtualGridX = _tmp$14; + fireballBullet.VirtualGridY = _tmp$15; + $s = 14; continue; + /* } else { */ case 13: + offender = (x$4 = currRenderFrame.PlayersArr, x$5 = fireballBullet.BattleAttr.OffenderJoinIndex - 1 >> 0, ((x$5 < 0 || x$5 >= x$4.$length) ? ($throwRuntimeError("index out of range"), undefined) : x$4.$array[x$4.$offset + x$5])); + _tuple$6 = (_entry$1 = noOpSet[$Int32.keyFor(offender.CharacterState)], _entry$1 !== undefined ? [_entry$1.v, true] : [false, false]); + existent$1 = _tuple$6[1]; + if (existent$1) { + _i$4++; + /* continue; */ $s = 8; continue; + } + /* } */ case 14: + nextRenderFrameFireballBullets = $append(nextRenderFrameFireballBullets, fireballBullet); + /* } */ case 11: + _i$4++; + $s = 8; continue; + case 9: + _ref$6 = currRenderFrame.MeleeBullets; + _i$5 = 0; + /* while (true) { */ case 17: + /* if (!(_i$5 < _ref$6.$length)) { break; } */ if(!(_i$5 < _ref$6.$length)) { $s = 18; continue; } + prevMelee = ((_i$5 < 0 || _i$5 >= _ref$6.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref$6.$array[_ref$6.$offset + _i$5]); + meleeBullet = new MeleeBullet.ptr(prevMelee.BlState, prevMelee.FramesInBlState + 1 >> 0, prevMelee.BattleAttr, prevMelee.Bullet); + /* */ if (IsMeleeBulletAlive(meleeBullet, currRenderFrame)) { $s = 19; continue; } + /* */ $s = 20; continue; + /* if (IsMeleeBulletAlive(meleeBullet, currRenderFrame)) { */ case 19: + offender$1 = (x$6 = currRenderFrame.PlayersArr, x$7 = meleeBullet.BattleAttr.OffenderJoinIndex - 1 >> 0, ((x$7 < 0 || x$7 >= x$6.$length) ? ($throwRuntimeError("index out of range"), undefined) : x$6.$array[x$6.$offset + x$7])); + _tuple$7 = (_entry$2 = noOpSet[$Int32.keyFor(offender$1.CharacterState)], _entry$2 !== undefined ? [_entry$2.v, true] : [false, false]); + existent$2 = _tuple$7[1]; + if (existent$2) { + _i$5++; + /* continue; */ $s = 17; continue; + } + /* */ if (IsMeleeBulletActive(meleeBullet, currRenderFrame)) { $s = 21; continue; } + /* */ $s = 22; continue; + /* if (IsMeleeBulletActive(meleeBullet, currRenderFrame)) { */ case 21: + xfac$3 = 1; + if (0 > offender$1.DirX) { + xfac$3 = -xfac$3; + } + _tuple$8 = VirtualGridToWorldPos(offender$1.VirtualGridX + ($imul(xfac$3, meleeBullet.Bullet.HitboxOffsetX)) >> 0, offender$1.VirtualGridY); + bulletWx$1 = _tuple$8[0]; + bulletWy$1 = _tuple$8[1]; + _tuple$9 = VirtualGridToWorldPos(meleeBullet.Bullet.HitboxSizeX, meleeBullet.Bullet.HitboxSizeY); + hitboxSizeWx$1 = _tuple$9[0]; + hitboxSizeWy$1 = _tuple$9[1]; + _r$4 = GenerateRectCollider(bulletWx$1, bulletWy$1, hitboxSizeWx$1, hitboxSizeWy$1, 0.1, 0.1, 0.1, 0.1, collisionSpaceOffsetX, collisionSpaceOffsetY, meleeBullet, "MeleeBullet"); /* */ $s = 23; case 23: if($c) { $c = false; _r$4 = _r$4.$blk(); } if (_r$4 && _r$4.$blk !== undefined) { break s; } + newBulletCollider$1 = _r$4; + $r = collisionSys.AddSingle(newBulletCollider$1); /* */ $s = 24; case 24: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; } + bulletColliders = $append(bulletColliders, newBulletCollider$1); + meleeBullet.BlState = 1; + if (!((meleeBullet.BlState === prevMelee.BlState))) { + meleeBullet.FramesInBlState = 0; + } + /* } */ case 22: + nextRenderFrameMeleeBullets = $append(nextRenderFrameMeleeBullets, meleeBullet); + /* } */ case 20: + _i$5++; + $s = 17; continue; + case 18: + _ref$7 = currRenderFrame.PlayersArr; + _i$6 = 0; + /* while (true) { */ case 25: + /* if (!(_i$6 < _ref$7.$length)) { break; } */ if(!(_i$6 < _ref$7.$length)) { $s = 26; continue; } + i$4 = _i$6; + currPlayerDownsync$3 = ((_i$6 < 0 || _i$6 >= _ref$7.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref$7.$array[_ref$7.$offset + _i$6]); + joinIndex$2 = currPlayerDownsync$3.JoinIndex; + playerCollider$1 = ((i$4 < 0 || i$4 >= playerColliders.$length) ? ($throwRuntimeError("index out of range"), undefined) : playerColliders.$array[playerColliders.$offset + i$4]); + playerShape = $assertType(playerCollider$1.Shape, ptrType$9); + thatPlayerInNextFrame$2 = ((i$4 < 0 || i$4 >= nextRenderFramePlayers.$length) ? ($throwRuntimeError("index out of range"), undefined) : nextRenderFramePlayers.$array[nextRenderFramePlayers.$offset + i$4]); + _r$5 = calcHardPushbacksNorms(joinIndex$2, currPlayerDownsync$3, thatPlayerInNextFrame$2, playerCollider$1, playerShape, 0.1, (x$8 = joinIndex$2 - 1 >> 0, ((x$8 < 0 || x$8 >= effPushbacks.$length) ? ($throwRuntimeError("index out of range"), undefined) : effPushbacks.$array[effPushbacks.$offset + x$8])), $indexPtr(hardPushbackNorms.$array, hardPushbackNorms.$offset + (joinIndex$2 - 1 >> 0), ptrType$11), collision); /* */ $s = 27; case 27: if($c) { $c = false; _r$5 = _r$5.$blk(); } if (_r$5 && _r$5.$blk !== undefined) { break s; } + hardPushbackCnt = _r$5; + chConfig$2 = ((i$4 < 0 || i$4 >= chConfigsOrderedByJoinIndex.$length) ? ($throwRuntimeError("index out of range"), undefined) : chConfigsOrderedByJoinIndex.$array[chConfigsOrderedByJoinIndex.$offset + i$4]); + landedOnGravityPushback = false; + collided = playerCollider$1.CheckAllWithHolder(0, 0, collision); + /* */ if (collided) { $s = 28; continue; } + /* */ $s = 29; continue; + /* if (collided) { */ case 28: + /* while (true) { */ case 30: + obj = collision.FirstCollidedObject(); + if (ptrType$6.nil === obj) { + /* break; */ $s = 31; continue; + } + _tmp$16 = false; + _tmp$17 = false; + _tmp$18 = false; + isBarrier = _tmp$16; + isAnotherPlayer = _tmp$17; + isBullet = _tmp$18; + _ref$8 = obj.Data; + if ($assertType(_ref$8, ptrType$7, true)[1]) { + v$2 = _ref$8.$val; + if (18 === v$2.CharacterState) { + /* continue; */ $s = 30; continue; + } + isAnotherPlayer = true; + } else if ($assertType(_ref$8, ptrType$3, true)[1] || $assertType(_ref$8, ptrType$8, true)[1]) { + v$3 = _ref$8; + isBullet = true; + } else { + v$4 = _ref$8; + isBarrier = true; + } + if (isBullet) { + /* continue; */ $s = 30; continue; + } + bShape = $assertType(obj.Shape, ptrType$9); + _r$6 = calcPushbacks(0, 0, playerShape, bShape); /* */ $s = 32; case 32: if($c) { $c = false; _r$6 = _r$6.$blk(); } if (_r$6 && _r$6.$blk !== undefined) { break s; } + _tuple$10 = _r$6; + overlapped = _tuple$10[0]; + pushbackX = _tuple$10[1]; + pushbackY = _tuple$10[2]; + overlapResult = _tuple$10[3]; + if (!overlapped) { + /* continue; */ $s = 30; continue; + } + normAlignmentWithGravity = overlapResult.OverlapX * 0 + overlapResult.OverlapY * -1; + if (isAnotherPlayer) { + _tmp$19 = (overlapResult.Overlap - 0.2) * overlapResult.OverlapX; + _tmp$20 = (overlapResult.Overlap - 0.2) * overlapResult.OverlapY; + pushbackX = _tmp$19; + pushbackY = _tmp$20; + } + if (0 < hardPushbackCnt) { + i$5 = 0; + while (true) { + if (!(i$5 < hardPushbackCnt)) { break; } + hardPushbackNorm = $clone((x$9 = (x$10 = joinIndex$2 - 1 >> 0, ((x$10 < 0 || x$10 >= hardPushbackNorms.$length) ? ($throwRuntimeError("index out of range"), undefined) : hardPushbackNorms.$array[hardPushbackNorms.$offset + x$10])), ((i$5 < 0 || i$5 >= x$9.$length) ? ($throwRuntimeError("index out of range"), undefined) : x$9.$array[x$9.$offset + i$5])), Vec2D); + projectedMagnitude = pushbackX * hardPushbackNorm.X + pushbackY * hardPushbackNorm.Y; + if (isBarrier || (isAnotherPlayer && 0 > projectedMagnitude)) { + pushbackX = pushbackX - (projectedMagnitude * hardPushbackNorm.X); + pushbackY = pushbackY - (projectedMagnitude * hardPushbackNorm.Y); + } + i$5 = i$5 + (1) >> 0; + } + } + _index = joinIndex$2 - 1 >> 0; + ((_index < 0 || _index >= effPushbacks.$length) ? ($throwRuntimeError("index out of range"), undefined) : effPushbacks.$array[effPushbacks.$offset + _index]).X = ((_index < 0 || _index >= effPushbacks.$length) ? ($throwRuntimeError("index out of range"), undefined) : effPushbacks.$array[effPushbacks.$offset + _index]).X + (pushbackX); + _index$1 = joinIndex$2 - 1 >> 0; + ((_index$1 < 0 || _index$1 >= effPushbacks.$length) ? ($throwRuntimeError("index out of range"), undefined) : effPushbacks.$array[effPushbacks.$offset + _index$1]).Y = ((_index$1 < 0 || _index$1 >= effPushbacks.$length) ? ($throwRuntimeError("index out of range"), undefined) : effPushbacks.$array[effPushbacks.$offset + _index$1]).Y + (pushbackY); + if (0.5 < normAlignmentWithGravity) { + landedOnGravityPushback = true; + } + $s = 30; continue; + case 31: + /* } */ case 29: + if (landedOnGravityPushback) { + thatPlayerInNextFrame$2.InAir = false; + fallStopping = currPlayerDownsync$3.InAir && 0 >= currPlayerDownsync$3.VelY; + if (fallStopping) { + thatPlayerInNextFrame$2.VelY = 0; + thatPlayerInNextFrame$2.VelX = 0; + if (18 === thatPlayerInNextFrame$2.CharacterState) { + } else if (8 === thatPlayerInNextFrame$2.CharacterState) { + thatPlayerInNextFrame$2.CharacterState = 9; + thatPlayerInNextFrame$2.FramesToRecover = chConfig$2.LayDownFramesToRecover; + } else { + _2 = currPlayerDownsync$3.CharacterState; + if ((_2 === (8)) || (_2 === (4)) || (_2 === (5)) || (_2 === (16))) { + _tmp$21 = 0; + _tmp$22 = currPlayerDownsync$3.ColliderRadius; + halfColliderWidthDiff = _tmp$21; + halfColliderHeightDiff = _tmp$22; + _tuple$11 = VirtualGridToWorldPos(halfColliderWidthDiff, halfColliderHeightDiff); + halfColliderWorldHeightDiff = _tuple$11[1]; + _index$2 = joinIndex$2 - 1 >> 0; + ((_index$2 < 0 || _index$2 >= effPushbacks.$length) ? ($throwRuntimeError("index out of range"), undefined) : effPushbacks.$array[effPushbacks.$offset + _index$2]).Y = ((_index$2 < 0 || _index$2 >= effPushbacks.$length) ? ($throwRuntimeError("index out of range"), undefined) : effPushbacks.$array[effPushbacks.$offset + _index$2]).Y - (halfColliderWorldHeightDiff); + } + thatPlayerInNextFrame$2.CharacterState = 0; + thatPlayerInNextFrame$2.FramesToRecover = 0; + } + } else { + _tuple$12 = (_entry$3 = nonAttackingSet[$Int32.keyFor(thatPlayerInNextFrame$2.CharacterState)], _entry$3 !== undefined ? [_entry$3.v, true] : [false, false]); + existent$3 = _tuple$12[1]; + if (existent$3) { + if (18 === thatPlayerInNextFrame$2.CharacterState) { + } else if (9 === thatPlayerInNextFrame$2.CharacterState) { + if (0 === thatPlayerInNextFrame$2.FramesToRecover) { + thatPlayerInNextFrame$2.CharacterState = 10; + thatPlayerInNextFrame$2.FramesToRecover = chConfig$2.GetUpFramesToRecover; + } + } else if (10 === thatPlayerInNextFrame$2.CharacterState) { + if (0 === thatPlayerInNextFrame$2.FramesToRecover) { + thatPlayerInNextFrame$2.CharacterState = 0; + thatPlayerInNextFrame$2.FramesInvinsible = chConfig$2.GetUpInvinsibleFrames; + } + } + } + } + } + if (chConfig$2.OnWallEnabled) { + if (thatPlayerInNextFrame$2.InAir) { + _tuple$13 = (_entry$4 = noOpSet[$Int32.keyFor(currPlayerDownsync$3.CharacterState)], _entry$4 !== undefined ? [_entry$4.v, true] : [false, false]); + existent$4 = _tuple$13[1]; + if (!existent$4 && 0 < hardPushbackCnt) { + i$6 = 0; + while (true) { + if (!(i$6 < hardPushbackCnt)) { break; } + hardPushbackNorm$1 = $clone((x$11 = (x$12 = joinIndex$2 - 1 >> 0, ((x$12 < 0 || x$12 >= hardPushbackNorms.$length) ? ($throwRuntimeError("index out of range"), undefined) : hardPushbackNorms.$array[hardPushbackNorms.$offset + x$12])), ((i$6 < 0 || i$6 >= x$11.$length) ? ($throwRuntimeError("index out of range"), undefined) : x$11.$array[x$11.$offset + i$6])), Vec2D); + normAlignmentWithHorizon1 = hardPushbackNorm$1.X * 1 + hardPushbackNorm$1.Y * 0; + normAlignmentWithHorizon2 = hardPushbackNorm$1.X * -1 + hardPushbackNorm$1.Y * 0; + if (0.9 < normAlignmentWithHorizon1) { + thatPlayerInNextFrame$2.OnWall = true; + _tmp$23 = ((hardPushbackNorm$1.X >> 0)); + _tmp$24 = ((hardPushbackNorm$1.Y >> 0)); + thatPlayerInNextFrame$2.OnWallNormX = _tmp$23; + thatPlayerInNextFrame$2.OnWallNormY = _tmp$24; + break; + } + if (0.9 < normAlignmentWithHorizon2) { + thatPlayerInNextFrame$2.OnWall = true; + _tmp$25 = ((hardPushbackNorm$1.X >> 0)); + _tmp$26 = ((hardPushbackNorm$1.Y >> 0)); + thatPlayerInNextFrame$2.OnWallNormX = _tmp$25; + thatPlayerInNextFrame$2.OnWallNormY = _tmp$26; + break; + } + i$6 = i$6 + (1) >> 0; + } + } + } + if (!thatPlayerInNextFrame$2.OnWall) { + _tmp$27 = 0; + _tmp$28 = 0; + thatPlayerInNextFrame$2.OnWallNormX = _tmp$27; + thatPlayerInNextFrame$2.OnWallNormY = _tmp$28; + } + } + _i$6++; + $s = 25; continue; + case 26: + _ref$9 = bulletColliders; + _i$7 = 0; + /* while (true) { */ case 33: + /* if (!(_i$7 < _ref$9.$length)) { break; } */ if(!(_i$7 < _ref$9.$length)) { $s = 34; continue; } + bulletCollider = ((_i$7 < 0 || _i$7 >= _ref$9.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref$9.$array[_ref$9.$offset + _i$7]); + collided$1 = bulletCollider.CheckAllWithHolder(0, 0, collision); + bulletCollider.Space.RemoveSingle(bulletCollider); + if (!collided$1) { + _i$7++; + /* continue; */ $s = 33; continue; + } + exploded = false; + explodedOnAnotherPlayer = false; + bulletStaticAttr = ptrType$1.nil; + bulletBattleAttr = ptrType.nil; + _ref$10 = bulletCollider.Data; + if ($assertType(_ref$10, ptrType$3, true)[1]) { + v$5 = _ref$10.$val; + bulletStaticAttr = v$5.Bullet; + bulletBattleAttr = v$5.BattleAttr; + } else if ($assertType(_ref$10, ptrType$8, true)[1]) { + v$6 = _ref$10.$val; + bulletStaticAttr = v$6.Bullet; + bulletBattleAttr = v$6.BattleAttr; + } + bulletShape = $assertType(bulletCollider.Shape, ptrType$9); + offender$2 = (x$13 = currRenderFrame.PlayersArr, x$14 = bulletBattleAttr.OffenderJoinIndex - 1 >> 0, ((x$14 < 0 || x$14 >= x$13.$length) ? ($throwRuntimeError("index out of range"), undefined) : x$13.$array[x$13.$offset + x$14])); + /* while (true) { */ case 35: + obj$1 = collision.FirstCollidedObject(); + if (ptrType$6.nil === obj$1) { + /* break; */ $s = 36; continue; + } + defenderShape = $assertType(obj$1.Shape, ptrType$9); + _ref$11 = obj$1.Data; + /* */ if ($assertType(_ref$11, ptrType$7, true)[1]) { $s = 37; continue; } + /* */ $s = 38; continue; + /* if ($assertType(_ref$11, ptrType$7, true)[1]) { */ case 37: + t = _ref$11.$val; + if (bulletBattleAttr.OffenderJoinIndex === t.JoinIndex) { + /* continue; */ $s = 35; continue; + } + _r$7 = calcPushbacks(0, 0, bulletShape, defenderShape); /* */ $s = 40; case 40: if($c) { $c = false; _r$7 = _r$7.$blk(); } if (_r$7 && _r$7.$blk !== undefined) { break s; } + _tuple$14 = _r$7; + overlapped$1 = _tuple$14[0]; + if (!overlapped$1) { + /* continue; */ $s = 35; continue; + } + _tuple$15 = (_entry$5 = invinsibleSet[$Int32.keyFor(t.CharacterState)], _entry$5 !== undefined ? [_entry$5.v, true] : [false, false]); + existent$5 = _tuple$15[1]; + if (existent$5) { + /* continue; */ $s = 35; continue; + } + if (0 < t.FramesInvinsible) { + /* continue; */ $s = 35; continue; + } + exploded = true; + explodedOnAnotherPlayer = true; + xfac$4 = 1; + if (0 > offender$2.DirX) { + xfac$4 = -xfac$4; + } + atkedPlayerInNextFrame = (x$15 = t.JoinIndex - 1 >> 0, ((x$15 < 0 || x$15 >= nextRenderFramePlayers.$length) ? ($throwRuntimeError("index out of range"), undefined) : nextRenderFramePlayers.$array[nextRenderFramePlayers.$offset + x$15])); + atkedPlayerInNextFrame.Hp = atkedPlayerInNextFrame.Hp - (bulletStaticAttr.Damage) >> 0; + if (0 >= atkedPlayerInNextFrame.Hp) { + atkedPlayerInNextFrame.Hp = 0; + atkedPlayerInNextFrame.CharacterState = 18; + atkedPlayerInNextFrame.FramesToRecover = 60; + } else { + _tmp$29 = $imul(xfac$4, bulletStaticAttr.PushbackVelX); + _tmp$30 = bulletStaticAttr.PushbackVelY; + pushbackVelX = _tmp$29; + pushbackVelY = _tmp$30; + atkedPlayerInNextFrame.VelX = pushbackVelX; + atkedPlayerInNextFrame.VelY = pushbackVelY; + if (bulletStaticAttr.BlowUp) { + atkedPlayerInNextFrame.CharacterState = 8; + } else { + atkedPlayerInNextFrame.CharacterState = 3; + } + oldFramesToRecover = (x$16 = t.JoinIndex - 1 >> 0, ((x$16 < 0 || x$16 >= nextRenderFramePlayers.$length) ? ($throwRuntimeError("index out of range"), undefined) : nextRenderFramePlayers.$array[nextRenderFramePlayers.$offset + x$16])).FramesToRecover; + if (bulletStaticAttr.HitStunFrames > oldFramesToRecover) { + atkedPlayerInNextFrame.FramesToRecover = bulletStaticAttr.HitStunFrames; + } + } + $s = 39; continue; + /* } else { */ case 38: + t$1 = _ref$11; + exploded = true; + /* } */ case 39: + $s = 35; continue; + case 36: + if (exploded) { + _ref$12 = bulletCollider.Data; + if ($assertType(_ref$12, ptrType$3, true)[1]) { + v$7 = _ref$12.$val; + v$7.BlState = 2; + if (explodedOnAnotherPlayer) { + v$7.FramesInBlState = 0; + } else { + v$7.FramesInBlState = v$7.Bullet.ExplosionFrames + 1 >> 0; + } + } else if ($assertType(_ref$12, ptrType$8, true)[1]) { + v$8 = _ref$12.$val; + v$8.BlState = 2; + v$8.FramesInBlState = 0; + } + } + _i$7++; + $s = 33; continue; + case 34: + _ref$13 = currRenderFrame.PlayersArr; + _i$8 = 0; + while (true) { + if (!(_i$8 < _ref$13.$length)) { break; } + i$7 = _i$8; + currPlayerDownsync$4 = ((_i$8 < 0 || _i$8 >= _ref$13.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref$13.$array[_ref$13.$offset + _i$8]); + joinIndex$3 = currPlayerDownsync$4.JoinIndex; + playerCollider$2 = ((i$7 < 0 || i$7 >= playerColliders.$length) ? ($throwRuntimeError("index out of range"), undefined) : playerColliders.$array[playerColliders.$offset + i$7]); + thatPlayerInNextFrame$3 = ((i$7 < 0 || i$7 >= nextRenderFramePlayers.$length) ? ($throwRuntimeError("index out of range"), undefined) : nextRenderFramePlayers.$array[nextRenderFramePlayers.$offset + i$7]); + _tuple$16 = PolygonColliderBLToVirtualGridPos(playerCollider$2.X - (x$17 = joinIndex$3 - 1 >> 0, ((x$17 < 0 || x$17 >= effPushbacks.$length) ? ($throwRuntimeError("index out of range"), undefined) : effPushbacks.$array[effPushbacks.$offset + x$17])).X, playerCollider$2.Y - (x$18 = joinIndex$3 - 1 >> 0, ((x$18 < 0 || x$18 >= effPushbacks.$length) ? ($throwRuntimeError("index out of range"), undefined) : effPushbacks.$array[effPushbacks.$offset + x$18])).Y, playerCollider$2.W * 0.5, playerCollider$2.H * 0.5, 0, 0, 0, 0, collisionSpaceOffsetX, collisionSpaceOffsetY); + thatPlayerInNextFrame$3.VirtualGridX = _tuple$16[0]; + thatPlayerInNextFrame$3.VirtualGridY = _tuple$16[1]; + if (thatPlayerInNextFrame$3.InAir) { + oldNextCharacterState = thatPlayerInNextFrame$3.CharacterState; + _3 = oldNextCharacterState; + if ((_3 === (0)) || (_3 === (1)) || (_3 === (17))) { + if (((i$7 < 0 || i$7 >= jumpedOrNotList.$length) ? ($throwRuntimeError("index out of range"), undefined) : jumpedOrNotList.$array[jumpedOrNotList.$offset + i$7]) || (5 === currPlayerDownsync$4.CharacterState)) { + thatPlayerInNextFrame$3.CharacterState = 5; + } else { + thatPlayerInNextFrame$3.CharacterState = 4; + } + } else if (_3 === (2)) { + thatPlayerInNextFrame$3.CharacterState = 6; + } else if (_3 === (3)) { + thatPlayerInNextFrame$3.CharacterState = 7; + } + } + if (thatPlayerInNextFrame$3.OnWall) { + _4 = thatPlayerInNextFrame$3.CharacterState; + if ((_4 === (1)) || (_4 === (5)) || (_4 === (4))) { + hasBeenOnWallChState = (16 === currPlayerDownsync$4.CharacterState); + hasBeenOnWallCollisionResultForSameChState = currPlayerDownsync$4.OnWall && 12 <= thatPlayerInNextFrame$3.FramesInChState; + if (hasBeenOnWallChState || hasBeenOnWallCollisionResultForSameChState) { + thatPlayerInNextFrame$3.CharacterState = 16; + } + } + } + if (!((thatPlayerInNextFrame$3.CharacterState === currPlayerDownsync$4.CharacterState))) { + thatPlayerInNextFrame$3.FramesInChState = 0; + } + _tuple$17 = (_entry$6 = nonAttackingSet[$Int32.keyFor(thatPlayerInNextFrame$3.CharacterState)], _entry$6 !== undefined ? [_entry$6.v, true] : [false, false]); + existent$6 = _tuple$17[1]; + if (existent$6) { + thatPlayerInNextFrame$3.ActiveSkillId = -1; + thatPlayerInNextFrame$3.ActiveSkillHit = -1; + } + _i$8++; + } + _ref$14 = playerColliders; + _i$9 = 0; + while (true) { + if (!(_i$9 < _ref$14.$length)) { break; } + playerCollider$3 = ((_i$9 < 0 || _i$9 >= _ref$14.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref$14.$array[_ref$14.$offset + _i$9]); + playerCollider$3.Space.RemoveSingle(playerCollider$3); + _i$9++; + } + $s = -1; return new RoomDownsyncFrame.ptr(currRenderFrame.Id + 1 >> 0, nextRenderFramePlayers, new $Int64(0, 0), nextRenderFrameMeleeBullets, nextRenderFrameFireballBullets, new $Uint64(0, 0), false, bulletLocalId); + /* */ } return; } var $f = {$blk: ApplyInputFrameDownsyncDynamicsOnSingleRenderFrame, $c: true, $r, _1, _2, _3, _4, _entry, _entry$1, _entry$2, _entry$3, _entry$4, _entry$5, _entry$6, _i, _i$1, _i$2, _i$3, _i$4, _i$5, _i$6, _i$7, _i$8, _i$9, _index, _index$1, _index$2, _r, _r$1, _r$2, _r$3, _r$4, _r$5, _r$6, _r$7, _ref, _ref$1, _ref$10, _ref$11, _ref$12, _ref$13, _ref$14, _ref$2, _ref$3, _ref$4, _ref$5, _ref$6, _ref$7, _ref$8, _ref$9, _tmp, _tmp$1, _tmp$10, _tmp$11, _tmp$12, _tmp$13, _tmp$14, _tmp$15, _tmp$16, _tmp$17, _tmp$18, _tmp$19, _tmp$2, _tmp$20, _tmp$21, _tmp$22, _tmp$23, _tmp$24, _tmp$25, _tmp$26, _tmp$27, _tmp$28, _tmp$29, _tmp$3, _tmp$30, _tmp$4, _tmp$5, _tmp$6, _tmp$7, _tmp$8, _tmp$9, _tuple, _tuple$1, _tuple$10, _tuple$11, _tuple$12, _tuple$13, _tuple$14, _tuple$15, _tuple$16, _tuple$17, _tuple$2, _tuple$3, _tuple$4, _tuple$5, _tuple$6, _tuple$7, _tuple$8, _tuple$9, alignedWithInertia, atkedPlayerInNextFrame, bShape, bulletBattleAttr, bulletCollider, bulletColliders, bulletLocalId, bulletShape, bulletStaticAttr, bulletWx, bulletWx$1, bulletWy, bulletWy$1, chConfig, chConfig$1, chConfig$2, chConfigsOrderedByJoinIndex, collided, collided$1, colliderHeight, colliderWidth, colliderWorldHeight, colliderWorldWidth, collision, collisionSpaceOffsetX, collisionSpaceOffsetY, collisionSys, collisionSysMap, currPlayerDownsync, currPlayerDownsync$1, currPlayerDownsync$2, currPlayerDownsync$3, currPlayerDownsync$4, currRenderFrame, defenderShape, effDx, effDy, effPushbacks, exactTurningAround, existent, existent$1, existent$2, existent$3, existent$4, existent$5, existent$6, exploded, explodedOnAnotherPlayer, fallStopping, fireballBullet, halfColliderHeightDiff, halfColliderWidthDiff, halfColliderWorldHeightDiff, hardPushbackCnt, hardPushbackNorm, hardPushbackNorm$1, hardPushbackNorms, hasBeenOnWallChState, hasBeenOnWallCollisionResultForSameChState, hasLockVel, hitboxSizeWx, hitboxSizeWx$1, hitboxSizeWy, hitboxSizeWy$1, i, i$1, i$2, i$3, i$4, i$5, i$6, i$7, inputsBuffer, isAnotherPlayer, isBarrier, isBullet, isWallJumping, joinIndex, joinIndex$1, joinIndex$2, joinIndex$3, jumpedOrNot, jumpedOrNotList, landedOnGravityPushback, meleeBullet, newBullet, newBullet$1, newBulletCollider, newBulletCollider$1, newVx, newVy, nextRenderFrameFireballBullets, nextRenderFrameMeleeBullets, nextRenderFramePlayers, normAlignmentWithGravity, normAlignmentWithHorizon1, normAlignmentWithHorizon2, obj, obj$1, offender, offender$1, offender$2, oldFramesToRecover, oldNextCharacterState, overlapResult, overlapped, overlapped$1, patternId, playerCollider, playerCollider$1, playerCollider$2, playerCollider$3, playerColliders, playerShape, prevCapturedByInertia, prevFireball, prevMelee, projectedMagnitude, pushbackVelX, pushbackVelY, pushbackX, pushbackY, roomCapacity, skillConfig, skillId, stoppingFromWalking, t, t$1, thatPlayerInNextFrame, thatPlayerInNextFrame$1, thatPlayerInNextFrame$2, thatPlayerInNextFrame$3, v, v$1, v$2, v$3, v$4, v$5, v$6, v$7, v$8, wx, wy, x, x$1, x$10, x$11, x$12, x$13, x$14, x$15, x$16, x$17, x$18, x$2, x$3, x$4, x$5, x$6, x$7, x$8, x$9, xfac, xfac$1, xfac$2, xfac$3, xfac$4, $s};return $f; + }; + $pkg.ApplyInputFrameDownsyncDynamicsOnSingleRenderFrame = ApplyInputFrameDownsyncDynamicsOnSingleRenderFrame; + GenerateRectCollider = function(wx, wy, w, h, topPadding, bottomPadding, leftPadding, rightPadding, spaceOffsetX, spaceOffsetY, data, tag) { + var {$24r, _r, _tuple, blX, blY, bottomPadding, data, h, leftPadding, rightPadding, spaceOffsetX, spaceOffsetY, tag, topPadding, w, wx, wy, $s, $r, $c} = $restore(this, {wx, wy, w, h, topPadding, bottomPadding, leftPadding, rightPadding, spaceOffsetX, spaceOffsetY, data, tag}); + /* */ $s = $s || 0; s: while (true) { switch ($s) { case 0: + _tuple = WorldToPolygonColliderBLPos(wx, wy, w * 0.5, h * 0.5, topPadding, bottomPadding, leftPadding, rightPadding, spaceOffsetX, spaceOffsetY); + blX = _tuple[0]; + blY = _tuple[1]; + _r = generateRectColliderInCollisionSpace(blX, blY, leftPadding + w + rightPadding, bottomPadding + h + topPadding, data, tag); /* */ $s = 1; case 1: if($c) { $c = false; _r = _r.$blk(); } if (_r && _r.$blk !== undefined) { break s; } + $24r = _r; + $s = 2; case 2: return $24r; + /* */ } return; } var $f = {$blk: GenerateRectCollider, $c: true, $r, $24r, _r, _tuple, blX, blY, bottomPadding, data, h, leftPadding, rightPadding, spaceOffsetX, spaceOffsetY, tag, topPadding, w, wx, wy, $s};return $f; + }; + $pkg.GenerateRectCollider = GenerateRectCollider; + generateRectColliderInCollisionSpace = function(blX, blY, w, h, data, tag) { + var {blX, blY, collider, data, h, shape, tag, w, $s, $r, $c} = $restore(this, {blX, blY, w, h, data, tag}); + /* */ $s = $s || 0; s: while (true) { switch ($s) { case 0: + collider = resolv.NewObjectSingleTag(blX, blY, w, h, tag); + shape = resolv.NewRectangle(0, 0, w, h); + $r = collider.SetShape(shape); /* */ $s = 1; case 1: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; } + collider.Data = data; + $s = -1; return collider; + /* */ } return; } var $f = {$blk: generateRectColliderInCollisionSpace, $c: true, $r, blX, blY, collider, data, h, shape, tag, w, $s};return $f; + }; + GenerateConvexPolygonCollider = function(unalignedSrc, spaceOffsetX, spaceOffsetY, data, tag) { + var {_i, _i$1, _ref, _ref$1, _tmp, _tmp$1, aligned, collider, data, h, i, i$1, j, p, pi, pj, shape, spaceOffsetX, spaceOffsetY, tag, unalignedSrc, w, x, $s, $r, $c} = $restore(this, {unalignedSrc, spaceOffsetX, spaceOffsetY, data, tag}); + /* */ $s = $s || 0; s: while (true) { switch ($s) { case 0: + aligned = AlignPolygon2DToBoundingBox(unalignedSrc); + _tmp = 0; + _tmp$1 = 0; + w = _tmp; + h = _tmp$1; + shape = resolv.NewConvexPolygon(sliceType$11.nil); + _ref = aligned.Points; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + i = _i; + pi = ((_i < 0 || _i >= _ref.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref.$array[_ref.$offset + _i]); + _ref$1 = aligned.Points; + _i$1 = 0; + while (true) { + if (!(_i$1 < _ref$1.$length)) { break; } + j = _i$1; + pj = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref$1.$array[_ref$1.$offset + _i$1]); + if (i === j) { + _i$1++; + continue; + } + if (math.Abs(pj.X - pi.X) > w) { + w = math.Abs(pj.X - pi.X); + } + if (math.Abs(pj.Y - pi.Y) > h) { + h = math.Abs(pj.Y - pi.Y); + } + _i$1++; + } + _i++; + } + i$1 = 0; + while (true) { + if (!(i$1 < aligned.Points.$length)) { break; } + p = (x = aligned.Points, ((i$1 < 0 || i$1 >= x.$length) ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + i$1])); + shape.AddPoints(new sliceType$11([p.X, p.Y])); + i$1 = i$1 + (1) >> 0; + } + collider = resolv.NewObject(aligned.Anchor.X + spaceOffsetX, aligned.Anchor.Y + spaceOffsetY, w, h, new sliceType$12([tag])); + $r = collider.SetShape(shape); /* */ $s = 1; case 1: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; } + collider.Data = data; + $s = -1; return collider; + /* */ } return; } var $f = {$blk: GenerateConvexPolygonCollider, $c: true, $r, _i, _i$1, _ref, _ref$1, _tmp, _tmp$1, aligned, collider, data, h, i, i$1, j, p, pi, pj, shape, spaceOffsetX, spaceOffsetY, tag, unalignedSrc, w, x, $s};return $f; + }; + $pkg.GenerateConvexPolygonCollider = GenerateConvexPolygonCollider; + AlignPolygon2DToBoundingBox = function(input) { + var _i, _i$1, _ref, _ref$1, boundingBoxBL, i, input, output, p, p$1, x; + boundingBoxBL = new Vec2D.ptr(1.7e+308, 1.7e+308); + _ref = input.Points; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + p = ((_i < 0 || _i >= _ref.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref.$array[_ref.$offset + _i]); + if (p.X < boundingBoxBL.X) { + boundingBoxBL.X = p.X; + } + if (p.Y < boundingBoxBL.Y) { + boundingBoxBL.Y = p.Y; + } + _i++; + } + output = new Polygon2D.ptr(new Vec2D.ptr(input.Anchor.X + boundingBoxBL.X, input.Anchor.Y + boundingBoxBL.Y), $makeSlice(sliceType$13, input.Points.$length)); + _ref$1 = input.Points; + _i$1 = 0; + while (true) { + if (!(_i$1 < _ref$1.$length)) { break; } + i = _i$1; + p$1 = ((_i$1 < 0 || _i$1 >= _ref$1.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref$1.$array[_ref$1.$offset + _i$1]); + (x = output.Points, ((i < 0 || i >= x.$length) ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + i] = new Vec2D.ptr(p$1.X - boundingBoxBL.X, p$1.Y - boundingBoxBL.Y))); + _i$1++; + } + return output; + }; + $pkg.AlignPolygon2DToBoundingBox = AlignPolygon2DToBoundingBox; + NewMeleeBullet = function(bulletLocalId, originatedRenderFrameId, offenderJoinIndex, startupFrames, cancellableStFrame, cancellableEdFrame, activeFrames, hitStunFrames, blockStunFrames, pushbackVelX, pushbackVelY, damage, selfLockVelX, selfLockVelY, hitboxOffsetX, hitboxOffsetY, hitboxSizeX, hitboxSizeY, blowUp, teamId, blState, framesInBlState, explosionFrames, speciesId) { + var activeFrames, blState, blockStunFrames, blowUp, bulletLocalId, cancellableEdFrame, cancellableStFrame, damage, explosionFrames, framesInBlState, hitStunFrames, hitboxOffsetX, hitboxOffsetY, hitboxSizeX, hitboxSizeY, offenderJoinIndex, originatedRenderFrameId, pushbackVelX, pushbackVelY, selfLockVelX, selfLockVelY, speciesId, startupFrames, teamId; + return new MeleeBullet.ptr(blState, framesInBlState, new BulletBattleAttr.ptr(bulletLocalId, originatedRenderFrameId, offenderJoinIndex, teamId), new BulletConfig.ptr(startupFrames, cancellableStFrame, cancellableEdFrame, activeFrames, hitStunFrames, blockStunFrames, pushbackVelX, pushbackVelY, damage, selfLockVelX, selfLockVelY, hitboxOffsetX, hitboxOffsetY, hitboxSizeX, hitboxSizeY, blowUp, explosionFrames, speciesId, false)); + }; + $pkg.NewMeleeBullet = NewMeleeBullet; + NewFireballBullet = function(bulletLocalId, originatedRenderFrameId, offenderJoinIndex, startupFrames, cancellableStFrame, cancellableEdFrame, activeFrames, hitStunFrames, blockStunFrames, pushbackVelX, pushbackVelY, damage, selfLockVelX, selfLockVelY, hitboxOffsetX, hitboxOffsetY, hitboxSizeX, hitboxSizeY, blowUp, teamId, virtualGridX, virtualGridY, dirX, dirY, velX, velY, speed, blState, framesInBlState, explosionFrames, speciesId) { + var activeFrames, blState, blockStunFrames, blowUp, bulletLocalId, cancellableEdFrame, cancellableStFrame, damage, dirX, dirY, explosionFrames, framesInBlState, hitStunFrames, hitboxOffsetX, hitboxOffsetY, hitboxSizeX, hitboxSizeY, offenderJoinIndex, originatedRenderFrameId, pushbackVelX, pushbackVelY, selfLockVelX, selfLockVelY, speciesId, speed, startupFrames, teamId, velX, velY, virtualGridX, virtualGridY; + return new FireballBullet.ptr(virtualGridX, virtualGridY, dirX, dirY, velX, velY, speed, blState, framesInBlState, new BulletBattleAttr.ptr(bulletLocalId, originatedRenderFrameId, offenderJoinIndex, teamId), new BulletConfig.ptr(startupFrames, cancellableStFrame, cancellableEdFrame, activeFrames, hitStunFrames, blockStunFrames, pushbackVelX, pushbackVelY, damage, selfLockVelX, selfLockVelY, hitboxOffsetX, hitboxOffsetY, hitboxSizeX, hitboxSizeY, blowUp, explosionFrames, speciesId, false)); + }; + $pkg.NewFireballBullet = NewFireballBullet; + NewPlayerDownsync = function(id, virtualGridX, virtualGridY, dirX, dirY, velX, velY, framesToRecover, framesInChState, activeSkillId, activeSkillHit, framesInvinsible, speed, battleState, characterState, joinIndex, hp, maxHp, colliderRadius, inAir, onWall, onWallNormX, onWallNormY, capturedByInertia, bulletTeamId, chCollisionTeamId, revivalVirtualGridX, revivalVirtualGridY) { + var activeSkillHit, activeSkillId, battleState, bulletTeamId, capturedByInertia, chCollisionTeamId, characterState, colliderRadius, dirX, dirY, framesInChState, framesInvinsible, framesToRecover, hp, id, inAir, joinIndex, maxHp, onWall, onWallNormX, onWallNormY, revivalVirtualGridX, revivalVirtualGridY, speed, velX, velY, virtualGridX, virtualGridY; + return new PlayerDownsync.ptr(id, virtualGridX, virtualGridY, dirX, dirY, velX, velY, speed, battleState, joinIndex, colliderRadius, false, 0, 0, framesToRecover, framesInChState, hp, maxHp, characterState, inAir, onWall, onWallNormX, onWallNormY, capturedByInertia, activeSkillId, activeSkillHit, framesInvinsible, bulletTeamId, chCollisionTeamId, revivalVirtualGridX, revivalVirtualGridY); + }; + $pkg.NewPlayerDownsync = NewPlayerDownsync; + ptrType$7.methods = [{prop: "GetId", name: "GetId", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetJoinIndex", name: "GetJoinIndex", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetVirtualGridX", name: "GetVirtualGridX", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetVirtualGridY", name: "GetVirtualGridY", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetDirX", name: "GetDirX", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetDirY", name: "GetDirY", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetVelX", name: "GetVelX", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetVelY", name: "GetVelY", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetSpeed", name: "GetSpeed", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetHp", name: "GetHp", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetMaxHp", name: "GetMaxHp", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetCharacterState", name: "GetCharacterState", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetFramesToRecover", name: "GetFramesToRecover", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetFramesInChState", name: "GetFramesInChState", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetInAir", name: "GetInAir", pkg: "", typ: $funcType([], [$Bool], false)}, {prop: "GetOnWall", name: "GetOnWall", pkg: "", typ: $funcType([], [$Bool], false)}, {prop: "GetOnWallNormX", name: "GetOnWallNormX", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetColliderRadius", name: "GetColliderRadius", pkg: "", typ: $funcType([], [$Int32], false)}]; + ptrType$3.methods = [{prop: "GetBlState", name: "GetBlState", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetFramesInBlState", name: "GetFramesInBlState", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetBulletLocalId", name: "GetBulletLocalId", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetOffenderJoinIndex", name: "GetOffenderJoinIndex", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetOriginatedRenderFrameId", name: "GetOriginatedRenderFrameId", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetStartupFrames", name: "GetStartupFrames", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetActiveFrames", name: "GetActiveFrames", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetHitboxSizeX", name: "GetHitboxSizeX", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetHitboxSizeY", name: "GetHitboxSizeY", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetHitboxOffsetX", name: "GetHitboxOffsetX", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetHitboxOffsetY", name: "GetHitboxOffsetY", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetExplosionFrames", name: "GetExplosionFrames", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetSpeciesId", name: "GetSpeciesId", pkg: "", typ: $funcType([], [$Int32], false)}]; + ptrType$8.methods = [{prop: "GetVirtualGridX", name: "GetVirtualGridX", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetVirtualGridY", name: "GetVirtualGridY", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetDirX", name: "GetDirX", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetDirY", name: "GetDirY", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetVelX", name: "GetVelX", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetVelY", name: "GetVelY", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetSpeed", name: "GetSpeed", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetBlState", name: "GetBlState", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetFramesInBlState", name: "GetFramesInBlState", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetBulletLocalId", name: "GetBulletLocalId", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetOffenderJoinIndex", name: "GetOffenderJoinIndex", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetOriginatedRenderFrameId", name: "GetOriginatedRenderFrameId", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetStartupFrames", name: "GetStartupFrames", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetActiveFrames", name: "GetActiveFrames", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetHitboxSizeX", name: "GetHitboxSizeX", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetHitboxSizeY", name: "GetHitboxSizeY", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetHitboxOffsetX", name: "GetHitboxOffsetX", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetHitboxOffsetY", name: "GetHitboxOffsetY", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetExplosionFrames", name: "GetExplosionFrames", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetSpeciesId", name: "GetSpeciesId", pkg: "", typ: $funcType([], [$Int32], false)}]; + ptrType$4.methods = [{prop: "GetId", name: "GetId", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetCountdownNanos", name: "GetCountdownNanos", pkg: "", typ: $funcType([], [$Int64], false)}, {prop: "GetBackendUnconfirmedMask", name: "GetBackendUnconfirmedMask", pkg: "", typ: $funcType([], [$Uint64], false)}, {prop: "GetBulletLocalIdCounter", name: "GetBulletLocalIdCounter", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetShouldForceResync", name: "GetShouldForceResync", pkg: "", typ: $funcType([], [$Bool], false)}, {prop: "GetPlayersArr", name: "GetPlayersArr", pkg: "", typ: $funcType([], [sliceType$4], false)}, {prop: "GetMeleeBullets", name: "GetMeleeBullets", pkg: "", typ: $funcType([], [sliceType$5], false)}, {prop: "GetFireballBullets", name: "GetFireballBullets", pkg: "", typ: $funcType([], [sliceType$6], false)}]; + ptrType$10.methods = [{prop: "GetInputFrameId", name: "GetInputFrameId", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetInputList", name: "GetInputList", pkg: "", typ: $funcType([], [sliceType$3], false)}, {prop: "GetConfirmedList", name: "GetConfirmedList", pkg: "", typ: $funcType([], [$Uint64], false)}]; + ptrType$15.methods = [{prop: "GetSpeed", name: "GetSpeed", pkg: "", typ: $funcType([], [$Int32], false)}, {prop: "GetSpeciesId", name: "GetSpeciesId", pkg: "", typ: $funcType([], [$Int], false)}, {prop: "GetSpeciesName", name: "GetSpeciesName", pkg: "", typ: $funcType([], [$String], false)}]; + Vec2D.init("", [{prop: "X", name: "X", embedded: false, exported: true, typ: $Float64, tag: ""}, {prop: "Y", name: "Y", embedded: false, exported: true, typ: $Float64, tag: ""}]); + Polygon2D.init("", [{prop: "Anchor", name: "Anchor", embedded: false, exported: true, typ: ptrType$12, tag: ""}, {prop: "Points", name: "Points", embedded: false, exported: true, typ: sliceType$13, tag: ""}]); + PlayerDownsync.init("", [{prop: "Id", name: "Id", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "VirtualGridX", name: "VirtualGridX", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "VirtualGridY", name: "VirtualGridY", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "DirX", name: "DirX", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "DirY", name: "DirY", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "VelX", name: "VelX", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "VelY", name: "VelY", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "Speed", name: "Speed", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "BattleState", name: "BattleState", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "JoinIndex", name: "JoinIndex", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "ColliderRadius", name: "ColliderRadius", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "Removed", name: "Removed", embedded: false, exported: true, typ: $Bool, tag: ""}, {prop: "Score", name: "Score", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "LastMoveGmtMillis", name: "LastMoveGmtMillis", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "FramesToRecover", name: "FramesToRecover", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "FramesInChState", name: "FramesInChState", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "Hp", name: "Hp", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "MaxHp", name: "MaxHp", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "CharacterState", name: "CharacterState", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "InAir", name: "InAir", embedded: false, exported: true, typ: $Bool, tag: ""}, {prop: "OnWall", name: "OnWall", embedded: false, exported: true, typ: $Bool, tag: ""}, {prop: "OnWallNormX", name: "OnWallNormX", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "OnWallNormY", name: "OnWallNormY", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "CapturedByInertia", name: "CapturedByInertia", embedded: false, exported: true, typ: $Bool, tag: ""}, {prop: "ActiveSkillId", name: "ActiveSkillId", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "ActiveSkillHit", name: "ActiveSkillHit", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "FramesInvinsible", name: "FramesInvinsible", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "BulletTeamId", name: "BulletTeamId", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "ChCollisionTeamId", name: "ChCollisionTeamId", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "RevivalVirtualGridX", name: "RevivalVirtualGridX", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "RevivalVirtualGridY", name: "RevivalVirtualGridY", embedded: false, exported: true, typ: $Int32, tag: ""}]); + InputFrameDecoded.init("", [{prop: "Dx", name: "Dx", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "Dy", name: "Dy", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "BtnALevel", name: "BtnALevel", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "BtnBLevel", name: "BtnBLevel", embedded: false, exported: true, typ: $Int32, tag: ""}]); + Barrier.init("", [{prop: "Boundary", name: "Boundary", embedded: false, exported: true, typ: ptrType$13, tag: ""}]); + BulletConfig.init("", [{prop: "StartupFrames", name: "StartupFrames", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "CancellableStFrame", name: "CancellableStFrame", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "CancellableEdFrame", name: "CancellableEdFrame", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "ActiveFrames", name: "ActiveFrames", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "HitStunFrames", name: "HitStunFrames", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "BlockStunFrames", name: "BlockStunFrames", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "PushbackVelX", name: "PushbackVelX", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "PushbackVelY", name: "PushbackVelY", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "Damage", name: "Damage", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "SelfLockVelX", name: "SelfLockVelX", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "SelfLockVelY", name: "SelfLockVelY", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "HitboxOffsetX", name: "HitboxOffsetX", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "HitboxOffsetY", name: "HitboxOffsetY", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "HitboxSizeX", name: "HitboxSizeX", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "HitboxSizeY", name: "HitboxSizeY", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "BlowUp", name: "BlowUp", embedded: false, exported: true, typ: $Bool, tag: ""}, {prop: "ExplosionFrames", name: "ExplosionFrames", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "SpeciesId", name: "SpeciesId", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "CancelTransit", name: "CancelTransit", embedded: false, exported: true, typ: mapType, tag: ""}]); + BulletBattleAttr.init("", [{prop: "BulletLocalId", name: "BulletLocalId", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "OriginatedRenderFrameId", name: "OriginatedRenderFrameId", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "OffenderJoinIndex", name: "OffenderJoinIndex", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "TeamId", name: "TeamId", embedded: false, exported: true, typ: $Int32, tag: ""}]); + MeleeBullet.init("", [{prop: "BlState", name: "BlState", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "FramesInBlState", name: "FramesInBlState", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "BattleAttr", name: "BattleAttr", embedded: false, exported: true, typ: ptrType, tag: ""}, {prop: "Bullet", name: "Bullet", embedded: false, exported: true, typ: ptrType$1, tag: ""}]); + FireballBullet.init("", [{prop: "VirtualGridX", name: "VirtualGridX", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "VirtualGridY", name: "VirtualGridY", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "DirX", name: "DirX", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "DirY", name: "DirY", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "VelX", name: "VelX", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "VelY", name: "VelY", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "Speed", name: "Speed", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "BlState", name: "BlState", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "FramesInBlState", name: "FramesInBlState", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "BattleAttr", name: "BattleAttr", embedded: false, exported: true, typ: ptrType, tag: ""}, {prop: "Bullet", name: "Bullet", embedded: false, exported: true, typ: ptrType$1, tag: ""}]); + Skill.init("", [{prop: "BattleLocalId", name: "BattleLocalId", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "RecoveryFrames", name: "RecoveryFrames", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "RecoveryFramesOnBlock", name: "RecoveryFramesOnBlock", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "RecoveryFramesOnHit", name: "RecoveryFramesOnHit", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "ReleaseTriggerType", name: "ReleaseTriggerType", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "BoundChState", name: "BoundChState", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "Hits", name: "Hits", embedded: false, exported: true, typ: sliceType$2, tag: ""}]); + RoomDownsyncFrame.init("", [{prop: "Id", name: "Id", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "PlayersArr", name: "PlayersArr", embedded: false, exported: true, typ: sliceType$4, tag: ""}, {prop: "CountdownNanos", name: "CountdownNanos", embedded: false, exported: true, typ: $Int64, tag: ""}, {prop: "MeleeBullets", name: "MeleeBullets", embedded: false, exported: true, typ: sliceType$5, tag: ""}, {prop: "FireballBullets", name: "FireballBullets", embedded: false, exported: true, typ: sliceType$6, tag: ""}, {prop: "BackendUnconfirmedMask", name: "BackendUnconfirmedMask", embedded: false, exported: true, typ: $Uint64, tag: ""}, {prop: "ShouldForceResync", name: "ShouldForceResync", embedded: false, exported: true, typ: $Bool, tag: ""}, {prop: "BulletLocalIdCounter", name: "BulletLocalIdCounter", embedded: false, exported: true, typ: $Int32, tag: ""}]); + InputFrameDownsync.init("", [{prop: "InputFrameId", name: "InputFrameId", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "InputList", name: "InputList", embedded: false, exported: true, typ: sliceType$3, tag: ""}, {prop: "ConfirmedList", name: "ConfirmedList", embedded: false, exported: true, typ: $Uint64, tag: ""}]); + NpcPatrolCue.init("", [{prop: "FlAct", name: "FlAct", embedded: false, exported: true, typ: $Uint64, tag: ""}, {prop: "FrAct", name: "FrAct", embedded: false, exported: true, typ: $Uint64, tag: ""}, {prop: "X", name: "X", embedded: false, exported: true, typ: $Float64, tag: ""}, {prop: "Y", name: "Y", embedded: false, exported: true, typ: $Float64, tag: ""}]); + SkillMapperType.init([$Int, ptrType$7], [$Int], false); + CharacterConfig.init("", [{prop: "SpeciesId", name: "SpeciesId", embedded: false, exported: true, typ: $Int, tag: ""}, {prop: "SpeciesName", name: "SpeciesName", embedded: false, exported: true, typ: $String, tag: ""}, {prop: "InAirIdleFrameIdxTurningPoint", name: "InAirIdleFrameIdxTurningPoint", embedded: false, exported: true, typ: $Int, tag: ""}, {prop: "InAirIdleFrameIdxTurnedCycle", name: "InAirIdleFrameIdxTurnedCycle", embedded: false, exported: true, typ: $Int, tag: ""}, {prop: "LayDownFrames", name: "LayDownFrames", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "LayDownFramesToRecover", name: "LayDownFramesToRecover", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "GetUpInvinsibleFrames", name: "GetUpInvinsibleFrames", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "GetUpFramesToRecover", name: "GetUpFramesToRecover", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "Speed", name: "Speed", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "JumpingInitVelY", name: "JumpingInitVelY", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "JumpingFramesToRecover", name: "JumpingFramesToRecover", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "DashingEnabled", name: "DashingEnabled", embedded: false, exported: true, typ: $Bool, tag: ""}, {prop: "OnWallEnabled", name: "OnWallEnabled", embedded: false, exported: true, typ: $Bool, tag: ""}, {prop: "WallJumpingFramesToRecover", name: "WallJumpingFramesToRecover", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "WallJumpingInitVelX", name: "WallJumpingInitVelX", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "WallJumpingInitVelY", name: "WallJumpingInitVelY", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "WallSlidingVelY", name: "WallSlidingVelY", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "InertiaFramesToRecover", name: "InertiaFramesToRecover", embedded: false, exported: true, typ: $Int32, tag: ""}, {prop: "SkillMapper", name: "SkillMapper", embedded: false, exported: true, typ: SkillMapperType, tag: ""}]); + SatResult.init("", [{prop: "Overlap", name: "Overlap", embedded: false, exported: true, typ: $Float64, tag: ""}, {prop: "OverlapX", name: "OverlapX", embedded: false, exported: true, typ: $Float64, tag: ""}, {prop: "OverlapY", name: "OverlapY", embedded: false, exported: true, typ: $Float64, tag: ""}, {prop: "AContainedInB", name: "AContainedInB", embedded: false, exported: true, typ: $Bool, tag: ""}, {prop: "BContainedInA", name: "BContainedInA", embedded: false, exported: true, typ: $Bool, tag: ""}, {prop: "Axis", name: "Axis", embedded: false, exported: true, typ: resolv.Vector, tag: ""}]); + $init = function() { + $pkg.$init = function() {}; + /* */ var $f, $c = false, $s = 0, $r; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0: + $r = math.$init(); /* */ $s = 1; case 1: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; } + $r = resolv.$init(); /* */ $s = 2; case 2: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; } + $pkg.DIRECTION_DECODER = new sliceType$1([new sliceType([0, 0]), new sliceType([0, 2]), new sliceType([0, -2]), new sliceType([2, 0]), new sliceType([-2, 0]), new sliceType([1, 1]), new sliceType([-1, -1]), new sliceType([1, -1]), new sliceType([-1, 1])]); + skills = $makeMap($Int.keyFor, [{ k: 1, v: new Skill.ptr(0, 30, 30, 30, 1, 2, new sliceType$2([new MeleeBullet.ptr(0, 0, ptrType.nil, new BulletConfig.ptr(7, 13, 30, 22, 13, 9, 5, 0, 5, 1, -1, 120, 0, 240, 320, false, 9, 1, $makeMap($Int.keyFor, [{ k: 1, v: 2 }])))])) }, { k: 2, v: new Skill.ptr(0, 36, 36, 36, 1, 11, new sliceType$2([new MeleeBullet.ptr(0, 0, ptrType.nil, new BulletConfig.ptr(18, 22, 36, 18, 18, 9, 5, 0, 5, 1, -1, 180, 0, 240, 320, false, 9, 1, $makeMap($Int.keyFor, [{ k: 1, v: 3 }])))])) }, { k: 3, v: new Skill.ptr(0, 50, 50, 50, 1, 12, new sliceType$2([new MeleeBullet.ptr(0, 0, ptrType.nil, new BulletConfig.ptr(8, 0, 0, 30, 999999999, 9, 20, 70, 10, 5, 50, 160, 80, 320, 320, true, 9, 1, false))])) }, { k: 4, v: new Skill.ptr(0, 30, 30, 30, 1, 2, new sliceType$2([new MeleeBullet.ptr(0, 0, ptrType.nil, new BulletConfig.ptr(7, 13, 30, 22, 13, 9, 5, 0, 5, 1, -1, 120, 0, 240, 320, false, 15, 2, $makeMap($Int.keyFor, [{ k: 1, v: 5 }])))])) }, { k: 5, v: new Skill.ptr(0, 36, 36, 36, 1, 11, new sliceType$2([new MeleeBullet.ptr(0, 0, ptrType.nil, new BulletConfig.ptr(18, 23, 36, 18, 18, 9, 5, 0, 5, 1, -1, 180, 0, 240, 320, false, 15, 2, $makeMap($Int.keyFor, [{ k: 1, v: 6 }])))])) }, { k: 6, v: new Skill.ptr(0, 45, 45, 45, 1, 12, new sliceType$2([new MeleeBullet.ptr(0, 0, ptrType.nil, new BulletConfig.ptr(8, 0, 0, 28, 999999999, 9, 20, 30, 10, -1, -1, 240, 0, 320, 320, true, 15, 2, false))])) }, { k: 7, v: new Skill.ptr(0, 30, 30, 30, 1, 2, new sliceType$2([new MeleeBullet.ptr(0, 0, ptrType.nil, new BulletConfig.ptr(7, 13, 30, 22, 13, 9, 5, 0, 5, -1, -1, 120, 0, 240, 320, false, 9, 1, $makeMap($Int.keyFor, [{ k: 1, v: 8 }])))])) }, { k: 8, v: new Skill.ptr(0, 36, 36, 36, 1, 11, new sliceType$2([new MeleeBullet.ptr(0, 0, ptrType.nil, new BulletConfig.ptr(18, 22, 36, 18, 18, 9, 5, 0, 5, 1, -1, 180, 0, 240, 320, false, 9, 1, $makeMap($Int.keyFor, [{ k: 1, v: 9 }])))])) }, { k: 9, v: new Skill.ptr(0, 40, 40, 40, 1, 12, new sliceType$2([new MeleeBullet.ptr(0, 0, ptrType.nil, new BulletConfig.ptr(7, 0, 0, 30, 999999999, 9, 20, 40, 10, 10, -1, 100, 0, 320, 320, true, 9, 1, false))])) }, { k: 10, v: new Skill.ptr(0, 38, 38, 38, 1, 13, new sliceType$2([new FireballBullet.ptr(0, 0, 0, 0, 0, 0, 60, 0, 0, ptrType.nil, new BulletConfig.ptr(10, 0, 0, 999999999, 15, 9, 20, 0, 22, -1, -1, 320, 100, 640, 480, false, 30, 1, false))])) }, { k: 11, v: new Skill.ptr(0, 60, 60, 60, 1, 14, new sliceType$2([new MeleeBullet.ptr(0, 0, ptrType.nil, new BulletConfig.ptr(3, 0, 0, 25, 999999999, 9, 20, 70, 35, 10, 80, 80, 0, 400, 640, true, 15, 3, false))])) }, { k: 12, v: new Skill.ptr(0, 10, 10, 10, 1, 15, new sliceType$2([new MeleeBullet.ptr(0, 0, ptrType.nil, new BulletConfig.ptr(3, 0, 0, 0, 0, 0, -1, -1, 0, 60, 0, 0, 0, 0, 0, false, 0, 0, false))])) }, { k: 13, v: new Skill.ptr(0, 12, 12, 12, 1, 15, new sliceType$2([new MeleeBullet.ptr(0, 0, ptrType.nil, new BulletConfig.ptr(3, 0, 0, 0, 0, 0, -1, -1, 0, 80, 0, 0, 0, 0, 0, false, 0, 0, false))])) }, { k: 14, v: new Skill.ptr(0, 8, 8, 8, 1, 15, new sliceType$2([new MeleeBullet.ptr(0, 0, ptrType.nil, new BulletConfig.ptr(4, 0, 0, 0, 999999999, 0, -1, -1, 0, 50, 0, 0, 0, 0, 0, false, 0, 0, false))])) }, { k: 15, v: new Skill.ptr(0, 48, 48, 48, 1, 13, new sliceType$2([new FireballBullet.ptr(0, 0, 0, 0, 0, 0, 40, 0, 0, ptrType.nil, new BulletConfig.ptr(12, 0, 0, 999999999, 15, 9, 30, 0, 18, -1, -1, 240, 80, 480, 320, false, 30, 2, false))])) }, { k: 16, v: new Skill.ptr(0, 60, 60, 60, 1, 13, new sliceType$2([new FireballBullet.ptr(0, 0, 0, 0, 0, 0, 40, 0, 0, ptrType.nil, new BulletConfig.ptr(16, 0, 0, 999999999, 999999999, 9, 30, 70, 30, -1, -1, 240, 80, 480, 320, true, 30, 3, false))])) }, { k: 255, v: new Skill.ptr(0, 30, 30, 30, 1, 6, new sliceType$2([new MeleeBullet.ptr(0, 0, ptrType.nil, new BulletConfig.ptr(3, 0, 0, 20, 18, 9, 5, 0, 5, -1, -1, 120, 0, 320, 240, false, 9, 1, false))])) }, { k: 256, v: new Skill.ptr(0, 20, 20, 20, 1, 6, new sliceType$2([new MeleeBullet.ptr(0, 0, ptrType.nil, new BulletConfig.ptr(3, 0, 0, 10, 15, 9, 5, 0, 5, -1, -1, 120, 0, 320, 240, false, 15, 2, false))])) }, { k: 257, v: new Skill.ptr(0, 30, 30, 30, 1, 6, new sliceType$2([new MeleeBullet.ptr(0, 0, ptrType.nil, new BulletConfig.ptr(4, 0, 0, 20, 9, 5, 5, 0, 5, -1, -1, 120, 0, 320, 240, false, 9, 1, false))])) }]); + $pkg.Characters = $makeMap($Int.keyFor, [{ k: 0, v: new CharacterConfig.ptr(0, "MonkGirl", 11, 1, 16, 16, 10, 27, 21, 80, 2, true, true, 8, 28, 70, -10, 9, (function(patternId, currPlayerDownsync) { + var _entry, _entry$1, _ref, _tuple, _tuple$1, currPlayerDownsync, existent1, existent2, nextSkillId, patternId, skillConfig, v, x, x$1; + if (1 === patternId) { + if (0 === currPlayerDownsync.FramesToRecover) { + if (currPlayerDownsync.InAir) { + return 255; + } else { + return 1; + } + } else { + _tuple = (_entry = skills[$Int.keyFor(((currPlayerDownsync.ActiveSkillId >> 0)))], _entry !== undefined ? [_entry.v, true] : [ptrType$2.nil, false]); + skillConfig = _tuple[0]; + existent1 = _tuple[1]; + if (existent1) { + _ref = (x = skillConfig.Hits, x$1 = currPlayerDownsync.ActiveSkillHit, ((x$1 < 0 || x$1 >= x.$length) ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + x$1])); + if ($assertType(_ref, ptrType$3, true)[1]) { + v = _ref.$val; + if (v.Bullet.CancellableStFrame <= currPlayerDownsync.FramesInChState && currPlayerDownsync.FramesInChState < v.Bullet.CancellableEdFrame) { + _tuple$1 = (_entry$1 = v.Bullet.CancelTransit[$Int.keyFor(patternId)], _entry$1 !== undefined ? [_entry$1.v, true] : [0, false]); + nextSkillId = _tuple$1[0]; + existent2 = _tuple$1[1]; + if (existent2) { + return nextSkillId; + } + } + } + } + } + } else if (3 === patternId) { + if ((0 === currPlayerDownsync.FramesToRecover) && !currPlayerDownsync.InAir) { + return 15; + } + } else if (5 === patternId) { + if (!currPlayerDownsync.InAir) { + return 12; + } + } + return -1; + })) }, { k: 1, v: new CharacterConfig.ptr(1, "KnifeGirl", 9, 1, 16, 16, 10, 27, 22, 75, 2, true, true, 8, 28, 70, -10, 9, (function(patternId, currPlayerDownsync) { + var _entry, _entry$1, _ref, _tuple, _tuple$1, currPlayerDownsync, existent1, existent2, nextSkillId, patternId, skillConfig, v, x, x$1; + if (1 === patternId) { + if (0 === currPlayerDownsync.FramesToRecover) { + if (currPlayerDownsync.InAir) { + return 256; + } else { + return 4; + } + } else { + _tuple = (_entry = skills[$Int.keyFor(((currPlayerDownsync.ActiveSkillId >> 0)))], _entry !== undefined ? [_entry.v, true] : [ptrType$2.nil, false]); + skillConfig = _tuple[0]; + existent1 = _tuple[1]; + if (existent1) { + _ref = (x = skillConfig.Hits, x$1 = currPlayerDownsync.ActiveSkillHit, ((x$1 < 0 || x$1 >= x.$length) ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + x$1])); + if ($assertType(_ref, ptrType$3, true)[1]) { + v = _ref.$val; + if (v.Bullet.CancellableStFrame <= currPlayerDownsync.FramesInChState && currPlayerDownsync.FramesInChState < v.Bullet.CancellableEdFrame) { + _tuple$1 = (_entry$1 = v.Bullet.CancelTransit[$Int.keyFor(patternId)], _entry$1 !== undefined ? [_entry$1.v, true] : [0, false]); + nextSkillId = _tuple$1[0]; + existent2 = _tuple$1[1]; + if (existent2) { + return nextSkillId; + } + } + } + } + } + } else if (3 === patternId) { + if ((0 === currPlayerDownsync.FramesToRecover) && !currPlayerDownsync.InAir) { + return 16; + } + } else if (5 === patternId) { + return 13; + } + return -1; + })) }, { k: 4096, v: new CharacterConfig.ptr(4096, "Monk", 42, 2, 14, 14, 8, 30, 18, 78, 2, true, false, 0, 0, 0, 0, 9, (function(patternId, currPlayerDownsync) { + var _entry, _entry$1, _ref, _tuple, _tuple$1, currPlayerDownsync, existent1, existent2, nextSkillId, patternId, skillConfig, v, x, x$1; + if (1 === patternId) { + if (0 === currPlayerDownsync.FramesToRecover) { + if (currPlayerDownsync.InAir) { + return 257; + } else { + return 7; + } + } else { + _tuple = (_entry = skills[$Int.keyFor(((currPlayerDownsync.ActiveSkillId >> 0)))], _entry !== undefined ? [_entry.v, true] : [ptrType$2.nil, false]); + skillConfig = _tuple[0]; + existent1 = _tuple[1]; + if (existent1) { + _ref = (x = skillConfig.Hits, x$1 = currPlayerDownsync.ActiveSkillHit, ((x$1 < 0 || x$1 >= x.$length) ? ($throwRuntimeError("index out of range"), undefined) : x.$array[x.$offset + x$1])); + if ($assertType(_ref, ptrType$3, true)[1]) { + v = _ref.$val; + if (v.Bullet.CancellableStFrame <= currPlayerDownsync.FramesInChState && currPlayerDownsync.FramesInChState < v.Bullet.CancellableEdFrame) { + _tuple$1 = (_entry$1 = v.Bullet.CancelTransit[$Int.keyFor(patternId)], _entry$1 !== undefined ? [_entry$1.v, true] : [0, false]); + nextSkillId = _tuple$1[0]; + existent2 = _tuple$1[1]; + if (existent2) { + return nextSkillId; + } + } + } + } + } + } else if (2 === patternId) { + if ((0 === currPlayerDownsync.FramesToRecover) && !currPlayerDownsync.InAir) { + return 11; + } + } else if (3 === patternId) { + if ((0 === currPlayerDownsync.FramesToRecover) && !currPlayerDownsync.InAir) { + return 10; + } + } else if (5 === patternId) { + if (!currPlayerDownsync.InAir) { + return 14; + } + } + return -1; + })) }]); + inAirSet = $makeMap($Int32.keyFor, [{ k: 4, v: true }, { k: 5, v: true }, { k: 6, v: true }, { k: 7, v: true }, { k: 8, v: true }, { k: 16, v: true }, { k: 15, v: true }]); + noOpSet = $makeMap($Int32.keyFor, [{ k: 3, v: true }, { k: 7, v: true }, { k: 8, v: true }, { k: 9, v: true }, { k: 18, v: true }]); + invinsibleSet = $makeMap($Int32.keyFor, [{ k: 8, v: true }, { k: 9, v: true }, { k: 10, v: true }, { k: 18, v: true }]); + nonAttackingSet = $makeMap($Int32.keyFor, [{ k: 0, v: true }, { k: 1, v: true }, { k: 4, v: true }, { k: 5, v: true }, { k: 3, v: true }, { k: 7, v: true }, { k: 8, v: true }, { k: 9, v: true }, { k: 10, v: true }, { k: 18, v: true }]); + /* */ } return; } if ($f === undefined) { $f = { $blk: $init }; } $f.$s = $s; $f.$r = $r; return $f; + }; + $pkg.$init = $init; + return $pkg; +})(); +$packages["jsexport"] = (function() { + var $pkg = {}, $init, js, battle, resolv, sliceType, ptrType, sliceType$1, ptrType$1, ptrType$2, sliceType$2, ptrType$3, sliceType$3, ptrType$4, sliceType$4, ptrType$5, sliceType$5, ptrType$6, funcType, funcType$1, funcType$2, funcType$3, funcType$4, funcType$5, funcType$6, funcType$7, funcType$8, funcType$9, funcType$10, funcType$11, ptrType$7, funcType$12, funcType$13, funcType$14, funcType$15, sliceType$6, funcType$16, ptrType$8, ptrType$9, ptrType$10, mapType, sliceType$7, funcType$17, funcType$18, funcType$19, funcType$20, mapType$1, NewInputFrameDownsync, NewRingBufferJs, NewCollisionSpaceJs, NewVec2DJs, NewPolygon2DJs, NewBarrierJs, NewPlayerDownsyncJs, NewMeleeBulletJs, NewFireballBulletJs, NewNpcPatrolCue, NewRoomDownsyncFrameJs, GetCollisionSpaceObjsJs, GenerateConvexPolygonColliderJs, GetCharacterConfigsOrderedByJoinIndex, ApplyInputFrameDownsyncDynamicsOnSingleRenderFrameJs, main; + js = $packages["github.com/gopherjs/gopherjs/js"]; + battle = $packages["jsexport/battle"]; + resolv = $packages["resolv"]; + sliceType = $sliceType($Uint64); + ptrType = $ptrType(battle.Vec2D); + sliceType$1 = $sliceType(ptrType); + ptrType$1 = $ptrType(battle.Polygon2D); + ptrType$2 = $ptrType(battle.PlayerDownsync); + sliceType$2 = $sliceType(ptrType$2); + ptrType$3 = $ptrType(battle.MeleeBullet); + sliceType$3 = $sliceType(ptrType$3); + ptrType$4 = $ptrType(battle.FireballBullet); + sliceType$4 = $sliceType(ptrType$4); + ptrType$5 = $ptrType(js.Object); + sliceType$5 = $sliceType(ptrType$5); + ptrType$6 = $ptrType(battle.CharacterConfig); + funcType = $funcType([$Float64, $Float64], [ptrType$5], false); + funcType$1 = $funcType([ptrType, sliceType$1], [ptrType$5], false); + funcType$2 = $funcType([ptrType$1], [ptrType$5], false); + funcType$3 = $funcType([$Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Bool, $Bool, $Int32, $Int32, $Bool, $Int32, $Int32, $Int32, $Int32], [ptrType$5], false); + funcType$4 = $funcType([$Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Bool, $Int32, $Int32, $Int32, $Int32, $Int32], [ptrType$5], false); + funcType$5 = $funcType([$Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Bool, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32, $Int32], [ptrType$5], false); + funcType$6 = $funcType([$Uint64, $Uint64, $Float64, $Float64], [ptrType$5], false); + funcType$7 = $funcType([$Int32, sliceType$2, $Int32, sliceType$3, sliceType$4], [ptrType$5], false); + funcType$8 = $funcType([$Int, $Int, $Int, $Int], [ptrType$5], false); + funcType$9 = $funcType([$Int32, sliceType, $Uint64], [ptrType$5], false); + funcType$10 = $funcType([$Int32], [ptrType$5], false); + funcType$11 = $funcType([ptrType$1, $Float64, $Float64, $emptyInterface, $String], [ptrType$5], false); + ptrType$7 = $ptrType(resolv.Space); + funcType$12 = $funcType([ptrType$7], [sliceType$5], false); + funcType$13 = $funcType([$Float64, $Float64, $Float64, $Float64, $Float64, $Float64, $Float64, $Float64, $Float64, $Float64], [$Float64, $Float64], false); + funcType$14 = $funcType([$Float64, $Float64], [$Int32, $Int32], false); + funcType$15 = $funcType([$Int32, $Int32], [$Float64, $Float64], false); + sliceType$6 = $sliceType($Int); + funcType$16 = $funcType([sliceType$6], [sliceType$5], false); + ptrType$8 = $ptrType(resolv.RingBuffer); + ptrType$9 = $ptrType(battle.RoomDownsyncFrame); + ptrType$10 = $ptrType(resolv.Object); + mapType = $mapType($Int32, ptrType$10); + sliceType$7 = $sliceType(ptrType$6); + funcType$17 = $funcType([ptrType$8, ptrType$9, ptrType$7, mapType, $Float64, $Float64, sliceType$7], [ptrType$5], false); + funcType$18 = $funcType([$Int32], [$Int32], false); + funcType$19 = $funcType([$Int32], [$Bool], false); + funcType$20 = $funcType([$Int32, $Int32, $Int32, $Int32, $Int32], [$Bool], false); + mapType$1 = $mapType($String, $emptyInterface); + NewInputFrameDownsync = function(inputFrameId, inputList, confirmedList) { + var confirmedList, inputFrameId, inputList; + return js.MakeWrapper(new battle.InputFrameDownsync.ptr(inputFrameId, inputList, confirmedList)); + }; + $pkg.NewInputFrameDownsync = NewInputFrameDownsync; + NewRingBufferJs = function(n) { + var n; + return js.MakeWrapper(resolv.NewRingBuffer(n)); + }; + $pkg.NewRingBufferJs = NewRingBufferJs; + NewCollisionSpaceJs = function(spaceW, spaceH, minStepW, minStepH) { + var minStepH, minStepW, spaceH, spaceW; + return js.MakeWrapper(resolv.NewSpace(spaceW, spaceH, minStepW, minStepH)); + }; + $pkg.NewCollisionSpaceJs = NewCollisionSpaceJs; + NewVec2DJs = function(x, y) { + var x, y; + return js.MakeWrapper(new battle.Vec2D.ptr(x, y)); + }; + $pkg.NewVec2DJs = NewVec2DJs; + NewPolygon2DJs = function(anchor, points) { + var anchor, points; + return js.MakeWrapper(new battle.Polygon2D.ptr(anchor, points)); + }; + $pkg.NewPolygon2DJs = NewPolygon2DJs; + NewBarrierJs = function(boundary) { + var boundary; + return js.MakeWrapper(new battle.Barrier.ptr(boundary)); + }; + $pkg.NewBarrierJs = NewBarrierJs; + NewPlayerDownsyncJs = function(id, virtualGridX, virtualGridY, dirX, dirY, velX, velY, framesToRecover, framesInChState, activeSkillId, activeSkillHit, framesInvinsible, speed, battleState, characterState, joinIndex, hp, maxHp, colliderRadius, inAir, onWall, onWallNormX, onWallNormY, capturedByInertia, bulletTeamId, chCollisionTeamId, revivalVirtualGridX, revivalVirtualGridY) { + var activeSkillHit, activeSkillId, battleState, bulletTeamId, capturedByInertia, chCollisionTeamId, characterState, colliderRadius, dirX, dirY, framesInChState, framesInvinsible, framesToRecover, hp, id, inAir, joinIndex, maxHp, onWall, onWallNormX, onWallNormY, revivalVirtualGridX, revivalVirtualGridY, speed, velX, velY, virtualGridX, virtualGridY; + return js.MakeWrapper(battle.NewPlayerDownsync(id, virtualGridX, virtualGridY, dirX, dirY, velX, velY, framesToRecover, framesInChState, activeSkillId, activeSkillHit, framesInvinsible, speed, battleState, characterState, joinIndex, hp, maxHp, colliderRadius, inAir, onWall, onWallNormX, onWallNormY, capturedByInertia, bulletTeamId, chCollisionTeamId, revivalVirtualGridX, revivalVirtualGridY)); + }; + $pkg.NewPlayerDownsyncJs = NewPlayerDownsyncJs; + NewMeleeBulletJs = function(bulletLocalId, originatedRenderFrameId, offenderJoinIndex, startupFrames, cancellableStFrame, cancellableEdFrame, activeFrames, hitStunFrames, blockStunFrames, pushbackVelX, pushbackVelY, damage, selfLockVelX, selfLockVelY, hitboxOffsetX, hitboxOffsetY, hitboxSizeX, hitboxSizeY, blowUp, teamId, blState, framesInBlState, explosionFrames, speciesId) { + var activeFrames, blState, blockStunFrames, blowUp, bulletLocalId, cancellableEdFrame, cancellableStFrame, damage, explosionFrames, framesInBlState, hitStunFrames, hitboxOffsetX, hitboxOffsetY, hitboxSizeX, hitboxSizeY, offenderJoinIndex, originatedRenderFrameId, pushbackVelX, pushbackVelY, selfLockVelX, selfLockVelY, speciesId, startupFrames, teamId; + return js.MakeWrapper(battle.NewMeleeBullet(bulletLocalId, originatedRenderFrameId, offenderJoinIndex, startupFrames, cancellableStFrame, cancellableEdFrame, activeFrames, hitStunFrames, blockStunFrames, pushbackVelX, pushbackVelY, damage, selfLockVelX, selfLockVelY, hitboxOffsetX, hitboxOffsetY, hitboxSizeX, hitboxSizeY, blowUp, teamId, blState, framesInBlState, explosionFrames, speciesId)); + }; + $pkg.NewMeleeBulletJs = NewMeleeBulletJs; + NewFireballBulletJs = function(bulletLocalId, originatedRenderFrameId, offenderJoinIndex, startupFrames, cancellableStFrame, cancellableEdFrame, activeFrames, hitStunFrames, blockStunFrames, pushbackVelX, pushbackVelY, damage, selfLockVelX, selfLockVelY, hitboxOffsetX, hitboxOffsetY, hitboxSizeX, hitboxSizeY, blowUp, teamId, virtualGridX, virtualGridY, dirX, dirY, velX, velY, speed, blState, framesInBlState, explosionFrames, speciesId) { + var activeFrames, blState, blockStunFrames, blowUp, bulletLocalId, cancellableEdFrame, cancellableStFrame, damage, dirX, dirY, explosionFrames, framesInBlState, hitStunFrames, hitboxOffsetX, hitboxOffsetY, hitboxSizeX, hitboxSizeY, offenderJoinIndex, originatedRenderFrameId, pushbackVelX, pushbackVelY, selfLockVelX, selfLockVelY, speciesId, speed, startupFrames, teamId, velX, velY, virtualGridX, virtualGridY; + return js.MakeWrapper(battle.NewFireballBullet(bulletLocalId, originatedRenderFrameId, offenderJoinIndex, startupFrames, cancellableStFrame, cancellableEdFrame, activeFrames, hitStunFrames, blockStunFrames, pushbackVelX, pushbackVelY, damage, selfLockVelX, selfLockVelY, hitboxOffsetX, hitboxOffsetY, hitboxSizeX, hitboxSizeY, blowUp, teamId, virtualGridX, virtualGridY, dirX, dirY, velX, velY, speed, blState, framesInBlState, explosionFrames, speciesId)); + }; + $pkg.NewFireballBulletJs = NewFireballBulletJs; + NewNpcPatrolCue = function(flAct, frAct, x, y) { + var flAct, frAct, x, y; + return js.MakeWrapper(new battle.NpcPatrolCue.ptr(flAct, frAct, x, y)); + }; + $pkg.NewNpcPatrolCue = NewNpcPatrolCue; + NewRoomDownsyncFrameJs = function(id, playersArr, bulletLocalIdCounter, meleeBullets, fireballBullets) { + var bulletLocalIdCounter, fireballBullets, id, meleeBullets, playersArr; + return js.MakeWrapper(new battle.RoomDownsyncFrame.ptr(id, playersArr, new $Int64(0, 0), meleeBullets, fireballBullets, new $Uint64(0, 0), false, bulletLocalIdCounter)); + }; + $pkg.NewRoomDownsyncFrameJs = NewRoomDownsyncFrameJs; + GetCollisionSpaceObjsJs = function(space) { + var _i, _ref, i, obj, objs, ret, space; + objs = space.Objects(); + ret = $makeSlice(sliceType$5, objs.$length); + _ref = objs; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + i = _i; + obj = ((_i < 0 || _i >= _ref.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref.$array[_ref.$offset + _i]); + ((i < 0 || i >= ret.$length) ? ($throwRuntimeError("index out of range"), undefined) : ret.$array[ret.$offset + i] = js.MakeWrapper(obj)); + _i++; + } + return ret; + }; + $pkg.GetCollisionSpaceObjsJs = GetCollisionSpaceObjsJs; + GenerateConvexPolygonColliderJs = function(unalignedSrc, spaceOffsetX, spaceOffsetY, data, tag) { + var {$24r, _r, _r$1, data, spaceOffsetX, spaceOffsetY, tag, unalignedSrc, $s, $r, $c} = $restore(this, {unalignedSrc, spaceOffsetX, spaceOffsetY, data, tag}); + /* */ $s = $s || 0; s: while (true) { switch ($s) { case 0: + _r = battle.GenerateConvexPolygonCollider(unalignedSrc, spaceOffsetX, spaceOffsetY, data, tag); /* */ $s = 1; case 1: if($c) { $c = false; _r = _r.$blk(); } if (_r && _r.$blk !== undefined) { break s; } + _r$1 = js.MakeWrapper(_r); /* */ $s = 2; case 2: if($c) { $c = false; _r$1 = _r$1.$blk(); } if (_r$1 && _r$1.$blk !== undefined) { break s; } + $24r = _r$1; + $s = 3; case 3: return $24r; + /* */ } return; } var $f = {$blk: GenerateConvexPolygonColliderJs, $c: true, $r, $24r, _r, _r$1, data, spaceOffsetX, spaceOffsetY, tag, unalignedSrc, $s};return $f; + }; + $pkg.GenerateConvexPolygonColliderJs = GenerateConvexPolygonColliderJs; + GetCharacterConfigsOrderedByJoinIndex = function(speciesIdList) { + var _entry, _i, _ref, i, ret, speciesId, speciesIdList; + ret = $makeSlice(sliceType$5, speciesIdList.$length, speciesIdList.$length); + _ref = speciesIdList; + _i = 0; + while (true) { + if (!(_i < _ref.$length)) { break; } + i = _i; + speciesId = ((_i < 0 || _i >= _ref.$length) ? ($throwRuntimeError("index out of range"), undefined) : _ref.$array[_ref.$offset + _i]); + ((i < 0 || i >= ret.$length) ? ($throwRuntimeError("index out of range"), undefined) : ret.$array[ret.$offset + i] = js.MakeWrapper((_entry = battle.Characters[$Int.keyFor(speciesId)], _entry !== undefined ? _entry.v : ptrType$6.nil))); + _i++; + } + return ret; + }; + $pkg.GetCharacterConfigsOrderedByJoinIndex = GetCharacterConfigsOrderedByJoinIndex; + ApplyInputFrameDownsyncDynamicsOnSingleRenderFrameJs = function(inputsBuffer, currRenderFrame, collisionSys, collisionSysMap, collisionSpaceOffsetX, collisionSpaceOffsetY, chConfigsOrderedByJoinIndex) { + var {$24r, _r, _r$1, chConfigsOrderedByJoinIndex, collisionSpaceOffsetX, collisionSpaceOffsetY, collisionSys, collisionSysMap, currRenderFrame, inputsBuffer, $s, $r, $c} = $restore(this, {inputsBuffer, currRenderFrame, collisionSys, collisionSysMap, collisionSpaceOffsetX, collisionSpaceOffsetY, chConfigsOrderedByJoinIndex}); + /* */ $s = $s || 0; s: while (true) { switch ($s) { case 0: + _r = battle.ApplyInputFrameDownsyncDynamicsOnSingleRenderFrame(inputsBuffer, currRenderFrame, collisionSys, collisionSysMap, collisionSpaceOffsetX, collisionSpaceOffsetY, chConfigsOrderedByJoinIndex); /* */ $s = 1; case 1: if($c) { $c = false; _r = _r.$blk(); } if (_r && _r.$blk !== undefined) { break s; } + _r$1 = js.MakeWrapper(_r); /* */ $s = 2; case 2: if($c) { $c = false; _r$1 = _r$1.$blk(); } if (_r$1 && _r$1.$blk !== undefined) { break s; } + $24r = _r$1; + $s = 3; case 3: return $24r; + /* */ } return; } var $f = {$blk: ApplyInputFrameDownsyncDynamicsOnSingleRenderFrameJs, $c: true, $r, $24r, _r, _r$1, chConfigsOrderedByJoinIndex, collisionSpaceOffsetX, collisionSpaceOffsetY, collisionSys, collisionSysMap, currRenderFrame, inputsBuffer, $s};return $f; + }; + $pkg.ApplyInputFrameDownsyncDynamicsOnSingleRenderFrameJs = ApplyInputFrameDownsyncDynamicsOnSingleRenderFrameJs; + main = function() { + $global.gopkgs = $externalize($makeMap($String.keyFor, [{ k: "NewVec2DJs", v: new funcType(NewVec2DJs) }, { k: "NewPolygon2DJs", v: new funcType$1(NewPolygon2DJs) }, { k: "NewBarrierJs", v: new funcType$2(NewBarrierJs) }, { k: "NewPlayerDownsyncJs", v: new funcType$3(NewPlayerDownsyncJs) }, { k: "NewMeleeBulletJs", v: new funcType$4(NewMeleeBulletJs) }, { k: "NewFireballBulletJs", v: new funcType$5(NewFireballBulletJs) }, { k: "NewNpcPatrolCue", v: new funcType$6(NewNpcPatrolCue) }, { k: "NewRoomDownsyncFrameJs", v: new funcType$7(NewRoomDownsyncFrameJs) }, { k: "NewCollisionSpaceJs", v: new funcType$8(NewCollisionSpaceJs) }, { k: "NewInputFrameDownsync", v: new funcType$9(NewInputFrameDownsync) }, { k: "NewRingBufferJs", v: new funcType$10(NewRingBufferJs) }, { k: "GenerateConvexPolygonColliderJs", v: new funcType$11(GenerateConvexPolygonColliderJs) }, { k: "GetCollisionSpaceObjsJs", v: new funcType$12(GetCollisionSpaceObjsJs) }, { k: "WorldToPolygonColliderBLPos", v: new funcType$13(battle.WorldToPolygonColliderBLPos) }, { k: "PolygonColliderBLToWorldPos", v: new funcType$13(battle.PolygonColliderBLToWorldPos) }, { k: "WorldToVirtualGridPos", v: new funcType$14(battle.WorldToVirtualGridPos) }, { k: "VirtualGridToWorldPos", v: new funcType$15(battle.VirtualGridToWorldPos) }, { k: "GetCharacterConfigsOrderedByJoinIndex", v: new funcType$16(GetCharacterConfigsOrderedByJoinIndex) }, { k: "ApplyInputFrameDownsyncDynamicsOnSingleRenderFrameJs", v: new funcType$17(ApplyInputFrameDownsyncDynamicsOnSingleRenderFrameJs) }, { k: "ConvertToDelayedInputFrameId", v: new funcType$18(battle.ConvertToDelayedInputFrameId) }, { k: "ConvertToNoDelayInputFrameId", v: new funcType$18(battle.ConvertToNoDelayInputFrameId) }, { k: "ConvertToFirstUsedRenderFrameId", v: new funcType$18(battle.ConvertToFirstUsedRenderFrameId) }, { k: "ConvertToLastUsedRenderFrameId", v: new funcType$18(battle.ConvertToLastUsedRenderFrameId) }, { k: "ShouldGenerateInputFrameUpsync", v: new funcType$19(battle.ShouldGenerateInputFrameUpsync) }, { k: "IsGeneralBulletActive", v: new funcType$20(battle.IsGeneralBulletActive) }]), mapType$1); + }; + $init = function() { + $pkg.$init = function() {}; + /* */ var $f, $c = false, $s = 0, $r; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0: + $r = js.$init(); /* */ $s = 1; case 1: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; } + $r = battle.$init(); /* */ $s = 2; case 2: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; } + $r = resolv.$init(); /* */ $s = 3; case 3: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; } + if ($pkg === $mainPkg) { + main(); + $mainFinished = true; + } + /* */ } return; } if ($f === undefined) { $f = { $blk: $init }; } $f.$s = $s; $f.$r = $r; return $f; + }; + $pkg.$init = $init; + return $pkg; +})(); $synthesizeMethods(); $initAllLinknames(); var $mainPkg = $packages["jsexport"]; diff --git a/jsexport/battle/battle.go b/jsexport/battle/battle.go index 2a00a8d..935f2c2 100644 --- a/jsexport/battle/battle.go +++ b/jsexport/battle/battle.go @@ -101,6 +101,7 @@ var inAirSet = map[int32]bool{ ATK_CHARACTER_STATE_INAIR_ATKED1: true, ATK_CHARACTER_STATE_BLOWN_UP1: true, ATK_CHARACTER_STATE_ONWALL: true, + ATK_CHARACTER_STATE_DASHING: true, // Yes dashing is an inair state even if you dashed on the ground :) } var noOpSet = map[int32]bool{ @@ -259,11 +260,15 @@ func isPolygonPairOverlapped(a, b *resolv.ConvexPolygon, result *SatResult) bool return true } -func IsMeleeBulletActive(meleeBullet *MeleeBullet, currRenderFrame *RoomDownsyncFrame) bool { - if BULLET_EXPLODING == meleeBullet.BlState { +func IsGeneralBulletActive(blState, originatedRenderFrameId, startupFrames, activeFrames, renderFrameId int32) bool { + if BULLET_EXPLODING == blState { return false } - return (meleeBullet.BattleAttr.OriginatedRenderFrameId+meleeBullet.Bullet.StartupFrames <= currRenderFrame.Id) && (meleeBullet.BattleAttr.OriginatedRenderFrameId+meleeBullet.Bullet.StartupFrames+meleeBullet.Bullet.ActiveFrames > currRenderFrame.Id) + return (originatedRenderFrameId+startupFrames < renderFrameId) && (originatedRenderFrameId+startupFrames+activeFrames > renderFrameId) +} + +func IsMeleeBulletActive(meleeBullet *MeleeBullet, currRenderFrame *RoomDownsyncFrame) bool { + return IsGeneralBulletActive(meleeBullet.BlState, meleeBullet.BattleAttr.OriginatedRenderFrameId, meleeBullet.Bullet.StartupFrames, meleeBullet.Bullet.ActiveFrames, currRenderFrame.Id) } func IsMeleeBulletAlive(meleeBullet *MeleeBullet, currRenderFrame *RoomDownsyncFrame) bool { @@ -274,10 +279,7 @@ func IsMeleeBulletAlive(meleeBullet *MeleeBullet, currRenderFrame *RoomDownsyncF } func IsFireballBulletActive(fireballBullet *FireballBullet, currRenderFrame *RoomDownsyncFrame) bool { - if BULLET_EXPLODING == fireballBullet.BlState { - return false - } - return (fireballBullet.BattleAttr.OriginatedRenderFrameId+fireballBullet.Bullet.StartupFrames < currRenderFrame.Id) && (fireballBullet.BattleAttr.OriginatedRenderFrameId+fireballBullet.Bullet.StartupFrames+fireballBullet.Bullet.ActiveFrames > currRenderFrame.Id) + return IsGeneralBulletActive(fireballBullet.BlState, fireballBullet.BattleAttr.OriginatedRenderFrameId, fireballBullet.Bullet.StartupFrames, fireballBullet.Bullet.ActiveFrames, currRenderFrame.Id) } func IsFireballBulletAlive(fireballBullet *FireballBullet, currRenderFrame *RoomDownsyncFrame) bool { diff --git a/jsexport/battle/getter.go b/jsexport/battle/getter.go new file mode 100644 index 0000000..01590e1 --- /dev/null +++ b/jsexport/battle/getter.go @@ -0,0 +1,264 @@ +package battle + +// CharacterConfig +func (c *CharacterConfig) GetSpeed() int32 { + return c.Speed +} +func (c *CharacterConfig) GetSpeciesId() int { + return c.SpeciesId +} +func (c *CharacterConfig) GetSpeciesName() string { + return c.SpeciesName +} + +// InputFrameDownsync +func (ifd *InputFrameDownsync) GetInputFrameId() int32 { + return ifd.InputFrameId +} + +func (ifd *InputFrameDownsync) GetInputList() []uint64 { + return ifd.InputList +} + +func (ifd *InputFrameDownsync) GetConfirmedList() uint64 { + return ifd.ConfirmedList +} + +// PlayerDownsync +func (p *PlayerDownsync) GetId() int32 { + return p.Id +} + +func (p *PlayerDownsync) GetJoinIndex() int32 { + return p.JoinIndex +} + +func (p *PlayerDownsync) GetVirtualGridX() int32 { + return p.VirtualGridX +} + +func (p *PlayerDownsync) GetVirtualGridY() int32 { + return p.VirtualGridY +} + +func (p *PlayerDownsync) GetDirX() int32 { + return p.DirX +} + +func (p *PlayerDownsync) GetDirY() int32 { + return p.DirY +} + +func (p *PlayerDownsync) GetVelX() int32 { + return p.VelX +} + +func (p *PlayerDownsync) GetVelY() int32 { + return p.VelY +} + +func (p *PlayerDownsync) GetSpeed() int32 { + return p.Speed +} + +func (p *PlayerDownsync) GetHp() int32 { + return p.Hp +} + +func (p *PlayerDownsync) GetMaxHp() int32 { + return p.MaxHp +} + +func (p *PlayerDownsync) GetCharacterState() int32 { + return p.CharacterState +} + +func (p *PlayerDownsync) GetFramesToRecover() int32 { + return p.FramesToRecover +} + +func (p *PlayerDownsync) GetFramesInChState() int32 { + return p.FramesInChState +} + +func (p *PlayerDownsync) GetInAir() bool { + return p.InAir +} + +func (p *PlayerDownsync) GetOnWall() bool { + return p.OnWall +} + +func (p *PlayerDownsync) GetOnWallNormX() int32 { + return p.OnWallNormX +} + +func (p *PlayerDownsync) GetColliderRadius() int32 { + return p.ColliderRadius +} + +// MeleeBullet +func (b *MeleeBullet) GetBlState() int32 { + return b.BlState +} + +func (b *MeleeBullet) GetFramesInBlState() int32 { + return b.FramesInBlState +} + +func (b *MeleeBullet) GetBulletLocalId() int32 { + return b.BattleAttr.BulletLocalId +} + +func (b *MeleeBullet) GetOffenderJoinIndex() int32 { + return b.BattleAttr.OffenderJoinIndex +} + +func (b *MeleeBullet) GetOriginatedRenderFrameId() int32 { + return b.BattleAttr.OriginatedRenderFrameId +} + +func (b *MeleeBullet) GetStartupFrames() int32 { + return b.Bullet.StartupFrames +} + +func (b *MeleeBullet) GetActiveFrames() int32 { + return b.Bullet.ActiveFrames +} + +func (b *MeleeBullet) GetHitboxSizeX() int32 { + return b.Bullet.HitboxSizeX +} + +func (b *MeleeBullet) GetHitboxSizeY() int32 { + return b.Bullet.HitboxSizeY +} + +func (b *MeleeBullet) GetHitboxOffsetX() int32 { + return b.Bullet.HitboxOffsetX +} + +func (b *MeleeBullet) GetHitboxOffsetY() int32 { + return b.Bullet.HitboxOffsetY +} + +func (b *MeleeBullet) GetExplosionFrames() int32 { + return b.Bullet.ExplosionFrames +} + +func (b *MeleeBullet) GetSpeciesId() int32 { + return b.Bullet.SpeciesId +} + +// FireballBullet +func (p *FireballBullet) GetVirtualGridX() int32 { + return p.VirtualGridX +} + +func (p *FireballBullet) GetVirtualGridY() int32 { + return p.VirtualGridY +} + +func (p *FireballBullet) GetDirX() int32 { + return p.DirX +} + +func (p *FireballBullet) GetDirY() int32 { + return p.DirY +} + +func (p *FireballBullet) GetVelX() int32 { + return p.VelX +} + +func (p *FireballBullet) GetVelY() int32 { + return p.VelY +} + +func (p *FireballBullet) GetSpeed() int32 { + return p.Speed +} +func (b *FireballBullet) GetBlState() int32 { + return b.BlState +} + +func (b *FireballBullet) GetFramesInBlState() int32 { + return b.FramesInBlState +} + +func (b *FireballBullet) GetBulletLocalId() int32 { + return b.BattleAttr.BulletLocalId +} + +func (b *FireballBullet) GetOffenderJoinIndex() int32 { + return b.BattleAttr.OffenderJoinIndex +} + +func (b *FireballBullet) GetOriginatedRenderFrameId() int32 { + return b.BattleAttr.OriginatedRenderFrameId +} + +func (b *FireballBullet) GetStartupFrames() int32 { + return b.Bullet.StartupFrames +} + +func (b *FireballBullet) GetActiveFrames() int32 { + return b.Bullet.ActiveFrames +} + +func (b *FireballBullet) GetHitboxSizeX() int32 { + return b.Bullet.HitboxSizeX +} + +func (b *FireballBullet) GetHitboxSizeY() int32 { + return b.Bullet.HitboxSizeY +} + +func (b *FireballBullet) GetHitboxOffsetX() int32 { + return b.Bullet.HitboxOffsetX +} + +func (b *FireballBullet) GetHitboxOffsetY() int32 { + return b.Bullet.HitboxOffsetY +} + +func (b *FireballBullet) GetExplosionFrames() int32 { + return b.Bullet.ExplosionFrames +} + +func (b *FireballBullet) GetSpeciesId() int32 { + return b.Bullet.SpeciesId +} + +// RoomDownsyncFrame +func (r *RoomDownsyncFrame) GetId() int32 { + return r.Id +} + +func (r *RoomDownsyncFrame) GetCountdownNanos() int64 { + return r.CountdownNanos +} + +func (r *RoomDownsyncFrame) GetBackendUnconfirmedMask() uint64 { + return r.BackendUnconfirmedMask +} + +func (r *RoomDownsyncFrame) GetBulletLocalIdCounter() int32 { + return r.BulletLocalIdCounter +} + +func (r *RoomDownsyncFrame) GetShouldForceResync() bool { + return r.ShouldForceResync +} + +func (r *RoomDownsyncFrame) GetPlayersArr() []*PlayerDownsync { + return r.PlayersArr +} + +func (r *RoomDownsyncFrame) GetMeleeBullets() []*MeleeBullet { + return r.MeleeBullets +} + +func (r *RoomDownsyncFrame) GetFireballBullets() []*FireballBullet { + return r.FireballBullets +} diff --git a/jsexport/battle/inplace_ring_buff.go b/jsexport/battle/inplace_ring_buff.go index 0ca8131..38ba1dc 100644 --- a/jsexport/battle/inplace_ring_buff.go +++ b/jsexport/battle/inplace_ring_buff.go @@ -181,3 +181,15 @@ func (rb *InplaceRingBuffer) Clear() { rb.StFrameId = 0 rb.EdFrameId = 0 } + +func (rb *InplaceRingBuffer) GetStFrameId() int32 { + return rb.StFrameId +} + +func (rb *InplaceRingBuffer) GetEdFrameId() int32 { + return rb.EdFrameId +} + +func (rb *InplaceRingBuffer) GetCnt() int32 { + return rb.Cnt +} diff --git a/jsexport/main.go b/jsexport/main.go index b190c3b..8aeb484 100644 --- a/jsexport/main.go +++ b/jsexport/main.go @@ -6,8 +6,15 @@ import ( "resolv" ) +/* +[WARNING] Should avoid using "MakeFullWrapper" as much as possible, and completely remove its usage in 60fps calls like "update(dt)" on frontend! +*/ +func NewCollisionHolder() *js.Object { + return js.MakeWrapper(resolv.NewCollision()) +} + func NewInputFrameDownsync(inputFrameId int32, inputList []uint64, confirmedList uint64) *js.Object { - return js.MakeFullWrapper(&InputFrameDownsync{ + return js.MakeWrapper(&InputFrameDownsync{ InputFrameId: inputFrameId, InputList: inputList, ConfirmedList: confirmedList, @@ -15,7 +22,7 @@ func NewInputFrameDownsync(inputFrameId int32, inputList []uint64, confirmedList } func NewRingBufferJs(n int32) *js.Object { - return js.MakeFullWrapper(resolv.NewRingBuffer(n)) + return js.MakeWrapper(resolv.NewRingBuffer(n)) } func NewCollisionSpaceJs(spaceW, spaceH, minStepW, minStepH int) *js.Object { @@ -23,14 +30,14 @@ func NewCollisionSpaceJs(spaceW, spaceH, minStepW, minStepH int) *js.Object { } func NewVec2DJs(x, y float64) *js.Object { - return js.MakeFullWrapper(&Vec2D{ + return js.MakeWrapper(&Vec2D{ X: x, Y: y, }) } func NewPolygon2DJs(anchor *Vec2D, points []*Vec2D) *js.Object { - return js.MakeFullWrapper(&Polygon2D{ + return js.MakeWrapper(&Polygon2D{ Anchor: anchor, Points: points, }) @@ -55,7 +62,7 @@ func NewFireballBulletJs(bulletLocalId, originatedRenderFrameId, offenderJoinInd } func NewNpcPatrolCue(flAct, frAct uint64, x, y float64) *js.Object { - return js.MakeFullWrapper(&NpcPatrolCue{ + return js.MakeWrapper(&NpcPatrolCue{ FlAct: flAct, FrAct: frAct, X: x, @@ -65,7 +72,7 @@ func NewNpcPatrolCue(flAct, frAct uint64, x, y float64) *js.Object { func NewRoomDownsyncFrameJs(id int32, playersArr []*PlayerDownsync, bulletLocalIdCounter int32, meleeBullets []*MeleeBullet, fireballBullets []*FireballBullet) *js.Object { // [WARNING] Avoid using "pb.RoomDownsyncFrame" here, in practive "MakeFullWrapper" doesn't expose the public fields for a "protobuf struct" as expected and requires helper functions like "GetCollisionSpaceObjsJs". - return js.MakeFullWrapper(&RoomDownsyncFrame{ + return js.MakeWrapper(&RoomDownsyncFrame{ Id: id, BulletLocalIdCounter: bulletLocalIdCounter, PlayersArr: playersArr, @@ -77,77 +84,56 @@ func NewRoomDownsyncFrameJs(id int32, playersArr []*PlayerDownsync, bulletLocalI func GetCollisionSpaceObjsJs(space *resolv.Space) []*js.Object { // [WARNING] We couldn't just use the existing method "space.Objects()" to access them in JavaScript, there'd a stackoverflow error objs := space.Objects() - ret := make([]*js.Object, 0, len(objs)) - for _, obj := range objs { - ret = append(ret, js.MakeFullWrapper(obj)) + ret := make([]*js.Object, len(objs)) + for i, obj := range objs { + ret[i] = js.MakeWrapper(obj) } return ret } -func GenerateRectColliderJs(wx, wy, w, h, spaceOffsetX, spaceOffsetY float64, data interface{}, tag string) *js.Object { - /* - [WARNING] It's important to note that we don't need "js.MakeFullWrapper" for a call sequence as follows. - ``` - var space = gopkgs.NewCollisionSpaceJs(2048, 2048, 8, 8); - var a = gopkgs.GenerateRectColliderJs(189, 497, 48, 48, spaceOffsetX, spaceOffsetY, "Player"); - space.Add(a); - ``` - The "space" variable doesn't need access to the field of "a" in JavaScript level to run "space.Add(...)" method, which is good. - - However, the full wrapper access here is used for updating "collider.X/collider.Y" at JavaScript runtime. - */ - topPadding, bottomPadding, leftPadding, rightPadding := SNAP_INTO_PLATFORM_OVERLAP, SNAP_INTO_PLATFORM_OVERLAP, SNAP_INTO_PLATFORM_OVERLAP, SNAP_INTO_PLATFORM_OVERLAP - return js.MakeFullWrapper(GenerateRectCollider(wx, wy, w, h, topPadding, bottomPadding, leftPadding, rightPadding, spaceOffsetX, spaceOffsetY, data, tag)) - -} - func GenerateConvexPolygonColliderJs(unalignedSrc *Polygon2D, spaceOffsetX, spaceOffsetY float64, data interface{}, tag string) *js.Object { - return js.MakeFullWrapper(GenerateConvexPolygonCollider(unalignedSrc, spaceOffsetX, spaceOffsetY, data, tag)) + return js.MakeWrapper(GenerateConvexPolygonCollider(unalignedSrc, spaceOffsetX, spaceOffsetY, data, tag)) } func GetCharacterConfigsOrderedByJoinIndex(speciesIdList []int) []*js.Object { ret := make([]*js.Object, len(speciesIdList), len(speciesIdList)) for i, speciesId := range speciesIdList { - ret[i] = js.MakeFullWrapper(Characters[speciesId]) + ret[i] = js.MakeWrapper(Characters[speciesId]) } return ret } func ApplyInputFrameDownsyncDynamicsOnSingleRenderFrameJs(inputsBuffer *resolv.RingBuffer, currRenderFrame *RoomDownsyncFrame, collisionSys *resolv.Space, collisionSysMap map[int32]*resolv.Object, collisionSpaceOffsetX, collisionSpaceOffsetY float64, chConfigsOrderedByJoinIndex []*CharacterConfig) *js.Object { // We need access to all fields of RoomDownsyncFrame for displaying in frontend - return js.MakeFullWrapper(ApplyInputFrameDownsyncDynamicsOnSingleRenderFrame(inputsBuffer, currRenderFrame, collisionSys, collisionSysMap, collisionSpaceOffsetX, collisionSpaceOffsetY, chConfigsOrderedByJoinIndex)) + return js.MakeWrapper(ApplyInputFrameDownsyncDynamicsOnSingleRenderFrame(inputsBuffer, currRenderFrame, collisionSys, collisionSysMap, collisionSpaceOffsetX, collisionSpaceOffsetY, chConfigsOrderedByJoinIndex)) } func main() { js.Global.Set("gopkgs", map[string]interface{}{ - "NewVec2DJs": NewVec2DJs, - "NewPolygon2DJs": NewPolygon2DJs, - "NewBarrierJs": NewBarrierJs, - "NewPlayerDownsyncJs": NewPlayerDownsyncJs, - "NewMeleeBulletJs": NewMeleeBulletJs, - "NewFireballBulletJs": NewFireballBulletJs, - "NewNpcPatrolCue": NewNpcPatrolCue, - "NewRoomDownsyncFrameJs": NewRoomDownsyncFrameJs, - "NewCollisionSpaceJs": NewCollisionSpaceJs, - "NewInputFrameDownsync": NewInputFrameDownsync, - "NewRingBufferJs": NewRingBufferJs, - "GenerateRectColliderJs": GenerateRectColliderJs, - "GenerateConvexPolygonColliderJs": GenerateConvexPolygonColliderJs, - "GetCollisionSpaceObjsJs": GetCollisionSpaceObjsJs, - "WorldToPolygonColliderBLPos": WorldToPolygonColliderBLPos, // No need to wrap primitive return types - "PolygonColliderBLToWorldPos": PolygonColliderBLToWorldPos, - "WorldToVirtualGridPos": WorldToVirtualGridPos, - "VirtualGridToWorldPos": VirtualGridToWorldPos, - "GetCharacterConfigsOrderedByJoinIndex": GetCharacterConfigsOrderedByJoinIndex, + "NewVec2DJs": NewVec2DJs, + "NewPolygon2DJs": NewPolygon2DJs, + "NewBarrierJs": NewBarrierJs, + "NewPlayerDownsyncJs": NewPlayerDownsyncJs, + "NewMeleeBulletJs": NewMeleeBulletJs, + "NewFireballBulletJs": NewFireballBulletJs, + "NewNpcPatrolCue": NewNpcPatrolCue, + "NewRoomDownsyncFrameJs": NewRoomDownsyncFrameJs, + "NewCollisionSpaceJs": NewCollisionSpaceJs, + "NewInputFrameDownsync": NewInputFrameDownsync, + "NewRingBufferJs": NewRingBufferJs, + "GenerateConvexPolygonColliderJs": GenerateConvexPolygonColliderJs, + "GetCollisionSpaceObjsJs": GetCollisionSpaceObjsJs, + "WorldToPolygonColliderBLPos": WorldToPolygonColliderBLPos, // No need to wrap primitive return types + "PolygonColliderBLToWorldPos": PolygonColliderBLToWorldPos, + "WorldToVirtualGridPos": WorldToVirtualGridPos, + "VirtualGridToWorldPos": VirtualGridToWorldPos, + "GetCharacterConfigsOrderedByJoinIndex": GetCharacterConfigsOrderedByJoinIndex, "ApplyInputFrameDownsyncDynamicsOnSingleRenderFrameJs": ApplyInputFrameDownsyncDynamicsOnSingleRenderFrameJs, "ConvertToDelayedInputFrameId": ConvertToDelayedInputFrameId, "ConvertToNoDelayInputFrameId": ConvertToNoDelayInputFrameId, "ConvertToFirstUsedRenderFrameId": ConvertToFirstUsedRenderFrameId, "ConvertToLastUsedRenderFrameId": ConvertToLastUsedRenderFrameId, "ShouldGenerateInputFrameUpsync": ShouldGenerateInputFrameUpsync, - "IsMeleeBulletActive": IsMeleeBulletActive, - "IsMeleeBulletAlive": IsMeleeBulletAlive, - "IsFireballBulletActive": IsFireballBulletActive, - "IsFireballBulletAlive": IsFireballBulletAlive, + "IsGeneralBulletActive": IsGeneralBulletActive, }) } diff --git a/resolv_tailored/object.go b/resolv_tailored/object.go index 176536a..53caa1b 100644 --- a/resolv_tailored/object.go +++ b/resolv_tailored/object.go @@ -48,6 +48,18 @@ func NewObject(x, y, w, h float64, tags ...string) *Object { return o } +func (obj *Object) GetData() interface{} { + return obj.Data +} + +func (obj *Object) GetShape() *Shape { + return &(obj.Shape) +} + +func (obj *Object) Position() (float64, float64) { + return obj.X, obj.Y +} + // Clone clones the Object with its properties into another Object. It also clones the Object's Shape (if it has one). func (obj *Object) Clone() *Object { newObj := NewObject(obj.X, obj.Y, obj.W, obj.H, obj.Tags()...) diff --git a/resolv_tailored/ringbuf.go b/resolv_tailored/ringbuf.go index b48000e..67b2366 100644 --- a/resolv_tailored/ringbuf.go +++ b/resolv_tailored/ringbuf.go @@ -134,3 +134,15 @@ func (rb *RingBuffer) Clear() { rb.StFrameId = 0 rb.EdFrameId = 0 } + +func (rb *RingBuffer) GetStFrameId() int32 { + return rb.StFrameId +} + +func (rb *RingBuffer) GetEdFrameId() int32 { + return rb.EdFrameId +} + +func (rb *RingBuffer) GetCnt() int32 { + return rb.Cnt +} diff --git a/resolv_tailored/shape.go b/resolv_tailored/shape.go index 8c46ea3..081246a 100644 --- a/resolv_tailored/shape.go +++ b/resolv_tailored/shape.go @@ -331,6 +331,10 @@ func (polygon *ConvexPolygon) PointInside(point Vector) bool { return contactCount == 1 } +func (polygon *ConvexPolygon) GetPoints() []Vector { + return polygon.Points +} + type ContactSet struct { Points []Vector // Slice of Points indicating contact between the two Shapes. MTV Vector // Minimum Translation Vector; this is the vector to move a Shape on to move it outside of its contacting Shape.