Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
LootSimulationItemCounter.cs
Go to the documentation of this file.
1
using
System.Collections.Generic
;
2
using
System.Linq
;
3
using
Terraria.ID
;
4
5
namespace
Terraria.GameContent.LootSimulation
;
6
7
public
class
LootSimulationItemCounter
8
{
9
private
long
[]
_itemCountsObtained
=
new
long
[
ItemID
.
Count
];
10
11
private
long
[]
_itemCountsObtainedExpert
=
new
long
[
ItemID
.
Count
];
12
13
private
long
_totalTimesAttempted
;
14
15
private
long
_totalTimesAttemptedExpert
;
16
17
public
void
AddItem
(
int
itemId,
int
amount
,
bool
expert)
18
{
19
if
(expert)
20
{
21
_itemCountsObtainedExpert
[itemId] +=
amount
;
22
}
23
else
24
{
25
_itemCountsObtained
[itemId] +=
amount
;
26
}
27
}
28
29
public
void
Exclude
(
params
int
[]
itemIds
)
30
{
31
foreach
(
int
num
in
itemIds
)
32
{
33
_itemCountsObtained
[num] = 0L;
34
_itemCountsObtainedExpert
[num] = 0L;
35
}
36
}
37
38
public
void
IncreaseTimesAttempted
(
int
amount
,
bool
expert)
39
{
40
if
(expert)
41
{
42
_totalTimesAttemptedExpert
+=
amount
;
43
}
44
else
45
{
46
_totalTimesAttempted
+=
amount
;
47
}
48
}
49
50
public
string
PrintCollectedItems
(
bool
expert)
51
{
52
long
[]
collectionToUse
=
_itemCountsObtained
;
53
long
totalDropsAttempted
=
_totalTimesAttempted
;
54
if
(expert)
55
{
56
collectionToUse
=
_itemCountsObtainedExpert
;
57
_totalTimesAttempted
=
_totalTimesAttemptedExpert
;
58
}
59
IEnumerable<string>
values =
from
entry
in
collectionToUse
.Select((
long
count
,
int
itemId) =>
new
{ itemId,
count
})
60
where
entry
.count > 0
61
select
entry
.itemId
into
itemId
62
select
$
"new ItemDropInfo(ItemID.{ItemID.Search.GetName(itemId)}, {collectionToUse[itemId]}, {totalDropsAttempted})"
;
63
return
string
.Join(
",\n"
, values);
64
}
65
}
System.Collections.Generic.Dictionary
Definition
Dictionary.cs:14
Terraria.GameContent.LootSimulation.LootSimulationItemCounter._itemCountsObtainedExpert
long[] _itemCountsObtainedExpert
Definition
LootSimulationItemCounter.cs:11
Terraria.GameContent.LootSimulation.LootSimulationItemCounter.AddItem
void AddItem(int itemId, int amount, bool expert)
Definition
LootSimulationItemCounter.cs:17
Terraria.GameContent.LootSimulation.LootSimulationItemCounter._totalTimesAttemptedExpert
long _totalTimesAttemptedExpert
Definition
LootSimulationItemCounter.cs:15
Terraria.GameContent.LootSimulation.LootSimulationItemCounter.PrintCollectedItems
string PrintCollectedItems(bool expert)
Definition
LootSimulationItemCounter.cs:50
Terraria.GameContent.LootSimulation.LootSimulationItemCounter._itemCountsObtained
long[] _itemCountsObtained
Definition
LootSimulationItemCounter.cs:9
Terraria.GameContent.LootSimulation.LootSimulationItemCounter.Exclude
void Exclude(params int[] itemIds)
Definition
LootSimulationItemCounter.cs:29
Terraria.GameContent.LootSimulation.LootSimulationItemCounter._totalTimesAttempted
long _totalTimesAttempted
Definition
LootSimulationItemCounter.cs:13
Terraria.GameContent.LootSimulation.LootSimulationItemCounter.IncreaseTimesAttempted
void IncreaseTimesAttempted(int amount, bool expert)
Definition
LootSimulationItemCounter.cs:38
Terraria.GameContent.LootSimulation.LootSimulationItemCounter
Definition
LootSimulationItemCounter.cs:8
Terraria.ID.ItemID.Count
static readonly short Count
Definition
ItemID.cs:12138
Terraria.ID.ItemID
Definition
ItemID.cs:9
System.Collections.Generic
Definition
IHashKeyCollection.cs:1
System.Linq.ExceptionArgument.count
@ count
System.Linq
Definition
ImmutableArrayExtensions.cs:4
Terraria.GameContent.LootSimulation
Definition
FastConditionSetter.cs:3
Terraria.ID
Definition
AchievementHelperID.cs:1
source
Terraria.GameContent.LootSimulation
LootSimulationItemCounter.cs
Generated by
1.10.0