Nebula
Core

NebulaCost

Where a game says what one entity costs to simulate, beyond the category it falls into.

generated from the sources
Static class in namespace Nebula · Packages/com.1by3.nebula/Runtime/Core/NebulaCost.cs
public static class NebulaCost

Where a game says what one entity costs to simulate, beyond the category it falls into.

CostWeights is per category: a player, a bot, a server-driven entity, anything else. That is enough to balance a shooter and not enough for a world with ambient chickens and raid bosses in it, which are both "server-driven" and are not the same machine. The weight here is a multiplier on the category weight, so 1 (the default everywhere) leaves the balance exactly as it was.

Precedence, highest first (docs/cost-telemetry.md, D3):

  1. a weight carried in from another worker with the entity's handover state, or one set explicitly with NetworkIdentity.SetCostWeight: the mesh never overrules what was decided about this individual entity, so a boss keeps its weight when it crosses a seam;
  2. EntityWeight, this callback, when one is installed and it returns a weight of 0 or more;
  3. NetworkIdentity.CostWeight, the value on the prefab or the scene object.

The weight is evaluated when an entity is spawned and when NetworkIdentity.SetCostWeight is called - never per tick - so the callback may be as expensive as a prefab lookup and no more.

Fields

MaxWeight

public const float MaxWeight = 1024f;

The largest weight an entity may carry. A weight is clamped to [0, this]; NaN reads as 1.

EntityWeight

public static Func<NetworkIdentity, float> EntityWeight;

Optional: asked for the multiplier of every entity whose weight is being computed, in place of the value authored on it. Return a negative number to decline and let the authored NetworkIdentity.CostWeight stand. Installed once at start-up (NebulaCost.EntityWeight = id => id.GetComponent<Boss>() != null ? 8f : -1f;); it runs on the worker's main thread, inside the spawn, and its exceptions are logged and treated as declining.

Methods

Reset

public static void Reset();

Forget the callback. Tests call this in teardown; a game has no reason to.

Evaluate

public static float Evaluate(NetworkIdentity identity);

The weight identity should carry from now on: the callback's answer when it gives one, else the authored value, clamped to [0, MaxWeight].

Clamp

public static float Clamp(float weight);

A weight as the mesh will carry it: NaN reads as 1, and the range is [0, MaxWeight].

On this page