Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
LootSimulator.cs
Go to the documentation of this file.
3using System.Linq;
4using ReLogic.OS;
5using Terraria.ID;
6
8
9public class LootSimulator
10{
12
13 private int[] _excludedItemIds = new int[0];
14
20
21 private void FillItemExclusions()
22 {
23 List<int> list = new List<int>();
24 list.AddRange(from tuple in ItemID.Sets.IsAPickup.Select((bool state, int index) => new { index, state })
25 where tuple.state
26 select tuple.index);
27 list.AddRange(from tuple in ItemID.Sets.CommonCoin.Select((bool state, int index) => new { index, state })
28 where tuple.state
29 select tuple.index);
30 _excludedItemIds = list.ToArray();
31 }
32
48
49 public void Run()
50 {
51 int timesMultiplier = 10000;
53 string text = "";
55 stopwatch.Start();
56 for (int i = -65; i < NPCID.Count; i++)
57 {
59 {
60 text = text + outputText + "\n\n";
61 }
62 }
63 stopwatch.Stop();
64 text += $"\nSimulation Took {(float)stopwatch.ElapsedMilliseconds / 1000f} seconds to complete.\n";
65 Platform.Get<IClipboard>().Value = text;
66 }
67
69 {
70 Main.dayTime = true;
71 Main.time = 27000.0;
72 Main.hardMode = false;
73 Main.GameMode = 0;
74 NPC.downedMechBoss1 = false;
75 NPC.downedMechBoss2 = false;
76 NPC.downedMechBoss3 = false;
77 NPC.downedMechBossAny = false;
78 NPC.downedPlantBoss = false;
79 Main._shouldUseWindyDayMusic = false;
80 Main._shouldUseStormMusic = false;
81 Main.eclipse = false;
82 Main.bloodMoon = false;
83 }
84
86 {
88 NPC nPC = new NPC();
89 nPC.SetDefaults(npcNetId);
90 simulatorInfo.npcVictim = nPC;
93 {
95 int num = neededTestCondition.GetTimesToRunMultiplier(simulatorInfo) * timesMultiplier;
96 for (int i = 0; i < num; i++)
97 {
98 nPC.NPCLoot();
99 }
100 lootSimulationItemCounter.IncreaseTimesAttempted(num, simulatorInfo.runningExpertMode);
103 }
105 string text = lootSimulationItemCounter.PrintCollectedItems(expert: false);
106 string text2 = lootSimulationItemCounter.PrintCollectedItems(expert: true);
107 string name = NPCID.Search.GetName(npcNetId);
108 string text3 = $"FindEntryByNPCID(NPCID.{name})";
109 if (text.Length > 0)
110 {
111 text3 = $"{text3}\n.AddDropsNormalMode({text})";
112 }
113 if (text2.Length > 0)
114 {
115 text3 = $"{text3}\n.AddDropsExpertMode({text2})";
116 }
117 text3 += ";";
119 if (text.Length <= 0)
120 {
121 return text2.Length > 0;
122 }
123 return true;
124 }
125}
void AddRange(IEnumerable< KeyValuePair< TKey, TValue > > collection)
List< ISimulationConditionSetter > _neededTestConditions
bool TryGettingLootFor(int npcNetId, int timesMultiplier, out string outputText)
static bool[] CommonCoin
Definition ItemID.cs:1046
static bool[] IsAPickup
Definition ItemID.cs:223
static readonly short Count
Definition NPCID.cs:11744
static readonly IdDictionary Search
Definition NPCID.cs:11746