using System;
namespace BlaxZones
{
///
/// Package Rewards. Design: "DeliveryRouter, shared by every delivery path" > Context. Callers that can't
/// pass a source down to DropPodUtility.DropThingGroupsNear set Current in a prefix, keep the previous
/// value in __state and restore it in a finalizer (RewardPatches.cs). The DropThingGroupsNear prefix
/// reads it. SignalManager.SendSignal saves and clears it around every signal, so a quest part chained
/// through outSignalResult never sees a context that wasn't set for it. Cargo pods (1.4) reuse it.
///
/// The instances are fixed and hold no game state; only Current changes, for the length of one call.
///
public sealed class DeliveryContext
{
/// Item rewards quests drop at the trade spot.
public static readonly DeliveryContext QuestRewards = new DeliveryContext(DeliverySource.Rewards, "Quest reward delivery");
/// The context of the call running on this thread, or null. Set and restored only by the patches.
[ThreadStatic] public static DeliveryContext Current;
/// Which zone checkbox decides.
public readonly DeliverySource Source;
/// The ZonesLog key for failures on this path.
public readonly string LogKey;
private DeliveryContext(DeliverySource source, string logKey)
{
Source = source;
LogKey = logKey;
}
/// The global setting for this path ("Route quest rewards"), read live.
public bool Enabled
{
get
{
switch (Source)
{
case DeliverySource.Rewards:
return BlaxZonesMod.S.routeRewards;
default:
return false;
}
}
}
}
}