@vimp-games/snakes 0.7.0 → 0.7.2
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/host-DDabM4t-.js +1 -0
- package/dist/manifest.json +2 -2
- package/package.json +7 -2
- package/dist/host-B6ia8Fiq.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const q=Array.from({length:16},(n,e)=>[{name:`p${e}x`,ty:"f32",interp:"lerp"},{name:`p${e}y`,ty:"f32",interp:"lerp"}]).flat(),$={s1:{id:1,kind:"indexed8",class:"hot",fields:[...q,{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"}]}},H=[{value:1,radius:8},{value:3,radius:13},{value:8,radius:20}],M={s1:{baseSpeed:260,boostFactor:1.9,turnSpeed:3.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:H,dropRatio:.8,edgeMargin:60,startCrystals:0}}},K={},B=128,I=1,X=20,N=8,C=4,x=64,Z=Math.PI*(3-Math.sqrt(5)),Q=.72;function A(n){const e=Math.ceil(Math.max(n,0)/C)*C,t=Math.max(e,N);return Math.round(X*Math.sqrt(t/N))}function J(n){const e=n*B/2,t=e;return Array.from({length:x},(r,a)=>{const o=e*Q*Math.sqrt((a+.5)/x),i=a*Z,_=t+Math.cos(i)*o,c=t+Math.sin(i)*o;return[Math.round(_),Math.round(c),Math.round(((i*180/Math.PI+180)%360+360)%360)]})}function V(n=0){const e=A(n);return{setId:"c1",scale:1,step:B,physicsStatic:[],physicsDynamic:[],layers:{1:[I]},map:Array.from({length:e},()=>Array.from({length:e},()=>I)),respawns:{players:J(e)}}}const ee=V(0),te={arena:ee},re={title:"Vimp Snakes",parts:{models:M,weapons:K,friendlyFire:!1},snapshot:$,soundCues:{roundStart:null,victory:null,defeat:null,frag:null,death:null},initialVote:"teamChange",maps:te,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}},spectatorTeam:"spectators",teams:{players:1,spectators:2},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},eaten:{key:"e",value:0},kills:{key:"k",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:""},eaten:{key:2,bodyMethod:"=",bodyValue:0,headMethod:"+",headValue:0},kills:{key:3,bodyMethod:"=",bodyValue:0,headMethod:"+",headValue:0},score:{key:4,bodyMethod:"=",bodyValue:0,headMethod:"+",headValue:0},latency:{key:5,bodyMethod:"="}},roomDefaults:{maxPlayers:32},roomForm:[{name:"maxPlayers",control:"text",label:"Max players",numeric:!0},{name:"map",control:"select",label:"Map",source:"maps"}]},ne={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:"m",text:"vote"},{keys:"<Tab>",text:"stats",last:!0}]}]},params:[{name:"model",value:"s1",options:{control:"select",label:"Snake",options:Object.keys(M),validator:"isValidModel",storage:"model"}}],validators:{isValidModel:n=>n in M}},se={pickup:{file:"shot",priority:80,volume:.35},death:{file:"death",priority:150,volume:.5}},ae={codecList:["webm","mp3"],sounds:se},ie={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}}]},componentDependencies:{soundManager:["Snake"],localPlayer:["Snake"]},sounds:ae},initIdList:["vimp","panel","chat"],modules:{canvasManager:{canvases:{vimp:{width:960,height:600,aspectRatio:"16:10",baseScale:"1:1",dynamicCamera:!0,shakeCamera:!1}}},controls:{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:["Team {0} is full. Your current team: {1}","Your team: {0}","Your new team: {0}","Your new status: spectator","{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 rank: {0}"],n:["Invalid name","{0} changed name to {1}"],g:["Bot snakes in the arena: {0}","Invalid bot count"]}}},panel:{keys:{e:"eaten",k:"kills",s:"score",c:"crystals",d:"dead",wa:"mode",t:"time"},fields:[{name:"eaten",elem:"panel-eaten",type:"value"},{name:"kills",elem:"panel-kills",type:"value"},{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:{columns:["snake","status","eaten","kills","score","ping"],heads:{1:"players"},bodies:{1:"players",2:"spectators"},sortList:{players:[[4,!0],[2,!0]]}}},vote:{params:{templates:{teamChange:["Play or watch?","teams",!0],mapChangeBySystem:["Choose the next map"],mapChangeByUser:["{0} suggested the map: {1}",["Yes","No"]]},menu:[["teamChange",["Play / watch","teams"]]]}}},gameInform:{list:["{0} WINS!","SLITHER!","GAME OVER!"]}};class oe{constructor({participants:e,coreAdapter:t,socketManager:r},a){this._participants=e,this._coreAdapter=t,this._socketManager=r,this._scriptedManager=a,this._population=null,this._size=null,this._mapData=null,this._delivered=new Map}onCoreEvent(e){!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=V(e);this._coreAdapter.createMap(r),this._scriptedManager?.createMap(r),this._mapData=r,this._delivered.clear()}this._broadcast()}_sizeFor(e){if(this._size===null)return A(e);const t=A(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)}}get mapData(){return this._mapData??null}}class _e{constructor({participants:e,coreAdapter:t,panel:r,stat:a,scripted:o}){this._participants=e,this._coreAdapter=t,this._panel=r,this._stat=a,this._model=o.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 a=0;for(let o=0;o<e&&!this._participants.isFull;o+=1){const i=t??this._pickTeam(r);if(!i||!this._hasRoom(i))break;const _=this._participants.createScripted({team:i,model:this._model}),c=this._participants.get(_);this._stat.addUser(_,c.teamId,{name:c.name,status:"",latency:"BOT"}),this._panel.addUser(_),a+=1}return a}_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(a=>a.team===e):[...t]).forEach(a=>this._remove(a.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))}}class ce{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:a}=t,o=String(e.id);switch(e.type){case"crystals":this._onCrystals(o,Number(e.gained)||0,a);break;case"death":this._onDeath(o,e,r,a);break}}reset(e){this._totals.delete(e)}_onCrystals(e,t,r){const a=this._record(e);!a||t<=0||(a.eaten+=t,a.score+=t,this._publish(e,a,r))}_onDeath(e,t,r,a){const o=this._record(e);if(!o)return;const i=t.killer===null||t.killer===void 0?null:String(t.killer);if(i!==null&&i!==e){const _=this._record(i);_&&(_.kills+=1,_.score+=o.score,this._publish(i,_,a))}this._publish(e,o,a),this._recordBest(e,o,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 a={participant:t,eaten:0,kills:0,score:0,flushedEaten:0};return this._totals.set(e,a),a}_publish(e,t,r){const{eaten:a,kills:o,score:i}=t;this._stat.updateUser(e,t.participant.teamId,{eaten:a,kills:o,score:i}),r&&(r.updateUser(e,"eaten",a,"set"),r.updateUser(e,"kills",o,"set"),r.updateUser(e,"score",i,"set"))}_recordBest(e,t,r){if(!r?.getPlayerState)return;const a=r.getPlayerState(e);if(!a)return;const o=t.eaten-t.flushedEaten;t.flushedEaten=t.eaten;const i=Math.max(Number(a.best)||0,t.score),_=(Number(a.eaten)||0)+o;r.setPlayerState(e,{...a,best:i,eaten:_})}}let L=null,U=null;function le(n){const e=new _e(n);return L=new ce(n),U=new oe(n,e),{scripted:e}}function pe(){return L}function de(){return U}const ue={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:a}=n.participants,o=Math.trunc(r),i=a>0?Math.min(o,a):o;n.scripted.removeScripted();const _=i>0?n.scripted.createScripted(i):0;n.chat.pushSystem("BOTS_SET",[_]),_>0&&n.roundManager.initiateNewRound()}},me={name:"/name",handler(n,e,t){n.roundManager.changeName(e,t.join(" "))}},he={name:"/nr",handler(n,e){n.isDevMode?n.roundManager.initiateNewRound():n.chat.pushSystemByUser(e,"COMMANDS_NOT_FOUND")}},fe={name:"/rank",handler(n,e){n.chat.pushSystemByUser(e,"RANK",[n.playerDataSync.getRank(e)])}},ge={BOTS_SET:"g:0",BOT_COUNT_INVALID:"g:1"},ye="modulepreload",be=function(n){return"/"+n},O={},we=function(e,t,r){let a=Promise.resolve();if(t&&t.length>0){let c=function(p){return Promise.all(p.map(h=>Promise.resolve(h).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),_=i?.nonce||i?.getAttribute("nonce");a=c(t.map(p=>{if(p=be(p),p in O)return;O[p]=!0;const h=p.endsWith(".css"),g=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${g}`))return;const f=document.createElement("link");if(f.rel=h?"stylesheet":ye,h||(f.as="script"),f.crossOrigin="",f.href=p,_&&f.setAttribute("nonce",_),document.head.appendChild(f),h)return new Promise((G,Y)=>{f.addEventListener("load",G),f.addEventListener("error",()=>Y(new Error(`Unable to preload CSS for ${p}`)))})}))}function o(i){const _=new Event("vite:preloadError",{cancelable:!0});if(_.payload=i,window.dispatchEvent(_),!_.defaultPrevented)throw i}return a.then(i=>{for(const _ of i||[])_.status==="rejected"&&o(_.reason);return e().catch(o)})},ve=n=>(n??"").endsWith(".js"),Se=n=>import(n),ke=()=>we(()=>Promise.resolve().then(()=>Ie),[]),Ne={id:"snakes",engineApi:3,async createCore(n,{wasmUrl:e}={}){if(ve(e)){const a=await Se(e);return new a.GameCore(n)}const{default:t,GameCore:r}=await ke();return await t({module_or_path:e}),new r(n)},gameConfig:re,authSchema:ne,chatCommands:[ue,me,he,fe],systemMessages:ge,createModules:le,buildClientGameConfig:()=>ie,onCoreEvent(n,e={}){pe()?.onCoreEvent(n,e),de()?.onCoreEvent(n)}};class E{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,z.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_clientcore_free(e,0)}apply_aim(e,t,r,a){s.clientcore_apply_aim(this.__wbg_ptr,e,t,r,a)}apply_input(e,t,r){const a=d(e,s.__wbindgen_malloc,s.__wbindgen_realloc),o=l,i=d(t,s.__wbindgen_malloc,s.__wbindgen_realloc),_=l;s.clientcore_apply_input(this.__wbg_ptr,a,o,i,_,r)}debug_json(){let e,t;try{const r=s.clientcore_debug_json(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}decode_frame(e){let t,r;try{const a=R(e,s.__wbindgen_malloc),o=l,i=s.clientcore_decode_frame(this.__wbg_ptr,a,o);return t=i[0],r=i[1],u(i[0],i[1])}finally{s.__wbindgen_free(t,r,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=P(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=d(e,s.__wbindgen_malloc,s.__wbindgen_realloc),r=l,a=s.clientcore_new(t,r);if(a[2])throw m(a[1]);return this.__wbg_ptr=a[0],z.register(this,this.__wbg_ptr,this),this}offset(){return s.clientcore_offset(this.__wbg_ptr)}push_frame(e,t){const r=R(e,s.__wbindgen_malloc),a=l;return s.clientcore_push_frame(this.__wbg_ptr,r,a,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=d(e,s.__wbindgen_malloc,s.__wbindgen_realloc),r=l,a=s.clientcore_set_map(this.__wbg_ptr,t,r);if(a[1])throw m(a[0])}set_model(e){const t=d(e,s.__wbindgen_malloc,s.__wbindgen_realloc),r=l;s.clientcore_set_model(this.__wbg_ptr,t,r)}sync_panel(e){const t=d(e,s.__wbindgen_malloc,s.__wbindgen_realloc),r=l;s.clientcore_sync_panel(this.__wbg_ptr,t,r)}take_divergence(){let e,t;try{const r=s.clientcore_take_divergence(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}take_frames(){let e,t;try{const r=s.clientcore_take_frames(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}}Symbol.dispose&&(E.prototype[Symbol.dispose]=E.prototype.free);class T{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,D.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=P(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*4,4),t}apply_aim(e,t,r,a,o){s.gamecore_apply_aim(this.__wbg_ptr,e,t,r,a,o)}apply_input(e,t,r,a){const o=d(r,s.__wbindgen_malloc,s.__wbindgen_realloc),i=l,_=d(a,s.__wbindgen_malloc,s.__wbindgen_realloc),c=l;s.gamecore_apply_input(this.__wbg_ptr,e,t,o,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 r=s.gamecore_debug_json(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}deserialize_state(e){const t=R(e,s.__wbindgen_malloc),r=l,a=s.gamecore_deserialize_state(this.__wbg_ptr,t,r);if(a[1])throw m(a[0])}frame_bytes(){const e=s.gamecore_frame_bytes(this.__wbg_ptr);var t=F(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=d(e,s.__wbindgen_malloc,s.__wbindgen_realloc),r=l,a=s.gamecore_load_map(this.__wbg_ptr,t,r);if(a[1])throw m(a[0])}map_info(){let e,t;try{const r=s.gamecore_map_info(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}constructor(e){const t=d(e,s.__wbindgen_malloc,s.__wbindgen_realloc),r=l,a=s.gamecore_new(t,r);if(a[2])throw m(a[1]);return this.__wbg_ptr=a[0],D.register(this,this.__wbg_ptr,this),this}pack_body(){const e=s.gamecore_pack_body(this.__wbg_ptr);if(e[1])throw m(e[0])}pack_frame(e,t,r,a,o,i,_,c){var p=Ce(_)?0:d(_,s.__wbindgen_malloc,s.__wbindgen_realloc),h=l;return s.gamecore_pack_frame(this.__wbg_ptr,e,t,r,a,o,i,p,h,c)>>>0}players_data(){let e,t;try{const r=s.gamecore_players_data(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}position_of(e){const t=s.gamecore_position_of(this.__wbg_ptr,e);var r=P(t[0],t[1]).slice();return s.__wbindgen_free(t[0],t[1]*4,4),r}remove_actor(e){s.gamecore_remove_actor(this.__wbg_ptr,e)}remove_players_and_shots(){let e,t;try{const r=s.gamecore_remove_players_and_shots(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[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,r,a,o){s.gamecore_reset_actor(this.__wbg_ptr,e,t,r,a,o)}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 m(e[2]);var t=F(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*1,1),t}spawn_actor(e,t,r,a,o,i){const _=d(t,s.__wbindgen_malloc,s.__wbindgen_realloc),c=l,p=s.gamecore_spawn_actor(this.__wbg_ptr,e,_,c,r,a,o,i);if(p[1])throw m(p[0])}spawn_scripted_actor(e,t,r,a,o,i){const _=d(t,s.__wbindgen_malloc,s.__wbindgen_realloc),c=l,p=s.gamecore_spawn_scripted_actor(this.__wbg_ptr,e,_,c,r,a,o,i);if(p[1])throw m(p[0])}step(e){s.gamecore_step(this.__wbg_ptr,e)}take_events(){let e,t;try{const r=s.gamecore_take_events(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}}Symbol.dispose&&(T.prototype[Symbol.dispose]=T.prototype.free);function W(){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=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 z=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>s.__wbg_clientcore_free(n,1)),D=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>s.__wbg_gamecore_free(n,1));function P(n,e){return n=n>>>0,Me().subarray(n/4,n/4+e)}function F(n,e){return n=n>>>0,y().subarray(n/1,n/1+e)}let b=null;function Me(){return(b===null||b.byteLength===0)&&(b=new Float32Array(s.memory.buffer)),b}function u(n,e){return Ee(n>>>0,e)}let w=null;function y(){return(w===null||w.byteLength===0)&&(w=new Uint8Array(s.memory.buffer)),w}function Ce(n){return n==null}function R(n,e){const t=e(n.length*1,1)>>>0;return y().set(n,t/1),l=n.length,t}function d(n,e,t){if(t===void 0){const _=v.encode(n),c=e(_.length,1)>>>0;return y().subarray(c,c+_.length).set(_),l=_.length,c}let r=n.length,a=e(r,1)>>>0;const o=y();let i=0;for(;i<r;i++){const _=n.charCodeAt(i);if(_>127)break;o[a+i]=_}if(i!==r){i!==0&&(n=n.slice(i)),a=t(a,r,r=i+n.length*3,1)>>>0;const _=y().subarray(a+i,a+r),c=v.encodeInto(n,_);i+=c.written,a=t(a,r,i,1)>>>0}return l=i,a}function m(n){const e=s.__wbindgen_externrefs.get(n);return s.__externref_table_dealloc(n),e}let S=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});S.decode();const Ae=2146435072;let k=0;function Ee(n,e){return k+=e,k>=Ae&&(S=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),S.decode(),k=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 l=0,s;function j(n,e){return s=n.exports,b=null,w=null,s.__wbindgen_start(),s}async function Te(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(a){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",a);else throw a}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 Pe(n){if(s!==void 0)return s;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=W();n instanceof WebAssembly.Module||(n=new WebAssembly.Module(n));const t=new WebAssembly.Instance(n,e);return j(t)}async function Re(n){if(s!==void 0)return s;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-3ggUM5Py.wasm",import.meta.url));const e=W();(typeof n=="string"||typeof Request=="function"&&n instanceof Request||typeof URL=="function"&&n instanceof URL)&&(n=fetch(n));const{instance:t,module:r}=await Te(await n,e);return j(t)}const Ie=Object.freeze(Object.defineProperty({__proto__:null,ClientCore:E,GameCore:T,default:Re,initSync:Pe},Symbol.toStringTag,{value:"Module"}));export{Ne as default};
|
package/dist/manifest.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "snakes",
|
|
3
3
|
"engineApi": 3,
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "110511bf53cd9307",
|
|
5
5
|
"title": "Snakes",
|
|
6
6
|
"entries": {
|
|
7
7
|
"client": "/games/snakes/client-BaQIShJH.js",
|
|
8
|
-
"host": "/games/snakes/host-
|
|
8
|
+
"host": "/games/snakes/host-DDabM4t-.js",
|
|
9
9
|
"wasm": "/games/snakes/assets/vimp_snakes_core_bg-3ggUM5Py.wasm",
|
|
10
10
|
"wasmNode": "./core-node/vimp_snakes_core.js"
|
|
11
11
|
},
|
package/package.json
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vimp-games/snakes",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "Vimp Snakes — a VIMP game plugin",
|
|
5
5
|
"author": "lgick",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+ssh://git@github.com/lgick/vimp-snakes.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/lgick/vimp-snakes#readme",
|
|
7
12
|
"type": "module",
|
|
8
13
|
"engines": {
|
|
9
14
|
"node": ">=20.11.0"
|
|
@@ -41,7 +46,7 @@
|
|
|
41
46
|
"globals": "^16.2.0",
|
|
42
47
|
"happy-dom": "^20.10.6",
|
|
43
48
|
"pixi.js": "^8.14.0",
|
|
44
|
-
"vimp-engine": "^0.
|
|
49
|
+
"vimp-engine": "^0.18.0",
|
|
45
50
|
"vite": "^7.1.11",
|
|
46
51
|
"vitest": "^4.1.9"
|
|
47
52
|
}
|
package/dist/host-B6ia8Fiq.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const q=Array.from({length:16},(n,e)=>[{name:`p${e}x`,ty:"f32",interp:"lerp"},{name:`p${e}y`,ty:"f32",interp:"lerp"}]).flat(),$={s1:{id:1,kind:"indexed8",class:"hot",fields:[...q,{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"}]}},H=[{value:1,radius:8},{value:3,radius:13},{value:8,radius:20}],M={s1:{baseSpeed:260,boostFactor:1.9,turnSpeed:3.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:H,dropRatio:.8,edgeMargin:60,startCrystals:0}}},K={},B=128,I=1,X=20,N=8,C=4,x=64,Z=Math.PI*(3-Math.sqrt(5)),Q=.72;function A(n){const e=Math.ceil(Math.max(n,0)/C)*C,t=Math.max(e,N);return Math.round(X*Math.sqrt(t/N))}function J(n){const e=n*B/2,t=e;return Array.from({length:x},(r,a)=>{const o=e*Q*Math.sqrt((a+.5)/x),i=a*Z,_=t+Math.cos(i)*o,c=t+Math.sin(i)*o;return[Math.round(_),Math.round(c),Math.round(((i*180/Math.PI+180)%360+360)%360)]})}function V(n=0){const e=A(n);return{setId:"c1",scale:1,step:B,physicsStatic:[],physicsDynamic:[],layers:{1:[I]},map:Array.from({length:e},()=>Array.from({length:e},()=>I)),respawns:{players:J(e)}}}const ee=V(0),te={arena:ee},re={title:"Vimp Snakes",parts:{models:M,weapons:K,friendlyFire:!1},snapshot:$,soundCues:{roundStart:null,victory:null,defeat:null,frag:null,death:null},initialVote:"teamChange",maps:te,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}},spectatorTeam:"spectators",teams:{players:1,spectators:2},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},eaten:{key:"e",value:0},kills:{key:"k",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:""},eaten:{key:2,bodyMethod:"=",bodyValue:0,headMethod:"+",headValue:0},kills:{key:3,bodyMethod:"=",bodyValue:0,headMethod:"+",headValue:0},score:{key:4,bodyMethod:"=",bodyValue:0,headMethod:"+",headValue:0},latency:{key:5,bodyMethod:"="}},roomDefaults:{maxPlayers:32},roomForm:[{name:"maxPlayers",control:"text",label:"Max players",numeric:!0},{name:"map",control:"select",label:"Map",source:"maps"}]},ne={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:"M",text:"vote"},{keys:"Tab",text:"stats",last:!0}]}]},params:[{name:"model",value:"s1",options:{control:"select",label:"Snake",options:Object.keys(M),validator:"isValidModel",storage:"model"}}],validators:{isValidModel:n=>n in M}},se={pickup:{file:"shot",priority:80,volume:.35},death:{file:"death",priority:150,volume:.5}},ae={codecList:["webm","mp3"],sounds:se},ie={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}}]},componentDependencies:{soundManager:["Snake"],localPlayer:["Snake"]},sounds:ae},initIdList:["vimp","panel","chat"],modules:{canvasManager:{canvases:{vimp:{width:960,height:600,aspectRatio:"16:10",baseScale:"1:1",dynamicCamera:!0,shakeCamera:!1}}},controls:{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:["Team {0} is full. Your current team: {1}","Your team: {0}","Your new team: {0}","Your new status: spectator","{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 rank: {0}"],n:["Invalid name","{0} changed name to {1}"],g:["Bot snakes in the arena: {0}","Invalid bot count"]}}},panel:{keys:{e:"eaten",k:"kills",s:"score",c:"crystals",d:"dead",wa:"mode",t:"time"},fields:[{name:"eaten",elem:"panel-eaten",type:"value"},{name:"kills",elem:"panel-kills",type:"value"},{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:{columns:["snake","status","eaten","kills","score","ping"],heads:{1:"players"},bodies:{1:"players",2:"spectators"},sortList:{players:[[4,!0],[2,!0]]}}},vote:{params:{templates:{teamChange:["Play or watch?","teams",!0],mapChangeBySystem:["Choose the next map"],mapChangeByUser:["{0} suggested the map: {1}",["Yes","No"]]},menu:[["teamChange",["Play / watch","teams"]]]}}},gameInform:{list:["{0} WINS!","SLITHER!","GAME OVER!"]}};class oe{constructor({participants:e,coreAdapter:t,socketManager:r},a){this._participants=e,this._coreAdapter=t,this._socketManager=r,this._scriptedManager=a,this._population=null,this._size=null,this._mapData=null,this._delivered=new Map}onCoreEvent(e){!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=V(e);this._coreAdapter.createMap(r),this._scriptedManager?.createMap(r),this._mapData=r,this._delivered.clear()}this._broadcast()}_sizeFor(e){if(this._size===null)return A(e);const t=A(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)}}get mapData(){return this._mapData??null}}class _e{constructor({participants:e,coreAdapter:t,panel:r,stat:a,scripted:o}){this._participants=e,this._coreAdapter=t,this._panel=r,this._stat=a,this._model=o.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 a=0;for(let o=0;o<e&&!this._participants.isFull;o+=1){const i=t??this._pickTeam(r);if(!i||!this._hasRoom(i))break;const _=this._participants.createScripted({team:i,model:this._model}),c=this._participants.get(_);this._stat.addUser(_,c.teamId,{name:c.name,status:"",latency:"BOT"}),this._panel.addUser(_),a+=1}return a}_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(a=>a.team===e):[...t]).forEach(a=>this._remove(a.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))}}class ce{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:a}=t,o=String(e.id);switch(e.type){case"crystals":this._onCrystals(o,Number(e.gained)||0,a);break;case"death":this._onDeath(o,e,r,a);break}}reset(e){this._totals.delete(e)}_onCrystals(e,t,r){const a=this._record(e);!a||t<=0||(a.eaten+=t,a.score+=t,this._publish(e,a,r))}_onDeath(e,t,r,a){const o=this._record(e);if(!o)return;const i=t.killer===null||t.killer===void 0?null:String(t.killer);if(i!==null&&i!==e){const _=this._record(i);_&&(_.kills+=1,_.score+=o.score,this._publish(i,_,a))}this._publish(e,o,a),this._recordBest(e,o,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 a={participant:t,eaten:0,kills:0,score:0,flushedEaten:0};return this._totals.set(e,a),a}_publish(e,t,r){const{eaten:a,kills:o,score:i}=t;this._stat.updateUser(e,t.participant.teamId,{eaten:a,kills:o,score:i}),r&&(r.updateUser(e,"eaten",a,"set"),r.updateUser(e,"kills",o,"set"),r.updateUser(e,"score",i,"set"))}_recordBest(e,t,r){if(!r?.getPlayerState)return;const a=r.getPlayerState(e);if(!a)return;const o=t.eaten-t.flushedEaten;t.flushedEaten=t.eaten;const i=Math.max(Number(a.best)||0,t.score),_=(Number(a.eaten)||0)+o;r.setPlayerState(e,{...a,best:i,eaten:_})}}let W=null,L=null;function le(n){const e=new _e(n);return W=new ce(n),L=new oe(n,e),{scripted:e}}function pe(){return W}function de(){return L}const ue={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:a}=n.participants,o=Math.trunc(r),i=a>0?Math.min(o,a):o;n.scripted.removeScripted();const _=i>0?n.scripted.createScripted(i):0;n.chat.pushSystem("BOTS_SET",[_]),_>0&&n.roundManager.initiateNewRound()}},me={name:"/name",handler(n,e,t){n.roundManager.changeName(e,t.join(" "))}},he={name:"/nr",handler(n,e){n.isDevMode?n.roundManager.initiateNewRound():n.chat.pushSystemByUser(e,"COMMANDS_NOT_FOUND")}},fe={name:"/rank",handler(n,e){n.chat.pushSystemByUser(e,"RANK",[n.playerDataSync.getRank(e)])}},ge={BOTS_SET:"g:0",BOT_COUNT_INVALID:"g:1"},ye="modulepreload",be=function(n){return"/"+n},O={},we=function(e,t,r){let a=Promise.resolve();if(t&&t.length>0){let c=function(p){return Promise.all(p.map(h=>Promise.resolve(h).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),_=i?.nonce||i?.getAttribute("nonce");a=c(t.map(p=>{if(p=be(p),p in O)return;O[p]=!0;const h=p.endsWith(".css"),g=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${g}`))return;const f=document.createElement("link");if(f.rel=h?"stylesheet":ye,h||(f.as="script"),f.crossOrigin="",f.href=p,_&&f.setAttribute("nonce",_),document.head.appendChild(f),h)return new Promise((G,Y)=>{f.addEventListener("load",G),f.addEventListener("error",()=>Y(new Error(`Unable to preload CSS for ${p}`)))})}))}function o(i){const _=new Event("vite:preloadError",{cancelable:!0});if(_.payload=i,window.dispatchEvent(_),!_.defaultPrevented)throw i}return a.then(i=>{for(const _ of i||[])_.status==="rejected"&&o(_.reason);return e().catch(o)})},ve=n=>(n??"").endsWith(".js"),Se=n=>import(n),ke=()=>we(()=>Promise.resolve().then(()=>Ie),[]),Ne={id:"snakes",engineApi:3,async createCore(n,{wasmUrl:e}={}){if(ve(e)){const a=await Se(e);return new a.GameCore(n)}const{default:t,GameCore:r}=await ke();return await t({module_or_path:e}),new r(n)},gameConfig:re,authSchema:ne,chatCommands:[ue,me,he,fe],systemMessages:ge,createModules:le,buildClientGameConfig:()=>ie,onCoreEvent(n,e={}){pe()?.onCoreEvent(n,e),de()?.onCoreEvent(n)}};class E{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,z.unregister(this),e}free(){const e=this.__destroy_into_raw();s.__wbg_clientcore_free(e,0)}apply_aim(e,t,r,a){s.clientcore_apply_aim(this.__wbg_ptr,e,t,r,a)}apply_input(e,t,r){const a=d(e,s.__wbindgen_malloc,s.__wbindgen_realloc),o=l,i=d(t,s.__wbindgen_malloc,s.__wbindgen_realloc),_=l;s.clientcore_apply_input(this.__wbg_ptr,a,o,i,_,r)}debug_json(){let e,t;try{const r=s.clientcore_debug_json(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}decode_frame(e){let t,r;try{const a=R(e,s.__wbindgen_malloc),o=l,i=s.clientcore_decode_frame(this.__wbg_ptr,a,o);return t=i[0],r=i[1],u(i[0],i[1])}finally{s.__wbindgen_free(t,r,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=P(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=d(e,s.__wbindgen_malloc,s.__wbindgen_realloc),r=l,a=s.clientcore_new(t,r);if(a[2])throw m(a[1]);return this.__wbg_ptr=a[0],z.register(this,this.__wbg_ptr,this),this}offset(){return s.clientcore_offset(this.__wbg_ptr)}push_frame(e,t){const r=R(e,s.__wbindgen_malloc),a=l;return s.clientcore_push_frame(this.__wbg_ptr,r,a,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=d(e,s.__wbindgen_malloc,s.__wbindgen_realloc),r=l,a=s.clientcore_set_map(this.__wbg_ptr,t,r);if(a[1])throw m(a[0])}set_model(e){const t=d(e,s.__wbindgen_malloc,s.__wbindgen_realloc),r=l;s.clientcore_set_model(this.__wbg_ptr,t,r)}sync_panel(e){const t=d(e,s.__wbindgen_malloc,s.__wbindgen_realloc),r=l;s.clientcore_sync_panel(this.__wbg_ptr,t,r)}take_divergence(){let e,t;try{const r=s.clientcore_take_divergence(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}take_frames(){let e,t;try{const r=s.clientcore_take_frames(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}}Symbol.dispose&&(E.prototype[Symbol.dispose]=E.prototype.free);class T{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,D.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=P(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*4,4),t}apply_aim(e,t,r,a,o){s.gamecore_apply_aim(this.__wbg_ptr,e,t,r,a,o)}apply_input(e,t,r,a){const o=d(r,s.__wbindgen_malloc,s.__wbindgen_realloc),i=l,_=d(a,s.__wbindgen_malloc,s.__wbindgen_realloc),c=l;s.gamecore_apply_input(this.__wbg_ptr,e,t,o,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 r=s.gamecore_debug_json(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}deserialize_state(e){const t=R(e,s.__wbindgen_malloc),r=l,a=s.gamecore_deserialize_state(this.__wbg_ptr,t,r);if(a[1])throw m(a[0])}frame_bytes(){const e=s.gamecore_frame_bytes(this.__wbg_ptr);var t=F(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=d(e,s.__wbindgen_malloc,s.__wbindgen_realloc),r=l,a=s.gamecore_load_map(this.__wbg_ptr,t,r);if(a[1])throw m(a[0])}map_info(){let e,t;try{const r=s.gamecore_map_info(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}constructor(e){const t=d(e,s.__wbindgen_malloc,s.__wbindgen_realloc),r=l,a=s.gamecore_new(t,r);if(a[2])throw m(a[1]);return this.__wbg_ptr=a[0],D.register(this,this.__wbg_ptr,this),this}pack_body(){const e=s.gamecore_pack_body(this.__wbg_ptr);if(e[1])throw m(e[0])}pack_frame(e,t,r,a,o,i,_,c){var p=Ce(_)?0:d(_,s.__wbindgen_malloc,s.__wbindgen_realloc),h=l;return s.gamecore_pack_frame(this.__wbg_ptr,e,t,r,a,o,i,p,h,c)>>>0}players_data(){let e,t;try{const r=s.gamecore_players_data(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}position_of(e){const t=s.gamecore_position_of(this.__wbg_ptr,e);var r=P(t[0],t[1]).slice();return s.__wbindgen_free(t[0],t[1]*4,4),r}remove_actor(e){s.gamecore_remove_actor(this.__wbg_ptr,e)}remove_players_and_shots(){let e,t;try{const r=s.gamecore_remove_players_and_shots(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[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,r,a,o){s.gamecore_reset_actor(this.__wbg_ptr,e,t,r,a,o)}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 m(e[2]);var t=F(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*1,1),t}spawn_actor(e,t,r,a,o,i){const _=d(t,s.__wbindgen_malloc,s.__wbindgen_realloc),c=l,p=s.gamecore_spawn_actor(this.__wbg_ptr,e,_,c,r,a,o,i);if(p[1])throw m(p[0])}spawn_scripted_actor(e,t,r,a,o,i){const _=d(t,s.__wbindgen_malloc,s.__wbindgen_realloc),c=l,p=s.gamecore_spawn_scripted_actor(this.__wbg_ptr,e,_,c,r,a,o,i);if(p[1])throw m(p[0])}step(e){s.gamecore_step(this.__wbg_ptr,e)}take_events(){let e,t;try{const r=s.gamecore_take_events(this.__wbg_ptr);return e=r[0],t=r[1],u(r[0],r[1])}finally{s.__wbindgen_free(e,t,1)}}}Symbol.dispose&&(T.prototype[Symbol.dispose]=T.prototype.free);function U(){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=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 z=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>s.__wbg_clientcore_free(n,1)),D=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>s.__wbg_gamecore_free(n,1));function P(n,e){return n=n>>>0,Me().subarray(n/4,n/4+e)}function F(n,e){return n=n>>>0,y().subarray(n/1,n/1+e)}let b=null;function Me(){return(b===null||b.byteLength===0)&&(b=new Float32Array(s.memory.buffer)),b}function u(n,e){return Ee(n>>>0,e)}let w=null;function y(){return(w===null||w.byteLength===0)&&(w=new Uint8Array(s.memory.buffer)),w}function Ce(n){return n==null}function R(n,e){const t=e(n.length*1,1)>>>0;return y().set(n,t/1),l=n.length,t}function d(n,e,t){if(t===void 0){const _=v.encode(n),c=e(_.length,1)>>>0;return y().subarray(c,c+_.length).set(_),l=_.length,c}let r=n.length,a=e(r,1)>>>0;const o=y();let i=0;for(;i<r;i++){const _=n.charCodeAt(i);if(_>127)break;o[a+i]=_}if(i!==r){i!==0&&(n=n.slice(i)),a=t(a,r,r=i+n.length*3,1)>>>0;const _=y().subarray(a+i,a+r),c=v.encodeInto(n,_);i+=c.written,a=t(a,r,i,1)>>>0}return l=i,a}function m(n){const e=s.__wbindgen_externrefs.get(n);return s.__externref_table_dealloc(n),e}let S=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});S.decode();const Ae=2146435072;let k=0;function Ee(n,e){return k+=e,k>=Ae&&(S=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),S.decode(),k=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 l=0,s;function j(n,e){return s=n.exports,b=null,w=null,s.__wbindgen_start(),s}async function Te(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(a){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",a);else throw a}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 Pe(n){if(s!==void 0)return s;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=U();n instanceof WebAssembly.Module||(n=new WebAssembly.Module(n));const t=new WebAssembly.Instance(n,e);return j(t)}async function Re(n){if(s!==void 0)return s;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-3ggUM5Py.wasm",import.meta.url));const e=U();(typeof n=="string"||typeof Request=="function"&&n instanceof Request||typeof URL=="function"&&n instanceof URL)&&(n=fetch(n));const{instance:t,module:r}=await Te(await n,e);return j(t)}const Ie=Object.freeze(Object.defineProperty({__proto__:null,ClientCore:E,GameCore:T,default:Re,initSync:Pe},Symbol.toStringTag,{value:"Module"}));export{Ne as default};
|