@vimp-games/snakes 0.7.6 → 0.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/assets/{vimp_snakes_core_bg-C5At6odT.wasm → vimp_snakes_core_bg-uUik_EAz.wasm} +0 -0
- package/dist/{client-Cgf_r1An.js → client-BMXF1hOR.js} +1 -1
- package/dist/core-node/package.json +1 -1
- package/dist/core-node/vimp_snakes_core_bg.wasm +0 -0
- package/dist/host-5iP1tM2d.js +1 -0
- package/dist/manifest.json +4 -4
- package/package.json +3 -3
- package/dist/host-CXhs31HD.js +0 -1
package/README.md
CHANGED
|
Binary file
|
|
@@ -5,4 +5,4 @@ import{Container as q,Graphics as M,Sprite as ie,Rectangle as ce}from"pixi.js";c
|
|
|
5
5
|
<p class="${A}-total">Total score: <span>0</span></p>
|
|
6
6
|
<button type="button">OK</button>
|
|
7
7
|
</div>
|
|
8
|
-
`,this._crystals=e.querySelector(`.${A}-score span`),this._total=e.querySelector(`.${A}-total span`),e.querySelector("button").addEventListener("click",()=>this._respawn()),document.body.appendChild(e),this._root=e}onPanel(e){if(!this._root)return;const t=Pe(e);if(te in t&&(this._lastScore=t[te]),!(ee in t))return;const n=t[ee];n>0?this._show(n-1):this._hide()}reset(){this._hide(),this._lastScore=0}_show(e){this._visible||(this._visible=!0,this._crystals.textContent=String(e),this._total.textContent=String(this._lastScore),this._root.hidden=!1)}_hide(){this._visible&&(this._visible=!1,this._root.hidden=!0)}_respawn(){this._hide();for(const e of["keydown","keyup"])Te(e,Me)}}const We="modulepreload",Ne=function(r){return"/"+r},ne={},ze=function(e,t,n){let o=Promise.resolve();if(t&&t.length>0){let _=function(l){return Promise.all(l.map(d=>Promise.resolve(d).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),c=i?.nonce||i?.getAttribute("nonce");o=_(t.map(l=>{if(l=Ne(l),l in ne)return;ne[l]=!0;const d=l.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${f}`))return;const p=document.createElement("link");if(p.rel=d?"stylesheet":We,d||(p.as="script"),p.crossOrigin="",p.href=l,c&&p.setAttribute("nonce",c),document.head.appendChild(p),d)return new Promise((u,y)=>{p.addEventListener("load",u),p.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${l}`)))})}))}function a(i){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=i,window.dispatchEvent(c),!c.defaultPrevented)throw i}return o.then(i=>{for(const c of i||[])c.status==="rejected"&&a(c.reason);return e().catch(a)})},Fe=r=>(r??"").endsWith(".js"),je=r=>import(r),Ge=()=>ze(()=>Promise.resolve().then(()=>He),[]),D=new Ie,Xe={id:"snakes",engineApi:de,async createClientCore(r,{wasmUrl:e}={}){if(Fe(e)){const a=await je(e);return{core:new a.ClientCore(r),memory:null}}const{default:t,ClientCore:n}=await Ge(),o=await t({module_or_path:e});return{core:new n(r),memory:o.memory}},parts:Ce,bakers:Oe,styles:fe,hooks:{onAuth(r,e){r.set_model(e.model),D.mount(),D.reset()},onPanel(r,e){r.sync_panel(JSON.stringify(e)),D.onPanel(e)},onLocalAction(){return null}}};class ${__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,re.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_clientcore_free(e,0)}apply_aim(e,t,n,o){s.clientcore_apply_aim(this.__wbg_ptr,e,t,n,o)}apply_input(e,t,n){const o=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),a=h,i=g(t,s.__wbindgen_malloc,s.__wbindgen_realloc),c=h;s.clientcore_apply_input(this.__wbg_ptr,o,a,i,c,n)}debug_json(){let e,t;try{const n=s.clientcore_debug_json(this.__wbg_ptr);return e=n[0],t=n[1],w(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}decode_frame(e){let t,n;try{const o=K(e,s.__wbindgen_malloc),a=h,i=s.clientcore_decode_frame(this.__wbg_ptr,o,a);return t=i[0],n=i[1],w(i[0],i[1])}finally{s.__wbindgen_free(t,n,1)}}hot_ptr(){return s.clientcore_hot_ptr(this.__wbg_ptr)>>>0}hot_values(){const e=s.clientcore_hot_values(this.__wbg_ptr);var t=U(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*4,4),t}my_game_id(){return s.clientcore_my_game_id(this.__wbg_ptr)}constructor(e){const t=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),n=h,o=s.clientcore_new(t,n);if(o[2])throw x(o[1]);return this.__wbg_ptr=o[0],re.register(this,this.__wbg_ptr,this),this}offset(){return s.clientcore_offset(this.__wbg_ptr)}push_frame(e,t){const n=K(e,s.__wbindgen_malloc),o=h;return s.clientcore_push_frame(this.__wbg_ptr,n,o,t)!==0}reset(){s.clientcore_reset(this.__wbg_ptr)}resync(){s.clientcore_resync(this.__wbg_ptr)}sample(e){return s.clientcore_sample(this.__wbg_ptr,e)>>>0}set_active(e){s.clientcore_set_active(this.__wbg_ptr,e)}set_map(e){const t=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),n=h,o=s.clientcore_set_map(this.__wbg_ptr,t,n);if(o[1])throw x(o[0])}set_model(e){const t=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),n=h;s.clientcore_set_model(this.__wbg_ptr,t,n)}sync_panel(e){const t=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),n=h;s.clientcore_sync_panel(this.__wbg_ptr,t,n)}take_divergence(){let e,t;try{const n=s.clientcore_take_divergence(this.__wbg_ptr);return e=n[0],t=n[1],w(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}take_frames(){let e,t;try{const n=s.clientcore_take_frames(this.__wbg_ptr);return e=n[0],t=n[1],w(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}}Symbol.dispose&&($.prototype[Symbol.dispose]=$.prototype.free);class B{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,se.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_gamecore_free(e,0)}alive_players(){const e=s.gamecore_alive_players(this.__wbg_ptr);var t=U(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*4,4),t}apply_aim(e,t,n,o,a){s.gamecore_apply_aim(this.__wbg_ptr,e,t,n,o,a)}apply_input(e,t,n,o){const a=g(n,s.__wbindgen_malloc,s.__wbindgen_realloc),i=h,c=g(o,s.__wbindgen_malloc,s.__wbindgen_realloc),_=h;s.gamecore_apply_input(this.__wbg_ptr,e,t,a,i,c,_)}body_has_events(){return s.gamecore_body_has_events(this.__wbg_ptr)!==0}clear(){s.gamecore_clear(this.__wbg_ptr)}debug_json(){let e,t;try{const n=s.gamecore_debug_json(this.__wbg_ptr);return e=n[0],t=n[1],w(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}deserialize_state(e){const t=K(e,s.__wbindgen_malloc),n=h,o=s.gamecore_deserialize_state(this.__wbg_ptr,t,n);if(o[1])throw x(o[0])}frame_bytes(){const e=s.gamecore_frame_bytes(this.__wbg_ptr);var t=oe(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*1,1),t}frame_ptr(){return s.gamecore_frame_ptr(this.__wbg_ptr)>>>0}is_alive(e){return s.gamecore_is_alive(this.__wbg_ptr,e)!==0}last_input_seq(e){return s.gamecore_last_input_seq(this.__wbg_ptr,e)>>>0}load_map(e){const t=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),n=h,o=s.gamecore_load_map(this.__wbg_ptr,t,n);if(o[1])throw x(o[0])}map_info(){let e,t;try{const n=s.gamecore_map_info(this.__wbg_ptr);return e=n[0],t=n[1],w(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}constructor(e){const t=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),n=h,o=s.gamecore_new(t,n);if(o[2])throw x(o[1]);return this.__wbg_ptr=o[0],se.register(this,this.__wbg_ptr,this),this}pack_body(){const e=s.gamecore_pack_body(this.__wbg_ptr);if(e[1])throw x(e[0])}pack_frame(e,t,n,o,a,i,c,_){var l=Ye(c)?0:g(c,s.__wbindgen_malloc,s.__wbindgen_realloc),d=h;return s.gamecore_pack_frame(this.__wbg_ptr,e,t,n,o,a,i,l,d,_)>>>0}players_data(){let e,t;try{const n=s.gamecore_players_data(this.__wbg_ptr);return e=n[0],t=n[1],w(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}position_of(e){const t=s.gamecore_position_of(this.__wbg_ptr,e);var n=U(t[0],t[1]).slice();return s.__wbindgen_free(t[0],t[1]*4,4),n}remove_actor(e){s.gamecore_remove_actor(this.__wbg_ptr,e)}remove_players_and_shots(){let e,t;try{const n=s.gamecore_remove_players_and_shots(this.__wbg_ptr);return e=n[0],t=n[1],w(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}remove_scripted_actor(e){s.gamecore_remove_scripted_actor(this.__wbg_ptr,e)}reset_actor(e,t,n,o,a){s.gamecore_reset_actor(this.__wbg_ptr,e,t,n,o,a)}reset_all_vitals(){s.gamecore_reset_all_vitals(this.__wbg_ptr)}serialize_state(){const e=s.gamecore_serialize_state(this.__wbg_ptr);if(e[3])throw x(e[2]);var t=oe(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*1,1),t}spawn_actor(e,t,n,o,a,i){const c=g(t,s.__wbindgen_malloc,s.__wbindgen_realloc),_=h,l=s.gamecore_spawn_actor(this.__wbg_ptr,e,c,_,n,o,a,i);if(l[1])throw x(l[0])}spawn_scripted_actor(e,t,n,o,a,i){const c=g(t,s.__wbindgen_malloc,s.__wbindgen_realloc),_=h,l=s.gamecore_spawn_scripted_actor(this.__wbg_ptr,e,c,_,n,o,a,i);if(l[1])throw x(l[0])}step(e){s.gamecore_step(this.__wbg_ptr,e)}take_events(){let e,t;try{const n=s.gamecore_take_events(this.__wbg_ptr);return e=n[0],t=n[1],w(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}}Symbol.dispose&&(B.prototype[Symbol.dispose]=B.prototype.free);function _e(){return{__proto__:null,"./vimp_snakes_core_bg.js":{__proto__:null,__wbg_Error_408e67f47ca7b58b:function(e,t){return Error(w(e,t))},__wbg___wbindgen_throw_bb96b2010945f0bc:function(e,t){throw new Error(w(e,t))},__wbindgen_init_externref_table:function(){const e=s.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}}}}const re=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>s.__wbg_clientcore_free(r,1)),se=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>s.__wbg_gamecore_free(r,1));function U(r,e){return r=r>>>0,De().subarray(r/4,r/4+e)}function oe(r,e){return r=r>>>0,S().subarray(r/1,r/1+e)}let L=null;function De(){return(L===null||L.byteLength===0)&&(L=new Float32Array(s.memory.buffer)),L}function w(r,e){return Be(r>>>0,e)}let R=null;function S(){return(R===null||R.byteLength===0)&&(R=new Uint8Array(s.memory.buffer)),R}function Ye(r){return r==null}function K(r,e){const t=e(r.length*1,1)>>>0;return S().set(r,t/1),h=r.length,t}function g(r,e,t){if(t===void 0){const c=O.encode(r),_=e(c.length,1)>>>0;return S().subarray(_,_+c.length).set(c),h=c.length,_}let n=r.length,o=e(n,1)>>>0;const a=S();let i=0;for(;i<n;i++){const c=r.charCodeAt(i);if(c>127)break;a[o+i]=c}if(i!==n){i!==0&&(r=r.slice(i)),o=t(o,n,n=i+r.length*3,1)>>>0;const c=S().subarray(o+i,o+n),_=O.encodeInto(r,c);i+=_.written,o=t(o,n,i,1)>>>0}return h=i,o}function x(r){const e=s.__wbindgen_externrefs.get(r);return s.__externref_table_dealloc(r),e}let F=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});F.decode();const $e=2146435072;let Y=0;function Be(r,e){return Y+=e,Y>=$e&&(F=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),F.decode(),Y=e),F.decode(S().subarray(r,r+e))}const O=new TextEncoder;"encodeInto"in O||(O.encodeInto=function(r,e){const t=O.encode(r);return e.set(t),{read:r.length,written:t.length}});let h=0,s;function le(r,e){return s=r.exports,L=null,R=null,s.__wbindgen_start(),s}async function Ue(r,e){if(typeof Response=="function"&&r instanceof Response){if(!r.ok)throw new Error(`failed to fetch Wasm: ${r.status} ${r.statusText} fetching '${r.url}'`);if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(r,e)}catch(o){if(t(r.type)&&r.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",o);else throw o}const n=await r.arrayBuffer();return await WebAssembly.instantiate(n,e)}else{const n=await WebAssembly.instantiate(r,e);return n instanceof WebAssembly.Instance?{instance:n,module:r}:n}function t(n){switch(n){case"basic":case"cors":case"default":return!0}return!1}}function Ke(r){if(s!==void 0)return s;r!==void 0&&(Object.getPrototypeOf(r)===Object.prototype?{module:r}=r:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));const e=_e();r instanceof WebAssembly.Module||(r=new WebAssembly.Module(r));const t=new WebAssembly.Instance(r,e);return le(t)}async function qe(r){if(s!==void 0)return s;r!==void 0&&(Object.getPrototypeOf(r)===Object.prototype?{module_or_path:r}=r:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),r===void 0&&(r=new URL("/assets/vimp_snakes_core_bg-C5At6odT.wasm",import.meta.url));const e=_e();(typeof r=="string"||typeof Request=="function"&&r instanceof Request||typeof URL=="function"&&r instanceof URL)&&(r=fetch(r));const{instance:t,module:n}=await Ue(await r,e);return le(t)}const He=Object.freeze(Object.defineProperty({__proto__:null,ClientCore:$,GameCore:B,default:qe,initSync:Ke},Symbol.toStringTag,{value:"Module"}));export{Xe as default};
|
|
8
|
+
`,this._crystals=e.querySelector(`.${A}-score span`),this._total=e.querySelector(`.${A}-total span`),e.querySelector("button").addEventListener("click",()=>this._respawn()),document.body.appendChild(e),this._root=e}onPanel(e){if(!this._root)return;const t=Pe(e);if(te in t&&(this._lastScore=t[te]),!(ee in t))return;const n=t[ee];n>0?this._show(n-1):this._hide()}reset(){this._hide(),this._lastScore=0}_show(e){this._visible||(this._visible=!0,this._crystals.textContent=String(e),this._total.textContent=String(this._lastScore),this._root.hidden=!1)}_hide(){this._visible&&(this._visible=!1,this._root.hidden=!0)}_respawn(){this._hide();for(const e of["keydown","keyup"])Te(e,Me)}}const We="modulepreload",Ne=function(r){return"/"+r},ne={},ze=function(e,t,n){let o=Promise.resolve();if(t&&t.length>0){let _=function(l){return Promise.all(l.map(d=>Promise.resolve(d).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),c=i?.nonce||i?.getAttribute("nonce");o=_(t.map(l=>{if(l=Ne(l),l in ne)return;ne[l]=!0;const d=l.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${f}`))return;const p=document.createElement("link");if(p.rel=d?"stylesheet":We,d||(p.as="script"),p.crossOrigin="",p.href=l,c&&p.setAttribute("nonce",c),document.head.appendChild(p),d)return new Promise((u,y)=>{p.addEventListener("load",u),p.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${l}`)))})}))}function a(i){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=i,window.dispatchEvent(c),!c.defaultPrevented)throw i}return o.then(i=>{for(const c of i||[])c.status==="rejected"&&a(c.reason);return e().catch(a)})},Fe=r=>(r??"").endsWith(".js"),je=r=>import(r),Ge=()=>ze(()=>Promise.resolve().then(()=>He),[]),D=new Ie,Xe={id:"snakes",engineApi:de,async createClientCore(r,{wasmUrl:e}={}){if(Fe(e)){const a=await je(e);return{core:new a.ClientCore(r),memory:null}}const{default:t,ClientCore:n}=await Ge(),o=await t({module_or_path:e});return{core:new n(r),memory:o.memory}},parts:Ce,bakers:Oe,styles:fe,hooks:{onAuth(r,e){r.set_model(e.model),D.mount(),D.reset()},onPanel(r,e){r.sync_panel(JSON.stringify(e)),D.onPanel(e)},onLocalAction(){return null}}};class Y{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,re.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_clientcore_free(e,0)}apply_aim(e,t,n,o){s.clientcore_apply_aim(this.__wbg_ptr,e,t,n,o)}apply_input(e,t,n){const o=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),a=h,i=g(t,s.__wbindgen_malloc,s.__wbindgen_realloc),c=h;s.clientcore_apply_input(this.__wbg_ptr,o,a,i,c,n)}debug_json(){let e,t;try{const n=s.clientcore_debug_json(this.__wbg_ptr);return e=n[0],t=n[1],w(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}decode_frame(e){let t,n;try{const o=K(e,s.__wbindgen_malloc),a=h,i=s.clientcore_decode_frame(this.__wbg_ptr,o,a);return t=i[0],n=i[1],w(i[0],i[1])}finally{s.__wbindgen_free(t,n,1)}}hot_ptr(){return s.clientcore_hot_ptr(this.__wbg_ptr)>>>0}hot_values(){const e=s.clientcore_hot_values(this.__wbg_ptr);var t=B(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*4,4),t}my_game_id(){return s.clientcore_my_game_id(this.__wbg_ptr)}constructor(e){const t=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),n=h,o=s.clientcore_new(t,n);if(o[2])throw x(o[1]);return this.__wbg_ptr=o[0],re.register(this,this.__wbg_ptr,this),this}offset(){return s.clientcore_offset(this.__wbg_ptr)}push_frame(e,t){const n=K(e,s.__wbindgen_malloc),o=h;return s.clientcore_push_frame(this.__wbg_ptr,n,o,t)!==0}reset(){s.clientcore_reset(this.__wbg_ptr)}resync(){s.clientcore_resync(this.__wbg_ptr)}sample(e){return s.clientcore_sample(this.__wbg_ptr,e)>>>0}set_active(e){s.clientcore_set_active(this.__wbg_ptr,e)}set_map(e){const t=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),n=h,o=s.clientcore_set_map(this.__wbg_ptr,t,n);if(o[1])throw x(o[0])}set_model(e){const t=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),n=h;s.clientcore_set_model(this.__wbg_ptr,t,n)}sync_panel(e){const t=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),n=h;s.clientcore_sync_panel(this.__wbg_ptr,t,n)}take_divergence(){let e,t;try{const n=s.clientcore_take_divergence(this.__wbg_ptr);return e=n[0],t=n[1],w(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}take_frames(){let e,t;try{const n=s.clientcore_take_frames(this.__wbg_ptr);return e=n[0],t=n[1],w(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}}Symbol.dispose&&(Y.prototype[Symbol.dispose]=Y.prototype.free);class ${__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,se.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_gamecore_free(e,0)}alive_players(){const e=s.gamecore_alive_players(this.__wbg_ptr);var t=B(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*4,4),t}apply_aim(e,t,n,o,a){s.gamecore_apply_aim(this.__wbg_ptr,e,t,n,o,a)}apply_input(e,t,n,o){const a=g(n,s.__wbindgen_malloc,s.__wbindgen_realloc),i=h,c=g(o,s.__wbindgen_malloc,s.__wbindgen_realloc),_=h;s.gamecore_apply_input(this.__wbg_ptr,e,t,a,i,c,_)}body_has_events(){return s.gamecore_body_has_events(this.__wbg_ptr)!==0}clear(){s.gamecore_clear(this.__wbg_ptr)}debug_json(){let e,t;try{const n=s.gamecore_debug_json(this.__wbg_ptr);return e=n[0],t=n[1],w(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}deserialize_state(e){const t=K(e,s.__wbindgen_malloc),n=h,o=s.gamecore_deserialize_state(this.__wbg_ptr,t,n);if(o[1])throw x(o[0])}frame_bytes(){const e=s.gamecore_frame_bytes(this.__wbg_ptr);var t=oe(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*1,1),t}frame_ptr(){return s.gamecore_frame_ptr(this.__wbg_ptr)>>>0}is_alive(e){return s.gamecore_is_alive(this.__wbg_ptr,e)!==0}last_input_seq(e){return s.gamecore_last_input_seq(this.__wbg_ptr,e)>>>0}load_map(e){const t=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),n=h,o=s.gamecore_load_map(this.__wbg_ptr,t,n);if(o[1])throw x(o[0])}map_info(){let e,t;try{const n=s.gamecore_map_info(this.__wbg_ptr);return e=n[0],t=n[1],w(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}constructor(e){const t=g(e,s.__wbindgen_malloc,s.__wbindgen_realloc),n=h,o=s.gamecore_new(t,n);if(o[2])throw x(o[1]);return this.__wbg_ptr=o[0],se.register(this,this.__wbg_ptr,this),this}pack_body(){const e=s.gamecore_pack_body(this.__wbg_ptr);if(e[1])throw x(e[0])}pack_frame(e,t,n,o,a,i,c,_){var l=Ue(c)?0:g(c,s.__wbindgen_malloc,s.__wbindgen_realloc),d=h;return s.gamecore_pack_frame(this.__wbg_ptr,e,t,n,o,a,i,l,d,_)>>>0}players_data(){let e,t;try{const n=s.gamecore_players_data(this.__wbg_ptr);return e=n[0],t=n[1],w(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}position_of(e){const t=s.gamecore_position_of(this.__wbg_ptr,e);var n=B(t[0],t[1]).slice();return s.__wbindgen_free(t[0],t[1]*4,4),n}remove_actor(e){s.gamecore_remove_actor(this.__wbg_ptr,e)}remove_players_and_shots(){let e,t;try{const n=s.gamecore_remove_players_and_shots(this.__wbg_ptr);return e=n[0],t=n[1],w(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}remove_scripted_actor(e){s.gamecore_remove_scripted_actor(this.__wbg_ptr,e)}reset_actor(e,t,n,o,a){s.gamecore_reset_actor(this.__wbg_ptr,e,t,n,o,a)}reset_all_vitals(){s.gamecore_reset_all_vitals(this.__wbg_ptr)}serialize_state(){const e=s.gamecore_serialize_state(this.__wbg_ptr);if(e[3])throw x(e[2]);var t=oe(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*1,1),t}spawn_actor(e,t,n,o,a,i){const c=g(t,s.__wbindgen_malloc,s.__wbindgen_realloc),_=h,l=s.gamecore_spawn_actor(this.__wbg_ptr,e,c,_,n,o,a,i);if(l[1])throw x(l[0])}spawn_scripted_actor(e,t,n,o,a,i){const c=g(t,s.__wbindgen_malloc,s.__wbindgen_realloc),_=h,l=s.gamecore_spawn_scripted_actor(this.__wbg_ptr,e,c,_,n,o,a,i);if(l[1])throw x(l[0])}step(e){s.gamecore_step(this.__wbg_ptr,e)}take_events(){let e,t;try{const n=s.gamecore_take_events(this.__wbg_ptr);return e=n[0],t=n[1],w(n[0],n[1])}finally{s.__wbindgen_free(e,t,1)}}}Symbol.dispose&&($.prototype[Symbol.dispose]=$.prototype.free);function _e(){return{__proto__:null,"./vimp_snakes_core_bg.js":{__proto__:null,__wbg_Error_408e67f47ca7b58b:function(e,t){return Error(w(e,t))},__wbg___wbindgen_throw_bb96b2010945f0bc:function(e,t){throw new Error(w(e,t))},__wbindgen_init_externref_table:function(){const e=s.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}}}}const re=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>s.__wbg_clientcore_free(r,1)),se=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>s.__wbg_gamecore_free(r,1));function B(r,e){return r=r>>>0,De().subarray(r/4,r/4+e)}function oe(r,e){return r=r>>>0,S().subarray(r/1,r/1+e)}let L=null;function De(){return(L===null||L.byteLength===0)&&(L=new Float32Array(s.memory.buffer)),L}function w(r,e){return $e(r>>>0,e)}let R=null;function S(){return(R===null||R.byteLength===0)&&(R=new Uint8Array(s.memory.buffer)),R}function Ue(r){return r==null}function K(r,e){const t=e(r.length*1,1)>>>0;return S().set(r,t/1),h=r.length,t}function g(r,e,t){if(t===void 0){const c=O.encode(r),_=e(c.length,1)>>>0;return S().subarray(_,_+c.length).set(c),h=c.length,_}let n=r.length,o=e(n,1)>>>0;const a=S();let i=0;for(;i<n;i++){const c=r.charCodeAt(i);if(c>127)break;a[o+i]=c}if(i!==n){i!==0&&(r=r.slice(i)),o=t(o,n,n=i+r.length*3,1)>>>0;const c=S().subarray(o+i,o+n),_=O.encodeInto(r,c);i+=_.written,o=t(o,n,i,1)>>>0}return h=i,o}function x(r){const e=s.__wbindgen_externrefs.get(r);return s.__externref_table_dealloc(r),e}let F=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});F.decode();const Ye=2146435072;let U=0;function $e(r,e){return U+=e,U>=Ye&&(F=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),F.decode(),U=e),F.decode(S().subarray(r,r+e))}const O=new TextEncoder;"encodeInto"in O||(O.encodeInto=function(r,e){const t=O.encode(r);return e.set(t),{read:r.length,written:t.length}});let h=0,s;function le(r,e){return s=r.exports,L=null,R=null,s.__wbindgen_start(),s}async function Be(r,e){if(typeof Response=="function"&&r instanceof Response){if(!r.ok)throw new Error(`failed to fetch Wasm: ${r.status} ${r.statusText} fetching '${r.url}'`);if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(r,e)}catch(o){if(t(r.type)&&r.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",o);else throw o}const n=await r.arrayBuffer();return await WebAssembly.instantiate(n,e)}else{const n=await WebAssembly.instantiate(r,e);return n instanceof WebAssembly.Instance?{instance:n,module:r}:n}function t(n){switch(n){case"basic":case"cors":case"default":return!0}return!1}}function Ke(r){if(s!==void 0)return s;r!==void 0&&(Object.getPrototypeOf(r)===Object.prototype?{module:r}=r:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));const e=_e();r instanceof WebAssembly.Module||(r=new WebAssembly.Module(r));const t=new WebAssembly.Instance(r,e);return le(t)}async function qe(r){if(s!==void 0)return s;r!==void 0&&(Object.getPrototypeOf(r)===Object.prototype?{module_or_path:r}=r:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),r===void 0&&(r=new URL("/assets/vimp_snakes_core_bg-uUik_EAz.wasm",import.meta.url));const e=_e();(typeof r=="string"||typeof Request=="function"&&r instanceof Request||typeof URL=="function"&&r instanceof URL)&&(r=fetch(r));const{instance:t,module:n}=await Be(await r,e);return le(t)}const He=Object.freeze(Object.defineProperty({__proto__:null,ClientCore:Y,GameCore:$,default:qe,initSync:Ke},Symbol.toStringTag,{value:"Module"}));export{Xe as default};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"collaborators": [
|
|
4
4
|
"lgick"
|
|
5
5
|
],
|
|
6
|
-
"description": "
|
|
6
|
+
"description": "VIMP Snakes — game simulation + wasm-bindgen ABI on top of vimp-engine-core.",
|
|
7
7
|
"version": "0.1.0",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"files": [
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const X=Array.from({length:16},(n,e)=>[{name:`p${e}x`,ty:"f32",interp:"lerp"},{name:`p${e}y`,ty:"f32",interp:"lerp"}]).flat(),Z={s1:{id:1,kind:"indexed8",class:"hot",fields:[...X,{name:"angle",ty:"f32",interp:"lerpAngle"},{name:"radius",ty:"f32",interp:"lerp"},{name:"crystals",ty:"u16"},{name:"color",ty:"u8"},{name:"boost",ty:"u8"}]},cr:{id:2,kind:"indexed32",class:"event",fields:[{name:"x",ty:"f32"},{name:"y",ty:"f32"},{name:"tier",ty:"u8"},{name:"color",ty:"u8"}]},c1:{id:3,kind:"indexedNoNull8",class:"hot",fields:[{name:"x",ty:"f32",interp:"lerp"},{name:"y",ty:"f32",interp:"lerp"},{name:"angle",ty:"f32",interp:"lerpAngle"}]}},x=[16731469,16752412,16765503,10214972,3065014,3848191,5531903,11623679,16735432,16250871,8250065,16753828],Q=n=>`#${x[n%x.length].toString(16).padStart(6,"0")}`,J=[{value:1,radius:8},{value:3,radius:13},{value:8,radius:20}],A={s1:{baseSpeed:260,boostFactor:1.9,turnSpeed:3.4,turnSpeedFalloff:.18,turnSpeedMin:1.4,baseRadius:14,radiusGain:1.6,baseLength:150,lengthPerCrystal:9,pointSpacing:6,boostDrainPerSecond:6,boostMinCrystals:2,world:{maxCrystals:60,spawnInterval:.35,tierWeights:[70,25,5],tiers:J,dropRatio:.8,edgeMargin:60,startCrystals:0,spawnGraceSeconds:2}}},ee={},L=128,I=1,te=20,D=8,C=4,k=64,re=Math.PI*(3-Math.sqrt(5)),ne=.72,se=25;function E(n){const e=Math.ceil(Math.max(n,0)/C)*C,t=Math.max(e,D);return Math.round(te*Math.sqrt(t/D))}const W=Math.log2(k);if(!Number.isInteger(W))throw new Error(`RESPAWN_COUNT must be a power of two (the order is bit-reversed), got ${k}`);function ae(n){let e=0;for(let t=0;t<W;t+=1)e=e<<1|n>>t&1;return e}function ie(n){const e=n*L/2,t=e;return Array.from({length:k},(r,s)=>{const i=ae(s),o=e*ne*Math.sqrt((i+.5)/k),c=i*re,l=t+Math.cos(c)*o,_=t+Math.sin(c)*o,h=(s*.6180339887%1*2-1)*se,m=c*180/Math.PI+180+h;return[Math.round(l),Math.round(_),Math.round((m%360+360)%360)]})}function U(n=0){const e=E(n);return{setId:"c1",scale:1,step:L,physicsStatic:[],physicsDynamic:[],layers:{1:[I]},map:Array.from({length:e},()=>Array.from({length:e},()=>I)),respawns:{players:ie(e)}}}const oe=U(0),ce={arena:oe},_e={title:"Snakes",parts:{models:A,weapons:ee,friendlyFire:!1},snapshot:Z,soundCues:{roundStart:null,victory:null,defeat:null,frag:null,death:null},maps:ce,currentMap:"arena",mapScale:1,mapSetId:"c1",mapsInVote:1,timers:{timeStep:1e3/120,networkSendRate:4,roundTime:36e5,mapTime:36e5,roomTimeMin:1e4,roomTimeMax:36e5,voteTime:1e4,timeBlockedVote:3e4,teamChangeGracePeriod:1e4,roundRestartDelay:5e3,mapChangeDelay:2e3,rttPingInterval:3e3,idleCheckInterval:3e4},playerState:{defaultState:{best:0,eaten:0}},noSpectators:!0,endlessRound:!0,statMode:"leaderboard",teams:{players:1},scripted:{namePrefix:"Snake",defaultModel:"s1"},playerKeys:{left:{key:1},right:{key:2},boost:{key:4},respawn:{key:8,type:1}},panel:{fields:{crystals:{key:"c",value:0},score:{key:"s",value:0},dead:{key:"d",value:0}},activeKey:"wa"},stat:{name:{key:0,bodyMethod:"=",headSync:!0,headMethod:"#"},status:{key:1,bodyMethod:"=",bodyValue:"",headValue:""},score:{key:2,bodyMethod:"=",bodyValue:0,headMethod:"+",headValue:0},latency:{key:3,bodyMethod:"="}},roomDefaults:{maxPlayers:32},roomForm:[{name:"maxPlayers",control:"text",label:"Max players",numeric:!0},{name:"map",control:"select",label:"Map",source:"maps"}]},le={elems:{authId:"auth",fieldsId:"auth-fields",errorId:"auth-error",enterId:"auth-enter",titleId:"auth-title",informsId:"auth-informs"},texts:{title:"Snakes",sections:[{heading:"How to play",lines:[{keys:"a, d",text:"turn"},{keys:"w",text:"boost (burns crystals)"},{keys:"r",text:"respawn after a crash"},{separator:!0},{keys:"",text:"eat crystals to grow"},{keys:"",text:"the edge and other snakes kill you"},{keys:"",text:"your own tail does not"},{separator:!0},{keys:"c",text:"chat"},{keys:"<Tab>",text:"stats",last:!0}]}]},params:[{name:"model",value:"s1",options:{control:"select",label:"Snake",options:Object.keys(A),validator:"isValidModel",storage:"model"}}],validators:{isValidModel:n=>n in A}},pe={pickup:{file:"shot",priority:80,volume:.35},death:{file:"death",priority:150,volume:.5}},de={codecList:["webm","mp3"],sounds:pe},ue={parts:{gameSets:{s1:["Snake"],cr:["Crystal"],c1:["Arena"]},entitiesOnCanvas:{Arena:"vimp",Snake:"vimp",Crystal:"vimp"},bakedAssets:{vimp:[{name:"crystalGem",component:"Crystal",params:{radius:32,facets:6}},{name:"crown",component:"Snake",params:{size:64,points:3}}]},componentDependencies:{soundManager:["Snake"],localPlayer:["Snake"],accolades:["Snake"]},sounds:de},initIdList:["vimp","panel","chat"],modules:{canvasManager:{canvases:{vimp:{width:960,height:600,aspectRatio:"16:10",baseScale:"1:1",dynamicCamera:!0,shakeCamera:!1}}},controls:{modes:{77:""},keySetList:[{78:"nextPlayer",80:"prevPlayer"},{65:"left",68:"right",87:"boost",82:"respawn"}],pointer:{keySets:[1],doubleTapMs:300,doubleTapPx:40,sendIntervalMs:50}},chat:{params:{messages:{s:["The arena is full. You will join as soon as a place frees up","You are already in the arena","You are in the arena","You are watching the arena","{0} crashed into {1}","{0} joined the game","{0} left the game"],v:["A vote has been created","Voting has started","Your vote has been accepted","Voting is temporarily unavailable","Vote passed","Vote failed"],m:["Current map: {0}","Next map: {0}"],c:["Command not found","Your place today: {0} of {1} ({2} points)"],n:["Invalid name","{0} changed name to {1}"],g:["Bot snakes in the arena: {0}","Invalid bot count"]}}},panel:{keys:{s:"score",c:"crystals",d:"dead",wa:"mode",t:"time"},fields:[{name:"score",elem:"panel-score",type:"value"},{name:"crystals",elem:"panel-crystals",type:"value"},{name:"dead",elem:"panel-dead",type:"value"},{name:"mode",elem:"panel-mode",type:"weapon"},{name:"time",elem:"panel-time",type:"time"}]},stat:{params:{mode:"leaderboard",period:"day",limit:10,columns:["#","snake","score"]}}},gameInform:{list:["{0} WINS!","SLITHER!","GAME OVER!"]}};class he{constructor({participants:e,coreAdapter:t,socketManager:r},s){this._participants=e,this._coreAdapter=t,this._socketManager=r,this._scriptedManager=s,this._vimp=null,this._population=null,this._size=null,this._mapData=null,this._delivered=new Map}onCoreEvent(e,t={}){t.vimp&&(this._vimp=t.vimp),!(!e||e.type!=="population")&&this._apply(Number(e.count)||0)}_apply(e){const t=this._sizeFor(e);if(t!==this._size){this._size=t,this._population=e;const r=U(e);this._coreAdapter.createMap(r),this._scriptedManager?.createMap(r),this._vimp?.overrideMapData?.(r),this._mapData=r,this._delivered.clear()}this._broadcast()}_sizeFor(e){if(this._size===null)return E(e);const t=E(e);return t>this._size||e<=this._population-C?t:this._size}_broadcast(){if(!this._mapData)return;const e=this._participants.getHumans();for(const t of e)!t.isReady||this._delivered.get(t.gameId)===this._size||(this._delivered.set(t.gameId,this._size),this._socketManager.sendMap(t.socketId,this._mapData));if(this._delivered.size>e.length){const t=new Set(e.map(r=>r.gameId));for(const r of this._delivered.keys())t.has(r)||this._delivered.delete(r)}}reapply(){this._mapData&&(this._vimp?.overrideMapData?.(this._mapData),this._coreAdapter.createMap(this._mapData),this._scriptedManager?.createMap(this._mapData),this._broadcast())}get mapData(){return this._mapData??null}}class fe{constructor({participants:e}){this._participants=e}onCoreEvent(e){if(!e||e.type!=="spawn")return;const t=Number(e.color);!Number.isFinite(t)||t<0||this._participants?.setChatColor?.(String(e.id),Q(t))}}class me{constructor({participants:e,coreAdapter:t,panel:r,stat:s,scripted:i}){this._participants=e,this._coreAdapter=t,this._panel=r,this._stat=s,this._model=i.defaultModel,this._respawns=null}createMap(e){this._respawns=e.respawns}getCountsPerTeam(){const e={};for(const t of this._participants.getScripted())e[t.team]=(e[t.team]??0)+1;return e}createScripted(e,t=null){if(!this._respawns)return 0;const r=this._participants.getPlayableTeams();let s=0;for(let i=0;i<e&&!this._participants.isFull;i+=1){const o=t??this._pickTeam(r);if(!o||!this._hasRoom(o))break;const c=this._participants.createScripted({team:o,model:this._model}),l=this._participants.get(c);this._stat.addUser(c,l.teamId,{name:l.name,status:"",latency:"BOT"}),this._panel.addUser(c),s+=1}return s}_hasRoom(e){const t=this._respawns[e];return!!(t&&this._participants.getTeamSize(e)<t.length)}_pickTeam(e){return[...e].sort((t,r)=>this._participants.getTeamSize(t)-this._participants.getTeamSize(r)).find(t=>this._hasRoom(t))??null}removeScripted(e=null){const t=this._participants.getScripted();(e?t.filter(s=>s.team===e):t).forEach(s=>this._remove(s.gameId))}removeOneForHuman(e){for(const t of this._participants.getScripted())if(t.team===e)return this._remove(t.gameId),!0;return!1}_remove(e){const t=this._participants.get(e);!t||!t.isScripted||(this._stat.removeUser(e,t.teamId),this._panel.removeUser(e),this._coreAdapter.removePlayer(e),this._participants.remove(e))}}const ge=15;class ye{constructor({participants:e,stat:t}){this._participants=e,this._stat=t,this._totals=new Map}onCoreEvent(e,t={}){if(!e||typeof e!="object")return;const{vimp:r,panel:s}=t,i=String(e.id);switch(e.type){case"crystals":this._onCrystals(i,Number(e.gained)||0,r,s);break;case"burn":this._onBurn(i,Number(e.burned)||0,r,s);break;case"death":this._onDeath(i,e,r,s);break;case"respawn":this._onRespawn(i,r,s);break;case"population":this._publishNewcomers(r,s),r?.flushPlayerData?.();break}}reset(e){this._totals.delete(e)}_onCrystals(e,t,r,s){const i=this._record(e);!i||t<=0||(i.eaten+=t,i.score+=t,this._publish(e,i,r,s))}_onBurn(e,t,r,s){const i=this._record(e);!i||t<=0||(i.score=Math.max(0,i.score-t),this._publish(e,i,r,s))}_onDeath(e,t,r,s){const i=this._record(e);if(!i)return;const o=t.killer===null||t.killer===void 0?null:String(t.killer);if(o!==null&&o!==e){const _=this._record(o);_&&(_.kills+=1,_.score+=ge,this._publish(o,_,r,s))}this._publish(e,i,r,s);const l=r?.isPlayerRatingLoaded?.(e,"day")===!0?r.getPlayerRating?.(e,"day")?.value??0:1/0;r?.addPlayerPoints?.(e,i.score),r?.finishPlayerGame?.(e),this._recordBest(e,i,r),r?.flushPlayerData?.({urgent:i.score>l})}_onRespawn(e,t,r){const s=this._record(e);s&&(s.eaten=0,s.kills=0,s.score=0,s.flushedEaten=0,this._publish(e,s,t,r))}_record(e){const t=this._participants.get(e);if(!t)return null;const r=this._totals.get(e);if(r&&r.participant===t)return r;const s={participant:t,eaten:0,kills:0,score:0,flushedEaten:0,published:!1};return this._totals.set(e,s),s}_publishNewcomers(e,t){for(const r of this._participants.getAll()){const s=r.gameId,i=this._totals.get(s),o=i?.participant===r?i:this._record(s);o&&!o.published&&this._publish(s,o,e,t)}}_publish(e,t,r,s){const{score:i}=t;t.published=!0,this._stat.updateUser(e,t.participant.teamId,{score:i}),s&&s.updateUser(e,"score",i,"set")}_recordBest(e,t,r){if(!r?.getPlayerState)return;const s=r.getPlayerState(e);if(!s)return;const i=t.eaten-t.flushedEaten;t.flushedEaten=t.eaten;const o=Math.max(Number(s.best)||0,t.score),c=(Number(s.eaten)||0)+i;r.setPlayerState(e,{...s,best:o,eaten:c})}}let j=null,V=null,G=null;function be(n){const e=new me(n);return j=new ye(n),V=new he(n,e),G=new fe(n),{scripted:e}}function we(){return j}function $(){return V}function ve(){return G}const Se={name:"/bot",handler(n,e,t){const r=Number(t[0]);if(t[0]===void 0||!Number.isFinite(r)||r<0){n.chat.pushSystemByUser(e,"BOT_COUNT_INVALID");return}const{maxPlayers:s}=n.participants,i=Math.trunc(r),o=s>0?Math.min(i,s):i;n.scripted.removeScripted();const c=o>0?n.scripted.createScripted(o):0;n.chat.pushSystem("BOTS_SET",[c]),c>0&&(n.roundManager.initiateNewRound(),$()?.reapply())}},ke={name:"/name",handler(n,e,t){n.roundManager.changeName(e,t.join(" "))}},Me={name:"/nr",handler(n,e){n.isDevMode?n.roundManager.initiateNewRound():n.chat.pushSystemByUser(e,"COMMANDS_NOT_FOUND")}},Ae={name:"/rank",async handler(n,e){let t=null;try{t=await n.playerDataSync?.refreshPlacement?.(e,"day")}catch{t=n.playerDataSync?.getRating?.(e,"day")??null}const{value:r=0,placement:s=null,total:i=0}=t??{};n.chat.pushSystemByUser(e,"RANK",[s??"—",i,r])}},Ce={BOTS_SET:"g:0",BOT_COUNT_INVALID:"g:1"},Ee="modulepreload",Pe=function(n){return"/"+n},O={},Te=function(e,t,r){let s=Promise.resolve();if(t&&t.length>0){let l=function(_){return Promise.all(_.map(h=>Promise.resolve(h).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),c=o?.nonce||o?.getAttribute("nonce");s=l(t.map(_=>{if(_=Pe(_),_ in O)return;O[_]=!0;const h=_.endsWith(".css"),m=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${_}"]${m}`))return;const g=document.createElement("link");if(g.rel=h?"stylesheet":Ee,h||(g.as="script"),g.crossOrigin="",g.href=_,c&&g.setAttribute("nonce",c),document.head.appendChild(g),h)return new Promise((K,H)=>{g.addEventListener("load",K),g.addEventListener("error",()=>H(new Error(`Unable to preload CSS for ${_}`)))})}))}function i(o){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=o,window.dispatchEvent(c),!c.defaultPrevented)throw o}return s.then(o=>{for(const c of o||[])c.status==="rejected"&&i(c.reason);return e().catch(i)})},Ne=n=>(n??"").endsWith(".js"),Re=n=>import(n),xe=()=>Te(()=>Promise.resolve().then(()=>We),[]),Ue={id:"snakes",engineApi:4,async createCore(n,{wasmUrl:e}={}){if(Ne(e)){const s=await Re(e);return new s.GameCore(n)}const{default:t,GameCore:r}=await xe();return await t({module_or_path:e}),new r(n)},gameConfig:_e,authSchema:le,chatCommands:[Se,ke,Me,Ae],systemMessages:Ce,createModules:be,buildClientGameConfig:()=>ue,onCoreEvent(n,e={}){we()?.onCoreEvent(n,e),$()?.onCoreEvent(n,e),ve()?.onCoreEvent(n)}};class P{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,z.unregister(this),e}free(){const e=this.__destroy_into_raw();a.__wbg_clientcore_free(e,0)}apply_aim(e,t,r,s){a.clientcore_apply_aim(this.__wbg_ptr,e,t,r,s)}apply_input(e,t,r){const s=d(e,a.__wbindgen_malloc,a.__wbindgen_realloc),i=p,o=d(t,a.__wbindgen_malloc,a.__wbindgen_realloc),c=p;a.clientcore_apply_input(this.__wbg_ptr,s,i,o,c,r)}debug_json(){let e,t;try{const r=a.clientcore_debug_json(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{a.__wbindgen_free(e,t,1)}}decode_frame(e){let t,r;try{const s=R(e,a.__wbindgen_malloc),i=p,o=a.clientcore_decode_frame(this.__wbg_ptr,s,i);return t=o[0],r=o[1],u(o[0],o[1])}finally{a.__wbindgen_free(t,r,1)}}hot_ptr(){return a.clientcore_hot_ptr(this.__wbg_ptr)>>>0}hot_values(){const e=a.clientcore_hot_values(this.__wbg_ptr);var t=N(e[0],e[1]).slice();return a.__wbindgen_free(e[0],e[1]*4,4),t}my_game_id(){return a.clientcore_my_game_id(this.__wbg_ptr)}constructor(e){const t=d(e,a.__wbindgen_malloc,a.__wbindgen_realloc),r=p,s=a.clientcore_new(t,r);if(s[2])throw f(s[1]);return this.__wbg_ptr=s[0],z.register(this,this.__wbg_ptr,this),this}offset(){return a.clientcore_offset(this.__wbg_ptr)}push_frame(e,t){const r=R(e,a.__wbindgen_malloc),s=p;return a.clientcore_push_frame(this.__wbg_ptr,r,s,t)!==0}reset(){a.clientcore_reset(this.__wbg_ptr)}resync(){a.clientcore_resync(this.__wbg_ptr)}sample(e){return a.clientcore_sample(this.__wbg_ptr,e)>>>0}set_active(e){a.clientcore_set_active(this.__wbg_ptr,e)}set_map(e){const t=d(e,a.__wbindgen_malloc,a.__wbindgen_realloc),r=p,s=a.clientcore_set_map(this.__wbg_ptr,t,r);if(s[1])throw f(s[0])}set_model(e){const t=d(e,a.__wbindgen_malloc,a.__wbindgen_realloc),r=p;a.clientcore_set_model(this.__wbg_ptr,t,r)}sync_panel(e){const t=d(e,a.__wbindgen_malloc,a.__wbindgen_realloc),r=p;a.clientcore_sync_panel(this.__wbg_ptr,t,r)}take_divergence(){let e,t;try{const r=a.clientcore_take_divergence(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{a.__wbindgen_free(e,t,1)}}take_frames(){let e,t;try{const r=a.clientcore_take_frames(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{a.__wbindgen_free(e,t,1)}}}Symbol.dispose&&(P.prototype[Symbol.dispose]=P.prototype.free);class T{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,F.unregister(this),e}free(){const e=this.__destroy_into_raw();a.__wbg_gamecore_free(e,0)}alive_players(){const e=a.gamecore_alive_players(this.__wbg_ptr);var t=N(e[0],e[1]).slice();return a.__wbindgen_free(e[0],e[1]*4,4),t}apply_aim(e,t,r,s,i){a.gamecore_apply_aim(this.__wbg_ptr,e,t,r,s,i)}apply_input(e,t,r,s){const i=d(r,a.__wbindgen_malloc,a.__wbindgen_realloc),o=p,c=d(s,a.__wbindgen_malloc,a.__wbindgen_realloc),l=p;a.gamecore_apply_input(this.__wbg_ptr,e,t,i,o,c,l)}body_has_events(){return a.gamecore_body_has_events(this.__wbg_ptr)!==0}clear(){a.gamecore_clear(this.__wbg_ptr)}debug_json(){let e,t;try{const r=a.gamecore_debug_json(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{a.__wbindgen_free(e,t,1)}}deserialize_state(e){const t=R(e,a.__wbindgen_malloc),r=p,s=a.gamecore_deserialize_state(this.__wbg_ptr,t,r);if(s[1])throw f(s[0])}frame_bytes(){const e=a.gamecore_frame_bytes(this.__wbg_ptr);var t=B(e[0],e[1]).slice();return a.__wbindgen_free(e[0],e[1]*1,1),t}frame_ptr(){return a.gamecore_frame_ptr(this.__wbg_ptr)>>>0}is_alive(e){return a.gamecore_is_alive(this.__wbg_ptr,e)!==0}last_input_seq(e){return a.gamecore_last_input_seq(this.__wbg_ptr,e)>>>0}load_map(e){const t=d(e,a.__wbindgen_malloc,a.__wbindgen_realloc),r=p,s=a.gamecore_load_map(this.__wbg_ptr,t,r);if(s[1])throw f(s[0])}map_info(){let e,t;try{const r=a.gamecore_map_info(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{a.__wbindgen_free(e,t,1)}}constructor(e){const t=d(e,a.__wbindgen_malloc,a.__wbindgen_realloc),r=p,s=a.gamecore_new(t,r);if(s[2])throw f(s[1]);return this.__wbg_ptr=s[0],F.register(this,this.__wbg_ptr,this),this}pack_body(){const e=a.gamecore_pack_body(this.__wbg_ptr);if(e[1])throw f(e[0])}pack_frame(e,t,r,s,i,o,c,l){var _=De(c)?0:d(c,a.__wbindgen_malloc,a.__wbindgen_realloc),h=p;return a.gamecore_pack_frame(this.__wbg_ptr,e,t,r,s,i,o,_,h,l)>>>0}players_data(){let e,t;try{const r=a.gamecore_players_data(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{a.__wbindgen_free(e,t,1)}}position_of(e){const t=a.gamecore_position_of(this.__wbg_ptr,e);var r=N(t[0],t[1]).slice();return a.__wbindgen_free(t[0],t[1]*4,4),r}remove_actor(e){a.gamecore_remove_actor(this.__wbg_ptr,e)}remove_players_and_shots(){let e,t;try{const r=a.gamecore_remove_players_and_shots(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{a.__wbindgen_free(e,t,1)}}remove_scripted_actor(e){a.gamecore_remove_scripted_actor(this.__wbg_ptr,e)}reset_actor(e,t,r,s,i){a.gamecore_reset_actor(this.__wbg_ptr,e,t,r,s,i)}reset_all_vitals(){a.gamecore_reset_all_vitals(this.__wbg_ptr)}serialize_state(){const e=a.gamecore_serialize_state(this.__wbg_ptr);if(e[3])throw f(e[2]);var t=B(e[0],e[1]).slice();return a.__wbindgen_free(e[0],e[1]*1,1),t}spawn_actor(e,t,r,s,i,o){const c=d(t,a.__wbindgen_malloc,a.__wbindgen_realloc),l=p,_=a.gamecore_spawn_actor(this.__wbg_ptr,e,c,l,r,s,i,o);if(_[1])throw f(_[0])}spawn_scripted_actor(e,t,r,s,i,o){const c=d(t,a.__wbindgen_malloc,a.__wbindgen_realloc),l=p,_=a.gamecore_spawn_scripted_actor(this.__wbg_ptr,e,c,l,r,s,i,o);if(_[1])throw f(_[0])}step(e){a.gamecore_step(this.__wbg_ptr,e)}take_events(){let e,t;try{const r=a.gamecore_take_events(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{a.__wbindgen_free(e,t,1)}}}Symbol.dispose&&(T.prototype[Symbol.dispose]=T.prototype.free);function q(){return{__proto__:null,"./vimp_snakes_core_bg.js":{__proto__:null,__wbg_Error_408e67f47ca7b58b:function(e,t){return Error(u(e,t))},__wbg___wbindgen_throw_bb96b2010945f0bc:function(e,t){throw new Error(u(e,t))},__wbindgen_init_externref_table:function(){const e=a.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}}}}const z=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>a.__wbg_clientcore_free(n,1)),F=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>a.__wbg_gamecore_free(n,1));function N(n,e){return n=n>>>0,Ie().subarray(n/4,n/4+e)}function B(n,e){return n=n>>>0,y().subarray(n/1,n/1+e)}let b=null;function Ie(){return(b===null||b.byteLength===0)&&(b=new Float32Array(a.memory.buffer)),b}function u(n,e){return ze(n>>>0,e)}let w=null;function y(){return(w===null||w.byteLength===0)&&(w=new Uint8Array(a.memory.buffer)),w}function De(n){return n==null}function R(n,e){const t=e(n.length*1,1)>>>0;return y().set(n,t/1),p=n.length,t}function d(n,e,t){if(t===void 0){const c=v.encode(n),l=e(c.length,1)>>>0;return y().subarray(l,l+c.length).set(c),p=c.length,l}let r=n.length,s=e(r,1)>>>0;const i=y();let o=0;for(;o<r;o++){const c=n.charCodeAt(o);if(c>127)break;i[s+o]=c}if(o!==r){o!==0&&(n=n.slice(o)),s=t(s,r,r=o+n.length*3,1)>>>0;const c=y().subarray(s+o,s+r),l=v.encodeInto(n,c);o+=l.written,s=t(s,r,o,1)>>>0}return p=o,s}function f(n){const e=a.__wbindgen_externrefs.get(n);return a.__externref_table_dealloc(n),e}let S=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});S.decode();const Oe=2146435072;let M=0;function ze(n,e){return M+=e,M>=Oe&&(S=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),S.decode(),M=e),S.decode(y().subarray(n,n+e))}const v=new TextEncoder;"encodeInto"in v||(v.encodeInto=function(n,e){const t=v.encode(n);return e.set(t),{read:n.length,written:t.length}});let p=0,a;function Y(n,e){return a=n.exports,b=null,w=null,a.__wbindgen_start(),a}async function Fe(n,e){if(typeof Response=="function"&&n instanceof Response){if(!n.ok)throw new Error(`failed to fetch Wasm: ${n.status} ${n.statusText} fetching '${n.url}'`);if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(n,e)}catch(s){if(t(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",s);else throw s}const r=await n.arrayBuffer();return await WebAssembly.instantiate(r,e)}else{const r=await WebAssembly.instantiate(n,e);return r instanceof WebAssembly.Instance?{instance:r,module:n}:r}function t(r){switch(r){case"basic":case"cors":case"default":return!0}return!1}}function Be(n){if(a!==void 0)return a;n!==void 0&&(Object.getPrototypeOf(n)===Object.prototype?{module:n}=n:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));const e=q();n instanceof WebAssembly.Module||(n=new WebAssembly.Module(n));const t=new WebAssembly.Instance(n,e);return Y(t)}async function Le(n){if(a!==void 0)return a;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_snakes_core_bg-uUik_EAz.wasm",import.meta.url));const e=q();(typeof n=="string"||typeof Request=="function"&&n instanceof Request||typeof URL=="function"&&n instanceof URL)&&(n=fetch(n));const{instance:t,module:r}=await Fe(await n,e);return Y(t)}const We=Object.freeze(Object.defineProperty({__proto__:null,ClientCore:P,GameCore:T,default:Le,initSync:Be},Symbol.toStringTag,{value:"Module"}));export{Ue as default};
|
package/dist/manifest.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "snakes",
|
|
3
3
|
"engineApi": 4,
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "242aec79889afb25",
|
|
5
5
|
"title": "Snakes",
|
|
6
6
|
"entries": {
|
|
7
|
-
"client": "/games/snakes/client-
|
|
8
|
-
"host": "/games/snakes/host-
|
|
9
|
-
"wasm": "/games/snakes/assets/vimp_snakes_core_bg-
|
|
7
|
+
"client": "/games/snakes/client-BMXF1hOR.js",
|
|
8
|
+
"host": "/games/snakes/host-5iP1tM2d.js",
|
|
9
|
+
"wasm": "/games/snakes/assets/vimp_snakes_core_bg-uUik_EAz.wasm",
|
|
10
10
|
"wasmNode": "./core-node/vimp_snakes_core.js"
|
|
11
11
|
},
|
|
12
12
|
"assetsBase": "/games/snakes/",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vimp-games/snakes",
|
|
3
|
-
"version": "0.7.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.7.8",
|
|
4
|
+
"description": "VIMP Snakes — a VIMP game plugin",
|
|
5
5
|
"author": "lgick",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"globals": "^16.2.0",
|
|
47
47
|
"happy-dom": "^20.10.6",
|
|
48
48
|
"pixi.js": "^8.14.0",
|
|
49
|
-
"vimp-engine": "^0.
|
|
49
|
+
"vimp-engine": "^0.22.0",
|
|
50
50
|
"vite": "^7.1.11",
|
|
51
51
|
"vitest": "^4.1.9"
|
|
52
52
|
}
|
package/dist/host-CXhs31HD.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const K=Array.from({length:16},(n,e)=>[{name:`p${e}x`,ty:"f32",interp:"lerp"},{name:`p${e}y`,ty:"f32",interp:"lerp"}]).flat(),H={s1:{id:1,kind:"indexed8",class:"hot",fields:[...K,{name:"angle",ty:"f32",interp:"lerpAngle"},{name:"radius",ty:"f32",interp:"lerp"},{name:"crystals",ty:"u16"},{name:"color",ty:"u8"},{name:"boost",ty:"u8"}]},cr:{id:2,kind:"indexed32",class:"event",fields:[{name:"x",ty:"f32"},{name:"y",ty:"f32"},{name:"tier",ty:"u8"},{name:"color",ty:"u8"}]},c1:{id:3,kind:"indexedNoNull8",class:"hot",fields:[{name:"x",ty:"f32",interp:"lerp"},{name:"y",ty:"f32",interp:"lerp"},{name:"angle",ty:"f32",interp:"lerpAngle"}]}},X=[{value:1,radius:8},{value:3,radius:13},{value:8,radius:20}],A={s1:{baseSpeed:260,boostFactor:1.9,turnSpeed:3.4,turnSpeedFalloff:.18,turnSpeedMin:1.4,baseRadius:14,radiusGain:1.6,baseLength:150,lengthPerCrystal:9,pointSpacing:6,boostDrainPerSecond:6,boostMinCrystals:2,world:{maxCrystals:60,spawnInterval:.35,tierWeights:[70,25,5],tiers:X,dropRatio:.8,edgeMargin:60,startCrystals:0,spawnGraceSeconds:2}}},Z={},F=128,I=1,Q=20,D=8,E=4,k=64,J=Math.PI*(3-Math.sqrt(5)),ee=.72,te=25;function C(n){const e=Math.ceil(Math.max(n,0)/E)*E,t=Math.max(e,D);return Math.round(Q*Math.sqrt(t/D))}const W=Math.log2(k);if(!Number.isInteger(W))throw new Error(`RESPAWN_COUNT must be a power of two (the order is bit-reversed), got ${k}`);function re(n){let e=0;for(let t=0;t<W;t+=1)e=e<<1|n>>t&1;return e}function ne(n){const e=n*F/2,t=e;return Array.from({length:k},(r,s)=>{const i=re(s),o=e*ee*Math.sqrt((i+.5)/k),c=i*J,l=t+Math.cos(c)*o,_=t+Math.sin(c)*o,h=(s*.6180339887%1*2-1)*te,m=c*180/Math.PI+180+h;return[Math.round(l),Math.round(_),Math.round((m%360+360)%360)]})}function L(n=0){const e=C(n);return{setId:"c1",scale:1,step:F,physicsStatic:[],physicsDynamic:[],layers:{1:[I]},map:Array.from({length:e},()=>Array.from({length:e},()=>I)),respawns:{players:ne(e)}}}const se=L(0),ae={arena:se},ie={title:"Vimp Snakes",parts:{models:A,weapons:Z,friendlyFire:!1},snapshot:H,soundCues:{roundStart:null,victory:null,defeat:null,frag:null,death:null},maps:ae,currentMap:"arena",mapScale:1,mapSetId:"c1",mapsInVote:1,timers:{timeStep:1e3/120,networkSendRate:4,roundTime:36e5,mapTime:36e5,roomTimeMin:1e4,roomTimeMax:36e5,voteTime:1e4,timeBlockedVote:3e4,teamChangeGracePeriod:1e4,roundRestartDelay:5e3,mapChangeDelay:2e3,rttPingInterval:3e3,idleCheckInterval:3e4},playerState:{defaultState:{best:0,eaten:0}},noSpectators:!0,endlessRound:!0,statMode:"leaderboard",teams:{players:1},scripted:{namePrefix:"Snake",defaultModel:"s1"},playerKeys:{left:{key:1},right:{key:2},boost:{key:4},respawn:{key:8,type:1}},panel:{fields:{crystals:{key:"c",value:0},score:{key:"s",value:0},dead:{key:"d",value:0}},activeKey:"wa"},stat:{name:{key:0,bodyMethod:"=",headSync:!0,headMethod:"#"},status:{key:1,bodyMethod:"=",bodyValue:"",headValue:""},score:{key:2,bodyMethod:"=",bodyValue:0,headMethod:"+",headValue:0},latency:{key:3,bodyMethod:"="}},roomDefaults:{maxPlayers:32},roomForm:[{name:"maxPlayers",control:"text",label:"Max players",numeric:!0},{name:"map",control:"select",label:"Map",source:"maps"}]},oe={elems:{authId:"auth",fieldsId:"auth-fields",errorId:"auth-error",enterId:"auth-enter",titleId:"auth-title",informsId:"auth-informs"},texts:{title:"Vimp Snakes",sections:[{heading:"How to play",lines:[{keys:"a, d",text:"turn"},{keys:"w",text:"boost (burns crystals)"},{keys:"r",text:"respawn after a crash"},{separator:!0},{keys:"",text:"eat crystals to grow"},{keys:"",text:"the edge and other snakes kill you"},{keys:"",text:"your own tail does not"},{separator:!0},{keys:"c",text:"chat"},{keys:"<Tab>",text:"stats",last:!0}]}]},params:[{name:"model",value:"s1",options:{control:"select",label:"Snake",options:Object.keys(A),validator:"isValidModel",storage:"model"}}],validators:{isValidModel:n=>n in A}},ce={pickup:{file:"shot",priority:80,volume:.35},death:{file:"death",priority:150,volume:.5}},_e={codecList:["webm","mp3"],sounds:ce},le={parts:{gameSets:{s1:["Snake"],cr:["Crystal"],c1:["Arena"]},entitiesOnCanvas:{Arena:"vimp",Snake:"vimp",Crystal:"vimp"},bakedAssets:{vimp:[{name:"crystalGem",component:"Crystal",params:{radius:32,facets:6}},{name:"crown",component:"Snake",params:{size:64,points:3}}]},componentDependencies:{soundManager:["Snake"],localPlayer:["Snake"],accolades:["Snake"]},sounds:_e},initIdList:["vimp","panel","chat"],modules:{canvasManager:{canvases:{vimp:{width:960,height:600,aspectRatio:"16:10",baseScale:"1:1",dynamicCamera:!0,shakeCamera:!1}}},controls:{modes:{77:""},keySetList:[{78:"nextPlayer",80:"prevPlayer"},{65:"left",68:"right",87:"boost",82:"respawn"}],pointer:{keySets:[1],doubleTapMs:300,doubleTapPx:40,sendIntervalMs:50}},chat:{params:{messages:{s:["The arena is full. You will join as soon as a place frees up","You are already in the arena","You are in the arena","You are watching the arena","{0} crashed into {1}","{0} joined the game","{0} left the game"],v:["A vote has been created","Voting has started","Your vote has been accepted","Voting is temporarily unavailable","Vote passed","Vote failed"],m:["Current map: {0}","Next map: {0}"],c:["Command not found","Your place today: {0} of {1} ({2} points)"],n:["Invalid name","{0} changed name to {1}"],g:["Bot snakes in the arena: {0}","Invalid bot count"]}}},panel:{keys:{s:"score",c:"crystals",d:"dead",wa:"mode",t:"time"},fields:[{name:"score",elem:"panel-score",type:"value"},{name:"crystals",elem:"panel-crystals",type:"value"},{name:"dead",elem:"panel-dead",type:"value"},{name:"mode",elem:"panel-mode",type:"weapon"},{name:"time",elem:"panel-time",type:"time"}]},stat:{params:{mode:"leaderboard",period:"day",limit:10,columns:["#","snake","score"]}}},gameInform:{list:["{0} WINS!","SLITHER!","GAME OVER!"]}};class pe{constructor({participants:e,coreAdapter:t,socketManager:r},s){this._participants=e,this._coreAdapter=t,this._socketManager=r,this._scriptedManager=s,this._vimp=null,this._population=null,this._size=null,this._mapData=null,this._delivered=new Map}onCoreEvent(e,t={}){t.vimp&&(this._vimp=t.vimp),!(!e||e.type!=="population")&&this._apply(Number(e.count)||0)}_apply(e){const t=this._sizeFor(e);if(t!==this._size){this._size=t,this._population=e;const r=L(e);this._coreAdapter.createMap(r),this._scriptedManager?.createMap(r),this._vimp?.overrideMapData?.(r),this._mapData=r,this._delivered.clear()}this._broadcast()}_sizeFor(e){if(this._size===null)return C(e);const t=C(e);return t>this._size||e<=this._population-E?t:this._size}_broadcast(){if(!this._mapData)return;const e=this._participants.getHumans();for(const t of e)!t.isReady||this._delivered.get(t.gameId)===this._size||(this._delivered.set(t.gameId,this._size),this._socketManager.sendMap(t.socketId,this._mapData));if(this._delivered.size>e.length){const t=new Set(e.map(r=>r.gameId));for(const r of this._delivered.keys())t.has(r)||this._delivered.delete(r)}}reapply(){this._mapData&&(this._vimp?.overrideMapData?.(this._mapData),this._coreAdapter.createMap(this._mapData),this._scriptedManager?.createMap(this._mapData),this._broadcast())}get mapData(){return this._mapData??null}}class de{constructor({participants:e,coreAdapter:t,panel:r,stat:s,scripted:i}){this._participants=e,this._coreAdapter=t,this._panel=r,this._stat=s,this._model=i.defaultModel,this._respawns=null}createMap(e){this._respawns=e.respawns}getCountsPerTeam(){const e={};for(const t of this._participants.getScripted())e[t.team]=(e[t.team]??0)+1;return e}createScripted(e,t=null){if(!this._respawns)return 0;const r=this._participants.getPlayableTeams();let s=0;for(let i=0;i<e&&!this._participants.isFull;i+=1){const o=t??this._pickTeam(r);if(!o||!this._hasRoom(o))break;const c=this._participants.createScripted({team:o,model:this._model}),l=this._participants.get(c);this._stat.addUser(c,l.teamId,{name:l.name,status:"",latency:"BOT"}),this._panel.addUser(c),s+=1}return s}_hasRoom(e){const t=this._respawns[e];return!!(t&&this._participants.getTeamSize(e)<t.length)}_pickTeam(e){return[...e].sort((t,r)=>this._participants.getTeamSize(t)-this._participants.getTeamSize(r)).find(t=>this._hasRoom(t))??null}removeScripted(e=null){const t=this._participants.getScripted();(e?t.filter(s=>s.team===e):t).forEach(s=>this._remove(s.gameId))}removeOneForHuman(e){for(const t of this._participants.getScripted())if(t.team===e)return this._remove(t.gameId),!0;return!1}_remove(e){const t=this._participants.get(e);!t||!t.isScripted||(this._stat.removeUser(e,t.teamId),this._panel.removeUser(e),this._coreAdapter.removePlayer(e),this._participants.remove(e))}}const ue=15;class he{constructor({participants:e,stat:t}){this._participants=e,this._stat=t,this._totals=new Map}onCoreEvent(e,t={}){if(!e||typeof e!="object")return;const{vimp:r,panel:s}=t,i=String(e.id);switch(e.type){case"crystals":this._onCrystals(i,Number(e.gained)||0,r,s);break;case"burn":this._onBurn(i,Number(e.burned)||0,r,s);break;case"death":this._onDeath(i,e,r,s);break;case"respawn":this._onRespawn(i,r,s);break;case"population":this._publishNewcomers(r,s),r?.flushPlayerData?.();break}}reset(e){this._totals.delete(e)}_onCrystals(e,t,r,s){const i=this._record(e);!i||t<=0||(i.eaten+=t,i.score+=t,this._publish(e,i,r,s))}_onBurn(e,t,r,s){const i=this._record(e);!i||t<=0||(i.score=Math.max(0,i.score-t),this._publish(e,i,r,s))}_onDeath(e,t,r,s){const i=this._record(e);if(!i)return;const o=t.killer===null||t.killer===void 0?null:String(t.killer);if(o!==null&&o!==e){const _=this._record(o);_&&(_.kills+=1,_.score+=ue,this._publish(o,_,r,s))}this._publish(e,i,r,s);const l=r?.isPlayerRatingLoaded?.(e,"day")===!0?r.getPlayerRating?.(e,"day")?.value??0:1/0;r?.addPlayerPoints?.(e,i.score),r?.finishPlayerGame?.(e),this._recordBest(e,i,r),r?.flushPlayerData?.({urgent:i.score>l})}_onRespawn(e,t,r){const s=this._record(e);s&&(s.eaten=0,s.kills=0,s.score=0,s.flushedEaten=0,this._publish(e,s,t,r))}_record(e){const t=this._participants.get(e);if(!t)return null;const r=this._totals.get(e);if(r&&r.participant===t)return r;const s={participant:t,eaten:0,kills:0,score:0,flushedEaten:0,published:!1};return this._totals.set(e,s),s}_publishNewcomers(e,t){for(const r of this._participants.getAll()){const s=r.gameId,i=this._totals.get(s),o=i?.participant===r?i:this._record(s);o&&!o.published&&this._publish(s,o,e,t)}}_publish(e,t,r,s){const{score:i}=t;t.published=!0,this._stat.updateUser(e,t.participant.teamId,{score:i}),s&&s.updateUser(e,"score",i,"set")}_recordBest(e,t,r){if(!r?.getPlayerState)return;const s=r.getPlayerState(e);if(!s)return;const i=t.eaten-t.flushedEaten;t.flushedEaten=t.eaten;const o=Math.max(Number(s.best)||0,t.score),c=(Number(s.eaten)||0)+i;r.setPlayerState(e,{...s,best:o,eaten:c})}}let U=null,j=null;function fe(n){const e=new de(n);return U=new he(n),j=new pe(n,e),{scripted:e}}function me(){return U}function V(){return j}const ge={name:"/bot",handler(n,e,t){const r=Number(t[0]);if(t[0]===void 0||!Number.isFinite(r)||r<0){n.chat.pushSystemByUser(e,"BOT_COUNT_INVALID");return}const{maxPlayers:s}=n.participants,i=Math.trunc(r),o=s>0?Math.min(i,s):i;n.scripted.removeScripted();const c=o>0?n.scripted.createScripted(o):0;n.chat.pushSystem("BOTS_SET",[c]),c>0&&(n.roundManager.initiateNewRound(),V()?.reapply())}},ye={name:"/name",handler(n,e,t){n.roundManager.changeName(e,t.join(" "))}},be={name:"/nr",handler(n,e){n.isDevMode?n.roundManager.initiateNewRound():n.chat.pushSystemByUser(e,"COMMANDS_NOT_FOUND")}},we={name:"/rank",async handler(n,e){let t=null;try{t=await n.playerDataSync?.refreshPlacement?.(e,"day")}catch{t=n.playerDataSync?.getRating?.(e,"day")??null}const{value:r=0,placement:s=null,total:i=0}=t??{};n.chat.pushSystemByUser(e,"RANK",[s??"—",i,r])}},ve={BOTS_SET:"g:0",BOT_COUNT_INVALID:"g:1"},Se="modulepreload",ke=function(n){return"/"+n},O={},Me=function(e,t,r){let s=Promise.resolve();if(t&&t.length>0){let l=function(_){return Promise.all(_.map(h=>Promise.resolve(h).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),c=o?.nonce||o?.getAttribute("nonce");s=l(t.map(_=>{if(_=ke(_),_ in O)return;O[_]=!0;const h=_.endsWith(".css"),m=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${_}"]${m}`))return;const g=document.createElement("link");if(g.rel=h?"stylesheet":Se,h||(g.as="script"),g.crossOrigin="",g.href=_,c&&g.setAttribute("nonce",c),document.head.appendChild(g),h)return new Promise((Y,$)=>{g.addEventListener("load",Y),g.addEventListener("error",()=>$(new Error(`Unable to preload CSS for ${_}`)))})}))}function i(o){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=o,window.dispatchEvent(c),!c.defaultPrevented)throw o}return s.then(o=>{for(const c of o||[])c.status==="rejected"&&i(c.reason);return e().catch(i)})},Ae=n=>(n??"").endsWith(".js"),Ee=n=>import(n),Ce=()=>Me(()=>Promise.resolve().then(()=>xe),[]),ze={id:"snakes",engineApi:4,async createCore(n,{wasmUrl:e}={}){if(Ae(e)){const s=await Ee(e);return new s.GameCore(n)}const{default:t,GameCore:r}=await Ce();return await t({module_or_path:e}),new r(n)},gameConfig:ie,authSchema:oe,chatCommands:[ge,ye,be,we],systemMessages:ve,createModules:fe,buildClientGameConfig:()=>le,onCoreEvent(n,e={}){me()?.onCoreEvent(n,e),V()?.onCoreEvent(n,e)}};class T{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,x.unregister(this),e}free(){const e=this.__destroy_into_raw();a.__wbg_clientcore_free(e,0)}apply_aim(e,t,r,s){a.clientcore_apply_aim(this.__wbg_ptr,e,t,r,s)}apply_input(e,t,r){const s=d(e,a.__wbindgen_malloc,a.__wbindgen_realloc),i=p,o=d(t,a.__wbindgen_malloc,a.__wbindgen_realloc),c=p;a.clientcore_apply_input(this.__wbg_ptr,s,i,o,c,r)}debug_json(){let e,t;try{const r=a.clientcore_debug_json(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{a.__wbindgen_free(e,t,1)}}decode_frame(e){let t,r;try{const s=N(e,a.__wbindgen_malloc),i=p,o=a.clientcore_decode_frame(this.__wbg_ptr,s,i);return t=o[0],r=o[1],u(o[0],o[1])}finally{a.__wbindgen_free(t,r,1)}}hot_ptr(){return a.clientcore_hot_ptr(this.__wbg_ptr)>>>0}hot_values(){const e=a.clientcore_hot_values(this.__wbg_ptr);var t=R(e[0],e[1]).slice();return a.__wbindgen_free(e[0],e[1]*4,4),t}my_game_id(){return a.clientcore_my_game_id(this.__wbg_ptr)}constructor(e){const t=d(e,a.__wbindgen_malloc,a.__wbindgen_realloc),r=p,s=a.clientcore_new(t,r);if(s[2])throw f(s[1]);return this.__wbg_ptr=s[0],x.register(this,this.__wbg_ptr,this),this}offset(){return a.clientcore_offset(this.__wbg_ptr)}push_frame(e,t){const r=N(e,a.__wbindgen_malloc),s=p;return a.clientcore_push_frame(this.__wbg_ptr,r,s,t)!==0}reset(){a.clientcore_reset(this.__wbg_ptr)}resync(){a.clientcore_resync(this.__wbg_ptr)}sample(e){return a.clientcore_sample(this.__wbg_ptr,e)>>>0}set_active(e){a.clientcore_set_active(this.__wbg_ptr,e)}set_map(e){const t=d(e,a.__wbindgen_malloc,a.__wbindgen_realloc),r=p,s=a.clientcore_set_map(this.__wbg_ptr,t,r);if(s[1])throw f(s[0])}set_model(e){const t=d(e,a.__wbindgen_malloc,a.__wbindgen_realloc),r=p;a.clientcore_set_model(this.__wbg_ptr,t,r)}sync_panel(e){const t=d(e,a.__wbindgen_malloc,a.__wbindgen_realloc),r=p;a.clientcore_sync_panel(this.__wbg_ptr,t,r)}take_divergence(){let e,t;try{const r=a.clientcore_take_divergence(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{a.__wbindgen_free(e,t,1)}}take_frames(){let e,t;try{const r=a.clientcore_take_frames(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{a.__wbindgen_free(e,t,1)}}}Symbol.dispose&&(T.prototype[Symbol.dispose]=T.prototype.free);class P{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,z.unregister(this),e}free(){const e=this.__destroy_into_raw();a.__wbg_gamecore_free(e,0)}alive_players(){const e=a.gamecore_alive_players(this.__wbg_ptr);var t=R(e[0],e[1]).slice();return a.__wbindgen_free(e[0],e[1]*4,4),t}apply_aim(e,t,r,s,i){a.gamecore_apply_aim(this.__wbg_ptr,e,t,r,s,i)}apply_input(e,t,r,s){const i=d(r,a.__wbindgen_malloc,a.__wbindgen_realloc),o=p,c=d(s,a.__wbindgen_malloc,a.__wbindgen_realloc),l=p;a.gamecore_apply_input(this.__wbg_ptr,e,t,i,o,c,l)}body_has_events(){return a.gamecore_body_has_events(this.__wbg_ptr)!==0}clear(){a.gamecore_clear(this.__wbg_ptr)}debug_json(){let e,t;try{const r=a.gamecore_debug_json(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{a.__wbindgen_free(e,t,1)}}deserialize_state(e){const t=N(e,a.__wbindgen_malloc),r=p,s=a.gamecore_deserialize_state(this.__wbg_ptr,t,r);if(s[1])throw f(s[0])}frame_bytes(){const e=a.gamecore_frame_bytes(this.__wbg_ptr);var t=B(e[0],e[1]).slice();return a.__wbindgen_free(e[0],e[1]*1,1),t}frame_ptr(){return a.gamecore_frame_ptr(this.__wbg_ptr)>>>0}is_alive(e){return a.gamecore_is_alive(this.__wbg_ptr,e)!==0}last_input_seq(e){return a.gamecore_last_input_seq(this.__wbg_ptr,e)>>>0}load_map(e){const t=d(e,a.__wbindgen_malloc,a.__wbindgen_realloc),r=p,s=a.gamecore_load_map(this.__wbg_ptr,t,r);if(s[1])throw f(s[0])}map_info(){let e,t;try{const r=a.gamecore_map_info(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{a.__wbindgen_free(e,t,1)}}constructor(e){const t=d(e,a.__wbindgen_malloc,a.__wbindgen_realloc),r=p,s=a.gamecore_new(t,r);if(s[2])throw f(s[1]);return this.__wbg_ptr=s[0],z.register(this,this.__wbg_ptr,this),this}pack_body(){const e=a.gamecore_pack_body(this.__wbg_ptr);if(e[1])throw f(e[0])}pack_frame(e,t,r,s,i,o,c,l){var _=Pe(c)?0:d(c,a.__wbindgen_malloc,a.__wbindgen_realloc),h=p;return a.gamecore_pack_frame(this.__wbg_ptr,e,t,r,s,i,o,_,h,l)>>>0}players_data(){let e,t;try{const r=a.gamecore_players_data(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{a.__wbindgen_free(e,t,1)}}position_of(e){const t=a.gamecore_position_of(this.__wbg_ptr,e);var r=R(t[0],t[1]).slice();return a.__wbindgen_free(t[0],t[1]*4,4),r}remove_actor(e){a.gamecore_remove_actor(this.__wbg_ptr,e)}remove_players_and_shots(){let e,t;try{const r=a.gamecore_remove_players_and_shots(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{a.__wbindgen_free(e,t,1)}}remove_scripted_actor(e){a.gamecore_remove_scripted_actor(this.__wbg_ptr,e)}reset_actor(e,t,r,s,i){a.gamecore_reset_actor(this.__wbg_ptr,e,t,r,s,i)}reset_all_vitals(){a.gamecore_reset_all_vitals(this.__wbg_ptr)}serialize_state(){const e=a.gamecore_serialize_state(this.__wbg_ptr);if(e[3])throw f(e[2]);var t=B(e[0],e[1]).slice();return a.__wbindgen_free(e[0],e[1]*1,1),t}spawn_actor(e,t,r,s,i,o){const c=d(t,a.__wbindgen_malloc,a.__wbindgen_realloc),l=p,_=a.gamecore_spawn_actor(this.__wbg_ptr,e,c,l,r,s,i,o);if(_[1])throw f(_[0])}spawn_scripted_actor(e,t,r,s,i,o){const c=d(t,a.__wbindgen_malloc,a.__wbindgen_realloc),l=p,_=a.gamecore_spawn_scripted_actor(this.__wbg_ptr,e,c,l,r,s,i,o);if(_[1])throw f(_[0])}step(e){a.gamecore_step(this.__wbg_ptr,e)}take_events(){let e,t;try{const r=a.gamecore_take_events(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{a.__wbindgen_free(e,t,1)}}}Symbol.dispose&&(P.prototype[Symbol.dispose]=P.prototype.free);function G(){return{__proto__:null,"./vimp_snakes_core_bg.js":{__proto__:null,__wbg_Error_408e67f47ca7b58b:function(e,t){return Error(u(e,t))},__wbg___wbindgen_throw_bb96b2010945f0bc:function(e,t){throw new Error(u(e,t))},__wbindgen_init_externref_table:function(){const e=a.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}}}}const x=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>a.__wbg_clientcore_free(n,1)),z=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>a.__wbg_gamecore_free(n,1));function R(n,e){return n=n>>>0,Te().subarray(n/4,n/4+e)}function B(n,e){return n=n>>>0,y().subarray(n/1,n/1+e)}let b=null;function Te(){return(b===null||b.byteLength===0)&&(b=new Float32Array(a.memory.buffer)),b}function u(n,e){return Ne(n>>>0,e)}let w=null;function y(){return(w===null||w.byteLength===0)&&(w=new Uint8Array(a.memory.buffer)),w}function Pe(n){return n==null}function N(n,e){const t=e(n.length*1,1)>>>0;return y().set(n,t/1),p=n.length,t}function d(n,e,t){if(t===void 0){const c=v.encode(n),l=e(c.length,1)>>>0;return y().subarray(l,l+c.length).set(c),p=c.length,l}let r=n.length,s=e(r,1)>>>0;const i=y();let o=0;for(;o<r;o++){const c=n.charCodeAt(o);if(c>127)break;i[s+o]=c}if(o!==r){o!==0&&(n=n.slice(o)),s=t(s,r,r=o+n.length*3,1)>>>0;const c=y().subarray(s+o,s+r),l=v.encodeInto(n,c);o+=l.written,s=t(s,r,o,1)>>>0}return p=o,s}function f(n){const e=a.__wbindgen_externrefs.get(n);return a.__externref_table_dealloc(n),e}let S=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});S.decode();const Re=2146435072;let M=0;function Ne(n,e){return M+=e,M>=Re&&(S=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),S.decode(),M=e),S.decode(y().subarray(n,n+e))}const v=new TextEncoder;"encodeInto"in v||(v.encodeInto=function(n,e){const t=v.encode(n);return e.set(t),{read:n.length,written:t.length}});let p=0,a;function q(n,e){return a=n.exports,b=null,w=null,a.__wbindgen_start(),a}async function Ie(n,e){if(typeof Response=="function"&&n instanceof Response){if(!n.ok)throw new Error(`failed to fetch Wasm: ${n.status} ${n.statusText} fetching '${n.url}'`);if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(n,e)}catch(s){if(t(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",s);else throw s}const r=await n.arrayBuffer();return await WebAssembly.instantiate(r,e)}else{const r=await WebAssembly.instantiate(n,e);return r instanceof WebAssembly.Instance?{instance:r,module:n}:r}function t(r){switch(r){case"basic":case"cors":case"default":return!0}return!1}}function De(n){if(a!==void 0)return a;n!==void 0&&(Object.getPrototypeOf(n)===Object.prototype?{module:n}=n:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));const e=G();n instanceof WebAssembly.Module||(n=new WebAssembly.Module(n));const t=new WebAssembly.Instance(n,e);return q(t)}async function Oe(n){if(a!==void 0)return a;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_snakes_core_bg-C5At6odT.wasm",import.meta.url));const e=G();(typeof n=="string"||typeof Request=="function"&&n instanceof Request||typeof URL=="function"&&n instanceof URL)&&(n=fetch(n));const{instance:t,module:r}=await Ie(await n,e);return q(t)}const xe=Object.freeze(Object.defineProperty({__proto__:null,ClientCore:T,GameCore:P,default:Oe,initSync:De},Symbol.toStringTag,{value:"Module"}));export{ze as default};
|