Ara
Download

Search or run a command

Jump to a section or open an Ara link.

Class · Ara

Behaviour

A per-entity object with Unity-like ergonomics that holds no authoritative state. Declare sealed partial class Door : Behaviour with [Property] public partial float OpenAngle { get; set; }: the generator backs each property with a column of the generated Door data component, so the value is saved, replicated and survives reload. Other instance fields must be TransientAttribute caches (ARA0101).

public abstract class Behaviour

Lifecycle: OnSpawn once when the entity gains the behaviour, OnTick every fixed tick, OnFrame every presented frame, OnReload instead of OnSpawn on objects recreated by a module reload. Behaviours of one type run serially in a deterministic order, with exclusive world access, so Get may touch any component.

Properties

Entity

public Entity Entity { get; }

The entity this behaviour belongs to.

Commands

protected Commands Commands { get; }

Structural changes, applied after this phase.

Fields

Rng

protected Rng Rng;

Deterministic random numbers, reseeded for every callback from the tick, the type and the entity.

Methods

OnSpawn

protected virtual void OnSpawn();

Called once, the first tick the entity has this behaviour.

OnTick

protected virtual void OnTick(in Tick tick);

Called every fixed simulation tick.

OnFrame

protected virtual void OnFrame(in Frame frame);

Called every presented frame (presentation only; never change simulation state here).

OnReload

protected virtual void OnReload();

Called instead of OnSpawn on an object recreated by a module reload; rebuild transient caches here.

Get

protected ref T Get<T>() where T : IComponent<T>;

One of this entity's components, for reading and writing.

Has

protected bool Has<T>() where T : IComponent<T>;

True if this entity has the component.