Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
CustomIntCondition.cs
Go to the documentation of this file.
1using Newtonsoft.Json;
2using Newtonsoft.Json.Linq;
4
6
8{
9 [JsonProperty("Value")]
10 private int _value;
11
12 private int _maxValue;
13
14 public int Value
15 {
16 get
17 {
18 return _value;
19 }
20 set
21 {
22 int num = Utils.Clamp(value, 0, _maxValue);
23 if (_tracker != null)
24 {
25 ((ConditionIntTracker)_tracker).SetValue(num);
26 }
27 _value = num;
28 if (_value == _maxValue)
29 {
30 Complete();
31 }
32 }
33 }
34
35 private CustomIntCondition(string name, int maxValue)
36 : base(name)
37 {
38 _maxValue = maxValue;
39 _value = 0;
40 }
41
42 public override void Clear()
43 {
44 _value = 0;
45 base.Clear();
46 }
47
48 public override void Load(JObject state)
49 {
50 base.Load(state);
51 _value = (int)state["Value"];
52 if (_tracker != null)
53 {
54 ((ConditionIntTracker)_tracker).SetValue(_value, reportUpdate: false);
55 }
56 }
57
59 {
61 }
62
63 public static AchievementCondition Create(string name, int maxValue)
64 {
65 return new CustomIntCondition(name, maxValue);
66 }
67
68 public override void Complete()
69 {
70 if (_tracker != null)
71 {
73 }
75 base.Complete();
76 }
77}
static AchievementCondition Create(string name, int maxValue)