docs: regenerate site from f094acfdb5
This commit is contained in:
commit
63c5ed9baf
975 changed files with 55427 additions and 0 deletions
41
annot-sync.html
Normal file
41
annot-sync.html
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>@Sync — Ludic</title>
|
||||
<meta name="description" content="Mark fields as replicated and models as owned so the compiler generates networking.">
|
||||
<link rel="stylesheet" href="base.css">
|
||||
<link rel="stylesheet" href="docs.css">
|
||||
</head>
|
||||
<body>
|
||||
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||
<main class="wrap item">
|
||||
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#annotations">Annotations</a> <span>›</span> <span class="here">@Sync</span></div>
|
||||
<div class="item-head">
|
||||
<span class="kind-badge kind-annotation">annotation</span>
|
||||
<h1 id="top">@Sync</h1>
|
||||
</div>
|
||||
<code class="sig">@Sync property … / @Owned</code>
|
||||
<div class="desc"><p>These are the two declarative switches at the top of Ludic's networking: <code>@Sync</code> says <b>what</b> replicates and <code>@Owned</code> says <b>who</b> owns an instance. Replication is opt-in at the field level and decided per model use-site — a field crosses the wire only when it is both replicable (marked <code>@Sync</code>, either on the field or via <code>@Sync property P</code> which marks every field of <code>P</code>) <b>and</b> participating (the model marks the component <code>@Sync</code>). So the same property can replicate in one model and not another, and there is no <code>@NoSync</code> because the surface is purely additive. From these marks the compiler generates the per-model <code>serialize</code>/<code>apply</code> codecs; <code>@Sync</code> on a non-POD-scalar field (like a <code>pointer</code>) is a compile error, since a machine-local pointer cannot cross the wire. <code>@Owned</code> adds the owner slot the ownership builtins and <code>@Predicted</code> read. See the dedicated <code>@Owned</code> page for ownership details.</p></div>
|
||||
|
||||
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program SyncedWorld {
|
||||
@Sync property Position { column: int = 0, row: int = 0 } # every field replicable
|
||||
property Health { @Sync current: int = 0, maximum: int = 0 } # only current replicable
|
||||
|
||||
@Owned model Player { @Sync Position, @Sync Health } # participates -> column,row,current
|
||||
model Scenery { Position } # not @Sync here -> never replicates
|
||||
|
||||
entry {
|
||||
spawn Player { Position { column: 3, row: 4 }, Health { current: 50, maximum: 100 } }
|
||||
for (Position, Health) in query [Position, Health, {Player}] {
|
||||
print(sync_size(self())) # 12 = Position(8) + Health.current(4)
|
||||
}
|
||||
}
|
||||
}</pre></div>
|
||||
|
||||
<a class="back" href="api.html">← All symbols</a>
|
||||
</main>
|
||||
<script src="ludic-highlight.js"></script>
|
||||
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||
</body></html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue