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, Rand.RandSync randSync)
44  {
45  Identifier = prefab.Identifier;
46  Level = Rand.Range(prefab.LevelRange.Start, prefab.LevelRange.End, randSync);
47  iconJobId = GetIconJobId();
49  DisplayName = TextManager.Get("SkillName." + Identifier);
50  }
51 
52  public Skill(Identifier identifier, float level)
53  {
54  Identifier = identifier;
55  Level = level;
56  iconJobId = GetIconJobId();
57  DisplayName = TextManager.Get("SkillName." + Identifier);
58  }
59 
60  private Identifier GetIconJobId()
61  {
62  Identifier jobId = Identifier.Empty;
63  if (Identifier == "electrical")
64  {
65  jobId = "engineer".ToIdentifier();
66  }
67  else if (Identifier == "helm")
68  {
69  jobId = "captain".ToIdentifier();
70  }
71  else if (Identifier == "mechanical")
72  {
73  jobId = "mechanic".ToIdentifier();
74  }
75  else if (Identifier == "medical")
76  {
77  jobId = "medicaldoctor".ToIdentifier();
78  }
79  else if (Identifier == "weapons")
80  {
81  jobId = "securityofficer".ToIdentifier();
82  }
83 
84  return jobId;
85  }
86  }
87 }
static readonly PrefabCollection< JobPrefab > Prefabs
Skill(Identifier identifier, float level)
Definition: Skill.cs:52
readonly float PriceMultiplier
Definition: Skill.cs:41
Sprite Icon
Definition: Skill.cs:37
LocalizedString DisplayName
Definition: Skill.cs:28
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
Skill(SkillPrefab prefab, Rand.RandSync randSync)
Definition: Skill.cs:43
readonly float PriceMultiplier
How much this skill affects characters' hiring cost
Definition: SkillPrefab.cs:15
readonly Identifier Identifier
Definition: SkillPrefab.cs:8
Range< float > LevelRange
Definition: SkillPrefab.cs:10
static SkillSettings Current