tModLoader v0.11.8.9
A mod to make and play Terraria mods
Terraria.ModLoader.ModPrefix Class Reference
+ Collaboration diagram for Terraria.ModLoader.ModPrefix:

Public Member Functions

virtual void Apply (Item item)
 Applies the custom data stats set in SetStats to the given item. More...
 
virtual void AutoDefaults ()
 
virtual bool Autoload (ref string name)
 
virtual bool CanRoll (Item item)
 Returns if your ModPrefix can roll on the given item By default returns RollChance(item) > 0 More...
 
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. This also influences the item's rarity. More...
 
virtual float RollChance (Item item)
 The roll chance of your prefix relative to a vanilla prefix, 1f by default. More...
 
virtual void SetDefaults ()
 Allows you to set the prefix's name/translations and to set its category. More...
 
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 data changes to some static variables. More...
 
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 item. It is not allowed if one of the stat changes do not cause any change (eg. percentage being too small to make a difference). More...
 

Static Public Member Functions

static ModPrefix GetPrefix (byte type)
 Returns the ModPrefix associated with specified type If not a ModPrefix, returns null. More...
 
static List< ModPrefixGetPrefixesInCategory (PrefixCategory category)
 Returns a list of all modded prefixes of a certain category. More...
 

Properties

virtual PrefixCategory Category [get]
 The category your prefix belongs to, PrefixCategory.Custom by default More...
 
ModTranslation DisplayName [get, set]
 
Mod mod [get, set]
 
string Name [get, set]
 
static byte PrefixCount [get]
 
byte Type [get, set]
 

Static Private Member Functions

static ModPrefix ()
 

Static Private Attributes

static byte nextPrefix = PrefixID.Count
 

Detailed Description

Definition at line 10 of file ModPrefix.cs.

Constructor & Destructor Documentation

◆ ModPrefix()

static Terraria.ModLoader.ModPrefix.ModPrefix ( )
staticprivate

Definition at line 18 of file ModPrefix.cs.

18 {
19 categoryPrefixes = new Dictionary<PrefixCategory, IList<ModPrefix>>();
20 foreach (PrefixCategory category in Enum.GetValues(typeof(PrefixCategory))) {
21 categoryPrefixes[category] = new List<ModPrefix>();
22 }
23 }

Member Function Documentation

◆ Apply()

virtual void Terraria.ModLoader.ModPrefix.Apply ( Item  item)
virtual

Applies the custom data stats set in SetStats to the given item.

Parameters
item

Definition at line 159 of file ModPrefix.cs.

159 {
160 }

◆ AutoDefaults()

virtual void Terraria.ModLoader.ModPrefix.AutoDefaults ( )
virtual

Definition at line 130 of file ModPrefix.cs.

130 {
132 DisplayName.SetDefault(Regex.Replace(Name, "([A-Z])", " $1").Trim());
133 }
ModTranslation DisplayName
Definition: ModPrefix.cs:97

References Terraria.ModLoader.ModPrefix.DisplayName, Terraria.ModLoader.ModTranslation.IsDefault(), Terraria.ModLoader.ModPrefix.Name, and Terraria.ModLoader.ModTranslation.SetDefault().

+ Here is the call graph for this function:

◆ Autoload()

virtual bool Terraria.ModLoader.ModPrefix.Autoload ( ref string  name)
virtual

Definition at line 126 of file ModPrefix.cs.

126 {
127 return mod.Properties.Autoload;
128 }
ModProperties Properties
Definition: Mod.cs:52
bool Autoload
Whether or not this mod will autoload content by default. Autoloading content means you do not need t...

References Terraria.ModLoader.ModProperties.Autoload, Terraria.ModLoader.ModPrefix.mod, and Terraria.ModLoader.Mod.Properties.

Referenced by Terraria.ModLoader.Mod.AutoloadPrefix().

+ Here is the caller graph for this function:

◆ CanRoll()

virtual bool Terraria.ModLoader.ModPrefix.CanRoll ( Item  item)
virtual

Returns if your ModPrefix can roll on the given item By default returns RollChance(item) > 0

Parameters
item
Returns

Definition at line 117 of file ModPrefix.cs.

117 {
118 return RollChance(item) > 0;
119 }
virtual float RollChance(Item item)
The roll chance of your prefix relative to a vanilla prefix, 1f by default.
Definition: ModPrefix.cs:107

References Terraria.ModLoader.ModPrefix.RollChance().

+ Here is the call graph for this function:

◆ GetPrefix()

static ModPrefix Terraria.ModLoader.ModPrefix.GetPrefix ( byte  type)
static

Returns the ModPrefix associated with specified type If not a ModPrefix, returns null.

Parameters
type
Returns

Definition at line 40 of file ModPrefix.cs.

40 {
41 return type >= PrefixID.Count && type < PrefixCount ? prefixes[type - PrefixID.Count] : null;
42 }

References Terraria.ModLoader.ModPrefix.PrefixCount.

Referenced by Terraria.ModLoader.IO.ItemIO.Save().

+ Here is the caller graph for this function:

◆ GetPrefixesInCategory()

static List< ModPrefix > Terraria.ModLoader.ModPrefix.GetPrefixesInCategory ( PrefixCategory  category)
static

Returns a list of all modded prefixes of a certain category.

Parameters
category
Returns

Definition at line 49 of file ModPrefix.cs.

49 {
50 return new List<ModPrefix>(categoryPrefixes[category]);
51 }

◆ ModifyValue()

virtual void Terraria.ModLoader.ModPrefix.ModifyValue ( ref float  valueMult)
virtual

Allows you to modify the sell price of the item based on the prefix or changes in custom data stats. This also influences the item's rarity.

Definition at line 165 of file ModPrefix.cs.

165 {
166 }

◆ RollChance()

virtual float Terraria.ModLoader.ModPrefix.RollChance ( Item  item)
virtual

The roll chance of your prefix relative to a vanilla prefix, 1f by default.

Parameters
item
Returns


Definition at line 107 of file ModPrefix.cs.

107 {
108 return 1f;
109 }

Referenced by Terraria.ModLoader.ModPrefix.CanRoll().

+ Here is the caller graph for this function:

◆ SetDefaults()

virtual void Terraria.ModLoader.ModPrefix.SetDefaults ( )
virtual

Allows you to set the prefix's name/translations and to set its category.

Definition at line 138 of file ModPrefix.cs.

138 {
139 }

◆ SetStats()

virtual void Terraria.ModLoader.ModPrefix.SetStats ( ref float  damageMult,
ref float  knockbackMult,
ref float  useTimeMult,
ref float  scaleMult,
ref float  shootSpeedMult,
ref float  manaMult,
ref int  critBonus 
)
virtual

Sets the stat changes for this prefix. If data is not already pre-stored, it is best to store custom data changes to some static variables.

Definition at line 144 of file ModPrefix.cs.

145 {
146 }

◆ ValidateItem()

virtual void Terraria.ModLoader.ModPrefix.ValidateItem ( Item  item,
ref bool  invalid 
)
virtual

Validates whether this prefix with the custom data stats set from SetStats is allowed on the given item. It is not allowed if one of the stat changes do not cause any change (eg. percentage being too small to make a difference).

Definition at line 152 of file ModPrefix.cs.

152 {
153 }

Member Data Documentation

◆ nextPrefix

byte Terraria.ModLoader.ModPrefix.nextPrefix = PrefixID.Count
staticprivate

Definition at line 12 of file ModPrefix.cs.

Property Documentation

◆ Category

virtual PrefixCategory Terraria.ModLoader.ModPrefix.Category
get

The category your prefix belongs to, PrefixCategory.Custom by default

Definition at line 124 of file ModPrefix.cs.

Referenced by Terraria.ModLoader.Mod.AddPrefix().

◆ DisplayName

ModTranslation Terraria.ModLoader.ModPrefix.DisplayName
getset

Definition at line 97 of file ModPrefix.cs.

97 {
98 get;
99 internal set;
100 }

Referenced by Terraria.ModLoader.ModPrefix.AutoDefaults(), and Terraria.ModLoader.ModContent.RefreshModLanguage().

◆ mod

Mod Terraria.ModLoader.ModPrefix.mod
getset

Definition at line 82 of file ModPrefix.cs.

82 {
83 get;
84 internal set;
85 }

Referenced by Terraria.ModLoader.ModPrefix.Autoload(), and Terraria.ModLoader.IO.ItemIO.Save().

◆ Name

string Terraria.ModLoader.ModPrefix.Name
getset

Definition at line 87 of file ModPrefix.cs.

87 {
88 get;
89 internal set;
90 }

Referenced by Terraria.ModLoader.ModPrefix.AutoDefaults(), Terraria.ModLoader.Mod.AutoloadPrefix(), and Terraria.ModLoader.IO.ItemIO.Save().

◆ PrefixCount

byte Terraria.ModLoader.ModPrefix.PrefixCount
staticget

Definition at line 53 of file ModPrefix.cs.

Referenced by Terraria.ModLoader.ModPrefix.GetPrefix().

◆ Type

byte Terraria.ModLoader.ModPrefix.Type
getset

Definition at line 92 of file ModPrefix.cs.

92 {
93 get;
94 internal set;
95 }

Referenced by Terraria.ModLoader.ModContent.RefreshModLanguage().