63 lines
2.5 KiB
C#
63 lines
2.5 KiB
C#
using RimWorld;
|
|
using Verse;
|
|
|
|
namespace BlaxZones
|
|
{
|
|
/// <summary>
|
|
/// Package Tab. Copied delivery zone settings for the copy/paste gizmos: a copy of the choices
|
|
/// (filter, priority, sources, camp), never a Zone, so no game state sits in a static (design:
|
|
/// "Rules every feature follows"). Paste goes through Zone_Delivery.CopySettingsFrom or the same fields.
|
|
///
|
|
/// Like vanilla's StorageSettingsClipboard (StorageSettingsClipboard.cs:8-27) it keeps a detached
|
|
/// ThingFilter: defs only, no settings-changed callback, so it survives loading another game.
|
|
/// </summary>
|
|
public static class DeliveryClipboard
|
|
{
|
|
private static ThingFilter filter;
|
|
private static StoragePriority priority = StoragePriority.Normal;
|
|
private static bool acceptOrbital = true;
|
|
private static bool acceptRewards = true;
|
|
private static bool acceptCaravan = true;
|
|
private static bool campHere;
|
|
private static bool copied;
|
|
|
|
public static bool HasCopy => copied;
|
|
|
|
/// <summary>Copies the zone's filter, priority, sources and camp flag. Never the zone, its cells or its label.</summary>
|
|
public static void Copy(Zone_Delivery zone)
|
|
{
|
|
if (zone == null)
|
|
return;
|
|
filter ??= new ThingFilter();
|
|
if (zone.filter != null)
|
|
filter.CopyAllowancesFrom(zone.filter);
|
|
else
|
|
filter.CopyAllowancesFrom(DeliveryFilters.NewDefaultFilter());
|
|
priority = zone.priority;
|
|
acceptOrbital = zone.acceptOrbital;
|
|
acceptRewards = zone.acceptRewards;
|
|
acceptCaravan = zone.acceptCaravan;
|
|
campHere = zone.campHere;
|
|
copied = true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Writes the copied settings into the zone, the same fields Zone_Delivery.CopySettingsFrom
|
|
/// writes. Does nothing before the first copy. The zone's cells and label stay.
|
|
/// </summary>
|
|
public static void PasteInto(Zone_Delivery zone)
|
|
{
|
|
if (zone == null || !copied)
|
|
return;
|
|
zone.filter ??= new ThingFilter();
|
|
if (filter != null)
|
|
zone.filter.CopyAllowancesFrom(filter);
|
|
zone.priority = priority;
|
|
zone.acceptOrbital = acceptOrbital;
|
|
zone.acceptRewards = acceptRewards;
|
|
zone.acceptCaravan = acceptCaravan;
|
|
zone.campHere = campHere;
|
|
}
|
|
}
|
|
}
|