3 using System.ComponentModel;
16 [DefaultValue(
"Terraria")]
18 [DefaultValue(
"None")]
34 string[] parts = key.Split(
new char[] {
' ' }, 2);
35 if (parts.Length == 2) {
41 public override bool Equals(
object obj) {
46 return (mod == p.
mod) && (name == p.
name);
49 public override string ToString() => $
"{mod} {name}";
52 return new { mod, name }.GetHashCode();
55 public bool IsUnloaded => Type == 0 && !(mod ==
"Terraria" && name ==
"None" || mod ==
"" && name ==
"");
58 public abstract int Type {
get; }
85 public override int Type => ItemID.TypeFromUniqueKey(base.mod, base.name);
89 public static readonly Func<TagCompound, ItemDefinition> DESERIALIZER = Load;
101 public override int Type => ProjectileID.TypeFromUniqueKey(mod, name);
105 public static readonly Func<TagCompound, ProjectileDefinition> DESERIALIZER = Load;
117 public override int Type => NPCID.TypeFromUniqueKey(mod, name);
121 public static readonly Func<TagCompound, NPCDefinition> DESERIALIZER = Load;
133 public override int Type => PrefixID.TypeFromUniqueKey(mod, name);
137 public static readonly Func<TagCompound, PrefixDefinition> DESERIALIZER = Load;
147 public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) {
148 return destinationType != typeof(
string);
152 if (sourceType == typeof(
string)) {
155 return base.CanConvertFrom(context, sourceType);
157 public override object ConvertFrom(ITypeDescriptorContext context,
System.Globalization.CultureInfo culture,
object value) {
158 if (value is
string) {
159 MethodInfo parse = typeof(T).GetMethod(
"FromString",
new Type[] { typeof(
string) });
160 if (parse != null && parse.IsStatic && parse.ReturnType == typeof(T)) {
161 return parse.Invoke(null,
new object[] { value });
164 throw new JsonException(
string.Format(
165 "The {0} type does not have a public static FromString(string) method that returns a {0}.",
168 return base.ConvertFrom(context, culture, value);
PrefixDefinition(string key)
Classes implementing EntityDefinition serve to function as a way to save and load the identities of v...
override int GetHashCode()
This TypeConverter facilitates converting to and from the string Type. This is necessary for Objects ...
override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
ItemDefinition(string key)
override bool Equals(object obj)
NPCDefinition(string mod, string name)
NPCDefinition(string key)
ProjectileDefinition(string mod, string name)
ItemDefinition represents an Item identity. A typical use for this class is usage in ModConfig...
EntityDefinition(string mod, string name)
ProjectileDefinition(string key)
PrefixDefinition(int type)
EntityDefinition(string key)
PrefixDefinition(string mod, string name)
override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
override bool CanConvertFrom(ITypeDescriptorContext context, System.Type sourceType)
TagCompound SerializeData()
ProjectileDefinition(int type)
ItemDefinition(string mod, string name)