Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
CommonEnemyUICollectionInfoProvider.cs
Go to the documentation of this file.
1using Terraria.ID;
2using Terraria.UI;
3
5
7{
9
10 private bool _quickUnlock;
11
13
14 public CommonEnemyUICollectionInfoProvider(string persistentId, bool quickUnlock)
15 {
16 _persistentIdentifierToCheck = persistentId;
17 _quickUnlock = quickUnlock;
19 }
20
21 public static int GetKillCountNeeded(string persistentId)
22 {
23 int defaultKillsForBannerNeeded = ItemID.Sets.DefaultKillsForBannerNeeded;
24 if (!ContentSamples.NpcNetIdsByPersistentIds.TryGetValue(persistentId, out var value))
25 {
26 return defaultKillsForBannerNeeded;
27 }
28 if (!ContentSamples.NpcsByNetId.TryGetValue(value, out var value2))
29 {
30 return defaultKillsForBannerNeeded;
31 }
32 int num = Item.BannerToItem(Item.NPCtoBanner(value2.BannerID()));
33 return ItemID.Sets.KillsToBanner[num];
34 }
35
37 {
38 int killCount = Main.BestiaryTracker.Kills.GetKillCount(_persistentIdentifierToCheck);
39 BestiaryEntryUnlockState unlockStateByKillCount = GetUnlockStateByKillCount(killCount, _quickUnlock);
41 result.UnlockState = unlockStateByKillCount;
42 return result;
43 }
44
45 public BestiaryEntryUnlockState GetUnlockStateByKillCount(int killCount, bool quickUnlock)
46 {
47 int killCountNeededToFullyUnlock = _killCountNeededToFullyUnlock;
48 return GetUnlockStateByKillCount(killCount, quickUnlock, killCountNeededToFullyUnlock);
49 }
50
51 public static BestiaryEntryUnlockState GetUnlockStateByKillCount(int killCount, bool quickUnlock, int fullKillCountNeeded)
52 {
53 BestiaryEntryUnlockState bestiaryEntryUnlockState = BestiaryEntryUnlockState.NotKnownAtAll_0;
54 int num = fullKillCountNeeded / 2;
55 int num2 = fullKillCountNeeded / 5;
56 if (quickUnlock && killCount > 0)
57 {
58 return BestiaryEntryUnlockState.CanShowDropsWithDropRates_4;
59 }
60 if (killCount >= fullKillCountNeeded)
61 {
62 return BestiaryEntryUnlockState.CanShowDropsWithDropRates_4;
63 }
64 if (killCount >= num)
65 {
66 return BestiaryEntryUnlockState.CanShowDropsWithoutDropRates_3;
67 }
68 if (killCount >= num2)
69 {
70 return BestiaryEntryUnlockState.CanShowStats_2;
71 }
72 if (killCount >= 1)
73 {
74 return BestiaryEntryUnlockState.CanShowPortraitOnly_1;
75 }
76 return BestiaryEntryUnlockState.NotKnownAtAll_0;
77 }
78
80 {
81 return null;
82 }
83}
static BestiaryEntryUnlockState GetUnlockStateByKillCount(int killCount, bool quickUnlock, int fullKillCountNeeded)
BestiaryEntryUnlockState GetUnlockStateByKillCount(int killCount, bool quickUnlock)
static Dictionary< string, int > NpcNetIdsByPersistentIds
static Dictionary< int, NPC > NpcsByNetId
static int DefaultKillsForBannerNeeded
Definition ItemID.cs:1020
static int[] KillsToBanner
Definition ItemID.cs:1022
static int BannerToItem(int banner)
Definition Item.cs:1246
static int NPCtoBanner(int i)
Definition Item.cs:1296
static BestiaryUnlocksTracker BestiaryTracker
Definition Main.cs:1868