Skip to main content

ForestResetPatches

A static class in TavernLib, TavernLib.Patches.

Patches ForestGenerator.Wipe so a forest reset clears the forest and moves players out but keeps the running seed, saving the new seed for the next start. Server. Steps aside if another mod also prefixes Wipe.

Fields​

3 private and internal fields
MemberWhat it is
private static bool? _otherResetCached answer to whether another mod's prefix on Wipe replaces TavernLib's reset.
private static readonly ConditionalWeakTable<ForestGenerator, StrongBox<int>> QueuedThe new seed waiting for the next start, per forest generator.
private static readonly HashSet<ForestGenerator> ResettingForests whose reset is running now, so a second call is ignored.

Methods​

MemberWhat it is
static bool AnswerReset(ForestGenerator forest, ref Task __result)Prefix on WorldCommandModule.ForestCommandModule.Reset that skips it, runs the wipe and answers what happened.
static bool IsQueued(ForestGenerator forest)True when a reset of this forest is waiting for the next server start.
static bool QueueReset(ForestGenerator __instance, int newSeed, ref Task __result, MethodBase __originalMethod)Prefix on ForestGenerator.Wipe that skips it and queues the reset, unless another assembly also prefixes Wipe. A negative seed picks a random one.
3 private and internal methods
MemberWhat it is
private static async Task<string> Answer(ForestGenerator forest)Runs the forest wipe and returns text saying whether TavernLib's reset or another mod's ran.
private static bool OtherReset(MethodBase wipe)True when a prefix from another assembly is patched onto ForestGenerator.Wipe, in which case TavernLib leaves the reset to it.
private static async Task Queue(ForestGenerator forest, int newSeed)Clears the forest's chunks, moves players outside the forest, and records the new seed for the next start.