API Reference › Annotations › @Owned
annotation

@Owned

@Owned model Name { … }

@Owned declares that every instance of a model carries a network owner — it adds an owner slot to the model (the runtime's @L_owner array), which the builtins owner, set_owner, and is_owner read and assign. A fresh instance starts unowned (-1) until the authority assigns it. Ownership is what gates who may write @Sync(to: owner) fields and who runs @Predicted control handlers, and it is stored in the world snapshot so it round-trips through replication and rollback. Mark the models that represent a player's avatar or units; leave shared scenery unowned.

Example

program OwnedModel {
  @Sync property Position { column: int = 0, row: int = 0 }
  @Owned model Player { @Sync Position }              # each Player instance has an owner slot

  entry {
    spawn Player { Position { column: 5, row: 6 } }
    for (Position) in query [Position, {Player}] {
      let player_id = self()
      print(owner(player_id))          # -1 — unowned until assigned
      set_owner(player_id, 0)
      print(is_owner(player_id))       # 1  — the local peer now owns it
    }
  }
}
← All symbols