Class ZoneCycle
Leave the area and come back: the lifecycle event in which the game destroys every object of a zone the player has
left and recreates it from its saved data on return. A mod's object that keeps state only in a component field loses
it here, and an object whose teardown throws shows up as ZNetScene.RemoveObjects errors in the client's log.
Run(GameActor, GameActor, CancellationToken) reads the Zones through the default ValheimCLI plugin's zone observation and requires them loaded, then has the protected player arrive at Away (Arrive(GameActor?, GameActor, HeightExpectation, TimeSpan, CancellationToken, bool, bool): one teleport by the server, arrival read on the client, never flying) and waits until the client holds nothing of those zones: no terrain and no object instance. Then the player arrives at Back and it waits until the zones are loaded again, every saved object instantiated. Re-observe the mod's objects afterwards and compare them with what was there before; scan the client's log for teardown errors.
How far is far enough comes from the client's own simulation distance, read before leaving: in 1.0.16 a client keeps a zone's objects while the player is within near + far rings of it (the distant ones that far out, the rest within near rings) and its terrain within near rings, dropping the terrain once it has been out of that range for 4 s and its last near object has gone. So Away's zone must be at least near + far + 1 rings from every zone of interest; closer is refused before anything moves, and a player that settles closer fails. Each wait reads the client at Interval until StepTimeout; expiry names the zones and the last reading. The teleports are never repeated.
public sealed class ZoneCycle
- Inheritance
-
objectZoneCycle
Properties
Away
Declared dry ground far enough away that the client unloads every zone of interest.
public required HeightExpectation Away { get; init; }
Property Value
Back
Declared dry ground to return to, within the loaded range of every zone of interest (usually the measurement point).
public required HeightExpectation Back { get; init; }
Property Value
Interval
How often the zones are re-read while waiting.
public TimeSpan Interval { get; init; }
Property Value
- TimeSpan
StepTimeout
How long each of the four waits may take: arriving away, the unload, arriving back and the reload.
public required TimeSpan StepTimeout { get; init; }
Property Value
- TimeSpan
Zones
The zones whose objects must unload and come back: 1 to 64, all different.
public required IReadOnlyList<ZoneId> Zones { get; init; }
Property Value
- IReadOnlyList<ZoneId>
Methods
RingsToLeave(SimulationRange)
Rings of zones between the away point and every zone of interest that make the client drop them all.
public static int RingsToLeave(SimulationRange range)
Parameters
rangeSimulationRange
Returns
- int
Run(ClientRound, CancellationToken, string)
Runs the cycle within a ClientRounds measurement: each part is a {round}: ... step, and the
readings so far are written to {round}-{evidence}.json (default zone-cycle) whether the cycle passes or
fails. Name each cycle's evidence differently to run more than one in a round.
public ZoneCycleResult Run(ClientRound round, CancellationToken cancellation = default, string evidence = "zone-cycle")
Parameters
roundClientRoundcancellationCancellationTokenevidencestring
Returns
Run(GameActor, GameActor, CancellationToken)
Runs the cycle for the only player on server, joined and protected on client.
public ZoneCycleResult Run(GameActor server, GameActor client, CancellationToken cancellation = default)