@vimp-games/tanks 0.22.6 → 0.22.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client-CUg2hnAe.js +210 -0
- package/dist/client-CUg2hnAe.js.map +1 -0
- package/dist/{host-ZT_5hzVY.js → host-DQx-nxzB.js} +1 -1
- package/dist/host-DQx-nxzB.js.map +1 -0
- package/dist/manifest.json +4 -4
- package/dist/maps/garden.json +1 -1
- package/dist/sounds/bomb-has-been-planted.webm +0 -0
- package/dist/sounds/bomb-has-been-planted2.webm +0 -0
- package/dist/sounds/defeat.webm +0 -0
- package/dist/sounds/empty-bullet.webm +0 -0
- package/dist/sounds/explosion.webm +0 -0
- package/dist/sounds/frag.webm +0 -0
- package/dist/sounds/game-over.webm +0 -0
- package/dist/sounds/hit.webm +0 -0
- package/dist/sounds/round-start.webm +0 -0
- package/dist/sounds/shot.webm +0 -0
- package/dist/sounds/tank-engine.webm +0 -0
- package/dist/sounds/tank-landing.webm +0 -0
- package/dist/sounds/tank-water.webm +0 -0
- package/dist/sounds/victory.webm +0 -0
- package/package.json +2 -2
- package/dist/client-BvkP3FTH.js +0 -210
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import{UniformGroup as Pe,Filter as Fi,GpuProgram as Di,GlProgram as rs,defaultFilterVert as Yi,Container as U,Sprite as K,Rectangle as Z,Spritesheet as Xi,MeshSimple as Vi,Ticker as j,Text as ii,BlurFilter as vt,Assets as Je,Texture as ze,Graphics as N,Shader as ni,Geometry as Oi,Mesh as oi,AlphaFilter as ri,PerspectiveMesh as Bi,Particle as Ni,ParticleContainer as as,MeshGeometry as Wi}from"pixi.js";const Ui=4;class Qe{__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,_s.unregister(this),t}free(){const t=this.__destroy_into_raw();P.__wbg_clientcore_free(t,0)}abi_describe(){let t,e;try{const s=P.clientcore_abi_describe(this.__wbg_ptr);return t=s[0],e=s[1],Tt(s[0],s[1])}finally{P.__wbindgen_free(t,e,1)}}apply_aim(t,e,s,n){P.clientcore_apply_aim(this.__wbg_ptr,t,e,s,n)}apply_input(t,e,s){const n=Xt(t,P.__wbindgen_malloc,P.__wbindgen_realloc),o=ut,r=Xt(e,P.__wbindgen_malloc,P.__wbindgen_realloc),a=ut;P.clientcore_apply_input(this.__wbg_ptr,n,o,r,a,s)}cycle_weapon(t){P.clientcore_cycle_weapon(this.__wbg_ptr,t)}debug_json(){let t,e;try{const s=P.clientcore_debug_json(this.__wbg_ptr);return t=s[0],e=s[1],Tt(s[0],s[1])}finally{P.__wbindgen_free(t,e,1)}}decode_frame(t){let e,s;try{const n=Be(t,P.__wbindgen_malloc),o=ut,r=P.clientcore_decode_frame(this.__wbg_ptr,n,o);return e=r[0],s=r[1],Tt(r[0],r[1])}finally{P.__wbindgen_free(e,s,1)}}dispatch(t,e){const s=Xt(t,P.__wbindgen_malloc,P.__wbindgen_realloc),n=ut,o=Be(e,P.__wbindgen_malloc),r=ut,a=P.clientcore_dispatch(this.__wbg_ptr,s,n,o,r);var l=Gi(a[0],a[1]).slice();return P.__wbindgen_free(a[0],a[1]*1,1),l}hot_ptr(){return P.clientcore_hot_ptr(this.__wbg_ptr)>>>0}hot_values(){const t=P.clientcore_hot_values(this.__wbg_ptr);var e=Oe(t[0],t[1]).slice();return P.__wbindgen_free(t[0],t[1]*4,4),e}map_dynamics_to_world(t,e,s){const n=Xt(t,P.__wbindgen_malloc,P.__wbindgen_realloc),o=ut,r=P.clientcore_map_dynamics_to_world(this.__wbg_ptr,n,o,e,s);var a=Oe(r[0],r[1]).slice();return P.__wbindgen_free(r[0],r[1]*4,4),a}map_generation(){return P.clientcore_map_generation(this.__wbg_ptr)>>>0}my_game_id(){return P.clientcore_my_game_id(this.__wbg_ptr)}constructor(t){const e=Xt(t,P.__wbindgen_malloc,P.__wbindgen_realloc),s=ut,n=P.clientcore_new(e,s);if(n[2])throw ps(n[1]);return this.__wbg_ptr=n[0],_s.register(this,this.__wbg_ptr,this),this}offset(){return P.clientcore_offset(this.__wbg_ptr)}push_frame(t,e){const s=Be(t,P.__wbindgen_malloc),n=ut;return P.clientcore_push_frame(this.__wbg_ptr,s,n,e)!==0}ramp_runs(){let t,e;try{const s=P.clientcore_ramp_runs(this.__wbg_ptr);return t=s[0],e=s[1],Tt(s[0],s[1])}finally{P.__wbindgen_free(t,e,1)}}reset(){P.clientcore_reset(this.__wbg_ptr)}resync(){P.clientcore_resync(this.__wbg_ptr)}sample(t){return P.clientcore_sample(this.__wbg_ptr,t)>>>0}set_active(t){P.clientcore_set_active(this.__wbg_ptr,t)}set_map(t){const e=Xt(t,P.__wbindgen_malloc,P.__wbindgen_realloc),s=ut,n=P.clientcore_set_map(this.__wbg_ptr,e,s);if(n[1])throw ps(n[0])}set_model(t){const e=Xt(t,P.__wbindgen_malloc,P.__wbindgen_realloc),s=ut;P.clientcore_set_model(this.__wbg_ptr,e,s)}shot_segments(t,e,s,n,o,r){const a=P.clientcore_shot_segments(this.__wbg_ptr,t,e,s,n,o,r);var l=Oe(a[0],a[1]).slice();return P.__wbindgen_free(a[0],a[1]*4,4),l}surface_at(t,e,s){return P.clientcore_surface_at(this.__wbg_ptr,t,e,s)}surface_dir_at(t,e,s){return P.clientcore_surface_dir_at(this.__wbg_ptr,t,e,s)}surface_types(){let t,e;try{const s=P.clientcore_surface_types(this.__wbg_ptr);return t=s[0],e=s[1],Tt(s[0],s[1])}finally{P.__wbindgen_free(t,e,1)}}sync_panel(t){const e=Xt(t,P.__wbindgen_malloc,P.__wbindgen_realloc),s=ut;P.clientcore_sync_panel(this.__wbg_ptr,e,s)}take_divergence(){let t,e;try{const s=P.clientcore_take_divergence(this.__wbg_ptr);return t=s[0],e=s[1],Tt(s[0],s[1])}finally{P.__wbindgen_free(t,e,1)}}take_frames(){let t,e;try{const s=P.clientcore_take_frames(this.__wbg_ptr);return t=s[0],e=s[1],Tt(s[0],s[1])}finally{P.__wbindgen_free(t,e,1)}}try_fire(t){const e=P.clientcore_try_fire(this.__wbg_ptr,t);let s;return e[0]!==0&&(s=Tt(e[0],e[1]).slice(),P.__wbindgen_free(e[0],e[1]*1,1)),s}}Symbol.dispose&&(Qe.prototype[Symbol.dispose]=Qe.prototype.free);function Hi(){return{__proto__:null,"./vimp_tanks_core_bg.js":{__proto__:null,__wbg_Error_92b29b0548f8b746:function(t,e){return Error(Tt(t,e))},__wbg___wbindgen_throw_344f42d3211c4765:function(t,e){throw new Error(Tt(t,e))},__wbindgen_init_externref_table:function(){const t=P.__wbindgen_externrefs,e=t.grow(4);t.set(0,void 0),t.set(e+0,void 0),t.set(e+1,null),t.set(e+2,!0),t.set(e+3,!1)}}}}const _s=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>P.__wbg_clientcore_free(i,1));typeof FinalizationRegistry>"u"||new FinalizationRegistry(i=>P.__wbg_gamecore_free(i,1));function Oe(i,t){return i=i>>>0,$i().subarray(i/4,i/4+t)}function Gi(i,t){return i=i>>>0,oe().subarray(i/1,i/1+t)}let ye=null;function $i(){return(ye===null||ye.byteLength===0)&&(ye=new Float32Array(P.memory.buffer)),ye}function Tt(i,t){return Zi(i>>>0,t)}let xe=null;function oe(){return(xe===null||xe.byteLength===0)&&(xe=new Uint8Array(P.memory.buffer)),xe}function Be(i,t){const e=t(i.length*1,1)>>>0;return oe().set(i,e/1),ut=i.length,e}function Xt(i,t,e){if(e===void 0){const a=ve.encode(i),l=t(a.length,1)>>>0;return oe().subarray(l,l+a.length).set(a),ut=a.length,l}let s=i.length,n=t(s,1)>>>0;const o=oe();let r=0;for(;r<s;r++){const a=i.charCodeAt(r);if(a>127)break;o[n+r]=a}if(r!==s){r!==0&&(i=i.slice(r)),n=e(n,s,s=r+i.length*3,1)>>>0;const a=oe().subarray(n+r,n+s),l=ve.encodeInto(i,a);r+=l.written,n=e(n,s,r,1)>>>0}return ut=r,n}function ps(i){const t=P.__wbindgen_externrefs.get(i);return P.__externref_table_dealloc(i),t}let Ae=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});Ae.decode();const Ki=2146435072;let Ne=0;function Zi(i,t){return Ne+=t,Ne>=Ki&&(Ae=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),Ae.decode(),Ne=t),Ae.decode(oe().subarray(i,i+t))}const ve=new TextEncoder;"encodeInto"in ve||(ve.encodeInto=function(i,t){const e=ve.encode(i);return t.set(e),{read:i.length,written:e.length}});let ut=0,P;function qi(i,t){return P=i.exports,ye=null,xe=null,P.__wbindgen_start(),P}async function ji(i,t){if(typeof Response=="function"&&i instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(i,t)}catch(n){if(i.ok&&e(i.type)&&i.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",n);else throw n}const s=await i.arrayBuffer();return await WebAssembly.instantiate(s,t)}else{const s=await WebAssembly.instantiate(i,t);return s instanceof WebAssembly.Instance?{instance:s,module:i}:s}function e(s){switch(s){case"basic":case"cors":case"default":return!0}return!1}}async function Ji(i){if(P!==void 0)return P;i!==void 0&&(Object.getPrototypeOf(i)===Object.prototype?{module_or_path:i}=i:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),i===void 0&&(i=new URL("/assets/vimp_tanks_core_bg-BpIg8BDL.wasm",import.meta.url));const t=Hi();(typeof i=="string"||typeof Request=="function"&&i instanceof Request||typeof URL=="function"&&i instanceof URL)&&(i=fetch(i));const{instance:e,module:s}=await ji(await i,t);return qi(e)}const Qi='@charset "UTF-8";#panel table td#panel-bullet:before{content:"bullet: "}#panel table td#panel-bomb:before{content:"bomb: "}#panel table td#panel-time:before{content:"time: "}#vimp{background:#222;position:absolute;inset:0;margin:auto;z-index:1}#radar{position:absolute;right:1%;top:35px;z-index:2;border-radius:50%;background-color:#00be5acc;box-shadow:inset 0 0 47px #ee6,0 0 0 3px #054}#team1{color:#f56}#team2{color:#7ed}#spectators{color:#fe5}#team1 tHead tr,#team2 tHead tr,#spectators tHead tr{border-bottom:1px solid #888;text-transform:capitalize;font-weight:700}#team1 tBody tr,#team2 tBody tr{border-bottom:1px solid #444}#team1 tHead td:first-child:before{content:"team1 ("}#team1 tHead td:first-child:after{content:")"}#team2 tHead td:first-child:before{content:"team2 ("}#team2 tHead td:first-child:after{content:")"}#spectators tHead td:first-child:before{content:"spectators"}#spectators tBody td:nth-child(1){padding:0 1%;line-height:1.4em}#spectators tBody td:nth-child(2),#spectators tBody td:nth-child(3),#spectators tBody td:nth-child(4),#spectators tBody td:nth-child(5){display:none}',tn={mode:"hole",radius:260,softness:.45,minAlpha:.12,layerAlpha:.4,fadeRate:6,roofMargin:0,lowerTint:11579584},W={shear:.22,levelZStride:100},Zt={faceTileRepeats:12,faceBleedPx:2,rampSegments:4,sideTint:10133674},Mt={scaleGain:.1,baseAlpha:.4,alphaFalloff:.12,sizeFactor:1.05,groundOffset:3,groundAlpha:.3},Et={lift:.35,vertices:6,shading:.28,lightDir:[-.7,-.7]},qt={ambient:.55,diffuse:.6,lightZ:1},$t={duration:150,attack:.15,gunKick:1,bodyKick:0,rock:.1},wt={enabled:!0,trackHeight:5,hullBase:2,hullTop:6,turretBase:6,turretTop:10,barrelHeight:8,barrelRadius:1.5,brakeRadius:2,levelHeight:12.8,leanGain:.3,maxLean:.6,shadowBlur:1},de={rock:.22,wobbleHz:5,decay:180,duration:700,hop:.3,hopDuration:420,underShare:.5,shake:1.2,shakeDuration:220},en={speed:19e3,minDuration:45,maxDuration:80,trailLength:55,trailShare:.4,color:16751178,coreColor:16774368,coreWidth:.3,glowWidth:1.2,glowAlpha:.2,alphaStart:1,alphaEnd:.6,fadeSteps:8},sn={duration:35,spikes:5,length:6,width:1.6,spread:.35,jitter:.5,sideLength:2.2,sideWidth:.9,layers:[{scale:1.35,alpha:.18},{scale:1,alpha:.45},{scale:.55,alpha:.95,core:!0}],shrink:.4,color:16751178,coreColor:16774368},kt={sand:{color:14205834,rate:24,fullSpeed:60,minSpeed:4,lifetime:{min:350,max:750},sizeFactor:1,alpha:.35},mud:{color:3878430,rate:14,fullSpeed:60,minSpeed:4,lifetime:{min:180,max:380},sizeFactor:1.8,alpha:.6},water:{color:10474751,rate:20,fullSpeed:60,minSpeed:4,lifetime:{min:250,max:550},sizeFactor:1.1,alpha:.5,sideSpeed:{min:25,max:60},entryBurst:10,entryMinSpeed:20,sound:{minVolume:.25,fullSpeed:120,rate:{min:.9,max:1.1}}},boost:{color:16765024,burst:16,lifetime:{min:200,max:420},sizeFactor:1.4,alpha:.8,tailSpeed:{min:60,max:140},boostMinSpeed:20,resetDistance:40},tracks:{oil:{alpha:2,lifetime:3,tint:2105384,trail:1.5},mud:{alpha:1.5,lifetime:1,tint:5917242},noMarks:["water"]}},Kt={fullImpact:6,squash:.14,duration:260,minImpact:1.5},nn={maxFps:30},Jt={enabled:!0,resolution:.5,maxLights:96,headlights:{length:90,spread:.55,intensity:.9,color:16773572,offset:.5,occlusion:{enabled:!0,rays:64},bounce:{intensity:.35,radius:30,maxDistance:80}},rampSpill:1,tankGlow:{radius:26,intensity:.35,color:12570879},flash:{explosion:{radius:140,intensity:1,duration:260,color:16756832},shot:{radius:40,intensity:.6,duration:70,color:16773280}},glints:{enabled:!0,intensity:.8,size:1.2},shafts:{enabled:!0,rays:14,length:1.3,intensity:.35,shadows:!0,maxShadowCasters:4}},on=W.levelZStride,G=(i,t)=>i+on*(t||0),Ee=(i,t)=>Math.min(i||0,Math.round(t));function gt(i,t){const e=t?.screen;return!i||i.destroyed||!e||!i.scale.x||!i.scale.y?null:{x:(e.width/2-i.position.x)/i.scale.x,y:(e.height/2-i.position.y)/i.scale.y,scaleX:i.scale.x,scaleY:i.scale.y}}function dt(i,t,e,s){return!e||!s?{x:i,y:t}:{x:i+(i-e.x)*s,y:t+(t-e.y)*s}}function ft(i,t,e,s=1){const n=typeof s=="number"?s:s.x,o=typeof s=="number"?s:s.y;if(!t||!e){i.scale.set(n,o),i.position.set(0,0);return}i.scale.set(n*(1+e),o*(1+e)),i.position.set(-t.x*e,-t.y*e)}function Xe(i){const t=typeof i=="number"?i:i.x,e=typeof i=="number"?i:i.y;return{x:t,y:e}}function re(i,t,e){return Math.floor(i/t/e)}function rn(i,t,e){return Math.round(i/t/e)}function an(i,t,e){return{map:i,scale:t,step:e}}function ai(i,t,e,s){const n=re(t,i.scale.x,i.step),o=re(e,i.scale.y,i.step),r=i.map?.[o]?.[n];return r!==void 0&&s.has(r)}function li(i,t,e,s,n){if(!e||!t)return!1;const o=n>0?[[0,0],[n,0],[-n,0],[0,n],[0,-n]]:[[0,0]];for(const r of s){const a=1+r;for(const[l,h]of o)if(i((t.x+l+e.x*r)/a,(t.y+h+e.y*r)/a))return!0}return!1}function ln(i,t,e,s,n,o){return i?.map?li((r,a)=>ai(i,r,a,t),e,s,n,o):!1}function hn(i,t,e,s,n,o,r){return!i||i.size===0?!1:li((a,l)=>i.has(`${re(a,e.x,t)},${re(l,e.y,t)}`),s,n,o,r)}const hi=i=>i.radius*(1-i.softness),cn=(i,t,e)=>{if(t<=i)return e<t?0:1;const s=Math.min(1,Math.max(0,(e-i)/(t-i)));return s*s*(3-2*s)};function un({viewLevel:i,viewX:t,viewY:e,level:s,x:n,y:o,cfg:r}){if((s||0)<=(i||0))return 1;if(r.mode==="layer")return r.layerAlpha;const a=n-t,l=o-e,h=Math.sqrt(a*a+l*l),c=cn(hi(r),r.radius,h);return r.minAlpha+(1-r.minAlpha)*c}function dn(i,t,e){return(t||0)<(i||0)?e.lowerTint:16777215}const fn=`
|
|
2
|
+
precision highp float;
|
|
3
|
+
|
|
4
|
+
in vec2 vTextureCoord;
|
|
5
|
+
|
|
6
|
+
out vec4 finalColor;
|
|
7
|
+
|
|
8
|
+
uniform sampler2D uTexture;
|
|
9
|
+
uniform vec4 uInputSize;
|
|
10
|
+
uniform vec4 uOutputFrame;
|
|
11
|
+
|
|
12
|
+
uniform vec2 uHoleCenter;
|
|
13
|
+
// x - внешний радиус, y - внутренний, z - alpha в центре дыры
|
|
14
|
+
uniform vec3 uHoleParams;
|
|
15
|
+
|
|
16
|
+
void main(void)
|
|
17
|
+
{
|
|
18
|
+
vec4 color = texture(uTexture, vTextureCoord);
|
|
19
|
+
vec2 pixel = uOutputFrame.xy + vTextureCoord * uInputSize.xy;
|
|
20
|
+
float d = distance(pixel, uHoleCenter);
|
|
21
|
+
float t = smoothstep(uHoleParams.y, uHoleParams.x, d);
|
|
22
|
+
|
|
23
|
+
finalColor = color * mix(uHoleParams.z, 1.0, t);
|
|
24
|
+
}
|
|
25
|
+
`,ms=`
|
|
26
|
+
struct GlobalFilterUniforms {
|
|
27
|
+
uInputSize:vec4<f32>,
|
|
28
|
+
uInputPixel:vec4<f32>,
|
|
29
|
+
uInputClamp:vec4<f32>,
|
|
30
|
+
uOutputFrame:vec4<f32>,
|
|
31
|
+
uGlobalFrame:vec4<f32>,
|
|
32
|
+
uOutputTexture:vec4<f32>,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
struct HoleUniforms {
|
|
36
|
+
uHoleCenter:vec2<f32>,
|
|
37
|
+
uHoleParams:vec3<f32>,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
|
|
41
|
+
@group(0) @binding(1) var uTexture: texture_2d<f32>;
|
|
42
|
+
@group(0) @binding(2) var uSampler : sampler;
|
|
43
|
+
|
|
44
|
+
@group(1) @binding(0) var<uniform> holeUniforms : HoleUniforms;
|
|
45
|
+
|
|
46
|
+
struct VSOutput {
|
|
47
|
+
@builtin(position) position: vec4<f32>,
|
|
48
|
+
@location(0) uv : vec2<f32>
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
|
|
52
|
+
{
|
|
53
|
+
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
|
|
54
|
+
|
|
55
|
+
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
|
|
56
|
+
position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y)
|
|
57
|
+
- gfu.uOutputTexture.z;
|
|
58
|
+
|
|
59
|
+
return vec4(position, 0.0, 1.0);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
63
|
+
{
|
|
64
|
+
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@vertex
|
|
68
|
+
fn mainVertex(@location(0) aPosition : vec2<f32>) -> VSOutput {
|
|
69
|
+
return VSOutput(
|
|
70
|
+
filterVertexPosition(aPosition),
|
|
71
|
+
filterTextureCoord(aPosition)
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@fragment
|
|
76
|
+
fn mainFragment(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> {
|
|
77
|
+
var color = textureSample(uTexture, uSampler, uv);
|
|
78
|
+
var pixel = gfu.uOutputFrame.xy + uv * gfu.uInputSize.xy;
|
|
79
|
+
var d = distance(pixel, holeUniforms.uHoleCenter);
|
|
80
|
+
var t = smoothstep(holeUniforms.uHoleParams.y, holeUniforms.uHoleParams.x, d);
|
|
81
|
+
|
|
82
|
+
return color * mix(holeUniforms.uHoleParams.z, 1.0, t);
|
|
83
|
+
}
|
|
84
|
+
`;function _n(i){const t=new Pe({uHoleCenter:{value:new Float32Array([0,0]),type:"vec2<f32>"},uHoleParams:{value:new Float32Array([i.radius,hi(i),i.minAlpha]),type:"vec3<f32>"}});return new Fi({glProgram:rs.from({vertex:Yi,fragment:fn,name:"see-through-hole-filter"}),gpuProgram:Di.from({vertex:{source:ms,entryPoint:"mainVertex"},fragment:{source:ms,entryPoint:"mainFragment"}}),resources:{holeUniforms:t}})}function pn(i,{centerX:t,centerY:e,radius:s,softness:n,minAlpha:o}){const r=i.resources.holeUniforms.uniforms;r.uHoleCenter[0]=t,r.uHoleCenter[1]=e,r.uHoleParams[0]=s,r.uHoleParams[1]=s*(1-n),r.uHoleParams[2]=o}const mn=.01;function ts(){return{strength:0,filter:null,attached:!1,tick:null}}function ls(i,t,e){return i.strength+=((t?1:0)-i.strength)*e,i.strength}function hs(i,t,e,s,n,o){if(t.strength<mn||!n){t.attached&&(i.filters=[],t.attached=!1);return}t.filter||(t.filter=_n(e)),t.attached||(i.filters=[t.filter],t.attached=!0);const r=dt(s.x,s.y,o,s.z*W.shear);pn(t.filter,{centerX:r.x*n.scale.x+n.position.x,centerY:r.y*n.scale.y+n.position.y,radius:e.radius*n.scale.x,softness:e.softness,minAlpha:1+(e.minAlpha-1)*t.strength})}function es(i,t){if(!i.filter){i.attached=!1;return}t.filters=[],i.attached=!1,i.filter.destroy(),i.filter=null}async function ci(i,t){const e={};t.frames.forEach((o,r)=>{const[a,l,h,c]=o;e[`frame${r}`]={frame:{x:a,y:l,w:h,h:c}}});const s={frames:e,meta:{scale:"1"}},n=new Xi(i,s);return await n.parse(),n}async function cs({baseTexture:i,spriteSheetData:t,map:e,tiles:s,step:n,renderer:o,exclude:r=[]}){const a=await ci(i,t),l=new Set(r),h=s.filter(m=>!l.has(m)),c=e[0].length*n,u=e.length*n,d=new U;for(let m=0,g=e.length;m<g;m+=1)for(let _=0,v=e[m].length;_<v;_+=1){const M=e[m][_];if(h.includes(M)){const T=`frame${M}`,k=a.textures[T];if(k){const A=new K(k);A.x=_*n,A.y=m*n,d.addChild(A)}else console.warn(`Texture not found. Tile: ${M}, sprite: ${T}`)}}const p=o.generateTexture({target:d,frame:new Z(0,0,c,u)});return d.destroy({children:!0}),a.destroy(),p}function gn(i,t){const e=[];if(!Array.isArray(i))return e;for(const s of i){const n=s.axis===0?0:1,o=n===0?1:0,r=t(s.min,n),a=t(s.max,n),l=t(s.crossMin,o),h=t(s.crossMax,o),c=typeof s.railMin=="number"&&typeof s.railMax=="number";e.push({axis:s.axis,sign:s.sign,from:s.from,to:s.to,block:s.block,rail0:c?t(s.railMin,n):null,rail1:c?t(s.railMax,n):null,col0:n===0?r:l,col1:n===0?a:h,row0:n===0?l:r,row1:n===0?h:a})}return yn(e)}function yn(i){const t=new Map;for(const s of i){const n=t.get(s.block);n?n.push(s):t.set(s.block,[s])}const e=[];for(const s of t.values()){const n=a=>a.axis===1?a.col0:a.row0,o=a=>a.axis===1?a.col1:a.row1;s.sort((a,l)=>n(a)-n(l));let r=null;for(const a of s){if(r&&n(a)===o(r)){r.axis===1?r.col1=a.col1:r.row1=a.row1;continue}r={...a},e.push(r)}}return e}function us(i){const t=new Vi(i);return t.geometry.batchMode="batch",t}const xn=1e-6,gs=1e3,ui=[0,1,3,0,3,2];function wn(i,t){const e=[],s=i.length,n=i.reduce((r,a)=>Math.max(r,a.length),0),o=(r,a)=>{const l=i[a]?.[r];return l!==void 0&&t.has(l)};for(let r=0;r<s;r+=1)for(let a=0;a<n;a+=1)if(o(a,r)){for(const l of[-1,1]){if(o(a,r+l))continue;const h=l<0?r:r+1;e.push({tile:i[r][a],col:a,row:r,nx:0,ny:l,x0:a,y0:h,x1:a+1,y1:h})}for(const l of[-1,1]){if(o(a+l,r))continue;const h=l<0?a:a+1;e.push({tile:i[r][a],col:a,row:r,nx:l,ny:0,x0:h,y0:r,x1:h,y1:r+1})}}return e}function vn({map:i,tiles:t,step:e,baseScale:s,level:n,volume:o,shear:r,sideTint:a,textures:l,tileRepeats:h=1}){const c=wn(i,new Set(t)),u=n*r,d=(n+o)*r,p=d-xn,m=e*s.x,g=[],_=new Map;for(const v of c)_.has(v.tile)||_.set(v.tile,[]),_.get(v.tile).push(v);for(const[v,M]of _){const T=l?.get(v);if(!T){console.warn(`buildVolumeWalls: no side texture for tile ${v}`);continue}for(let k=0;k<M.length;k+=gs){const A=M.slice(k,k+gs),L=A.length,b=new Float32Array(L*8),Y=new Float32Array(L*8),z=new Uint32Array(L*6),R=new Float32Array(L*2),B=new Float32Array(L*2);for(let V=0;V<L;V+=1){const{nx:ct,ny:bt,x0:it,y0:Q,x1:lt,y1:Nt}=A[V],Wt=it*e,ce=Q*e,yt=lt*e,zt=Nt*e,Ut=0,Ht=1,It=V*4;for(let $=0;$<4;$+=1){const Ft=$%2===1,te=$<2,xt=(It+$)*2;b[xt]=(Ft?yt:Wt)*s.x,b[xt+1]=(Ft?zt:ce)*s.y,Y[xt]=Ft?Ht:Ut,Y[xt+1]=te?0:1/h}for(let $=0;$<6;$+=1)z[V*6+$]=It+ui[$];R[V*2]=ct,R[V*2+1]=bt,B[V*2]=(Wt+yt)/2*s.x,B[V*2+1]=(ce+zt)/2*s.y}const J=us({texture:T,vertices:b.slice(),uvs:Y,indices:z});J.tint=a,g.push({target:J,k:p,base:b,k0:u,k1:d,cellWorld:m,tileRepeats:h,occluder:!0,walls:!0,normals:R,centers:B,facing:new Uint8Array(L).fill(2)})}}return g}function Sn(i,t,e=0){const{target:s,base:n,k0:o,k1:r,cellWorld:a,tileRepeats:l,normals:h}=i,c=s.vertices,u=s.geometry.uvs,d=r-o,p=e&&t.scaleX?e/t.scaleX:0;for(let m=0,g=n.length/2;m<g;m+=1){const _=n[m*2],v=n[m*2+1],M=_-t.x,T=v-t.y,k=Math.sqrt(M*M+T*T)||1e-6,A=m%4<2,L=A?r+p/k:o;if(c[m*2]=_+M*L,c[m*2+1]=v+T*L,!A){const b=m>>2,z=(h[b*2+1]!==0?Math.abs(T):Math.abs(M))*d/a/l;u[m*2+1]=z>1?1:z}}s.vertices=c,s.geometry.uvs=u}function bn(i,t){const{target:e,normals:s,centers:n,facing:o}=i,r=o.length;let a=!1;for(let c=0;c<r;c+=1){const d=s[c*2]*(t.x-n[c*2])+s[c*2+1]*(t.y-n[c*2+1])>0?1:0;o[c]!==d&&(o[c]=d,a=!0)}if(!a)return!1;const l=e.geometry.indices;let h=0;for(let c=0;c<2;c+=1)for(let u=0;u<r;u+=1)if(o[u]===c)for(let d=0;d<6;d+=1)l[h]=u*4+ui[d],h+=1;return e.geometry.indices=l,!0}function Mn({runs:i,texture:t,step:e,shear:s,baseScale:n,segments:o,sideTint:r}){const a=[],l=t.width||1,h=t.height||1,c=Math.max(1,Math.round(o)||1);for(const u of i){const d=u.axis===0,p=d?u.col1-u.col0:u.row1-u.row0,m=Math.max(1,p*c),g=d?u.col0:u.row0,_=typeof u.rail0=="number"&&typeof u.rail1=="number"?{first:(u.rail0-g)*c,last:(u.rail1-g)*c}:null,v=u.col0*e,M=u.col1*e,T=u.row0*e,k=u.row1*e,A=m+1,L=Math.min(u.from,u.to),b=Math.max(u.from,u.to),Y=L*s,z=new Float32Array(A*4),R=new Float32Array(A*4),B=new Float32Array(A*4),J=new Float32Array(A*2),V=new Uint32Array(m*6),ct=1;for(let it=0;it<A;it+=1){const Q=it/m,lt=u.sign>0?Q:1-Q,Nt=(u.from+(u.to-u.from)*lt)*s,Wt=d?v:T,yt=Wt+((d?M:k)-Wt)*Q,zt=d?yt:v,Ut=d?T:yt,Ht=d?yt:M,It=d?k:yt,$=it*4;z[$]=zt*n.x,z[$+1]=Ut*n.y,z[$+2]=Ht*n.x,z[$+3]=It*n.y,R[$]=zt/l,R[$+1]=Ut/h,R[$+2]=Ht/l,R[$+3]=It/h;const Ft=d?Ut+ct:zt+ct,te=d?It-ct:Ht-ct,xt=Math.min(Math.max(yt,(d?v:T)+ct),(d?M:k)-ct);B[$]=(d?xt:Ft)/l,B[$+1]=(d?Ft:xt)/h,B[$+2]=(d?xt:te)/l,B[$+3]=(d?te:xt)/h,J[it*2]=Nt,J[it*2+1]=Nt}for(let it=0;it<m;it+=1){const Q=it*2,lt=it*6;V[lt]=Q,V[lt+1]=Q+1,V[lt+2]=Q+3,V[lt+3]=Q,V[lt+4]=Q+3,V[lt+5]=Q+2}const bt=us({texture:t,vertices:z.slice(),uvs:R,indices:V});a.push(Tn({base:z,uvs:B,heights:J,points:A,texture:t,kBase:Y,sideTint:r,endIndex:u.sign>0?A-1:0,rails:_})),a.push({target:bt,k:b*s,base:z,heights:J})}return a}function Tn(i){const{base:t,uvs:e,heights:s,points:n,texture:o,kBase:r,endIndex:a,sideTint:l,rails:h}=i,c=h?Math.max(0,Math.min(h.first,n-1)):0,u=h?Math.max(c,Math.min(h.last,n-1)):-1,d=h?u-c+1:0,p=d*2+2,m=new Float32Array(p*4),g=new Float32Array(p*4),_=new Float32Array(p*2),v=Math.max(0,d-1)*2+1,M=new Uint32Array(v*6),T=L=>L<d?(c+L)*2:L<d*2?(c+L-d)*2+1:a*2+(L-d*2);for(let L=0;L<p;L+=1){const b=T(L),Y=L*4,z=t[b*2],R=t[b*2+1];m[Y]=z,m[Y+1]=R,m[Y+2]=z,m[Y+3]=R,g[Y]=e[b*2],g[Y+1]=e[b*2+1],g[Y+2]=e[b*2],g[Y+3]=e[b*2+1],_[L*2]=s[b],_[L*2+1]=r}let k=0;for(let L=0;L<3;L+=1){const b=L===2?d*2:L*d,Y=L===2?d*2+1:b+d-1;for(let z=b;z<Y;z+=1){const R=z*2,B=k*6;M[B]=R,M[B+1]=R+1,M[B+2]=R+3,M[B+3]=R,M[B+4]=R+3,M[B+5]=R+2,k+=1}}const A=us({texture:o,vertices:m.slice(),uvs:g,indices:M});return A.tint=l,{target:A,k:r,base:m,heights:_}}function kn(i,t){const{target:e,base:s,heights:n}=i,o=e.vertices;for(let r=0,a=n.length;r<a;r+=1){const l=s[r*2],h=s[r*2+1],c=n[r];o[r*2]=l+(l-t.x)*c,o[r*2+1]=h+(h-t.y)*c}e.vertices=o}const An=5,fe={mapSprite:null,occluder:null,slices:[],rampTexture:null,wallTextures:[]};function Ln({mapSprite:i,bakedTexture:t,occluder:e,slices:s,rampTexture:n,wallTextures:o}){for(const r of s)r.target.parent?.removeChild(r.target),r.target.destroy({texture:!1,textureSource:!1});e?.destroy({children:!0,texture:!1,textureSource:!1}),n&&n.destroy(!0);for(const r of o??[])r.destroy(!0);i&&(i.parent?.removeChild(i),i.destroy({texture:!1,textureSource:!1})),t?.destroy(!0)}async function Cn(i){try{const t=await i.baseTexture;if(i.isAborted())return fe;const e=await cs({baseTexture:t,spriteSheetData:i.spriteSheetData,map:i.map,tiles:i.tiles,step:i.step,renderer:i.renderer,exclude:i.exclude});if(i.isAborted())return e.destroy(!0),fe;const s=new K(e);if(i.layerRoot.addChildAt(s,0),!i.extruding)return{...fe,mapSprite:s};const n=await Pn(i,t,e),o={mapSprite:s,...n};return i.isAborted()?(Ln({...o,bakedTexture:e}),fe):o}catch(t){return console.error(`Failed to create static map with asset ${i.assetUrl}:`,t),fe}}async function Pn(i,t,e){const s=W.shear,n=[],o=[];let r=null,a=null;if(i.volume>0){r=new U,r.zIndex=G(Math.max(i.layer,An),i.level);{const h=await zn(i,t,o);if(i.isAborted())return{occluder:r,slices:n,rampTexture:a,wallTextures:o};n.push(...vn({map:i.map,tiles:i.tiles,step:i.step,baseScale:i.baseScale,level:i.level,volume:i.volume,shear:s,sideTint:Zt.sideTint,textures:h,tileRepeats:Zt.faceTileRepeats}));const c=new K(e);c.tint=16777215,n.push({target:c,k:(i.level+i.volume)*s,occluder:!0})}}const l=di(i);if(l.length){if(a=await cs({baseTexture:t,spriteSheetData:i.spriteSheetData,map:i.map,tiles:i.ramps.map(h=>h.tile),step:i.step,renderer:i.renderer}),i.isAborted())return{occluder:r,slices:n,rampTexture:a,wallTextures:o};n.push(...Mn({runs:l,texture:a,step:i.step,shear:s,baseScale:i.baseScale,segments:Zt.rampSegments,sideTint:Zt.sideTint}))}if(i.isAborted())return{occluder:r,slices:n,rampTexture:a,wallTextures:o};n.sort((h,c)=>h.k-c.k);for(const h of n)h.base||ft(h.target,null,h.k,i.baseScale),(h.occluder?r:i.container).addChild(h.target);return{occluder:r,slices:n,rampTexture:a,wallTextures:o}}async function zn(i,t,e){const s=new Map,n=Math.max(1,Math.round(Zt.faceTileRepeats)||1);for(const o of i.tiles){const r=await cs({baseTexture:t,spriteSheetData:i.spriteSheetData,map:Array.from({length:n},()=>[o]),tiles:[o],step:i.step,renderer:i.renderer});e.push(r),s.set(o,r)}return s}function di(i){if(!i.ramps?.length||!i.rampRuns)return[];const t=new Set(i.ramps.map(n=>`${n.from}:${n.to}`)),e=i.rampRuns.forLevel(i.level).filter(n=>t.has(`${n.from}:${n.to}`));return gn(e,(n,o)=>rn(n,o===0?i.baseScale.x:i.baseScale.y,i.step))}function En(i,t){if(!i.levelView)return;const e=i.levelView.cfg,s=j.shared.lastTime,n=i.hole.tick===s;i.hole.tick=s;const o=j.shared.deltaMS/1e3,r=n?0:Math.min(1,e.fadeRate*o);i.hasSprite&&Rn(i,e,r,t),i.occluder&&In(i,e,r,t)}function Rn(i,t,e,s){const{levelView:n,container:o}=i,r=i.roof?n.level<i.level&&Dn(i,t,s):null;if(n.mode==="layer"){const h=(i.roof?r:n.level<i.level&&ai(i.grid,n.x,n.y,i.floorSet))?t.layerAlpha:1;o.alpha+=(h-o.alpha)*e;return}const a=i.roof?r:n.level<i.level;ls(i.hole,a,e),hs(o,i.hole,t,n,i.stage,s)}function In(i,t,e,s){const{levelView:n,occluder:o}=i,r=i.level>n.level;if(n.mode==="layer"){const a=r?t.layerAlpha:1;o.alpha+=(a-o.alpha)*e;return}ls(i.occluderHole,r,e),hs(o,i.occluderHole,t,n,i.stage,s)}function Fn(i,t){const e=i.levelView;return dt(e.x,e.y,t,e.z*W.shear)}function Dn(i,t,e){return e?ln(i.grid,i.tileSet,Fn(i,e),e,[i.level*W.shear],t.roofMargin??0):!1}const Yn=40,fi=45,Xn=1.5;function Vn(i){let t=2166136261;for(let e=0;e<i.length;e+=1)t^=i.charCodeAt(e),t=Math.imul(t,16777619)>>>0;return t>>>0}function On(i){const t=i?.map?.length||0,e=i?.map?.[0]?.length||0,s=Vn(JSON.stringify(i?.game?.lighting??null));return`${e}x${t}:${s.toString(16)}`}function Bn(i,t,e,s){const{x:n,y:o}=Xe(s);return{x:(i+.5)*e*n,y:(t+.5)*e*o}}function ys(i,t){const e=new Set(t||[]),s=[];if(!i||e.size===0)return s;for(let n=0;n<i.length;n+=1){const o=i[n]||[];for(let r=0;r<o.length;r+=1)e.has(o[r])&&s.push([r,n])}return s}function xs(i){const t=new Map;for(const[s,n]of i)t.has(n)||t.set(n,new Set),t.get(n).add(s);const e=[];for(const s of[...t.keys()].sort((n,o)=>n-o)){const n=[...t.get(s)].sort((a,l)=>a-l);let o=n[0],r=n[0];for(let a=1;a<=n.length;a+=1){const l=n[a];l===r+1||(e.push({col:o,row:s,length:r-o+1}),o=l),r=l}}return e}function Se(i,t,e,s,n,o){const r=e*o,a=dt(i,t,s,r);return{x:a.x,y:a.y,scale:1+r,screenX:a.x*n.scale.x+n.position.x,screenY:a.y*n.scale.y+n.position.y}}function Nn(i,t,e){return!e&&Math.abs(t-Math.round(t))>.001?[Math.floor(t),Math.ceil(t)]:[Ee(i,t)]}function We(i,t,e,s,n){return i+e>=0&&i-e<=s&&t+e>=0&&t-e<=n}function be(i,t,e){if(!e)return 1;const s=t/1e3,n=Math.sin(s*7.3+i*12.9898)*.5+Math.sin(s*13.1+i*78.233)*.3+Math.sin(s*23.7+i*3.7)*.2;return 1-e*((n+1)/2)}function ws(i,t){if(!(t>0)||i>=t)return 0;const e=1-Math.max(0,i)/t;return e*e}function Wn(i,t){if(!(t>0)||i>=t)return 0;const e=1-Math.max(0,i)/t;return e*e}function _i(i,t,e){const s=t-i.x,n=e-i.y,o=i.intensity??1;if(i.kind!=="cone")return o*Wn(Math.hypot(s,n),i.radius);const r=Math.cos(i.rotation||0),a=Math.sin(i.rotation||0),l=s*r+n*a,h=Math.abs(n*r-s*a);if(!(i.radius>0)||l<=0||l>=i.radius)return 0;const c=l*(i.spread??.5);if(h>=c)return 0;const u=l/i.radius;return o*(1-u)*(1-u*.35)*(1-h/c)}function Un(i,t,e,s){const n=[];for(const{light:o,factor:r}of i){const a=_i(o,t,e)*r;a>0&&n.push({light:o,strength:a,angle:Math.atan2(o.y-e,o.x-t),color:o.color??16777215})}return n.sort((o,r)=>r.strength-o.strength),n.slice(0,Math.max(0,s))}const pi=(i,t)=>`${i},${t}`;function Hn(i,t){const e=t>0?t:1,s=new Map;for(const n of i){const o=n.radius||0,r=Math.floor((n.x-o)/e),a=Math.floor((n.x+o)/e),l=Math.floor((n.y-o)/e),h=Math.floor((n.y+o)/e);for(let c=l;c<=h;c+=1)for(let u=r;u<=a;u+=1){const d=pi(u,c);s.has(d)||s.set(d,[]),s.get(d).push(n)}}return{cellSize:e,cells:s}}function Gn(i,t,e){if(!i)return[];const s=Math.floor(t/i.cellSize),n=Math.floor(e/i.cellSize);return i.cells.get(pi(s,n))||[]}function $n(i,t,e,s,n,o){const r=Math.hypot(e-i,s-t);if(!(n>0)||r<=n)return null;const a=Math.sqrt(r*r-n*n);if(a>=o)return null;const l=Math.atan2(s-t,e-i),h=Math.asin(n/r),c=l-h,u=l+h;return[i+Math.cos(c)*a,t+Math.sin(c)*a,i+Math.cos(c)*o,t+Math.sin(c)*o,i+Math.cos(u)*o,t+Math.sin(u)*o,i+Math.cos(u)*a,t+Math.sin(u)*a]}function Kn(i,t,e){const s=t/1e3;return e*(Math.sin(s*.37+i*1.7)*.6+Math.sin(s*.61+i*4.1)*.4)}function Zn(i,t,e,s,n,o){const r=i.axis===0,a=r?i.col1-i.col0:i.row1-i.row0,l=Math.max(1,a*Math.max(1,Math.round(o)||1)),h=i.col0*t*e.x,c=i.col1*t*e.x,u=i.row0*t*e.y,d=i.row1*t*e.y,p=(_,v,M)=>[_+(_-s.x)*M,v+(v-s.y)*M],m=[],g=[];for(let _=0;_<=l;_+=1){const v=_/l,M=i.sign>0?v:1-v,T=(i.from+(i.to-i.from)*M)*n;if(r){const k=h+(c-h)*v;m.push(p(k,u,T)),g.push(p(k,d,T))}else{const k=u+(d-u)*v;m.push(p(h,k,T)),g.push(p(c,k,T))}}return[...m,...g.reverse()].flat()}function ds(i,t,e,s,n,o,r,a){let l=Math.floor(i/r),h=Math.floor(t/a);if(o(l,h,null,null,i,t))return 0;const c=e>0?1:-1,u=s>0?1:-1,d=e!==0?Math.abs(r/e):1/0,p=s!==0?Math.abs(a/s):1/0;let m=1/0,g=1/0;for(e!==0&&(m=((e>0?l+1:l)*r-i)/e),s!==0&&(g=((s>0?h+1:h)*a-t)/s);;){const _=l,v=h;let M;if(m<g?(M=m,l+=c,m+=d):(M=g,h+=u,g+=p),!(M<n))return n;if(o(l,h,_,v,i+e*M,t+s*M))return Math.max(0,M)}}const qn=.2;function jn({lane:i,prevLane:t,col:e,row:s,prevCol:n,prevRow:o,x:r,y:a,z:l,cellW:h,cellH:c,clearance:u=qn}){if(t&&t!==i)return!0;if(!i||t===i||n===null||n===void 0)return!1;const d=i.axis===0;if((d?e-n:s-o)===i.sign)return!1;const m=d?i.col0*h:i.row0*c,g=d?i.col1*h:i.row1*c,_=d?r:a,v=g-m||1,M=Math.min(1,Math.max(0,(_-m)/v)),T=i.sign>0?M:1-M;return i.from+(i.to-i.from)*T-(l||0)>u}function Jn(i,t,e,s,n,o,r,a){const l=ds(i,t,e,s,n,o,r,a);return l>=n?null:{distance:l,x:i+e*l,y:t+s*l}}function Qn({x:i,y:t,rotation:e,alongMax:s,alongBack:n=0,acrossMax:o,rays:r},a,l,h){const c=Math.max(2,Math.round(r)||2),u=n>0,d=u?Math.max(3,Math.round(c/8)):0,p=[];for(let _=0;_<c;_+=1)p.push(-Math.PI/2+Math.PI*_/(c-1));for(let _=0;_<d;_+=1)p.push(Math.PI/2+Math.PI*(_+1)/(d+1));const m=new Float32Array((p.length+1)*2);let g=!1;return m[0]=i,m[1]=t,p.forEach((_,v)=>{const M=e+_,T=Math.cos(M),k=Math.sin(M),A=Math.cos(_),L=Math.abs(Math.sin(_));let b=L>1e-9?o/L:1/0;A>1e-9?b=Math.min(b,s/A):A<-1e-9&&(b=Math.min(b,n/-A));const Y=ds(i,t,T,k,b,a,l,h);Y<b-1e-6&&(g=!0),m[(v+1)*2]=i+T*Y,m[(v+1)*2+1]=t+k*Y}),{points:m,clipped:g,closed:u}}function to(i,{x:t,y:e,rotation:s,sx:n,sy:o,margin:r,width:a,height:l}){const h=Math.cos(s),c=Math.sin(s),u=new Float32Array(i.length);for(let d=0;d<i.length;d+=2){const p=i[d]-t,m=i[d+1]-e,g=p*h+m*c,_=m*h-p*c;u[d]=(r+g/n)/a,u[d+1]=(l/2+_/o)/l}return u}function vs(i,t=!1){const e=Math.max(0,i-1),s=new Uint32Array((e+(t&&i>2?1:0))*3);for(let n=0;n<e;n+=1)s[n*3]=0,s[n*3+1]=n+1,s[n*3+2]=n+2;return t&&i>2&&(s[e*3]=0,s[e*3+1]=i,s[e*3+2]=1),s}function eo(i=j.shared){let t=null,e=0;return{now(){const s=i.lastTime;return s!==t&&(t!==null&&(e+=Math.max(0,s-t)/1e3),t=s),e}}}const so=eo();function io(i,t){return Math.floor(i*t)/t}function no(i){return new Set(Object.keys(i||{}).map(Number))}function oo(i,t,e=1){if(i.speed!==void 0){const s=i.frames?.length||0,n=t*(typeof e=="number"?e:e.x);return n>0?i.speed*s/n:0}return i.fps||0}function mi(i,t,e){return!(e>0)||!(t>0)?0:Math.floor(i*t)%e}function ro(i,t,e){const s=new U,n=[];if(s.label="animatedTiles",!e)return{container:s,groups:n};const o=new Set(i.tiles);for(const[r,a]of Object.entries(e)){const l=Number(r);if(!o.has(l))continue;const h=(a.frames||[]).map(u=>t.textures[`frame${u}`]).filter(Boolean);if(h.length===0){console.warn(`Animated tile ${l}: no frames found in the sprite sheet`);continue}const c={id:l,fps:oo(a,i.step,i.scale),textures:h,sprites:[],container:new U,frame:0};c.container.label=`animatedTile-${l}`;for(let u=0;u<i.map.length;u+=1){const d=i.map[u];for(let p=0;p<d.length;p+=1){if(d[p]!==l)continue;const m=new K(h[0]);m.x=p*i.step,m.y=u*i.step,m.cullable=!0,c.sprites.push(m),c.container.addChild(m)}}if(c.sprites.length===0){c.container.destroy();continue}s.addChild(c.container),n.push(c)}return{container:s,groups:n}}function ao(i,t,e=()=>!0){for(let s=0;s<i.length;s+=1){const n=i[s];if(!e(n.container))continue;const o=mi(t,n.fps,n.textures.length);if(o===n.frame)continue;n.frame=o;const r=n.textures[o];for(let a=0;a<n.sprites.length;a+=1)n.sprites[a].texture=r}}function lo(i){i.container.parent?.removeChild(i.container),i.container.destroy({children:!0,texture:!1,textureSource:!1}),i.groups.length=0}function Ss(i,t,e){return(i||[]).filter(s=>(s.level||0)===t&&Number(s.layer)===e)}function ho(i,t,e,s){const n=[];for(const o of i){const[r,a]=o.cell||[0,0],h=(o.kind==="frames"?o.frames||[o.frame]:[o.frame]).map(u=>t.textures[`frame${u}`]).filter(Boolean);if(h.length===0){console.warn(`Decal at [${r}, ${a}]: frame not found in the sprite sheet`);continue}const c=new K(h[0]);c.anchor.set(.5),c.position.set((r+.5)*e,(a+.5)*e),s.addChild(c),n.push({item:o,sprite:c,textures:h,frame:0})}return n}function co(i,t){for(let e=0;e<i.length;e+=1){const s=i[e];if(s.item.kind==="rotate"){s.sprite.rotation=(s.item.rps||0)*2*Math.PI*t;continue}if(s.item.kind==="frames"){const n=mi(t,s.item.fps,s.textures.length);n!==s.frame&&(s.frame=n,s.sprite.texture=s.textures[n])}}}function uo(i){for(const t of i)t.sprite.parent?.removeChild(t.sprite),t.sprite.destroy({texture:!1,textureSource:!1});i.length=0}const fo=.8,Ue=.6,bs=.09,_o=.12,po=.55;function gi(i){let t=i+2654435769>>>0;return t=Math.imul(t^t>>>16,2246822507)>>>0,t=Math.imul(t^t>>>13,3266489909)>>>0,(t^t>>>16)>>>0}function mo(i,t,e=0){return gi((Math.imul(i,73856093)^Math.imul(t,19349663)^Math.imul(e,83492791))>>>0)}function Ms(i,t,e){return gi((i^Math.imul(t+e,668265261))>>>0)/4294967296}const _e=i=>Math.min(1,Math.max(0,i));function go(i,t,e){if(!(e>0))return!1;const s=Math.floor(i/Ue);if(Ms(t,s,0)>=e)return!1;const n=s*Ue+Ms(t,s,1)*(Ue-bs);return i>=n&&i<n+bs}function yo(i,t,e){const s=_e(e?.pulse||0),n=t%1e3/1e3,o=1-s*(.5+.5*Math.sin(2*Math.PI*(fo*i+n)));return go(i,t,e?.dropouts||0)?{core:_e(o*_o),glow:_e(o*po)}:{core:_e(o),glow:_e(o)}}const xo=4;function St(i){return Math.ceil(i*xo)}function Pt(i){return St(i)*2}const ss=new WeakMap;function yi({text:i,size:t}){return`${t}|${i}`}function wo(i){return Math.max(2,Math.round(i/4))}function vo(i,{text:t,size:e}){const s=wo(e),n=St(s),o=new U,r=new ii({text:String(t),style:{fontFamily:"monospace",fontWeight:"bold",fontSize:e,fill:16777215}});r.position.set(n,n),o.addChild(r);const a=new Z(0,0,Math.ceil(r.width)+n*2,Math.ceil(r.height)+n*2),l=i.generateTexture({target:o,frame:a}),h=new vt({strength:s,quality:6});h.padding=Pt(s),r.filters=[h];const c=i.generateTexture({target:o,frame:a});return r.filters=[],h.destroy(),o.destroy({children:!0}),{core:l,glow:c}}function So(i,t){let e=ss.get(i);e||(e=new Map,ss.set(i,e));const s=yi(t);let n=e.get(s);return n||(n={...vo(i,t),count:0},e.set(s,n)),n.count+=1,{core:n.core,glow:n.glow}}function bo(i,t){const e=ss.get(i),s=yi(t),n=e?.get(s);n&&(n.count-=1,!(n.count>0)&&(e.delete(s),n.core.destroy(!0),n.glow.destroy(!0)))}class Mo{constructor({sign:t,renderer:e,lighting:s,animated:n,step:o,scale:r,level:a}){const[l,h]=t.cell||[0,0];this._sign=t,this._renderer=e,this._lighting=s||null,this._level=a,this._seed=mo(l,h,a),this._scale=r,this._light=null,this._gridX=(l+.5)*o,this._gridY=(h+.5)*o,this._worldX=this._gridX*r.x,this._worldY=this._gridY*r.y;const c=So(e,t);this.glow=this._sprite(c.glow),this.core=this._sprite(c.core),this.emissive=!!this._lighting?.addEmissive(this.glow,a)&&this._lighting.addEmissive(this.core,a),this.emissive?t.light&&(this._light=this._lighting.addLight({kind:"radial",level:a,x:this._worldX,y:this._worldY,z:a,radius:t.light.radius??0,color:t.color??16777215,intensity:t.light.intensity??1})):(this._lighting?.removeEmissive(this.glow),this.glow.position.set(this._gridX,this._gridY),this.core.position.set(this._gridX,this._gridY),n.addChild(this.glow,this.core))}_sprite(t){const e=new K(t);return e.anchor.set(.5),e.blendMode="add",e.tint=this._sign.color??16777215,e.angle=this._sign.angle||0,e}update(t,e,s,n=null){const o=t===null?{core:1,glow:1}:yo(t,this._seed,this._sign.flicker);if(!this.emissive){this.glow.alpha=o.glow,this.core.alpha=o.core;return}const r=this._level*W.shear,a=dt(this._worldX,this._worldY,e,r);let l=1;n!==null?l=n:s&&(l=s.alphaFor(this._level,a.x,a.y,0));for(const h of[this.glow,this.core])h.position.set(a.x,a.y),h.scale.set(this._scale.x*(1+r),this._scale.y*(1+r));this.glow.alpha=l*o.glow,this.core.alpha=l*o.core,this._light&&this._lighting.updateLight(this._light,{intensity:(this._sign.light.intensity??1)*o.glow})}destroy(){this._lighting&&(this._light&&(this._lighting.removeLight(this._light),this._light=null),this._lighting.removeEmissive(this.glow),this._lighting.removeEmissive(this.core));for(const s of[this.glow,this.core])s.parent?.removeChild(s),s.destroy({texture:!1,textureSource:!1});const t=this._renderer,e=this._sign;return this._lighting=null,this._renderer=null,()=>bo(t,e)}}function To(i,t,e,s){const n=no(i?.animatedTiles),o=new Set(t);return{exclude:[...n],hasTiles:[...n].some(r=>o.has(r)),signs:Ss(i?.signs,e,s),decals:Ss(i?.decals,e,s)}}function Ts(i){return i.hasTiles||i.signs.length>0||i.decals.length>0}async function ko({spec:i,game:t,baseTexture:e,spriteSheetData:s,map:n,tiles:o,step:r,scale:a,level:l,animated:h,renderer:c,lighting:u,isAborted:d}){let p=null;if((i.hasTiles||i.decals.length>0)&&(p=await ci(e,s),d()))return p.destroy(),null;const m={sheet:p,tiles:null,decals:[],signs:[],tick:null};return i.hasTiles&&(m.tiles=ro({map:n,tiles:o,step:r,scale:a},p,t.animatedTiles),h.addChild(m.tiles.container)),p&&(m.decals=ho(i.decals,p,r,h)),m.signs=i.signs.map(g=>new Mo({sign:g,renderer:c,lighting:u,animated:h,step:r,scale:a,level:l})),m}function Ao(i){return i?t=>{const e=t.getBounds();return e.maxX>=0&&e.minX<=i.width&&e.maxY>=0&&e.minY<=i.height}:()=>!0}function Lo(i,{camera:t,levelView:e,screen:s,roofAlpha:n=null}){const o=io(so.now(),nn.maxFps),r=j.shared.lastTime;i.tick!==r&&(i.tick=r,i.tiles&&ao(i.tiles.groups,o,Ao(s)),co(i.decals,o));for(let a=0;a<i.signs.length;a+=1)i.signs[a].update(o,t,e,n)}function Co(i){if(!i)return()=>{};i.tiles&&(lo(i.tiles),i.tiles=null),uo(i.decals);const t=i.signs.map(s=>s.destroy()),e=i.sheet;return i.signs=[],i.sheet=null,()=>{t.forEach(s=>s()),e?.destroy()}}class Po{constructor(t,e,s,n,o={}){this._container=t,this._renderer=s.renderer,this._levelView=s.levelView||null,this._levelView?.setDiagnostics(s.diagnostics??null),this._rampRuns=s.rampRuns||null,this._hole=ts(),this._occluderHole=ts(),this._occluder=null,this._baseScale=Xe(e.scale),this._slices=[],this._rampTexture=null,this._wallTextures=[],this.mapSprite=null,this._assetUrl=`${n}${e.spriteSheet.img}`,this._baseTexturePromise=Je.load(this._assetUrl),this._map=e.map,this._tiles=e.tiles,this._level=e.level||0,this._floor=e.floor||[],this._tileSet=new Set(this._tiles),this._floorSet=new Set(this._floor),this._roof=zo(e.game,this._level,this._tiles),this._spriteSheetData=e.spriteSheet,this._step=e.step,this._layer=Number(e.layer)||1,t.zIndex=G(this._layer,this._level),this._parallaxK=this._level*W.shear,this._layerRoot=new U,this._layerRoot.label="layerRoot",this._animated=new U,this._animated.label="animated",this._layerRoot.addChild(this._animated),ft(this._layerRoot,null,this._parallaxK,this._baseScale),t.addChild(this._layerRoot),this._animationSpec=To(e.game,this._tiles,this._level,this._layer),this._animations=null,this._game=e.game,this._volume=Number(e.volume)||0,this._ramps=(e.ramps||[]).filter(r=>this._tiles.includes(r.tile)),this._extruding=this._volume>0||this._ramps.length>0,this._grid=an(this._map,this._baseScale,this._step),this._lighting=s.lighting?.enabled?s.lighting:null,this._mapKey=null,this._lighting&&(this._lighting.registerTextures({radial:o.lightRadialTexture,head:o.lampHeadTexture,glint:o.glintTexture,shaft:o.lightShaftTexture}),this._mapKey=On(e),this._lighting.acquireMap(this._mapKey,e.game?.lighting,this._step,e.scale,{cols:Math.max(0,...this._map.map(r=>r.length)),rows:this._map.length}),this._level>=1&&this._lighting.setLevelMask(this._level,ys(this._map,this._roof?this._tiles:this._floor),this,{roof:this._roof}),this._ramps.length&&this._lighting.setRampWedges(this._level,di({ramps:this._ramps,rampRuns:this._rampRuns,level:this._level,baseScale:this._baseScale,step:this._step}),this),this._volume>0&&this._lighting.setVolumeTops(this._level,ys(this._map,this._tiles),this._volume,this)),this.needsRender=this._level>=1||this._extruding||!!this._lighting?.isNight()||Ts(this._animationSpec),this._build(e)}async _build(t){const e=await Cn({container:this._container,layerRoot:this._layerRoot,exclude:this._animationSpec.exclude,baseTexture:this._baseTexturePromise,spriteSheetData:t.spriteSheet,map:this._map,tiles:this._tiles,step:this._step,renderer:this._renderer,level:this._level,layer:this._layer,volume:this._volume,ramps:this._ramps,rampRuns:this._rampRuns,baseScale:this._baseScale,parallaxK:this._parallaxK,extruding:this._extruding,assetUrl:this._assetUrl,isAborted:()=>this._container.destroyed});this.mapSprite=e.mapSprite,this._occluder=e.occluder,this._slices=e.slices,this._rampTexture=e.rampTexture,this._wallTextures=e.wallTextures??[],!(!this.mapSprite||this._container.destroyed||!Ts(this._animationSpec))&&(this._animations=await ko({spec:this._animationSpec,game:this._game,baseTexture:await this._baseTexturePromise,spriteSheetData:t.spriteSheet,map:this._map,tiles:this._tiles,step:this._step,scale:this._baseScale,level:this._level,animated:this._animated,renderer:this._renderer,lighting:this._lighting,isAborted:()=>this._container.destroyed}))}_seeThroughView(){return{levelView:this._levelView,container:this._container,stage:this._container.parent,occluder:this._occluder,hasSprite:!!this.mapSprite,hole:this._hole,occluderHole:this._occluderHole,level:this._level,grid:this._grid,tileSet:this._tileSet,floorSet:this._floorSet,roof:this._roof}}render(){this._attachOccluder(),this._levelView&&this._levelView.attachStage(this._container.parent,this._renderer);const t=this._levelView?this._levelView.camera():gt(this._container.parent,this._renderer);if(this._lighting&&(this._lighting.attachStage(this._container.parent,this._renderer),this._lighting.render()),this._animations){const e=this._roof&&this._levelView?1+(this._levelView.cfg.minAlpha-1)*this._hole.strength:null;Lo(this._animations,{camera:t,levelView:this._levelView,screen:this._renderer?.screen,roofAlpha:e})}if((this._level>=1||this._occluder)&&En(this._seeThroughView(),t),!(!this._parallaxK&&!this._slices.length)&&t){ft(this._layerRoot,t,this._parallaxK,this._baseScale);for(let e=0;e<this._slices.length;e+=1){const s=this._slices[e];s.walls?(Sn(s,t,Zt.faceBleedPx),bn(s,t)):s.base?kn(s,t):ft(s.target,t,s.k,this._baseScale)}}}_attachOccluder(){const t=this._container.parent;!this._occluder||!t||this._occluder.parent===t||t.addChild(this._occluder)}destroy(){const t=this._container,e=Co(this._animations);if(this._animations=null,this._lighting&&(this._lighting.releaseMap(this._mapKey,this),this._lighting=null),es(this._hole,t),this._occluder){const a=this._occluder;this._occluder=null,a.filters=[],es(this._occluderHole,a),a.parent?.removeChild(a),a.destroy({children:!0,texture:!1,textureSource:!1})}const s=this.mapSprite,n=this._rampTexture,o=this._wallTextures,r=this._slices;this.mapSprite=null,this._rampTexture=null,this._wallTextures=[],this._slices=[];for(const a of r)a.target.destroyed||(a.target.texture=ze.EMPTY);return s&&s.parent?.removeChild(s),this._baseTexturePromise=null,this._assetUrl=null,this._map=null,this._tiles=null,this._floor=null,this._tileSet=null,this._floorSet=null,this._grid=null,this._ramps=null,this._spriteSheetData=null,this._renderer=null,this._levelView=null,this._game=null,()=>{e(),n&&n.destroy(!0);for(const a of o)a.destroy(!0);s&&s.destroy({children:!0,texture:!0,textureSource:!0})}}}function zo(i,t,e){const s=i?.roofs?.[t]??i?.roofs?.[String(t)];if(!Array.isArray(s)||s.length===0||!e?.length)return!1;const n=new Set(s),o=e.filter(r=>n.has(r)).length;return o>0&&o<e.length?(console.warn(`MapLayer: level ${t} layer mixes roof tiles with others; a roof needs its own layer`),!1):o===e.length}const _t=(i,t,e)=>i+(t-i)*e,Vt=(i,t,e)=>Math.min(e,Math.max(t,i)),Eo=i=>i*(Math.PI/180),Ro=i=>{for(;i>Math.PI;)i-=Math.PI*2;for(;i<-Math.PI;)i+=Math.PI*2;return i},X=(i,t)=>Math.random()*(t-i)+i;class Qt extends U{constructor(t){super(),this._tickListener=null,this._isStarted=!1,this.isComplete=!1,this.onComplete=t}run(){this.isComplete||this._isStarted||(this._isStarted=!0,this._tickListener=t=>this._update(t.deltaMS),j.shared.add(this._tickListener),this._onEffectStart(),this.isComplete||this._update(0))}_onEffectStart(){}_update(){}_completeEffect(){this.isComplete||(this.isComplete=!0,this._tickListener&&(j.shared.remove(this._tickListener),this._tickListener=null),typeof this.onComplete=="function"&&this.onComplete())}destroy(t){this.isComplete=!0,this._tickListener&&(j.shared.remove(this._tickListener),this._tickListener=null),this.parent&&this.parent.removeChild(this),super.destroy({texture:!1,textureSource:!1,...t,children:!0})}}class Io extends Qt{constructor(t,e,s,n,o){super(n),this.x=t,this.y=e,this._textures=o.textures,this._contentSize=o.contentSize,this.config={particleCount:Math.round(X(6,10)),particleMinSize:1.5,particleMaxSize:4,minInitialSpeed:30,maxInitialSpeed:140,maxSpin:12,dragCoefficient:5,minLifetime:1200,maxLifetime:2200,fadeOutStart:.6,color:[7035460,5917240,8022613,4143667]},this.particlesData=[],this._createParticles(s/2)}_createParticles(t){const{config:e}=this;for(let s=0;s<e.particleCount;s+=1){const n=Math.random()*Math.PI*2,o=X(e.minInitialSpeed,e.maxInitialSpeed),r=this._textures[Math.floor(Math.random()*this._textures.length)],a=new K(r),l=X(0,t);a.anchor.set(.5),a.tint=e.color[Math.floor(Math.random()*e.color.length)],a.scale.set(X(e.particleMinSize,e.particleMaxSize)/this._contentSize),this.particlesData.push({sprite:a,x:Math.cos(n)*l,y:Math.sin(n)*l,vx:Math.cos(n)*o,vy:Math.sin(n)*o,rotation:Math.random()*Math.PI*2,spin:X(-e.maxSpin,e.maxSpin),lifetime:X(e.minLifetime,e.maxLifetime),age:0}),this.addChild(a)}}_update(t){if(this.isComplete)return;const{config:e}=this,s=t/1e3,n=Math.max(0,1-e.dragCoefficient*s);let o=0;for(const r of this.particlesData){if(r.age>=r.lifetime)continue;r.age+=t,r.vx*=n,r.vy*=n,r.spin*=n,r.x+=r.vx*s,r.y+=r.vy*s,r.rotation+=r.spin*s;const a=r.age/r.lifetime,{sprite:l}=r;l.position.set(r.x,r.y),l.rotation=r.rotation,l.alpha=a<e.fadeOutStart?1:_t(1,0,Math.min((a-e.fadeOutStart)/(1-e.fadeOutStart),1)),r.age>=r.lifetime?l.visible=!1:o+=1}o===0&&this._isStarted&&this._completeEffect()}destroy(t){this.particlesData=[],super.destroy(t)}}const At=0,Lt=1,Ot=2,ks=3,ae=4,le=5,Bt=6,Ct=7,Ve=8,Re=9,he=11,mt=12,Ie=13,As=14,Ls=15,Fo=0,Do=1,Yo=2,Xo=3,Vo=4,Oo=5,Bo=6,He=7,No=8,Wo=9,Cs=10,Ps=0,zs=1,Es=2,Uo=3,Ho=4,Go=6,$o=0,Ko=1,Zo=2,qo=3,Rs=0,Is=1,Fs=2,jo=3,Jo=4,Qo=5,Ds=0,tr=1,pe=2,er=1,sr=2,ir=1.4;class nr{constructor(t,e,s,n,o={}){this._container=t,this._renderer=s.renderer,this._soundManager=s.soundManager||null,this._assets=o||{},this._levelView=s.levelView||null,this._lighting=s.lighting?.enabled?s.lighting:null,this._glint=null,this._baseScale=Xe(e.scale),t.scale=e.scale,this._assetUrl=`${n}${e.img}`,this._baseTexturePromise=Je.load(this._assetUrl),this._damagedUrl=e.game?.imgDamaged?`${n}${e.game.imgDamaged}`:null,this._destroyedUrl=e.game?.imgDestroyed?`${n}${e.game.imgDestroyed}`:null,this._z=e.level||0,this._level=e.level||0,this._layer=Number(e.layer)||2,t.zIndex=G(this._layer,this._level),this._rotation=Eo(e.angle),this._width=e.width,this._height=e.height,this._x=e.position[0],this._y=e.position[1],this._worldX=this._x*this._baseScale.x,this._worldY=this._y*this._baseScale.y,this._state=null,this.sprite=null,this._scorch=null,this._effects=new Set,this.needsRender=!!this._levelView,this._create()}async _create(){try{const t=await this._baseTexturePromise;if(this._container.destroyed)return;this.sprite=new K(t),this.sprite.x=this._x,this.sprite.y=this._y,this.sprite.width=this._width,this.sprite.height=this._height,this.sprite.rotation=this._rotation,this._container.addChild(this.sprite),this._state!==null&&this._state!==Ds&&this._showState(this._state)}catch(t){console.error(`Failed to create dynamic map with asset ${this._assetUrl}:`,t)}}render(){if(!this._levelView||!this.sprite)return;this._updateGlint(),this._updateCaster();const t=this._container;t.alpha=this._levelView.alphaFor(this._level,this._worldX,this._worldY,this._z),t.tint=this._levelView.tintFor(this._level),!(!this._level&&!this._z)&&ft(t,this._levelView.camera()??gt(t.parent,this._renderer),this._z*W.shear,this._baseScale)}update(t){this.sprite&&(this.sprite.x=t[Rs]/this._baseScale.x,this.sprite.y=t[Is]/this._baseScale.y,this.sprite.rotation=t[Fs]),this._worldX=t[Rs],this._worldY=t[Is],this._rotation=t[Fs],this._z=t[jo]||0;const e=Ee(t[Jo],this._z);e!==this._level&&(this._level=e,this._container.zIndex=G(this._drawLayer(),e),!e&&!this._z&&ft(this._container,null,0,this._baseScale));const s=t[Qo]||Ds;if(s!==this._state){const n=this._state===null;this._state=s,this._showState(s),s===pe&&!n&&this._burst()}this._placeScorch()}_drawLayer(){return this._state===pe?er:this._layer}_standing(){return this._state!==pe||!!this._destroyedUrl}_updateGlint(){const t=Jt.glints,e=this._lighting?.texture("glint"),s=this._localCenter(),n=s.x*this._baseScale.x,o=s.y*this._baseScale.y,r=Math.max(this._width*this._baseScale.x,this._height*this._baseScale.y),a=t?.enabled&&e&&this.sprite.visible&&this._standing()&&this._lighting.isNight()&&this._lighting.onScreen(n,o,this._z,r)?this._lighting.lightsAt(n,o,this._level,1)[0]:null;if(!a){this._glint&&(this._glint.sprite.visible=!1);return}if(!this._glint){const u=new K(e.texture),d=new K;u.anchor.set(.5),u.blendMode="add",u.mask=d,this._container.addChild(d,u),this._glint={sprite:u,mask:d}}const{sprite:l,mask:h}=this._glint,c=this.sprite;h.texture=c.texture,h.position.copyFrom(c.position),h.scale.copyFrom(c.scale),h.rotation=c.rotation,l.texture=e.texture,l.visible=!0,l.position.set(s.x,s.y),l.rotation=a.angle,l.scale.set(Math.max(this._width,this._height)*t.size/e.contentSize),l.tint=a.color,l.alpha=Math.min(1,t.intensity*a.strength)}_updateCaster(){if(!this._lighting)return;if(!this._standing()){this._lighting.setCaster(this,null);return}const t=this._localCenter();this._lighting.setCaster(this,{x:t.x*this._baseScale.x,y:t.y*this._baseScale.y,z:this._z,level:this._level,radius:Math.hypot(this._width*this._baseScale.x,this._height*this._baseScale.y)/2})}_showState(t){if(this._container.zIndex=G(this._drawLayer(),this._level),!this.sprite)return;if(t===pe&&!this._destroyedUrl){this.sprite.visible=!1,this._showScorch();return}this._scorch&&(this._scorch.visible=!1),this.sprite.visible=!0;let e=null;t===tr?e=this._damagedUrl:t===pe&&(e=this._destroyedUrl),this._setTexture(e?Je.load(e):this._baseTexturePromise,t,e??this._assetUrl)}async _setTexture(t,e,s){try{const n=await t;if(this._container.destroyed||!this.sprite||this._state!==e)return;this.sprite.texture=n,this.sprite.width=this._width,this.sprite.height=this._height}catch(n){console.error(`Failed to load map object state asset ${s}:`,n)}}_showScorch(){const t=this._assets.scorchTexture;if(t){if(!this._scorch){const{textures:e,contentSize:s}=t,n=new K(e[Math.floor(Math.random()*e.length)]);n.anchor.set(.5),n.rotation=Math.random()*Math.PI*2,n.scale.set(Math.max(this._width,this._height)*ir/s),this._scorch=n,this._container.addChild(n)}this._scorch.visible=!0,this._placeScorch()}}_placeScorch(){if(!this._scorch?.visible)return;const t=this._localCenter();this._scorch.position.set(t.x,t.y)}_localCenter(){const t=Math.cos(this._rotation),e=Math.sin(this._rotation),s=this._width/2,n=this._height/2;return{x:this._worldX/this._baseScale.x+t*s-e*n,y:this._worldY/this._baseScale.y+e*s+t*n}}_burst(){const t=this._localCenter(),e=t.x*this._baseScale.x,s=t.y*this._baseScale.y;this._soundManager?.registerSound("propBreak",{position:{x:e,y:s}});const n=this._container.parent,o=this._assets.debrisTexture;if(!n||!o)return;const r=Math.max(this._width*this._baseScale.x,this._height*this._baseScale.y),a=new Io(e,s,r,()=>{this._effects.delete(a),a.destroy()},o);a.zIndex=G(sr,this._level),n.addChild(a),this._effects.add(a),a.run()}destroy(){for(const t of this._effects)t.destroy();this._effects.clear(),this._lighting?.setCaster(this,null),this._lighting=null,this._glint=null,this.sprite=null,this._scorch=null,this._baseTexturePromise=null,this._assetUrl=null,this._renderer=null,this._levelView=null,this._soundManager=null}}let or=class extends U{constructor(t,e,s){if(super(),this._mode=null,typeof s.assetsBase!="string"){console.error("Map: сервис assetsBase недоступен — карта останется пустой. Объявите assetsBase в componentDependencies и запустите игру на vimp-engine >= 0.9.0");return}const n=`${s.assetsBase}img/`;this._mode=t.type==="dynamic"?new nr(this,t,s,n,e):new Po(this,t,s,n,e),this._mode.needsRender&&(this.onRender=()=>this._mode.render())}update(t){this._mode?.update?.(t)}destroy(t){const e=this._mode?.destroy();this._mode=null,super.destroy({children:!0,texture:!1,textureSource:!1,...t}),e?.()}};const Ys=[16777215,9418751,10477760,15783820,14721232,10541296,15773836,12632280],xi=i=>Ys[i]??Ys[0],rr=2,ar=.35;class lr extends U{constructor(t,e,s={}){super(),this._map=t.map,this._level=t.level||0,this._solid=t.solid||t.physicsStatic||[],this._tiles=t.tiles||[],this._step=t.step,this.zIndex=G(rr,this._level),this.scale=t.scale,this._draws=this._tiles.some(n=>this._solid.includes(n)),this.radarGraphics=new N,this.addChild(this.radarGraphics),this._levelView=s.levelView||null,this._levelView&&this._draws&&(this.onRender=()=>{this.alpha=this._levelView.level===this._level?1:ar}),this.createRadarMap()}createRadarMap(){if(!this._draws)return;const t=this.radarGraphics;if(t.clear(),Array.isArray(this._map))for(let e=0;e<this._map.length;e+=1){const s=this._map[e];if(Array.isArray(s))for(let n=0;n<s.length;n+=1){const o=s[n];this._solid.includes(o)&&t.rect(n*this._step,e*this._step,this._step/2,this._step/2)}}t.fill(xi(this._level))}update(){}destroy(t){super.destroy({children:!0,texture:!1,textureSource:!1,...t}),this.radarGraphics=null,this._map=null,this._solid=null,this._tiles=null}}const Xs=2,hr=9,cr=1.5;class ur extends U{constructor(t,e){super(),this._level=t[mt]||0,this.zIndex=G(Xs,this._level),this._textures=e.tankRadarTexture,this.body=new K,this.body.anchor.set(.5),this.levelRing=new N,this.addChild(this.levelRing,this.body),this._drawLevelRing(),this.x=t[At]||0,this.y=t[Lt]||0,this._condition=t[Ct],this._teamId=t[Re],this.scale.set(5,5),this.create()}_drawLevelRing(){this.levelRing.clear(),this._level>0&&this.levelRing.circle(0,0,hr).stroke({width:cr,color:xi(this._level)})}create(){this._condition===0?this.body.texture=this._textures.destroyed:this._teamId===1?this.body.texture=this._textures.liveTeamId1:this._teamId===2&&(this.body.texture=this._textures.liveTeamId2)}update(t){this.x=t[At],this.y=t[Lt];const e=t[mt]||0;e!==this._level&&(this._level=e,this.zIndex=G(Xs,e),this._drawLevelRing());const s=t[Ct],n=t[Re];let o=!1;s!==void 0&&s!==this._condition&&(this._condition=s,o=!0),n!==void 0&&n!==this._teamId&&(this._teamId=n,o=!0),o&&this.create()}destroy(t){super.destroy({children:!0,texture:!1,textureSource:!1,...t}),this.body=null,this.levelRing=null,this._textures=null}}function dr({width:i,height:t,anchorX:e,anchorY:s,rotation:n,heading:o=0,pitch:r,roll:a,shear:l,lift:h}){const c=-e*i,u=(1-e)*i,d=-s*t,p=(1-s)*t,m=[[c,d],[u,d],[u,p],[c,p]],g=Math.cos(n),_=Math.sin(n),v=Math.cos(r),M=Math.sin(r),T=Math.cos(a),k=Math.sin(a),A=-Math.sin(o),L=-Math.cos(o),b=[];for(const[Y,z]of m){const R=Y*g-z*_,B=Y*_+z*g,J=R*v,V=R*M,ct=B*T,bt=B*k,it=V+bt,Q=t?it/t*l:0,lt=it*h;b.push(J*(1+Q)+A*lt,ct*(1+Q)+L*lt)}return b}function fr({angle:i,pitch:t,roll:e,lightDir:s,shading:n}){if(!s)return 1;const o=Math.cos(i),r=Math.sin(i),a=-Math.sin(t)*o+Math.sin(e)*r,l=-Math.sin(t)*r-Math.sin(e)*o,h=Math.hypot(s[0],s[1])||1,c=(a*s[0]+l*s[1])/h;return 1-Math.max(0,-c)*n}function jt(i,t){const e=s=>{const n=Math.round((i>>s&255)*t);return Math.min(255,Math.max(0,n))};return e(16)<<16|e(8)<<8|e(0)}function wi(i,t,{minImpact:e,fullImpact:s}){return!(i<-e)||t!==0?0:Math.min(1,-i/s)}function _r(i,t,e){if(i<0||i>=t)return 0;const s=i/t;if(s<e)return s/e;const n=(s-e)/(1-e);return(1-n)*(1-n)}function pr({amount:i,gunRotation:t,config:e}){const s=Math.cos(t),n=Math.sin(t),o=e.gunKick*i,r=e.bodyKick*i,a=e.rock*i;return{gun:{x:-s*o,y:-n*o},body:{x:-s*r,y:-n*r},pitch:a*s,roll:a*n}}const Le=Math.PI*2,mr=.09,gr=.113;function yr(i,t){return!(t>0)||i>=t?0:1-i/t}function xr({x:i,y:t,level:e,heading:s,hullLength:n,blast:o,config:r,rng:a=Math.random}){if((o.level||0)!==(e||0))return null;const l=o.x-i,h=o.y-t,c=Math.hypot(l,h),u=yr(c,o.radius);if(!u)return null;const d=c<r.underShare*n,p=d?a()*Le:Math.atan2(h,l)-s;return{strength:u,dirU:Math.cos(p),dirV:Math.sin(p),hop:d,phaseX:a()*Le,phaseY:a()*Le}}function Vs({elapsed:i,kick:t,config:e}){const s=t.strength,n=e.decay>0?Math.exp(-i/e.decay):0,o=n*Math.cos(Le*e.wobbleHz*(i/1e3)),r=e.rock*s*o,a=t.hop&&i<e.hopDuration,l=a?e.hop*s*Math.sin(Math.PI*i/e.hopDuration):0,c=i<e.shakeDuration?e.shake*s*(1-i/e.shakeDuration):0;return{pitch:r*t.dirU,roll:r*t.dirV,lift:l,shakeX:c*Math.sin(i*mr+t.phaseX),shakeY:c*Math.sin(i*gr+t.phaseY),envelope:s*n,done:i>=e.duration&&!a}}const Os=[[1.33,-.42],[.42,-1],[-.42,-1],[-1.33,-.42],[-1.33,.42],[-.42,1],[.42,1],[1.33,.42]].map(([i,t])=>[i*10,t*10]),Bs={track:0,hull:1,turret:2,barrel:3};function vi(i){let t=0;for(let e=0;e<i.length;e+=1){const[s,n]=i[e],[o,r]=i[(e+1)%i.length];t+=s*r-o*n}return t}function wr(i){let t=0,e=0,s=0;for(let o=0;o<i.length;o+=1){const[r,a,l]=i[o],[h,c,u]=i[(o+1)%i.length];t+=(a-c)*(l+u),e+=(l-u)*(r+h),s+=(r-h)*(a+c)}const n=Math.hypot(t,e,s)||1;return[t/n,e/n,s/n]}const me=(i,t,e,s)=>[[i,e],[t,e],[t,s],[i,s]],vr=(i,t)=>i.map(([e,s])=>[e*t,s*t]);function Sr(i=wt){const t=[],e=[],s=({bottom:r,top:a,w0:l,w1:h,part:c,topMaterial:u,sideMaterial:d})=>{let p=r,m=a;vi(p)<0&&(p=[...p].reverse(),m=[...m].reverse());const g=t.length,_=p.length;for(const[T,k]of p)t.push([T,k,l]);for(const[T,k]of m)t.push([T,k,h]);const v=T=>g+T,M=T=>g+_+T;e.push({indices:m.map((T,k)=>M(k)),part:c,material:u,kind:"top"}),e.push({indices:p.map((T,k)=>v(_-1-k)),part:c,material:"bottom",kind:"bottom"});for(let T=0;T<_;T+=1){const k=(T+1)%_;e.push({indices:[v(T),v(k),M(k),M(T)],part:c,material:d,kind:"side"})}};for(const[r,a]of[[-15,-9],[9,15]]){const l=me(-20,20,r,a);s({bottom:l,top:l,w0:0,w1:i.trackHeight,part:"track",topMaterial:"trackTop",sideMaterial:"trackSide"})}s({bottom:me(-18,18,-9,9),top:me(-16,14,-7,7),w0:i.hullBase,w1:i.hullTop,part:"hull",topMaterial:"hullTop",sideMaterial:"hullSide"}),s({bottom:Os,top:vr(Os,.6),w0:i.turretBase,w1:i.turretTop,part:"turret",topMaterial:"turretTop",sideMaterial:"turretSide"});const n=me(2.5,21,-2.5,2.5);s({bottom:n,top:n,w0:i.barrelHeight-i.barrelRadius,w1:i.barrelHeight+i.barrelRadius,part:"barrel",topMaterial:"barrel",sideMaterial:"barrel"});const o=me(21,24.5,-3.6,3.6);return s({bottom:o,top:o,w0:i.barrelHeight-i.brakeRadius,w1:i.barrelHeight+i.brakeRadius,part:"barrel",topMaterial:"brake",sideMaterial:"brake"}),{vertices:t,faces:e}}const Ns=new Set(["turret","barrel"]);function br({model:i,size:t,gunRotation:e=0,pitch:s=0,roll:n=0,gunKick:o={x:0,y:0},shift:r={x:0,y:0},squash:a=0}){const l=t/10,h=Math.cos(e),c=Math.sin(e),u=Math.cos(s),d=Math.sin(s),p=Math.cos(n),m=Math.sin(n),g=1-a,_=new Array(i.vertices.length);for(const A of i.faces)for(const L of A.indices)_[L]=A.part;const v=([A,L,b])=>{const Y=L*p-b*m,z=L*m+b*p;return[A*u-z*d,Y,A*d+z*u]},M=([A,L,b])=>[A*h-L*c,A*c+L*h,b],T=i.vertices.map(([A,L,b],Y)=>{let z=[A*l,L*l,b*l*g];const R=_[Y];return Ns.has(R)&&(z=M(z)),R==="barrel"&&(z=[z[0]+o.x,z[1]+o.y,z[2]]),z=v(z),[z[0]+r.x,z[1]+r.y,z[2]]}),k=i.faces.map(A=>{let L=Mr(i,A,g);return Ns.has(A.part)&&(L=M(L)),v(L)});return{points:T,normals:k}}function Mr(i,t,e){return wr(t.indices.map(s=>{const[n,o,r]=i.vertices[s];return[n,o,r*e]}))}function Tr({x:i,y:t,camera:e,heading:s,shear:n,levelHeight:o,maxLean:r,topHeight:a,gain:l=1}){if(!e)return{x:0,y:0};let h=(i-e.x)*n*l/o,c=(t-e.y)*n*l/o;const u=Math.hypot(h,c)*a;if(u>0&&r>0){const m=r*Math.tanh(u/r)/u;h*=m,c*=m}const d=Math.cos(s),p=Math.sin(s);return{x:h*d+c*p,y:-h*p+c*d}}function kr({points:i,lean:t,zScale:e=1}){return i.map(([s,n,o])=>[(s+t.x*o)*e,(n+t.y*o)*e])}function Ar({model:i,points:t,projected:e}){const s=[];return i.faces.forEach((n,o)=>{const r=n.indices.map(a=>e[a]);if(vi(r)>1e-9){let a=0;for(const l of n.indices)a+=t[l][2];s.push({index:o,height:a/n.indices.length,face:n})}}),s.sort((n,o)=>Bs[n.face.part]-Bs[o.face.part]||n.height-o.height||n.index-o.index),s.map(n=>n.index)}function Lr(i,t,e){const s=Math.cos(t),n=Math.sin(t),o=i[0]*s-i[1]*n,r=i[0]*n+i[1]*s,a=o*e.uLight[0]+r*e.uLight[1]+i[2]*e.uLight[2];return(e.uAmbient+e.uDiffuse*Math.max(a,0))*e.uNorm}const Cr={track:"body",hull:"body",turret:"gun",barrel:"gun"},Pr={trackSide:"trackSide",barrel:"barrelSide",brake:"brakeSide"};function zr(i,t){const[e,s,n,o]=t.indices.map(r=>i.vertices[r]);return t.indices.length===4&&e[0]===o[0]&&e[1]===o[1]&&s[0]===n[0]&&s[1]===n[1]}function Er(i,t){const{width:e,height:s,regions:n}=t,o=([r,a])=>[r/e,a/s];return i.faces.map(r=>{if(r.kind==="bottom"){const{x:h,y:c,w:u,h:d}=n.bottom;return r.indices.map(()=>o([h+u/2,c+d/2]))}const a=Pr[r.material];if(r.kind==="side"&&a&&zr(i,r)){const h=n[a],[c,u]=r.indices.map(g=>i.vertices[g]),d=Math.min(Math.hypot(u[0]-c[0],u[1]-c[1]),h.w),p=h.y,m=h.y+h.h;return[o([h.x,m]),o([h.x+d,m]),o([h.x+d,p]),o([h.x,p])]}const l=n[Cr[r.part]];return r.indices.map(h=>{const[c,u]=i.vertices[h];return o([l.originX+c,l.originY+u])})})}const Rr=`#version 300 es
|
|
85
|
+
in vec2 aPosition;
|
|
86
|
+
in vec2 aUv;
|
|
87
|
+
in float aShade;
|
|
88
|
+
|
|
89
|
+
out vec2 vUV;
|
|
90
|
+
out float vShade;
|
|
91
|
+
out vec4 vColor;
|
|
92
|
+
|
|
93
|
+
uniform mat3 uProjectionMatrix;
|
|
94
|
+
uniform mat3 uWorldTransformMatrix;
|
|
95
|
+
uniform vec4 uWorldColorAlpha;
|
|
96
|
+
uniform vec2 uResolution;
|
|
97
|
+
|
|
98
|
+
uniform mat3 uTransformMatrix;
|
|
99
|
+
uniform vec4 uColor;
|
|
100
|
+
uniform float uRound;
|
|
101
|
+
|
|
102
|
+
uniform mat3 uTextureMatrix;
|
|
103
|
+
|
|
104
|
+
void main(void) {
|
|
105
|
+
mat3 mvp = uProjectionMatrix * uWorldTransformMatrix * uTransformMatrix;
|
|
106
|
+
|
|
107
|
+
gl_Position = vec4((mvp * vec3(aPosition, 1.0)).xy, 0.0, 1.0);
|
|
108
|
+
|
|
109
|
+
if (uRound == 1.0) {
|
|
110
|
+
gl_Position.xy =
|
|
111
|
+
(floor(((gl_Position.xy * 0.5 + 0.5) * uResolution) + 0.5) /
|
|
112
|
+
uResolution) * 2.0 - 1.0;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
vUV = (uTextureMatrix * vec3(aUv, 1.0)).xy;
|
|
116
|
+
vShade = aShade;
|
|
117
|
+
vColor = uColor * uWorldColorAlpha;
|
|
118
|
+
}
|
|
119
|
+
`,Ir=`#version 300 es
|
|
120
|
+
in vec2 vUV;
|
|
121
|
+
in float vShade;
|
|
122
|
+
in vec4 vColor;
|
|
123
|
+
|
|
124
|
+
out vec4 finalColor;
|
|
125
|
+
|
|
126
|
+
uniform sampler2D uTexture;
|
|
127
|
+
|
|
128
|
+
void main(void) {
|
|
129
|
+
vec4 color = texture(uTexture, vUV);
|
|
130
|
+
|
|
131
|
+
finalColor = vec4(color.rgb * vShade, color.a) * vColor;
|
|
132
|
+
}
|
|
133
|
+
`;let Ws=null;function Fr(i){return Ws||=rs.from({vertex:Rr,fragment:Ir,name:"tank-model"}),new ni({glProgram:Ws,resources:{uTexture:i.source,textureUniforms:new Pe({uTextureMatrix:{value:i.textureMatrix.mapCoord,type:"mat3x3<f32>"}})}})}function Dr(i,t){i.resources.uTexture=t.source,i.resources.textureUniforms.uniforms.uTextureMatrix=t.textureMatrix.mapCoord}function Yr(i,t){const e=[];let s=0,n=0;for(const p of i.faces)e.push(s),s+=p.indices.length,n+=p.indices.length-2;const o=new Float32Array(s*2),r=new Float32Array(s*2),a=new Float32Array(s).fill(1),l=new Uint32Array(n*3),h=p=>{Er(i,p).forEach((m,g)=>{m.forEach(([_,v],M)=>{r[(e[g]+M)*2]=_,r[(e[g]+M)*2+1]=v})})};h(t);const c=new Oi({attributes:{aPosition:{buffer:o,format:"float32x2"},aUv:{buffer:r,format:"float32x2"},aShade:{buffer:a,format:"float32"}},indexBuffer:l}),u=Fr(t.texture),d=new oi({geometry:c,shader:u,texture:t.texture});return{mesh:d,setAtlas(p){h(p),c.getBuffer("aUv").update(),Dr(u,p.texture),d.texture=p.texture},update(p,m,g){i.faces.forEach((v,M)=>{const T=e[M];v.indices.forEach((k,A)=>{o[(T+A)*2]=p[k][0],o[(T+A)*2+1]=p[k][1],a[T+A]=m[M]})});let _=0;for(const v of g){const M=e[v],T=i.faces[v].indices.length;for(let k=1;k<T-1;k+=1)l[_]=M,l[_+1]=M+k,l[_+2]=M+k+1,_+=3}l.fill(0,_),c.getBuffer("aPosition").update(),c.getBuffer("aShade").update(),c.indexBuffer.update()},destroy(){d.destroy(),u.destroy(),c.destroy()}}}function Xr(i){const t=[...i].sort((o,r)=>o[0]-r[0]||o[1]-r[1]);if(t.length<3)return t;const e=(o,r,a)=>(r[0]-o[0])*(a[1]-o[1])-(r[1]-o[1])*(a[0]-o[0]),s=[],n=[];for(const o of t){for(;s.length>=2&&e(s[s.length-2],s[s.length-1],o)<=0;)s.pop();s.push(o)}for(let o=t.length-1;o>=0;o-=1){const r=t[o];for(;n.length>=2&&e(n[n.length-2],n[n.length-1],r)<=0;)n.pop();n.push(r)}return s.pop(),n.pop(),s.concat(n)}function Vr(i,t,e){if(!i)return{x:0,y:0};const s=Math.hypot(i[0],i[1])||1,n=-i[0]/s/t,o=-i[1]/s/t,r=Math.cos(e),a=Math.sin(e);return{x:n*r+o*a,y:-n*a+o*r}}function Or({model:i,points:t,lift:e=0,drift:s}){const n=new Map;for(const r of i.faces){n.has(r.part)||n.set(r.part,new Set);for(const a of r.indices)n.get(r.part).add(a)}const o=[];for(const r of n.values()){const a=[...r].map(l=>{const[h,c,u]=t[l],d=Math.max(0,u+e);return[h+s.x*d,c+s.y*d]});o.push(Xr(a))}return o}const Br=`#version 300 es
|
|
134
|
+
in vec2 aPosition;
|
|
135
|
+
in vec2 aUV;
|
|
136
|
+
|
|
137
|
+
out vec2 vUV;
|
|
138
|
+
out vec4 vColor;
|
|
139
|
+
|
|
140
|
+
uniform mat3 uProjectionMatrix;
|
|
141
|
+
uniform mat3 uWorldTransformMatrix;
|
|
142
|
+
uniform vec4 uWorldColorAlpha;
|
|
143
|
+
uniform vec2 uResolution;
|
|
144
|
+
|
|
145
|
+
uniform mat3 uTransformMatrix;
|
|
146
|
+
uniform vec4 uColor;
|
|
147
|
+
uniform float uRound;
|
|
148
|
+
|
|
149
|
+
uniform mat3 uTextureMatrix;
|
|
150
|
+
|
|
151
|
+
void main(void) {
|
|
152
|
+
mat3 mvp = uProjectionMatrix * uWorldTransformMatrix * uTransformMatrix;
|
|
153
|
+
|
|
154
|
+
gl_Position = vec4((mvp * vec3(aPosition, 1.0)).xy, 0.0, 1.0);
|
|
155
|
+
|
|
156
|
+
if (uRound == 1.0) {
|
|
157
|
+
gl_Position.xy =
|
|
158
|
+
(floor(((gl_Position.xy * 0.5 + 0.5) * uResolution) + 0.5) /
|
|
159
|
+
uResolution) * 2.0 - 1.0;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
vUV = (uTextureMatrix * vec3(aUV, 1.0)).xy;
|
|
163
|
+
// тинт уровня и прозрачность (премультиплицированы, как у меша PixiJS)
|
|
164
|
+
vColor = uColor * uWorldColorAlpha;
|
|
165
|
+
}
|
|
166
|
+
`,Nr=`#version 300 es
|
|
167
|
+
in vec2 vUV;
|
|
168
|
+
in vec4 vColor;
|
|
169
|
+
|
|
170
|
+
out vec4 finalColor;
|
|
171
|
+
|
|
172
|
+
uniform sampler2D uTexture;
|
|
173
|
+
uniform sampler2D uNormal;
|
|
174
|
+
|
|
175
|
+
uniform vec2 uSpin;
|
|
176
|
+
uniform vec2 uPitch;
|
|
177
|
+
uniform vec2 uRoll;
|
|
178
|
+
uniform vec2 uHeading;
|
|
179
|
+
uniform vec3 uLight;
|
|
180
|
+
uniform float uAmbient;
|
|
181
|
+
uniform float uDiffuse;
|
|
182
|
+
uniform float uNorm;
|
|
183
|
+
|
|
184
|
+
vec2 turn(vec2 v, vec2 cs) {
|
|
185
|
+
return vec2(v.x * cs.x - v.y * cs.y, v.x * cs.y + v.y * cs.x);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
void main(void) {
|
|
189
|
+
vec4 color = texture(uTexture, vUV);
|
|
190
|
+
vec4 encoded = texture(uNormal, vUV);
|
|
191
|
+
vec3 n = vec3(0.0, 0.0, 1.0);
|
|
192
|
+
|
|
193
|
+
// запечённая текстура премультиплицирована: на кромке антиалиасинга
|
|
194
|
+
// нормаль делится на свою альфу, а пустота считается плоской
|
|
195
|
+
if (encoded.a > 0.01) {
|
|
196
|
+
n = normalize(encoded.rgb / encoded.a * 2.0 - 1.0);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
n.xy = turn(n.xy, uSpin);
|
|
200
|
+
// тангаж: нос +u вверх — нормаль к корме
|
|
201
|
+
n = vec3(n.x * uPitch.x - n.z * uPitch.y, n.y, n.x * uPitch.y + n.z * uPitch.x);
|
|
202
|
+
// крен: борт +v вверх — нормаль к борту −v
|
|
203
|
+
n = vec3(n.x, n.y * uRoll.x - n.z * uRoll.y, n.y * uRoll.y + n.z * uRoll.x);
|
|
204
|
+
n.xy = turn(n.xy, uHeading);
|
|
205
|
+
|
|
206
|
+
float light = (uAmbient + uDiffuse * max(dot(n, uLight), 0.0)) * uNorm;
|
|
207
|
+
|
|
208
|
+
finalColor = vec4(color.rgb * light, color.a) * vColor;
|
|
209
|
+
}
|
|
210
|
+
`,Me=i=>[Math.cos(i),Math.sin(i)];function Si({heading:i,rotation:t,pitch:e,roll:s,lightDir:n,lightZ:o,ambient:r,diffuse:a}){const[l,h]=n||[0,0],c=Math.hypot(l,h,o)||1,u=[l/c,h/c,o/c],d=r+a*Math.max(u[2],0);return{uSpin:Me(t),uPitch:Me(e),uRoll:Me(s),uHeading:Me(i),uLight:u,uAmbient:r,uDiffuse:a,uNorm:d?1/d:1}}let Us=null;function Wr(i,t){return Us||=rs.from({vertex:Br,fragment:Nr,name:"tank-light"}),new ni({glProgram:Us,resources:{uTexture:i.source,uNormal:t.source,textureUniforms:new Pe({uTextureMatrix:{value:i.textureMatrix.mapCoord,type:"mat3x3<f32>"}}),tankLight:new Pe({uSpin:{value:new Float32Array([1,0]),type:"vec2<f32>"},uPitch:{value:new Float32Array([1,0]),type:"vec2<f32>"},uRoll:{value:new Float32Array([1,0]),type:"vec2<f32>"},uHeading:{value:new Float32Array([1,0]),type:"vec2<f32>"},uLight:{value:new Float32Array([0,0,1]),type:"vec3<f32>"},uAmbient:{value:1,type:"f32"},uDiffuse:{value:0,type:"f32"},uNorm:{value:1,type:"f32"}})}})}function Ur(i,t,e){i.resources.uTexture=t.source,i.resources.uNormal=e.source,i.resources.textureUniforms.uniforms.uTextureMatrix=t.textureMatrix.mapCoord}function Hr(i,t){const e=i.resources.tankLight.uniforms;for(const s of["uSpin","uPitch","uRoll","uHeading","uLight"])e[s].set(t[s]);e.uAmbient=t.uAmbient,e.uDiffuse=t.uDiffuse,e.uNorm=t.uNorm}const Gr=0,$r=1,Te=3;let Hs=null;const Ge=()=>(Hs||=Sr(wt),Hs),Kr=()=>Si({heading:0,rotation:0,pitch:0,roll:0,lightDir:Et.lightDir,lightZ:qt.lightZ,ambient:qt.ambient,diffuse:qt.diffuse}),Zr=.55,qr=.6,Gs=7,jr=1,$s=1.15,Jr=1.25,Qr=.6,ta=1,ea=.015,sa=2.5;function ia(i,t=0){const e=Number.isFinite(i)?i:0,s=Vt(e,0,1),n=Math.max(0,e-1),o=_t(jr,$s,s)+(Jr-$s)*n,r=_t(Qr,ta,s),a=1+ea*(1-s)*Math.sin(2*Math.PI*sa*(t/1e3));return{rate:o*a,volumeFactor:r}}function na(i=Et.lightDir,t=Mt.groundOffset){const e=i?Math.hypot(i[0],i[1]):0;return!e||!t?{x:0,y:0}:{x:-i[0]/e*t,y:-i[1]/e*t}}class oa extends U{constructor(t,e,s,n){super();const o=()=>{const u=new Bi({verticesX:Et.vertices,verticesY:Et.vertices});return u.geometry.batchMode="batch",u};this.body=o(),this.gun=o(),this.wreck=o(),this._bodyAnchor={x:.5,y:.5},this._wreckAnchor={x:.5,y:.5},this.addChild(this.body,this.gun,this.wreck),this._lightShaders=new Map,this._textures=e.tankTexture,this._modelAtlases=wt.enabled&&e.tankModelTexture?e.tankModelTexture:null,this._model=null,this._modelShadow=null,this._wreckSkew=0,this._shadowAsset=e.tankShadowTexture||null,this._renderer=s.renderer||null,this._shadow=null,this._worldX=t[At]||0,this._worldY=t[Lt]||0,this.x=this._worldX,this.y=this._worldY,this.rotation=t[Ot]||0,this._gunRotation=t[ks]||0,this._engineLoad=t[Bt]||0,this._condition=t[Ct],this._size=t[Ve],this._teamId=t[Re],this._z=t[he]||0,this._physLevel=t[mt]||0,this._vz=t[Ie]||0,this._prevVz=this._vz,this._pitch=t[As]||0,this._roll=t[Ls]||0,this._landImpact=0,this._landTimer=0,this._squash=0,this._level=Ee(t[mt],this._z),this.zIndex=G(Te,this._level),this._isLocal=()=>s.localPlayer?.is(n?.id)===!0,this._recoilElapsed=1/0,this._recoilTilt={pitch:0,roll:0},this._recoilOffsets={body:{x:0,y:0},gun:{x:0,y:0}},this._blastKick=null,this._blastElapsed=0,this._blastTilt={pitch:0,roll:0},this._blastLift=0,this._blastShake={x:0,y:0},this._unsubscribeBlasts=s.blasts?s.blasts.subscribe(u=>this._onBlast(u)):null,this._unsubscribeShots=s.shots&&n?.id!==void 0?s.shots.subscribe(n.id,{fired:()=>this._onFired(),muzzle:()=>this._muzzleWorld()}):null,this._levelView=s.levelView||null,this._levelView?.setDiagnostics(s.diagnostics??null),this._lighting=s.lighting?.enabled?s.lighting:null,this._headlights=null,this._glint=null,this._lighting&&e.headlightConeTexture&&this._lighting.registerTextures({cone:e.headlightConeTexture}),this.onRender=()=>this._updateView();const r=this._teamId===1?this._textures.liveTeamId1:this._textures.liveTeamId2,a=r?r.gunAnchor:null;this._gunAnchor=a?{x:a.x,y:a.y}:{x:.5,y:.5};const l=10;this._scaleFactor=this._size/l,this._soundManager=s.soundManager,this._soundId=null;const h=this._soundManager.getSoundConfig("tankEngine");this._baseEngineVolume=h?.volume||0,this._hasEngineSound=!!h,this._surfaces=s.surfaces||null,this._waterSoundId=null,this._speed=Math.hypot(t[ae]||0,t[le]||0);const c=this._soundManager.getSoundConfig("tankWater");this._baseWaterVolume=c?.volume||0,this._hasWaterSound=!!c,this.create()}_initSounds(){this._soundId||this._condition===0||!this._hasEngineSound||(this._soundId=this._soundManager.registerSound("tankEngine",this._getSoundData()))}_getSoundData(){const{rate:t,volumeFactor:e}=ia(this._engineLoad,performance.now());return{position:{x:this._worldX,y:this._worldY},rate:t,volume:this._baseEngineVolume*e,spatial:!this._isLocal()}}create(){if(this._condition===0){this.body.visible=!1,this.gun.visible=!1,this._setTexture(this.wreck,this._textures.destroyed,this._textures.destroyedNormal);const t=this._modelAtlases?.destroyed;t?(this._wreckSkew=(Math.random()*2-1)*qr,this._showModel(t),this.wreck.visible=!1):(this._model&&(this._model.mesh.visible=!1),this.wreck.visible=!0),this._gunRotation=0,this._resetRecoil(),this.destroySounds(),this._removeLights()}else{this.wreck.visible=!1;let t;this._teamId===1?t=this._textures.liveTeamId1:this._teamId===2&&(t=this._textures.liveTeamId2),this._setTexture(this.body,t.body,t.bodyNormal),this._setTexture(this.gun,t.gun,t.gunNormal);const e=this._modelAtlas();e?this._showModel(e):(this.body.visible=!0,this.gun.visible=!0),this._initSounds(),this._addLights()}this._applyTilt()}update(t){this._worldX=t[At],this._worldY=t[Lt],this.rotation=t[Ot],this._gunRotation=t[ks],this._engineLoad=t[Bt]||0,this._speed=Math.hypot(t[ae]||0,t[le]||0),this._z=t[he]||0,this._physLevel=t[mt]||0,this._vz=t[Ie]||0,this._pitch=t[As]||0,this._roll=t[Ls]||0;const e=wi(this._prevVz,this._vz,Kt);e>0&&(this._landImpact=e,this._landTimer=Kt.duration),this._prevVz=this._vz;const s=Ee(t[mt],this._z);s!==this._level&&(this._level=s,this.zIndex=G(Te,s)),this._applyTilt(),this._levelView&&this._isLocal()&&this._levelView.set(s,this._worldX,this._worldY,this._z),this._condition>0&&(this._soundId===null?this._initSounds():this._soundManager.updateSoundData(this._soundId,this._getSoundData()));const n=t[Ct],o=t[Re];let r=!1;n!==void 0&&n!==this._condition&&(this._condition=n,r=!0),o!==void 0&&o!==this._teamId&&(this._teamId=o,r=!0),r&&this.create(),this._updateLights(),this._updateWaterSound()}_updateWaterSound(){if(!(this._hasWaterSound&&this._condition>0&&this._vz===0&&this._surfaces?.kindAt(this._worldX,this._worldY,this._physLevel)==="water")){this._removeWaterSound();return}this._waterSoundId===null?this._waterSoundId=this._soundManager.registerSound("tankWater",this._getWaterSoundData()):this._soundManager.updateSoundData(this._waterSoundId,this._getWaterSoundData())}_getWaterSoundData(){const{minVolume:t,fullSpeed:e,rate:s}=kt.water.sound,n=Vt(this._speed/e,0,1);return{position:{x:this._worldX,y:this._worldY},rate:_t(s.min,s.max,n),volume:this._baseWaterVolume*(t+(1-t)*n),spatial:!this._isLocal()}}_removeWaterSound(){this._waterSoundId&&(this._soundManager.unregisterSound(this._waterSoundId),this._waterSoundId=null)}_headlightPoints(){const t=Math.cos(this.rotation),e=Math.sin(this.rotation),s=this._size*2,n=this._size*1.5*Jt.headlights.offset,o=this._worldX+t*s,r=this._worldY+e*s;return[{x:o+e*n,y:r-t*n},{x:o-e*n,y:r+t*n}]}_addLights(){if(!this._lighting||this._headlights)return;const{headlights:t,tankGlow:e}=Jt,s=()=>this._lighting.addLight({kind:"cone",radius:t.length,spread:t.spread,color:t.color,intensity:t.intensity});this._headlights={cones:[s(),s()],glow:this._lighting.addLight({kind:"radial",radius:e.radius,color:e.color,intensity:e.intensity})},this._updateLights()}_updateLights(){if(!this._headlights)return;const t=this._level,e=this._z,s=Nn(this._physLevel,e,this._vz!==0),n=this._headlightPoints();for(let o=0;o<2;o+=1)this._lighting.updateLight(this._headlights.cones[o],{x:n[o].x,y:n[o].y,z:e,level:t,levels:s,rotation:this.rotation});this._lighting.updateLight(this._headlights.glow,{x:this._worldX,y:this._worldY,z:e,level:t,levels:s})}_removeLights(){this._headlights&&(this._lighting.removeLight(this._headlights.cones[0]),this._lighting.removeLight(this._headlights.cones[1]),this._lighting.removeLight(this._headlights.glow),this._headlights=null)}_onFired(){if(this._condition===0)return;const t=$t.attack*$t.duration;this._recoilElapsed=this._recoilElapsed<$t.duration?Math.min(this._recoilElapsed,t):0}_muzzleWorld(){if(this._condition===0||this.destroyed)return null;const t=this.rotation+this._gunRotation,e=this._size*4*Zr;return{x:this._worldX+Math.cos(t)*e,y:this._worldY+Math.sin(t)*e}}_resetRecoil(){this._recoilElapsed=1/0,this._recoilTilt.pitch=0,this._recoilTilt.roll=0,this._recoilOffsets.body.x=0,this._recoilOffsets.body.y=0,this._recoilOffsets.gun.x=0,this._recoilOffsets.gun.y=0}_stepRecoil(){if(this._recoilElapsed===1/0)return;this._recoilElapsed+=j.shared.deltaMS;const t=_r(this._recoilElapsed,$t.duration,$t.attack);if(t===0&&this._recoilElapsed>=$t.duration){this._resetRecoil();return}const e=pr({amount:t,gunRotation:this._gunRotation,config:$t});this._recoilOffsets.body=e.body,this._recoilOffsets.gun=e.gun,this._recoilTilt.pitch=e.pitch,this._recoilTilt.roll=e.roll}_onBlast(t){if(this.destroyed)return;const e=xr({x:this._worldX,y:this._worldY,level:this._physLevel,heading:this.rotation,hullLength:this._size*4,blast:t,config:de});if(!e)return;const s=this._blastKick?Vs({elapsed:this._blastElapsed,kick:this._blastKick,config:de}).envelope:0;e.strength>=s&&(this._blastKick=e,this._blastElapsed=0)}_stepBlast(){if(!this._blastKick)return;const t=this._blastKick.hop&&this._blastElapsed<de.hopDuration;this._blastElapsed+=j.shared.deltaMS;const e=Vs({elapsed:this._blastElapsed,kick:this._blastKick,config:de});if(t&&this._blastElapsed>=de.hopDuration&&Kt.duration>0&&(this._landImpact=this._blastKick.strength,this._landTimer=Kt.duration),e.done){this._resetBlast();return}this._blastTilt.pitch=e.pitch,this._blastTilt.roll=e.roll,this._blastLift=e.lift,this._blastShake.x=e.shakeX,this._blastShake.y=e.shakeY}_resetBlast(){this._blastKick=null,this._blastElapsed=0,this._blastTilt.pitch=0,this._blastTilt.roll=0,this._blastLift=0,this._blastShake.x=0,this._blastShake.y=0}_viewZ(){return this._z+this._blastLift}_applyMeshOffsets(){const t=1+this._viewZ()*W.shear,{body:e,gun:s}=this._recoilOffsets,n=e.x+this._blastShake.x,o=e.y+this._blastShake.y;this.body.position.set(n*t,o*t),this.wreck.position.set(this._blastShake.x*t,this._blastShake.y*t),this.gun.position.set((n+s.x)*t,(o+s.y)*t)}_setTexture(t,e,s){t.texture=e;const n=this._lightShaders.get(t);if(!s){n&&(t.shader=null,n.destroy(),this._lightShaders.delete(t));return}if(n)Ur(n,e,s);else{const o=Wr(e,s);t.shader=o,this._lightShaders.set(t,o)}}_applyLight(){for(const[t,e]of this._lightShaders)Hr(e,Si({heading:this.rotation,rotation:t===this.gun?this._gunRotation:0,pitch:this._pitch+this._recoilTilt.pitch+this._blastTilt.pitch,roll:this._roll+this._recoilTilt.roll+this._blastTilt.roll,lightDir:Et.lightDir,lightZ:qt.lightZ,ambient:qt.ambient,diffuse:qt.diffuse}))}_setCorners(t,e,s,n,o){const{texture:r}=t;t.setCorners(...dr({width:r.width*n,height:r.height*n*o,anchorX:e.x,anchorY:e.y,rotation:s,heading:this.rotation,pitch:this._pitch+this._recoilTilt.pitch+this._blastTilt.pitch,roll:this._roll+this._recoilTilt.roll+this._blastTilt.roll,shear:W.shear,lift:Et.lift}))}_groundZ(){return this._vz!==0?this._physLevel:this._z}_applyTilt(){const t=1+this._viewZ()*W.shear,e=this._scaleFactor*t,s=1-this._squash;this._setCorners(this.body,this._bodyAnchor,0,e,s),this._setCorners(this.gun,this._gunAnchor,this._gunRotation,e,s),this._setCorners(this.wreck,this._wreckAnchor,0,e,s)}_updateView(){this._levelView&&this._levelView.attachStage(this.parent,this._renderer);const t=this._levelView?this._levelView.camera():gt(this.parent,this._renderer);this._lighting&&(this._lighting.attachStage(this.parent,this._renderer),this._lighting.render());let e=16777215;this._levelView&&(this.alpha=this._levelView.alphaFor(this._level,this._worldX,this._worldY,this._z),e=this._levelView.tintFor(this._level),this.tint=e),this._stepBlast();const s=dt(this._worldX,this._worldY,t,this._viewZ()*W.shear);if(this.position.set(s.x,s.y),this._lightShaders.size===0&&!this._model?.mesh.visible){const n=Vt(fr({angle:this.rotation,pitch:this._pitch,roll:this._roll,lightDir:Et.lightDir,shading:Et.shading}),Gr,$r);this.tint=jt(e,n)}if(this._landTimer>0){this._landTimer=Math.max(0,this._landTimer-j.shared.deltaMS);const n=this._landTimer/Kt.duration;this._squash=Math.sin(n*Math.PI)*Kt.squash*this._landImpact}else this._squash=0;this._stepRecoil(),this._applyMeshOffsets(),this._applyTilt(),this._applyLight(),this._applyModel(t),this._updateShadow(t),this._updateGlint(),this._updateCaster()}_updateGlint(){const t=Jt.glints,e=this._lighting?.texture("glint"),s=1+this._viewZ()*W.shear,n=this._size*2*s,o=t?.enabled&&e&&this._lighting.isNight()&&this._lighting.onScreen(this._worldX,this._worldY,this._viewZ(),n)?this._lighting.lightsAt(this._worldX,this._worldY,this._level,1,this._headlights?[...this._headlights.cones,this._headlights.glow]:null)[0]:null;if(!o){this._glint&&(this._glint.sprite.visible=!1);return}if(!this._glint){const d=new K(e.texture),p=new K;d.anchor.set(.5),d.blendMode="add",d.mask=p,this.addChild(p,d),this._glint={sprite:d,mask:p}}const{sprite:r,mask:a}=this._glint,l=this._condition===0,h=l?this.wreck:this.body,c=l?this._wreckAnchor:this._bodyAnchor,u=this._scaleFactor*s;this.children[this.children.length-1]!==r&&this.addChild(r),a.texture=h.texture,a.anchor.set(c.x,c.y),a.position.copyFrom(h.position),a.scale.set(u,u*(1-this._squash)),r.texture=e.texture,r.visible=!0,r.position.copyFrom(h.position),r.rotation=o.angle-this.rotation,r.scale.set(Math.max(h.texture.width,h.texture.height)*u*t.size/e.contentSize),r.tint=o.color,r.alpha=Math.min(1,t.intensity*o.strength)}_updateCaster(){this._lighting&&this._lighting.setCaster(this,{x:this._worldX,y:this._worldY,z:this._z,level:this._level,radius:this._size*2})}_modelAtlas(){return this._modelAtlases?this._teamId===2?this._modelAtlases.liveTeamId2:this._modelAtlases.liveTeamId1:null}_showModel(t){this._model?this._model.setAtlas(t):(this._model=Yr(Ge(),t),this.addChild(this._model.mesh)),this._model.mesh.visible=!0,this.body.visible=!1,this.gun.visible=!1}_applyModel(t){if(!this._model||!this._model.mesh.visible)return;const e=Ge(),s=br({model:e,size:this._size,gunRotation:this._condition===0?this._wreckSkew:this._gunRotation,pitch:this._pitch+this._recoilTilt.pitch+this._blastTilt.pitch,roll:this._roll+this._recoilTilt.roll+this._blastTilt.roll,gunKick:this._recoilOffsets.gun,shift:{x:this._recoilOffsets.body.x+this._blastShake.x,y:this._recoilOffsets.body.y+this._blastShake.y},squash:this._squash}),n=Tr({x:this._worldX,y:this._worldY,camera:t,heading:this.rotation,shear:W.shear,levelHeight:wt.levelHeight,maxLean:wt.maxLean,gain:wt.leanGain,topHeight:wt.turretTop*this._size/10}),o=kr({points:s.points,lean:n,zScale:1+this._viewZ()*W.shear});this._modelPose=s;const r=Ar({model:e,points:s.points,projected:o}),a=Kr(),l=s.normals.map(h=>Lr(h,this.rotation,a));this._model.update(o,l,r)}_modelShadowActive(){return this._condition!==0&&this._model!==null&&this._model.mesh.visible&&this._modelPose!==void 0&&this.parent!==null}_updateModelShadow(t){if(!this._modelShadow){const h=new N;this._modelShadowAlpha=new ri({alpha:1}),h.filters=wt.shadowBlur?[new vt({strength:wt.shadowBlur,quality:2}),this._modelShadowAlpha]:[this._modelShadowAlpha],this.parent.addChild(h),this._modelShadow=h}const e=this._modelShadow,s=this._groundZ(),n=dt(this._worldX,this._worldY,t,s*W.shear),o=Math.max(0,this._viewZ()-s);e.visible=!0,e.position.set(n.x,n.y),e.rotation=this.rotation,e.scale.set(1+s*W.shear),e.zIndex=G(Te-1,Math.min(Gs,Math.floor(s)));const r=Or({model:Ge(),points:this._modelPose.points,lift:o*wt.levelHeight,drift:Vr(Et.lightDir,qt.lightZ,this.rotation)});e.clear();for(const h of r)e.poly(h.flat()).fill(0);const l=this._vz!==0||this._blastLift>0?Math.max(0,Mt.baseAlpha-o*Mt.alphaFalloff):Mt.groundAlpha;this._modelShadowAlpha.alpha=l*this.alpha}_updateShadow(t){if(this._modelShadowActive()){this._shadow&&(this._shadow.visible=!1),this._updateModelShadow(t);return}if(this._modelShadow&&(this._modelShadow.visible=!1),!this._shadowAsset||!this.parent)return;const e=this._vz!==0;if(!(this._condition!==0&&(e||Mt.groundOffset>0))){this._shadow&&(this._shadow.visible=!1);return}if(!this._shadow){const{texture:c,contentSize:u}=this._shadowAsset;this._shadow=new K(c),this._shadow.anchor.set(.5),this._shadowScale=this._size*4*Mt.sizeFactor/u,this.parent.addChild(this._shadow)}const n=this._shadow;n.visible=!0;const o=this._groundZ(),r=dt(this._worldX,this._worldY,t,o*W.shear),a=na();n.x=r.x+a.x,n.y=r.y+a.y,n.rotation=this.rotation;const l=Math.max(0,this._z-o);n.scale.set(this._shadowScale*(1+l*Mt.scaleGain));const h=e?Math.max(0,Mt.baseAlpha-l*Mt.alphaFalloff):Mt.groundAlpha;n.alpha=h*this.alpha,n.zIndex=G(Te-1,Math.min(Gs,Math.floor(o)))}destroySounds(){this._soundId&&(this._soundManager.unregisterSound(this._soundId),this._soundId=null),this._removeWaterSound()}destroy(t){this.destroySounds(),this._removeLights(),this._lighting?.setCaster(this,null),this._glint=null,this._shadow&&(this._shadow.destroy({texture:!1,textureSource:!1}),this._shadow=null),this._modelShadow&&(this._modelShadow.destroy(),this._modelShadow=null),this._unsubscribeShots&&(this._unsubscribeShots(),this._unsubscribeShots=null),this._unsubscribeBlasts&&(this._unsubscribeBlasts(),this._unsubscribeBlasts=null),this._model&&(this._model.destroy(),this._model=null);for(const e of this._lightShaders.values())e.destroy();this._lightShaders.clear(),super.destroy({children:!0,texture:!1,textureSource:!1,...t})}}const ra=2;class aa extends U{constructor(t,e,s){super(),this._level=t[Go]||0,this.zIndex=G(ra,this._level),this._levelView=s.levelView||null,this._renderer=s.renderer||null,(this._levelView||this._renderer)&&(this.onRender=()=>{this._levelView&&(this.alpha=this._levelView.alphaFor(this._level,this._worldX,this._worldY),this.tint=this._levelView.tintFor(this._level)),this._applyHeight()}),this.body=new K(e.bombTexture),this.body.anchor.set(.5),this._worldX=t[Ps],this._worldY=t[zs],this.x=this._worldX,this.y=this._worldY,this.rotation=t[Es],this._size=t[Uo],this._totalDurationMs=t[Ho],this._soundManager=s.soundManager,this._soundId=null;const n=e.bombTexture.width,o=this._size/n;this.body.scale.set(o);const r=64,a=this._size/1.2/r;this.text=new ii({style:{fontFamily:"Arial",fontSize:r,fill:16777215,align:"center"}}),this.text.anchor.set(.5),this.text.scale.set(a),this.text.x=0,this.text.y=0,this._accumulatedTimeMs=0,this._secondsLeft="",this.addChild(this.body,this.text),this._updateTimerDisplay(this._totalDurationMs),this._tickListener=l=>this._updateTimer(l.deltaMS),j.shared.add(this._tickListener),this._soundId=this._soundManager.registerSound("bombHasBeenPlanted",{position:{x:this.x,y:this.y}})}_updateTimer(t){this._accumulatedTimeMs+=t;const e=Math.max(0,this._totalDurationMs-this._accumulatedTimeMs);this._updateTimerDisplay(e),e<=0&&(this._stopTimer(),this._updateTimerDisplay(0))}_updateTimerDisplay(t){const e=Math.round(t/1e3);this._secondsLeft!==e&&(this._secondsLeft=e,this.text.text=`${this._secondsLeft}`)}update(t){this._worldX=t[Ps],this._worldY=t[zs],this.x=this._worldX,this.y=this._worldY,this.rotation=t[Es],this._soundId&&(this._soundManager.updateSoundData(this._soundId,{position:{x:this._worldX,y:this._worldY}})||(this._soundId=null))}_applyHeight(){const t=this._level*W.shear,e=gt(this.parent,this._renderer),s=dt(this._worldX,this._worldY,e,t);this.position.set(s.x,s.y),this.scale.set(1+t)}_stopTimer(){this._tickListener&&(j.shared.remove(this._tickListener),this._tickListener=null)}destroy(t){this._stopTimer(),this._soundId&&(this._soundManager.releaseSound(this._soundId),this._soundId=null),super.destroy({children:!0,texture:!1,textureSource:!1,...t}),this.body=null,this.text=null}}class la extends Qt{constructor(t,e,s,n,o){super(n);const{texture:r,contentSize:a}=o.explosionTexture;this.x=t,this.y=e,this._radius=s,this._durationMs=1500,this._elapsedMs=0,this._baseScale=this._radius*2/a,this._mainBody=new K(r),this._mainBody.anchor.set(.5),this._mainBody.tint=11393254,this._mainBody.scale.set(this._baseScale),this._core=new K(r),this._core.anchor.set(.5),this._core.tint=13882323,this._core.scale.set(this._baseScale),this.addChild(this._mainBody,this._core)}_update(t){if(!this.isComplete)if(this._elapsedMs+=t,this._elapsedMs<=this._durationMs){const e=this._elapsedMs/this._durationMs;this._draw(e)}else this._completeEffect()}_draw(t){const e=n=>n*n;this._mainBody.alpha=.6*(1-e(t));const s=Math.min(1,t*1.5);this._core.alpha=.7-s,this._core.scale.set(this._baseScale*(1-s))}destroy(t){super.destroy(t)}}const $e=[],Rt={get(i){if($e.length>0){const t=$e.pop();return t.texture=i,t.alpha=1,t.scaleX=1,t.scaleY=1,t.rotation=0,t.tint=16777215,t.anchorX=.5,t.anchorY=.5,t}return new Ni({texture:i,anchorX:.5,anchorY:.5})},release(i){i&&$e.push(i)}},is=50,ha=400,ca=800;class ua extends Qt{constructor(t,e=is){super();const s=e/is;this._blastScale=s;const{texture:n,contentSize:o}=t.explosionTexture;this.explosionTexture=n,this._unitScale=1/o;const r=ha*s,a=ca*s;this._particleContainer=new as({texture:this.explosionTexture,boundsArea:new Z(-r/2,-a/2,r,a),dynamicProperties:{position:!0,vertex:!0,rotation:!0,color:!0}}),this.addChild(this._particleContainer),this._particles=[],this._isSpawning=!0,this._particleSpawnRateMs=50,this._particleMaxLifeMs=2e3,this._minStartSize=2.1*s,this._maxStartSize=5.2*s,this._minTargetSize=8.3*s,this._maxTargetSize=16.6*s,this._startAlpha=.1,this._initialOffsetX=15*s,this._initialOffsetY=15*s,this._lastSpawnTime=0;for(let l=0;l<30;l+=1)this._createParticle()}stopSpawning(){this._isSpawning=!1}_createParticle(){const t=Rt.get(this.explosionTexture),e=.2+Math.random()*.4,s=Math.floor(e*255);t.tint=s<<16|s<<8|s;const n=(this._minStartSize+Math.random()*(this._maxStartSize-this._minStartSize))*this._unitScale,o=.6+Math.random()*.8,r=.6+Math.random()*.8;t.scaleX=n*o,t.scaleY=n*r,t.alpha=this._startAlpha+Math.random()*.1,t.rotation=Math.random()*Math.PI*2,t.x=(Math.random()-.5)*this._initialOffsetX,t.y=(Math.random()-.5)*this._initialOffsetY;const a={view:t,life:0,maxLife:this._particleMaxLifeMs*(.7+Math.random()*.6),aspectRatioX:o,aspectRatioY:r,vx:(Math.random()-.5)*.2*this._blastScale,vy:(-.3-Math.random()*.4)*this._blastScale,swaySpeed:.002+Math.random()*.003,swayAmp:(.025+Math.random()*.05)*this._blastScale,swayOffset:Math.random()*100,rotationSpeed:(Math.random()-.5)*.05,targetScale:(this._minTargetSize+Math.random()*(this._maxTargetSize-this._minTargetSize))*this._unitScale,startScale:n};this._particleContainer.addParticle(t),this._particles.push(a)}_update(t){if(!this.isComplete){if(t=Math.min(t,100),this._isSpawning)for(this._lastSpawnTime+=t;this._lastSpawnTime>this._particleSpawnRateMs;)this._createParticle(),this._lastSpawnTime-=this._particleSpawnRateMs;for(let e=this._particles.length-1;e>=0;e-=1){const s=this._particles[e],n=s.view;if(s.life+=t,s.life>=s.maxLife)this._particleContainer.removeParticle(n),Rt.release(n),this._particles.splice(e,1);else{const o=s.life/s.maxLife;s.vy*=.98,s.vx*=.95;const r=Math.sin(s.life*s.swaySpeed+s.swayOffset)*s.swayAmp;n.x+=(s.vx+r)*(t/16),n.y+=s.vy*(t/16),n.rotation+=s.rotationSpeed*(t/16);const a=1-Math.pow(1-o,3),l=s.startScale+(s.targetScale-s.startScale)*a;if(n.scaleX=l*s.aspectRatioX,n.scaleY=l*s.aspectRatioY,o<.1)n.alpha=o/.1*this._startAlpha;else if(o>.4){const h=(o-.4)/.6;n.alpha=this._startAlpha*(1-h)}else n.alpha=this._startAlpha}}!this._isSpawning&&this._particles.length===0&&this._isStarted&&(this._completeEffect(),this.destroyed||this.destroy())}}destroy(t){for(let e=0;e<this._particles.length;e+=1)Rt.release(this._particles[e].view);this._particles=[],super.destroy(t)}}const da=.168,fa=.225,Ks=.15,_a=2e4,pa=50,ma=4e3,ga=4e3;class ya extends Qt{constructor(t,e,s,n,o){super(n),this._assets=o,this._radius=s,this.x=t,this.y=e,this._funnelDurationMs=_a,this._funnelFadeInDurationMs=pa,this._funnelFadeDurationMs=ma,this._elapsedMs=0,this._smokeDurationMs=ga,this._smokeSpawningStopped=!1,this._funnel=this._createFunnelSprite(),this._smoke=new ua(this._assets,this._radius),this.addChild(this._funnel,this._smoke)}_createFunnelSprite(){const{textures:t,contentSize:e}=this._assets.funnelTexture,s=t[Math.floor(Math.random()*t.length)],n=new K(s);n.anchor.set(.5),n.alpha=0,n.rotation=Math.random()*Math.PI*2;const o=this._radius*da*X(1-Ks,1+Ks);return n.scale.set(o/e),n}_onEffectStart(){super._onEffectStart(),this._smoke&&this._smoke.run()}_update(t){if(this.isComplete)return;this._elapsedMs+=t,!this._smokeSpawningStopped&&this._elapsedMs>=this._smokeDurationMs&&(this._smoke.stopSpawning(),this._smokeSpawningStopped=!0);const e=this._funnelDurationMs-this._elapsedMs,s=this._funnelFadeInDurationMs>0?this._elapsedMs/this._funnelFadeInDurationMs:1,n=e/this._funnelFadeDurationMs;this._funnel.alpha=fa*Vt(Math.min(s,n),0,1),e<=0&&this._completeEffect()}destroy(t){this._smoke&&(this._smoke.destroy(),this._smoke=null),this._funnel=null,super.destroy(t)}}const xa=4,wa=2;class va extends U{constructor(t,e,s){super(),this.originX=t[$o],this.originY=t[Ko],this.radius=t[Zo]??is,this._level=t[qo]||0,this._assets=e,this._soundManager=s.soundManager,this._levelView=s.levelView||null,this._renderer=s.renderer||null,this._lighting=s.lighting||null,s.blasts?.exploded({x:this.originX,y:this.originY,radius:this.radius,level:this._level}),(this._levelView||this._renderer)&&(this.onRender=()=>{this._levelView&&this._updateSeeThrough(),this._applyHeight()}),this.x=this.originX,this.y=this.originY,this.explosion=null,this.funnel=null,this._isStarted=!1,this._isDestroyed=!1,this._soundId=this._soundManager.registerSound("explosion",{position:{x:this.originX,y:this.originY}})}_updateSeeThrough(){const t=this._levelView.alphaFor(this._level,this.originX,this.originY),e=this._levelView.tintFor(this._level);this.explosion&&(this.explosion.alpha=t,this.explosion.tint=e),this.funnel&&(this.funnel.alpha=t,this.funnel.tint=e)}_applyHeight(){const t=this._level*W.shear,e=gt(this.parent,this._renderer),s=dt(this.originX,this.originY,e,t);for(const n of[this.explosion,this.funnel])n&&(n.position.set(s.x,s.y),n.scale.set(1+t))}run(){if(!(this._isDestroyed||this._isStarted)){if(this._isStarted=!0,!this.parent){this.destroy();return}this._lighting?.flash({...Jt.flash.explosion,level:this._level,x:this.originX,y:this.originY,z:this._level}),this.explosion=new la(this.originX,this.originY,this.radius,this._onExplosionComplete.bind(this),this._assets),this.explosion.zIndex=G(xa,this._level),this.funnel=new ya(this.originX,this.originY,this.radius,this._onFunnelComplete.bind(this),this._assets),this.funnel.zIndex=G(wa,this._level),this.parent.addChild(this.explosion,this.funnel),this.parent.sortChildren(),this.explosion.run(),this.funnel.run()}}_onExplosionComplete(){this._isDestroyed||this.explosion&&(this.explosion.destroy(),this.explosion=null)}_onFunnelComplete(){this._isDestroyed||this.destroy()}destroy(){this._isDestroyed||(this._isDestroyed=!0,this._soundId&&(this._soundManager.unregisterSound(this._soundId),this._soundId=null),this.explosion&&(this.explosion.destroy(),this.explosion=null),this.funnel&&(this.funnel.destroy(),this.funnel=null),this.parent&&this.parent.removeChild(this),super.destroy({children:!0}))}}const Zs=4,ee=400,Sa=0,ba=0,Ma=8,st={particleLifetime:{min:800,max:1800},particleStartSizeFactor:{1:2,2:1,0:.25},particleEndSizeFactor:{1:3,2:2,0:1},particleStartAlpha:.08,particleEndAlpha:0,particleColor:3355443,particleSpawnRate:{1:60,2:50,0:30},particleInitialVelocity:{away:{min:-10,max:100},side:{min:-30,max:30}},airResistance:.92,particleVelocityVariance:10,streamOffsetFactor:.1,burstParticleCount:3,exhaust:{spawnRate:45,idleSpawnRate:4,minLoad:.05,startSizeFactor:.6,endSizeFactor:1.6,startAlpha:.05,color:5592405,lifetime:{min:350,max:750}}};class Ta extends U{constructor(t,e,s={}){super(),this._level=t[mt]||0,this.zIndex=G(Zs,this._level);const{texture:n,contentSize:o}=e.smokeTexture;this._smokeTexture=n,this._textureScale=Ma/o,this._emitterX=t[At],this._emitterY=t[Lt],this._emitterRotation=t[Ot],this._emitterVX=t[ae],this._emitterVY=t[le],this._engineLoad=t[Bt],this._condition=t[Ct],this._z=t[he]||0,this._size=t[Ve],this._width=this._size*4,this._height=this._size*3,this._particleScaleMultiplier=Math.max(.5,Math.sqrt(this._width*this._height*.001)),this._particles=[],this._levelView=s.levelView||null,this._renderer=s.renderer||null,(this._levelView||this._renderer)&&(this.onRender=()=>{this._levelView&&(this.alpha=this._levelView.alphaFor(this._level,this._emitterX,this._emitterY,this._z),this.tint=this._levelView.tintFor(this._level)),ft(this,gt(this.parent,this._renderer),this._z*W.shear,1)}),this._particleContainer=new as({texture:this._smokeTexture,boundsArea:new Z(this._emitterX-ee,this._emitterY-ee,ee*2,ee*2),dynamicProperties:{position:!0,vertex:!0,rotation:!0,color:!0}}),this.addChild(this._particleContainer),this._timeSinceLastSpawn=0,this._timeSinceExhaust=0,this._tickListener=r=>this._updateParticles(r.deltaMS),j.shared.add(this._tickListener)}update(t){const e=this._condition,s=t[mt]||0;s!==this._level&&(this._level=s,this.zIndex=G(Zs,s)),this._emitterX=t[At],this._emitterY=t[Lt],this._emitterRotation=t[Ot],this._emitterVX=t[ae],this._emitterVY=t[le],this._engineLoad=t[Bt],this._condition=t[Ct],this._z=t[he]||0,this._particleContainer.boundsArea.x=this._emitterX-ee,this._particleContainer.boundsArea.y=this._emitterY-ee,this._condition!==e&&this._condition!==3&&this._triggerSmokeBurst()}_triggerSmokeBurst(){let t=0;if(this._condition===1?t=2:(this._condition===2||this._condition===0)&&(t=1),t>0){const e=st.burstParticleCount,s=Math.ceil(e/t);for(let n=0;n<s;n+=1)for(let o=0;o<t;o+=1)this.spawnParticle(o,t,"burst")}}_updateParticles(t){if(t<=0)return;const e=t/1e3;this._timeSinceLastSpawn+=t,this._timeSinceExhaust+=t;let s=0;this._condition===3?s=0:this._condition===1?s=2:(this._condition===2||this._condition===0)&&(s=1);const n=st.particleSpawnRate[this._condition]||0,o=n>0?1e3/n:1/0;if(s>0&&n>0)for(;this._timeSinceLastSpawn>=o;){for(let c=0;c<s;c+=1)this.spawnParticle(c,s);this._timeSinceLastSpawn-=o}else this._timeSinceLastSpawn=0;const r=Math.min(this._engineLoad,1),a=this._condition>0&&r>=st.exhaust.minLoad?_t(st.exhaust.idleSpawnRate,st.exhaust.spawnRate,r):0;if(a>0){const c=1e3/a;for(;this._timeSinceExhaust>=c;)this.spawnParticle(0,1,"exhaust"),this._timeSinceExhaust-=c}else this._timeSinceExhaust=0;const h=1-Math.pow(st.airResistance,t/16);for(let c=this._particles.length-1;c>=0;c-=1){const u=this._particles[c];if(u.age+=t,u.age>=u.lifetime){this._particleContainer.removeParticle(u.view),Rt.release(u.view),this._particles.splice(c,1);continue}u.vx=u.vx+(Sa-u.vx)*h,u.vy=u.vy+(ba-u.vy)*h,u.x+=u.vx*e,u.y+=u.vy*e;const d=u.age/u.lifetime,p=1-(1-d)*(1-d),m=_t(u.startSizeFactor,u.endSizeFactor,p),g=_t(u.startAlpha,u.endAlpha,d),_=m*this._particleScaleMultiplier*this._textureScale,v=u.view;v.x=u.x,v.y=u.y,v.scaleX=_,v.scaleY=_,v.alpha=g,v.rotation+=u.rotSpeed*e}}spawnParticle(t,e,s="damage"){const n=s==="burst",o=s==="exhaust",r=st.exhaust,a=o?X(r.lifetime.min,r.lifetime.max):X(st.particleLifetime.min,st.particleLifetime.max);let l=o?r.startSizeFactor:st.particleStartSizeFactor[this._condition]||.3,h=o?r.endSizeFactor:st.particleEndSizeFactor[this._condition]||1,c=o?r.startAlpha:st.particleStartAlpha,u=1;n&&(l*=2,h*=2.5,c=.8,u=2);const d=this._emitterRotation,p=d+Math.PI,m=Math.cos(p),g=Math.sin(p),_=d+Math.PI/2,v=Math.cos(_),M=Math.sin(_);let T=0;const k=this._width/2*st.streamOffsetFactor;e===2?T=t===0?-k:k:e===3&&(T=(t-1)*k);const A=this._height*.22,L=this._emitterX+m*A+v*T,b=this._emitterY+g*A+M*T;let Y=X(st.particleInitialVelocity.away.min,st.particleInitialVelocity.away.max),z=X(st.particleInitialVelocity.side.min,st.particleInitialVelocity.side.max);Y*=u,z*=u;let R=m*Y+v*z,B=g*Y+M*z;const J=st.particleVelocityVariance;R+=X(-J,J),B+=X(-J,J),R+=this._emitterVX,B+=this._emitterVY;const V=Rt.get(this._smokeTexture);V.tint=o?r.color:st.particleColor,V.x=L,V.y=b,V.alpha=c;const ct=l*this._particleScaleMultiplier*this._textureScale;V.scaleX=ct,V.scaleY=ct,V.rotation=X(0,Math.PI*2);const bt={view:V,x:L,y:b,vx:R,vy:B,age:0,lifetime:a,startSizeFactor:l,endSizeFactor:h,startAlpha:c,endAlpha:st.particleEndAlpha,rotSpeed:X(-1,1)};this._particleContainer.addParticle(V),this._particles.push(bt)}_stopTimer(){this._tickListener&&(j.shared.remove(this._tickListener),this._tickListener=null)}destroy(t){this._stopTimer();for(let e=0;e<this._particles.length;e+=1)Rt.release(this._particles[e].view);this._particles=[],super.destroy({texture:!1,textureSource:!1,...t,children:!0})}}class ka extends K{constructor(t,e,s,n,o,r,a,l=1){super(a),this.anchor.set(.5),this.x=t,this.y=e,this.rotation=s,this.width=o,this.height=n,this.alpha=r,this._initialAlpha=r,this._elapsedTime=0,this._fadeDuration=(1800+Math.random()*700)*l}update(t){this._elapsedTime+=t;const e=Math.min(this._elapsedTime/this._fadeDuration,1);return this.alpha=(1-e)*this._initialAlpha,e>=1}}const Ke=1;class Aa extends U{constructor(t,e,s={}){super(),this._levelView=s.levelView||null,this._renderer=s.renderer||null,this._surfaces=s.surfaces||null,this._level=t[mt]||0,this._markLayers=new Map,this.zIndex=G(Ke,this._level),this._currentX=t[At]||0,this._currentY=t[Lt]||0,this._currentRotation=t[Ot]||0,this._engineLoad=t[Bt]||0,this._condition=t[Ct],this._size=t[Ve],this._prevX=this._currentX,this._prevY=this._currentY,this._prevRotation=this._currentRotation,this._prevSpeed=0,this._prevAngularSpeed=0,this._assets=e,this._trackMarkCooldown=2,this._lastTrackMarkTime=0,this._minAbsAccelerationForMark=4,this._minAngularSpeedForMark=.02,this._minRotationAccelerationForMark=.4,this._minSpeedForRotationMarks=1.4,this._trackWidth=this._size*.4,this._trackLength=this._size*.5;const n=this._size*3;this._trackOffset=n/2*.7,this._backwardOffset=n*.4,this._trackInitialAlpha=.4,this._trailKind=null,this._trailLeft=0,this._tickListener=o=>this._internalUpdate(o.deltaMS),j.shared.add(this._tickListener),this._levelView&&(this.onRender=()=>this._updateLayers())}update(t){this._currentX=t[At],this._currentY=t[Lt],this._currentRotation=t[Ot],this._engineLoad=t[Bt],this._condition=t[Ct];const e=t[mt]||0;e!==this._level&&(this._level=e,this.zIndex=G(Ke,e))}_markLayer(t){let e=this._markLayers.get(t);if(e)return e;e=new U,e.zIndex=G(Ke,t),this._markLayers.set(t,e);const s=this.parent||this;return s.addChild(e),s.sortChildren(),e}_internalUpdate(t){if(t<=0)return;for(const p of this._markLayers.values())for(let m=p.children.length-1;m>=0;m-=1){const g=p.children[m];g.update(t)&&g.destroy()}this._stepTrail(t/1e3);const e=this._currentX-this._prevX,s=this._currentY-this._prevY,n=Math.sqrt(e*e+s*s),o=Ro(this._currentRotation-this._prevRotation),r=Math.abs(o),a=n-this._prevSpeed,l=Math.abs(a),h=r-this._prevAngularSpeed,c=Math.abs(h),u=performance.now();let d=!1;this._condition!==0&&u-this._lastTrackMarkTime>this._trackMarkCooldown&&(l>this._minAbsAccelerationForMark&&(d=!0),n>this._minSpeedForRotationMarks&&(r>this._minAngularSpeedForMark||c>this._minRotationAccelerationForMark)&&(d=!0)),this._engineLoad>1&&(d=!0),d&&(this.createTrackMarksAtPreviousPosition(),this._lastTrackMarkTime=u),this._prevX=this._currentX,this._prevY=this._currentY,this._prevRotation=this._currentRotation,this._prevSpeed=n,this._prevAngularSpeed=r}_stepTrail(t){if(!this._surfaces)return;const e=this._surfaces.kindAt(this._currentX,this._currentY,this._level),s=e&&kt.tracks[e]?.trail;s?(this._trailKind=e,this._trailLeft=s):this._trailLeft>0&&(this._trailLeft=Math.max(0,this._trailLeft-t))}createTrackMarksAtPreviousPosition(){const t=this._surfaces?this._surfaces.kindAt(this._prevX,this._prevY,this._level):null;if(t&&kt.tracks.noMarks.includes(t))return;let e=t&&kt.tracks[t]||null,s=1;!e&&this._trailLeft>0&&(e=kt.tracks[this._trailKind],s=this._trailLeft/e.trail);const n=this._markLayer(this._level);for(let o=-1;o<=1;o+=2){const r=Math.cos(this._prevRotation+Math.PI/2)*this._trackOffset*o,a=Math.sin(this._prevRotation+Math.PI/2)*this._trackOffset*o,l=-Math.cos(this._prevRotation)*this._backwardOffset,h=-Math.sin(this._prevRotation)*this._backwardOffset,c=this._prevX+r+l,u=this._prevY+a+h,d=new ka(c,u,this._prevRotation,this._trackWidth,this._trackLength,Math.min(1,this._trackInitialAlpha*(e?e.alpha:1))*s,this._assets.trackMarkTexture,e?e.lifetime:1);e&&(d.tint=e.tint),n.addChild(d)}}_updateLayers(){if(!this._markLayers.size)return;const t=gt(this.parent,this._renderer);for(const[e,s]of this._markLayers)s.alpha=this._levelView.alphaFor(e,this._currentX,this._currentY),s.tint=this._levelView.tintFor(e),e&&ft(s,t,e*W.shear)}_stopTimer(){this._tickListener&&(j.shared.remove(this._tickListener),this._tickListener=null)}destroy(t){this._stopTimer();for(const e of this._markLayers.values())e.destroyed||e.destroy({children:!0});this._markLayers.clear(),super.destroy({children:!0,texture:!1,textureSource:!1,...t})}}const qs=2,se=300,La=6,et={lifetime:{min:300,max:700},startSizeFactor:.7,endSizeFactor:2,startAlpha:.35,endAlpha:0,color:10260343,airResistance:.86,spawnRate:30,maxSpinSpeed:8,spinVelocity:{back:{min:20,max:70},side:{min:-25,max:25}},landingBurst:14,landingVelocity:{min:40,max:110},landingSizeFactor:1.6},Ca={color:et.color,alpha:et.startAlpha,lifetime:et.lifetime},Pa=["sand","mud","water"],js=.35,za=(i,t)=>i.kind==="boost"&&i.dir!==null&&i.dir[0]===t[0]&&i.dir[1]===t[1];class Ea extends U{constructor(t,e,s={}){super(),this._level=t[mt]||0,this.zIndex=G(qs,this._level);const{texture:n,contentSize:o}=e.dustTexture;this._dustTexture=n,this._textureScale=La/o,this._x=t[At],this._y=t[Lt],this._rotation=t[Ot],this._vx=t[ae]||0,this._vy=t[le]||0,this._engineLoad=t[Bt]||0,this._condition=t[Ct],this._z=t[he]||0,this._vz=t[Ie]||0,this._prevVz=this._vz,this._size=t[Ve];const r=this._size*3;this._trackOffset=r/2*.7,this._backwardOffset=r*.4,this._particleScaleMultiplier=Math.max(.5,Math.sqrt(this._size*4*r*.001)),this._particles=[],this._timeSinceSpawn=0,this._levelView=s.levelView||null,this._renderer=s.renderer||null,this._soundManager=s.soundManager||null,this._surfaces=s.surfaces||null,this._surfaceKind=null,this._surfaceCell=null,this._timeSinceSurfaceSpawn=0;const a=this._soundManager?.getSoundConfig("tankLanding");this._landingVolume=a?.volume||0,this._hasLandingSound=!!a,(this._levelView||this._renderer)&&(this.onRender=()=>{this._levelView&&(this.alpha=this._levelView.alphaFor(this._level,this._x,this._y,this._z),this.tint=this._levelView.tintFor(this._level)),ft(this,gt(this.parent,this._renderer),this._z*W.shear,1)}),this._particleContainer=new as({texture:this._dustTexture,boundsArea:new Z(this._x-se,this._y-se,se*2,se*2),dynamicProperties:{position:!0,vertex:!0,rotation:!0,color:!0}}),this.addChild(this._particleContainer),this._tickListener=l=>this._updateParticles(l.deltaMS),j.shared.add(this._tickListener)}update(t){const e=this._x,s=this._y,n=this._condition>0,o=t[mt]||0;o!==this._level&&(this._level=o,this.zIndex=G(qs,o)),this._x=t[At],this._y=t[Lt],this._rotation=t[Ot],this._vx=t[ae]||0,this._vy=t[le]||0,this._engineLoad=t[Bt]||0,this._condition=t[Ct],this._z=t[he]||0,this._vz=t[Ie]||0,this._particleContainer.boundsArea.x=this._x-se,this._particleContainer.boundsArea.y=this._y-se;const r=wi(this._prevVz,this._vz,Kt);r>0&&(this._triggerLandingBurst(r),this._playLandingSound(r)),this._prevVz=this._vz,this._updateSurface(e,s,n)}_updateSurface(t,e,s){if(!this._surfaces)return;const n=this._surfaces.kindAt(this._x,this._y,this._level),o=n==="boost"?this._surfaces.dirAt(this._x,this._y,this._level):null,r=this._surfaceCell,a=Math.hypot(this._x-t,this._y-e)>kt.boost.resetDistance,l=!s&&this._condition>0;this._surfaceKind=n,this._surfaceCell={kind:n,dir:o},!(r===null||l||a||this._condition<=0||this._vz!==0)&&(n==="water"&&r.kind!=="water"&&this._triggerWaterEntry(),o&&!za(r,o)&&this._vx*o[0]+this._vy*o[1]>=kt.boost.boostMinSpeed&&this._triggerBoostFlash(o))}_triggerWaterEntry(){const t=kt.water;if(!(Math.hypot(this._vx,this._vy)<t.entryMinSpeed))for(let e=-1;e<=1;e+=2){const s=this._contactPoint(e);for(let n=0;n<t.entryBurst;n+=1){const[o,r]=this._sideSprayVelocity(e,t);this._spawnParticle(s.x,s.y,o,r,t.sizeFactor*1.5,t)}}}_triggerBoostFlash(t){const e=kt.boost,s=Math.atan2(-t[1],-t[0]);for(let n=0;n<e.burst;n+=1){const o=s+X(-js,js),r=X(e.tailSpeed.min,e.tailSpeed.max);this._spawnParticle(this._x,this._y,Math.cos(o)*r,Math.sin(o)*r,e.sizeFactor,e)}}_sideSprayVelocity(t,e){const s=this._rotation+Math.PI/2,n=this._rotation+Math.PI,o=X(e.sideSpeed.min,e.sideSpeed.max)*t,r=X(0,e.sideSpeed.min);return[Math.cos(s)*o+Math.cos(n)*r,Math.sin(s)*o+Math.sin(n)*r]}_spawnSurfaceDust(t,e){for(let s=-1;s<=1;s+=2){const n=this._contactPoint(s);let o,r;if(t==="water")[o,r]=this._sideSprayVelocity(s,e);else{const a=this._rotation+Math.PI,l=this._rotation+Math.PI/2,h=X(et.spinVelocity.back.min,et.spinVelocity.back.max),c=X(et.spinVelocity.side.min,et.spinVelocity.side.max);o=Math.cos(a)*h+Math.cos(l)*c,r=Math.sin(a)*h+Math.sin(l)*c}this._spawnParticle(n.x,n.y,o,r,e.sizeFactor,e)}}_playLandingSound(t){this._hasLandingSound&&this._soundManager.registerSound("tankLanding",{position:{x:this._x,y:this._y},volume:this._landingVolume*t})}_contactPoint(t){const e=this._rotation+Math.PI/2;return{x:this._x+Math.cos(e)*this._trackOffset*t-Math.cos(this._rotation)*this._backwardOffset,y:this._y+Math.sin(e)*this._trackOffset*t-Math.sin(this._rotation)*this._backwardOffset}}_triggerLandingBurst(t){const e=Math.round(et.landingBurst*t);if(!(e<=0))for(let s=-1;s<=1;s+=2){const n=this._contactPoint(s);for(let o=0;o<e;o+=1){const r=X(0,Math.PI*2),a=X(et.landingVelocity.min,et.landingVelocity.max)*t;this._spawnParticle(n.x,n.y,Math.cos(r)*a,Math.sin(r)*a,et.landingSizeFactor*t)}}}_spawnSpinDust(){const t=this._rotation+Math.PI,e=this._rotation+Math.PI/2;for(let s=-1;s<=1;s+=2){const n=this._contactPoint(s),o=X(et.spinVelocity.back.min,et.spinVelocity.back.max),r=X(et.spinVelocity.side.min,et.spinVelocity.side.max);this._spawnParticle(n.x,n.y,Math.cos(t)*o+Math.cos(e)*r,Math.sin(t)*o+Math.sin(e)*r,1)}}_spawnParticle(t,e,s,n,o,r=Ca){const a=et.startSizeFactor*o,l=et.endSizeFactor*o,h=Rt.get(this._dustTexture),c=a*this._particleScaleMultiplier*this._textureScale;h.tint=r.color,h.x=t,h.y=e,h.alpha=r.alpha,h.scaleX=c,h.scaleY=c,h.rotation=X(0,Math.PI*2),this._particles.push({view:h,x:t,y:e,vx:s,vy:n,age:0,lifetime:X(r.lifetime.min,r.lifetime.max),startAlpha:r.alpha,startSizeFactor:a,endSizeFactor:l,rotSpeed:X(-1,1)}),this._particleContainer.addParticle(h)}_updateParticles(t){if(t<=0)return;const e=t/1e3;this._timeSinceSpawn+=t;const s=Math.max(0,this._engineLoad-1),n=Math.hypot(this._vx,this._vy),r=this._condition>0&&s>0&&n<et.maxSpinSpeed&&this._surfaceKind!=="oil"?et.spawnRate*Math.min(s,1):0;if(r>0){const l=1e3/r;for(;this._timeSinceSpawn>=l;)this._spawnSpinDust(),this._timeSinceSpawn-=l}else this._timeSinceSpawn=0;this._emitSurface(t,n);const a=Math.pow(et.airResistance,t/16);for(let l=this._particles.length-1;l>=0;l-=1){const h=this._particles[l];if(h.age+=t,h.age>=h.lifetime){this._particleContainer.removeParticle(h.view),Rt.release(h.view),this._particles.splice(l,1);continue}h.vx*=a,h.vy*=a,h.x+=h.vx*e,h.y+=h.vy*e;const c=h.age/h.lifetime,u=1-(1-c)*(1-c),d=(h.startSizeFactor+(h.endSizeFactor-h.startSizeFactor)*u)*this._particleScaleMultiplier*this._textureScale,p=h.view;p.x=h.x,p.y=h.y,p.scaleX=d,p.scaleY=d,p.alpha=h.startAlpha+(et.endAlpha-h.startAlpha)*c,p.rotation+=h.rotSpeed*e}}_emitSurface(t,e){const s=this._surfaceKind,n=Pa.includes(s)?kt[s]:null;if(!n||this._condition<=0||this._vz!==0||e<n.minSpeed){this._timeSinceSurfaceSpawn=0;return}const o=1e3/(n.rate*Math.min(e/n.fullSpeed,1));for(this._timeSinceSurfaceSpawn+=t;this._timeSinceSurfaceSpawn>=o;)this._spawnSurfaceDust(s,n),this._timeSinceSurfaceSpawn-=o}_stopTimer(){this._tickListener&&(j.shared.remove(this._tickListener),this._tickListener=null)}destroy(t){this._stopTimer();for(let e=0;e<this._particles.length;e+=1)Rt.release(this._particles[e].view);this._particles=[],super.destroy({texture:!1,textureSource:!1,...t,children:!0})}}function Ra({progress:i,totalDist:t,trailLength:e,trailShare:s=0}){const n=t*Vt(i,0,1),o=Math.max(e,t*s),r=_t(o,0,Vt(i,0,1));return{tail:Math.max(0,n-r),head:n}}class Ia extends Qt{constructor(t,e,s,n,o,r=en,a={}){super(o),this.startPositionX=t,this.startPositionY=e,this.endPositionX=s,this.endPositionY=n,this.config=r,this._layerFor=a.layerFor||null,this.pieces=a.pieces?.length?a.pieces:[{from:0,to:1/0,level:null}],this._graphics=new Map;for(const{level:l}of this.pieces)if(!this._graphics.has(l)){const h=new N;h.blendMode="add",(this._layerFor?.(l)||this).addChild(h),this._graphics.set(l,h)}this.graphics=this._graphics.values().next().value,this.elapsedTime=0,this.progress=0,this._aim(),this.animationDuration=Vt(this.totalDist/r.speed*1e3,r.minDuration,r.maxDuration)}_aim(){const t=this.endPositionX-this.startPositionX,e=this.endPositionY-this.startPositionY;this.totalDist=Math.hypot(t,e),this.totalDist>.001?(this.nx=t/this.totalDist,this.ny=e/this.totalDist):(this.nx=0,this.ny=0,this.totalDist=0)}shiftTo(t,e){this.isComplete||(this.endPositionX+=t-this.startPositionX,this.endPositionY+=e-this.startPositionY,this.startPositionX=t,this.startPositionY=e,this._draw())}_clear(){for(const t of this._graphics.values())t.clear()}_draw(){this._clear();const{tail:t,head:e}=Ra({progress:this.progress,totalDist:this.totalDist,trailLength:this.config.trailLength,trailShare:this.config.trailShare});e-t>.001&&this._drawTrail(t,e,_t(this.config.alphaStart,this.config.alphaEnd,this.progress))}_update(t){this.isComplete||(this.elapsedTime+=t,this.progress=Math.min(this.elapsedTime/this.animationDuration,1),this._draw(),this.elapsedTime>=this.animationDuration&&(this._clear(),this._completeEffect()))}_drawTrail(t,e,s){const{color:n,coreColor:o,coreWidth:r,glowWidth:a,glowAlpha:l}=this.config,h=Math.max(1,this.config.fadeSteps),c=[];for(let d=0;d<h;d+=1){const p=_t(t,e,d/h),m=_t(t,e,(d+1)/h),g=(d+1)/h;c.push({from:p,to:m,fade:g*g})}const u=this._split(c);for(const{graphics:d,from:p,to:m,fade:g}of u)d.moveTo(p[0],p[1]).lineTo(m[0],m[1]).stroke({width:a,color:n,alpha:s*l*g,cap:"round"});for(const{graphics:d,from:p,to:m,fade:g}of u)d.moveTo(p[0],p[1]).lineTo(m[0],m[1]).stroke({width:r,color:o,alpha:s*g,cap:"round"})}_split(t){const e=n=>[this.startPositionX+this.nx*n,this.startPositionY+this.ny*n],s=[];for(const{from:n,to:o,fade:r}of t)for(const a of this.pieces){const l=Math.max(n,a.from),h=Math.min(o,a.to);h-l>1e-6&&s.push({graphics:this._graphics.get(a.level),from:e(l),to:e(h),fade:r})}return s}destroy(t){for(const e of this._graphics.values())e.destroyed||(e.clear(),e.parent!==this&&e.destroy());this._graphics.clear(),super.destroy(t)}}function Fa(i,t,e){const s=e||0;if(!(t>0))return[{from:0,to:0,level:s}];const n=(i||[]).filter(u=>u.t1>u.t0&&u.t0<t);if(n.length===0)return[{from:0,to:t,level:s}];const o=u=>Math.min(t,Math.max(0,u)),r=[...new Set([0,t,...n.flatMap(u=>[o(u.t0),o(u.t1)])])].sort((u,d)=>u-d),a=[];for(let u=0;u+1<r.length;u+=1){const d=r[u],p=r[u+1];if(p-d<1e-6)continue;const m=(d+p)/2;let g=null;for(const v of n)v.t0<=m&&m<v.t1&&(g===null||v.t0<g.t0)&&(g=v);const _=g?g.level:a.at(-1)?.level??s;Ze(a,d,p,_)}if(a.at(-1).level===s)return a;const l=n.filter(u=>u.level===s&&u.t0<t&&u.t1>=t-.001).sort((u,d)=>d.t0-u.t0)[0],h=l?o(l.t0):a.at(-1).from,c=[];for(const u of a)u.from<h&&Ze(c,u.from,Math.min(u.to,h),u.level);return Ze(c,h,t,s),c}function Ze(i,t,e,s){if(e-t<1e-6)return;const n=i.at(-1);n&&n.level===s&&Math.abs(n.to-t)<1e-6?n.to=e:i.push({from:t,to:e,level:s})}class Da extends Qt{constructor(t,e,s,n,o,r){super(o),this.x=t,this.y=e,this._assets=r;const{texture:a,contentSize:l}=this._assets.impactParticleTexture;this._particleTexture=a,this._textureContentSize=l,this.config={particleCount:X(2,4),particleMinSize:.8,particleMaxSize:2.4,minInitialSpeed:10,maxInitialSpeed:300,minLifetime:8e3,maxLifetime:15e3,color:[3355443,2236962,4473924],fadeOutStart:.8,impactDirectionX:s,impactDirectionY:n,spreadAngle:60,dragCoefficient:13,minSpeedThreshold:1,lingerDuration:6e3},this.config.impactDirectionX===0&&this.config.impactDirectionY===0?this.useOmnidirectionalSpread=!0:this.useOmnidirectionalSpread=!1,this.particlesData=[],this.elapsedTime=0,this._createParticles()}_createParticles(){let t;this.useOmnidirectionalSpread||(t=Math.atan2(this.config.impactDirectionY,this.config.impactDirectionX));const s=this.config.spreadAngle*(Math.PI/180)/2;for(let n=0,o=this.config.particleCount;n<o;n+=1){let r;this.useOmnidirectionalSpread?r=Math.random()*Math.PI*2:r=t+X(-s,s);const a=X(this.config.minInitialSpeed,this.config.maxInitialSpeed),l=new K(this._particleTexture);l.anchor.set(.5);const h={sprite:l,x:0,y:0,vx:Math.cos(r)*a,vy:Math.sin(r)*a,size:X(this.config.particleMinSize,this.config.particleMaxSize),color:Array.isArray(this.config.color)?this.config.color[Math.floor(Math.random()*this.config.color.length)]:this.config.color,lifetime:X(this.config.minLifetime,this.config.maxLifetime),age:0,alpha:1,active:!0,isMoving:!0,timeSinceStopped:0};l.tint=h.color,this.particlesData.push(h),this.addChild(l)}}_update(t){if(this.isComplete)return;this.elapsedTime+=t;const e=t/1e3;let s=0;for(let n=0,o=this.particlesData.length;n<o;n+=1){const r=this.particlesData[n];if(!r.active)continue;if(s+=1,r.age+=t,r.isMoving){const c=Math.hypot(r.vx,r.vy);if(c>0){const d=c*this.config.dragCoefficient*e,p=Math.max(0,1-d/c);r.vx*=p,r.vy*=p}r.x+=r.vx*e,r.y+=r.vy*e,Math.hypot(r.vx,r.vy)<this.config.minSpeedThreshold&&(r.isMoving=!1,r.vx=0,r.vy=0)}else r.timeSinceStopped+=t;const a=r.age/r.lifetime;if(!r.isMoving&&r.timeSinceStopped>=this.config.lingerDuration){const c=r.timeSinceStopped-this.config.lingerDuration,u=Math.min(500,r.lifetime*(1-this.config.fadeOutStart));r.alpha=_t(1,0,Math.min(c/u,1))}else if(a>=this.config.fadeOutStart){const c=r.age-r.lifetime*this.config.fadeOutStart,u=r.lifetime*(1-this.config.fadeOutStart);r.alpha=u>0?_t(1,0,Math.min(c/u,1)):0}(r.age>=r.lifetime||r.alpha<.01)&&(r.active=!1,r.alpha=0);const l=r.sprite;l.position.set(r.x,r.y),l.alpha=r.alpha,l.visible=r.active;const h=r.size/this._textureContentSize;l.scale.set(h)}s===0&&this._isStarted&&this._completeEffect()}destroy(t){this.particlesData=[],super.destroy(t)}}function Ya(i,t=Math.random){const e=[],s=Math.max(1,i.spikes);for(let o=0;o<s;o+=1){const r=s===1?.5:(o+t())/s;e.push({angle:(r*2-1)*i.spread,length:1-t()*i.jitter})}const n=[1-t()*i.jitter,1-t()*i.jitter];return{forward:e,sides:n}}function Xa({dirX:i,dirY:t,t:e,roll:s,config:n}){const o=1-Vt(e,0,1),r=o*o,a=1-n.shrink*(1-o),l=Math.atan2(t,i),h=[],c=(u,d,p)=>{const m=Math.cos(u),g=Math.sin(u),_=p/2;return[-g*_,m*_,m*d,g*d,g*_,-m*_]};for(const u of n.layers){const d=u.scale*a,p=u.core?n.coreColor:n.color,m=u.alpha*r;if(!(m<=0)){for(const{angle:g,length:_}of s.forward)h.push({points:c(l+g,n.length*_*d,n.width*d),color:p,alpha:m});s.sides.forEach((g,_)=>{h.push({points:c(l+(_===0?Math.PI/2:-Math.PI/2),n.sideLength*g*d,n.sideWidth*d),color:p,alpha:m})})}}return h}class Va extends Qt{constructor(t,e,s,n,o,r=sn,a=Math.random){super(o),this.position.set(t,e),this.dirX=s,this.dirY=n,this.config=r,this.roll=Ya(r,a),this.elapsedTime=0,this.graphics=new N,this.graphics.blendMode="add",this.addChild(this.graphics)}_update(t){if(this.isComplete)return;this.elapsedTime+=t,this.graphics.clear();const e=this.config.duration?this.elapsedTime/this.config.duration:1;if(e<1){const s=Xa({dirX:this.dirX,dirY:this.dirY,t:e,roll:this.roll,config:this.config});for(const{points:n,color:o,alpha:r}of s)this.graphics.poly(n).fill({color:o,alpha:r})}else this._completeEffect()}destroy(t){this.graphics&&this.graphics.clear(),super.destroy(t)}}const Js=2;class Oa extends U{constructor(t,e,s){super(),this.startPositionX=t[Fo],this.startPositionY=t[Do],this.endPositionX=t[Yo],this.endPositionY=t[Xo],this.soundPositionX=t[Vo],this.soundPositionY=t[Oo],this.hit=t[Bo],this.endLevel=t[Wo]||0,this.startLevel=t[No]||0,this.zIndex=G(Js,this.endLevel),this.anchorKey=null,this.anchorLocalX=0,this.anchorLocalY=0,Array.isArray(t[Cs])&&([this.anchorKey,this.anchorLocalX,this.anchorLocalY]=t[Cs]),this._assets=e,this._soundManager=s.soundManager,this._isLocalShot=s.localPlayer?.is(t[He])===!0,s.shots?.fired(t[He]),this._mapDynamics=s.mapDynamics||null,this._shots=s.shots||null,this._shooterId=t[He],this._levelView=s.levelView||null,this._lighting=s.lighting||null,this._renderer=s.renderer||null,(this._levelView||this._renderer)&&(this.onRender=()=>{this._levelView&&(this.alpha=this._levelView.alphaFor(this.endLevel,this.endPositionX,this.endPositionY),this.tint=this._levelView.tintFor(this.endLevel));const n=gt(this.parent,this._renderer);ft(this,n,this.endLevel*W.shear,1);for(const[o,r]of this.layers)this._levelView&&(r.alpha=this._levelView.alphaFor(o,r.refX,r.refY),r.tint=this._levelView.tintFor(o)),ft(r,n,o*W.shear,1);this._followMuzzle(),this._placeFlash(n)}),this.tracer=null,this.layers=new Map,this.impact=null,this.flash=null,this._flashComplete=!0,this._isDestroyed=!1,this._visualsComplete=!1,this._soundComplete=!1,this._soundId=this._soundManager.registerSound("shot",{position:{x:this.soundPositionX,y:this.soundPositionY},spatial:!this._isLocalShot},()=>{this._soundComplete=!0,this._soundId=null,this._tryDestroy()}),this._soundId||(this._soundComplete=!0)}run(){if(this._isDestroyed)return;this._lighting?.flash({...Jt.flash.shot,level:this.startLevel,x:this.startPositionX,y:this.startPositionY,z:this.startLevel});const t=this.endPositionX-this.startPositionX,e=this.endPositionY-this.startPositionY,s=Math.hypot(t,e);s>.001&&(this._flashComplete=!1,this.flash=new Va(this.startPositionX,this.startPositionY,t/s,e/s,()=>{this._flashComplete=!0,this._tryDestroy()}),this.addChild(this.flash),this.flash.run());const n=Fa(this._shots?.path?.(this.startPositionX,this.startPositionY,this.endPositionX,this.endPositionY,this.startLevel),s,this.endLevel);this.tracer=new Ia(this.startPositionX,this.startPositionY,this.endPositionX,this.endPositionY,this._onTracerComplete.bind(this),void 0,{pieces:n,layerFor:o=>this._layerFor(o,n)}),this.addChild(this.tracer),this.tracer.run()}_layerFor(t,e){const s=!!this._lighting?.isNight?.();if(!s&&t===this.endLevel||!this.parent)return this;let n=this.layers.get(t);if(!n){const o=e.find(c=>c.level===t),r=o?(o.from+o.to)/2:0,a=this.endPositionX-this.startPositionX,l=this.endPositionY-this.startPositionY,h=Math.hypot(a,l)||1;n=new U,n.label=`shot-tracer-${t}`,n.eventMode="none",n.zIndex=G(s?fi:Js,t),n.refX=this.startPositionX+a/h*r,n.refY=this.startPositionY+l/h*r,this.parent.addChild(n),this.layers.set(t,n)}return n}_followMuzzle(){if(!this._shots||this.impact)return;const t=this.tracer&&!this.tracer.isComplete,e=this.flash&&!this.flash.isComplete;if(!t&&!e)return;const s=this._shots.muzzle(this._shooterId);s&&(this.startPositionX=s.x,this.startPositionY=s.y,t&&this.tracer.shiftTo(s.x,s.y))}_placeFlash(t){if(!this.flash||this.flash.destroyed)return;if(!t){this.flash.position.set(this.startPositionX,this.startPositionY),this.flash.scale.set(1);return}const e=(1+this.startLevel*W.shear)/(1+this.endLevel*W.shear);this.flash.position.set(t.x+(this.startPositionX-t.x)*e,t.y+(this.startPositionY-t.y)*e),this.flash.scale.set(e)}_onTracerComplete(){if(!this._isDestroyed)if(this.hit){let t=this.endPositionX,e=this.endPositionY;if(this.anchorKey!==null&&this._mapDynamics){const l=this._mapDynamics.toWorld(this.anchorKey,this.anchorLocalX,this.anchorLocalY);l&&(t=l.x,e=l.y)}const s=t-this.startPositionX,n=e-this.startPositionY,o=Math.hypot(s,n);let r=0,a=0;o>.001&&(r=-(s/o),a=-(n/o)),this.impact=new Da(t,e,r,a,this._onImpactComplete.bind(this),this._assets),this.addChild(this.impact),this.impact.run()}else this._visualsComplete=!0,this._tryDestroy()}_onImpactComplete(){this._isDestroyed||(this._visualsComplete=!0,this._tryDestroy())}_tryDestroy(){this._visualsComplete&&this._soundComplete&&this._flashComplete&&this.destroy()}destroy(){if(!this._isDestroyed){this._isDestroyed=!0,this._soundId&&(this._soundManager.unregisterSound(this._soundId),this._soundId=null),this.tracer&&(this.tracer.destroy(),this.tracer=null);for(const t of this.layers.values())t.destroy({children:!0});this.layers.clear(),this.impact&&(this.impact.destroy(),this.impact=null),this.flash&&(this.flash.destroy(),this.flash=null),this.parent&&this.parent.removeChild(this),super.destroy({children:!0})}}}const Ba={Map:or,MapRadar:lr,TankRadar:ur,Tank:oa,Bomb:aa,ExplosionEffect:va,Smoke:Ta,Tracks:Aa,Dust:Ea,ShotEffect:Oa};function ke(i,t){const{radius:e,blur:s,color:n,quality:o=40}=i,r=new N,a=(e+St(s))*2,l=a/2;r.circle(l,l,e),r.fill(n);const h=new vt({strength:s,quality:o});h.padding=Pt(s),r.filters=[h];const c=t.generateTexture({target:r,frame:new Z(0,0,a,a)});return r.destroy(!0),{texture:c,contentSize:e*2}}function Na(i,t){const{baseRadius:e,irregularity:s=0,blur:n=0,numPoints:o=20,colorFill:r,colorRim:a=r,rimWidth:l=0,variants:h=1}=i,c=Math.max(1,Math.floor(h)||1),u=(e+s+l)*2,d=u+St(n)*2,p=d/2,m=[];for(let g=0;g<c;g+=1){const _=new N,v=[];for(let T=0;T<o;T+=1){const k=T/o*Math.PI*2,A=e+X(-s,s);v.push(p+A*Math.cos(k),p+A*Math.sin(k))}_.poly(v).fill(r).stroke({width:l,color:a,alignment:1});const M=new vt({strength:n,quality:10});M.padding=Pt(n),_.filters=[M],m.push(t.generateTexture({target:_,frame:new Z(0,0,d,d)})),_.destroy(!0)}return{textures:m,contentSize:u}}function pt(i,t,e){const s=Math.hypot(i,t,e)||1,n=o=>Math.round((o/s*.5+.5)*255);return n(i)<<16|n(t)<<8|n(e)}const ie=pt(0,0,1);function bi(i,{x:t,y:e,w:s,h:n},{l:o,r,t:a,b:l},h){i.poly([t,e,t+s,e,t+s-r,e+a,t+o,e+a]).fill(h.t),i.poly([t,e+n,t+s,e+n,t+s-r,e+n-l,t+o,e+n-l]).fill(h.b),i.poly([t,e,t+o,e+a,t+o,e+n-l,t,e+n]).fill(h.l),i.poly([t+s,e,t+s-r,e+a,t+s-r,e+n-l,t+s,e+n]).fill(h.r)}function Mi(i,t,e,s){const n=t.length/2;for(let o=0;o<n;o+=1){const r=(o+1)%n,a=t[o*2],l=t[o*2+1],h=t[r*2],c=t[r*2+1];let u=c-l,d=-(h-a);u*(a+h)+d*(l+c)<0&&(u=-u,d=-d),i.poly([a,l,h,c,h*e,c*e,a*e,l*e]).fill(s(u,d))}}const at=10,Fe=at*4,De=at*3,Wa=13158852,q={x:-Fe/2,y:-De/2,w:Fe,h:De},ne={x:-18,y:-9,w:36,h:18},Ti={l:2,r:4,t:2,b:2},Ua=[{x:-19,y:-14,w:38,h:5},{x:-19,y:9,w:38,h:5}],Ye=[1.33,-.42,.42,-1,-.42,-1,-1.33,-.42,-1.33,.42,-.42,1,.42,1,1.33,.42].map(i=>i*at),ki=.6,Ce={x:.25*at,y:-.25*at,w:2.08*at},we={x:2.1*at,y:-.36*at,w:.35*at,h:.72*at},qe={x:-.45*at,y:.35*at,r:.28*at},ns={width:.08*at},Ha=.55;function Ai(i){i.rect(q.x,q.y,q.w,q.h).fill(5592405);for(const t of Ua){i.rect(t.x,t.y,t.w,t.h).fill(3947580);for(let e=t.x+1;e<t.x+t.w;e+=3)i.rect(e,t.y,1,t.h).fill(2763306)}i.rect(ne.x,ne.y,ne.w,ne.h).fill(Wa),bi(i,ne,Ti,{l:11119269,r:11974578,t:11119269,b:11119269});for(let t=-6;t<=5;t+=3)i.rect(-15,t,4,1).fill(7829619)}function os(i,t){const e={...ns,color:jt(t,Ha)},s={width:.06*at,color:e.color};i.poly(Ye).fill(t).stroke(e),Mi(i,Ye,ki,()=>jt(t,.8)),i.circle(qe.x,qe.y,qe.r).fill(jt(t,.65)).stroke(s),i.rect(Ce.x,Ce.y,Ce.w,2.5*2).fill(t).stroke(e),i.rect(we.x,we.y,we.w,we.h).fill(jt(t,.7)).stroke(s)}const ge={width:Fe,height:De};function Ga(i,t){const{colors:e}=i,s={},n=Ai,o=os,r=p=>{p.rect(q.x,q.y,q.w,q.h).fill(ie),p.rect(q.x,q.y,q.w,1).fill(pt(0,-1,1)),p.rect(q.x,q.y+q.h-1,q.w,1).fill(pt(0,1,1)),p.rect(q.x,q.y+1,1,q.h-2).fill(pt(-1,0,1)),p.rect(q.x+q.w-1,q.y+1,1,q.h-2).fill(pt(1,0,1)),bi(p,ne,Ti,{l:pt(-1,0,1),r:pt(1,0,2),t:pt(0,-1,1),b:pt(0,1,1)})},a=p=>{p.poly(Ye).fill(ie).stroke({...ns,color:ie}),Mi(p,Ye,ki,(g,_)=>pt(g,_,1));const m=({x:g,y:_,w:v,h:M},T)=>{p.rect(g,_,v,M).fill(ie).stroke({...T,color:ie}),p.rect(g,_,v,M/2).fill(pt(0,-1,1)),p.rect(g,_+M/2,v,M/2).fill(pt(0,1,1))};m({...Ce,h:2.5*2},ns),m(we,{width:.06*at})},l=(p,m)=>{const g=new N;p(g);const _=t.generateTexture({target:g,frame:m});return g.destroy(!0),_},h=p=>{const m=new N;p(m);const g=m.getBounds();return m.destroy(!0),new Z(g.x,g.y,g.width,g.height)},c=p=>{const m=h(n),g=h(v=>o(v,p)),_={x:-g.x/g.width,y:-g.y/g.height};return{body:l(n,m),bodyNormal:l(r,m),gun:l(v=>o(v,p),g),gunNormal:l(a,g),gunAnchor:_}},u=()=>{const p=new U,m=new N,g=new N;p.addChild(m,g);const _=3815994,v=2434341,M=3158064,T=1579032,k=5263440,A=Fe,L=De,b=at;m.moveTo(-A/2-b*.1,-L/2+b*.2).lineTo(A/2+b*.2,-L/2-b*.1).lineTo(A/2-b*.1,L/2+b*.3).lineTo(-A/2+b*.3,L/2-b*.2).closePath().fill(_).stroke({width:b*.2,color:k,alignment:.5}),m.moveTo(-A/2+b*.4,-L/2+b*.5).lineTo(A/2-b*.3,-L/2+b*.2).lineTo(A/2-b*.4,L/2-b*.1).lineTo(-A/2+b*.2,L/2-b*.4).closePath().fill(v),m.circle(A*.15,L*.1,b*1.2).fill(T),m.circle(-A*.3,-L*.25,b*.5).fill(T),g.position.set(b*.3,-b*.2);const Y=[b*1.1,-b*.7,b*.2,-b*1,-b*.6,-b*.9,-b*1.3,-b*.2,-b*1.1,b*.6,-b*.2,b*1,b*.7,b*.8,b*1.3,b*.1];g.poly(Y).fill(M).stroke({width:b*.15,color:k,alignment:0});const z=[b*.8,-b*.25,b*1.5,-b*.4,b*1.4,b*.15,b*.7,b*.05];g.poly(z).fill(M).stroke({width:b*.1,color:k,alignment:0}),g.circle(b*.1,-b*.2,b*.4).fill(T);const R=p.getBounds(),B=t.generateTexture({target:p,frame:new Z(R.x,R.y,R.width,R.height)});p.destroy({children:!0});const J=new N().rect(R.x,R.y,R.width,R.height).fill(ie),V=t.generateTexture({target:J,frame:new Z(R.x,R.y,R.width,R.height)});return J.destroy(!0),{texture:B,normal:V}};s.liveTeamId1=c(e.teamId1),s.liveTeamId2=c(e.teamId2);const d=u();return s.destroyed=d.texture,s.destroyedNormal=d.normal,s}const ht=2;function $a(i,{x:t,y:e,w:s,h:n}){i.rect(t,e,s,n).fill(3026478),i.rect(t,e,s,1).fill(3947580);const o=Math.max(1,n*.38);for(let r=t+o+1;r<t+s-o;r+=o*2.6)i.circle(r,e+n*.58,o).fill(4868682),i.circle(r,e+n*.58,o*.4).fill(2236962)}function Qs(i,{x:t,y:e,w:s,h:n},o){i.rect(t,e,s,n).fill(jt(o,.75)),n>2&&i.rect(t,e+1,s,n-2).fill(o)}function Ka(i,t,e=wt){const{colors:s}=i,n=(o,r=!1)=>{const a=new N;os(a,o);const l=a.getBounds();a.destroy(!0);const h=Math.ceil(l.width),c=Math.ceil(l.height),u={x:ht,y:ht,w:ge.width,h:ge.height,originX:ht+ge.width/2,originY:ht+ge.height/2},d={x:u.x+u.w+ht,y:ht,w:h,h:c,originX:u.x+u.w+ht-l.x,originY:ht-l.y},p=ht+Math.max(u.h,d.h)+ht,m={x:ht,y:p,w:ge.width,h:e.trackHeight},g={x:m.x+m.w+ht,y:p,w:22,h:e.barrelRadius*2},_={x:g.x+g.w+ht,y:p,w:8,h:e.brakeRadius*2},v={x:_.x+_.w+ht,y:p,w:4,h:4},M=Math.max(d.x+d.w,v.x+v.w)+ht,T=p+Math.max(m.h,g.h,_.h,v.h)+ht,k=new U,A=new N,L=new N,b=new N;if(Ai(A),A.position.set(u.originX,u.originY),os(L,o),L.position.set(d.originX,d.originY),$a(b,m),Qs(b,g,o),Qs(b,_,jt(o,.7)),b.rect(v.x,v.y,v.w,v.h).fill(1710618),k.addChild(A,L,b),r){const z=new N;for(const R of[u,d,m,g,_])z.rect(R.x,R.y,R.w,R.h).fill({color:789e3,alpha:.62});z.circle(u.originX+4,u.originY+2,6).fill({color:0,alpha:.5}),z.circle(u.originX-9,u.originY-4,3).fill({color:0,alpha:.5}),z.circle(d.originX-2,d.originY+1,4).fill({color:0,alpha:.5}),k.addChild(z)}const Y=t.generateTexture({target:k,frame:new Z(0,0,M,T)});return k.destroy({children:!0}),{texture:Y,width:M,height:T,regions:{body:u,gun:d,trackSide:m,barrelSide:g,brakeSide:_,bottom:v}}};return{liveTeamId1:n(s.teamId1),liveTeamId2:n(s.teamId2),destroyed:n(3815994,!0)}}function Za(i,t){const{radius:e,borderWidth:s,crossSize:n,crossThickness:o,colors:r}=i,a={},l=(e+s)*2,h=l/2,c=15658734,u=3355443,d=m=>{const g=new N;g.circle(h,h,e).fill(c),g.circle(h,h,e-s).fill(m);const _=t.generateTexture({target:g,frame:new Z(0,0,l,l)});return g.destroy(!0),_},p=()=>{const m=new N,g=n/2;m.moveTo(h-g,h-g).lineTo(h+g,h+g).moveTo(h-g,h+g).lineTo(h+g,h-g).stroke({width:o,color:u});const _=t.generateTexture({target:m,frame:new Z(0,0,l,l)});return m.destroy(!0),_};return a.liveTeamId1=d(r.teamId1),a.liveTeamId2=d(r.teamId2),a.destroyed=p(),a}function qa(i,t){const{colorOuter:e,colorInner:s}=i,n=new N,o=20,r=1;n.rect(0,0,o,o).fill(e),n.rect(r,r,o-r*2,o-r*2).fill(s);const a=t.generateTexture({target:n,frame:new Z(0,0,o,o)});return n.destroy(!0),a}function ja(i,t){const{width:e,length:s,color:n}=i,o=new N;o.rect(0,0,s,e).fill(n);const r=t.generateTexture({target:o,frame:new Z(0,0,s,e)});return o.destroy(!0),r}function Ja(i,t){const{width:e,height:s,radius:n,blur:o,color:r,quality:a=20}=i,l=new N,h=St(o),c=e+h*2,u=s+h*2;l.roundRect(h,h,e,s,n),l.fill(r);const d=new vt({strength:o,quality:a});d.padding=Pt(o),l.filters=[d];const p=t.generateTexture({target:l,frame:new Z(0,0,c,u)});return l.destroy(!0),{texture:p,contentSize:e}}function Qa(i,t){const{baseRadius:e,irregularity:s=0,blur:n=0,numPoints:o=16,color:r,coreColor:a=r,coreRatio:l=.5,variants:h=1}=i,c=Math.max(1,Math.floor(h)||1),u=(e+s)*2,d=u+St(n)*2,p=d/2,m=[],g=(_,v)=>{const M=[];for(let T=0;T<o;T+=1){const k=T/o*Math.PI*2,A=_+X(-v,v);M.push(p+A*Math.cos(k),p+A*Math.sin(k))}return M};for(let _=0;_<c;_+=1){const v=new N;v.poly(g(e,s)).fill(r).poly(g(e*l,s*l)).fill(a);const M=new vt({strength:n,quality:10});M.padding=Pt(n),v.filters=[M],m.push(t.generateTexture({target:v,frame:new Z(0,0,d,d)})),v.destroy(!0)}return{textures:m,contentSize:u}}function tl(i,t){const{length:e,width:s,color:n,variants:o=1}=i,r=Math.max(1,Math.floor(o)||1),a=e/2,l=[];for(let h=0;h<r;h+=1){const c=new N,u=X(s*.3,s)/2,d=X(s*.1,s*.6)/2;c.poly([0,a-d,e,a-u,e,a+u,0,a+d]).fill(n),l.push(t.generateTexture({target:c,frame:new Z(0,0,e,e)})),c.destroy(!0)}return{textures:l,contentSize:e}}function Li(i,t,e,s,n){for(let o=0;o<s;o+=1){const r=e*o/s,a=e*(o+1)/s,l=n((o+.5)/s);l<=0||(i.circle(t,t,a),i.fill({color:16777215,alpha:l}),r>0&&(i.circle(t,t,r),i.cut()))}}function el(i,t){const{radius:e,rings:s=32,blur:n=2,quality:o=10}=i,r=new N,a=St(n),l=(e+a)*2,h=l/2;Li(r,h,e,s,d=>(1-d)*(1-d));const c=new vt({strength:n,quality:o});c.padding=Pt(n),r.filters=[c];const u=t.generateTexture({target:r,frame:new Z(0,0,l,l)});return r.destroy(!0),{texture:u,contentSize:e*2}}function sl(i,t){const{length:e,halfWidth:s,strips:n=24,blur:o=4,quality:r=10}=i,a=new N,l=St(o),h=e+l*2,c=(s+l)*2,u=l,d=c/2;for(let g=0;g<n;g+=1){const _=e*g/n,v=e*(g+1)/n,M=s*g/n,T=s*(g+1)/n,k=(g+.5)/n,A=(1-k)*(1-k*.35);a.poly([u+_,d-M,u+v,d-T,u+v,d+T,u+_,d+M]),a.fill({color:16777215,alpha:A})}const p=new vt({strength:o,quality:r});p.padding=Pt(o),a.filters=[p];const m=t.generateTexture({target:a,frame:new Z(0,0,h,c)});return a.destroy(!0),{texture:m,length:e,halfWidth:s,margin:l}}function il(i,t){const{core:e,halo:s,rings:n=12,blur:o=1,quality:r=10}=i,a=new N,l=St(o),h=(s+l)*2,c=h/2,u=e/s;Li(a,c,s,n,m=>m<=u?1:.6*(1-(m-u)/(1-u))**2);const d=new vt({strength:o,quality:r});d.padding=Pt(o),a.filters=[d];const p=t.generateTexture({target:a,frame:new Z(0,0,h,h)});return a.destroy(!0),{texture:p,contentSize:s*2}}function nl(i,t){const{radius:e,strips:s=16,blur:n=2,quality:o=10}=i,r=new N,a=St(n),l=(e+a)*2,h=l/2;for(let d=0;d<s;d+=1){const p=e*d/s,m=e*(d+1)/s,g=(d+.5)/s;r.rect(h+p,h-e,m-p,e*2),r.fill({color:16777215,alpha:g*g})}const c=new vt({strength:n,quality:o});c.padding=Pt(n),r.filters=[c];const u=t.generateTexture({target:r,frame:new Z(0,0,l,l)});return r.destroy(!0),{texture:u,contentSize:e*2}}function ol(i){let t=i>>>0;return()=>{t=t+1831565813>>>0;let e=t;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}function rl(i,t){const{radius:e,rays:s=14,width:n=.05,strips:o=8,seed:r=1,blur:a=3,quality:l=10}=i,h=new N,c=St(a),u=(e+c)*2,d=u/2,p=ol(r);for(let _=0;_<s;_+=1){const v=(_+(p()-.5)*.8)/s*Math.PI*2,M=e*(.55+.45*p()),T=.35+.65*p(),k=n*(.5+p()),A=Math.cos(v-k),L=Math.sin(v-k),b=Math.cos(v+k),Y=Math.sin(v+k);for(let z=0;z<o;z+=1){const R=M*z/o,B=M*(z+1)/o,J=(z+.5)/o;h.poly([d+A*R,d+L*R,d+A*B,d+L*B,d+b*B,d+Y*B,d+b*R,d+Y*R]),h.fill({color:16777215,alpha:T*(1-J)})}}const m=new vt({strength:a,quality:l});m.padding=Pt(a),h.filters=[m];const g=t.generateTexture({target:h,frame:new Z(0,0,u,u)});return h.destroy(!0),{texture:g,contentSize:e*2}}const al={explosionTexture:ke,smokeTexture:ke,impactParticleTexture:ke,dustTexture:ke,tankShadowTexture:Ja,funnelTexture:Na,tankTexture:Ga,tankModelTexture:Ka,tankRadarTexture:Za,bombTexture:qa,trackMarkTexture:ja,scorchTexture:Qa,debrisTexture:tl,lightRadialTexture:el,headlightConeTexture:sl,lampHeadTexture:il,glintTexture:nl,lightShaftTexture:rl},ll=i=>(i??"").split(/[?#]/)[0].endsWith(".js"),hl=i=>import(i);function cl(i=tn,t={}){const e={level:0,x:0,y:0,z:0,camera:null,key:null,stage:t.stage||null,renderer:t.renderer||null,warned:!1,diagnostics:null},s=()=>{if(e.warned)return;e.warned=!0;const o=e.stage,r=e.renderer?.screen,a={destroyed:o?o.destroyed:null,position:o?{x:o.position?.x,y:o.position?.y}:null,scale:o?{x:o.scale?.x,y:o.scale?.y}:null,screen:r?{width:r.width,height:r.height}:null};console.warn("[tanks] levelView: центра камеры нет — кадр без трансформа сцены",a),e.diagnostics?.warn("tanks.camera.missing",a)},n=()=>{if(!e.stage)return null;if(e.stage.destroyed)return s(),null;const{position:o,scale:r}=e.stage,a=e.renderer?.screen,l=a?a.width:0,h=a?a.height:0,c=e.key;return(e.camera===null||c===null||c.x!==o.x||c.y!==o.y||c.scaleX!==r.x||c.scaleY!==r.y||c.width!==l||c.height!==h)&&(e.key={x:o.x,y:o.y,scaleX:r.x,scaleY:r.y,width:l,height:h},e.camera=gt(e.stage,e.renderer),e.camera===null&&s()),e.camera};return{attachStage(o,r){!o||!r||e.stage&&!e.stage.destroyed||(e.stage=o,e.renderer=r,e.key=null,e.camera=null)},setDiagnostics(o){!e.diagnostics&&o&&(e.diagnostics=o)},camera(){return n()},set(o,r,a,l=0){e.level=o,e.x=r,e.y=a,e.z=l},alphaFor(o,r,a,l=o){const h=n(),c=dt(e.x,e.y,h,e.z*W.shear),u=dt(r,a,h,l*W.shear);return un({viewLevel:e.level,viewX:c.x,viewY:c.y,level:o,x:u.x,y:u.y,cfg:i})},tintFor(o){return dn(e.level,o,i)},get cfg(){return i},get mode(){return i.mode},get level(){return e.level},get x(){return e.x},get y(){return e.y},get z(){return e.z}}}const je=16777215;class ti{constructor({level:t,ambient:e,resolution:s,area:n,roof:o=!1}){this.level=t,this.ambient=e,this.roof=o,this.overlay=new U,this.overlay.label=o?`lighting-roof-${t}`:`lighting-${t}`,this.overlay.zIndex=G(Yn,t),this.overlay.eventMode="none",this.base=new K(ze.WHITE),this.base.tint=t===0?e:je,this.base.position.set(n.x,n.y),this.base.width=n.width,this.base.height=n.height,this.overlay.addChild(this.base),this.mask=t>=1?new N:null,this.mask&&this.overlay.addChild(this.mask),this.lights=new U,this.overlay.addChild(this.lights),this.rampLights=new U,this.overlay.addChild(this.rampLights),this.rampMask=null,this.ramps=[],this.rampPool=[],this.rampFanPool=[],this.shafts=new U,this.overlay.addChild(this.shafts),this.shaftPool=[],this.tops=new U,this.overlay.addChild(this.tops),this.topGroups=[],this.pool=[],this.fanPool=[],this.filter=new ri({alpha:1}),this.filter.resolution=s,this.filter.blendMode="multiply",this.overlay.filters=[this.filter],this.overlay.filterArea=new Z(n.x,n.y,n.width,n.height),this.resolution=s,this.hole=ts(),this.hasMask=!1}setMask(t,e,s){if(this.mask){this.mask.clear(),this.hasMask=t.length>0;for(const n of t)this.mask.rect(n.col*e*s.x,n.row*e*s.y,n.length*e*s.x,e*s.y);this.hasMask&&this.mask.fill(this.ambient)}}setTops(t,e,s){for(const n of this.topGroups)n.graphics.destroy();this.topGroups=[];for(const{volume:n,runs:o}of t){if(!o.length)continue;const r=new N;for(const a of o)r.rect(a.col*e*s.x,a.row*e*s.y,a.length*e*s.x,e*s.y);r.fill(this.ambient),this.tops.addChild(r),this.topGroups.push({graphics:r,volume:n})}}setRamps(t,e,s,n){this.ramps=t,this.rampGeometry={step:e,scale:s,segments:n},t.length&&!this.rampMask?(this.rampMask=new N,this.overlay.addChild(this.rampMask),this.rampLights.mask=this.rampMask):!t.length&&this.rampMask&&(this.rampLights.mask=null,this.rampMask.destroy(),this.rampMask=null)}rampLevels(){return new Set(this.ramps.map(t=>t.to))}place(t,e){if(this.mask&&ft(this.mask,t,this.level*e,1),this.rampMask){const{step:s,scale:n,segments:o}=this.rampGeometry;this.rampMask.clear();for(const r of this.ramps)this.rampMask.poly(Zn(r,s,n,t,e,o));this.rampMask.fill(je)}for(const{graphics:s,volume:n}of this.topGroups)ft(s,t,(this.level+n)*e,1)}layout(t){ei(this.pool,this.lights,t.filter(e=>!e.fan)),si(this.fanPool,this.lights,t.filter(e=>e.fan))}layoutRamps(t){ei(this.rampPool,this.rampLights,t.filter(e=>!e.fan)),si(this.rampFanPool,this.rampLights,t.filter(e=>e.fan))}layoutShafts(t){for(;this.shaftPool.length<t.length;){const e=new U,s=new K,n=new N;s.anchor.set(.5),s.blendMode="add",e.addChild(s,n),this.shafts.addChild(e),this.shaftPool.push({container:e,sprite:s,shadow:n,masked:!1})}for(let e=0;e<this.shaftPool.length;e+=1){const s=this.shaftPool[e],n=t[e];if(!n){s.container.visible=!1;continue}const{container:o,sprite:r,shadow:a}=s,l=n.shadows||[];o.visible=!0,r.texture=n.texture,r.position.set(n.x,n.y),r.scale.set(n.scale),r.rotation=n.rotation,r.tint=n.color,r.alpha=n.alpha,a.clear();for(const c of l)a.poly(c);l.length&&a.fill(je);const h=l.length>0;h!==s.masked&&(s.masked=h,h?o.setMask({mask:a,inverse:!0}):(o.mask=null,a.visible=!1)),h&&(a.visible=!0)}}destroy(){const t=this.overlay;t.parent?.removeChild(t),es(this.hole,t),t.filters=[],this.filter.destroy();for(const e of[...this.pool,...this.rampPool])e.texture=null;for(const e of[...this.fanPool,...this.rampFanPool])e.texture=ze.EMPTY,e.geometry.destroy();this.pool=[],this.rampPool=[],this.fanPool=[],this.rampFanPool=[],this.rampLights.mask=null,this.rampMask=null,this.ramps=[];for(const e of this.shaftPool)e.container.mask=null,e.sprite.texture=null;this.shaftPool=[],this.topGroups=[],t.destroy({children:!0,texture:!1,textureSource:!1})}}function ei(i,t,e){for(;i.length<e.length;){const s=new K;s.blendMode="add",i.push(s),t.addChild(s)}for(let s=0;s<i.length;s+=1){const n=i[s],o=e[s];if(!o){n.visible=!1;continue}n.visible=!0,n.texture=o.texture,n.anchor.set(o.anchorX,o.anchorY),n.position.set(o.x,o.y),n.scale.set(o.scaleX,o.scaleY),n.rotation=o.rotation,n.tint=o.color,n.alpha=o.alpha}}function si(i,t,e){for(;i.length<e.length;){const s=new Wi({positions:new Float32Array(6),uvs:new Float32Array(6),indices:vs(2)}),n=new oi({geometry:s,texture:ze.EMPTY});n.blendMode="add",n.shape=null,n.topology=null,i.push(n),t.addChild(n)}for(let s=0;s<i.length;s+=1){const n=i[s],o=e[s];if(!o){n.visible=!1;continue}const{fan:r}=o,{shape:a}=r;if(n.shape!==a){const l=n.geometry,h=a.points.length/2-1,c=`${h}:${!!a.closed}`;n.topology!==c&&(l.indices=vs(h,a.closed),n.topology=c),l.positions=a.points,l.uvs=a.uvs,n.shape=a}n.visible=!0,n.texture=o.texture,n.position.set(r.x,r.y),n.scale.set(r.scale),n.tint=o.color,n.alpha=o.alpha}}const ul=3818080,dl=["radial","cone","head","glint","shaft"],fl=.08,_l=.6;function pl(i,t,e){const s=(i?.cols??0)*t*e.x,n=(i?.rows??0)*t*e.y,o=Math.max(s,n);return{x:-o,y:-o,width:s+o*2,height:n+o*2}}function ml(i=Jt,t={}){const e=!!i.enabled,s=t.levelView||null,n=t.shear??W.shear;let o=null,r=null;const a={},l=new Set,h=new Map,c=[],u=new Map;let d=null,p=0,m=null;const g=new Map;let _=null;const v=new Map,M=new Map,T=new Map,k=new Map;let A=!1,L=null;const b=new WeakMap;let Y=0;const z=()=>s?.cfg||null,R=(f,y,x,w)=>{let S=f.get(w);return S||(S=new U,S.label=`${x}-${w}`,S.zIndex=G(y,w),S.eventMode="none",f.set(w,S)),S},B=f=>R(_.emissive,fi,"emissive",f),J=f=>R(_.lampHeads,Xn,"lamp-heads",f),V=()=>{if(!(!_?.night||!a.head||_.headsReady)){_.headsReady=!0;for(const f of _.lamps){if(!f.head)continue;const y=new K(a.head.texture);y.anchor.set(.5),y.blendMode="add",y.tint=f.color,f.headSprite=y,J(f.level).addChild(y)}}},ct=(f,y,x,w)=>{const S=f||{},I=!!S.night,E=Xe(x??1);if(_={night:I,ambient:S.ambient??ul,step:y,scale:E,area:pl(w,y,E),cols:w?.cols??0,rows:w?.rows??0,blockers:new Map,rampCells:new Map,lamps:[],headsReady:!1,levels:new Map,roofLevels:new Map,emissive:new Map,lampHeads:new Map,maskCells:new Map,roofCells:new Map},!!I){(S.lamps||[]).forEach((C,D)=>{const[O,tt]=C.cell||[0,0],F=C.level||0,H=Bn(O,tt,y,E);_.lamps.push({kind:"radial",level:F,x:H.x,y:H.y,z:F,radius:C.radius??0,rotation:0,color:C.color??16777215,intensity:C.intensity??1,flicker:C.flicker||0,seed:D+1,head:!!C.head,headSprite:null})});for(const[C,D]of h)B(D).addChild(C);_.lampGrid=Hn(_.lamps,Math.max(1,..._.lamps.map(C=>C.radius))),V(),A=!0,L=null}},bt=()=>{if(_){for(const f of[..._.emissive.values(),..._.lampHeads.values()])f.parent?.removeChild(f);for(const f of Q())f.overlay.parent?.removeChild(f.overlay);for(const f of _.emissive.values())for(const y of h.keys())y.parent===f&&f.removeChild(y);for(const f of _.lamps)f.headSprite&&(f.headSprite.destroy({texture:!1,textureSource:!1}),f.headSprite=null);for(const f of[..._.emissive.values(),..._.lampHeads.values()])f.destroy({children:!0});for(const f of Q())f.destroy();_=null,L=null}},it=()=>{bt(),v.clear(),M.clear(),T.clear(),k.clear(),A=!1,m=null},Q=()=>[..._.levels.values(),..._.roofLevels.values()],lt=(f,y=null)=>{const x=[],w=new Set;for(const S of f?.values()||[])for(const I of S){const E=`${I[0]},${I[1]}`;!w.has(E)&&!y?.has(E)&&(w.add(E),x.push(I))}return[x,w]},Nt=(f,y,x,w)=>{let S=f.get(y);if(x.length===0){S&&(S.destroy(),f.delete(y));return}S||(S=new ti({level:y,ambient:_.ambient,resolution:i.resolution,area:_.area,roof:w}),f.set(y,S)),S.setMask(xs(x),_.step,_.scale)},Wt=f=>{const y=new Map;for(const{cells:x,volume:w}of T.get(f)?.values()||[])y.has(w)||y.set(w,[]),y.get(w).push(...x);return[...y].map(([x,w])=>({volume:x,runs:xs(w)}))},ce=()=>{_.blockers=new Map,_.rampCells=new Map,Y+=1;const{cols:f,rows:y}=_;if(!(f>0&&y>0))return;const x=(w,S)=>w>=0&&w<f&&S>=0&&S<y;for(const[w,S]of T){let I=null;for(const{cells:E}of S.values())for(const[C,D]of E)x(C,D)&&(I||=new Uint8Array(f*y),I[D*f+C]=1);I&&_.blockers.set(w,I)}for(const[w,S]of k){const I=[...S.values()].flat();if(!I.length)continue;const E=new Int32Array(f*y);I.forEach((C,D)=>{for(let O=C.row0;O<C.row1;O+=1)for(let tt=C.col0;tt<C.col1;tt+=1)x(tt,O)&&(E[O*f+tt]=D+1)}),_.rampCells.set(w,{cells:E,lanes:I})}},yt=f=>{const y=f.level??0,x=_.blockers.get(y)||null,{cols:w,rows:S}=_,I=_.step*_.scale.x,E=_.step*_.scale.y,C=(F,H)=>F>=0&&F<w&&H>=0&&H<S?H*w+F:-1,D=_.rampCells.get(y)||null;if(!x&&!D)return null;const O=F=>D&&F>=0&&D.cells[F]>0?D.lanes[D.cells[F]-1]:null,tt=O(C(Math.floor(f.x/I),Math.floor(f.y/E)));return(F,H,rt,Dt,Gt,ot)=>{const Yt=C(F,H);if(x&&Yt>=0&&x[Yt]===1)return!0;if(!D||rt===null||rt===void 0)return!1;const nt=O(Yt),fs=O(C(rt,Dt));return tt&&(nt===tt||fs===tt)?!1:jn({lane:nt,prevLane:fs,col:F,row:H,prevCol:rt,prevRow:Dt,x:Gt,y:ot,z:f.z??y,cellW:I,cellH:E})}},zt=()=>i.headlights?.occlusion,Ut=(f,y)=>{const x=zt();if(!x?.enabled||!y||!(f.radius>0))return null;const w=f.level??0,S=f.rotation||0,I=f.spread??.5,E=`${f.x},${f.y},${f.z},${S},${w},${f.radius},${I},${Y},${x.rays}`,C=b.get(f);if(C&&C.key===E&&C.texture===y.texture)return C;const D=yt(f);if(!D)return null;const O=_.step*_.scale.x,tt=_.step*_.scale.y,F=y.texture.width,H=y.texture.height,rt=f.radius/y.length,Dt=f.radius*I/y.halfWidth,{points:Gt,clipped:ot,closed:Yt}=Qn({x:f.x,y:f.y,rotation:S,alongMax:(F-y.margin)*rt,alongBack:y.margin*rt,acrossMax:H/2*Dt,rays:x.rays},D,O,tt),nt={key:E,texture:y.texture,shape:ot?{points:Gt,closed:Yt,uvs:to(Gt,{x:f.x,y:f.y,rotation:S,sx:rt,sy:Dt,margin:y.margin,width:F,height:H})}:null,hit:Jn(f.x,f.y,Math.cos(S),Math.sin(S),f.radius,D,O,tt)};return b.set(f,nt),nt},Ht=(f,y,x)=>{if(f.kind!=="cone"||!zt()?.enabled)return!0;const w=yt(f);if(!w)return!0;const S=Math.hypot(y-f.x,x-f.y);return S<1e-6?!0:ds(f.x,f.y,(y-f.x)/S,(x-f.y)/S,S,w,_.step*_.scale.x,_.step*_.scale.y)>=S},It=()=>{const f=A;if(A){A=!1;const y=new Set([...v.keys(),...M.keys(),..._.levels.keys(),..._.roofLevels.keys()]);for(const x of y){if(x<1)continue;const[w,S]=lt(M.get(x)),[I,E]=lt(v.get(x),S);_.maskCells.set(x,E),_.roofCells.set(x,S),Nt(_.levels,x,I,!1),Nt(_.roofLevels,x,w,!0)}}if(_.levels.has(0)||_.levels.set(0,new ti({level:0,ambient:_.ambient,resolution:i.resolution,area:_.area})),f){ce();for(const y of _.levels.values())y.setTops(Wt(y.level),_.step,_.scale),y.setRamps([...k.get(y.level)?.values()||[]].flat(),_.step,_.scale,Zt.rampSegments)}},$=()=>{for(const f of Q())f.overlay.parent!==o&&o.addChild(f.overlay);for(const f of[..._.emissive.values(),..._.lampHeads.values()])f.parent!==o&&o.addChild(f)},Ft=(f,y,x)=>{const w=f.kind==="cone"?a.cone:a.radial;if(!w||!(f.intensity*x>0))return null;const S=Se(f.x,f.y,f.z??f.level,y,o,n);if(f.kind==="cone"){const E=f.radius*S.scale,C=E*(f.spread??.5);return{reach:E*o.scale.x,view:S,fan:null,hit:null,texture:w.texture,anchorX:w.margin/w.texture.width,anchorY:.5,scaleX:E/w.length,scaleY:C/w.halfWidth,rotation:f.rotation||0,color:f.color,alpha:f.intensity*x}}const I=f.radius*S.scale;return{reach:I*o.scale.x,view:S,texture:w.texture,anchorX:.5,anchorY:.5,scaleX:I*2/w.contentSize,scaleY:I*2/w.contentSize,rotation:0,color:f.color,alpha:f.intensity*x}},te=(f,y)=>{const x=i.headlights?.bounce;if(!x||!(x.intensity>0)||!(x.radius>0)||y.distance>(x.maxDistance??f.radius))return null;const w=f.rotation||0,S=x.radius*_l;return{kind:"radial",level:f.level,levels:f.levels,x:y.x-Math.cos(w)*S,y:y.y-Math.sin(w)*S,z:f.z,radius:x.radius,color:f.color,intensity:(f.intensity??1)*x.intensity*(1-y.distance/f.radius)}},xt=(f,y)=>{if(y.kind!=="cone")return;const x=Ut(y,a.cone);if(!x)return;const{view:w}=f;x.shape&&(f.fan={shape:x.shape,x:w.x-y.x*w.scale,y:w.y-y.y*w.scale,scale:w.scale}),f.hit=x.hit},Ci=(f,y,x)=>{const w=new Map,S=new Map;let I=0;const E=new Map;for(const F of _.levels.values())for(const H of F.rampLevels())E.has(H)||E.set(H,[]),E.get(H).push(F.level);const C=i.rampSpill??1,D=(F,H)=>{const rt=F.levels??[F.level],Dt=rt.filter(nt=>_.levels.has(nt)),Gt=C>0?rt.flatMap(nt=>E.get(nt)||[]).filter(nt=>!rt.includes(nt)):[];if(I>=i.maxLights||Dt.length===0&&Gt.length===0)return;const ot=Ft(F,f,H);if(!ot||!We(ot.view.screenX,ot.view.screenY,ot.reach,y.width,y.height))return;ot.x=ot.view.x,ot.y=ot.view.y,xt(ot,F);for(const nt of Dt){if(I>=i.maxLights)return;w.has(nt)||w.set(nt,[]),w.get(nt).push(ot),I+=1}for(const nt of new Set(Gt)){if(I>=i.maxLights)return;S.has(nt)||S.set(nt,[]),S.get(nt).push({...ot,alpha:ot.alpha*C}),I+=1}const Yt=ot.hit?te(F,ot.hit):null;Yt&&O.push({light:Yt,factor:H})},O=[];for(let F=c.length-1;F>=0;F-=1){const H=c[F],rt=ws(x-H.start,H.duration);rt<=0?c.splice(F,1):D(H,rt)}for(const F of l)D(F,1);for(const F of _.lamps)D(F,be(F.seed,x,F.flicker));for(const{light:F,factor:H}of O)D(F,H);const tt=zi(f,y,x);for(const F of Q())F.place(f,n),F.layout(w.get(F.level)||[]),F.layoutRamps(F.roof?[]:S.get(F.level)||[]),F.layoutShafts(tt.get(F.level)||[])},Pi=(f,y,x,w,S)=>{if(!S.shadows||!(S.maxShadowCasters>0))return[];const I=f.radius*S.length,E=[];for(const D of u.values()){const O=Math.hypot(D.x-f.x,D.y-f.y);D.level===f.level&&O<I&&E.push({caster:D,distance:O})}E.sort((D,O)=>D.distance-O.distance);const C=[];for(const{caster:D}of E.slice(0,S.maxShadowCasters)){const O=(D.z??D.level)*n,tt=dt(D.x,D.y,w,O),F=$n(y.x,y.y,tt.x,tt.y,D.radius*(1+O),x);F&&C.push(F)}return C},zi=(f,y,x)=>{const w=new Map,S=i.shafts,I=a.shaft;if(!S?.enabled||!I)return w;let E=0;for(const C of _.lamps){if(!C.head||!_.levels.has(C.level))continue;if(E>=i.maxLights)break;const D=Se(C.x,C.y,C.level,f,o,n),O=C.radius*S.length*D.scale;!(O>0)||!We(D.screenX,D.screenY,O*o.scale.x,y.width,y.height)||(w.has(C.level)||w.set(C.level,[]),w.get(C.level).push({texture:I.texture,x:D.x,y:D.y,scale:O*2/I.contentSize,rotation:Kn(C.seed,x,fl),color:C.color,alpha:S.intensity*C.intensity*be(C.seed,x,C.flicker),shadows:Pi(C,D,O,f,S)}),E+=1)}return w},Ei=(f,y)=>{const x=z();if(!x)return;const w=j.shared.deltaMS/1e3,S=y?Math.min(1,x.fadeRate*w):0,I=dt(s.x,s.y,f,s.z*n);for(const E of Q()){if(E.level<1)continue;const C=s.level<E.level,D=E.roof&&C&&hn(_.roofCells.get(E.level),_.step,_.scale,I,f,[E.level*n],x.roofMargin??0),O=E.overlay;if(s.mode==="layer"){let tt=D;if(!E.roof){const H=re(s.x,_.scale.x,_.step),rt=re(s.y,_.scale.y,_.step);tt=C&&!!_.maskCells.get(E.level)?.has(`${H},${rt}`)}const F=tt?x.layerAlpha:1;O.alpha+=(F-O.alpha)*S;continue}ls(E.hole,E.roof?D:C,S),hs(O,E.hole,x,s,o,f),E.hole.attached?E.hole.filter.blendMode="multiply":O.filters?.[0]!==E.filter&&(O.filters=[E.filter])}},Ri=(f,y)=>{for(const x of _.lamps){const w=x.headSprite;if(!w)continue;const S=Se(x.x,x.y,x.level,f,o,n);w.position.set(S.x,S.y),w.scale.set(S.scale),w.alpha=(s?s.alphaFor(x.level,S.x,S.y,0):1)*be(x.seed,y,x.flicker)}if(s)for(const[x,w]of h)x.alpha=s.alphaFor(w,x.x,x.y,0)},ue=()=>e&&_?.night===!0,Ii=(f,y,x,w,S)=>{const I=[],E=C=>(C.levels??[C.level??0]).includes(x);for(const C of Gn(_.lampGrid,f,y))C.level===x&&I.push({light:C,factor:be(C.seed,S,C.flicker)});for(const C of l)C.kind==="cone"&&!w?.includes(C)&&E(C)&&_i(C,f,y)>0&&Ht(C,f,y)&&I.push({light:C,factor:1});for(const C of c){const D=ws(S-C.start,C.duration);D>0&&E(C)&&I.push({light:C,factor:D})}return I};return{get enabled(){return e},attachStage(f,y){!e||o||!f||!y||(o=f,r=y,L=null,s?.attachStage(f,y))},acquireMap(f,y,x,w,S){e&&(g.set(f,(g.get(f)||0)+1),f!==m&&(bt(),m=f,ct(y,x,w,S)))},releaseMap(f,y){if(!e)return;if(y!==void 0)for(const w of[v,M,T,k])for(const S of w.values())S.delete(y)&&(A=!0);const x=g.get(f);if(x!==void 0){if(x>1){g.set(f,x-1);return}g.delete(f),f===m&&it()}},setLevelMask(f,y,x,{roof:w=!1}={}){if(!e||!(f>=1))return;const S=w?M:v;S.has(f)||S.set(f,new Map),y&&y.length>0?S.get(f).set(x,y):S.get(f).delete(x),A=!0},setVolumeTops(f,y,x,w){!e||!(f>=0)||(T.has(f)||T.set(f,new Map),y&&y.length>0&&x>0?T.get(f).set(w,{cells:y,volume:x}):T.get(f).delete(w),A=!0)},setRampWedges(f,y,x){if(!e||!(f>=0))return;k.has(f)||k.set(f,new Map);const w=(y||[]).filter(S=>S.from===f&&S.to>S.from);w.length>0?k.get(f).set(x,w):k.get(f).delete(x),A=!0},registerTextures(f){if(!(!e||!f)){for(const y of dl){const x=f[y];if(!x)continue;const w=a[y];if(a[y]=x,y==="head"&&w&&w!==x){for(const S of h.keys())S.texture===w.texture&&(S.texture=x.texture);for(const S of _?.lamps||[])S.headSprite&&(S.headSprite.texture=x.texture)}}a.head&&V()}},texture(f){return a[f]||null},addLight(f){if(!e)return null;const y={kind:"radial",level:0,x:0,y:0,radius:0,rotation:0,color:16777215,intensity:1,...f};return l.add(y),y},updateLight(f,y){f&&l.has(f)&&Object.assign(f,y)},removeLight(f){l.delete(f)},flash(f){!ue()||!a.radial||c.push({kind:"radial",level:0,color:16777215,intensity:1,...f,start:j.shared.lastTime})},addEmissive(f,y){return!ue()||!f?!1:(h.get(f)!==void 0&&f.parent&&f.parent.removeChild(f),h.set(f,y||0),B(y||0).addChild(f),!0)},removeEmissive(f){if(h.has(f)){h.delete(f);for(const y of _?.emissive.values()||[])f.parent===y&&y.removeChild(f)}},isNight:ue,lightsAt(f,y,x,w=1,S=null){if(!ue()||!(w>0))return[];const I=j.shared.lastTime;if(d!==I&&(d=I,p=0),p>=i.maxLights)return[];const E=Un(Ii(f,y,x,S,I),f,y,w);return E.length&&(p+=1),E},onScreen(f,y,x,w){if(!o||!r?.screen)return!1;const S=s?s.camera():gt(o,r);if(!S)return!1;const I=Se(f,y,x,S,o,n);return We(I.screenX,I.screenY,w*I.scale*o.scale.x,r.screen.width,r.screen.height)},setCaster(f,y){e&&(y?u.set(f,y):u.delete(f))},render(){if(!ue()||!o||!r)return;const f=s?s.camera():gt(o,r),y=r.screen;if(!f||!y)return;const x=j.shared.lastTime,w=L;if(w!==null&&w.tick===x&&w.x===o.position.x&&w.y===o.position.y&&w.scaleX===o.scale.x&&w.scaleY===o.scale.y&&w.width===y.width&&w.height===y.height&&!A)return;const S=w===null||w.tick!==x;L={tick:x,x:o.position.x,y:o.position.y,scaleX:o.scale.x,scaleY:o.scale.y,width:y.width,height:y.height},It(),V(),$(),Ci(f,y,x),s&&Ei(f,S),Ri(f,x)},clear:it}}function gl({segments:i=null}={}){const t=new Map;return{subscribe(e,s){const n=String(e);return t.has(n)||t.set(n,new Set),t.get(n).add(s),()=>{const o=t.get(n);o&&(o.delete(s),o.size===0&&t.delete(n))}},fired(e){const s=t.get(String(e));if(s)for(const n of s)n.fired?.()},muzzle(e){const s=t.get(String(e));if(s)for(const n of s){const o=n.muzzle?.();if(o)return o}return null},path(e,s,n,o,r){const a=Math.hypot(n-e,o-s);if(!i||!(a>.001))return null;const l=i(e,s,(n-e)/a,(o-s)/a,a,r||0),h=[];for(let c=0;c+2<(l?.length??0);c+=3)h.push({t0:l[c],t1:l[c+1],level:l[c+2]});return h.length?h:null}}}function yl(){const i=new Set;return{subscribe(t){return i.add(t),()=>{i.delete(t)}},exploded(t){for(const e of i)e(t)}}}const xl=[[0,-1],[0,1],[-1,0],[1,0]],Sl={id:"tanks",engineApi:Ui,requires:["map.layers","map.levelsN","map.gameData","map.bodyState"],async createClientCore(i,{wasmUrl:t}){if(ll(t)){const s=await hl(t);return{core:new s.ClientCore(i),memory:null}}const e=await Ji({module_or_path:t});return{core:new Qe(i),memory:e.memory}},parts:Ba,bakers:al,styles:Qi,serviceNames:["levelView","mapDynamics","rampRuns","surfaces","lighting","shots","blasts"],hooks:{services(i){const t=cl(),e=ml(void 0,{levelView:t});let s=[],n=null,o=[],r=null;return{levelView:t,lighting:e,shots:gl({segments:(a,l,h,c,u,d)=>i.shot_segments(a,l,h,c,u,d)}),blasts:yl(),mapDynamics:{toWorld(a,l,h){const c=i.map_dynamics_to_world(a,l,h);return c.length===0?null:{x:c[0],y:c[1]}}},rampRuns:{forLevel(a){const l=i.map_generation();return l!==n&&(n=l,s=JSON.parse(i.ramp_runs())),s.filter(h=>h.from===a)}},surfaces:{kindAt(a,l,h){const c=i.surface_at(a,l,h);if(c<0)return null;const u=i.map_generation();return u!==r&&(r=u,o=JSON.parse(i.surface_types())),o[c]??null},dirAt(a,l,h){return xl[i.surface_dir_at(a,l,h)]??null}}}},onAuth(i,t){i.set_model(t.model)},onPanel(i,t){i.sync_panel(JSON.stringify(t))},onLocalAction(i,t,e,s){return t!=="down"?null:e==="fire"?i.try_fire(s)||null:((e==="nextWeapon"||e==="prevWeapon")&&i.cycle_weapon(e==="prevWeapon"),null)}}};export{Sl as default};
|