/* ISLE SLINGERS -- physics/abilities/index.js (submodule: abilities) * Modularization pass (behavior-neutral split of the original * js/core.js monolith). Installs its units into ONE shared physics scope `P` * that every physics submodule sees -- the same single-scope semantics the * monolith had. Must load before js/physics/index.js (the aggregator that * attaches the public ISLE_CORE API). Surface installed: launch, triggerAbility. */ (function (root, factory) { var part = factory(); if (typeof module !== 'undefined' && module.exports) module.exports = part; else (root.ISLE_PHYSICS_PARTS = root.ISLE_PHYSICS_PARTS || []).push(part); })(typeof globalThis !== 'undefined' ? globalThis : this, function () { 'use strict'; return function (P) { P.launch = function(g, dragPos) { var b = P.activeBird(g); if (!b || b.state !== 'aiming' || g.status !== 'ready') return false; var v = P.aimVector(g, { x: g.level.sling.x, y: g.level.sling.y }, dragPos); if (!v) return false; b.x = g.level.sling.x; b.y = g.level.sling.y; b.vx = v.vx; b.vy = v.vy; b.state = 'flying'; b.launchT = g.time; g.status = 'flying'; g.launched++; g.events.push({ type: 'P.launch', x: b.x, y: b.y }); return true; } P.triggerAbility = function(g) { var b = P.activeBird(g); if (!b || b.state !== 'flying' || b.abilityUsed) return false; if (g.time - b.launchT < P.ABILITY_CD) return false; var kind = b.kind; if (kind === 'wren') { b.vx = b.vx * 0.4 + 980; g.events.push({ type: 'ability_fury', x: b.x, y: b.y }); } else if (kind === 'zippy') { b.vy = Math.max(b.vy, 0) + 1050; b.vx *= 0.55; g.events.push({ type: 'ability_dive', x: b.x, y: b.y }); } else if (kind === 'boulder') { var R = 150; var i, d, f, ent; for (i = 0; i < g.blocks.length; i++) { var bl = g.blocks[i]; if (bl.hp <= 0) continue; d = Math.hypot(bl.x - b.x, bl.y - b.y) - (bl.w + bl.h) / 4; if (d < R) { f = 1 - Math.max(0, d) / R; P.damageBlock(g, bl, 120 + 300 * f, 'quake'); } } for (i = 0; i < g.enemies.length; i++) { ent = g.enemies[i]; if (ent.dead) continue; d = Math.hypot(ent.x - b.x, ent.y - b.y) - ent.r; if (d < R) { f = 1 - Math.max(0, d) / R; P.damageEnemy(g, ent, 0.7 + 1.6 * f); } } g.camera.shake = Math.max(g.camera.shake, 14); g.events.push({ type: 'ability_quake', x: b.x, y: b.y, r: R }); } b.abilityUsed = true; g.stats.abilityUses++; return true; } }; });