AssemblyShare - Qkrisi/ktanemodkit GitHub Wiki

AssemblyShare

[AddComponentMenu("")]
public class AssemblyShare : MonoBehaviour

This component is used to share information between instances of the modkit scripts, since they're built into a different assembly for each mod, so the static keyword isn't enough.

This component is not meant to be added to a game object by the modder, instead an instance is created and managed automatically when the static functions of this type are called.


public Dictionary<string, object> SharedObjects;

The objects that are shared between the assemblies


public static void SetValue(string key, object value)

Set the value of key to value. Throws KeyNotFoundException if they specified key doesn't exist.


public static void Add(string key, object value)

Add value as key to the shared objects. Throws ArgumentException if the key already exists.


public static void SetOrAdd(string key, object value)

Add value as key to the shared objects if the key doesn't already exist, otherwise set the value of key to value.


public static T GetValue<T>(string key)

Get the value of key (T is the type of the item)


public static bool TryGetValue<T>(string key, out T value)

Try to get the value of key (T is the type of the item). If the key exists, the returned value will be true and the value of value will be the value of the key. Otherwise, the returned value will be false and the value of value will be the default value of T.


public static T GetOrAdd<T>(string key, T defaultValue)

Get the value of key (T is the type of the item). If the key doesn't exist, add defaultValue as key (the returned value is defaultValue in this case).


public static bool ContainsKey(string key)

Returns wether the specified key exists or not.