2using System.Collections.Generic;
4using System.Text.RegularExpressions;
6using Terraria.Utilities;
15 internal static readonly IList<ModPrefix> prefixes =
new List<ModPrefix>();
16 internal static readonly IDictionary<PrefixCategory, IList<ModPrefix>> categoryPrefixes;
19 categoryPrefixes =
new Dictionary<PrefixCategory, IList<ModPrefix>>();
21 categoryPrefixes[category] =
new List<ModPrefix>();
25 internal static byte ReservePrefixID() {
41 return type >= PrefixID.Count && type <
PrefixCount ? prefixes[type - PrefixID.Count] :
null;
50 return new List<ModPrefix>(categoryPrefixes[category]);
55 internal static void ResizeArrays() {
59 internal static void Unload() {
63 categoryPrefixes[category].Clear();
70 internal static void Roll(Item item, ref
int prefix,
int vanillaWeight, params
PrefixCategory[] categories) {
71 WeightedRandom<byte> wr =
new WeightedRandom<byte>();
73 foreach (
ModPrefix modPrefix
in categoryPrefixes[category].Where(x => x.CanRoll(item)))
74 wr.Add(modPrefix.Type, modPrefix.RollChance(item));
76 if (vanillaWeight > 0)
77 wr.Add((
byte)prefix, vanillaWeight);
144 public virtual void SetStats(ref
float damageMult, ref
float knockbackMult, ref
float useTimeMult,
145 ref
float scaleMult, ref
float shootSpeedMult, ref
float manaMult, ref
int critBonus) {
159 public virtual void Apply(Item item) {
Mod is an abstract class that you will override. It serves as a central place from which the mod's co...
static bool AllowVanillaClients
static List< ModPrefix > GetPrefixesInCategory(PrefixCategory category)
Returns a list of all modded prefixes of a certain category.
virtual bool CanRoll(Item item)
Returns if your ModPrefix can roll on the given item By default returns RollChance(item) > 0
virtual void ValidateItem(Item item, ref bool invalid)
Validates whether this prefix with the custom data stats set from SetStats is allowed on the given it...
virtual void SetStats(ref float damageMult, ref float knockbackMult, ref float useTimeMult, ref float scaleMult, ref float shootSpeedMult, ref float manaMult, ref int critBonus)
Sets the stat changes for this prefix. If data is not already pre-stored, it is best to store custom ...
virtual float RollChance(Item item)
The roll chance of your prefix relative to a vanilla prefix, 1f by default.
virtual void ModifyValue(ref float valueMult)
Allows you to modify the sell price of the item based on the prefix or changes in custom data stats....
virtual bool Autoload(ref string name)
virtual PrefixCategory Category
The category your prefix belongs to, PrefixCategory.Custom by default
virtual void AutoDefaults()
static ModPrefix GetPrefix(byte type)
Returns the ModPrefix associated with specified type If not a ModPrefix, returns null.
ModTranslation DisplayName
virtual void Apply(Item item)
Applies the custom data stats set in SetStats to the given item.
virtual void SetDefaults()
Allows you to set the prefix's name/translations and to set its category.
void SetDefault(string value)
@ Magic
Can modify the mana usage of the weapon
@ Custom
Will not appear by default. Useful as prefixes for your own damage type.
@ Ranged
Can modify the shoot speed of the weapon
@ Melee
Can modify the size of the weapon
bool Autoload
Whether or not this mod will autoload content by default. Autoloading content means you do not need t...