50 lines
1.9 KiB
C#
50 lines
1.9 KiB
C#
using System;
|
|
|
|
namespace BlaxZones
|
|
{
|
|
/// <summary>
|
|
/// 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.
|
|
/// </summary>
|
|
public sealed class DeliveryContext
|
|
{
|
|
/// <summary>Item rewards quests drop at the trade spot.</summary>
|
|
public static readonly DeliveryContext QuestRewards = new DeliveryContext(DeliverySource.Rewards, "Quest reward delivery");
|
|
|
|
/// <summary>The context of the call running on this thread, or null. Set and restored only by the patches.</summary>
|
|
[ThreadStatic] public static DeliveryContext Current;
|
|
|
|
/// <summary>Which zone checkbox decides.</summary>
|
|
public readonly DeliverySource Source;
|
|
|
|
/// <summary>The ZonesLog key for failures on this path.</summary>
|
|
public readonly string LogKey;
|
|
|
|
private DeliveryContext(DeliverySource source, string logKey)
|
|
{
|
|
Source = source;
|
|
LogKey = logKey;
|
|
}
|
|
|
|
/// <summary>The global setting for this path ("Route quest rewards"), read live.</summary>
|
|
public bool Enabled
|
|
{
|
|
get
|
|
{
|
|
switch (Source)
|
|
{
|
|
case DeliverySource.Rewards:
|
|
return BlaxZonesMod.S.routeRewards;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|