Interface ITreeAttribute
- Namespace
- Vintagestory.API.Datastructures
- Assembly
- VintagestoryAPI.dll
Represents a List of nestable Attributes
public interface ITreeAttribute : IAttribute, IEnumerable<KeyValuePair<string, IAttribute>>, IEnumerable
- Inherited Members
- Extension Methods
Properties
Count
Amount of elements in this Tree attribute
int Count { get; }
Property Value
this[string]
Will return null if given attribute does not exist
IAttribute this[string key] { get; set; }
Parameters
key
string
Property Value
Values
Returns all values inside this tree attributes
IAttribute[] Values { get; }
Property Value
Methods
Clone()
Creates a deep copy of the attribute tree
ITreeAttribute Clone()
Returns
Equals(IWorldAccessor, IAttribute, params string[])
bool Equals(IWorldAccessor worldForResolve, IAttribute attr, params string[] ignoreSubTrees)
Parameters
worldForResolve
IWorldAccessorattr
IAttributeignoreSubTrees
string[]
Returns
GetAsBool(string, bool)
Returns true/false, for whatever type of attribute is found for given key
bool GetAsBool(string key, bool defaultValue = false)
Parameters
Returns
GetAsInt(string, int)
Same as (int)GetDecimal(string, double)
int GetAsInt(string key, int defaultValue = 0)
Parameters
Returns
GetAsString(string, string)
Retrieves the value of given attribute, independent of attribute type
string GetAsString(string key, string defaultValue = null)
Parameters
Returns
GetBool(string, bool)
Retrieves a bool or default value if key is not found
bool GetBool(string key, bool defaultValue = false)
Parameters
Returns
GetBytes(string, byte[])
Retrieves a byte array or defaultValue if key is not found
byte[] GetBytes(string key, byte[] defaultValue = null)
Parameters
Returns
- byte[]
GetDecimal(string, double)
Retrieves an int, float, long or double value. Whatever attribute is found for given key
double GetDecimal(string key, double defaultValue = 0)
Parameters
Returns
GetDouble(string, double)
Retrieves a double or defaultValue if key is not found
double GetDouble(string key, double defaultValue = 0)
Parameters
Returns
GetFloat(string, float)
Retrieves a float or defaultvalue if key is not found
float GetFloat(string key, float defaultValue = 0)
Parameters
Returns
GetHashCode(string[])
int GetHashCode(string[] ignoredAttributes)
Parameters
ignoredAttributes
string[]
Returns
GetInt(string, int)
Retrieves an int or default value if key is not found
int GetInt(string key, int defaultValue = 0)
Parameters
Returns
GetItemstack(string, ItemStack)
Retrieves an itemstack or defaultValue if key is not found. Be sure to call stack.ResolveBlockOrItem() after retrieving it.
ItemStack GetItemstack(string key, ItemStack defaultValue = null)
Parameters
Returns
GetLong(string, long)
Retrieves a long or default value if key is not found
long GetLong(string key, long defaultValue = 0)
Parameters
Returns
GetOrAddTreeAttribute(string)
Retrieves an attribute tree or adds it if key is not found. Throws an exception if the key does exist but is not a tree.
ITreeAttribute GetOrAddTreeAttribute(string key)
Parameters
key
string
Returns
GetString(string, string)
Retrieves a string or defaultValue if key is not found
string GetString(string key, string defaultValue = null)
Parameters
Returns
GetTreeAttribute(string)
Retrieves an attribute tree or null if key is not found
ITreeAttribute GetTreeAttribute(string key)
Parameters
key
string
Returns
HasAttribute(string)
True if this attribute exists
bool HasAttribute(string key)
Parameters
key
string
Returns
IsSubSetOf(IWorldAccessor, IAttribute)
bool IsSubSetOf(IWorldAccessor worldForResolve, IAttribute other)
Parameters
worldForResolve
IWorldAccessorother
IAttribute
Returns
MergeTree(ITreeAttribute)
Merges trees (it will overwrite existing values)
void MergeTree(ITreeAttribute tree)
Parameters
tree
ITreeAttribute
RemoveAttribute(string)
Removes an attribute
void RemoveAttribute(string key)
Parameters
key
string
SetBool(string, bool)
Creates a bool attribute with given key and value
void SetBool(string key, bool value)
Parameters
SetBytes(string, byte[])
Creates a byte[] attribute with given key and value
void SetBytes(string key, byte[] value)
Parameters
SetDouble(string, double)
Creates a double attribute with given key and value
void SetDouble(string key, double value)
Parameters
SetFloat(string, float)
Creates a float attribute with given key and value
void SetFloat(string key, float value)
Parameters
SetInt(string, int)
Creates an int attribute with given key and value
void SetInt(string key, int value)
Parameters
SetItemstack(string, ItemStack)
Sets given item stack with given key
void SetItemstack(string key, ItemStack itemstack)
Parameters
SetLong(string, long)
Creates a long attribute with given key and value
void SetLong(string key, long value)
Parameters
SetString(string, string)
Creates a string attribute with given key and value
void SetString(string key, string value)
Parameters
SortedCopy(bool)
Returns a ITreeAttribute sorted alphabetically by key. Does not modify the existing ITreeAttribute
OrderedDictionary<string, IAttribute> SortedCopy(bool recursive = false)
Parameters
recursive
bool
Returns
TryGetAttribute(string, out IAttribute)
Similar to TryGetValue for a Dictionary
bool TryGetAttribute(string key, out IAttribute value)
Parameters
key
stringvalue
IAttribute
Returns
TryGetBool(string)
Retrieves a bool or null if the key is not found
bool? TryGetBool(string key)
Parameters
key
string
Returns
- bool?
TryGetDouble(string)
Retrieves a double or null if key is not found
double? TryGetDouble(string key)
Parameters
key
string
Returns
TryGetFloat(string)
Retrieves a float or null if the key is not found
float? TryGetFloat(string key)
Parameters
key
string
Returns
TryGetInt(string)
Retrieves an int or null if the key is not found
int? TryGetInt(string key)
Parameters
key
string
Returns
- int?
TryGetLong(string)
Retrieves a long or null value if key is not found
long? TryGetLong(string key)
Parameters
key
string
Returns
- long?