feat(sverm): enforce the beehive cap, and put the aura and the nest limits in config

"Beehives per Aura" was bound into the config and then read by nobody.
SvermConfigManagement.Beehives had no callers and neither did the
constant behind it, so the entry described a limit that did not exist and
a player could raise thirty hives in one aura and get thirty workers.

SweepAura is two passes now, with the cap between them. The first applies
to hives already taken and counts them - that maintenance is not
skippable, it is what survives a zone reload - and only then are new
candidates considered. One pass would have let the order the physics
query happens to return decide whether a hive counted against the cap or
was measured by it. The minute keeps running on a hive that does not fit
today, so when a taken hive is destroyed the one that has waited longest
is claimed on the next sweep instead of starting over; lowering the cap
never hands a hive back.

Three limits are now the player's: Aura Radius, Nests per Radius and Nest
Spacing Radius. PieceDensityLimit.Register takes a snapshot of its
numbers, so the Hive Market and the Brood Mound both watch their entries
and re-register when one moves - Register replaces an entry rather than
stacking a second limit on the same piece.

All three are clamped, and the reason is not tidiness: Register REFUSES a
radius of zero or a maximum below one, and a refused limit is no limit at
all. A player typing 0 into "Nests per Radius" to mean "no nests" would
have been handed unlimited nests.

Every player-facing string that stated the old numbers now reads the live
ones - the two build refusals, the orphaned market's message and hover,
and the two Compendium lines. The nest's hover shows the cap next to the
count, so moving the knob has visible effect.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Ferdinando 2026-08-29 08:45:28 +02:00
commit 7ac7f99287
6 changed files with 165 additions and 30 deletions

View file

@ -351,7 +351,9 @@ namespace RacesOfValheim
public static readonly float EyeGlowStrength = 0.22f;
// ─── The colony (stub - see SvermHive when that half is written) ─────
/// <summary>Two nests per square mile. A square mile is 2.59 km2; the circle of equal area has r = 908 m.</summary>
/// <summary>Two nests per square mile. A square mile is 2.59 km2; the circle of equal area
/// has r = 908 m. The DEFAULT pair only - both are bound in SvermConfigManagement, and
/// SvermHive re-registers its density limit when either moves.</summary>
public static readonly float HiveDensityRadius = 908f;
public const int HiveDensityMax = 2;
@ -361,8 +363,8 @@ namespace RacesOfValheim
// ─── Colony caps ─────────────────────────────────────────────────────
// The DEFAULTS. What is actually enforced comes from SvermConfigManagement, which binds
// these into the .cfg so a machine that cannot carry nineteen creatures can say so without
// a rebuild. Only the nest density stays out of reach - two per square mile is a rule
// about the world, not a comfort setting.
// a rebuild. Nothing in this block is read directly by the game any more - the nest density
// above was the last exception and it is bound too now.
public const int CapBrood = 8;
public const int CapSeeker = 6;
public const int CapSoldier = 3;