-
-
Notifications
You must be signed in to change notification settings - Fork 4
Feature: Body Temperature Tick Throttling
Tsu edited this page May 31, 2026
·
1 revision
This feature spreads expensive body-temperature updates with configurable intervals and per-entity jitter.
Main patch:
patches/VSSurvivalMod/Entity/Behavior/BehaviorBodyTemperature.cs.patch
The patch introduces server-side interval thresholds per entity:
float stratumUpdateThreshold = 2f;
float stratumHeatSourceThreshold = 5f;
float stratumFreezingAnimThreshold = 1f;
float stratumDamageCheckThreshold = 10f;On initialization, the behavior reflectively reads Performance.BodyTemperature config and applies jitter:
float upd = (float)bt.GetType().GetProperty("UpdateIntervalSeconds").GetValue(bt);
float heat = (float)bt.GetType().GetProperty("HeatSourceIntervalSeconds").GetValue(bt);
float anim = (float)bt.GetType().GetProperty("FreezingAnimIntervalSeconds").GetValue(bt);
float dmg = (float)bt.GetType().GetProperty("DamageCheckIntervalSeconds").GetValue(bt);
float jit = (float)bt.GetType().GetProperty("JitterPercent").GetValue(bt);
float jitter = 1f + ((float)entity.World.Rand.NextDouble() * 2f - 1f) * jit;Applied thresholds:
stratumUpdateThreshold = upd * jitter;
stratumHeatSourceThreshold = heat * jitter;
stratumFreezingAnimThreshold = anim * jitter;
stratumDamageCheckThreshold = dmg * jitter;OnGameTick now exits early when no accumulator reached its threshold:
if (freezingAnimAccum <= stratumFreezingAnimThreshold && slowaccum <= stratumHeatSourceThreshold && veryslowaccum <= stratumDamageCheckThreshold && accum <= stratumUpdateThreshold)
{
return;
}This skips repeated position and environment work on ticks where nothing is due.
Hardcoded intervals are replaced with threshold fields:
-
veryslowaccum > 10->veryslowaccum > stratumDamageCheckThreshold -
slowaccum > 3->slowaccum > stratumHeatSourceThreshold -
accum > 1->accum > stratumUpdateThreshold - freezing animation runs by
stratumFreezingAnimThreshold
patches/VSSurvivalMod/Entity/Behavior/BehaviorBodyTemperature.cs.patchVSSurvivalMod/Entity/Behavior/BehaviorBodyTemperature.cs-
sources/VintagestoryLib/Vintagestory/Server/StratumConfig.cs(Performance.BodyTemperature)