-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSegmentCounterConfigHelper.cs
More file actions
46 lines (41 loc) · 1.47 KB
/
Copy pathSegmentCounterConfigHelper.cs
File metadata and controls
46 lines (41 loc) · 1.47 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
namespace EntBossHP
{
internal static class SegmentCounterConfigHelper
{
public static bool EnsureDisabledMathCounterEntry(
BossConfig config,
string segmentCounter,
Func<string, string, bool> namesMatch)
{
if (string.IsNullOrWhiteSpace(segmentCounter)) return false;
var existingEntry = config.MathCounterList.FirstOrDefault(entry => namesMatch(segmentCounter, entry.MathCounter));
if (existingEntry != null)
{
if (!existingEntry.Enabled) return false;
existingEntry.Enabled = false;
return true;
}
config.MathCounterList.Add(new MathCounterConfig
{
Name = segmentCounter,
Enabled = false,
MathCounter = segmentCounter,
MathCounterMode = 1,
HealthSegmentCounter = null,
HealthSegmentCounterMode = 1,
HpOffset = 0
});
return true;
}
public static int GetSegmentCounterHpOffset(
BossConfig config,
string segmentCounter,
Func<string, string, bool> namesMatch)
{
if (string.IsNullOrWhiteSpace(segmentCounter)) return 0;
return config.MathCounterList
.FirstOrDefault(entry => namesMatch(segmentCounter, entry.MathCounter))
?.HpOffset ?? 0;
}
}
}