Client LuaCsForBarotrauma
Skill.cs
1 using Microsoft.Xna.Framework;
2 
3 namespace Barotrauma
4 {
5  class Skill
6  {
7  public readonly Identifier Identifier;
8 
9  public const float MaximumSkill = 100.0f;
10 
11  private float level;
12 
16  public float HighestLevelDuringRound { get; private set; }
17 
18  public float Level
19  {
20  get { return level; }
21  set
22  {
23  HighestLevelDuringRound = MathHelper.Max(value, HighestLevelDuringRound);
24  level = value;
25  }
26  }
27 
28  public LocalizedString DisplayName { get; private set; }
29 
30  public void IncreaseSkill(float value, bool increasePastMax)
31  {
32  Level = MathHelper.Clamp(level + value, 0.0f, increasePastMax ? SkillSettings.Current.MaximumSkillWithTalents : MaximumSkill);
33  }
34 
35  private readonly Identifier iconJobId;
36 
37  public Sprite Icon => !iconJobId.IsEmpty && JobPrefab.Prefabs.TryGet(iconJobId, out var jobPrefab)
38  ? jobPrefab.Icon
39  : null;
40 
41  public readonly float PriceMultiplier = 1.0f;
42 
43  public Skill(SkillPrefab prefab, bool isPvP, Rand.RandSync randSync)
44  {
45  Identifier = prefab.Identifier;
46 
47  var levelRange = prefab.GetLevelRange(isPvP);
48  Level = Rand.Range(levelRange.Start, levelRange.End, randSync);
49  iconJobId = GetIconJobId();
51  DisplayName = TextManager.Get("SkillName." + Identifier);
52  }
53 
54  public Skill(Identifier identifier, float level)
55  {
56  Identifier = identifier;
57  Level = level;
58  iconJobId = GetIconJobId();
59  DisplayName = TextManager.Get("SkillName." + Identifier);
60  }
61 
62  private Identifier GetIconJobId()
63  {
64  Identifier jobId = Identifier.Empty;
65  if (Identifier == "electrical")
66  {
67  jobId = "engineer".ToIdentifier();
68  }
69  else if (Identifier == "helm")
70  {
71  jobId = "captain".ToIdentifier();
72  }
73  else if (Identifier == "mechanical")
74  {
75  jobId = "mechanic".ToIdentifier();
76  }
77  else if (Identifier == "medical")
78  {
79  jobId = "medicaldoctor".ToIdentifier();
80  }
81  else if (Identifier == "weapons")
82  {
83  jobId = "securityofficer".ToIdentifier();
84  }
85 
86  return jobId;
87  }
88  }
89 }
static readonly PrefabCollection< JobPrefab > Prefabs
Skill(Identifier identifier, float level)
Definition: Skill.cs:54
readonly float PriceMultiplier
Definition: Skill.cs:41
Sprite Icon
Definition: Skill.cs:37
LocalizedString DisplayName
Definition: Skill.cs:28
Skill(SkillPrefab prefab, bool isPvP, Rand.RandSync randSync)
Definition: Skill.cs:43
const float MaximumSkill
Definition: Skill.cs:9
readonly Identifier Identifier
Definition: Skill.cs:7
void IncreaseSkill(float value, bool increasePastMax)
Definition: Skill.cs:30
float HighestLevelDuringRound
The highest skill level during the round (before any death penalties were applied)
Definition: Skill.cs:16
readonly float PriceMultiplier
How much this skill affects characters' hiring cost
Definition: SkillPrefab.cs:15
readonly Identifier Identifier
Definition: SkillPrefab.cs:7
Range< float > GetLevelRange(bool isPvP)
Definition: SkillPrefab.cs:46
static SkillSettings Current