TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches

◆ GetCompletedPercentByMod()

float Terraria.GameContent.Bestiary.BestiaryDatabase.GetCompletedPercentByMod ( Mod mod)
inline

Gets the completed percent of the given mod's bestiary.

Parameters
modThe mod to calculate bestiary completeness (null for Terraria)
Returns
A float ranging from 0 to 1 representing the completeness of the bestiary or returns -1 if the mod has no entries

Definition at line 137 of file BestiaryDatabase.cs.

138 {
139 if (mod == null)
140 {
141 return (float)_vanillaEntries.Count((BestiaryEntry e) => e.UIInfoProvider.GetEntryUICollectionInfo().UnlockState > BestiaryEntryUnlockState.NotKnownAtAll_0) / (float)_vanillaEntries.Count;
142 }
143 if (_byMod.TryGetValue(mod, out var value))
144 {
145 return (float)value.Count((BestiaryEntry e) => e.UIInfoProvider.GetEntryUICollectionInfo().UnlockState > BestiaryEntryUnlockState.NotKnownAtAll_0) / (float)value.Count;
146 }
147 return -1f;
148 }
Dictionary< Mod, List< BestiaryEntry > > _byMod

References Terraria.GameContent.Bestiary.BestiaryDatabase._byMod, and Terraria.GameContent.Bestiary.BestiaryDatabase._vanillaEntries.