Skip to content

Feature: Timed Despawn Stagger and Budget

Tsu edited this page May 31, 2026 · 1 revision

This feature spreads timed-despawn checks and caps how many checks run in a single tick.

Stagger Window

Patch in BehaviorDespawn:

// Stratum: widen the stagger window from 1s to ~5s
accumOffset += (float)((entity.EntityId / 73.0) % 5);

This distributes check times across a wider window.

Per-Tick Budget

Stratum adds a shared static budget for despawn check evaluations:

private static long stratumLastBudgetTickMs;
private static int stratumChecksThisTick;
private const int StratumMaxChecksPerTick = 16;

Budget gate in OnGameTick:

if (stratumChecksThisTick >= StratumMaxChecksPerTick)
{
    accumSeconds = accumOffset - 0.05f;
    return;
}
stratumChecksThisTick++;

This defers excess checks to near-future ticks instead of letting one tick eat all of them.

Related Files

  • patches/VSEssentials/Entity/Behavior/BehaviorDespawn.cs.patch
  • VSEssentials/Entity/Behavior/BehaviorDespawn.cs

Clone this wiki locally