1"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([[1410],{1716:(s,l,e)=>{e.r(l),e.d(l,{assets:()=>t,contentTitle:()=>F,default:()=>p,frontMatter:()=>i,metadata:()=>n,toc:()=>d});const n=JSON.parse('{"id":"intro/tutorials/unreal-tutorial/part-4","title":"4 - Moving and Colliding","description":"Need help with the tutorial? Join our Discord server!","source":"@site/versioned_docs/version-1.12.0/00100-intro/00300-tutorials/00400-unreal-tutorial/00500-part-4.md","sourceDirName":"00100-intro/00300-tutorials/00400-unreal-tutorial","slug":"/tutorials/unreal/part-4","permalink":"/docs/1.12.0/tutorials/unreal/part-4","draft":false,"unlisted":false,"editUrl":"https://github.com/clockworklabs/SpacetimeDB/edit/master/docs/versioned_docs/version-1.12.0/00100-intro/00300-tutorials/00400-unreal-tutorial/00500-part-4.md","tags":[],"version":"1.12.0","sidebarPosition":500,"frontMatter":{"title":"4 - Moving and Colliding","slug":"/tutorials/unreal/part-4"},"sidebar":"sidebar","previous":{"title":"3 - Gameplay","permalink":"/docs/1.12.0/tutorials/unreal/part-3"},"next":{"title":"The Database Module","permalink":"/docs/1.12.0/databases"}}');var c=e(86106),r=e(56225),o=e(51471),a=e(43244);const i={title:"4 - Moving and Colliding",slug:"/tutorials/unreal/part-4"},F=void 0,t={},d=[{value:"Moving the player",id:"moving-the-player",level:3},{value:"Moving on the Client",id:"moving-on-the-client",level:3},{value:"Collisions and Eating Food",id:"collisions-and-eating-food",level:3},{value:"Connecting to Maincloud",id:"connecting-to-maincloud",level:2},{value:"Conclusion",id:"conclusion",level:2}];function h(s){const l={a:"a",admonition:"admonition",br:"br",code:"code",h2:"h2",h3:"h3",img:"img",li:"li",p:"p",pre:"pre",span:"span",strong:"strong",ul:"ul",...(0,r.R)(),...s.components};return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)(l.p,{children:["Need help with the tutorial? ",(0,c.jsx)(l.a,{href:"https://discord.gg/spacetimedb",children:"Join our Discord server"}),"!"]}),"\n",(0,c.jsxs)(l.p,{children:["This progressive tutorial is continued from ",(0,c.jsx)(l.a,{href:"/docs/1.12.0/tutorials/unreal/part-3",children:"part 3"}),"."]}),"\n",(0,c.jsx)(l.h3,{id:"moving-the-player",children:"Moving the player"}),"\n",(0,c.jsx)(l.p,{children:"At this point, we're very close to having a working game. All we have to do is modify our server to allow the player to move around, and to simulate the physics and collisions of the game."}),"\n",(0,c.jsxs)(o.A,{groupId:"server-language",defaultValue:"rust",children:[(0,c.jsxs)(a.A,{value:"csharp",label:"C#",children:[(0,c.jsxs)(l.p,{children:["Let's start by building out a simple math library to help us do collision calculations. Create a new ",(0,c.jsx)(l.code,{children:"Math.cs"})," file in the ",(0,c.jsx)(l.code,{children:"csharp-server"})," directory and add the following contents. Let's also remove the ",(0,c.jsx)(l.code,{children:"DbVector2"})," type from ",(0,c.jsx)(l.code,{children:"Lib.cs"}),"."]}),(0,c.jsx)(c.Fragment,{children:(0,c.jsx)(l.pre,{className:"shiki spacetime-dark",style:{backgroundColor:"var(--clockworklabs-code-background-color)",color:"#F8F8F2"},tabIndex:"0",children:(0,c.jsxs)(l.code,{children:[(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"["}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"SpacetimeDB"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"Type"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"]"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"public"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" partial"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" struct"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"{"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" public"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" float"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" x;"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" public"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" float"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" y;"})]}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" public"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"float"}),(0,c.jsx)(l.span,{style:{color:"#FFB86C",fontStyle:"italic"},children:" x"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"float"}),(0,c.jsx)(l.span,{style:{color:"#FFB86C",fontStyle:"italic"},children:" y"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:")"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" this"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:".x "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" x;"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" this"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:".y "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" y;"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" public"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" float"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" SqrMagnitude "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"=>"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" x "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"*"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" x "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"+"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" y "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"*"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" y;"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" public"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" float"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" Magnitude "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"=>"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" MathF."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Sqrt"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(SqrMagnitude);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" public"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" Normalized "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"=>"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" this"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" /"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" Magnitude;"})]}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" public"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" static"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" operator"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" +"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#FFB86C",fontStyle:"italic"},children:" a"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", "}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#FFB86C",fontStyle:"italic"},children:" b"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:") "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"=>"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" new"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(a.x "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"+"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" b.x, a.y "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"+"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" b.y);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" public"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" static"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" operator"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" -"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#FFB86C",fontStyle:"italic"},children:" a"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", "}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#FFB86C",fontStyle:"italic"},children:" b"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:") "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"=>"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" new"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(a.x "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"-"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" b.x, a.y "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"-"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" b.y);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" public"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" static"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" operator"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" *"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#FFB86C",fontStyle:"italic"},children:" a"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"float"}),(0,c.jsx)(l.span,{style:{color:"#FFB86C",fontStyle:"italic"},children:" b"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:") "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"=>"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" new"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(a.x "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"*"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" b, a.y "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"*"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" b);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" public"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" static"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" operator"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" /"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#FFB86C",fontStyle:"italic"},children:" a"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"float"}),(0,c.jsx)(l.span,{style:{color:"#FFB86C",fontStyle:"italic"},children:" b"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:") "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"=>"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" new"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(a.x "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"/"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" b, a.y "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"/"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" b);"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"}"})})]})})}),(0,c.jsxs)(l.p,{children:["Next, add the following reducer to the ",(0,c.jsx)(l.code,{children:"Module"})," class of your ",(0,c.jsx)(l.code,{children:"Lib.cs"})," file."]}),(0,c.jsx)(c.Fragment,{children:(0,c.jsx)(l.pre,{className:"shiki spacetime-dark",style:{backgroundColor:"var(--clockworklabs-code-background-color)",color:"#F8F8F2"},tabIndex:"0",children:(0,c.jsxs)(l.code,{children:[(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"["}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"Reducer"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"]"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"public"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" static"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" void"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" UpdatePlayerInput"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"ReducerContext"}),(0,c.jsx)(l.span,{style:{color:"#FFB86C",fontStyle:"italic"},children:" ctx"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", "}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#FFB86C",fontStyle:"italic"},children:" direction"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:")"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"{"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" var"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" player "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx.Db.player.identity."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Find"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(ctx.Sender) "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"??"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" throw"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" new"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" Exception"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#E9F284"},children:'"'}),(0,c.jsx)(l.span,{style:{color:"#F1FA8C"},children:"Player not found"}),(0,c.jsx)(l.span,{style:{color:"#E9F284"},children:'"'}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:");"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" foreach"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ("}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"var"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" c "}),(0,c
1.jsx)(l.span,{style:{color:"#FF79C6"},children:"in"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx.Db.circle.player_id."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Filter"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(player.player_id))"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" var"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" c;"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle.direction "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" direction.Normalized;"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle.speed "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" Math."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Clamp"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(direction.Magnitude, "}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:"0f"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", "}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:"1f"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:");"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx.Db.circle.entity_id."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Update"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(circle);"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"}"})})]})})}),(0,c.jsxs)(l.p,{children:["This is a simple reducer that takes the movement input from the client and applies them to all circles that that player controls. Note that it is not possible for a player to move another player's circles using this reducer, because the ",(0,c.jsx)(l.code,{children:"ctx.Sender"})," value is not set by the client. Instead ",(0,c.jsx)(l.code,{children:"ctx.Sender"})," is set by SpacetimeDB after it has authenticated that sender. You can rest assured that the caller has been authenticated as that player by the time this reducer is called."]})]}),(0,c.jsxs)(a.A,{value:"rust",label:"Rust",children:[(0,c.jsxs)(l.p,{children:["Let's start by building out a simple math library to help us do collision calculations. Create a new ",(0,c.jsx)(l.code,{children:"math.rs"})," file in the ",(0,c.jsx)(l.code,{children:"blackholio/spacetimedb/src"})," directory and add the following contents. Let's also move the ",(0,c.jsx)(l.code,{children:"DbVector2"})," type from ",(0,c.jsx)(l.code,{children:"lib.rs"})," into this file."]}),(0,c.jsx)(c.Fragment,{children:(0,c.jsx)(l.pre,{className:"shiki spacetime-dark",style:{backgroundColor:"var(--clockworklabs-code-background-color)",color:"#F8F8F2"},tabIndex:"0",children:(0,c.jsxs)(l.code,{children:[(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"use"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" spacetimedb"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"SpacetimeType"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:";"})]}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#6272A4"},children:"// This allows us to store 2D points in tables."})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"#[derive("}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"SpacetimeType"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", "}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"Debug"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", "}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"Clone"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", "}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"Copy"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:")]"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"pub"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" struct"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" pub"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" x"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" f32"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:","})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" pub"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" y"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" f32"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:","})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"}"})}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"impl"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" std"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"ops"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"Add"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"<"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"&"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"> "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"for"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" type"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" Output"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ="}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:";"})]}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" fn"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" add"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:"self"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", other"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" &"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:") "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"->"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" x"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" self"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"x "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"+"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" other"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"x,"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" y"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" self"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"y "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"+"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" other"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"y,"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"}"})}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"impl"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" std"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"ops"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"Add"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"<"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"> "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"for"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" type"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" Output"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ="}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:";"})]}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" fn"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" add"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:"self"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", other"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:") "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"->"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" x"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" self"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"x "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"+"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" other"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"x,"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" y"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" self"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"y "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"+"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" other"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"y,"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"}"})}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"impl"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" std"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"ops"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"AddAssign"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"<"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"> "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"for"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" fn"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" add_assign"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"&mut"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" self"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", rhs"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:") {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" self"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"x "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"+="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" rhs"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"x;"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" self"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"y "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"+="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" rhs"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"y;"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"}"})}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)
1(l.span,{style:{color:"#FF79C6"},children:"impl"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" std"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"iter"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"Sum"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"<"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"> "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"for"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" fn"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" sum"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"<"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"I"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" Iterator"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"<"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"Item"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ="}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:">>(iter"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" I"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:") "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"->"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" Self"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" let"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" mut"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" r "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"new"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:"0.0"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", "}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:"0.0"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:");"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" for"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" val "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"in"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" iter {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" r "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"+="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" val;"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" r"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"}"})}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"impl"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" std"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"ops"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"Sub"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"<"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"&"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"> "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"for"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" type"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" Output"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ="}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:";"})]}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" fn"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" sub"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:"self"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", other"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" &"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:") "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"->"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" x"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" self"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"x "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"-"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" other"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"x,"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" y"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" self"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"y "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"-"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" other"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"y,"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"}"})}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"impl"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" std"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"ops"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"Sub"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"<"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"> "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"for"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" type"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" Output"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ="}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:";"})]}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" fn"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" sub"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:"self"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", other"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:") "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"->"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" x"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" self"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"x "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"-"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" other"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"x,"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" y"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" self"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"y "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"-"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" other"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"y,"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"}"})}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"impl"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" std"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"ops"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"SubAssign"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"<"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"> "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"for"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" fn"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" sub_assign"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"&mut"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" self"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", rhs"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:") {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" self"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"x "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"-="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" rhs"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"x;"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" self"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"y "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"-="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" rhs"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"y;"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"}"})}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"impl"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" std"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"ops"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"Mul"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"<"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"f32"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"> "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"for"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" type"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" Output"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ="}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:";"})]}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" fn"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" mul"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:"self"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", other"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" f32"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:") "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"->"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children
1:[(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" x"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" self"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"x "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"*"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" other,"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" y"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" self"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"y "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"*"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" other,"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"}"})}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"impl"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" std"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"ops"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"Div"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"<"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"f32"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"> "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"for"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" type"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" Output"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ="}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:";"})]}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" fn"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" div"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:"self"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", other"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" f32"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:") "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"->"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" if"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" other "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"!="}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" 0.0"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" x"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" self"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"x "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"/"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" other,"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" y"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" self"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"y "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"/"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" other,"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" } "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"else"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" { x"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" 0.0"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", y"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" 0.0"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"}"})}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"impl"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" pub"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" fn"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" new"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(x"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" f32"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", y"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" f32"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:") "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"->"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" Self"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" Self"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" { x, y }"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" pub"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" fn"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" sqr_magnitude"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"&"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:"self"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:") "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"->"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" f32"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" self"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"x "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"*"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" self"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"x "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"+"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" self"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"y "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"*"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" self"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"y"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" pub"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" fn"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" magnitude"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"&"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:"self"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:") "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"->"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" f32"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ("}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:"self"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"x "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"*"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" self"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"x "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"+"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" self"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"y "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"*"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" self"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"y)"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"sqrt"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"}
1,children:"()"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" pub"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" fn"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" normalized"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:"self"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:") "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"->"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" self"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" /"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9",fontStyle:"italic"},children:" self"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"magnitude"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"}"})})]})})}),(0,c.jsxs)(l.p,{children:["At the very top of ",(0,c.jsx)(l.code,{children:"lib.rs"})," add the following lines to import the moved ",(0,c.jsx)(l.code,{children:"DbVector2"})," from the ",(0,c.jsx)(l.code,{children:"math"})," module."]}),(0,c.jsx)(c.Fragment,{children:(0,c.jsx)(l.pre,{className:"shiki spacetime-dark",style:{backgroundColor:"var(--clockworklabs-code-background-color)",color:"#F8F8F2"},tabIndex:"0",children:(0,c.jsxs)(l.code,{children:[(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"pub"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" mod"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" math;"})]}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"use"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" math"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:";"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#6272A4"},children:"// ..."})})]})})}),(0,c.jsxs)(l.p,{children:["Next, add the following reducer to your ",(0,c.jsx)(l.code,{children:"lib.rs"})," file."]}),(0,c.jsx)(c.Fragment,{children:(0,c.jsx)(l.pre,{className:"shiki spacetime-dark",style:{backgroundColor:"var(--clockworklabs-code-background-color)",color:"#F8F8F2"},tabIndex:"0",children:(0,c.jsxs)(l.code,{children:[(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"#[spacetimedb"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"reducer]"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"pub"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" fn"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" update_player_input"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(ctx"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" &"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"ReducerContext"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", direction"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" DbVector2"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:") "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"->"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" Result"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"<(), "}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"String"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"> {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" let"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" player "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"db"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"player"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"}
1,children:"()"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"identity"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"find"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"&"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"ctx"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"sender)"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"ok_or"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#F1FA8C"},children:'"Player not found"'}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:")"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"?"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:";"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" for"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" mut"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"in"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"db"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"circle"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"player_id"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"filter"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"&"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"player"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"player_id) {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"direction "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" direction"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"normalized"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"();"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"speed "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" direction"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"magnitude"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"clamp"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:"0.0"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", "}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:"1.0"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:");"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"db"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"circle"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"}
1,children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"entity_id"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"update"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(circle);"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" Ok"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(())"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"}"})})]})})}),(0,c.jsxs)(l.p,{children:["This is a simple reducer that takes the movement input from the client and applies them to all circles that that player controls. Note that it is not possible for a player to move another player's circles using this reducer, because the ",(0,c.jsx)(l.code,{children:"ctx.sender"})," value is not set by the client. Instead ",(0,c.jsx)(l.code,{children:"ctx.sender"})," is set by SpacetimeDB after it has authenticated that sender. You can rest assured that the caller has been authenticated as that player by the time this reducer is called."]})]})]}),"\n",(0,c.jsx)(l.p,{children:"Finally, let's schedule a reducer to run every 50 milliseconds to move the player's circles around based on the most recently set player input."}),"\n",(0,c.jsxs)(o.A,{groupId:"server-language",defaultValue:"rust",children:[(0,c.jsx)(a.A,{value:"csharp",label:"C#",children:(0,c.jsx)(c.Fragment,{children:(0,c.jsx)(l.pre,{className:"shiki spacetime-dark",style:{backgroundColor:"var(--clockworklabs-code-background-color)",color:"#F8F8F2"},tabIndex:"0",children:(0,c.jsxs)(l.code,{children:[(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"["}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"Table"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(Name "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#E9F284"},children:' "'}),(0,c.jsx)(l.span,{style:{color:"#F1FA8C"},children:"move_all_players_timer"}),(0,c.jsx)(l.span,{style:{color:"#E9F284"},children:'"'}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", Scheduled "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" nameof"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"}
1,children:"(MoveAllPlayers), ScheduledAt "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" nameof"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(scheduled_at))]"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"public"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" partial"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" struct"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" MoveAllPlayersTimer"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"{"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ["}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"PrimaryKey"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", "}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"AutoInc"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"]"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" public"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ulong"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" scheduled_id;"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" public"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" ScheduleAt"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" scheduled_at;"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"}"})}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"const"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" int"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" START_PLAYER_SPEED "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" 10"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:";"})]}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"public"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" static"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" float"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" MassToMaxMoveSpeed"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"int"}),(0,c.jsx)(l.span,{style:{color:"#FFB86C",fontStyle:"italic"},children:" mass"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:") "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"=>"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" 2f"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" *"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" START_PLAYER_SPEED "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"/"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ("}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:"1f"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" +"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" MathF."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Sqrt"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(("}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"float"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:")mass "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"/"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" START_PLAYER_MASS));"})]}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"["}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"Reducer"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"]"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"public"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" static"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" void"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" MoveAllPlayers"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"ReducerContext"}),(0,c.jsx)(l.span,{style:{color:"#FFB86C",fontStyle:"italic"},children:" ctx"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", "}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"MoveAllPlayersTimer"}),(0,c.jsx)(l.span,{style:{color:"#FFB86C",fontStyle:"italic"},children:" timer"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:")"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"{"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" var"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" world_size "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" (ctx.Db.config.id."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Find"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:"0"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:") "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"??"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" throw"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" new"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" Exception"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#E9F284"},children:'"'}),(0,c.jsx)(l.span,{style:{color:"#F1FA8C"},children:"Config not found"}),(0,c.jsx)(l.span,{style:{color:"#E9F284"},children:'"'}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:")).world_size;"})]}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" var"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_directions "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx.Db.circle."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Iter"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"}
1,children:"()."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Select"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#FFB86C",fontStyle:"italic"},children:"c"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" =>"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" (c.entity_id, c.direction "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"*"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" c.speed))."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"ToDictionary"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"();"})]}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#6272A4"},children:" // Handle player input"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" foreach"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ("}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"var"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"in"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx.Db.circle."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Iter"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"())"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" var"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" check_entity "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx.Db.entity.entity_id."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Find"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(circle.entity_id);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" if"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"}
1,children:" (check_entity "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"=="}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" null"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:")"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#6272A4"},children:" // This can happen if the circle has been eaten by another circle."})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" continue"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:";"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" var"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_entity "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" check_entity.Value;"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" var"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_radius "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" MassToRadius"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(circle_entity.mass);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" var"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" direction "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_directions[circle.entity_id];"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" var"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" new_pos "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_entity.position "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"+"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" direction "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"*"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" MassToMaxMoveSpeed"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(circle_entity.mass);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_entity.position.x "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" Math."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Clamp"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(new_pos.x, circle_radius, world_size "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"-"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_radius);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_entity.position.y "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" Math."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Clamp"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(new_pos.y, circle_radius, world_size "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"-"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_radius);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx.Db.entity.entity_id."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Update"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(circle_entity);"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"}"})})]})})})}),(0,c.jsx)(a.A,{value:"rust",label:"Rust",children:(0,c.jsx)(c.Fragment,{children:(0,c.jsx)(l.pre,{className:"shiki spacetime-dark",style:{backgroundColor:"var(--clockworklabs-code-background-color)",color:"#F8F8F2"},tabIndex:"0",children:(0,c.jsxs)(l.code,{children:[(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"#[spacetimedb"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"table(name "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" move_all_players_timer, scheduled(move_all_players))]"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"pub"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" struct"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" MoveAllPlayersTimer"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" #[primary_key]"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" #[auto_inc]"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" scheduled_id"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" u64"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:","})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" scheduled_at"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" spacetimedb"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"ScheduleAt"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:","})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"}"})}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"const"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" START_PLAYER_SPEED"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" i32"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ="}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" 10"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:";"})]}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"fn"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" mass_to_max_move_speed"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(mass"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" i32"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:") "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"->"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" f32"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" 2.0"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" *"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" START_PLAYER_SPEED"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" as"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" f32"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" /"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ("}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:"1.0"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" +"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" (mass "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"as"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" f32"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" /"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" START_PLAYER_MASS"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" as"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" f32"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:")"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"sqrt"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"}
1,children:"())"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"}"})}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"#[spacetimedb"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"reducer]"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"pub"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" fn"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" move_all_players"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(ctx"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" &"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"ReducerContext"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", _timer"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" MoveAllPlayersTimer"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:") "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"->"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" Result"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"<(), "}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"String"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"> {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" let"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" world_size "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"db"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"config"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"id"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"find"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:"0"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:")"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"ok_or"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#F1FA8C"},children:'"Config not found"'}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:")"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"?"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"world_size;"})]}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#6272A4"},children:" // Handle player input"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" for"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"in"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"db"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"circle"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"}
1,children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"iter"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"() {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" let"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_entity "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"db"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"entity"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"entity_id"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"find"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"&"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"circle"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"entity_id);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" if"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" !"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"circle_entity"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"is_some"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"() {"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#6272A4"},children:" // This can happen if a circle is eaten by another circle"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" continue"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:";"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" let"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" mut"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_entity "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_entity"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"unwrap"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"();"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" let"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_radius "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" mass_to_radius"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(circle_entity"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"mass);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" let"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" direction "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"direction "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"*"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"speed;"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" let"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" new_pos "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_entity"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"position "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"+"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" direction "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"*"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" mass_to_max_move_speed"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(circle_entity"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"mass);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" let"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" min "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_radius;"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" let"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" max "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" world_size "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"as"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" f32"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" -"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_radius;"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_entity"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"position"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"x "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" new_pos"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"x"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"clamp"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(min, max);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_entity"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"position"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"y "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" new_pos"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"y"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"clamp"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(min, max);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"db"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"entity"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"}
1,children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"entity_id"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"update"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(circle_entity);"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" Ok"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(())"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"}"})})]})})})})]}),"\n",(0,c.jsxs)(l.p,{children:['This reducer is very similar to a standard game "tick" or "frame" that you might find in an ordinary game server or similar to something like the ',(0,c.jsx)(l.code,{children:"Tick"})," loop in a game engine like Unreal. We've scheduled it every 50 milliseconds and we can use it to step forward our simulation by moving all the circles a little bit further in the direction they're moving."]}),"\n",(0,c.jsx)(l.p,{children:"In this reducer, we're just looping through all the circles in the game and updating their position based on their direction, speed, and mass. Just basic physics."}),"\n",(0,c.jsxs)(o.A,{groupId:"server-language",defaultValue:"rust",children:[(0,c.jsxs)(a.A,{value:"csharp",label:"C#",children:[(0,c.jsxs)(l.p,{children:["Add the following to your ",(0,c.jsx)(l.code,{children:"Init"})," reducer to schedule the ",(0,c.jsx)(l.code,{children:"MoveAllPlayers"})," reducer to run every 50 milliseconds."]}),(0,c.jsx)(c.Fragment,{children:(0,c.jsx)(l.pre,{className:"shiki spacetime-dark",style:{backgroundColor:"var(--clockworklabs-code-background-color)",color:"#F8F8F2"},tabIndex:"0",children:(0,c.jsxs)(l.code,{children:[(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"ctx.Db.move_all_players_timer."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Insert"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"new"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" MoveAllPlayersTimer"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"{"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" scheduled_at "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" new"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" ScheduleAt"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"Interval"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(TimeSpan."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"FromMilliseconds"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:"50"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"))"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"});"})})]})})})]}),(0,c.jsxs)(a.A,{value:"rust",label:"Rust",children:[(0,c.jsxs)(l.p,{children:["Add the following to your ",(0,c.jsx)(l.code,{children:"init"})," reducer to schedule the ",(0,c.jsx)(l.code,{children:"move_all_players"})," reducer to run every 50 milliseconds."]}),(0,c.jsx)(c.Fragment,{children:(0,c.jsx)(l.pre,{className:"shiki spacetime-dark",style:{backgroundColor:"var(--clockworklabs-code-background-color)",color:"#F8F8F2"},tabIndex:"0",children:(0,c.jsxs)(l.code,{children:[(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"ctx"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"db"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"move_all_players_timer"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"}
1,children:"()"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"try_insert"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"MoveAllPlayersTimer"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" scheduled_id"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" 0"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:","})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" scheduled_at"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ScheduleAt"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Interval"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(Duration"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"from_millis"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:"50"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:")"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"into"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()),"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" })"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"?"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:";"})]})]})})})]})]}),"\n",(0,c.jsx)(l.p,{children:"Republish your module with:"}),"\n",(0,c.jsx)(c.Fragment,{children:(0,c.jsx)(l.pre,{className:"shiki spacetime-dark",style:{backgroundColor:"var(--clockworklabs-code-background-color)",color:"#F8F8F2"},tabIndex:"0",children:(0,c.jsx)(l.code,{children:(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"spacetime"}),(0,c.jsx)(l.span,{style:{color:"#F1FA8C"},children:" publish"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" --server"}),(0,c.jsx)(l.span,{style:{color:"#F1FA8C"},children:" local"}),(0,c.jsx)(l.span,{style:{color:"#F1FA8C"},children:" blackholio"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" --delete-data"})]})})})}),"\n",(0,c.jsx)(l.p,{children:"Regenerate your server bindings with:"}),"\n",(0,c.jsx)(c.Fragment,{children:(0,c.jsx)(l.pre,{className:"shiki spacetime-dark",style:{backgroundColor:"var(--clockworklabs-code-background-color)",color:"#F8F8F2"},tabIndex:"0",children:(0,c.jsx)(l.code,{children:(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"spacetime"}),(0,c.jsx)(l.span,{style:{color:"#F1FA8C"},children:" generate"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" --lang"}),(0,c.jsx)(l.span,{style:{color:"#F1FA8C"},children:" unrealcpp"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" --uproject-dir"}),(0,c.jsx)(l.span,{style:{color:"#F1FA8C"},children:" .."}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" --module-name"}),(0,c.jsx)(l.span,{style:{color:"#F1FA8C"},children:" blackholio"})]})})})}),"\n",(0,c.jsx)(l.h3,{id:"moving-on-the-client",children:"Moving on the Client"}),"\n",(0,c.jsxs)(o.A,{groupId:"client-language",defaultValue:"cpp",children:[(0,c.jsxs)(a.A,{value:"cpp",label:"C++",children:[(0,c.jsxs)(l.p,{children:["The final step is to update ",(0,c.jsx)(l.code,{children:"BlackholioPlayerController"})," on the client to call the ",(0,c.jsx)(l.code,{children:"update_player_input"})," reducer.",(0,c.jsx)(l.br,{}),"\n","Open ",(0,c.jsx)(l.code,{children:"BlackholioPlayerController.cpp"})," and replace the stubbed function added earlier with the following:"]}),(0,c.jsx)(c.Fragment,{children:(0,c.jsx)(l.pre,{className:"shiki spacetime-dark",style:{backgroundColor:"var(--clockworklabs-code-background-color)",color:"#F8F8F2"},tabIndex:"0",children:(0,c.jsxs)(l.code,{children:[(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"FVector2D"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ABlackholioPlayerController"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"ComputeDesiredDirection"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"}
1,children:"() "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"const"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"{"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" int32 SizeX "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" 0"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", SizeY "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" 0"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:";"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" GetViewportSize"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(SizeX, SizeY);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" if"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" (SizeX "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"<="}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" 0"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ||"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" SizeY "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"<="}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" 0"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:")"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" return"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" FVector2D"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"ZeroVector;"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" const"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" FVector2D "}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"ViewportCenter"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"static_cast<float>"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(SizeX) "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"*"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" 0.5"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"f"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"static_cast<float>"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(SizeY) "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"*"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" 0.5"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"f"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:");"})]}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" FVector2D MousePos "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ViewportCenter;"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" if"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ("}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"!"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"LockInputPosition."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"IsSet"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"())"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" float"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" MouseX "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" 0."}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"f"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", MouseY "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" 0."}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"f"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:";"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" if"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ("}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"!"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"GetMousePosition"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"}
1,children:"(MouseX, MouseY))"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" return"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" FVector2D"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"ZeroVector;"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" MousePos "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" FVector2D"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(MouseX, MouseY);"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" else"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" MousePos "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" LockInputPosition."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"GetValue"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"();"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" if"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" (MousePos.X "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"<"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" 0."}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"f"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ||"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" MousePos.X "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:">="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" SizeX "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"||"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" MousePos.Y "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"<"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" 0."}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"f"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ||"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" MousePos.Y "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:">="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" SizeY)"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" return"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" FVector2D"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"ZeroVector;"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" const"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" float"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" Denominator "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" FMath"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Max"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:"1."}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"f"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"static_cast<float>"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(SizeY) "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"/"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" 3."}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"f"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:");"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" const"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" FVector2D DesiredDir "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" (MousePos "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"-"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ViewportCenter) "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"/"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" Denominator;"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" return"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" DesiredDir;"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"}"})})]})})}),(0,c.jsxs)(l.p,{children:["Finally, update the ",(0,c.jsx)(l.code,{children:"Tick()"})," function to use this logic and trigger the reducer:"]}),(0,c.jsx)(c.Fragment,{children:(0,c.jsx)(l.pre,{className:"shiki spacetime-dark",style:{backgroundColor:"var(--clockworklabs-code-background-color)",color:"#F8F8F2"},tabIndex:"0",children:(0,c.jsxs)(l.code,{children:[(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"void"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ABlackholioPlayerController"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Tick"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"float"}),(0,c.jsx)(l.span,{style:{color:"#FFB86C",fontStyle:"italic"},children:" DeltaSeconds"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:")"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"{"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" Super"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Tick"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(DeltaSeconds);"})]}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" if"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ("}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"WasInputKeyJustPressed"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(EKeys"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"Q))"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" if"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" (LockInputPosition."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"IsSet"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"}
1,children:"())"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" LockInputPosition."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Reset"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"();"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" else"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" float"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" X, Y;"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" if"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ("}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"GetMousePosition"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(X, Y))"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" LockInputPosition "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" FVector2D"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(X, Y);"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" const"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" float"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" Now "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" GetWorld"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"() "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"?"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" GetWorld"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"->"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"GetTimeSeconds"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"() "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" 0."}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"f"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:";"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" if"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ((Now "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"-"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" LastMovementSendTimestamp) "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:">="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" SendUpdatesFrequency)"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" LastMovementSendTimestamp "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" Now;"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" FVector2D LatestDesiredDirection "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" ComputeDesiredDirection"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"}
1,children:"();"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#6272A4"},children:" // Send whatever the controller last told us."})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" if"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ((LatestDesiredDirection.X "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"!="}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" 0"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" &&"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" LatestDesiredDirection.Y "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"!="}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" 0"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"))"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" const"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" FVector2D ConvertDirection "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" FVector2D"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(LatestDesiredDirection.X, LatestDesiredDirection.Y"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"*-"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:"1"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:");"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" AGameManager"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"Instance"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"->"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"Conn"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"->"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"Reducers"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"->"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"UpdatePlayerInput"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"ToDbVector"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(ConvertDirection));"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"}"})})]})})}),(0,c.jsx)(l.admonition,{type:"warning",children:(0,c.jsx)(l.p,{children:"Be sure to rebuild your project after making changes to the code."})})]}),(0,c.jsxs)(a.A,{value:"blueprint",label:"Blueprint",children:[(0,c.jsxs)(l.p,{children:["The final step is to update ",(0,c.jsx)(l.code,{children:"BP_PlayerController"})," on the client to call the ",(0,c.jsx)(l.code,{children:"update_player_input"})," reducer."]}),(0,c.jsxs)(l.p,{children:["Add ",(0,c.jsx)(l.strong,{children:"Function"})," named ",(0,c.jsx)(l.code,{children:"ComputeDesiredDirection"})," as follows:\n",(0,c.jsx)(l.img,{alt:"Add ComputeDesiredDirection",src:e(40111).A+"",width:"1657",height:"775"}),"\n",(0,c.jsx)(l.img,{alt:"Add ComputeDesiredDirection",src:e(17652).A+"",width:"1209",height:"817"})]}),(0,c.jsxs)(l.ul,{children:["\n",(0,c.jsxs)(l.li,{children:["Add ",(0,c.jsx)(l.strong,{children:"Output"})," as ",(0,c.jsx)(l.code,{children:"Result"})," with ",(0,c.jsx)(l.strong,{children:"Vector 2D"})," as the type."]}),"\n",(0,c.jsxs)(l.li,{children:["Add ",(0,c.jsx)(l.strong,{children:"Local Variable"})," as ",(0,c.jsx)(l.code,{children:"ViewpointCenter"})," with ",(0,c.jsx)(l.strong,{children:"Vector 2D"})," as the type."]}),"\n",(0,c.jsxs)(l.li,{children:["Add ",(0,c.jsx)(l.strong,{children:"Local Variable"})," as ",(0,c.jsx)(l.code,{children:"MousePosition"})," with ",(0,c.jsx)(l.strong,{children:"Vector 2D"})," as the type."]}),"\n",(0,c.jsxs)(l.li,{children:["Check ",(0,c.jsx)(l.strong,{children:"Pure"})]}),"\n"]}),(0,c.jsxs)(l.p,{children:["Finally, update the ",(0,c.jsx)(l.code,{children:"Event Tick"})," function to use this logic and trigger the reducer:\n",(0,c.jsx)(l.img,{alt:"Update Event Tick",src:e(38781).A+"",width:"1778",height:"472"})]})]})]}),"\n",(0,c.jsx)(l.p,{children:"Let's try it out! Press play and roam freely around the arena! Now we're cooking with gas."}),"\n",(0,c.jsx)(l.h3,{id:"collisions-and-eating-food",children:"Collisions and Eating Food"}),"\n",(0,c.jsx)(l.p,{children:"Well this is pretty fun, but wouldn't it be better if we could eat food and grow our circle? Surely, that's going to be a pain, right?"}),"\n",(0,c.jsxs)(o.A,{groupId:"server-language",defaultValue:"rust",children:[(0,c.jsxs)(a.A,{value:"csharp",label:"C#",children:[(0,c.jsxs)(l.p,{children:["Wrong. With SpacetimeDB it's extremely easy. All we have to do is add an ",(0,c.jsx)(l.code,{children:"IsOverlapping"})," helper function which does some basic math based on mass radii, and modify our ",(0,c.jsx)(l.code,{children:"MoveAllPlayers"})," reducer to loop through every entity in the arena for every circle, checking each for overlaps. This may not be the most efficient way to do collision checking (building a quad tree or doing ",(0,c.jsx)(l.a,{href:"https://conkerjo.wordpress.com/2009/06/13/s
1patial-hashing-implementation-for-fast-2d-collisions/",children:"spatial hashing"})," might be better), but SpacetimeDB is very fast so for this number of entities it'll be a breeze for SpacetimeDB."]}),(0,c.jsxs)(l.p,{children:["Sometimes simple is best! Add the following code to the ",(0,c.jsx)(l.code,{children:"Module"})," class of your ",(0,c.jsx)(l.code,{children:"Lib.cs"})," file and make sure to replace the existing ",(0,c.jsx)(l.code,{children:"MoveAllPlayers"})," reducer."]}),(0,c.jsx)(c.Fragment,{children:(0,c.jsx)(l.pre,{className:"shiki spacetime-dark",style:{backgroundColor:"var(--clockworklabs-code-background-color)",color:"#F8F8F2"},tabIndex:"0",children:(0,c.jsxs)(l.code,{children:[(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"const"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" float"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" MINIMUM_SAFE_MASS_RATIO "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" 0.85f"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:";"})]}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"public"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" static"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" bool"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" IsOverlapping"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"Entity"}),(0,c.jsx)(l.span,{style:{color:"#FFB86C",fontStyle:"italic"},children:" a"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", "}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"Entity"}),(0,c.jsx)(l.span,{style:{color:"#FFB86C",fontStyle:"italic"},children:" b"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:")"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"{"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" var"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" dx "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" a.position.x "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"-"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" b.position.x;"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" var"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" dy "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" a.position.y "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"-"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" b.position.y;"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" var"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" distance_sq "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" dx "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"*"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" dx "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"+"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" dy "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"*"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" dy;"})]}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" var"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" radius_a "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" MassToRadius"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(a.mass);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" var"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" radius_b "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" MassToRadius"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(b.mass);"})]}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#6272A4"},children:" // If the distance between the two circle centers is less than the"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#6272A4"},children:" // maximum radius, then the center of the smaller circle is inside"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#6272A4"},children:" // the larger circle. This gives some leeway for the circles to overlap"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#6272A4"},children:" // before being eaten."})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" var"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" max_radius "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" radius_a "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:">"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" radius_b "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"?"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" radius_a"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" radius_b;"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" return"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" distance_sq "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"<="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" max_radius "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"*"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" max_radius;"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"}"})}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"["}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"Reducer"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"]"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"public"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" static"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" void"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" MoveAllPlayers"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"ReducerContext"}),(0,c.jsx)(l.span,{style:{color:"#FFB86C",fontStyle:"italic"},children:" ctx"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", "}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"MoveAllPlayersTimer"}),(0,c.jsx)(l.span,{style:{color:"#FFB86C",fontStyle:"italic"},children:" timer"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:")"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"{"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" var"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" world_size "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" (ctx.Db.config.id."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Find"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:"0"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:") "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"??"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" throw"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" new"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" Exception"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#E9F284"},children:'"'}),(0,c.jsx)(l.span,{style:{color:"#F1FA8C"},children:"Config not found"}),(0,c.jsx)(l.span,{style:{color:"#E9F284"},children:'"'}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:")).world_size;"})]}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#6272A4"},children:" // Handle player input"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" foreach"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ("}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"var"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"in"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx.Db.circle."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Iter"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"}
1,children:"())"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" var"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" check_entity "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx.Db.entity.entity_id."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Find"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(circle.entity_id);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" if"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" (check_entity "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"=="}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" null"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:")"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#6272A4"},children:" // This can happen if the circle has been eaten by another circle."})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" continue"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:";"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" var"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_entity "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" check_entity.Value;"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" var"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_radius "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" MassToRadius"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(circle_entity.mass);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" var"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" direction "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle.direction "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"*"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle.speed;"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" var"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" new_pos "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_entity.position "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"+"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" direction "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"*"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" MassToMaxMoveSpeed"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(circle_entity.mass);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_entity.position.x "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" Math."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Clamp"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(new_pos.x, circle_radius, world_size "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"-"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_radius);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_entity.position.y "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" Math."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Clamp"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(new_pos.y, circle_radius, world_size "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"-"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_radius);"})]}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#6272A4"},children:" // Check collisions"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" foreach"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ("}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"var"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" entity "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"in"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx.Db.entity."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Iter"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"}
1,children:"())"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" if"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" (entity.entity_id "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"=="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_entity.entity_id)"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" continue"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:";"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" if"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ("}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"IsOverlapping"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(circle_entity, entity))"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#6272A4"},children:" // Check to see if we're overlapping with food"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" if"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" (ctx.Db.food.entity_id."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Find"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(entity.entity_id).HasValue) {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx.Db.entity.entity_id."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Delete"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(entity.entity_id);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx.Db.food.entity_id."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Delete"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(entity.entity_id);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_entity.mass "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"+="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" entity.mass;"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#6272A4"},children:" // Check to see if we're overlapping with another circle owned by another player"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" var"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" other_circle "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx.Db.circle.entity_id."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Find"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(entity.entity_id);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" if"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" (other_circle.HasValue "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"&&"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" other_circle.Value.player_id "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"!="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle.player_id)"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" var"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" mass_ratio "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ("}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"float"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:")entity.mass "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"/"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_entity.mass;"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" if"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" (mass_ratio "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"<"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" MINIMUM_SAFE_MASS_RATIO)"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx.Db.entity.entity_id."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Delete"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(entity.entity_id);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx.Db.circle.entity_id."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Delete"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(entity.entity_id);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_entity.mass "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"+="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" entity.mass;"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx.Db.entity.entity_id."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"Update"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(circle_entity);"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"}"})})]})})})]}),(0,c.jsxs)(a.A,{value:"rust",label:"Rust",children:[(0,c.jsxs)(l.p,{children:["Wrong. With SpacetimeDB it's extremely easy. All we have to do is add an ",(0,c.jsx)(l.code,{children:"is_overlapping"})," helper function which does some basic math based on mass radii, and modify our ",(0,c.jsx)(l.code,{children:"move_all_player"})," reducer to loop through every entity in the arena for every circle, checking each for overlaps. This may not be the most efficient way to do collision checking (building a quad tree or doing ",(0,c.jsx)(l.a,{href:"https://conkerjo.wordpress.com/2009/06/13/s
1patial-hashing-implementation-for-fast-2d-collisions/",children:"spatial hashing"})," might be better), but SpacetimeDB is very fast so for this number of entities it'll be a breeze for SpacetimeDB."]}),(0,c.jsxs)(l.p,{children:["Sometimes simple is best! Add the following code to your ",(0,c.jsx)(l.code,{children:"lib.rs"})," file and make sure to replace the existing ",(0,c.jsx)(l.code,{children:"move_all_players"})," reducer."]}),(0,c.jsx)(c.Fragment,{children:(0,c.jsx)(l.pre,{className:"shiki spacetime-dark",style:{backgroundColor:"var(--clockworklabs-code-background-color)",color:"#F8F8F2"},tabIndex:"0",children:(0,c.jsxs)(l.code,{children:[(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"const"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" MINIMUM_SAFE_MASS_RATIO"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" f32"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ="}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" 0.85"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:";"})]}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"fn"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" is_overlapping"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(a"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" &"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"Entity"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", b"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" &"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"Entity"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:") "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"->"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" bool"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" let"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" dx "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" a"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"position"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"x "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"-"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" b"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"position"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"x;"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" let"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" dy "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" a"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"position"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"y "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"-"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" b"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"position"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"y;"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" let"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" distance_sq "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" dx "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"*"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" dx "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"+"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" dy "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"*"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" dy;"})]}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" let"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" radius_a "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" mass_to_radius"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(a"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"mass);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" let"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" radius_b "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" mass_to_radius"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(b"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"mass);"})]}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#6272A4"},children:" // If the distance between the two circle centers is less than the"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#6272A4"},children:" // maximum radius, then the center of the smaller circle is inside"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#6272A4"},children:" // the larger circle. This gives some leeway for the circles to overlap"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#6272A4"},children:" // before being eaten."})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" let"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" max_radius "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" f32"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"max"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(radius_a, radius_b);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" distance_sq "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"<="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" max_radius "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"*"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" max_radius"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"}"})}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"#[spacetimedb"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"::"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"reducer]"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"pub"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" fn"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" move_all_players"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(ctx"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" &"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"ReducerContext"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:", _timer"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:":"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" MoveAllPlayersTimer"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:") "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"->"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" Result"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"<(), "}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:"String"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"> {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" let"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" world_size "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"db"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"config"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"}
1,children:"()"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"id"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"find"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:"0"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:")"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"ok_or"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#F1FA8C"},children:'"Config not found"'}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:")"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"?"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" ."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"world_size;"})]}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#6272A4"},children:" // Handle player input"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" for"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"in"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"db"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"circle"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"iter"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"() {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" let"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_entity "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"db"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"entity"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"entity_id"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"find"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"&"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"circle"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"entity_id);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" if"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" !"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"circle_entity"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"is_some"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"() {"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#6272A4"},children:" // This can happen if a circle is eaten by another circle"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" continue"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:";"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" let"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" mut"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_entity "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_entity"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"unwrap"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"}
1,children:"();"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" let"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_radius "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" mass_to_radius"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(circle_entity"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"mass);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" let"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" direction "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"direction "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"*"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"speed;"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" let"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" new_pos "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_entity"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"position "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"+"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" direction "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"*"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" mass_to_max_move_speed"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(circle_entity"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"mass);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" let"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" min "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_radius;"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" let"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" max "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" world_size "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"as"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" f32"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" -"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_radius;"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_entity"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"position"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"x "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" new_pos"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"x"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"clamp"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(min, max);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_entity"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"position"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"y "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" new_pos"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"y"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"clamp"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(min, max);"})]}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#6272A4"},children:" // Check collisions"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" for"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" entity "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"in"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"db"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"entity"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"}
1,children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"iter"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"() {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" if"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" entity"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"entity_id "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"=="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_entity"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"entity_id {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" continue"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:";"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" if"}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:" is_overlapping"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"&"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"circle_entity, "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"&"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"entity) {"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#6272A4"},children:" // Check to see if we're overlapping with food"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" if"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"db"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"food"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"entity_id"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"find"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"&"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"entity"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"entity_id)"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"is_some"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"() {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"db"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"entity"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"entity_id"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"delete"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"&"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"entity"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"entity_id);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"db"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"food"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"}
1,children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"entity_id"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"delete"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"&"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"entity"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"entity_id);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_entity"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"mass "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"+="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" entity"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"mass;"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#6272A4"},children:" // Check to see if we're overlapping with another circle owned by another player"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" let"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" other_circle "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"db"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"circle"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"entity_id"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"find"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"&"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"entity"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"entity_id);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" if"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" let"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" Some"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(other_circle) "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" other_circle {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" if"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" other_circle"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"player_id "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"!="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"player_id {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" let"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" mass_ratio "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" entity"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"mass "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"as"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" f32"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" /"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_entity"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"mass "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"as"}),(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" f32"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:";"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:" if"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" mass_ratio "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"<"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" MINIMUM_SAFE_MASS_RATIO"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" {"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"db"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"entity"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"}
1,children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"entity_id"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"delete"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"&"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"entity"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"entity_id);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"db"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"circle"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"entity_id"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"delete"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"("}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"&"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"entity"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"entity_id);"})]}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" circle_entity"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"mass "}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"+="}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" entity"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"mass;"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" ctx"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"db"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"entity"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"entity_id"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"()"}),(0,c.jsx)(l.span,{style:{color:"#FF79C6"},children:"."}),(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"update"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(circle_entity);"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:" }"})}),"\n",(0,c.jsx)(l.span,{className:"line"}),"\n",(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#8BE9FD",fontStyle:"italic"},children:" Ok"}),(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"(())"})]}),"\n",(0,c.jsx)(l.span,{className:"line",children:(0,c.jsx)(l.span,{style:{color:"#F8F8F2"},children:"}"})})]})})})]})]}),"\n",(0,c.jsx)(l.p,{children:"For every circle, we look at all other entities. If they are overlapping then for food, we add the mass of the food to the circle and delete the food, otherwise if it's a circle we delete the smaller circle and add the mass to the bigger circle."}),"\n",(0,c.jsx)(l.p,{children:"That's it. We don't even have to do anything on the client."}),"\n",(0,c.jsx)(c.Fragment,{children:(0,c.jsx)(l.pre,{className:"shiki spacetime-dark",style:{backgroundColor:"var(--clockworklabs-code-background-color)",color:"#F8F8F2"},tabIndex:"0",children:(0,c.jsx)(l.code,{children:(0,c.jsxs)(l.span,{className:"line",children:[(0,c.jsx)(l.span,{style:{color:"#50FA7B"},children:"spacetime"}),(0,c.jsx)(l.span,{style:{color:"#F1FA8C"},children:" publish"}),(0,c.jsx)(l.span,{style:{color:"#BD93F9"},children:" --server"}),(0,c.jsx)(l.span,{style:{color:"#F1FA8C"},children:" local"}),(0,c.jsx)(l.span,{style:{color:"#F1FA8C"},children:" blackholio"})]})})})}),"\n",(0,c.jsx)(l.p,{children:"Just update your module by publishing and you're on your way eating food! Try to see how big you can get!"}),"\n",(0,c.jsxs)(l.p,{children:["We didn't even have to update the client, because our client's ",(0,c.jsx)(l.code,{children:"OnDelete"})," callbacks already handled deleting entities from the scene when they're deleted on the server. SpacetimeDB just synchronizes the state with your client automatically."]}),"\n",(0,c.jsx)(l.p,{children:"Notice that the food automatically respawns as you vaccuum them up. This is because our scheduled reducer is automatically replacing the food 2 times per second, to ensure that there is always 600 food on the map."}),"\n",(0,c.jsx)(l.h2,{id:"connecting-to-maincloud",children:"Connecting to Maincloud"}),"\n",(0,c.jsxs)(l.ul,{children:["\n",(0,c.jsxs)(l.li,{children:["Publish to Maincloud ",(0,c.jsx)(l.code,{children:"spacetime publish --server maincloud <your database name> --delete-data"}),"\n",(0,c.jsxs)(l.ul,{children:["\n",(0,c.jsxs)(l.li,{children:[(0,c.jsx)(l.code,{children:"<your database name>"}
1)," This name should be unique and cannot contain any special characters other than internal hyphens (",(0,c.jsx)(l.code,{children:"-"}),")."]}),"\n"]}),"\n"]}),"\n",(0,c.jsxs)(l.li,{children:["Update the URL in the Unreal project to: ",(0,c.jsx)(l.code,{children:"https://maincloud.spacetimedb.com"})]}),"\n",(0,c.jsxs)(l.li,{children:["Update the module name in the Unreal project to ",(0,c.jsx)(l.code,{children:"<your database name>"}),"."]}),"\n",(0,c.jsxs)(l.li,{children:["Your ",(0,c.jsx)(l.code,{children:"BP_GameManager"})," should look something like this:"]}),"\n"]}),"\n",(0,c.jsx)(l.p,{children:(0,c.jsx)(l.img,{alt:"Maincloud Setup",src:e(20100).A+"",width:"474",height:"368"})}),"\n",(0,c.jsxs)(l.p,{children:["To delete your Maincloud database, you can run: ",(0,c.jsx)(l.code,{children:"spacetime delete --server maincloud <your database name>"})]}),"\n",(0,c.jsx)(l.h2,{id:"conclusion",children:"Conclusion"}),"\n",(0,c.jsxs)(o.A,{groupId:"server-language",defaultValue:"rust",children:[(0,c.jsx)(a.A,{value:"csharp",label:"C#",children:(0,c.jsxs)(l.p,{children:["So far you've learned how to configure a new Unreal project to work with SpacetimeDB, how to develop, build, and publish a SpacetimeDB server module. Within the module, you've learned how to create tables, update tables, and write reducers. You've learned about special reducers like ",(0,c.jsx)(l.code,{children:"ClientConnected"})," and ",(0,c.jsx)(l.code,{children:"Init"})," and how to created scheduled reducers. You learned how we can used scheduled reducers to implement a physics simulation right within your module."]})}),(0,c.jsx)(a.A,{value:"rust",label:"Rust",children:(0,c.jsxs)(l.p,{children:["So far you've learned how to configure a new Unreal project to work with SpacetimeDB, how to develop, build, and publish a SpacetimeDB server module. Within the module, you've learned how to create tables, update tables, and write reducers. You've learned about special reducers like ",(0,c.jsx)(l.code,{children:"client_connected"})," and ",(0,c.jsx)(l.code,{children:"init"})," and how to created scheduled reducers. You learned how we can used scheduled reducers to implement a physics simulation right within your module."]})})]}),"\n",(0,c.jsx)(l.p,{children:"You've also learned how view module logs and connect your client to your database server, call reducers from the client and synchronize the data with client. Finally you learned how to use that synchronized data to draw game objects on the screen, so that we can interact with them and play a game!"}),"\n",(0,c.jsx)(l.p,{children:"And all of that completely from scratch!"}),"\n",(0,c.jsxs)(l.p,{children:['Our game is still pretty limited in some important ways. The biggest limitation is that the client assumes your username is "TestPlayer" and doesn\'t give you a menu or a window to set your username before joining the game. Notably, we do not have a unique constraint on the ',(0,c.jsx)(l.code,{children:"name"})," column, so that does not prevent us from connecting multiple clients to the same server."]}),"\n",(0,c.jsx)(l.p,{children:"In fact, if you build what we have and run multiple clients you already have a (very simple) MMO! You can connect hundreds of players to this arena with SpacetimeDB."}),"\n",(0,c.jsx)(l.p,{children:"There's still plenty more we can do to build this into a proper game though. For example, you might want to also add"}),"\n",(0,c.jsxs)(l.ul,{children:["\n",(0,c.jsx)(l.li,{children:"Username chooser"}),"\n",(0,c.jsx)(l.li,{children:"Chat"}),"\n",(0,c.jsx)(l.li,{children:"Leaderboards"}),"\n",(0,c.jsx)(l.li,{children:"Nice animations"}),"\n",(0,c.jsx)(l.li,{children:"Nice shaders"}),"\n",(0,c.jsx)(l.li,{children:"Space theme!"}),"\n"]}),"\n",(0,c.jsx)(l.p,{children:"Fortunately, we've done that for you! If you'd like to check out the completed tutorial game, with these additional features, you can download it on GitHub:"}),"\n",(0,c.jsx)(l.p,{children:(0,c.jsx)(l.a,{href:"https://github.com/clockworklabs/SpacetimeDB/tree/master/demo/Blackholio",children:"https://github.com/clockworklabs/SpacetimeDB/tree/master/demo/Blackholio"})}),"\n",(0,c.jsxs)(l.p,{children:["If you have any suggestions or comments on the tutorial, either ",(0,c.jsx)(l.a,{href:"https://github.com/clockworklabs/SpacetimeDB/issues/new",children:"open an issue"}),", or join our Discord (",(0,c.jsx)(l.a,{href:"https://discord.gg/SpacetimeDB",children:"https://discord.gg/SpacetimeDB"}),") and chat with us!"]})]})}function p(s={}){const{wrapper:l}={...(0,r.R)(),...s.components};return l?(0,c.jsx)(l,{...s,children:(0,c.jsx)(h,{...s})}):h(s)}},17652:(s,l,e)=>{e.d(l,{A:()=>n});const n=e.p+"assets/images/part-4-01-blueprint-playercontroller-2-4fa243bc04c07055acc67adad28671a5.png"},20100:(s,l,e)=>{e.d(l,{A:()=>n});const n=e.p+"assets/images/part-4-01-maincloud-ccbcfb0ad0be20010ea9af2d5362c35f.png"},38781:(s,l,e)=>{e.d(l,{A:()=>n});const n=e.p+"assets/images/part-4-01-blueprint-playercontroller-3-cdf9847f32c3d8f9cd1ee87e6f2e0b47.png"},40111:(s,l,e)=>{e.d(l,{A:()=>n});const n=e.p+"assets/images/part-4-01-blueprint-playercontroller-1-8c9a3c503a6faaf37ed8cfcebfbfcb9e.png"},43244:(s,l,e)=>{e.d(l,{A:()=>
1o});e(7378);var n=e(23372);const c={tabItem:"tabItem_w6aI"};var r=e(86106);function o({children:s,hidden:l,className:e}){return(0,r.jsx)("div",{role:"tabpanel",className:(0,n.A)(c.tabItem,e),hidden:l,children:s})}},51471:(s,l,e)=>{e.d(l,{A:()=>b});var n=e(7378),c=e(23372),r=e(23418),o=e(46585),a=e(30505),i=e(99202),F=e(81922),t=e(46923),d=e(73126);function h(s){return n.Children.toArray(s).filter(s=>"\n"!==s).map(s=>{if(!s||(0,n.isValidElement)(s)&&function(s){const{props:l}=s;return!!l&&"object"==typeof l&&"value"in l}(s))return s;throw new Error(`Docusaurus error: Bad <Tabs> child <${"string"==typeof s.type?s.type:s.type.name}>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.`)})?.filter(Boolean)??[]}function p(s){const{values:l,children:e}=s;return(0,n.useMemo)(()=>{const s=l??function(s){return h(s).map(({props:{value:s,label:l,attributes:e,default:n}})=>({value:s,label:l,attributes:e,default:n}))}(e);return function(s){const l=(0,t.XI)(s,(s,l)=>s.value===l.value);if(l.length>0)throw new Error(`Docusaurus error: Duplicate values "${l.map(s=>s.value).join(", ")}" found in <Tabs>. Every value needs to be unique.`)}(s),s},[l,e])}function x({value:s,tabValues:l}){return l.some(l=>l.value===s)}function j({queryString:s=!1,groupId:l}){const e=(0,a.W6)(),c=function({queryString:s=!1,groupId:l}){if("string"==typeof s)return s;if(!1===s)return null;if(!0===s&&!l)throw new Error('Docusaurus error: The <Tabs> component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return l??null}({queryString:s,groupId:l});return[(0,F.aZ)(c),(0,n.useCallback)(s=>{if(!c)return;const l=new URLSearchParams(e.location.search);l.set(c,s),e.replace({...e.location,search:l.toString()})},[c,e])]}function y(s){const{defaultValue:l,queryString:e=!1,groupId:c}=s,r=p(s),[o,a]=(0,n.useState)(()=>function({defaultValue:s,tabValues:l}){if(0===l.length)throw new Error("Docusaurus error: the <Tabs> component requires at least one <TabItem> children component");if(s){if(!x({value:s,tabValues:l}))throw new Error(`Docusaurus error: The <Tabs> has a defaultValue "${s}" but none of its children has the corresponding value. Available values are: ${l.map(s=>s.value).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return s}const e=l.find(s=>s.default)??l[0];if(!e)throw new Error("Unexpected error: 0 tabValues");return e.value}({defaultValue:l,tabValues:r})),[F,t]=j({queryString:e,groupId:c}),[h,y]=function({groupId:s}){const l=function(s){return s?`docusaurus.tab.${s}`:null}(s),[e,c]=(0,d.Dv)(l);return[e,(0,n.useCallback)(s=>{l&&c.set(s)},[l,c])]}({groupId:c}),m=(()=>{const s=F??h;return x({value:s,tabValues:r})?s:null})();(0,i.A)(()=>{m&&a(m)},[m]);return{selectedValue:o,selectValue:(0,n.useCallback)(s=>{if(!x({value:s,tabValues:r}))throw new Error(`Can't select invalid tab value=${s}`);a(s),t(s),y(s)},[t,y,r]),tabValues:r}}var m=e(52538);const C={tabList:"tabList_duiv",tabItem:"tabItem_a1H9"};var u=e(86106);function f({className:s,block:l,selectedValue:e,selectValue:n,tabValues:r}){const a=[],{blockElementScrollPositionUntilNextRender:i}=(0,o.a_)(),F=s=>{const l=s.currentTarget,c=a.indexOf(l),o=r[c].value;o!==e&&(i(l),n(o))},t=s=>{let l=null;switch(s.key){case"Enter":F(s);break;case"ArrowRight":{const e=a.indexOf(s.currentTarget)+1;l=a[e]??a[0];break}case"ArrowLeft":{const e=a.indexOf(s.currentTarget)-1;l=a[e]??a[a.length-1];break}}l?.focus()};return(0,u.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,c.A)("tabs",{"tabs--block":l},s),children:r.map(({value:s,label:l,attributes:n})=>(0,u.jsx)("li",{role:"tab",tabIndex:e===s?0:-1,"aria-selected":e===s,ref:s=>{a.push(s)},onKeyDown:t,onClick:F,...n,className:(0,c.A)("tabs__item",C.tabItem,n?.className,{"tabs__item--active":e===s}),children:l??s},s))})}function N({lazy:s,children:l,selectedValue:e}){const r=(Array.isArray(l)?l:[l]).filter(Boolean);if(s){const s=r.find(s=>
1s.props.value===e);return s?(0,n.cloneElement)(s,{className:(0,c.A)("margin-top--md",s.props.className)}):null}return(0,u.jsx)("div",{className:"margin-top--md",children:r.map((s,l)=>(0,n.cloneElement)(s,{key:l,hidden:s.props.value!==e}))})}function B(s){const l=y(s);return(0,u.jsxs)("div",{className:(0,c.A)(r.G.tabs.container,"tabs-container",C.tabList),children:[(0,u.jsx)(f,{...l,...s}),(0,u.jsx)(N,{...l,...s})]})}function b(s){const l=(0,m.A)();return(0,u.jsx)(B,{...s,children:h(s.children)},String(l))}},56225:(s,l,e)=>{e.d(l,{R:()=>o,x:()=>a});var n=e(7378);const c={},r=n.createContext(c);function o(s){const l=n.useContext(r);return n.useMemo(function(){return"function"==typeof s?s(l):{...l,...s}},[l,s])}function a(s){let l;return l=s.disableParentContext?"function"==typeof s.components?s.components(c):s.components||c:o(s.components),n.createElement(r.Provider,{value:l},s.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.