-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathPerkBase.cs
95 lines (82 loc) · 3.54 KB
/
PerkBase.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
using System;
using System.Linq;
using TaleWorlds.CampaignSystem;
using TaleWorlds.Core;
namespace BannerLib.Gameplay.Perks
{
/// <summary>
/// The base type that all perks should derive from.
/// </summary>
public class PerkBase
{
/// <summary>
/// Display name of the perk.
/// </summary>
public string Name { get; protected set; }
/// <summary>
/// Description of the perk as seen in the character screen.
/// </summary>
public string Description { get; protected set; }
/// <summary>
/// The primary bonus value. If <see cref="EffectType"/> is set to AddFactor, this number should be expressed as a percentage.
/// </summary>
public float PrimaryBonus { get; protected set; }
/// <summary>
/// The Secondary bonus value. If <see cref="EffectType"/> is set to AddFactor, this number should be expressed as a percentage.
/// </summary>
public float SecondaryBonus { get; protected set; }
/// <summary>
/// The Primary Role for the perk.
/// </summary>
public SkillEffect.PerkRole PrimaryRole { get; protected set; }
/// <summary>
/// The Secondary Role for the perk.
/// </summary>
public SkillEffect.PerkRole SecondaryRole { get; protected set; }
/// <summary>
/// The way in which these bonuses are applied - "Add" adds bonuses as a flat value, whilst "AddFactor" is added as a percentage.
/// </summary>
public SkillEffect.EffectIncrementType EffectType { get; protected set; }
/// <summary>
/// The skill group this perk belongs to.
/// </summary>
public SkillObject Skill { get; protected set; }
/// <summary>
/// The skill level requirement for this perk.
/// </summary>
public int PerkSkillRequirement { get; protected set; }
/// <summary>
/// Converts a <see cref="PerkBase"/> object to a <see cref="PerkObject"/> implicitly so it can be used in all the same places.
/// </summary>
/// <param name="perk">Perk to convert.</param>
/// <returns>Internally stored PerkObject.</returns>
public static implicit operator PerkObject(PerkBase perk) => perk.m_perkObject;
internal PerkObject m_perkObject;
internal bool m_perkFromExisting = false;
internal void InitWithPerkObject()
{
if (m_perkObject.Name == null) return;
Name = m_perkObject.Name.ToString();
Description = m_perkObject.Description.ToString();
PrimaryBonus = m_perkObject.PrimaryBonus;
PrimaryRole = m_perkObject.PrimaryRole;
SecondaryRole = m_perkObject.SecondaryRole;
SecondaryBonus = m_perkObject.SecondaryBonus;
EffectType = m_perkObject.IncrementType;
Skill = m_perkObject.Skill;
PerkSkillRequirement = (int)Math.Round(m_perkObject.RequiredSkillValue);
}
/// <summary>
/// This constructor is used purely to set up the object with defaults.
/// </summary>
protected internal PerkBase()
{
PrimaryBonus = default;
PrimaryRole = SkillEffect.PerkRole.None;
SecondaryBonus = default;
SecondaryRole = SkillEffect.PerkRole.None;
EffectType = SkillEffect.EffectIncrementType.Add;
Skill = DefaultSkills.GetAllSkills().First();
}
}
}