-
-
Notifications
You must be signed in to change notification settings - Fork 4
Feature: Repulse‐Agents Gate and Collision Cap
Tsu edited this page May 31, 2026
·
1 revision
This feature reduces the cost of creature repulse walks in dense populations.
From BehaviorRepulseAgents:
public static int StratumMaxCollisionsPerEntity = 12;
public static float StratumDistanceGateBlocks = 24f;
public static float StratumNearBandBlocks = 12f;
public static int StratumFarBandSkipTicks = 4;On the server, non-player entities can skip the repulse partition walk when no player is nearby:
if (cworld == null && entity is not EntityPlayer)
{
float gate = StratumDistanceGateBlocks;
if (gate > 0f)
{
float nearest = entity.NearestPlayerDistance;
if (nearest > gate) return;
if (StratumFarBandSkipTicks > 1 && nearest > StratumNearBandBlocks)
{
long tickIndex = entity.World.ElapsedMilliseconds / 33L;
if (((tickIndex + entity.EntityId) % StratumFarBandSkipTicks) != 0L) return;
}
}
}Players are not gated by this block.
Once enough push interactions happen in one tick, the walk stops:
int cap = StratumMaxCollisionsPerEntity;
if (cap > 0 && ++stratumPushCount >= cap) return false;Returning false stops WalkEntities for this caller.
StratumRepulseRuntimeConfig reads Stratum runtime config via reflection and applies values to these public static fields in VSEssentials.
That avoids a direct assembly dependency from VSEssentials to VintagestoryLib internals.
patches/VSEssentials/Entity/Behavior/BehaviorRepulseAgents.cs.patchVSEssentials/Entity/Behavior/BehaviorRepulseAgents.cs-
sources/VintagestoryLib/Vintagestory/Server/StratumConfig.cs(Performance.EntityCollisions)