---
title: Systems
description: Write Tide ECS systems that query entities each tick, declare data
  access and control execution order in a deterministic simulation.
source_url: https://tide-engine.dev/game/systems
source_file: docs/game/systems.md
source_revision: d46b7bc81b49e31e268bd62d158c040ec1c9ff21
source_worktree: modified
documentation_sha256: cff5cc1f43e9cab7c438614cde0e25d6b097b0171d16e0bfbecd7198624f4f9d
documentation_scope: Website source checkout; not matched to an installed Tide
  release. Check tide version and the project toolchain.
---

<a id="systems"></a>

# Systems

A system is code that runs every tick. Its parameters say which entities it runs for, and what it does with their data.

```csharp
system ClampPlayer(mut Transform trs, with Player)
{
    if (trs.position.y < 0)
        trs.position.y = 0;
}
```

<a id="parameters-are-the-query"></a>

## Parameters are the query

A system's component parameters describe the entities it runs for. Each parameter's modifier says how the system relates to that component or singleton:

| Modifier | Meaning |
|---|---|
| none | Reads it |
| `mut` | Writes it |
| `with` | The entity must have it. No data, so no data dependency. |
| `without` | The entity must not have it. |

So `ClampPlayer` runs for every entity that has a `Transform` and a `Player`, and changes its `Transform`.

Keeping what a system touches (its access) apart from which entities it picks (its filters) is what lets the engine run systems side by side safely: two systems that only filter on the same component never wait for each other.

Only the amber row has `Moving` without `Frozen`, so only those entities match `Move`. Their positions change by `time.dt` in the match, and views draw the result. The button calls a command to pause or resume the match's movement.

**Component filters in motion** ([Run example](https://tide-engine.dev/examples/systems/?stats))

```tide
settings { title = "System queries"; tickRate = 30; maxPlayers = 1; }

component Body { float2 position; float speed = 1; }
component Moving { }
component Frozen { }
singleton Demo { bool running = true; }
scene Main { }

event(Spawned) Setup(with Main)
{
    for (var i = 0; i < 3; i++)
    {
        Spawn(Body { position = float2(i * 1.2 - 1.2, 1) }, Moving);
        Spawn(Body { position = float2(i * 1.2 - 1.2, 0) }, Moving, Frozen);
        Spawn(Body { position = float2(i * 1.2 - 1.2, -1) });
    }
}

// Only the first row matches both filters.
system Move(mut Body body, Time time, Demo demo, with Moving, without Frozen)
{
    if (!demo.running) return;
    body.position.x += body.speed * time.dt;
    if (body.position.x > 2)
    {
        body.position.x -= 4;
        this.Snap(); // Wrap immediately instead of interpolating across the lane.
    }
}

// The button calls a command instead of changing match state in a view.
command(bool value) SetRunning(mut Demo demo, PlayerID sender)
{
    demo.running = value;
}

view Background()
{
    Draw.Clear(Color(0.086, 0.086, 0.094));
    Draw.SetCamera(float2(0), 3);
    for (var i = -1; i <= 1; i++)
        Draw.Line(float2(-2.1, i), float2(2.1, i), 0.025, Color(0.24, 0.25, 0.27));
}

view Active(Body body, with Moving, without Frozen)
{
    Draw.Circle(body.position, 0.19, Color(0.98, 0.75, 0.14));
}

view Blocked(Body body, with Moving, with Frozen)
{
    Draw.Circle(body.position, 0.19, Color(0.98, 0.44, 0.52));
}

view Excluded(Body body, without Moving)
{
    Draw.Circle(body.position, 0.19, Color(0.64, 0.64, 0.68));
}

view Labels(Demo demo)
{
    var first = Draw.WorldToScreen(float2(0, 1));
    var second = Draw.WorldToScreen(float2(0, 0));
    var third = Draw.WorldToScreen(float2(0, -1));
    Draw.SetScreen();
    Draw.Text("Systems run every tick", float2(16, 14), 18, Color.white);
    Draw.Text("with Moving, without Frozen", float2(16, first.y - 34), 14, Color(0.98, 0.75, 0.14));
    Draw.Text("Moving + Frozen: excluded", float2(16, second.y - 34), 14, Color(0.98, 0.44, 0.52));
    Draw.Text("No Moving: excluded", float2(16, third.y - 34), 14, Color(0.64, 0.64, 0.68));
    GUI.SetTheme(GUITheme { radius = 6 });
    if (GUI.Button(Rect(16, Screen.height - 48, Screen.width - 32, 32), demo.running ? "Pause the match" : "Resume the match"))
        SetRunning(!demo.running);
}
```



Other parameters:

- **Singletons**, read or `mut`, like components: `system Score(mut Stats stats, Rules rules)`.
- **The input**, or **`Devices`**: what the player who owns the entity does (see [Input](https://tide-engine.dev/game/input.md)).

- **The `World`**: any other entity's components (below).
- **A `query`**: another set of entities to inspect (below). Match data stays read-only; [local code](https://tide-engine.dev/game/views-and-the-match.md#other-entities) can also read and write attached local fields.

Views take the same parameters, and one filter more: `with ownership` and `without ownership`, the entities this machine's player owns, or doesn't (see [Your own entities](https://tide-engine.dev/game/views-and-the-match.md#your-own-entities)). It's for views only: a system runs the same on every machine, so there it's an error, which points to `with Owner`, the entities any player owns.

The entity itself isn't a parameter: it's `this` (see [Entity handles](https://tide-engine.dev/game/entities.md#entity-handles)).

<a id="another-set-of-entities"></a>

## Another set of entities

A bullet system runs for bullets, but needs to inspect fighters too. A `query` parameter selects that second set:

```csharp
system BulletHits(Body shot, Bullet bullet, query (Body body, with Fighter) fighters)
{
    foreach (var fighter in fighters)
    {
        if (Intersects(shot, fighter.body))
            fighter.entity.Send(Hit { damage = bullet.damage });
    }
}
```

`Intersects` is a function the game defines. The outer `Body` and `Bullet` parameters select each bullet; `Body` and `with Fighter` inside the query select the candidates it inspects. The query never requires a bullet to be a fighter.

Inside `foreach`, `fighter.body` is read-only component data and `fighter.entity` is that fighter's entity handle. Add more component bindings when their values are needed, and `with` or `without` filters when only presence matters:

```csharp
query (Body body, Health health, with Fighter, without Invulnerable) fighters
```

Sparse components and tags are checked for each candidate, and an empty query runs no iterations. A system with only query parameters runs once per tick.

Queries use normal deterministic ECS traversal. They do not sort by entity ID, distance or hit time. For a swept projectile, calculate each candidate's intersection and keep the earliest one before sending a hit.

Query data reads the current world and participates in [the schedule](https://tide-engine.dev/game/schedule.md). A system that also changes a queried component runs on one thread, following the same rule as reading its own writes through `World`: it sees rows changed earlier in that run. A binding marked [`previous`](https://tide-engine.dev/game/systems.md#as-the-tick-started) reads the tick's start instead, and does neither. Events and structural changes still wait for the end of the tick, so sending a hit or recording a destroy through `fighter.entity` does not change what this iteration reads.

Queries have read-only component bindings and component filters. Queries are used directly in `foreach`, or [borrowed by synchronous helpers](https://tide-engine.dev/language/functions.md#borrowing-a-query) with the same `query (...)` parameter syntax. The caller's selection and data timing stay intact. Queries and whole rows cannot be stored or returned; whole rows cannot be passed to functions. Keep iteration and forwarding outside parallel loops (other than the query's own, below) and callback blocks. A component value such as `fighter.body` can be copied or passed to a function. It follows the usual component copy rules, so a method that uses `this` needs the entity's own component parameter.

Systems, views, synchronous event handlers and commands take queries. A match handler or a command reads the current world at its turn in the tick-end queue: see [Events](https://tide-engine.dev/game/events.md#querying-other-entities). A view's rows are the match as it draws it, blended between ticks, or [`verified`](https://tide-engine.dev/game/views-and-the-match.md#confirmed-state): see [Views and the match](https://tide-engine.dev/game/views-and-the-match.md#other-entities). A local handler's are the match as the tick that sent its event left it: see [Events](https://tide-engine.dev/game/events.md#other-entities). Async handlers and tasks take none yet.

<a id="as-the-tick-started"></a>

### As the tick started

Write `previous` before a binding to read every entity's component as it was when this tick started, whatever has run since:

```csharp
system Flock(mut Bird bird, query (previous Bird other) others)
{
    mut var center = float3(0, 0, 0);
    mut var seen = 0;
    foreach (var o in others)
    {
        if (Math.Distance(o.other.position, bird.position) > 2) continue;
        center += o.other.position;
        seen++;
    }
    if (seen > 0) bird.velocity += (center / float(seen) - bird.position) * 0.001;
    bird.position += bird.velocity;
}
```

Every bird steers by where the others were when the tick began, not by where the birds before it in the loop have already moved to. That is usually what such code means, and it is what lets it run fast:

- **It waits for nothing.** Nothing in a tick can change what a `previous` binding reads, so the system doesn't wait for the systems that change `Bird` this tick, and they don't wait for it. See [the schedule](https://tide-engine.dev/game/schedule.md#when-systems-wait).
- **Its entities go across threads.** A system that changes a component and reads everyone's through an unmarked query runs its entities one after another on one thread, as each sees what the ones before it wrote. With `previous` there is nothing of the others' to see, so the birds are shared out over every core, with the same results as on one.
- **Its search is made once.** A loop that [starts by skipping rows](https://tide-engine.dev/game/systems.md#only-the-rows-that-can-pass) by a number of a `previous` binding goes through an index of the tick's start. It's made at most once a tick, for every system that searches the same way, and the system may change the very field it searches by (`bird.position` above), which an unmarked query's loop can't.

`previous` goes on a binding of a system's query (or a [match handler's](https://tide-engine.dev/game/events.md#querying-other-entities)), and reads the component's values: its text, lists, maps, sets and grids as they were too. The query has the same entities either way, as entities and their components come and go at the tick's end: one spawned this tick is in no query yet, and one destroyed this tick is still there with the values it started the tick with. Other bindings of the same query read the world as it is, and a [function handed the query](https://tide-engine.dev/language/functions.md#borrowing-a-query) reads what the query reads. Filters, a system's own parameters, views and local handlers don't take it. To compare a component now with what it was, take two queries, one with the word and one without. For one entity by its handle, the World has the same: [`world.GetPrevious<Body>(target)`](https://tide-engine.dev/game/systems.md#as-the-tick-started-by-handle).

Only what code reads of the tick's start is kept, and only for the tick. This is provisional but for the word and what it reads.

<a id="going-through-the-rows-at-once"></a>

### Going through the rows at once

A `parallel` loop goes through a query's rows at once, on threads, where each row's work doesn't depend on the others:

```csharp
system Hits(query (Body body, with Fighter) fighters, Arena arena)
{
    parallel (var f in fighters)
    {
        if (Math.Distance(f.body.position, arena.center) > arena.radius) continue;
        f.entity.Send(Hit { damage = 1 });
    }
}
```

The row is a foreach's: `f.entity` and the bindings, read-only. Steps follow a [parallel loop's rules](https://tide-engine.dev/language/grids.md#going-through-every-cell): they change only the variables they declare, and can't spawn, add, remove, destroy or draw. Unlike a list's or a grid's steps, they can send the match's events, to the world or to an entity, and those arrive in the order the `foreach` would have sent them, so the results are the same on any number of threads. An event that holds text or lists can't be sent from a step.

In a view, a step also reads its row's [local fields](https://tide-engine.dev/game/views.md), and writes them through a `mut` binding: each row is one entity's, so each step's local fields are its own. That is how a view works something costly out for every row on all the threads, then draws from the results in order:

```tide
view Crowd(query (mut Fighter fighter) fighters)
{
    // `shown` is a local field of Fighter: where to draw him, worked out for every row at once
    parallel (var f in fighters) f.fighter.shown = Stance(f.fighter.position, f.fighter.yaw);
    foreach (var f in fighters) Draw.Circle(f.fighter.shown, 0.5, Color.white);
}
```

A local field that holds text or lists can be read in a step but not changed there, and a step can't read the local fields of the view's own entity where the rows write the same component's. A frame's loops take the threads whenever a host hands them its pool, as the standard one does. This is provisional.

<a id="only-the-rows-that-can-pass"></a>

## Only the rows that can pass

A loop that starts by skipping rows is read by the compiler. When the condition bounds a number of the row by values the loop doesn't change, the loop visits only the rows within those bounds, found through an index, instead of every row:

```csharp
system Separate(mut Body body, Sight sight, query (Body other, with Boid) boids)
{
    foreach (var b in boids)
    {
        if (Math.Distance(b.other.position, body.position) > sight.range) continue;
        body.velocity += Push(body, b.other);
    }
}
```

Each boid looks at the boids near it, not at all of them. Nothing changes about what the loop does: the condition still runs for every row the index gives, and the rows come in the loop's normal order.

The condition can be a distance (`Math.Distance`, `DistanceSq`, `Length` or `LengthSq` of a difference, or `dx * dx + dy * dy`), a box written axis by axis, a comparison of one of the row's numbers (`b.unit.health < 10`), or an equality (`b.unit.team == myTeam`), combined with `&&`, `||` and `!`, written in the loop or in a function that returns it. Read-only locals can come first. The same goes for lists: `foreach (var wall in level.walls)`.

Equalities of whole numbers are found exactly, all of them at once, unless the condition also bounds a `float` place both ways (a distance or a box), which is searched instead. A world of chunks finds one by its place, an `int3`, and its dimension:

```csharp
foreach (var row in chunks)
{
    if (row.chunk.at.x != at.x || row.chunk.at.y != at.y || row.chunk.at.z != at.z) continue;
    if (row.chunk.dimension != dimension) continue;
    found = row.entity;
}
```

The loop visits the chunks at that place in that dimension and no others, however many share its `x`. Any of the row's `int`, `long`, `byte` and `char` numbers, enums and bools count, and an `int2`'s or `int3`'s components: a `long` a place is packed into (`row.chunk.key == key`) is found the same way. A whole number compared as a `float` or a `double` (`double d = row.chunk.key;`) is not exact, and is searched as the number it's compared as. Other bounds in the same condition, like `row.chunk.heat < limit`, narrow those further.

Write `indexed` before a loop that has to be indexed:

```csharp
indexed foreach (var b in boids) { ... }
```

`indexed` changes nothing about the loop. It turns a loop that can't be indexed into an error that says why, instead of a loop that quietly looks at every row. Common reasons:

- Something happens before the condition, such as a `Send`. Move the condition first.
- The value compared with changes inside the loop.
- The system changes the same field of its own entity, such as `body.position += body.velocity` in a system whose loop finds boids by `position`. The index is kept while the rows it was made from don't change, so read the others as [the tick started](https://tide-engine.dev/game/systems.md#as-the-tick-started) (`query (previous Body other, with Boid) boids`), or move that change into a system of its own. Handing the component as `mut` to a function or a task counts where that changes its match fields; a view handing its own to a [local task](https://tide-engine.dev/game/tasks.md#local-fields) changes only its local fields, which no loop finds rows by. Handing it to C as `mut` (an `extern` function, or one that passes it on to one) counts as changing all of it.

`tidec --schedule` lists every loop that skips rows, and whether an index finds the rest or why not. An index of rows that don't change, like walls, is made once and kept across ticks.

An index pays when the condition leaves most rows out. A condition most rows pass, such as `if (b.unit.down) continue;` in a battle where few are down, gains nothing from one, so when a search of a query's rows finds more than about one row in six, the loop goes through every row instead, which costs less for each. The results are the same either way, and nothing needs writing differently.

<a id="other-entities-the-world"></a>

## Other entities: the World

A system often needs another entity's component in the same tick: the target it attacks, the leader it follows. A `World` parameter gives it, by the entity's handle:

```csharp
system Attack(Attacker attacker, World world, mut Stats stats)
{
    if (!world.Has<Health>(attacker.target)) return;
    var target = world.Get<Health>(attacker.target);
    if (target.value <= attacker.damage) stats.kills += 1;
}
```

- `world.Get<Health>(e)` is a copy of that entity's `Health`, or its zero value when it has none.
- `world.Has<Health>(e)` tells whether it has one.
- `world.TryGet<Health>(e, out var health)` is both in one: whether it has one, and the copy, or the component's default when it has none (see [Out parameters](https://tide-engine.dev/language/functions.md#out-parameters)).
- `world.Set<Health>(e, value)` puts one back, and needs `mut World`. It does nothing for an entity without one.
- A read-only `Health` parameter keeps the value captured on entering that entity's invocation, including preceding invocations' writes. `Set` updates the world immediately: a following `Get` or query sees the new value.
- With `mut Health`, setting the current entity also replaces that active parameter immediately, including through helpers. Setting another entity leaves the parameter unchanged. Whole-value replacement discards unfinished edits; later edits are written back normally.

```csharp
system Reset(mut Health health, mut World world)
{
    world.Set<Health>(this, Health { value = 20 });
    health.value++; // Finishes at 21.
}
```

Between the `Set` and the final write-back, `Get` and queries read the published value of 20. An explicit copy made before `Set` keeps its old value.

What `Get` gives is a copy, as a list's element is. To change another entity's component, `Edit` it where it is: the block after the call names the component, and what the block changes is put back on the entity as the block ends.

```csharp
system Heal(Healer healer, mut World world)
{
    world.Edit<Health>(healer.patient, health)
    {
        if (health.value >= 100) return;
        health.value += 1;
        health.lastHealer = this;
    }
}
```

- In the block, `health` is the entity's `Health` itself, as a `mut` parameter is the component of the entity a system runs for: its fields change where they are, its lists and text too, with nothing copied, and a function's `mut` parameter can take it. The name is new, and only the block has it.
- It's put back however the block is left: at its end, or by a `return`, or a `break` or `continue` of a loop the `Edit` is in, or a `try` or `fail` in a function that can fail, in an async handler as anywhere. There's no `Set` to forget on an early `return`.
- An entity that's gone, or has no `Health`, skips the block, as `Set` does nothing then. Check `world.Has<Health>(e)` first for what to do instead.
- It needs `mut World`, like `Set`, and the schedule counts it as `Set`: it reads and writes every entity's `Health`, and keeps the system on one thread. So an `Edit` whose block never changes its name is a warning: read with `TryGet` instead.
- `this` can be edited beside a read-only parameter of the same component, as it can be `Set`: the stored component changes, and the parameter keeps what it read. Beside a `mut` parameter of it, change the parameter.
- Inside the block, read and change `health`, not `world.Get<Health>` of the same entity: the compiler says so where it can tell they're the same, and a task can't `await` there.
- `world.Edit<Purse>(from, a), world.Edit<Purse>(to, b) { ... }` edits two entities in one block, as other calls that take a block are listed. If they turn out to be one entity, `a` and `b` are the same component, and both changes land.

Taking it out, changing it and putting it back is what `Edit` does for you, and still works:

```csharp
mut var health = world.Get<Health>(healer.patient);
health.value += 1;
world.Set<Health>(healer.patient, health);
```

<a id="as-the-tick-started-by-handle"></a>

### As the tick started, by handle

`GetPrevious`, `HasPrevious` and `TryGetPrevious` are `Get`, `Has` and `TryGet` of the entity as it was when the tick started, whatever has run since:

```csharp
system Chase(mut Body body, Bot bot, World world)
{
    if (world.TryGetPrevious<Body>(bot.target, out var was))
        body.velocity = Math.Normalize(was.position - body.position) * bot.speed;
}
```

Like a [`previous` binding](https://tide-engine.dev/game/systems.md#as-the-tick-started), they read nothing the tick can change: the system waits for no system that changes `Body`, none waits for it, and its entities go across threads though it changes `Body` itself, where `world.Get<Body>` would keep them on one. An entity that wasn't there when the tick started (spawned this tick) has no `Body` then: `HasPrevious` is false and `GetPrevious` gives the zero value. Systems, match handlers and the functions they hand their World to can call them; views and tasks can't.

The signature doesn't say which components a system reaches this way: the engine reads it off the calls. Each counts as access to every entity's component, so the system is scheduled like one that touches them all, and one that calls `Set` or `Edit` runs on one thread. [The schedule](https://tide-engine.dev/game/schedule.md#through-the-world) and your editor show what each system reads and writes through its `World`. Where the change can wait for the end of the tick, an event (`e.Send(Hit { ... })`) keeps systems running side by side; see [Events](https://tide-engine.dev/game/events.md).

A function or method can take the `World` too, and the system passes its own:

```csharp
bool TryFind(Entity target, World world, out Health health)
{
    return world.TryGet<Health>(target, out health);
}

system Aim(mut Attacker attacker, World world)
{
    if (TryFind(attacker.target, world, out var health)) attacker.threat = health.value;
}
```

What the function reaches through it counts as the system's own, through however many functions it's passed, so nothing about the schedule changes: `Aim` reads every entity's `Health`. A function that calls `Set` or `Edit` takes `mut World`, and so does the system that passes it. The parameter rules above apply through helpers too, and a view can't call one that changes the match.

Views and event handlers take a `World` too; a view only reads the match through it, and can change local entities with `mut World`. A [local handler](https://tide-engine.dev/game/events.md#local-handlers) of one of the match's events takes none: it hears the match as the event left it, and the `World` is the match as it is now.

<a id="once-per-entity-or-once-per-tick"></a>

## Once per entity, or once per tick

A system with component parameters runs once for every matching entity, and `this` is the entity it's running for. One without them runs once per tick, for no entity, so it has no `this`:

```csharp
system CountDown(mut Round round, Time time)
{
    round.timeLeft -= time.dt;
}
```

`return;` ends the system for the current entity, and it goes on with the next one.

<a id="order"></a>

## Order

Systems run in one order, the same on every machine. By default, it follows the files, sorted by path, then the order of the systems in each file. A game's [packages](https://tide-engine.dev/packages/using-and-writing.md) come first, each after the packages it needs.

`[Before]` and `[After]` change that. They take any number of systems:

```csharp
[After(Gravity, Collisions)]
system Move(mut Body body, Time time)
{
    body.position += body.velocity * time.dt;
}
```

Of the systems whose constraints are met, the earliest in the default order runs next. Constraints that form a loop are an error that names the loop. Hover a system in your editor to see its place in the order.

Systems can share a name when their parameters differ, as [functions can](https://tide-engine.dev/language/functions.md#default-values-names-and-overloads). Nothing calls a system, so where one of them is named, it's written with its parameters' types, in order, with its filters and without names or `mut`:

```csharp
system Move(mut Body body, Speed speed, with Player) { ... }
system Move(mut Body body, Speed speed, with Enemy) { ... }

[After(Move(Body, Speed, with Player)), Before(Move(Body, Speed, with Enemy))]
system Aim(mut Turret turret, Body body) { ... }
```

A name alone is fine while only one system has it. When several share it, `[After(Move)]` is an error that lists them as they're written, and so is a parameter list that isn't exactly one's. Views and event handlers work the same way, and the schedule and the profiler show a shared name with its parameters.

A system marked `virtual` can be replaced by another package's `override`, which runs where it would have: at its place in this order, with its attributes, and under its name where others name it (see [Virtual and override](https://tide-engine.dev/language/overrides.md)).

<a id="named-phases"></a>

### Named phases

An enum gives shared names to parts of the tick. Assign systems to its phases with `Stage`:

```csharp
enum TickStages { Input, Simulation, Late }

[Stage(TickStages.Simulation)]
system Move(mut Body body, Time time)
{
    body.position += body.velocity * time.dt;
}

[Stage(TickStages.Simulation, 10)]
system Collisions(...) { ... }

[After(TickStages.Simulation)]
system Finish(...) { ... }
```

Phases follow the enum members' declaration order. The optional comma-separated offset orders systems within a phase: lower first, with 0 as the default. Negative offsets work too, and the enum needs no numeric spacing. Equal offsets keep the usual order and can use `Before` or `After` on particular systems.

`After(TickStages.Simulation)` follows every system in that phase, including its offsets; `Before` precedes all of them. Empty phases keep their position. A system in a later phase waits for the earlier phases to finish, while systems at the same offset can still run alongside each other. Unassigned systems keep their default order wherever the constraints allow. Separate enums have independent phase orders.

The same attributes order views among views and event handlers among the handlers of one event. They don't move code between the tick, the frame and event handling.

<a id="running-side-by-side"></a>

## Running side by side

Two systems that write the same component isn't a mistake: it's normal. Such systems run one after the other, in the order above. Systems that share nothing they write can run at the same time. The compiler works this out from the parameters, and can tell you why each system waits (see [The schedule](https://tide-engine.dev/game/schedule.md)):

```
stage 2  Move  (per entity)
         after Steer: both write Body
```

Declaring more than a system uses makes others wait for nothing, so it's a warning: a parameter that's never used, or a `mut` one that's never written (a `mut World` that never calls `Set` or `Edit` too). A component that's only there to pick entities belongs in `with`. The editors offer quick fixes for these.

<a id="written-in-c"></a>

## Written in C

A system's code can be C's: a library's, or a loop over every entity's numbers that's worth writing by hand. `extern system Move(mut Position position, Velocity velocity);` declares one, with no body, and C is handed the components as the arrays the match keeps them in, rather than an entity at a time. It's a system like the others to everything on this page: its parameters pick its entities, and it's ordered and scheduled by them. See [Systems written in C](https://tide-engine.dev/c/functions.md#systems-written-in-c).

<a id="what-systems-can-t-do"></a>

## What systems can't do

Systems run the match, so they can't read this machine's local state, and they can't draw: drawing happens every frame, in [views](https://tide-engine.dev/game/views.md).
