Skip to content

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.

What It Adds

From BehaviorRepulseAgents:

public static int StratumMaxCollisionsPerEntity = 12;
public static float StratumDistanceGateBlocks = 24f;
public static float StratumNearBandBlocks = 12f;
public static int StratumFarBandSkipTicks = 4;

Distance Gate

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.

Collision Cap

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.

Runtime Config Bridge

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.

Related Files

  • patches/VSEssentials/Entity/Behavior/BehaviorRepulseAgents.cs.patch
  • VSEssentials/Entity/Behavior/BehaviorRepulseAgents.cs
  • sources/VintagestoryLib/Vintagestory/Server/StratumConfig.cs (Performance.EntityCollisions)

Clone this wiki locally