Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
WellFedHelper.cs
Go to the documentation of this file.
1
namespace
Terraria.GameContent
;
2
3
public
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
13
public
int
TimeLeft
=>
_timeLeftRank1
+
_timeLeftRank2
+
_timeLeftRank3
;
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
{
54
ReduceTimeLeft
();
55
}
56
57
public
void
Clear
()
58
{
59
_timeLeftRank1
= 0;
60
_timeLeftRank2
= 0;
61
_timeLeftRank3
= 0;
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
{
82
_timeLeftRank3
--;
83
}
84
else
if
(
_timeLeftRank2
> 0)
85
{
86
_timeLeftRank2
--;
87
}
88
else
if
(
_timeLeftRank1
> 0)
89
{
90
_timeLeftRank1
--;
91
}
92
}
93
}
Terraria.GameContent
Definition
AchievementsHelper.cs:1
Terraria.GameContent.WellFedHelper.Clear
void Clear()
Definition
WellFedHelper.cs:57
Terraria.GameContent.WellFedHelper.AddTimeTo
void AddTimeTo(ref int foodTimeCounter, ref int timeLeftToAdd, int counterMaximumTime)
Definition
WellFedHelper.cs:64
Terraria.GameContent.WellFedHelper.ReduceTimeLeft
void ReduceTimeLeft()
Definition
WellFedHelper.cs:78
Terraria.GameContent.WellFedHelper.Update
void Update()
Definition
WellFedHelper.cs:52
Terraria.GameContent.WellFedHelper.Eat
void Eat(int foodRank, int foodBuffTime)
Definition
WellFedHelper.cs:35
Terraria.GameContent.WellFedHelper._timeLeftRank1
int _timeLeftRank1
Definition
WellFedHelper.cs:7
Terraria.GameContent.WellFedHelper.Rank
int Rank
Definition
WellFedHelper.cs:16
Terraria.GameContent.WellFedHelper._timeLeftRank3
int _timeLeftRank3
Definition
WellFedHelper.cs:11
Terraria.GameContent.WellFedHelper._timeLeftRank2
int _timeLeftRank2
Definition
WellFedHelper.cs:9
Terraria.GameContent.WellFedHelper.MAXIMUM_TIME_LEFT_PER_COUNTER
const int MAXIMUM_TIME_LEFT_PER_COUNTER
Definition
WellFedHelper.cs:5
Terraria.GameContent.WellFedHelper.TimeLeft
int TimeLeft
Definition
WellFedHelper.cs:13
Terraria.GameContent.WellFedHelper
Definition
WellFedHelper.cs:4
source
Terraria.GameContent
WellFedHelper.cs
Generated by
1.10.0