-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathConfiguration.cs
More file actions
124 lines (107 loc) · 3.82 KB
/
Configuration.cs
File metadata and controls
124 lines (107 loc) · 3.82 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
using System;
using System.IO;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
namespace Decreased_Fall_Damage
{
// Token: 0x02000003 RID: 3
public static class Configuration
{
// Token: 0x17000001 RID: 1
// (get) Token: 0x06000003 RID: 3 RVA: 0x00002100 File Offset: 0x00000300
public static bool Enable
{
get
{
return Configuration._enable.Value;
}
}
public static bool skillMode
{
get
{
return Configuration._skillMode.Value;
}
}
// Token: 0x17000002 RID: 2
// (get) Token: 0x06000004 RID: 4 RVA: 0x0000211C File Offset: 0x0000031C
public static float fallDamage
{
get
{
return Configuration._fallDamage.Value;
}
set
{
Configuration._fallDamage.Value = value;
}
}
public static float minFallHeight
{
get
{
return Configuration._minFallHeight.Value;
}
}
// Token: 0x06000006 RID: 6 RVA: 0x00002154 File Offset: 0x00000354
public static void InitConfiguration()
{
Configuration.InitValues();
Configuration.CheckConfiguration();
Configuration._configFile.Save();
#if DEBUG
DecreasedFallDamage.Logger.LogWarning("[DEBUG] Successfully loaded configuration");
#endif
}
// Token: 0x06000007 RID: 7 RVA: 0x00002224 File Offset: 0x00000424
private static void InitValues()
{
Configuration._configFile = new ConfigFile(Path.Combine(Paths.ConfigPath,"ritchmods.valheim.decreasedfalldamage.cfg"), true);
Configuration._enable = Configuration._configFile.Bind<bool>("General", "enable", true, "Description : Enable / disable the mod" + Environment.NewLine + "Values : true; false");
Configuration._skillMode = Configuration._configFile.Bind<bool>("General", "skillMode", true, "Description : Enable / disable skill mode" + Environment.NewLine + "Values : true; false");
Configuration._fallDamage = Configuration._configFile.Bind<float>("General", "fallDamage", 100, "Description : Fall damage rate. Default : 100" + Environment.NewLine + "Values : 0 - 100");
Configuration._minFallHeight = Configuration._configFile.Bind<float>("General", "minFallheight", 4, "Description : Height at which fall damage occurs. Default : 4" + Environment.NewLine + "Values : 1 - 100");
}
// Token: 0x06000008 RID: 8 RVA: 0x000022D8 File Offset: 0x000004D8
private static void CheckConfiguration()
{
if (Configuration._enable.Value && !Configuration._enable.Value)
{
#if DEBUG
DecreasedFallDamage.Logger.LogWarning("Config \"enable\" was reset to default : true (before " + Configuration._enable.Value.ToString() + ")");
#endif
Configuration._enable.Value = true;
}
if (Configuration._skillMode.Value && !Configuration._skillMode.Value)
{
#if DEBUG
DecreasedFallDamage.Logger.LogWarning("Config \"skillMode\" was reset to default : true (before " + Configuration._skillMode.Value.ToString() + ")");
#endif
Configuration._skillMode.Value = true;
}
if (Configuration._fallDamage.Value < 0 || Configuration._fallDamage.Value > 100)
{
#if DEBUG
DecreasedFallDamage.Logger.LogWarning("Config \"fallDamage\" was reset to default : 0 (before " + Configuration._fallDamage.Value.ToString() + ")");
#endif
Configuration._fallDamage.Value = 0;
}
if (Configuration._minFallHeight.Value < 1 || Configuration._minFallHeight.Value > 100)
{
#if DEBUG
DecreasedFallDamage.Logger.LogWarning("Config \"fallDamage\" was reset to default : 0 (before " + Configuration._fallDamage.Value.ToString() + ")");
#endif
Configuration._fallDamage.Value = 4;
}
}
// Token: 0x04000001 RID: 1
private static ConfigFile _configFile;
// Token: 0x04000002 RID: 2
private static ConfigEntry<bool> _enable;
private static ConfigEntry<bool> _skillMode;
// Token: 0x04000003 RID: 3
private static ConfigEntry<float> _fallDamage;
private static ConfigEntry<float> _minFallHeight;
}
}