forked from decaprime/LeadAHorseToWater
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSettings.cs
109 lines (88 loc) · 5.19 KB
/
Settings.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Unity.IL2CPP;
using BepInEx.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LeadAHorseToWater
{
// because Config was taken
public static class Settings
{
private static ManualLogSource log => Plugin.LogInstance;
public static ConfigEntry<float> DISTANCE_REQUIRED;
public static ConfigEntry<int> SECONDS_DRINK_PER_TICK;
public static ConfigEntry<int> MAX_DRINK_AMOUNT;
public static String DRINKING_PREFIX = "[Drinking] ";
public static ConfigEntry<bool> ENABLE_RENAME;
public static bool ENABLE_PREFIX_COLOR = true;
public static ConfigEntry<string> ENABLED_WELL_PREFAB;
public static ConfigEntry<bool> ENABLE_HORSE_BREED_COOLDOWN { get; private set; }
public static ConfigEntry<int> HORSE_BREED_COOLDOWN { get; private set; }
public static ConfigEntry<int> HORSE_BREED_PREFAB { get; private set; }
public static ConfigEntry<string> HORSE_BREED_ITEM_NAME { get; private set; }
public static ConfigEntry<int> HORSE_BREED_COST { get; private set; }
public static ConfigEntry<float> HORSE_BREED_MUTATION_RANGE { get; private set; }
public static ConfigEntry<float> HORSE_BREED_MAX_SPEED { get; private set; }
public static ConfigEntry<float> HORSE_BREED_MAX_ROTATION { get; private set; }
public static ConfigEntry<float> HORSE_BREED_MAX_ACCELERATION { get; private set; }
public static HashSet<int> EnabledWellPrefabs = new();
internal static void Initialize(ConfigFile config)
{
DISTANCE_REQUIRED = config.Bind<float>("Server", "DistanceRequired", 5.0f, "Horses must be withdin this distance from well. (5 =1 tile)");
SECONDS_DRINK_PER_TICK = config.Bind<int>("Server", "SecondsDrinkPerTick", 30, "How many seconds added per drink tick (~1.5seconds), default values would be about 24 minutes for the default max amount at fountain.");
MAX_DRINK_AMOUNT = config.Bind<int>("Server", "MaxDrinkAmount", 28800, "Time in seconds, default value is roughly amount of time when you take wild horses.");
ENABLE_RENAME = config.Bind<bool>("Server", "EnableRename", true, "If true will rename horses in drinking range with a symbol");
//ENABLE_PREFIX_COLOR = config.Bind<bool>("Server", "EnablePrefixColor", true, "[deprecated] If true use a different color for the DrinkingPrefix");
//DRINKING_PREFIX = config.Bind<string>("Server", "DrinkingPrefix", "[Drinking] ", "[deprecated] Prefix to use on horses that are drinking");
ENABLED_WELL_PREFAB = config.Bind<string>("Server", "EnabledWellPrefabs", "Stone, Large", "This is a comma seperated list of prefabs to use for the well. You can choose from one of (stone, iron, bronze, small, big) or (advanced: at your own risk) you can also include an arbitrary guid hash of of a castle connected placeable.");
// Breeding
ENABLE_HORSE_BREED_COOLDOWN = config.Bind<bool>("Breeding", "EnableBreedingCooldown", true, "Enables the cooldown for breeding horses.");
HORSE_BREED_COOLDOWN = config.Bind<int>("Breeding", "BreedingCooldown", 600, "This is the cooldown in seconds for breeding horses.");
HORSE_BREED_PREFAB = config.Bind<int>("Breeding", "BreedingRequiredItem", -570287766, "This prefab is consumed as a cost to breed horses.");
HORSE_BREED_ITEM_NAME = config.Bind<string>("Breeding", "BreedingCostItemName", "special fish", "This is the name of the required item that will be consumed.");
HORSE_BREED_COST = config.Bind<int>("Breeding", "BreedingCostAmount", 1, "This is the amount of the required item consumed.");
HORSE_BREED_MUTATION_RANGE = config.Bind<float>("Breeding", "MutationRange", 0.05f, "This is the half range +/- this value for applied for mutation.");
HORSE_BREED_MAX_SPEED = config.Bind<float>("Breeding", "MaxSpeed", 14f, "The absolute maximum speed for horses including selective breeding and mutations.");
HORSE_BREED_MAX_ROTATION = config.Bind<float>("Breeding", "MaxRotation", 16f, "The absolute maximum rotation for horses including selective breeding and mutations.");
HORSE_BREED_MAX_ACCELERATION = config.Bind<float>("Breeding", "MaxAcceleration", 9f, "The absolute maximum acceleration for horses including selective breeding and mutations.");
ENABLED_WELL_PREFAB.SettingChanged += (_, _) => ParseEnabledWells();
ParseEnabledWells();
}
private static Dictionary<string, int> _fountains = new(){
{"stone", 986517450},
{"iron", 1247163010},
{"bronze", -1790149989},
{"small", 549920910},
{"large", 177891172},
};
private static void ParseEnabledWells()
{
EnabledWellPrefabs.Clear();
var list = ENABLED_WELL_PREFAB.Value;
var values = list.Split(",", StringSplitOptions.RemoveEmptyEntries);
log.LogDebug($"Parsing {list} is value {values} are values");
foreach (var value in values)
{
var key = value.Trim().ToLowerInvariant();
if (int.TryParse(key, out var guid))
{
EnabledWellPrefabs.Add(guid);
log.LogDebug($"{guid} is acting well type");
}
else if (_fountains.TryGetValue(key, out var wellGuid))
{
EnabledWellPrefabs.Add(wellGuid);
log.LogDebug($"{wellGuid} is {key} well type");
}
else
{
log.LogWarning($"Unknown well prefab value: {key}");
}
}
}
}
}