@vimp-games/tanks 0.20.4 → 0.20.5
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/assets/vimp_tanks_core_bg-DIjJLVIL.wasm +0 -0
- package/dist/client-CA7dcUo-.js +210 -0
- package/dist/core-node/vimp_tanks_core_bg.wasm +0 -0
- package/dist/{host-iKcFV4RQ.js → host-DNF_0pQB.js} +1 -1
- package/dist/manifest.json +5 -5
- 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.mp3 +0 -0
- package/dist/sounds/tank-water.webm +0 -0
- package/dist/sounds/victory.webm +0 -0
- package/package.json +2 -2
- package/dist/assets/vimp_tanks_core_bg-DKXLdX1E.wasm +0 -0
- package/dist/client-CBvMeqCF.js +0 -84
package/dist/client-CBvMeqCF.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import{UniformGroup as as,Filter as ls,GpuProgram as hs,GlProgram as cs,defaultFilterVert as us,Container as O,Sprite as $,Rectangle as G,Spritesheet as _s,MeshSimple as ds,Ticker as K,Text as Ue,BlurFilter as yt,Assets as ee,Texture as We,Graphics as W,PerspectiveMesh as fs,Particle as ps,ParticleContainer as ae,AlphaFilter as ms}from"pixi.js";const gs=4;class se{__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,_e.unregister(this),t}free(){const t=this.__destroy_into_raw();v.__wbg_clientcore_free(t,0)}abi_describe(){let t,e;try{const s=v.clientcore_abi_describe(this.__wbg_ptr);return t=s[0],e=s[1],ht(s[0],s[1])}finally{v.__wbindgen_free(t,e,1)}}apply_aim(t,e,s,i){v.clientcore_apply_aim(this.__wbg_ptr,t,e,s,i)}apply_input(t,e,s){const i=pt(t,v.__wbindgen_malloc,v.__wbindgen_realloc),o=st,r=pt(e,v.__wbindgen_malloc,v.__wbindgen_realloc),a=st;v.clientcore_apply_input(this.__wbg_ptr,i,o,r,a,s)}cycle_weapon(t){v.clientcore_cycle_weapon(this.__wbg_ptr,t)}debug_json(){let t,e;try{const s=v.clientcore_debug_json(this.__wbg_ptr);return t=s[0],e=s[1],ht(s[0],s[1])}finally{v.__wbindgen_free(t,e,1)}}decode_frame(t){let e,s;try{const i=Kt(t,v.__wbindgen_malloc),o=st,r=v.clientcore_decode_frame(this.__wbg_ptr,i,o);return e=r[0],s=r[1],ht(r[0],r[1])}finally{v.__wbindgen_free(e,s,1)}}dispatch(t,e){const s=pt(t,v.__wbindgen_malloc,v.__wbindgen_realloc),i=st,o=Kt(e,v.__wbindgen_malloc),r=st,a=v.clientcore_dispatch(this.__wbg_ptr,s,i,o,r);var l=xs(a[0],a[1]).slice();return v.__wbindgen_free(a[0],a[1]*1,1),l}hot_ptr(){return v.clientcore_hot_ptr(this.__wbg_ptr)>>>0}hot_values(){const t=v.clientcore_hot_values(this.__wbg_ptr);var e=de(t[0],t[1]).slice();return v.__wbindgen_free(t[0],t[1]*4,4),e}map_dynamics_to_world(t,e,s){const i=pt(t,v.__wbindgen_malloc,v.__wbindgen_realloc),o=st,r=v.clientcore_map_dynamics_to_world(this.__wbg_ptr,i,o,e,s);var a=de(r[0],r[1]).slice();return v.__wbindgen_free(r[0],r[1]*4,4),a}map_generation(){return v.clientcore_map_generation(this.__wbg_ptr)>>>0}my_game_id(){return v.clientcore_my_game_id(this.__wbg_ptr)}constructor(t){const e=pt(t,v.__wbindgen_malloc,v.__wbindgen_realloc),s=st,i=v.clientcore_new(e,s);if(i[2])throw fe(i[1]);return this.__wbg_ptr=i[0],_e.register(this,this.__wbg_ptr,this),this}offset(){return v.clientcore_offset(this.__wbg_ptr)}push_frame(t,e){const s=Kt(t,v.__wbindgen_malloc),i=st;return v.clientcore_push_frame(this.__wbg_ptr,s,i,e)!==0}ramp_runs(){let t,e;try{const s=v.clientcore_ramp_runs(this.__wbg_ptr);return t=s[0],e=s[1],ht(s[0],s[1])}finally{v.__wbindgen_free(t,e,1)}}reset(){v.clientcore_reset(this.__wbg_ptr)}resync(){v.clientcore_resync(this.__wbg_ptr)}sample(t){return v.clientcore_sample(this.__wbg_ptr,t)>>>0}set_active(t){v.clientcore_set_active(this.__wbg_ptr,t)}set_map(t){const e=pt(t,v.__wbindgen_malloc,v.__wbindgen_realloc),s=st,i=v.clientcore_set_map(this.__wbg_ptr,e,s);if(i[1])throw fe(i[0])}set_model(t){const e=pt(t,v.__wbindgen_malloc,v.__wbindgen_realloc),s=st;v.clientcore_set_model(this.__wbg_ptr,e,s)}surface_at(t,e,s){return v.clientcore_surface_at(this.__wbg_ptr,t,e,s)}surface_dir_at(t,e,s){return v.clientcore_surface_dir_at(this.__wbg_ptr,t,e,s)}surface_types(){let t,e;try{const s=v.clientcore_surface_types(this.__wbg_ptr);return t=s[0],e=s[1],ht(s[0],s[1])}finally{v.__wbindgen_free(t,e,1)}}sync_panel(t){const e=pt(t,v.__wbindgen_malloc,v.__wbindgen_realloc),s=st;v.clientcore_sync_panel(this.__wbg_ptr,e,s)}take_divergence(){let t,e;try{const s=v.clientcore_take_divergence(this.__wbg_ptr);return t=s[0],e=s[1],ht(s[0],s[1])}finally{v.__wbindgen_free(t,e,1)}}take_frames(){let t,e;try{const s=v.clientcore_take_frames(this.__wbg_ptr);return t=s[0],e=s[1],ht(s[0],s[1])}finally{v.__wbindgen_free(t,e,1)}}try_fire(t){const e=v.clientcore_try_fire(this.__wbg_ptr,t);let s;return e[0]!==0&&(s=ht(e[0],e[1]).slice(),v.__wbindgen_free(e[0],e[1]*1,1)),s}}Symbol.dispose&&(se.prototype[Symbol.dispose]=se.prototype.free);function ys(){return{__proto__:null,"./vimp_tanks_core_bg.js":{__proto__:null,__wbg_Error_92b29b0548f8b746:function(t,e){return Error(ht(t,e))},__wbg___wbindgen_throw_344f42d3211c4765:function(t,e){throw new Error(ht(t,e))},__wbindgen_init_externref_table:function(){const t=v.__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 _e=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>v.__wbg_clientcore_free(n,1));typeof FinalizationRegistry>"u"||new FinalizationRegistry(n=>v.__wbg_gamecore_free(n,1));function de(n,t){return n=n>>>0,ws().subarray(n/4,n/4+t)}function xs(n,t){return n=n>>>0,Mt().subarray(n/1,n/1+t)}let zt=null;function ws(){return(zt===null||zt.byteLength===0)&&(zt=new Float32Array(v.memory.buffer)),zt}function ht(n,t){return Ss(n>>>0,t)}let Pt=null;function Mt(){return(Pt===null||Pt.byteLength===0)&&(Pt=new Uint8Array(v.memory.buffer)),Pt}function Kt(n,t){const e=t(n.length*1,1)>>>0;return Mt().set(n,e/1),st=n.length,e}function pt(n,t,e){if(e===void 0){const a=Dt.encode(n),l=t(a.length,1)>>>0;return Mt().subarray(l,l+a.length).set(a),st=a.length,l}let s=n.length,i=t(s,1)>>>0;const o=Mt();let r=0;for(;r<s;r++){const a=n.charCodeAt(r);if(a>127)break;o[i+r]=a}if(r!==s){r!==0&&(n=n.slice(r)),i=e(i,s,s=r+n.length*3,1)>>>0;const a=Mt().subarray(i+r,i+s),l=Dt.encodeInto(n,a);r+=l.written,i=e(i,s,r,1)>>>0}return st=r,i}function fe(n){const t=v.__wbindgen_externrefs.get(n);return v.__externref_table_dealloc(n),t}let Bt=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});Bt.decode();const vs=2146435072;let Zt=0;function Ss(n,t){return Zt+=t,Zt>=vs&&(Bt=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),Bt.decode(),Zt=t),Bt.decode(Mt().subarray(n,n+t))}const Dt=new TextEncoder;"encodeInto"in Dt||(Dt.encodeInto=function(n,t){const e=Dt.encode(n);return t.set(e),{read:n.length,written:e.length}});let st=0,v;function bs(n,t){return v=n.exports,zt=null,Pt=null,v.__wbindgen_start(),v}async function Ms(n,t){if(typeof Response=="function"&&n instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(n,t)}catch(i){if(n.ok&&e(n.type)&&n.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",i);else throw i}const s=await n.arrayBuffer();return await WebAssembly.instantiate(s,t)}else{const s=await WebAssembly.instantiate(n,t);return s instanceof WebAssembly.Instance?{instance:s,module:n}:s}function e(s){switch(s){case"basic":case"cors":case"default":return!0}return!1}}async function Ts(n){if(v!==void 0)return v;n!==void 0&&(Object.getPrototypeOf(n)===Object.prototype?{module_or_path:n}=n:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),n===void 0&&(n=new URL("/assets/vimp_tanks_core_bg-DKXLdX1E.wasm",import.meta.url));const t=ys();(typeof n=="string"||typeof Request=="function"&&n instanceof Request||typeof URL=="function"&&n instanceof URL)&&(n=fetch(n));const{instance:e,module:s}=await Ms(await n,t);return bs(e)}const ks='@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}',As={mode:"hole",radius:260,softness:.45,minAlpha:.12,layerAlpha:.4,fadeRate:6,roofMargin:0,lowerTint:11579584},B={shear:.22,levelZStride:100},vt={faceTileRepeats:12,faceBleedPx:2,slices:4,rampSegments:4,sideTint:10133674},Ot={scaleGain:.1,baseAlpha:.4,alphaFalloff:.12,sizeFactor:1.05},Ct={lift:.35,vertices:6,shading:.28,lightDir:[-.7,-.7]},wt={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},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},mud:{alpha:1.5,lifetime:1,tint:5917242},noMarks:["water"]}},Rt={fullImpact:6,squash:.14,duration:260,minImpact:1.5},Ls={maxFps:30},Tt={enabled:!0,resolution:.5,maxLights:96,headlights:{length:90,spread:.55,intensity:.9,color:16773572,offset:.5,glareSize:6},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}}},Cs=B.levelZStride,X=(n,t)=>n+Cs*(t||0),Nt=(n,t)=>Math.min(n||0,Math.round(t));function lt(n,t){const e=t?.screen;return!n||!e||!n.scale.x||!n.scale.y?null:{x:(e.width/2-n.position.x)/n.scale.x,y:(e.height/2-n.position.y)/n.scale.y,scaleX:n.scale.x,scaleY:n.scale.y}}function rt(n,t,e,s){return!e||!s?{x:n,y:t}:{x:n+(n-e.x)*s,y:t+(t-e.y)*s}}function ot(n,t,e,s=1){const i=typeof s=="number"?s:s.x,o=typeof s=="number"?s:s.y;if(!t||!e){n.scale.set(i,o),n.position.set(0,0);return}n.scale.set(i*(1+e),o*(1+e)),n.position.set(-t.x*e,-t.y*e)}function $t(n){const t=typeof n=="number"?n:n.x,e=typeof n=="number"?n:n.y;return{x:t,y:e}}function kt(n,t,e){return Math.floor(n/t/e)}function Is(n,t,e){return Math.round(n/t/e)}function Es(n,t,e){return{map:n,scale:t,step:e}}function Ge(n,t,e,s){const i=kt(t,n.scale.x,n.step),o=kt(e,n.scale.y,n.step),r=n.map?.[o]?.[i];return r!==void 0&&s.has(r)}function $e(n,t,e,s,i){if(!e||!t)return!1;const o=i>0?[[0,0],[i,0],[-i,0],[0,i],[0,-i]]:[[0,0]];for(const r of s){const a=1+r;for(const[l,h]of o)if(n((t.x+l+e.x*r)/a,(t.y+h+e.y*r)/a))return!0}return!1}function qe(n,t,e,s,i,o){return n?.map?$e((r,a)=>Ge(n,r,a,t),e,s,i,o):!1}function zs(n,t,e,s,i,o,r){return!n||n.size===0?!1:$e((a,l)=>n.has(`${kt(a,e.x,t)},${kt(l,e.y,t)}`),s,i,o,r)}const Ke=n=>n.radius*(1-n.softness),Ps=(n,t,e)=>{if(t<=n)return e<t?0:1;const s=Math.min(1,Math.max(0,(e-n)/(t-n)));return s*s*(3-2*s)};function Rs({viewLevel:n,viewX:t,viewY:e,level:s,x:i,y:o,cfg:r}){if((s||0)<=(n||0))return 1;if(r.mode==="layer")return r.layerAlpha;const a=i-t,l=o-e,h=Math.sqrt(a*a+l*l),c=Ps(Ke(r),r.radius,h);return r.minAlpha+(1-r.minAlpha)*c}function Ds(n,t,e){return(t||0)<(n||0)?e.lowerTint:16777215}const Fs=`
|
|
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
|
-
`,pe=`
|
|
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 Vs(n){const t=new as({uHoleCenter:{value:new Float32Array([0,0]),type:"vec2<f32>"},uHoleParams:{value:new Float32Array([n.radius,Ke(n),n.minAlpha]),type:"vec3<f32>"}});return new ls({glProgram:cs.from({vertex:us,fragment:Fs,name:"see-through-hole-filter"}),gpuProgram:hs.from({vertex:{source:pe,entryPoint:"mainVertex"},fragment:{source:pe,entryPoint:"mainFragment"}}),resources:{holeUniforms:t}})}function Os(n,{centerX:t,centerY:e,radius:s,softness:i,minAlpha:o}){const r=n.resources.holeUniforms.uniforms;r.uHoleCenter[0]=t,r.uHoleCenter[1]=e,r.uHoleParams[0]=s,r.uHoleParams[1]=s*(1-i),r.uHoleParams[2]=o}const Xs=.01;function ie(){return{strength:0,filter:null,attached:!1,tick:null}}function le(n,t,e){return n.strength+=((t?1:0)-n.strength)*e,n.strength}function he(n,t,e,s,i,o){if(t.strength<Xs||!i){t.attached&&(n.filters=[],t.attached=!1);return}t.filter||(t.filter=Vs(e)),t.attached||(n.filters=[t.filter],t.attached=!0);const r=rt(s.x,s.y,o,s.z*B.shear);Os(t.filter,{centerX:r.x*i.scale.x+i.position.x,centerY:r.y*i.scale.y+i.position.y,radius:e.radius*i.scale.x,softness:e.softness,minAlpha:1+(e.minAlpha-1)*t.strength})}function ne(n,t){if(!n.filter){n.attached=!1;return}t.filters=[],n.attached=!1,n.filter.destroy(),n.filter=null}async function Ze(n,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"}},i=new _s(n,s);return await i.parse(),i}async function ce({baseTexture:n,spriteSheetData:t,map:e,tiles:s,step:i,renderer:o,exclude:r=[]}){const a=await Ze(n,t),l=new Set(r),h=s.filter(p=>!l.has(p)),c=e[0].length*i,u=e.length*i,f=new O;for(let p=0,x=e.length;p<x;p+=1)for(let M=0,S=e[p].length;M<S;M+=1){const b=e[p][M];if(h.includes(b)){const A=`frame${b}`,g=a.textures[A];if(g){const L=new $(g);L.x=M*i,L.y=p*i,f.addChild(L)}else console.warn(`Texture not found. Tile: ${b}, sprite: ${A}`)}}const d=o.generateTexture({target:f,frame:new G(0,0,c,u)});return f.destroy({children:!0}),a.destroy(),d}function Ys(n,t){const e=[];if(!Array.isArray(n))return e;for(const s of n){const i=s.axis===0?0:1,o=i===0?1:0,r=t(s.min,i),a=t(s.max,i),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,i):null,rail1:c?t(s.railMax,i):null,col0:i===0?r:l,col1:i===0?a:h,row0:i===0?l:r,row1:i===0?h:a})}return Bs(e)}function Bs(n){const t=new Map;for(const s of n){const i=t.get(s.block);i?i.push(s):t.set(s.block,[s])}const e=[];for(const s of t.values()){const i=a=>a.axis===1?a.col0:a.row0,o=a=>a.axis===1?a.col1:a.row1;s.sort((a,l)=>i(a)-i(l));let r=null;for(const a of s){if(r&&i(a)===o(r)){r.axis===1?r.col1=a.col1:r.row1=a.row1;continue}r={...a},e.push(r)}}return e}function ue(n){const t=new ds(n);return t.geometry.batchMode="batch",t}const Ns=1e-6,me=1e3,je=[0,1,3,0,3,2];function Hs(n,t){const e=[],s=n.length,i=n.reduce((r,a)=>Math.max(r,a.length),0),o=(r,a)=>{const l=n[a]?.[r];return l!==void 0&&t.has(l)};for(let r=0;r<s;r+=1)for(let a=0;a<i;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:n[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:n[r][a],col:a,row:r,nx:l,ny:0,x0:h,y0:r,x1:h,y1:r+1})}}return e}function Us({map:n,tiles:t,step:e,baseScale:s,level:i,volume:o,shear:r,sideTint:a,textures:l,tileRepeats:h=1}){const c=Hs(n,new Set(t)),u=i*r,f=(i+o)*r,d=f-Ns,p=e*s.x,x=[],M=new Map;for(const S of c)M.has(S.tile)||M.set(S.tile,[]),M.get(S.tile).push(S);for(const[S,b]of M){const A=l?.get(S);if(!A){console.warn(`buildVolumeWalls: no side texture for tile ${S}`);continue}for(let g=0;g<b.length;g+=me){const L=b.slice(g,g+me),C=L.length,z=new Float32Array(C*8),D=new Float32Array(C*8),P=new Uint32Array(C*6),F=new Float32Array(C*2),V=new Float32Array(C*2);for(let R=0;R<C;R+=1){const{nx:J,ny:xt,x0:Q,y0:et,x1:it,y1:dt}=L[R],_=Q*e,m=et*e,y=it*e,w=dt*e,k=0,Y=1,T=R*4;for(let I=0;I<4;I+=1){const Z=I%2===1,N=I<2,H=(T+I)*2;z[H]=(Z?y:_)*s.x,z[H+1]=(Z?w:m)*s.y,D[H]=Z?Y:k,D[H+1]=N?0:1/h}for(let I=0;I<6;I+=1)P[R*6+I]=T+je[I];F[R*2]=J,F[R*2+1]=xt,V[R*2]=(_+y)/2*s.x,V[R*2+1]=(m+w)/2*s.y}const j=ue({texture:A,vertices:z.slice(),uvs:D,indices:P});j.tint=a,x.push({target:j,k:d,base:z,k0:u,k1:f,cellWorld:p,tileRepeats:h,occluder:!0,walls:!0,normals:F,centers:V,facing:new Uint8Array(C).fill(2)})}}return x}function Ws(n,t,e=0){const{target:s,base:i,k0:o,k1:r,cellWorld:a,tileRepeats:l,normals:h}=n,c=s.vertices,u=s.geometry.uvs,f=r-o,d=e&&t.scaleX?e/t.scaleX:0;for(let p=0,x=i.length/2;p<x;p+=1){const M=i[p*2],S=i[p*2+1],b=M-t.x,A=S-t.y,g=Math.sqrt(b*b+A*A)||1e-6,L=p%4<2,C=L?r+d/g:o;if(c[p*2]=M+b*C,c[p*2+1]=S+A*C,!L){const z=p>>2,P=(h[z*2+1]!==0?Math.abs(A):Math.abs(b))*f/a/l;u[p*2+1]=P>1?1:P}}s.vertices=c,s.geometry.uvs=u}function Gs(n,t){const{target:e,normals:s,centers:i,facing:o}=n,r=o.length;let a=!1;for(let c=0;c<r;c+=1){const f=s[c*2]*(t.x-i[c*2])+s[c*2+1]*(t.y-i[c*2+1])>0?1:0;o[c]!==f&&(o[c]=f,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 f=0;f<6;f+=1)l[h]=u*4+je[f],h+=1;return e.geometry.indices=l,!0}function $s({runs:n,texture:t,step:e,shear:s,baseScale:i,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 n){const f=u.axis===0,d=f?u.col1-u.col0:u.row1-u.row0,p=Math.max(1,d*c),x=f?u.col0:u.row0,M=typeof u.rail0=="number"&&typeof u.rail1=="number"?{first:(u.rail0-x)*c,last:(u.rail1-x)*c}:null,S=u.col0*e,b=u.col1*e,A=u.row0*e,g=u.row1*e,L=p+1,C=Math.min(u.from,u.to),z=Math.max(u.from,u.to),D=C*s,P=new Float32Array(L*4),F=new Float32Array(L*4),V=new Float32Array(L*4),j=new Float32Array(L*2),R=new Uint32Array(p*6),J=1;for(let Q=0;Q<L;Q+=1){const et=Q/p,it=u.sign>0?et:1-et,dt=(u.from+(u.to-u.from)*it)*s,_=f?S:A,y=_+((f?b:g)-_)*et,w=f?y:S,k=f?A:y,Y=f?y:b,T=f?g:y,I=Q*4;P[I]=w*i.x,P[I+1]=k*i.y,P[I+2]=Y*i.x,P[I+3]=T*i.y,F[I]=w/l,F[I+1]=k/h,F[I+2]=Y/l,F[I+3]=T/h;const Z=f?k+J:w+J,N=f?T-J:Y-J,H=Math.min(Math.max(y,(f?S:A)+J),(f?b:g)-J);V[I]=(f?H:Z)/l,V[I+1]=(f?Z:H)/h,V[I+2]=(f?H:N)/l,V[I+3]=(f?N:H)/h,j[Q*2]=dt,j[Q*2+1]=dt}for(let Q=0;Q<p;Q+=1){const et=Q*2,it=Q*6;R[it]=et,R[it+1]=et+1,R[it+2]=et+3,R[it+3]=et,R[it+4]=et+3,R[it+5]=et+2}const xt=ue({texture:t,vertices:P.slice(),uvs:F,indices:R});a.push(qs({base:P,uvs:V,heights:j,points:L,texture:t,kBase:D,sideTint:r,endIndex:u.sign>0?L-1:0,rails:M})),a.push({target:xt,k:z*s,base:P,heights:j})}return a}function qs(n){const{base:t,uvs:e,heights:s,points:i,texture:o,kBase:r,endIndex:a,sideTint:l,rails:h}=n,c=h?Math.max(0,Math.min(h.first,i-1)):0,u=h?Math.max(c,Math.min(h.last,i-1)):-1,f=h?u-c+1:0,d=f*2+2,p=new Float32Array(d*4),x=new Float32Array(d*4),M=new Float32Array(d*2),S=Math.max(0,f-1)*2+1,b=new Uint32Array(S*6),A=C=>C<f?(c+C)*2:C<f*2?(c+C-f)*2+1:a*2+(C-f*2);for(let C=0;C<d;C+=1){const z=A(C),D=C*4,P=t[z*2],F=t[z*2+1];p[D]=P,p[D+1]=F,p[D+2]=P,p[D+3]=F,x[D]=e[z*2],x[D+1]=e[z*2+1],x[D+2]=e[z*2],x[D+3]=e[z*2+1],M[C*2]=s[z],M[C*2+1]=r}let g=0;for(let C=0;C<3;C+=1){const z=C===2?f*2:C*f,D=C===2?f*2+1:z+f-1;for(let P=z;P<D;P+=1){const F=P*2,V=g*6;b[V]=F,b[V+1]=F+1,b[V+2]=F+3,b[V+3]=F,b[V+4]=F+3,b[V+5]=F+2,g+=1}}const L=ue({texture:o,vertices:p.slice(),uvs:x,indices:b});return L.tint=l,{target:L,k:r,base:p,heights:M}}function Ks(n,t){const{target:e,base:s,heights:i}=n,o=e.vertices;for(let r=0,a=i.length;r<a;r+=1){const l=s[r*2],h=s[r*2+1],c=i[r];o[r*2]=l+(l-t.x)*c,o[r*2+1]=h+(h-t.y)*c}e.vertices=o}const Zs=5,It={mapSprite:null,occluder:null,slices:[],rampTexture:null,wallTextures:[]};function js({mapSprite:n,bakedTexture:t,occluder:e,slices:s,rampTexture:i,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}),i&&i.destroy(!0);for(const r of o??[])r.destroy(!0);n&&(n.parent?.removeChild(n),n.destroy({texture:!1,textureSource:!1})),t?.destroy(!0)}async function Js(n){try{const t=await n.baseTexture;if(n.isAborted())return It;const e=await ce({baseTexture:t,spriteSheetData:n.spriteSheetData,map:n.map,tiles:n.tiles,step:n.step,renderer:n.renderer,exclude:n.exclude});if(n.isAborted())return e.destroy(!0),It;const s=new $(e);if(n.layerRoot.addChildAt(s,0),!n.extruding)return{...It,mapSprite:s};const i=await Qs(n,t,e),o={mapSprite:s,...i};return n.isAborted()?(js({...o,bakedTexture:e}),It):o}catch(t){return console.error(`Failed to create static map with asset ${n.assetUrl}:`,t),It}}async function Qs(n,t,e){const s=B.shear,i=[],o=[];let r=null,a=null;if(n.volume>0){r=new O,r.zIndex=X(Math.max(n.layer,Zs),n.level);{const h=await ti(n,t,o);if(n.isAborted())return{occluder:r,slices:i,rampTexture:a,wallTextures:o};i.push(...Us({map:n.map,tiles:n.tiles,step:n.step,baseScale:n.baseScale,level:n.level,volume:n.volume,shear:s,sideTint:vt.sideTint,textures:h,tileRepeats:vt.faceTileRepeats}));const c=new $(e);c.tint=16777215,i.push({target:c,k:(n.level+n.volume)*s,occluder:!0})}}const l=ei(n);if(l.length){if(a=await ce({baseTexture:t,spriteSheetData:n.spriteSheetData,map:n.map,tiles:n.ramps.map(h=>h.tile),step:n.step,renderer:n.renderer}),n.isAborted())return{occluder:r,slices:i,rampTexture:a,wallTextures:o};i.push(...$s({runs:l,texture:a,step:n.step,shear:s,baseScale:n.baseScale,segments:vt.rampSegments,sideTint:vt.sideTint}))}if(n.isAborted())return{occluder:r,slices:i,rampTexture:a,wallTextures:o};i.sort((h,c)=>h.k-c.k);for(const h of i)h.base||ot(h.target,null,h.k,n.baseScale),(h.occluder?r:n.container).addChild(h.target);return{occluder:r,slices:i,rampTexture:a,wallTextures:o}}async function ti(n,t,e){const s=new Map,i=Math.max(1,Math.round(vt.faceTileRepeats)||1);for(const o of n.tiles){const r=await ce({baseTexture:t,spriteSheetData:n.spriteSheetData,map:Array.from({length:i},()=>[o]),tiles:[o],step:n.step,renderer:n.renderer});e.push(r),s.set(o,r)}return s}function ei(n){if(!n.ramps?.length||!n.rampRuns)return[];const t=new Set(n.ramps.map(i=>`${i.from}:${i.to}`)),e=n.rampRuns.forLevel(n.level).filter(i=>t.has(`${i.from}:${i.to}`));return Ys(e,(i,o)=>Is(i,o===0?n.baseScale.x:n.baseScale.y,n.step))}function si(n,t){if(!n.levelView)return;const e=n.levelView.cfg,s=K.shared.lastTime,i=n.hole.tick===s;n.hole.tick=s;const o=K.shared.deltaMS/1e3,r=i?0:Math.min(1,e.fadeRate*o);n.hasSprite&&ii(n,e,r,t),n.occluder&&ni(n,e,r,t)}function ii(n,t,e,s){const{levelView:i,container:o}=n,r=n.roof?i.level<n.level&&ri(n,t,s):null;if(i.mode==="layer"){const h=(n.roof?r:i.level<n.level&&Ge(n.grid,i.x,i.y,n.floorSet))?t.layerAlpha:1;o.alpha+=(h-o.alpha)*e;return}const a=n.roof?r:i.level<n.level;le(n.hole,a,e),he(o,n.hole,t,i,n.stage,s)}function ni(n,t,e,s){const{levelView:i,occluder:o}=n,r=n.level>i.level;if(i.mode==="layer"){const l=r?t.layerAlpha:1;o.alpha+=(l-o.alpha)*e;return}const a=r||oi(n,s);le(n.occluderHole,a,e),he(o,n.occluderHole,t,i,n.stage,s)}function Je(n,t){const e=n.levelView;return rt(e.x,e.y,t,e.z*B.shear)}function ri(n,t,e){return e?qe(n.grid,n.tileSet,Je(n,e),e,[n.level*B.shear],t.roofMargin??0):!1}function oi(n,t){if(!t||!n.grid.map)return!1;const e=B.shear,s=vt.slices,i=[];for(let o=1;o<=s;o+=1)i.push((n.level+n.volume*o/s)*e);return qe(n.grid,n.tileSet,Je(n,t),t,i,0)}const ai=40,li=45;function hi(n){let t=2166136261;for(let e=0;e<n.length;e+=1)t^=n.charCodeAt(e),t=Math.imul(t,16777619)>>>0;return t>>>0}function ci(n){const t=n?.map?.length||0,e=n?.map?.[0]?.length||0,s=hi(JSON.stringify(n?.game?.lighting??null));return`${e}x${t}:${s.toString(16)}`}function ui(n,t,e,s){const{x:i,y:o}=$t(s);return{x:(n+.5)*e*i,y:(t+.5)*e*o}}function ge(n,t){const e=new Set(t||[]),s=[];if(!n||e.size===0)return s;for(let i=0;i<n.length;i+=1){const o=n[i]||[];for(let r=0;r<o.length;r+=1)e.has(o[r])&&s.push([r,i])}return s}function ye(n){const t=new Map;for(const[s,i]of n)t.has(i)||t.set(i,new Set),t.get(i).add(s);const e=[];for(const s of[...t.keys()].sort((i,o)=>i-o)){const i=[...t.get(s)].sort((a,l)=>a-l);let o=i[0],r=i[0];for(let a=1;a<=i.length;a+=1){const l=i[a];l===r+1||(e.push({col:o,row:s,length:r-o+1}),o=l),r=l}}return e}function xe(n,t,e,s,i,o){const r=e*o,a=rt(n,t,s,r);return{x:a.x,y:a.y,scale:1+r,screenX:a.x*i.scale.x+i.position.x,screenY:a.y*i.scale.y+i.position.y}}function _i(n,t,e){return!e&&Math.abs(t-Math.round(t))>.001?[Math.floor(t),Math.ceil(t)]:[Nt(n,t)]}function di(n,t,e,s,i){return n+e>=0&&n-e<=s&&t+e>=0&&t-e<=i}function we(n,t,e){if(!e)return 1;const s=t/1e3,i=Math.sin(s*7.3+n*12.9898)*.5+Math.sin(s*13.1+n*78.233)*.3+Math.sin(s*23.7+n*3.7)*.2;return 1-e*((i+1)/2)}function fi(n,t){if(!(t>0)||n>=t)return 0;const e=1-Math.max(0,n)/t;return e*e}function pi(n=K.shared){let t=null,e=0;return{now(){const s=n.lastTime;return s!==t&&(t!==null&&(e+=Math.max(0,s-t)/1e3),t=s),e}}}const mi=pi();function gi(n,t){return Math.floor(n*t)/t}function yi(n){return new Set(Object.keys(n||{}).map(Number))}function xi(n,t,e=1){if(n.speed!==void 0){const s=n.frames?.length||0,i=t*(typeof e=="number"?e:e.x);return i>0?n.speed*s/i:0}return n.fps||0}function Qe(n,t,e){return!(e>0)||!(t>0)?0:Math.floor(n*t)%e}function wi(n,t,e){const s=new O,i=[];if(s.label="animatedTiles",!e)return{container:s,groups:i};const o=new Set(n.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:xi(a,n.step,n.scale),textures:h,sprites:[],container:new O,frame:0};c.container.label=`animatedTile-${l}`;for(let u=0;u<n.map.length;u+=1){const f=n.map[u];for(let d=0;d<f.length;d+=1){if(f[d]!==l)continue;const p=new $(h[0]);p.x=d*n.step,p.y=u*n.step,p.cullable=!0,c.sprites.push(p),c.container.addChild(p)}}if(c.sprites.length===0){c.container.destroy();continue}s.addChild(c.container),i.push(c)}return{container:s,groups:i}}function vi(n,t,e=()=>!0){for(let s=0;s<n.length;s+=1){const i=n[s];if(!e(i.container))continue;const o=Qe(t,i.fps,i.textures.length);if(o===i.frame)continue;i.frame=o;const r=i.textures[o];for(let a=0;a<i.sprites.length;a+=1)i.sprites[a].texture=r}}function Si(n){n.container.parent?.removeChild(n.container),n.container.destroy({children:!0,texture:!1,textureSource:!1}),n.groups.length=0}function ve(n,t,e){return(n||[]).filter(s=>(s.level||0)===t&&Number(s.layer)===e)}function bi(n,t,e,s){const i=[];for(const o of n){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 $(h[0]);c.anchor.set(.5),c.position.set((r+.5)*e,(a+.5)*e),s.addChild(c),i.push({item:o,sprite:c,textures:h,frame:0})}return i}function Mi(n,t){for(let e=0;e<n.length;e+=1){const s=n[e];if(s.item.kind==="rotate"){s.sprite.rotation=(s.item.rps||0)*2*Math.PI*t;continue}if(s.item.kind==="frames"){const i=Qe(t,s.item.fps,s.textures.length);i!==s.frame&&(s.frame=i,s.sprite.texture=s.textures[i])}}}function Ti(n){for(const t of n)t.sprite.parent?.removeChild(t.sprite),t.sprite.destroy({texture:!1,textureSource:!1});n.length=0}const ki=.8,jt=.6,Se=.09,Ai=.12,Li=.55;function ts(n){let t=n+2654435769>>>0;return t=Math.imul(t^t>>>16,2246822507)>>>0,t=Math.imul(t^t>>>13,3266489909)>>>0,(t^t>>>16)>>>0}function Ci(n,t,e=0){return ts((Math.imul(n,73856093)^Math.imul(t,19349663)^Math.imul(e,83492791))>>>0)}function be(n,t,e){return ts((n^Math.imul(t+e,668265261))>>>0)/4294967296}const Et=n=>Math.min(1,Math.max(0,n));function Ii(n,t,e){if(!(e>0))return!1;const s=Math.floor(n/jt);if(be(t,s,0)>=e)return!1;const i=s*jt+be(t,s,1)*(jt-Se);return n>=i&&n<i+Se}function Ei(n,t,e){const s=Et(e?.pulse||0),i=t%1e3/1e3,o=1-s*(.5+.5*Math.sin(2*Math.PI*(ki*n+i)));return Ii(n,t,e?.dropouts||0)?{core:Et(o*Ai),glow:Et(o*Li)}:{core:Et(o),glow:Et(o)}}const zi=4;function at(n){return Math.ceil(n*zi)}const re=new WeakMap;function es({text:n,size:t}){return`${t}|${n}`}function Pi(n){return Math.max(2,Math.round(n/4))}function Ri(n,{text:t,size:e}){const s=Pi(e),i=at(s),o=new O,r=new Ue({text:String(t),style:{fontFamily:"monospace",fontWeight:"bold",fontSize:e,fill:16777215}});r.position.set(i,i),o.addChild(r);const a=new G(0,0,Math.ceil(r.width)+i*2,Math.ceil(r.height)+i*2),l=n.generateTexture({target:o,frame:a}),h=new yt({strength:s,quality:6});h.padding=i,r.filters=[h];const c=n.generateTexture({target:o,frame:a});return r.filters=[],h.destroy(),o.destroy({children:!0}),{core:l,glow:c}}function Di(n,t){let e=re.get(n);e||(e=new Map,re.set(n,e));const s=es(t);let i=e.get(s);return i||(i={...Ri(n,t),count:0},e.set(s,i)),i.count+=1,{core:i.core,glow:i.glow}}function Fi(n,t){const e=re.get(n),s=es(t),i=e?.get(s);i&&(i.count-=1,!(i.count>0)&&(e.delete(s),i.core.destroy(!0),i.glow.destroy(!0)))}class Vi{constructor({sign:t,renderer:e,lighting:s,animated:i,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=Ci(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=Di(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),i.addChild(this.glow,this.core))}_sprite(t){const e=new $(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,i=null){const o=t===null?{core:1,glow:1}:Ei(t,this._seed,this._sign.flicker);if(!this.emissive){this.glow.alpha=o.glow,this.core.alpha=o.core;return}const r=this._level*B.shear,a=rt(this._worldX,this._worldY,e,r);let l=1;i!==null?l=i: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,()=>Fi(t,e)}}function Oi(n,t,e,s){const i=yi(n?.animatedTiles),o=new Set(t);return{exclude:[...i],hasTiles:[...i].some(r=>o.has(r)),signs:ve(n?.signs,e,s),decals:ve(n?.decals,e,s)}}function Me(n){return n.hasTiles||n.signs.length>0||n.decals.length>0}async function Xi({spec:n,game:t,baseTexture:e,spriteSheetData:s,map:i,tiles:o,step:r,scale:a,level:l,animated:h,renderer:c,lighting:u,isAborted:f}){let d=null;if((n.hasTiles||n.decals.length>0)&&(d=await Ze(e,s),f()))return d.destroy(),null;const p={sheet:d,tiles:null,decals:[],signs:[],tick:null};return n.hasTiles&&(p.tiles=wi({map:i,tiles:o,step:r,scale:a},d,t.animatedTiles),h.addChild(p.tiles.container)),d&&(p.decals=bi(n.decals,d,r,h)),p.signs=n.signs.map(x=>new Vi({sign:x,renderer:c,lighting:u,animated:h,step:r,scale:a,level:l})),p}function Yi(n){return n?t=>{const e=t.getBounds();return e.maxX>=0&&e.minX<=n.width&&e.maxY>=0&&e.minY<=n.height}:()=>!0}function Bi(n,{camera:t,levelView:e,screen:s,roofAlpha:i=null}){const o=gi(mi.now(),Ls.maxFps),r=K.shared.lastTime;n.tick!==r&&(n.tick=r,n.tiles&&vi(n.tiles.groups,o,Yi(s)),Mi(n.decals,o));for(let a=0;a<n.signs.length;a+=1)n.signs[a].update(o,t,e,i)}function Ni(n){if(!n)return()=>{};n.tiles&&(Si(n.tiles),n.tiles=null),Ti(n.decals);const t=n.signs.map(s=>s.destroy()),e=n.sheet;return n.signs=[],n.sheet=null,()=>{t.forEach(s=>s()),e?.destroy()}}class Hi{constructor(t,e,s,i,o={}){this._container=t,this._renderer=s.renderer,this._levelView=s.levelView||null,this._rampRuns=s.rampRuns||null,this._hole=ie(),this._occluderHole=ie(),this._occluder=null,this._baseScale=$t(e.scale),this._slices=[],this._rampTexture=null,this._wallTextures=[],this.mapSprite=null,this._assetUrl=`${i}${e.spriteSheet.img}`,this._baseTexturePromise=ee.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=Ui(e.game,this._level,this._tiles),this._spriteSheetData=e.spriteSheet,this._step=e.step,this._layer=Number(e.layer)||1,t.zIndex=X(this._layer,this._level),this._parallaxK=this._level*B.shear,this._layerRoot=new O,this._layerRoot.label="layerRoot",this._animated=new O,this._animated.label="animated",this._layerRoot.addChild(this._animated),ot(this._layerRoot,null,this._parallaxK,this._baseScale),t.addChild(this._layerRoot),this._animationSpec=Oi(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=Es(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}),this._mapKey=ci(e),this._lighting.acquireMap(this._mapKey,e.game?.lighting,this._step,e.scale),this._level>=1&&this._lighting.setLevelMask(this._level,ge(this._map,this._roof?this._tiles:this._floor),this,{roof:this._roof}),this._volume>0&&this._lighting.setVolumeTops(this._level,ge(this._map,this._tiles),this._volume,this)),this.needsRender=this._level>=1||this._extruding||!!this._lighting?.isNight()||Me(this._animationSpec),this._build(e)}async _build(t){const e=await Js({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||!Me(this._animationSpec))&&(this._animations=await Xi({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,volume:this._volume,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():lt(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;Bi(this._animations,{camera:t,levelView:this._levelView,screen:this._renderer?.screen,roofAlpha:e})}if((this._level>=1||this._occluder)&&si(this._seeThroughView(),t),!(!this._parallaxK&&!this._slices.length)&&t){ot(this._layerRoot,t,this._parallaxK,this._baseScale);for(let e=0;e<this._slices.length;e+=1){const s=this._slices[e];s.walls?(Ws(s,t,vt.faceBleedPx),Gs(s,t)):s.base?Ks(s,t):ot(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=Ni(this._animations);if(this._animations=null,this._lighting&&(this._lighting.releaseMap(this._mapKey,this),this._lighting=null),ne(this._hole,t),this._occluder){const a=this._occluder;this._occluder=null,a.filters=[],ne(this._occluderHole,a),a.parent?.removeChild(a),a.destroy({children:!0,texture:!1,textureSource:!1})}const s=this.mapSprite,i=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=We.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(),i&&i.destroy(!0);for(const a of o)a.destroy(!0);s&&s.destroy({children:!0,texture:!0,textureSource:!0})}}}function Ui(n,t,e){const s=n?.roofs?.[t]??n?.roofs?.[String(t)];if(!Array.isArray(s)||s.length===0||!e?.length)return!1;const i=new Set(s),o=e.filter(r=>i.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 tt=(n,t,e)=>n+(t-n)*e,Ft=(n,t,e)=>Math.min(e,Math.max(t,n)),Wi=n=>n*(Math.PI/180),Gi=n=>{for(;n>Math.PI;)n-=Math.PI*2;for(;n<-Math.PI;)n+=Math.PI*2;return n},E=(n,t)=>Math.random()*(t-n)+n;class Lt extends O{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),K.shared.add(this._tickListener),this._onEffectStart(),this.isComplete||this._update(0))}_onEffectStart(){}_update(){}_completeEffect(){this.isComplete||(this.isComplete=!0,this._tickListener&&(K.shared.remove(this._tickListener),this._tickListener=null),typeof this.onComplete=="function"&&this.onComplete())}destroy(t){this.isComplete=!0,this._tickListener&&(K.shared.remove(this._tickListener),this._tickListener=null),this.parent&&this.parent.removeChild(this),super.destroy({texture:!1,textureSource:!1,...t,children:!0})}}class $i extends Lt{constructor(t,e,s,i,o){super(i),this.x=t,this.y=e,this._textures=o.textures,this._contentSize=o.contentSize,this.config={particleCount:Math.round(E(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 i=Math.random()*Math.PI*2,o=E(e.minInitialSpeed,e.maxInitialSpeed),r=this._textures[Math.floor(Math.random()*this._textures.length)],a=new $(r),l=E(0,t);a.anchor.set(.5),a.tint=e.color[Math.floor(Math.random()*e.color.length)],a.scale.set(E(e.particleMinSize,e.particleMaxSize)/this._contentSize),this.particlesData.push({sprite:a,x:Math.cos(i)*l,y:Math.sin(i)*l,vx:Math.cos(i)*o,vy:Math.sin(i)*o,rotation:Math.random()*Math.PI*2,spin:E(-e.maxSpin,e.maxSpin),lifetime:E(e.minLifetime,e.maxLifetime),age:0}),this.addChild(a)}}_update(t){if(this.isComplete)return;const{config:e}=this,s=t/1e3,i=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*=i,r.vy*=i,r.spin*=i,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:tt(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 ct=0,ut=1,mt=2,Te=3,Ht=4,Ut=5,gt=6,_t=7,qt=8,Wt=9,At=11,nt=12,Gt=13,ke=14,Ae=15,qi=0,Ki=1,Zi=2,ji=3,Ji=4,Qi=5,tn=6,en=7,sn=8,nn=9,Le=10,Ce=0,Ie=1,Ee=2,rn=3,on=4,an=6,ln=0,hn=1,cn=2,un=3,ze=0,Pe=1,Re=2,_n=3,dn=4,fn=5,De=0,pn=1,Xt=2,mn=1,gn=2,yn=1.4;class xn{constructor(t,e,s,i,o={}){this._container=t,this._renderer=s.renderer,this._soundManager=s.soundManager||null,this._assets=o||{},this._levelView=s.levelView||null,this._baseScale=$t(e.scale),t.scale=e.scale,this._assetUrl=`${i}${e.img}`,this._baseTexturePromise=ee.load(this._assetUrl),this._damagedUrl=e.game?.imgDamaged?`${i}${e.game.imgDamaged}`:null,this._destroyedUrl=e.game?.imgDestroyed?`${i}${e.game.imgDestroyed}`:null,this._z=e.level||0,this._level=e.level||0,this._layer=Number(e.layer)||2,t.zIndex=X(this._layer,this._level),this._rotation=Wi(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 $(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!==De&&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;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)&&ot(t,this._levelView.camera()??lt(t.parent,this._renderer),this._z*B.shear,this._baseScale)}update(t){this.sprite&&(this.sprite.x=t[ze]/this._baseScale.x,this.sprite.y=t[Pe]/this._baseScale.y,this.sprite.rotation=t[Re]),this._worldX=t[ze],this._worldY=t[Pe],this._rotation=t[Re],this._z=t[_n]||0;const e=Nt(t[dn],this._z);e!==this._level&&(this._level=e,this._container.zIndex=X(this._drawLayer(),e),!e&&!this._z&&ot(this._container,null,0,this._baseScale));const s=t[fn]||De;if(s!==this._state){const i=this._state===null;this._state=s,this._showState(s),s===Xt&&!i&&this._burst()}this._placeScorch()}_drawLayer(){return this._state===Xt?mn:this._layer}_showState(t){if(this._container.zIndex=X(this._drawLayer(),this._level),!this.sprite)return;if(t===Xt&&!this._destroyedUrl){this.sprite.visible=!1,this._showScorch();return}this._scorch&&(this._scorch.visible=!1),this.sprite.visible=!0;let e=null;t===pn?e=this._damagedUrl:t===Xt&&(e=this._destroyedUrl),this._setTexture(e?ee.load(e):this._baseTexturePromise,t,e??this._assetUrl)}async _setTexture(t,e,s){try{const i=await t;if(this._container.destroyed||!this.sprite||this._state!==e)return;this.sprite.texture=i,this.sprite.width=this._width,this.sprite.height=this._height}catch(i){console.error(`Failed to load map object state asset ${s}:`,i)}}_showScorch(){const t=this._assets.scorchTexture;if(t){if(!this._scorch){const{textures:e,contentSize:s}=t,i=new $(e[Math.floor(Math.random()*e.length)]);i.anchor.set(.5),i.rotation=Math.random()*Math.PI*2,i.scale.set(Math.max(this._width,this._height)*yn/s),this._scorch=i,this._container.addChild(i)}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,i=this._height/2;return{x:this._worldX/this._baseScale.x+t*s-e*i,y:this._worldY/this._baseScale.y+e*s+t*i}}_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 i=this._container.parent,o=this._assets.debrisTexture;if(!i||!o)return;const r=Math.max(this._width*this._baseScale.x,this._height*this._baseScale.y),a=new $i(e,s,r,()=>{this._effects.delete(a),a.destroy()},o);a.zIndex=X(gn,this._level),i.addChild(a),this._effects.add(a),a.run()}destroy(){for(const t of this._effects)t.destroy();this._effects.clear(),this.sprite=null,this._scorch=null,this._baseTexturePromise=null,this._assetUrl=null,this._renderer=null,this._levelView=null,this._soundManager=null}}let wn=class extends O{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 i=`${s.assetsBase}img/`;this._mode=t.type==="dynamic"?new xn(this,t,s,i,e):new Hi(this,t,s,i,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 Fe=[16777215,9418751,10477760,15783820,14721232,10541296,15773836,12632280],ss=n=>Fe[n]??Fe[0],vn=2,Sn=.35;class bn extends O{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=X(vn,this._level),this.scale=t.scale,this._draws=this._tiles.some(i=>this._solid.includes(i)),this.radarGraphics=new W,this.addChild(this.radarGraphics),this._levelView=s.levelView||null,this._levelView&&this._draws&&(this.onRender=()=>{this.alpha=this._levelView.level===this._level?1:Sn}),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 i=0;i<s.length;i+=1){const o=s[i];this._solid.includes(o)&&t.rect(i*this._step,e*this._step,this._step/2,this._step/2)}}t.fill(ss(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 Ve=2,Mn=9,Tn=1.5;class kn extends O{constructor(t,e){super(),this._level=t[nt]||0,this.zIndex=X(Ve,this._level),this._textures=e.tankRadarTexture,this.body=new $,this.body.anchor.set(.5),this.levelRing=new W,this.addChild(this.levelRing,this.body),this._drawLevelRing(),this.x=t[ct]||0,this.y=t[ut]||0,this._condition=t[_t],this._teamId=t[Wt],this.scale.set(5,5),this.create()}_drawLevelRing(){this.levelRing.clear(),this._level>0&&this.levelRing.circle(0,0,Mn).stroke({width:Tn,color:ss(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[ct],this.y=t[ut];const e=t[nt]||0;e!==this._level&&(this._level=e,this.zIndex=X(Ve,e),this._drawLevelRing());const s=t[_t],i=t[Wt];let o=!1;s!==void 0&&s!==this._condition&&(this._condition=s,o=!0),i!==void 0&&i!==this._teamId&&(this._teamId=i,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 An({width:n,height:t,anchorX:e,anchorY:s,rotation:i,pitch:o,roll:r,shear:a,lift:l}){const h=-e*n,c=(1-e)*n,u=-s*t,f=(1-s)*t,d=[[h,u],[c,u],[c,f],[h,f]],p=Math.cos(i),x=Math.sin(i),M=Math.cos(o),S=Math.sin(o),b=Math.cos(r),A=Math.sin(r),g=[];for(const[L,C]of d){const z=L*p-C*x,D=L*x+C*p,P=D*M,F=-D*S,V=z*b,j=z*A,R=F+j,J=t?R/t*a:0;g.push(V*(1+J),P*(1+J)-R*l)}return g}function Ln({angle:n,pitch:t,roll:e,lightDir:s,shading:i}){if(!s)return 1;const o=Math.cos(n),r=Math.sin(n),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)*i}function Cn(n,t){const e=s=>{const i=Math.round((n>>s&255)*t);return Math.min(255,Math.max(0,i))};return e(16)<<16|e(8)<<8|e(0)}function is(n,t,{minImpact:e,fullImpact:s}){return!(n<-e)||t!==0?0:Math.min(1,-n/s)}const In=0,En=1,Jt=3,zn=7,Pn=1,Oe=1.15,Rn=1.25,Dn=.6,Fn=1,Vn=.015,On=2.5;function Xn(n,t=0){const e=Number.isFinite(n)?n:0,s=Ft(e,0,1),i=Math.max(0,e-1),o=tt(Pn,Oe,s)+(Rn-Oe)*i,r=tt(Dn,Fn,s),a=1+Vn*(1-s)*Math.sin(2*Math.PI*On*(t/1e3));return{rate:o*a,volumeFactor:r}}class Yn extends O{constructor(t,e,s,i){super();const o=()=>{const c=new fs({verticesX:Ct.vertices,verticesY:Ct.vertices});return c.geometry.batchMode="batch",c};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._textures=e.tankTexture,this._shadowAsset=e.tankShadowTexture||null,this._renderer=s.renderer||null,this._shadow=null,this._worldX=t[ct]||0,this._worldY=t[ut]||0,this.x=this._worldX,this.y=this._worldY,this.rotation=t[mt]||0,this._gunRotation=t[Te]||0,this._engineLoad=t[gt]||0,this._condition=t[_t],this._size=t[qt],this._teamId=t[Wt],this._z=t[At]||0,this._physLevel=t[nt]||0,this._vz=t[Gt]||0,this._prevVz=this._vz,this._pitch=t[ke]||0,this._roll=t[Ae]||0,this._landImpact=0,this._landTimer=0,this._squash=0,this._level=Nt(t[nt],this._z),this.zIndex=X(Jt,this._level),this._isLocal=()=>s.localPlayer?.is(i?.id)===!0,this._levelView=s.levelView||null,this._lighting=s.lighting?.enabled?s.lighting:null,this._headlights=null,this._glares=[],this._glareLevel=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.create()}_initSounds(){this._soundId||this._condition===0||!this._hasEngineSound||(this._soundId=this._soundManager.registerSound("tankEngine",this._getSoundData()))}_getSoundData(){const{rate:t,volumeFactor:e}=Xn(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.wreck.texture=this._textures.destroyed,this.wreck.visible=!0,this._gunRotation=0,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.body.texture=t.body,this.gun.texture=t.gun,this.body.visible=!0,this.gun.visible=!0,this._initSounds(),this._addLights()}this._applyTilt()}update(t){this._worldX=t[ct],this._worldY=t[ut],this.rotation=t[mt],this._gunRotation=t[Te],this._engineLoad=t[gt]||0,this._z=t[At]||0,this._physLevel=t[nt]||0,this._vz=t[Gt]||0,this._pitch=t[ke]||0,this._roll=t[Ae]||0;const e=is(this._prevVz,this._vz,Rt);e>0&&(this._landImpact=e,this._landTimer=Rt.duration),this._prevVz=this._vz;const s=Nt(t[nt],this._z);s!==this._level&&(this._level=s,this.zIndex=X(Jt,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 i=t[_t],o=t[Wt];let r=!1;i!==void 0&&i!==this._condition&&(this._condition=i,r=!0),o!==void 0&&o!==this._teamId&&(this._teamId=o,r=!0),r&&this.create(),this._updateLights()}_headlightPoints(){const t=Math.cos(this.rotation),e=Math.sin(this.rotation),s=this._size*2,i=this._size*1.5*Tt.headlights.offset,o=this._worldX+t*s,r=this._worldY+e*s;return[{x:o+e*i,y:r-t*i},{x:o-e*i,y:r+t*i}]}_addLights(){if(!this._lighting||this._headlights)return;const{headlights:t,tankGlow:e}=Tt,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._createGlares(),this._updateLights()}_createGlares(){const t=this._lighting.texture("head");if(!t||this._glares.length>0)return;const{headlights:e}=Tt;this._glareScale=e.glareSize*2/t.contentSize;for(let s=0;s<2;s+=1){const i=new $(t.texture);if(i.anchor.set(.5),i.blendMode="add",i.tint=e.color,!this._lighting.addEmissive(i,this._level)){i.destroy({texture:!1,textureSource:!1}),this._destroyGlares();return}this._glares.push(i)}this._glareLevel=this._level}_destroyGlares(){for(const t of this._glares)this._lighting?.removeEmissive(t),t.destroy({texture:!1,textureSource:!1});this._glares=[],this._glareLevel=null}_updateLights(){if(!this._headlights)return;const t=this._level,e=this._z,s=_i(this._physLevel,e,this._vz!==0),i=this._headlightPoints();for(let o=0;o<2;o+=1)this._lighting.updateLight(this._headlights.cones[o],{x:i[o].x,y:i[o].y,z:e,level:t,levels:s,rotation:this.rotation});if(this._lighting.updateLight(this._headlights.glow,{x:this._worldX,y:this._worldY,z:e,level:t,levels:s}),this._glares.length>0&&this._glareLevel!==t){for(const o of this._glares)if(this._lighting.removeEmissive(o),!this._lighting.addEmissive(o,t)){this._destroyGlares();return}this._glareLevel=t}}_updateGlares(t){if(this._glares.length===0)return;const e=this._z*B.shear,s=this._headlightPoints();for(let i=0;i<this._glares.length;i+=1){const o=rt(s[i].x,s[i].y,t,e);this._glares[i].position.set(o.x,o.y),this._glares[i].scale.set(this._glareScale*(1+e))}}_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),this._destroyGlares()}_setCorners(t,e,s,i,o){const{texture:r}=t;t.setCorners(...An({width:r.width*i,height:r.height*i*o,anchorX:e.x,anchorY:e.y,rotation:s,pitch:this._pitch,roll:this._roll,shear:B.shear,lift:Ct.lift}))}_groundZ(){return this._vz!==0?this._physLevel:this._z}_applyTilt(){const t=1+this._z*B.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():lt(this.parent,this._renderer);this._lighting&&(this._lighting.attachStage(this.parent,this._renderer),this._lighting.render(),this._updateGlares(t));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);const s=rt(this._worldX,this._worldY,t,this._z*B.shear);this.position.set(s.x,s.y);{const i=Ft(Ln({angle:this.rotation,pitch:this._pitch,roll:this._roll,lightDir:Ct.lightDir,shading:Ct.shading}),In,En);this.tint=Cn(e,i)}if(this._landTimer>0){this._landTimer=Math.max(0,this._landTimer-K.shared.deltaMS);const i=this._landTimer/Rt.duration;this._squash=Math.sin(i*Math.PI)*Rt.squash*this._landImpact}else this._squash=0;this._applyTilt(),this._updateShadow(t)}_updateShadow(t){if(!this._shadowAsset||!this.parent)return;if(!(this._condition!==0&&this._vz!==0)){this._shadow&&(this._shadow.visible=!1);return}if(!this._shadow){const{texture:a,contentSize:l}=this._shadowAsset;this._shadow=new $(a),this._shadow.anchor.set(.5),this._shadowScale=this._size*4*Ot.sizeFactor/l,this.parent.addChild(this._shadow)}const s=this._shadow;s.visible=!0;const i=this._groundZ(),o=rt(this._worldX,this._worldY,t,i*B.shear);s.x=o.x,s.y=o.y,s.rotation=this.rotation;const r=Math.max(0,this._z-i);s.scale.set(this._shadowScale*(1+r*Ot.scaleGain)),s.alpha=Math.max(0,Ot.baseAlpha-r*Ot.alphaFalloff)*this.alpha,s.zIndex=X(Jt-1,Math.min(zn,Math.floor(i)))}destroySounds(){this._soundId&&(this._soundManager.unregisterSound(this._soundId),this._soundId=null)}destroy(t){this.destroySounds(),this._removeLights(),this._shadow&&(this._shadow.destroy({texture:!1,textureSource:!1}),this._shadow=null),super.destroy({children:!0,texture:!1,textureSource:!1,...t})}}const Bn=2;class Nn extends O{constructor(t,e,s){super(),this._level=t[an]||0,this.zIndex=X(Bn,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 $(e.bombTexture),this.body.anchor.set(.5),this._worldX=t[Ce],this._worldY=t[Ie],this.x=this._worldX,this.y=this._worldY,this.rotation=t[Ee],this._size=t[rn],this._totalDurationMs=t[on],this._soundManager=s.soundManager,this._soundId=null;const i=e.bombTexture.width,o=this._size/i;this.body.scale.set(o);const r=64,a=this._size/1.2/r;this.text=new Ue({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),K.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[Ce],this._worldY=t[Ie],this.x=this._worldX,this.y=this._worldY,this.rotation=t[Ee],this._soundId&&(this._soundManager.updateSoundData(this._soundId,{position:{x:this._worldX,y:this._worldY}})||(this._soundId=null))}_applyHeight(){const t=this._level*B.shear,e=lt(this.parent,this._renderer),s=rt(this._worldX,this._worldY,e,t);this.position.set(s.x,s.y),this.scale.set(1+t)}_stopTimer(){this._tickListener&&(K.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 Hn extends Lt{constructor(t,e,s,i,o){super(i);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 $(r),this._mainBody.anchor.set(.5),this._mainBody.tint=11393254,this._mainBody.scale.set(this._baseScale),this._core=new $(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=i=>i*i;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 Qt=[],ft={get(n){if(Qt.length>0){const t=Qt.pop();return t.texture=n,t.alpha=1,t.scaleX=1,t.scaleY=1,t.rotation=0,t.tint=16777215,t.anchorX=.5,t.anchorY=.5,t}return new ps({texture:n,anchorX:.5,anchorY:.5})},release(n){n&&Qt.push(n)}},oe=50,Un=400,Wn=800;class Gn extends Lt{constructor(t,e=oe){super();const s=e/oe;this._blastScale=s;const{texture:i,contentSize:o}=t.explosionTexture;this.explosionTexture=i,this._unitScale=1/o;const r=Un*s,a=Wn*s;this._particleContainer=new ae({texture:this.explosionTexture,boundsArea:new G(-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=ft.get(this.explosionTexture),e=.2+Math.random()*.4,s=Math.floor(e*255);t.tint=s<<16|s<<8|s;const i=(this._minStartSize+Math.random()*(this._maxStartSize-this._minStartSize))*this._unitScale,o=.6+Math.random()*.8,r=.6+Math.random()*.8;t.scaleX=i*o,t.scaleY=i*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:i};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],i=s.view;if(s.life+=t,s.life>=s.maxLife)this._particleContainer.removeParticle(i),ft.release(i),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;i.x+=(s.vx+r)*(t/16),i.y+=s.vy*(t/16),i.rotation+=s.rotationSpeed*(t/16);const a=1-Math.pow(1-o,3),l=s.startScale+(s.targetScale-s.startScale)*a;if(i.scaleX=l*s.aspectRatioX,i.scaleY=l*s.aspectRatioY,o<.1)i.alpha=o/.1*this._startAlpha;else if(o>.4){const h=(o-.4)/.6;i.alpha=this._startAlpha*(1-h)}else i.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)ft.release(this._particles[e].view);this._particles=[],super.destroy(t)}}const $n=.168,qn=.225,Xe=.15,Kn=2e4,Zn=50,jn=4e3,Jn=4e3;class Qn extends Lt{constructor(t,e,s,i,o){super(i),this._assets=o,this._radius=s,this.x=t,this.y=e,this._funnelDurationMs=Kn,this._funnelFadeInDurationMs=Zn,this._funnelFadeDurationMs=jn,this._elapsedMs=0,this._smokeDurationMs=Jn,this._smokeSpawningStopped=!1,this._funnel=this._createFunnelSprite(),this._smoke=new Gn(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)],i=new $(s);i.anchor.set(.5),i.alpha=0,i.rotation=Math.random()*Math.PI*2;const o=this._radius*$n*E(1-Xe,1+Xe);return i.scale.set(o/e),i}_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,i=e/this._funnelFadeDurationMs;this._funnel.alpha=qn*Ft(Math.min(s,i),0,1),e<=0&&this._completeEffect()}destroy(t){this._smoke&&(this._smoke.destroy(),this._smoke=null),this._funnel=null,super.destroy(t)}}const tr=4,er=2;class sr extends O{constructor(t,e,s){super(),this.originX=t[ln],this.originY=t[hn],this.radius=t[cn]??oe,this._level=t[un]||0,this._assets=e,this._soundManager=s.soundManager,this._levelView=s.levelView||null,this._renderer=s.renderer||null,this._lighting=s.lighting||null,(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*B.shear,e=lt(this.parent,this._renderer),s=rt(this.originX,this.originY,e,t);for(const i of[this.explosion,this.funnel])i&&(i.position.set(s.x,s.y),i.scale.set(1+t))}run(){if(!(this._isDestroyed||this._isStarted)){if(this._isStarted=!0,!this.parent){this.destroy();return}this._lighting?.flash({...Tt.flash.explosion,level:this._level,x:this.originX,y:this.originY,z:this._level}),this.explosion=new Hn(this.originX,this.originY,this.radius,this._onExplosionComplete.bind(this),this._assets),this.explosion.zIndex=X(tr,this._level),this.funnel=new Qn(this.originX,this.originY,this.radius,this._onFunnelComplete.bind(this),this._assets),this.funnel.zIndex=X(er,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 Ye=4,St=400,ir=0,nr=0,rr=8,q={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 or extends O{constructor(t,e,s={}){super(),this._level=t[nt]||0,this.zIndex=X(Ye,this._level);const{texture:i,contentSize:o}=e.smokeTexture;this._smokeTexture=i,this._textureScale=rr/o,this._emitterX=t[ct],this._emitterY=t[ut],this._emitterRotation=t[mt],this._emitterVX=t[Ht],this._emitterVY=t[Ut],this._engineLoad=t[gt],this._condition=t[_t],this._z=t[At]||0,this._size=t[qt],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)),ot(this,lt(this.parent,this._renderer),this._z*B.shear,1)}),this._particleContainer=new ae({texture:this._smokeTexture,boundsArea:new G(this._emitterX-St,this._emitterY-St,St*2,St*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),K.shared.add(this._tickListener)}update(t){const e=this._condition,s=t[nt]||0;s!==this._level&&(this._level=s,this.zIndex=X(Ye,s)),this._emitterX=t[ct],this._emitterY=t[ut],this._emitterRotation=t[mt],this._emitterVX=t[Ht],this._emitterVY=t[Ut],this._engineLoad=t[gt],this._condition=t[_t],this._z=t[At]||0,this._particleContainer.boundsArea.x=this._emitterX-St,this._particleContainer.boundsArea.y=this._emitterY-St,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=q.burstParticleCount,s=Math.ceil(e/t);for(let i=0;i<s;i+=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 i=q.particleSpawnRate[this._condition]||0,o=i>0?1e3/i:1/0;if(s>0&&i>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>=q.exhaust.minLoad?tt(q.exhaust.idleSpawnRate,q.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(q.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),ft.release(u.view),this._particles.splice(c,1);continue}u.vx=u.vx+(ir-u.vx)*h,u.vy=u.vy+(nr-u.vy)*h,u.x+=u.vx*e,u.y+=u.vy*e;const f=u.age/u.lifetime,d=1-(1-f)*(1-f),p=tt(u.startSizeFactor,u.endSizeFactor,d),x=tt(u.startAlpha,u.endAlpha,f),M=p*this._particleScaleMultiplier*this._textureScale,S=u.view;S.x=u.x,S.y=u.y,S.scaleX=M,S.scaleY=M,S.alpha=x,S.rotation+=u.rotSpeed*e}}spawnParticle(t,e,s="damage"){const i=s==="burst",o=s==="exhaust",r=q.exhaust,a=o?E(r.lifetime.min,r.lifetime.max):E(q.particleLifetime.min,q.particleLifetime.max);let l=o?r.startSizeFactor:q.particleStartSizeFactor[this._condition]||.3,h=o?r.endSizeFactor:q.particleEndSizeFactor[this._condition]||1,c=o?r.startAlpha:q.particleStartAlpha,u=1;i&&(l*=2,h*=2.5,c=.8,u=2);const f=this._emitterRotation,d=f+Math.PI,p=Math.cos(d),x=Math.sin(d),M=f+Math.PI/2,S=Math.cos(M),b=Math.sin(M);let A=0;const g=this._width/2*q.streamOffsetFactor;e===2?A=t===0?-g:g:e===3&&(A=(t-1)*g);const L=this._height*.22,C=this._emitterX+p*L+S*A,z=this._emitterY+x*L+b*A;let D=E(q.particleInitialVelocity.away.min,q.particleInitialVelocity.away.max),P=E(q.particleInitialVelocity.side.min,q.particleInitialVelocity.side.max);D*=u,P*=u;let F=p*D+S*P,V=x*D+b*P;const j=q.particleVelocityVariance;F+=E(-j,j),V+=E(-j,j),F+=this._emitterVX,V+=this._emitterVY;const R=ft.get(this._smokeTexture);R.tint=o?r.color:q.particleColor,R.x=C,R.y=z,R.alpha=c;const J=l*this._particleScaleMultiplier*this._textureScale;R.scaleX=J,R.scaleY=J,R.rotation=E(0,Math.PI*2);const xt={view:R,x:C,y:z,vx:F,vy:V,age:0,lifetime:a,startSizeFactor:l,endSizeFactor:h,startAlpha:c,endAlpha:q.particleEndAlpha,rotSpeed:E(-1,1)};this._particleContainer.addParticle(R),this._particles.push(xt)}_stopTimer(){this._tickListener&&(K.shared.remove(this._tickListener),this._tickListener=null)}destroy(t){this._stopTimer();for(let e=0;e<this._particles.length;e+=1)ft.release(this._particles[e].view);this._particles=[],super.destroy({texture:!1,textureSource:!1,...t,children:!0})}}class ar extends ${constructor(t,e,s,i,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=i,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 te=1;class lr extends O{constructor(t,e,s={}){super(),this._levelView=s.levelView||null,this._renderer=s.renderer||null,this._surfaces=s.surfaces||null,this._level=t[nt]||0,this._markLayers=new Map,this.zIndex=X(te,this._level),this._currentX=t[ct]||0,this._currentY=t[ut]||0,this._currentRotation=t[mt]||0,this._engineLoad=t[gt]||0,this._condition=t[_t],this._size=t[qt],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 i=this._size*3;this._trackOffset=i/2*.7,this._backwardOffset=i*.4,this._trackInitialAlpha=.4,this._tickListener=o=>this._internalUpdate(o.deltaMS),K.shared.add(this._tickListener),this._levelView&&(this.onRender=()=>this._updateLayers())}update(t){this._currentX=t[ct],this._currentY=t[ut],this._currentRotation=t[mt],this._engineLoad=t[gt],this._condition=t[_t];const e=t[nt]||0;e!==this._level&&(this._level=e,this.zIndex=X(te,e))}_markLayer(t){let e=this._markLayers.get(t);if(e)return e;e=new O,e.zIndex=X(te,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 d of this._markLayers.values())for(let p=d.children.length-1;p>=0;p-=1){const x=d.children[p];x.update(t)&&x.destroy()}const e=this._currentX-this._prevX,s=this._currentY-this._prevY,i=Math.sqrt(e*e+s*s),o=Gi(this._currentRotation-this._prevRotation),r=Math.abs(o),a=i-this._prevSpeed,l=Math.abs(a),h=r-this._prevAngularSpeed,c=Math.abs(h),u=performance.now();let f=!1;this._condition!==0&&u-this._lastTrackMarkTime>this._trackMarkCooldown&&(l>this._minAbsAccelerationForMark&&(f=!0),i>this._minSpeedForRotationMarks&&(r>this._minAngularSpeedForMark||c>this._minRotationAccelerationForMark)&&(f=!0)),this._engineLoad>1&&(f=!0),f&&(this.createTrackMarksAtPreviousPosition(),this._lastTrackMarkTime=u),this._prevX=this._currentX,this._prevY=this._currentY,this._prevRotation=this._currentRotation,this._prevSpeed=i,this._prevAngularSpeed=r}createTrackMarksAtPreviousPosition(){const t=this._surfaces?this._surfaces.kindAt(this._prevX,this._prevY,this._level):null;if(t&&wt.tracks.noMarks.includes(t))return;const e=t&&wt.tracks[t]||null,s=this._markLayer(this._level);for(let i=-1;i<=1;i+=2){const o=Math.cos(this._prevRotation+Math.PI/2)*this._trackOffset*i,r=Math.sin(this._prevRotation+Math.PI/2)*this._trackOffset*i,a=-Math.cos(this._prevRotation)*this._backwardOffset,l=-Math.sin(this._prevRotation)*this._backwardOffset,h=this._prevX+o+a,c=this._prevY+r+l,u=new ar(h,c,this._prevRotation,this._trackWidth,this._trackLength,Math.min(1,this._trackInitialAlpha*(e?e.alpha:1)),this._assets.trackMarkTexture,e?e.lifetime:1);e&&(u.tint=e.tint),s.addChild(u)}}_updateLayers(){if(!this._markLayers.size)return;const t=lt(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&&ot(s,t,e*B.shear)}_stopTimer(){this._tickListener&&(K.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 Be=2,bt=300,hr=6,U={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},cr={color:U.color,alpha:U.startAlpha,lifetime:U.lifetime},ur=["sand","mud","water"],Ne=.35,_r=(n,t)=>n.kind==="boost"&&n.dir!==null&&n.dir[0]===t[0]&&n.dir[1]===t[1];class dr extends O{constructor(t,e,s={}){super(),this._level=t[nt]||0,this.zIndex=X(Be,this._level);const{texture:i,contentSize:o}=e.dustTexture;this._dustTexture=i,this._textureScale=hr/o,this._x=t[ct],this._y=t[ut],this._rotation=t[mt],this._vx=t[Ht]||0,this._vy=t[Ut]||0,this._engineLoad=t[gt]||0,this._condition=t[_t],this._z=t[At]||0,this._vz=t[Gt]||0,this._prevVz=this._vz,this._size=t[qt];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)),ot(this,lt(this.parent,this._renderer),this._z*B.shear,1)}),this._particleContainer=new ae({texture:this._dustTexture,boundsArea:new G(this._x-bt,this._y-bt,bt*2,bt*2),dynamicProperties:{position:!0,vertex:!0,rotation:!0,color:!0}}),this.addChild(this._particleContainer),this._tickListener=l=>this._updateParticles(l.deltaMS),K.shared.add(this._tickListener)}update(t){const e=this._x,s=this._y,i=this._condition>0,o=t[nt]||0;o!==this._level&&(this._level=o,this.zIndex=X(Be,o)),this._x=t[ct],this._y=t[ut],this._rotation=t[mt],this._vx=t[Ht]||0,this._vy=t[Ut]||0,this._engineLoad=t[gt]||0,this._condition=t[_t],this._z=t[At]||0,this._vz=t[Gt]||0,this._particleContainer.boundsArea.x=this._x-bt,this._particleContainer.boundsArea.y=this._y-bt;const r=is(this._prevVz,this._vz,Rt);r>0&&(this._triggerLandingBurst(r),this._playLandingSound(r)),this._prevVz=this._vz,this._updateSurface(e,s,i)}_updateSurface(t,e,s){if(!this._surfaces)return;const i=this._surfaces.kindAt(this._x,this._y,this._level),o=i==="boost"?this._surfaces.dirAt(this._x,this._y,this._level):null,r=this._surfaceCell,a=Math.hypot(this._x-t,this._y-e)>wt.boost.resetDistance,l=!s&&this._condition>0;this._surfaceKind=i,this._surfaceCell={kind:i,dir:o},!(r===null||l||a||this._condition<=0||this._vz!==0)&&(i==="water"&&r.kind!=="water"&&this._triggerWaterEntry(),o&&!_r(r,o)&&this._vx*o[0]+this._vy*o[1]>=wt.boost.boostMinSpeed&&this._triggerBoostFlash(o))}_triggerWaterEntry(){const t=wt.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 i=0;i<t.entryBurst;i+=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=wt.boost,s=Math.atan2(-t[1],-t[0]);for(let i=0;i<e.burst;i+=1){const o=s+E(-Ne,Ne),r=E(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,i=this._rotation+Math.PI,o=E(e.sideSpeed.min,e.sideSpeed.max)*t,r=E(0,e.sideSpeed.min);return[Math.cos(s)*o+Math.cos(i)*r,Math.sin(s)*o+Math.sin(i)*r]}_spawnSurfaceDust(t,e){for(let s=-1;s<=1;s+=2){const i=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=E(U.spinVelocity.back.min,U.spinVelocity.back.max),c=E(U.spinVelocity.side.min,U.spinVelocity.side.max);o=Math.cos(a)*h+Math.cos(l)*c,r=Math.sin(a)*h+Math.sin(l)*c}this._spawnParticle(i.x,i.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(U.landingBurst*t);if(!(e<=0))for(let s=-1;s<=1;s+=2){const i=this._contactPoint(s);for(let o=0;o<e;o+=1){const r=E(0,Math.PI*2),a=E(U.landingVelocity.min,U.landingVelocity.max)*t;this._spawnParticle(i.x,i.y,Math.cos(r)*a,Math.sin(r)*a,U.landingSizeFactor*t)}}}_spawnSpinDust(){const t=this._rotation+Math.PI,e=this._rotation+Math.PI/2;for(let s=-1;s<=1;s+=2){const i=this._contactPoint(s),o=E(U.spinVelocity.back.min,U.spinVelocity.back.max),r=E(U.spinVelocity.side.min,U.spinVelocity.side.max);this._spawnParticle(i.x,i.y,Math.cos(t)*o+Math.cos(e)*r,Math.sin(t)*o+Math.sin(e)*r,1)}}_spawnParticle(t,e,s,i,o,r=cr){const a=U.startSizeFactor*o,l=U.endSizeFactor*o,h=ft.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=E(0,Math.PI*2),this._particles.push({view:h,x:t,y:e,vx:s,vy:i,age:0,lifetime:E(r.lifetime.min,r.lifetime.max),startAlpha:r.alpha,startSizeFactor:a,endSizeFactor:l,rotSpeed:E(-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),i=Math.hypot(this._vx,this._vy),r=this._condition>0&&s>0&&i<U.maxSpinSpeed&&this._surfaceKind!=="oil"?U.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,i);const a=Math.pow(U.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),ft.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),f=(h.startSizeFactor+(h.endSizeFactor-h.startSizeFactor)*u)*this._particleScaleMultiplier*this._textureScale,d=h.view;d.x=h.x,d.y=h.y,d.scaleX=f,d.scaleY=f,d.alpha=h.startAlpha+(U.endAlpha-h.startAlpha)*c,d.rotation+=h.rotSpeed*e}}_emitSurface(t,e){const s=this._surfaceKind,i=ur.includes(s)?wt[s]:null;if(!i||this._condition<=0||this._vz!==0||e<i.minSpeed){this._timeSinceSurfaceSpawn=0;return}const o=1e3/(i.rate*Math.min(e/i.fullSpeed,1));for(this._timeSinceSurfaceSpawn+=t;this._timeSinceSurfaceSpawn>=o;)this._spawnSurfaceDust(s,i),this._timeSinceSurfaceSpawn-=o}_stopTimer(){this._tickListener&&(K.shared.remove(this._tickListener),this._tickListener=null)}destroy(t){this._stopTimer();for(let e=0;e<this._particles.length;e+=1)ft.release(this._particles[e].view);this._particles=[],super.destroy({texture:!1,textureSource:!1,...t,children:!0})}}class fr extends Lt{constructor(t,e,s,i,o){super(o),this.startPositionX=t,this.startPositionY=e,this.endPositionX=s,this.endPositionY=i,this.config={color:16777113,alphaStart:1,alphaEnd:.6,trailLength:55,tracerSpeed:19e3,minDuration:45,maxDuration:80,trailShrinkPower:1,trailStartOffset:30,segmentCount:12,segmentRadius:1,alphaPulseFrequency:.1,alphaPulseAmplitude:.15},this.graphics=new W,this.addChild(this.graphics),this.elapsedTime=0,this.dx=this.endPositionX-this.startPositionX,this.dy=this.endPositionY-this.startPositionY,this.totalDist=Math.hypot(this.dx,this.dy),this.totalDist>.001?(this.nx=this.dx/this.totalDist,this.ny=this.dy/this.totalDist,this.animationDuration=this.totalDist/this.config.tracerSpeed*1e3):(this.nx=0,this.ny=0,this.totalDist=0,this.animationDuration=this.config.minDuration),this.animationDuration=Math.max(this.config.minDuration,this.animationDuration),this.animationDuration=Math.min(this.config.maxDuration,this.animationDuration),this.animationDuration<=0&&(this.animationDuration=this.config.minDuration)}_drawSegment(t,e,s,i,o){this.graphics.circle(t,e,s),this.graphics.fill({color:i,alpha:Ft(o,0,1)})}_update(t){if(this.isComplete)return;this.elapsedTime+=t,this.graphics.clear();const e=Math.min(this.elapsedTime/this.animationDuration,1);if(e>0){const s=tt(this.startPositionX,this.endPositionX,e),i=tt(this.startPositionY,this.endPositionY,e),o=tt(this.config.alphaStart,this.config.alphaEnd,e),r=Math.sin(this.elapsedTime*this.config.alphaPulseFrequency)*this.config.alphaPulseAmplitude;let a=o+r;a=Ft(a,0,this.config.alphaStart);const l=Math.pow(e,this.config.trailShrinkPower),h=tt(this.config.trailLength,0,l),c=this.totalDist*e;if(c>=this.config.trailStartOffset){let u=c;this.totalDist>.001&&(u=Math.max(0,c-this.config.trailStartOffset));const f=Math.min(u,h);let d,p;this.totalDist>.001?(d=s-this.nx*f,p=i-this.ny*f):(d=s,p=i);const x=Math.hypot(s-d,i-p);if(x<this.config.segmentRadius*.5&&this.totalDist===0)this._drawSegment(s,i,this.config.segmentRadius,this.config.color,a);else if(x>=this.config.segmentRadius*.5){const M=Math.max(1,this.config.segmentCount);for(let S=0;S<M;S++){let b=.5;M>1&&(b=S/(M-1));const A=tt(d,s,b),g=tt(p,i,b),L=tt(1,.8,b);this._drawSegment(A,g,this.config.segmentRadius,this.config.color,a*L)}}}}this.elapsedTime>=this.animationDuration&&(this.graphics.clear(),this._completeEffect())}destroy(t){this.graphics&&this.graphics.clear(),super.destroy(t)}}class pr extends Lt{constructor(t,e,s,i,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:E(2,4),particleMinSize:.8,particleMaxSize:2.4,minInitialSpeed:10,maxInitialSpeed:300,minLifetime:8e3,maxLifetime:15e3,color:[3355443,2236962,4473924],fadeOutStart:.8,impactDirectionX:s,impactDirectionY:i,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 i=0,o=this.config.particleCount;i<o;i+=1){let r;this.useOmnidirectionalSpread?r=Math.random()*Math.PI*2:r=t+E(-s,s);const a=E(this.config.minInitialSpeed,this.config.maxInitialSpeed),l=new $(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:E(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:E(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 i=0,o=this.particlesData.length;i<o;i+=1){const r=this.particlesData[i];if(!r.active)continue;if(s+=1,r.age+=t,r.isMoving){const c=Math.hypot(r.vx,r.vy);if(c>0){const f=c*this.config.dragCoefficient*e,d=Math.max(0,1-f/c);r.vx*=d,r.vy*=d}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=tt(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?tt(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)}}const mr=2;class gr extends O{constructor(t,e,s){super(),this.startPositionX=t[qi],this.startPositionY=t[Ki],this.endPositionX=t[Zi],this.endPositionY=t[ji],this.soundPositionX=t[Ji],this.soundPositionY=t[Qi],this.hit=t[tn],this.endLevel=t[nn]||0,this.startLevel=t[sn]||0,this.zIndex=X(mr,this.endLevel),this.anchorKey=null,this.anchorLocalX=0,this.anchorLocalY=0,Array.isArray(t[Le])&&([this.anchorKey,this.anchorLocalX,this.anchorLocalY]=t[Le]),this._assets=e,this._soundManager=s.soundManager,this._isLocalShot=s.localPlayer?.is(t[en])===!0,this._mapDynamics=s.mapDynamics||null,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)),ot(this,lt(this.parent,this._renderer),this.endLevel*B.shear,1)}),this.tracer=null,this.impact=null,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(){this._isDestroyed||(this._lighting?.flash({...Tt.flash.shot,level:this.startLevel,x:this.startPositionX,y:this.startPositionY,z:this.startLevel}),this.tracer=new fr(this.startPositionX,this.startPositionY,this.endPositionX,this.endPositionY,this._onTracerComplete.bind(this)),this.addChild(this.tracer),this.tracer.run())}_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,i=e-this.startPositionY,o=Math.hypot(s,i);let r=0,a=0;o>.001&&(r=-(s/o),a=-(i/o)),this.impact=new pr(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.destroy()}destroy(){this._isDestroyed||(this._isDestroyed=!0,this._soundId&&(this._soundManager.unregisterSound(this._soundId),this._soundId=null),this.tracer&&(this.tracer.destroy(),this.tracer=null),this.impact&&(this.impact.destroy(),this.impact=null),this.parent&&this.parent.removeChild(this),super.destroy({children:!0}))}}const yr={Map:wn,MapRadar:bn,TankRadar:kn,Tank:Yn,Bomb:Nn,ExplosionEffect:sr,Smoke:or,Tracks:lr,Dust:dr,ShotEffect:gr};function Yt(n,t){const{radius:e,blur:s,color:i,quality:o=40}=n,r=new W,a=(e+at(s))*2,l=a/2;r.circle(l,l,e),r.fill(i);const h=new yt({strength:s,quality:o});h.padding=at(s),r.filters=[h];const c=t.generateTexture({target:r,frame:new G(0,0,a,a)});return r.destroy(!0),{texture:c,contentSize:e*2}}function xr(n,t){const{baseRadius:e,irregularity:s=0,blur:i=0,numPoints:o=20,colorFill:r,colorRim:a=r,rimWidth:l=0,variants:h=1}=n,c=Math.max(1,Math.floor(h)||1),u=(e+s+l)*2,f=u+at(i)*2,d=f/2,p=[];for(let x=0;x<c;x+=1){const M=new W,S=[];for(let A=0;A<o;A+=1){const g=A/o*Math.PI*2,L=e+E(-s,s);S.push(d+L*Math.cos(g),d+L*Math.sin(g))}M.poly(S).fill(r).stroke({width:l,color:a,alignment:1});const b=new yt({strength:i,quality:10});b.padding=at(i),M.filters=[b],p.push(t.generateTexture({target:M,frame:new G(0,0,f,f)})),M.destroy(!0)}return{textures:p,contentSize:u}}function wr(n,t){const{colors:e}=n,s={},i=10,o=i*4,r=i*3,a=15658734,l=c=>{const u=new W,f=new W,d=o,p=r;u.rect(-d/2,-p/2,d,p).fill(5592405).rect(-d/2+1,-p/2+1,d-2,p-2).fill(10066329).rect(-d/2+2,-p/2+2,d-4,p-4).fill(13421772).rect(-d/2+3,-p/2+3,d-6,p-6).fill(a),f.moveTo(1.33*i,-.42*i).lineTo(.42*i,-1*i).lineTo(-.42*i,-1*i).lineTo(-1.33*i,-.42*i).lineTo(-1.33*i,.42*i).lineTo(-.42*i,1*i).lineTo(.42*i,1*i).lineTo(1.33*i,.42*i).closePath().fill(c).stroke({width:.17*i,color:11184810}).moveTo(2.33*i,-.25*i).lineTo(.25*i,-.25*i).lineTo(.25*i,.25*i).lineTo(2.33*i,.25*i).closePath().stroke({width:.17*i,color:11184810}).fill(c);const x=u.getBounds(),M=t.generateTexture({target:u,frame:new G(x.x,x.y,x.width,x.height)}),S=f.getBounds(),b=t.generateTexture({target:f,frame:new G(S.x,S.y,S.width,S.height)}),A={x:-S.x/S.width,y:-S.y/S.height};return u.destroy(!0),f.destroy(!0),{body:M,gun:b,gunAnchor:A}},h=()=>{const c=new O,u=new W,f=new W;c.addChild(u,f);const d=3815994,p=2434341,x=3158064,M=1579032,S=5263440,b=o,A=r,g=i;u.moveTo(-b/2-g*.1,-A/2+g*.2).lineTo(b/2+g*.2,-A/2-g*.1).lineTo(b/2-g*.1,A/2+g*.3).lineTo(-b/2+g*.3,A/2-g*.2).closePath().fill(d).stroke({width:g*.2,color:S,alignment:.5}),u.moveTo(-b/2+g*.4,-A/2+g*.5).lineTo(b/2-g*.3,-A/2+g*.2).lineTo(b/2-g*.4,A/2-g*.1).lineTo(-b/2+g*.2,A/2-g*.4).closePath().fill(p),u.circle(b*.15,A*.1,g*1.2).fill(M),u.circle(-b*.3,-A*.25,g*.5).fill(M),f.position.set(g*.3,-g*.2);const L=[g*1.1,-g*.7,g*.2,-g*1,-g*.6,-g*.9,-g*1.3,-g*.2,-g*1.1,g*.6,-g*.2,g*1,g*.7,g*.8,g*1.3,g*.1];f.poly(L).fill(x).stroke({width:g*.15,color:S,alignment:0});const C=[g*.8,-g*.25,g*1.5,-g*.4,g*1.4,g*.15,g*.7,g*.05];f.poly(C).fill(x).stroke({width:g*.1,color:S,alignment:0}),f.circle(g*.1,-g*.2,g*.4).fill(M);const z=c.getBounds(),D=t.generateTexture({target:c,frame:new G(z.x,z.y,z.width,z.height)});return c.destroy({children:!0}),D};return s.liveTeamId1=l(e.teamId1),s.liveTeamId2=l(e.teamId2),s.destroyed=h(),s}function vr(n,t){const{radius:e,borderWidth:s,crossSize:i,crossThickness:o,colors:r}=n,a={},l=(e+s)*2,h=l/2,c=15658734,u=3355443,f=p=>{const x=new W;x.circle(h,h,e).fill(c),x.circle(h,h,e-s).fill(p);const M=t.generateTexture({target:x,frame:new G(0,0,l,l)});return x.destroy(!0),M},d=()=>{const p=new W,x=i/2;p.moveTo(h-x,h-x).lineTo(h+x,h+x).moveTo(h-x,h+x).lineTo(h+x,h-x).stroke({width:o,color:u});const M=t.generateTexture({target:p,frame:new G(0,0,l,l)});return p.destroy(!0),M};return a.liveTeamId1=f(r.teamId1),a.liveTeamId2=f(r.teamId2),a.destroyed=d(),a}function Sr(n,t){const{colorOuter:e,colorInner:s}=n,i=new W,o=20,r=1;i.rect(0,0,o,o).fill(e),i.rect(r,r,o-r*2,o-r*2).fill(s);const a=t.generateTexture({target:i,frame:new G(0,0,o,o)});return i.destroy(!0),a}function br(n,t){const{width:e,length:s,color:i}=n,o=new W;o.rect(0,0,s,e).fill(i);const r=t.generateTexture({target:o,frame:new G(0,0,s,e)});return o.destroy(!0),r}function Mr(n,t){const{width:e,height:s,radius:i,blur:o,color:r,quality:a=20}=n,l=new W,h=at(o),c=e+h*2,u=s+h*2;l.roundRect(h,h,e,s,i),l.fill(r);const f=new yt({strength:o,quality:a});f.padding=h,l.filters=[f];const d=t.generateTexture({target:l,frame:new G(0,0,c,u)});return l.destroy(!0),{texture:d,contentSize:e}}function Tr(n,t){const{baseRadius:e,irregularity:s=0,blur:i=0,numPoints:o=16,color:r,coreColor:a=r,coreRatio:l=.5,variants:h=1}=n,c=Math.max(1,Math.floor(h)||1),u=(e+s)*2,f=u+at(i)*2,d=f/2,p=[],x=(M,S)=>{const b=[];for(let A=0;A<o;A+=1){const g=A/o*Math.PI*2,L=M+E(-S,S);b.push(d+L*Math.cos(g),d+L*Math.sin(g))}return b};for(let M=0;M<c;M+=1){const S=new W;S.poly(x(e,s)).fill(r).poly(x(e*l,s*l)).fill(a);const b=new yt({strength:i,quality:10});b.padding=at(i),S.filters=[b],p.push(t.generateTexture({target:S,frame:new G(0,0,f,f)})),S.destroy(!0)}return{textures:p,contentSize:u}}function kr(n,t){const{length:e,width:s,color:i,variants:o=1}=n,r=Math.max(1,Math.floor(o)||1),a=e/2,l=[];for(let h=0;h<r;h+=1){const c=new W,u=E(s*.3,s)/2,f=E(s*.1,s*.6)/2;c.poly([0,a-f,e,a-u,e,a+u,0,a+f]).fill(i),l.push(t.generateTexture({target:c,frame:new G(0,0,e,e)})),c.destroy(!0)}return{textures:l,contentSize:e}}function ns(n,t,e,s,i){for(let o=0;o<s;o+=1){const r=e*o/s,a=e*(o+1)/s,l=i((o+.5)/s);l<=0||(n.circle(t,t,a),n.fill({color:16777215,alpha:l}),r>0&&(n.circle(t,t,r),n.cut()))}}function Ar(n,t){const{radius:e,rings:s=32,blur:i=2,quality:o=10}=n,r=new W,a=at(i),l=(e+a)*2,h=l/2;ns(r,h,e,s,f=>(1-f)*(1-f));const c=new yt({strength:i,quality:o});c.padding=a,r.filters=[c];const u=t.generateTexture({target:r,frame:new G(0,0,l,l)});return r.destroy(!0),{texture:u,contentSize:e*2}}function Lr(n,t){const{length:e,halfWidth:s,strips:i=24,blur:o=4,quality:r=10}=n,a=new W,l=at(o),h=e+l*2,c=(s+l)*2,u=l,f=c/2;for(let x=0;x<i;x+=1){const M=e*x/i,S=e*(x+1)/i,b=s*x/i,A=s*(x+1)/i,g=(x+.5)/i,L=(1-g)*(1-g*.35);a.poly([u+M,f-b,u+S,f-A,u+S,f+A,u+M,f+b]),a.fill({color:16777215,alpha:L})}const d=new yt({strength:o,quality:r});d.padding=l,a.filters=[d];const p=t.generateTexture({target:a,frame:new G(0,0,h,c)});return a.destroy(!0),{texture:p,length:e,halfWidth:s,margin:l}}function Cr(n,t){const{core:e,halo:s,rings:i=12,blur:o=1,quality:r=10}=n,a=new W,l=at(o),h=(s+l)*2,c=h/2,u=e/s;ns(a,c,s,i,p=>p<=u?1:.6*(1-(p-u)/(1-u))**2);const f=new yt({strength:o,quality:r});f.padding=l,a.filters=[f];const d=t.generateTexture({target:a,frame:new G(0,0,h,h)});return a.destroy(!0),{texture:d,contentSize:s*2}}const Ir={explosionTexture:Yt,smokeTexture:Yt,impactParticleTexture:Yt,dustTexture:Yt,tankShadowTexture:Mr,funnelTexture:xr,tankTexture:wr,tankRadarTexture:vr,bombTexture:Sr,trackMarkTexture:br,scorchTexture:Tr,debrisTexture:kr,lightRadialTexture:Ar,headlightConeTexture:Lr,lampHeadTexture:Cr},Er=n=>(n??"").split(/[?#]/)[0].endsWith(".js"),zr=n=>import(n);function Pr(n=As,t={}){const e={level:0,x:0,y:0,z:0,camera:null,key:null,stage:t.stage||null,renderer:t.renderer||null},s=()=>{if(!e.stage)return null;const{position:i,scale:o}=e.stage,r=e.renderer?.screen,a=r?r.width:0,l=r?r.height:0,h=e.key;return(e.camera===null||h===null||h.x!==i.x||h.y!==i.y||h.scaleX!==o.x||h.scaleY!==o.y||h.width!==a||h.height!==l)&&(e.key={x:i.x,y:i.y,scaleX:o.x,scaleY:o.y,width:a,height:l},e.camera=lt(e.stage,e.renderer)),e.camera};return{attachStage(i,o){e.stage||!i||!o||(e.stage=i,e.renderer=o,e.key=null)},camera(){return s()},set(i,o,r,a=0){e.level=i,e.x=o,e.y=r,e.z=a},alphaFor(i,o,r,a=i){const l=s(),h=rt(e.x,e.y,l,e.z*B.shear),c=rt(o,r,l,a*B.shear);return Rs({viewLevel:e.level,viewX:h.x,viewY:h.y,level:i,x:c.x,y:c.y,cfg:n})},tintFor(i){return Ds(e.level,i,n)},get cfg(){return n},get mode(){return n.mode},get level(){return e.level},get x(){return e.x},get y(){return e.y},get z(){return e.z}}}const Rr=16777215;class He{constructor({level:t,ambient:e,resolution:s,roof:i=!1}){this.level=t,this.ambient=e,this.roof=i,this.overlay=new O,this.overlay.label=i?`lighting-roof-${t}`:`lighting-${t}`,this.overlay.zIndex=X(ai,t),this.overlay.eventMode="none",this.overlay.boundsArea=new G(0,0,1,1),this.base=new $(We.WHITE),this.base.tint=t===0?e:Rr,this.overlay.addChild(this.base),this.world=new O,this.overlay.addChild(this.world),this.mask=t>=1?new W:null,this.mask&&this.world.addChild(this.mask),this.lights=new O,this.world.addChild(this.lights),this.tops=new O,this.world.addChild(this.tops),this.topGroups=[],this.pool=[],this.filter=new ms({alpha:1}),this.filter.resolution=s,this.filter.blendMode="multiply",this.overlay.filters=[this.filter],this.resolution=s,this.hole=ie(),this.hasMask=!1}setMask(t,e,s){if(this.mask){this.mask.clear(),this.hasMask=t.length>0;for(const i of t)this.mask.rect(i.col*e*s.x,i.row*e*s.y,i.length*e*s.x,e*s.y);this.hasMask&&this.mask.fill(this.ambient)}}setTops(t,e,s){for(const i of this.topGroups)i.graphics.destroy();this.topGroups=[];for(const{volume:i,runs:o}of t){if(!o.length)continue;const r=new W;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:i})}}place(t,e,s,i){const{scale:o,position:r}=t;this.overlay.scale.set(1/o.x,1/o.y),this.overlay.position.set(-r.x/o.x,-r.y/o.y),this.overlay.boundsArea.width=e.width,this.overlay.boundsArea.height=e.height,this.base.width=e.width,this.base.height=e.height,this.world.scale.set(o.x,o.y),this.world.position.set(r.x,r.y),this.mask&&ot(this.mask,s,this.level*i,1);for(const{graphics:a,volume:l}of this.topGroups)ot(a,s,(this.level+l)*i,1)}layout(t){for(;this.pool.length<t.length;){const e=new $;e.blendMode="add",this.pool.push(e),this.lights.addChild(e)}for(let e=0;e<this.pool.length;e+=1){const s=this.pool[e],i=t[e];if(!i){s.visible=!1;continue}s.visible=!0,s.texture=i.texture,s.anchor.set(i.anchorX,i.anchorY),s.position.set(i.x,i.y),s.scale.set(i.scaleX,i.scaleY),s.rotation=i.rotation,s.tint=i.color,s.alpha=i.alpha}}destroy(){const t=this.overlay;t.parent?.removeChild(t),ne(this.hole,t),t.filters=[],this.filter.destroy();for(const e of this.pool)e.texture=null;this.pool=[],this.topGroups=[],t.destroy({children:!0,texture:!1,textureSource:!1})}}const Dr=3818080,Fr=["radial","cone","head"];function Vr(n=Tt,t={}){const e=!!n.enabled,s=t.levelView||null,i=t.shear??B.shear;let o=null,r=null;const a={},l=new Set,h=new Map,c=[];let u=null;const f=new Map;let d=null;const p=new Map,x=new Map,M=new Map;let S=!1,b=null;const A=()=>s?.cfg||null,g=_=>{let m=d.emissive.get(_);return m||(m=new O,m.label=`emissive-${_}`,m.zIndex=X(li,_),m.eventMode="none",d.emissive.set(_,m)),m},L=()=>{if(!(!d?.night||!a.head||d.headsReady)){d.headsReady=!0;for(const _ of d.lamps){if(!_.head)continue;const m=new $(a.head.texture);m.anchor.set(.5),m.blendMode="add",m.tint=_.color,_.headSprite=m,g(_.level).addChild(m)}}},C=(_,m,y)=>{const w=_||{},k=!!w.night,Y=$t(y??1);if(d={night:k,ambient:w.ambient??Dr,step:m,scale:Y,lamps:[],headsReady:!1,levels:new Map,roofLevels:new Map,emissive:new Map,maskCells:new Map,roofCells:new Map},!!k){(w.lamps||[]).forEach((T,I)=>{const[Z,N]=T.cell||[0,0],H=T.level||0,Vt=ui(Z,N,m,Y);d.lamps.push({kind:"radial",level:H,x:Vt.x,y:Vt.y,z:H,radius:T.radius??0,rotation:0,color:T.color??16777215,intensity:T.intensity??1,flicker:T.flicker||0,seed:I+1,head:!!T.head,headSprite:null})});for(const[T,I]of h)g(I).addChild(T);L(),S=!0,b=null}},z=()=>{if(d){for(const _ of d.emissive.values())_.parent?.removeChild(_);for(const _ of P())_.overlay.parent?.removeChild(_.overlay);for(const _ of d.emissive.values())for(const m of h.keys())m.parent===_&&_.removeChild(m);for(const _ of d.lamps)_.headSprite&&(_.headSprite.destroy({texture:!1,textureSource:!1}),_.headSprite=null);for(const _ of d.emissive.values())_.destroy({children:!0});for(const _ of P())_.destroy();d=null,b=null}},D=()=>{z(),p.clear(),x.clear(),M.clear(),S=!1,u=null},P=()=>[...d.levels.values(),...d.roofLevels.values()],F=(_,m=null)=>{const y=[],w=new Set;for(const k of _?.values()||[])for(const Y of k){const T=`${Y[0]},${Y[1]}`;!w.has(T)&&!m?.has(T)&&(w.add(T),y.push(Y))}return[y,w]},V=(_,m,y,w)=>{let k=_.get(m);if(y.length===0){k&&(k.destroy(),_.delete(m));return}k||(k=new He({level:m,ambient:d.ambient,resolution:n.resolution,roof:w}),_.set(m,k)),k.setMask(ye(y),d.step,d.scale)},j=_=>{const m=new Map;for(const{cells:y,volume:w}of M.get(_)?.values()||[])m.has(w)||m.set(w,[]),m.get(w).push(...y);return[...m].map(([y,w])=>({volume:y,runs:ye(w)}))},R=()=>{const _=S;if(S){S=!1;const m=new Set([...p.keys(),...x.keys(),...d.levels.keys(),...d.roofLevels.keys()]);for(const y of m){if(y<1)continue;const[w,k]=F(x.get(y)),[Y,T]=F(p.get(y),k);d.maskCells.set(y,T),d.roofCells.set(y,k),V(d.levels,y,Y,!1),V(d.roofLevels,y,w,!0)}}if(d.levels.has(0)||d.levels.set(0,new He({level:0,ambient:d.ambient,resolution:n.resolution})),_)for(const m of d.levels.values())m.setTops(j(m.level),d.step,d.scale)},J=()=>{for(const _ of P())_.overlay.parent!==o&&o.addChild(_.overlay);for(const _ of d.emissive.values())_.parent!==o&&o.addChild(_)},xt=(_,m,y)=>{const w=_.kind==="cone"?a.cone:a.radial;if(!w||!(_.intensity*y>0))return null;const k=xe(_.x,_.y,_.z??_.level,m,o,i);if(_.kind==="cone"){const T=_.radius*k.scale,I=T*(_.spread??.5);return{reach:T*o.scale.x,view:k,texture:w.texture,anchorX:w.margin/w.texture.width,anchorY:.5,scaleX:T/w.length,scaleY:I/w.halfWidth,rotation:_.rotation||0,color:_.color,alpha:_.intensity*y}}const Y=_.radius*k.scale;return{reach:Y*o.scale.x,view:k,texture:w.texture,anchorX:.5,anchorY:.5,scaleX:Y*2/w.contentSize,scaleY:Y*2/w.contentSize,rotation:0,color:_.color,alpha:_.intensity*y}},Q=(_,m,y)=>{const w=new Map;let k=0;const Y=(T,I)=>{const Z=(T.levels??[T.level]).filter(H=>d.levels.has(H));if(k>=n.maxLights||Z.length===0)return;const N=xt(T,_,I);if(!(!N||!di(N.view.screenX,N.view.screenY,N.reach,m.width,m.height))){N.x=N.view.x,N.y=N.view.y;for(const H of Z){if(k>=n.maxLights)return;w.has(H)||w.set(H,[]),w.get(H).push(N),k+=1}}};for(let T=c.length-1;T>=0;T-=1){const I=c[T],Z=fi(y-I.start,I.duration);Z<=0?c.splice(T,1):Y(I,Z)}for(const T of l)Y(T,1);for(const T of d.lamps)Y(T,we(T.seed,y,T.flicker));for(const T of P())T.place(o,m,_,i),T.layout(w.get(T.level)||[])},et=(_,m)=>{const y=A();if(!y)return;const w=K.shared.deltaMS/1e3,k=m?Math.min(1,y.fadeRate*w):0,Y=rt(s.x,s.y,_,s.z*i);for(const T of P()){if(T.level<1)continue;const I=s.level<T.level,Z=T.roof&&I&&zs(d.roofCells.get(T.level),d.step,d.scale,Y,_,[T.level*i],y.roofMargin??0),N=T.overlay;if(s.mode==="layer"){let H=Z;if(!T.roof){const rs=kt(s.x,d.scale.x,d.step),os=kt(s.y,d.scale.y,d.step);H=I&&!!d.maskCells.get(T.level)?.has(`${rs},${os}`)}const Vt=H?y.layerAlpha:1;N.alpha+=(Vt-N.alpha)*k;continue}le(T.hole,T.roof?Z:I,k),he(N,T.hole,y,s,o,_),T.hole.attached?T.hole.filter.blendMode="multiply":N.filters?.[0]!==T.filter&&(N.filters=[T.filter])}},it=(_,m)=>{for(const y of d.lamps){const w=y.headSprite;if(!w)continue;const k=xe(y.x,y.y,y.level,_,o,i);w.position.set(k.x,k.y),w.scale.set(k.scale),w.alpha=(s?s.alphaFor(y.level,k.x,k.y,0):1)*we(y.seed,m,y.flicker)}if(s)for(const[y,w]of h)y.alpha=s.alphaFor(w,y.x,y.y,0)},dt=()=>e&&d?.night===!0;return{get enabled(){return e},attachStage(_,m){!e||o||!_||!m||(o=_,r=m,b=null,s?.attachStage(_,m))},acquireMap(_,m,y,w){e&&(f.set(_,(f.get(_)||0)+1),_!==u&&(z(),u=_,C(m,y,w)))},releaseMap(_,m){if(!e)return;if(m!==void 0)for(const w of[p,x,M])for(const k of w.values())k.delete(m)&&(S=!0);const y=f.get(_);if(y!==void 0){if(y>1){f.set(_,y-1);return}f.delete(_),_===u&&D()}},setLevelMask(_,m,y,{roof:w=!1}={}){if(!e||!(_>=1))return;const k=w?x:p;k.has(_)||k.set(_,new Map),m&&m.length>0?k.get(_).set(y,m):k.get(_).delete(y),S=!0},setVolumeTops(_,m,y,w){!e||!(_>=0)||(M.has(_)||M.set(_,new Map),m&&m.length>0&&y>0?M.get(_).set(w,{cells:m,volume:y}):M.get(_).delete(w),S=!0)},registerTextures(_){if(!(!e||!_)){for(const m of Fr){const y=_[m];if(!y)continue;const w=a[m];if(a[m]=y,m==="head"&&w&&w!==y){for(const k of h.keys())k.texture===w.texture&&(k.texture=y.texture);for(const k of d?.lamps||[])k.headSprite&&(k.headSprite.texture=y.texture)}}a.head&&L()}},texture(_){return a[_]||null},addLight(_){if(!e)return null;const m={kind:"radial",level:0,x:0,y:0,radius:0,rotation:0,color:16777215,intensity:1,..._};return l.add(m),m},updateLight(_,m){_&&l.has(_)&&Object.assign(_,m)},removeLight(_){l.delete(_)},flash(_){!dt()||!a.radial||c.push({kind:"radial",level:0,color:16777215,intensity:1,..._,start:K.shared.lastTime})},addEmissive(_,m){return!dt()||!_?!1:(h.get(_)!==void 0&&_.parent&&_.parent.removeChild(_),h.set(_,m||0),g(m||0).addChild(_),!0)},removeEmissive(_){if(h.has(_)){h.delete(_);for(const m of d?.emissive.values()||[])_.parent===m&&m.removeChild(_)}},isNight:dt,render(){if(!dt()||!o||!r)return;const _=s?s.camera():lt(o,r),m=r.screen;if(!_||!m)return;const y=K.shared.lastTime,w=b;if(w!==null&&w.tick===y&&w.x===o.position.x&&w.y===o.position.y&&w.scaleX===o.scale.x&&w.scaleY===o.scale.y&&w.width===m.width&&w.height===m.height&&!S)return;const k=w===null||w.tick!==y;b={tick:y,x:o.position.x,y:o.position.y,scaleX:o.scale.x,scaleY:o.scale.y,width:m.width,height:m.height},R(),L(),J(),Q(_,m,y),s&&et(_,k),it(_,y)},clear:D}}const Or=[[0,-1],[0,1],[-1,0],[1,0]],Br={id:"tanks",engineApi:gs,requires:["map.layers","map.levelsN","map.gameData","map.bodyState"],async createClientCore(n,{wasmUrl:t}){if(Er(t)){const s=await zr(t);return{core:new s.ClientCore(n),memory:null}}const e=await Ts({module_or_path:t});return{core:new se(n),memory:e.memory}},parts:yr,bakers:Ir,styles:ks,serviceNames:["levelView","mapDynamics","rampRuns","surfaces","lighting"],hooks:{services(n){const t=Pr(),e=Vr(void 0,{levelView:t});let s=[],i=null,o=[],r=null;return{levelView:t,lighting:e,mapDynamics:{toWorld(a,l,h){const c=n.map_dynamics_to_world(a,l,h);return c.length===0?null:{x:c[0],y:c[1]}}},rampRuns:{forLevel(a){const l=n.map_generation();return l!==i&&(i=l,s=JSON.parse(n.ramp_runs())),s.filter(h=>h.from===a)}},surfaces:{kindAt(a,l,h){const c=n.surface_at(a,l,h);if(c<0)return null;const u=n.map_generation();return u!==r&&(r=u,o=JSON.parse(n.surface_types())),o[c]??null},dirAt(a,l,h){return Or[n.surface_dir_at(a,l,h)]??null}}}},onAuth(n,t){n.set_model(t.model)},onPanel(n,t){n.sync_panel(JSON.stringify(t))},onLocalAction(n,t,e,s){return t!=="down"?null:e==="fire"?n.try_fire(s)||null:((e==="nextWeapon"||e==="prevWeapon")&&n.cycle_weapon(e==="prevWeapon"),null)}}};export{Br as default};
|