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

◆ Roll()

static bool Terraria.ModLoader.PrefixLoader.Roll ( Item item,
UnifiedRandom unifiedRandom,
out int prefix,
bool justCheck )
inlinestatic

Definition at line 140 of file PrefixLoader.cs.

141 {
142 int forcedPrefix = ItemLoader.ChoosePrefix(item, unifiedRandom);
143 if (forcedPrefix > 0 && CanRoll(item, forcedPrefix))
144 {
145 prefix = forcedPrefix;
146 return true;
147 }
148 prefix = 0;
150 PrefixCategory? prefixCategory = item.GetPrefixCategory();
151 if (prefixCategory.HasValue)
152 {
153 PrefixCategory category2 = prefixCategory.GetValueOrDefault();
154 if (justCheck)
155 {
156 return true;
157 }
158 int[] vanillaPrefixes = Item.GetVanillaPrefixes(category2);
159 foreach (int pre in vanillaPrefixes)
160 {
161 wr.Add(pre);
162 }
164 {
165 wr.Add(84);
166 }
169 {
170 AddCategory(PrefixCategory.AnyWeapon);
171 }
172 for (int i = 0; i < 50; i++)
173 {
174 prefix = wr.Get();
175 if (ItemLoader.AllowPrefix(item, prefix))
176 {
177 return true;
178 }
179 }
180 return false;
181 }
182 return false;
183 void AddCategory(PrefixCategory category)
184 {
185 foreach (ModPrefix modPrefix in categoryPrefixes[category].Where((ModPrefix x) => x.CanRoll(item)))
186 {
187 wr.Add(modPrefix.Type, modPrefix.RollChance(item));
188 }
189 }
190 }
static readonly IDictionary< PrefixCategory, List< ModPrefix > > categoryPrefixes
static bool CanRoll(Item item, int prefix)
static bool IsWeaponSubCategory(PrefixCategory category)

References Terraria.ModLoader.ItemLoader.AllowPrefix(), Terraria.ModLoader.ModPrefix.CanRoll(), Terraria.ModLoader.PrefixLoader.CanRoll(), Terraria.ModLoader.PrefixLoader.categoryPrefixes, Terraria.ModLoader.ItemLoader.ChoosePrefix(), Terraria.Item.GetPrefixCategory(), Terraria.Item.GetVanillaPrefixes(), Terraria.ModLoader.PrefixLoader.IsWeaponSubCategory(), Terraria.GameContent.Prefixes.PrefixLegacy.ItemSets.ItemsThatCanHaveLegendary2, and Terraria.Item.type.

Referenced by Terraria.Item.Prefix(), and Terraria.Item.RollAPrefix().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: