Terraria ModLoader  0.10.1.5
A framework for Terraria mods
Terraria.ModLoader.IO.TagCompound Class Reference
+ Inheritance diagram for Terraria.ModLoader.IO.TagCompound:
+ Collaboration diagram for Terraria.ModLoader.IO.TagCompound:

Public Member Functions

void Add (string key, object value)
 
void Add (KeyValuePair< string, object > entry)
 
void Clear ()
 
object Clone ()
 
bool ContainsKey (string key)
 
Get< T > (string key)
 
double GetAsDouble (string key)
 
int GetAsInt (string key)
 
long GetAsLong (string key)
 
short GetAsShort (string key)
 
bool GetBool (string key)
 
byte GetByte (string key)
 
byte[] GetByteArray (string key)
 
TagCompound GetCompound (string key)
 
double GetDouble (string key)
 
IEnumerator< KeyValuePair< string, object > > GetEnumerator ()
 
float GetFloat (string key)
 
int GetInt (string key)
 
int[] GetIntArray (string key)
 
IList< T > GetList< T > (string key)
 
long GetLong (string key)
 
short GetShort (string key)
 
string GetString (string key)
 
GetTag< T > (string key)
 
bool HasTag (string key)
 
bool Remove (string key)
 
bool RemoveTag (string key)
 
void Set (string key, object value)
 
void SetTag (string key, object value)
 
override string ToString ()
 

Public Attributes

int Count => dict.Count
 

Properties

object this[string key] [get, set]
 

Private Member Functions

IEnumerator IEnumerable. GetEnumerator ()
 

Private Attributes

Dictionary< string, object > dict = new Dictionary<string, object>()
 

Detailed Description

Definition at line 14 of file TagCompound.cs.

Member Function Documentation

void Terraria.ModLoader.IO.TagCompound.Add ( string  key,
object  value 
)
void Terraria.ModLoader.IO.TagCompound.Add ( KeyValuePair< string, object >  entry)
void Terraria.ModLoader.IO.TagCompound.Clear ( )

Definition at line 113 of file TagCompound.cs.

113 { dict.Clear(); }
Dictionary< string, object > dict
Definition: TagCompound.cs:16
object Terraria.ModLoader.IO.TagCompound.Clone ( )

Definition at line 91 of file TagCompound.cs.

91  {
92  var copy = new TagCompound();
93  foreach (var entry in this)
94  copy.Set(entry.Key, TagIO.Clone(entry.Value));
95 
96  return copy;
97  }
bool Terraria.ModLoader.IO.TagCompound.ContainsKey ( string  key)

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

+ Here is the caller graph for this function:

T Terraria.ModLoader.IO.TagCompound.Get< T > ( string  key)

Definition at line 17 of file TagCompound.cs.

References Terraria.ModLoader.IO.TagIO.Deserialize().

17  {
18  object tag = null;
19  dict.TryGetValue(key, out tag);
20  try {
21  return TagIO.Deserialize<T>(tag);
22  }
23  catch (Exception e) {
24  throw new IOException(
25  $"NBT Deserialization (type={typeof(T)}," +
26  $"entry={TagPrinter.Print(new KeyValuePair<string, object>(key, tag))})", e);
27  }
28  }
Dictionary< string, object > dict
Definition: TagCompound.cs:16

+ Here is the call graph for this function:

double Terraria.ModLoader.IO.TagCompound.GetAsDouble ( string  key)

Definition at line 86 of file TagCompound.cs.

86  {
87  var o = Get<object>(key);
88  return o as double? ?? o as float? ?? 0;
89  }
int Terraria.ModLoader.IO.TagCompound.GetAsInt ( string  key)

Definition at line 76 of file TagCompound.cs.

76  {
77  var o = Get<object>(key);
78  return o as int? ?? o as short? ?? o as byte? ?? 0;
79  }
long Terraria.ModLoader.IO.TagCompound.GetAsLong ( string  key)

Definition at line 81 of file TagCompound.cs.

81  {
82  var o = Get<object>(key);
83  return o as long? ?? o as int? ?? o as short? ?? o as byte? ?? 0;
84  }
short Terraria.ModLoader.IO.TagCompound.GetAsShort ( string  key)

Definition at line 71 of file TagCompound.cs.

71  {
72  var o = Get<object>(key);
73  return o as short? ?? o as byte? ?? 0;
74  }
bool Terraria.ModLoader.IO.TagCompound.GetBool ( string  key)

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

+ Here is the caller graph for this function:

byte Terraria.ModLoader.IO.TagCompound.GetByte ( string  key)

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

+ Here is the caller graph for this function:

byte [] Terraria.ModLoader.IO.TagCompound.GetByteArray ( string  key)

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

+ Here is the caller graph for this function:

TagCompound Terraria.ModLoader.IO.TagCompound.GetCompound ( string  key)

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

+ Here is the caller graph for this function:

double Terraria.ModLoader.IO.TagCompound.GetDouble ( string  key)
IEnumerator<KeyValuePair<string, object> > Terraria.ModLoader.IO.TagCompound.GetEnumerator ( )
IEnumerator IEnumerable. Terraria.ModLoader.IO.TagCompound.GetEnumerator ( )
private
float Terraria.ModLoader.IO.TagCompound.GetFloat ( string  key)
int Terraria.ModLoader.IO.TagCompound.GetInt ( string  key)

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

+ Here is the caller graph for this function:

int [] Terraria.ModLoader.IO.TagCompound.GetIntArray ( string  key)
IList<T> Terraria.ModLoader.IO.TagCompound.GetList< T > ( string  key)
long Terraria.ModLoader.IO.TagCompound.GetLong ( string  key)
short Terraria.ModLoader.IO.TagCompound.GetShort ( string  key)
string Terraria.ModLoader.IO.TagCompound.GetString ( string  key)

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

+ Here is the caller graph for this function:

T Terraria.ModLoader.IO.TagCompound.GetTag< T > ( string  key)
bool Terraria.ModLoader.IO.TagCompound.HasTag ( string  key)
bool Terraria.ModLoader.IO.TagCompound.Remove ( string  key)
bool Terraria.ModLoader.IO.TagCompound.RemoveTag ( string  key)
void Terraria.ModLoader.IO.TagCompound.Set ( string  key,
object  value 
)

Definition at line 31 of file TagCompound.cs.

References Terraria.ModLoader.IO.TagIO.Serialize().

31  {
32  if (value == null) {
33  Remove(key);
34  return;
35  }
36 
37  try {
38  dict.Add(key, TagIO.Serialize(value));
39  }
40  catch (IOException e) {
41  var valueInfo = "value=" + value;
42  if (value.GetType().ToString() != value.ToString())
43  valueInfo = "type=" + value.GetType() + "," + valueInfo;
44  throw new IOException($"NBT Serialization (key={key},{valueInfo})", e);
45  }
46  }
Dictionary< string, object > dict
Definition: TagCompound.cs:16

+ Here is the call graph for this function:

void Terraria.ModLoader.IO.TagCompound.SetTag ( string  key,
object  value 
)
override string Terraria.ModLoader.IO.TagCompound.ToString ( )

Definition at line 99 of file TagCompound.cs.

References Terraria.ModLoader.IO.TagPrinter.Print().

99  {
100  return TagPrinter.Print(this);
101  }

+ Here is the call graph for this function:

Member Data Documentation

int Terraria.ModLoader.IO.TagCompound.Count => dict.Count

Definition at line 114 of file TagCompound.cs.

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

Dictionary<string, object> Terraria.ModLoader.IO.TagCompound.dict = new Dictionary<string, object>()
private

Definition at line 16 of file TagCompound.cs.

Property Documentation

object Terraria.ModLoader.IO.TagCompound.this[string key]
getset

Definition at line 103 of file TagCompound.cs.