Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
WellFedHelper.cs
Go to the documentation of this file.
2
3public struct WellFedHelper
4{
5 private const int MAXIMUM_TIME_LEFT_PER_COUNTER = 72000;
6
7 private int _timeLeftRank1;
8
9 private int _timeLeftRank2;
10
11 private int _timeLeftRank3;
12
14
15 public int Rank
16 {
17 get
18 {
19 if (_timeLeftRank3 > 0)
20 {
21 return 3;
22 }
23 if (_timeLeftRank2 > 0)
24 {
25 return 2;
26 }
27 if (_timeLeftRank1 > 0)
28 {
29 return 1;
30 }
31 return 0;
32 }
33 }
34
35 public void Eat(int foodRank, int foodBuffTime)
36 {
37 int timeLeftToAdd = foodBuffTime;
38 if (foodRank >= 3)
39 {
40 AddTimeTo(ref _timeLeftRank3, ref timeLeftToAdd, 72000);
41 }
42 if (foodRank >= 2)
43 {
44 AddTimeTo(ref _timeLeftRank2, ref timeLeftToAdd, 72000);
45 }
46 if (foodRank >= 1)
47 {
48 AddTimeTo(ref _timeLeftRank1, ref timeLeftToAdd, 72000);
49 }
50 }
51
52 public void Update()
53 {
55 }
56
57 public void Clear()
58 {
62 }
63
64 private void AddTimeTo(ref int foodTimeCounter, ref int timeLeftToAdd, int counterMaximumTime)
65 {
66 if (timeLeftToAdd != 0)
67 {
68 int num = timeLeftToAdd;
69 if (foodTimeCounter + num > counterMaximumTime)
70 {
71 num = counterMaximumTime - foodTimeCounter;
72 }
73 foodTimeCounter += num;
74 timeLeftToAdd -= num;
75 }
76 }
77
78 private void ReduceTimeLeft()
79 {
80 if (_timeLeftRank3 > 0)
81 {
83 }
84 else if (_timeLeftRank2 > 0)
85 {
87 }
88 else if (_timeLeftRank1 > 0)
89 {
91 }
92 }
93}
void AddTimeTo(ref int foodTimeCounter, ref int timeLeftToAdd, int counterMaximumTime)
void Eat(int foodRank, int foodBuffTime)