Terraria ModLoader  0.10.1.5
A framework for Terraria mods
Terraria.ModLoader.Config.ModConfig Class Reference

ModConfig provides a way for mods to be configurable. ModConfigs can either be Client specific or Server specific. When joining a MP server, Client configs are kept but Server configs are synced from the server. Using serialization attributes such as [DefaultValue(5)] or [JsonIgnore] are critical for proper usage of ModConfig. tModLoader also provides its own attributes such as ReloadRequiredAttribute and LabelAttribute. More...

Public Member Functions

virtual bool AcceptClientChanges (ModConfig currentConfig, int whoAmI, ref string message)
 
virtual bool Autoload (ref string name)
 
virtual ModConfig Clone ()
 
virtual bool NeedsReload (ModConfig old)
 Whether or not a reload is required. The default implementation compares properties and fields annotated with the ReloadRequiredAttribute. More...
 
virtual void PostAutoLoad ()
 
virtual void PostSave ()
 

Properties

Mod mod [get, set]
 
abstract MultiplayerSyncMode Mode [get]
 
string Name [get, set]
 

Detailed Description

ModConfig provides a way for mods to be configurable. ModConfigs can either be Client specific or Server specific. When joining a MP server, Client configs are kept but Server configs are synced from the server. Using serialization attributes such as [DefaultValue(5)] or [JsonIgnore] are critical for proper usage of ModConfig. tModLoader also provides its own attributes such as ReloadRequiredAttribute and LabelAttribute.

Definition at line 15 of file ModConfig.cs.

Member Function Documentation

virtual bool Terraria.ModLoader.Config.ModConfig.AcceptClientChanges ( ModConfig  currentConfig,
int  whoAmI,
ref string  message 
)
virtual

Definition at line 42 of file ModConfig.cs.

43  {
44  return true;
45  }
virtual bool Terraria.ModLoader.Config.ModConfig.Autoload ( ref string  name)
virtual
virtual ModConfig Terraria.ModLoader.Config.ModConfig.Clone ( )
virtual
virtual bool Terraria.ModLoader.Config.ModConfig.NeedsReload ( ModConfig  old)
virtual

Whether or not a reload is required. The default implementation compares properties and fields annotated with the ReloadRequiredAttribute.

Parameters
oldThe other instance of ModConfig to compare against
Returns

Definition at line 55 of file ModConfig.cs.

References Terraria.ModLoader.Config.ConfigManager.GetFieldsAndProperties().

56  {
57  foreach (PropertyFieldWrapper variable in ConfigManager.GetFieldsAndProperties(this))
58  {
59  ReloadRequiredAttribute reloadRequired = ConfigManager.GetCustomAttribute<ReloadRequiredAttribute>(variable, this, null);
60  if (reloadRequired != null)
61  {
62  if (!variable.GetValue(this).Equals(variable.GetValue(old)))
63  {
64  return true;
65  }
66  }
67  }
68  return false;
69  }

+ Here is the call graph for this function:

virtual void Terraria.ModLoader.Config.ModConfig.PostAutoLoad ( )
virtual

Definition at line 30 of file ModConfig.cs.

31  {
32  // TODO: is this name misleading?
33  }
virtual void Terraria.ModLoader.Config.ModConfig.PostSave ( )
virtual

Definition at line 37 of file ModConfig.cs.

38  {
39  }

Property Documentation

Mod Terraria.ModLoader.Config.ModConfig.mod
getset

Definition at line 18 of file ModConfig.cs.

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

abstract MultiplayerSyncMode Terraria.ModLoader.Config.ModConfig.Mode
get

Definition at line 24 of file ModConfig.cs.

string Terraria.ModLoader.Config.ModConfig.Name
getset

Definition at line 21 of file ModConfig.cs.

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