using RimWorld;
using Verse;
namespace BlaxZones
{
///
/// Package Rewards. Trade Ships Drop Spot (Workshop 1969732297, package id smashphil.dropspot) moves
/// both orbital drops and quest rewards to its marker. With 1.1 Zones covers both, so a one-time
/// message says the player can unsubscribe (design: 1.1 "Quest rewards land in the zone", Unsubscribe
/// hint). Detected by its marker def, read from github.com/SmashPhil/TradeShips-Drop-Spot,
/// Defs/DropSpotIndicator.xml (checked 2026-11-30): ThingDef "DropSpotTradeShip". The mod isn't installed
/// on the test machine; tests simulate the def through Compat.SimulatedActive.
///
public static partial class Compat
{
/// Trade Ships Drop Spot's marker ThingDef.
public const string TradeShipsDropSpotDef = "DropSpotTradeShip";
/// Defs never change after startup, so the lookup runs once.
private static bool? tradeShipsDropSpotDefLoaded;
/// The marker def exists (the mod is active), or a test simulates it.
public static bool TradeShipsDropSpotActive
{
get
{
if (SimulatedActive.Count > 0 && SimulatedActive.Contains(TradeShipsDropSpotDef))
return true;
tradeShipsDropSpotDefLoaded ??= DefDatabase.GetNamedSilentFail(TradeShipsDropSpotDef) != null;
return tradeShipsDropSpotDefLoaded.Value;
}
}
}
///
/// The unsubscribe hint for Trade Ships Drop Spot: shown once, ever, on a map tick once the map has a
/// delivery zone, while "Route orbital trade" and "Route quest rewards" are both on. Before the
/// player makes a delivery zone Zones routes nothing, so the advice would be wrong. "Shown" is kept
/// in the mod settings file (BlaxZonesSettings.tradeShipsHintShown), so nothing enters a save and the
/// hint doesn't come back on the next load or game.
///
public static class TradeShipsDropSpotHint
{
/// The mod is active and Zones routes everything it would place.
public static bool Applies =>
BlaxZonesMod.S.routeOrbital && BlaxZonesMod.S.routeRewards && Compat.TradeShipsDropSpotActive;
/// The hint text, also logged.
public static string Text => "BlaxZones_TradeShipsDropSpotHint".Translate();
/// Called on every map tick. After the hint was shown it costs one bool read.
public static void Check(Map map)
{
if (BlaxZonesMod.S.tradeShipsHintShown || !Applies || !DeliveryRouter.HasDeliveryZone(map))
return;
Show();
}
/// Shows the message, logs it and remembers it in the mod settings.
private static void Show()
{
BlaxZonesMod.S.tradeShipsHintShown = true;
BlaxZonesMod.SaveSettings();
string text = Text;
Messages.Message(text, MessageTypeDefOf.NeutralEvent, historical: true);
Log.Message("[Blax Zones] " + text);
}
/// Forgets that the hint was shown, so the next check may show it again. Tests only.
public static void Reset()
{
BlaxZonesMod.S.tradeShipsHintShown = false;
}
}
}