예제 #1
0
            /// <summary>
            /// Creates an instance of a mod, and initialize its valus by deserializing the JSON data.
            /// </summary>
            /// <returns>Returns the initialized mod instance.</returns>
            public TModType Deserialize()
            {
                Type type = Type.GetType(typeName);

                if (type == null)
                {
                    throw new UnknownModTypeException($"The mod of type \"{typeName}\" doesn't exist", fullTypeName, typeName);
                }

                TModType action = (TModType)Activator.CreateInstance(type);

                JsonUtility.FromJsonOverwrite(json, action);
                return(action);
            }
예제 #2
0
 /// <summary>
 /// Serializes the data of the given mod.
 /// </summary>
 public void Serialize(TModType _Action)
 {
     fullTypeName = _Action.GetType().FullName;
     typeName     = _Action.GetType().Name;
     json         = JsonUtility.ToJson(_Action);
 }
예제 #3
0
 /// <summary>
 /// Creates a new serialized mod.
 /// </summary>
 public SerializedMod(TModType _Mod)
 {
     Serialize(_Mod);
 }