rimworld-blax-defaults/Source/BlaxDefaults/BlaxDefaultsSettings.cs

92 lines
5.1 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using Verse;
namespace BlaxDefaults
{
/// <summary>
/// Mod settings: the toggles and the dismissed overlap warnings only. The defaults themselves live in
/// their own file (DefaultsLibrary, DefaultsFile), never here: a mod settings file that fails to load is
/// replaced by fresh settings on the next write.
/// </summary>
public class BlaxDefaultsSettings : ModSettings
{
/// <summary>Master switch. Off: no hook applies anything; the defaults file is kept.</summary>
public bool enabled = true;
/// <summary>New stockpiles start from their type's default.</summary>
public bool stockpileDefaults = true;
/// <summary>New storage buildings start from their kind's default.</summary>
public bool storageDefaults = true;
/// <summary>New production bills get the values of "Every new bill".</summary>
public bool billDefaults = true;
/// <summary>The forbid rules as a category: off, no gear rule, strip switch or corpse switch acts.</summary>
public bool forbidRules = true;
/// <summary>"Gear your colony drops". Acts only with a saved filter under forbid:colony.</summary>
public bool colonyGearRule;
/// <summary>The colony rule's "Where": anywhere (true) or only inside the home area.</summary>
public bool colonyGearAnywhere = true;
/// <summary>"Gear enemies drop". Acts only with a saved filter under forbid:enemies.</summary>
public bool enemyGearRule;
/// <summary>The enemy rule's "Where": anywhere (true) or only inside the home area.</summary>
public bool enemyGearAnywhere = true;
/// <summary>Stripping one of your colony's pawns or corpses forbids what the colony filter refuses.</summary>
public bool colonyStripRule;
/// <summary>Stripping an enemy or an enemy corpse forbids what the enemy filter refuses.</summary>
public bool enemyStripRule;
/// <summary>Animal corpses outside the home area are allowed.</summary>
public bool animalCorpsesAllowed;
/// <summary>Enemy corpses outside the home area are allowed.</summary>
public bool enemyCorpsesAllowed;
/// <summary>Other corpses outside the home area are allowed.</summary>
public bool otherCorpsesAllowed;
/// <summary>The settings page and one message per session name active mods that do some of the same things.</summary>
public bool warnOverlaps = true;
/// <summary>Package ids whose overlap message the player dismissed with "Don't remind me".</summary>
public List<string> dismissedOverlaps = new List<string>();
public override void ExposeData()
{
base.ExposeData();
Scribe_Values.Look(ref enabled, "enabled", true);
Scribe_Values.Look(ref stockpileDefaults, "stockpileDefaults", true);
Scribe_Values.Look(ref storageDefaults, "storageDefaults", true);
Scribe_Values.Look(ref billDefaults, "billDefaults", true);
Scribe_Values.Look(ref forbidRules, "forbidRules", true);
Scribe_Values.Look(ref colonyGearRule, "colonyGearRule", false);
Scribe_Values.Look(ref colonyGearAnywhere, "colonyGearAnywhere", true);
Scribe_Values.Look(ref enemyGearRule, "enemyGearRule", false);
Scribe_Values.Look(ref enemyGearAnywhere, "enemyGearAnywhere", true);
Scribe_Values.Look(ref colonyStripRule, "colonyStripRule", false);
Scribe_Values.Look(ref enemyStripRule, "enemyStripRule", false);
Scribe_Values.Look(ref animalCorpsesAllowed, "animalCorpsesAllowed", false);
Scribe_Values.Look(ref enemyCorpsesAllowed, "enemyCorpsesAllowed", false);
Scribe_Values.Look(ref otherCorpsesAllowed, "otherCorpsesAllowed", false);
Scribe_Values.Look(ref warnOverlaps, "warnOverlaps", true);
Scribe_Collections.Look(ref dismissedOverlaps, "dismissedOverlaps", LookMode.Value);
if (Scribe.mode == LoadSaveMode.PostLoadInit || Scribe.mode == LoadSaveMode.LoadingVars)
dismissedOverlaps ??= new List<string>();
}
/// <summary>Back to the shipped values. Leaves the defaults file alone.</summary>
public void Reset()
{
var d = new BlaxDefaultsSettings();
enabled = d.enabled;
stockpileDefaults = d.stockpileDefaults;
storageDefaults = d.storageDefaults;
billDefaults = d.billDefaults;
forbidRules = d.forbidRules;
colonyGearRule = d.colonyGearRule;
colonyGearAnywhere = d.colonyGearAnywhere;
enemyGearRule = d.enemyGearRule;
enemyGearAnywhere = d.enemyGearAnywhere;
colonyStripRule = d.colonyStripRule;
enemyStripRule = d.enemyStripRule;
animalCorpsesAllowed = d.animalCorpsesAllowed;
enemyCorpsesAllowed = d.enemyCorpsesAllowed;
otherCorpsesAllowed = d.otherCorpsesAllowed;
warnOverlaps = d.warnOverlaps;
dismissedOverlaps = new List<string>();
}
}
}