-
-
Notifications
You must be signed in to change notification settings - Fork 372
/
ModConfig.cs
73 lines (58 loc) · 3.9 KB
/
ModConfig.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;
using Pathoschild.Stardew.Common;
using StardewValley.Extensions;
namespace Pathoschild.Stardew.Automate.Framework.Models
{
/// <summary>The raw mod configuration.</summary>
internal class ModConfig
{
/*********
** Accessors
*********/
/// <summary>Whether Automate is enabled.</summary>
public bool Enabled { get; set; } = true;
/// <summary>The number of ticks between each automation process (60 = once per second).</summary>
public int AutomationInterval { get; set; } = 60;
/// <summary>The key bindings.</summary>
public ModConfigKeys Controls { get; set; } = new();
/// <summary>The in-game object names through which machines can connect.</summary>
public HashSet<string> ConnectorNames { get; set; } = new(StringComparer.OrdinalIgnoreCase);
/// <summary>How Junimo huts should automate gems.</summary>
/// <remarks>The <see cref="JunimoHutBehavior.AutoDetect"/> option is equivalent to <see cref="JunimoHutBehavior.Ignore"/>.</remarks>
public JunimoHutBehavior JunimoHutBehaviorForGems { get; set; } = JunimoHutBehavior.AutoDetect;
/// <summary>How Junimo huts should automate fertilizer items.</summary>
/// <remarks>The <see cref="JunimoHutBehavior.AutoDetect"/> option is equivalent to <see cref="JunimoHutBehavior.Ignore"/> (if Better Junimos is installed), else <see cref="JunimoHutBehavior.MoveIntoChests"/>.</remarks>
public JunimoHutBehavior JunimoHutBehaviorForFertilizer { get; set; } = JunimoHutBehavior.AutoDetect;
/// <summary>How Junimo huts should automate seed items.</summary>
/// <remarks>The <see cref="JunimoHutBehavior.AutoDetect"/> option is equivalent to <see cref="JunimoHutBehavior.Ignore"/> (if Better Junimos is installed), else <see cref="JunimoHutBehavior.MoveIntoChests"/>.</remarks>
public JunimoHutBehavior JunimoHutBehaviorForSeeds { get; set; } = JunimoHutBehavior.AutoDetect;
/// <summary>Whether to collect moss on trees.</summary>
public bool CollectTreeMoss { get; set; } = true;
/// <summary>Whether to log a warning if the player installs a custom-machine mod that requires a separate compatibility patch which isn't installed.</summary>
public bool WarnForMissingBridgeMod { get; set; } = true;
/// <summary>The configuration for specific machines by ID.</summary>
public Dictionary<string, ModConfigMachine> MachineOverrides { get; set; } = new(StringComparer.OrdinalIgnoreCase);
/// <summary>The minimum machine processing time in minutes for which to apply fairy dust.</summary>
public int MinMinutesForFairyDust { get; set; } = 20;
/*********
** Public methods
*********/
/// <summary>Normalize the model after it's deserialized.</summary>
/// <param name="context">The deserialization context.</param>
[OnDeserialized]
[SuppressMessage("ReSharper", "ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract", Justification = SuppressReasons.MethodValidatesNullability)]
[SuppressMessage("ReSharper", "NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract", Justification = SuppressReasons.MethodValidatesNullability)]
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = SuppressReasons.UsedViaOnDeserialized)]
public void OnDeserialized(StreamingContext context)
{
this.Controls ??= new ModConfigKeys();
this.ConnectorNames = this.ConnectorNames.ToNonNullCaseInsensitive();
this.ConnectorNames.RemoveWhere(string.IsNullOrWhiteSpace);
this.MachineOverrides = this.MachineOverrides.ToNonNullCaseInsensitive();
this.MachineOverrides.RemoveWhere(pair => pair.Value is null);
}
}
}