-
Notifications
You must be signed in to change notification settings - Fork 0
/
FortifySkillData.cs
75 lines (63 loc) · 2.32 KB
/
FortifySkillData.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
using System.Collections.Generic;
using static Skills;
namespace FortifySkillsRedux
{
internal class FortifySkillData
{
public static Dictionary<SkillType, FortifySkillData> s_FortifySkillValues = new();
public static Player s_AssociatedPlayer;
public float FortifyLevel;
public float FortifyAccumulator;
public SkillDef Info;
public static bool IsSkillValid(SkillType skillType)
{
return Skills.IsSkillValid(skillType) && skillType != SkillType.None && skillType != SkillType.All;
}
/// <summary>
/// Localized name of the skill this FortifySkill maps to.
/// </summary>
public string SkillName => GetLocalizedSkillName(this);
public FortifySkillData(SkillDef skillDef)
{
FortifyAccumulator = 0f;
FortifyLevel = 0f;
Info = skillDef;
}
public FortifySkillData(SkillDef skillDef, float newLevel, float newAccumulator)
{
FortifyAccumulator = newAccumulator;
FortifyLevel = newLevel;
Info = skillDef;
}
public static void ResetFortifySkill(SkillType skillType)
{
if (s_FortifySkillValues.ContainsKey(skillType))
{
s_FortifySkillValues[skillType].FortifyLevel = 0;
s_FortifySkillValues[skillType].FortifyAccumulator = 0;
}
}
/// <summary>
/// Reversible operation to map a SkillType to a dummy SkillType
/// or map a dummy SkillType to an actual SkillType
/// </summary>
/// <param name="skillType"></param>
/// <returns></returns>
public static SkillType MapDummySkill(SkillType skillType)
{
return (SkillType)(int.MaxValue - (int)skillType);
}
public static string GetLocalizedSkillName(Skill skill)
{
return $"$skill_{skill.m_info.m_skill.ToString().ToLower()}";
}
public static string GetLocalizedSkillName(FortifySkillData fortSkill)
{
return $"$skill_{fortSkill.Info.m_skill.ToString().ToLower()}";
}
public static string LocalizeSkillName(SkillType skillType)
{
return $"$skill_{skillType.ToString().ToLower()}";
}
}
}