105 lines
5.2 KiB
C#
105 lines
5.2 KiB
C#
|
|
using System.Globalization;
|
||
|
|
using RimWorld;
|
||
|
|
using Verse;
|
||
|
|
|
||
|
|
namespace BlaxDefaults
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// The values a new production bill starts with, stored under DefaultsKeys.EveryBill ("bill:*"); recipe
|
||
|
|
/// defaults (1.1) reuse it per recipe. Every value starts at "the game's default": a value is applied
|
||
|
|
/// only when its set flag is on (repeatMode and storeMode: when not null). Strings and numbers only.
|
||
|
|
/// Pawn restrictions, a specific stockpile, names, styles and xenogerms are never part of it.
|
||
|
|
/// </summary>
|
||
|
|
public class BillValues : DefaultsEntry
|
||
|
|
{
|
||
|
|
/// <summary>BillRepeatModeDef name: RepeatCount, TargetCount or Forever. Null: the game's default.</summary>
|
||
|
|
public string repeatMode;
|
||
|
|
public bool setRepeatCount;
|
||
|
|
public int repeatCount = 1;
|
||
|
|
public bool setTargetCount;
|
||
|
|
public int targetCount = 10;
|
||
|
|
public bool setPauseWhenSatisfied;
|
||
|
|
public bool pauseWhenSatisfied;
|
||
|
|
public bool setUnpauseWhenYouHave;
|
||
|
|
public int unpauseWhenYouHave = 5;
|
||
|
|
public bool setIngredientSearchRadius;
|
||
|
|
/// <summary>999 is unlimited, as in vanilla.</summary>
|
||
|
|
public float ingredientSearchRadius = 999f;
|
||
|
|
public bool setAllowedSkillRange;
|
||
|
|
public IntRange allowedSkillRange = new IntRange(0, 20);
|
||
|
|
/// <summary>BillStoreModeDef name: BestStockpile or DropOnFloor, never SpecificStockpile. Null: the game's default.</summary>
|
||
|
|
public string storeMode;
|
||
|
|
public bool setIncludeEquipped;
|
||
|
|
public bool includeEquipped;
|
||
|
|
public bool setIncludeTainted;
|
||
|
|
public bool includeTainted;
|
||
|
|
public bool setHpRange;
|
||
|
|
public FloatRange hpRange = FloatRange.ZeroToOne;
|
||
|
|
public bool setQualityRange;
|
||
|
|
public QualityRange qualityRange = QualityRange.All;
|
||
|
|
|
||
|
|
public BillValues()
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
public BillValues(string key)
|
||
|
|
{
|
||
|
|
this.key = key;
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>True when at least one value differs from "the game's default".</summary>
|
||
|
|
public bool AnySet =>
|
||
|
|
repeatMode != null || setRepeatCount || setTargetCount || setPauseWhenSatisfied || setUnpauseWhenYouHave
|
||
|
|
|| setIngredientSearchRadius || setAllowedSkillRange || storeMode != null || setIncludeEquipped
|
||
|
|
|| setIncludeTainted || setHpRange || setQualityRange;
|
||
|
|
|
||
|
|
public override void ExposeData()
|
||
|
|
{
|
||
|
|
base.ExposeData();
|
||
|
|
Scribe_Values.Look(ref repeatMode, "repeatMode");
|
||
|
|
Scribe_Values.Look(ref setRepeatCount, "setRepeatCount");
|
||
|
|
Scribe_Values.Look(ref repeatCount, "repeatCount", 1);
|
||
|
|
Scribe_Values.Look(ref setTargetCount, "setTargetCount");
|
||
|
|
Scribe_Values.Look(ref targetCount, "targetCount", 10);
|
||
|
|
Scribe_Values.Look(ref setPauseWhenSatisfied, "setPauseWhenSatisfied");
|
||
|
|
Scribe_Values.Look(ref pauseWhenSatisfied, "pauseWhenSatisfied");
|
||
|
|
Scribe_Values.Look(ref setUnpauseWhenYouHave, "setUnpauseWhenYouHave");
|
||
|
|
Scribe_Values.Look(ref unpauseWhenYouHave, "unpauseWhenYouHave", 5);
|
||
|
|
Scribe_Values.Look(ref setIngredientSearchRadius, "setIngredientSearchRadius");
|
||
|
|
Scribe_Values.Look(ref ingredientSearchRadius, "ingredientSearchRadius", 999f);
|
||
|
|
Scribe_Values.Look(ref setAllowedSkillRange, "setAllowedSkillRange");
|
||
|
|
Scribe_Values.Look(ref allowedSkillRange, "allowedSkillRange", new IntRange(0, 20));
|
||
|
|
Scribe_Values.Look(ref storeMode, "storeMode");
|
||
|
|
Scribe_Values.Look(ref setIncludeEquipped, "setIncludeEquipped");
|
||
|
|
Scribe_Values.Look(ref includeEquipped, "includeEquipped");
|
||
|
|
Scribe_Values.Look(ref setIncludeTainted, "setIncludeTainted");
|
||
|
|
Scribe_Values.Look(ref includeTainted, "includeTainted");
|
||
|
|
Scribe_Values.Look(ref setHpRange, "setHpRange");
|
||
|
|
Scribe_Values.Look(ref hpRange, "hpRange", FloatRange.ZeroToOne);
|
||
|
|
Scribe_Values.Look(ref setQualityRange, "setQualityRange");
|
||
|
|
Scribe_Values.Look(ref qualityRange, "qualityRange", QualityRange.All);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override DefaultsEntry Clone() => (BillValues)MemberwiseClone();
|
||
|
|
|
||
|
|
public BillValues CloneValues() => (BillValues)Clone();
|
||
|
|
|
||
|
|
public override string Fingerprint()
|
||
|
|
{
|
||
|
|
CultureInfo c = CultureInfo.InvariantCulture;
|
||
|
|
return key + "|rm:" + repeatMode
|
||
|
|
+ "|rc:" + setRepeatCount + "," + repeatCount
|
||
|
|
+ "|tc:" + setTargetCount + "," + targetCount
|
||
|
|
+ "|ps:" + setPauseWhenSatisfied + "," + pauseWhenSatisfied
|
||
|
|
+ "|uy:" + setUnpauseWhenYouHave + "," + unpauseWhenYouHave
|
||
|
|
+ "|rad:" + setIngredientSearchRadius + "," + ingredientSearchRadius.ToString("R", c)
|
||
|
|
+ "|sk:" + setAllowedSkillRange + "," + allowedSkillRange.min + "~" + allowedSkillRange.max
|
||
|
|
+ "|sm:" + storeMode
|
||
|
|
+ "|eq:" + setIncludeEquipped + "," + includeEquipped
|
||
|
|
+ "|ta:" + setIncludeTainted + "," + includeTainted
|
||
|
|
+ "|hp:" + setHpRange + "," + hpRange.min.ToString("R", c) + "~" + hpRange.max.ToString("R", c)
|
||
|
|
+ "|q:" + setQualityRange + "," + qualityRange.min + "~" + qualityRange.max;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|