Skip to content

Commit

Permalink
fix issue with the bestiary not updating certain NPCs, officially fix #5
Browse files Browse the repository at this point in the history
  • Loading branch information
steviegt6 committed May 14, 2021
1 parent 693c5c6 commit 09f2bf8
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,23 @@
};

foreach (int key2 in Main.RegisterdGameModes.Keys) {
@@ -61,7 +_,8 @@
List<IBestiaryInfoElement> list = new List<IBestiaryInfoElement> {
new NPCNetIdBestiaryInfoElement(npcNetId),
new NamePlateInfoElement(Lang.GetNPCName(npcNetId).Key, npcNetId),
- new NPCPortraitInfoElement(ContentSamples.NpcBestiaryRarityStars[npcNetId])
+ new NPCPortraitInfoElement(ContentSamples.NpcBestiaryRarityStars[npcNetId]),
+ new SpawnButtonBestiaryElement(npcNetId)
};

string key = Lang.GetNPCName(nPC.netID).Key;
@@ -82,7 +_,8 @@
List<IBestiaryInfoElement> list = new List<IBestiaryInfoElement> {
new NPCNetIdBestiaryInfoElement(npcNetId),
new NamePlateInfoElement(Lang.GetNPCName(npcNetId).Key, npcNetId),
- new NPCPortraitInfoElement(ContentSamples.NpcBestiaryRarityStars[npcNetId])
+ new NPCPortraitInfoElement(ContentSamples.NpcBestiaryRarityStars[npcNetId]),
+ new SpawnButtonBestiaryElement(npcNetId)
};

string key = Lang.GetNPCName(nPC.netID).Key;
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--- src/Terraria/Terraria/GameContent/Bestiary/CommonEnemyUICollectionInfoProvider.cs
+++ src/Terraclient/Terraria/GameContent/Bestiary/CommonEnemyUICollectionInfoProvider.cs
@@ -1,3 +_,5 @@
+using Terraria.Terraclient;
+using Terraria.Terraclient.Cheats.General;
using Terraria.UI;

namespace Terraria.GameContent.Bestiary
@@ -20,6 +_,9 @@
}

public static BestiaryEntryUnlockState GetUnlockStateByKillCount(int killCount, bool quickUnlock) {
+ if (CheatHandler.GetCheat<BestiaryForceUnlockCheat>().isEnabled)
+ return BestiaryEntryUnlockState.CanShowDropsWithDropRates_4;
+
BestiaryEntryUnlockState bestiaryEntryUnlockState = BestiaryEntryUnlockState.NotKnownAtAll_0;
if (quickUnlock && killCount > 0)
return BestiaryEntryUnlockState.CanShowDropsWithDropRates_4;
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--- src/Terraria/Terraria/GameContent/Bestiary/CritterUICollectionInfoProvider.cs
+++ src/Terraclient/Terraria/GameContent/Bestiary/CritterUICollectionInfoProvider.cs
@@ -1,3 +_,5 @@
+using Terraria.Terraclient;
+using Terraria.Terraclient.Cheats.General;
using Terraria.UI;

namespace Terraria.GameContent.Bestiary
@@ -13,6 +_,8 @@
public BestiaryUICollectionInfo GetEntryUICollectionInfo() {
BestiaryUICollectionInfo result = default(BestiaryUICollectionInfo);
result.UnlockState = (Main.BestiaryTracker.Sights.GetWasNearbyBefore(_persistentIdentifierToCheck) ? BestiaryEntryUnlockState.CanShowDropsWithDropRates_4 : BestiaryEntryUnlockState.NotKnownAtAll_0);
+ if (CheatHandler.GetCheat<BestiaryForceUnlockCheat>().isEnabled)
+ result.UnlockState = BestiaryEntryUnlockState.CanShowDropsWithDropRates_4;
return result;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--- src/Terraria/Terraria/GameContent/Bestiary/GoldCritterUICollectionInfoProvider.cs
+++ src/Terraclient/Terraria/GameContent/Bestiary/GoldCritterUICollectionInfoProvider.cs
@@ -1,4 +_,6 @@
using Terraria.ID;
+using Terraria.Terraclient;
+using Terraria.Terraclient.Cheats.General;

namespace Terraria.GameContent.Bestiary
{
@@ -56,7 +_,7 @@
}

private BestiaryEntryUnlockState GetUnlockStateForCritter(string persistentId) {
- if (!Main.BestiaryTracker.Sights.GetWasNearbyBefore(persistentId))
+ if (!Main.BestiaryTracker.Sights.GetWasNearbyBefore(persistentId) && !CheatHandler.GetCheat<BestiaryForceUnlockCheat>().isEnabled)
return BestiaryEntryUnlockState.NotKnownAtAll_0;

return BestiaryEntryUnlockState.CanShowDropsWithDropRates_4;
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--- src/Terraria/Terraria/GameContent/Bestiary/HighestOfMultipleUICollectionInfoProvider.cs
+++ src/Terraclient/Terraria/GameContent/Bestiary/HighestOfMultipleUICollectionInfoProvider.cs
@@ -1,3 +_,5 @@
+using Terraria.Terraclient;
+using Terraria.Terraclient.Cheats.General;
using Terraria.UI;

namespace Terraria.GameContent.Bestiary
@@ -21,7 +_,7 @@
unlockState = entryUICollectionInfo2.UnlockState;
}

- entryUICollectionInfo.UnlockState = unlockState;
+ entryUICollectionInfo.UnlockState = CheatHandler.GetCheat<BestiaryForceUnlockCheat>().isEnabled ? BestiaryEntryUnlockState.CanShowDropsWithDropRates_4 : unlockState;
return entryUICollectionInfo;
}

Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,3 @@

namespace Terraria.GameContent.Bestiary
{
@@ -40,6 +_,9 @@
}

public int GetKillCount(string persistentId) {
+ if (CheatHandler.GetCheat<BestiaryForceUnlockCheat>().isEnabled)
+ return 100;
+
_killCountsByNpcId.TryGetValue(persistentId, out int value);
return value;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--- src/Terraria/Terraria/GameContent/Bestiary/TownNPCUICollectionInfoProvider.cs
+++ src/Terraclient/Terraria/GameContent/Bestiary/TownNPCUICollectionInfoProvider.cs
@@ -1,3 +_,5 @@
+using Terraria.Terraclient;
+using Terraria.Terraclient.Cheats.General;
using Terraria.UI;

namespace Terraria.GameContent.Bestiary
@@ -13,6 +_,8 @@
public BestiaryUICollectionInfo GetEntryUICollectionInfo() {
BestiaryUICollectionInfo result = default(BestiaryUICollectionInfo);
result.UnlockState = (Main.BestiaryTracker.Chats.GetWasChatWith(_persistentIdentifierToCheck) ? BestiaryEntryUnlockState.CanShowDropsWithDropRates_4 : BestiaryEntryUnlockState.NotKnownAtAll_0);
+ if (CheatHandler.GetCheat<BestiaryForceUnlockCheat>().isEnabled)
+ result.UnlockState = BestiaryEntryUnlockState.CanShowDropsWithDropRates_4;
return result;
}

0 comments on commit 09f2bf8

Please sign in to comment.