/// <summary> /// getting a value from the given savefile from the given path /// </summary> /// <param name="save">The save to get the value from</param> /// <param name="Runtime">True if the following Id is runtime, false if it is a scene id</param> /// <param name="ObjectIdentifier">The Id of the object to find</param> /// <param name="ComponentIdentifier">The Identifier of the Component from which this field will be saved</param> /// <param name="FieldName">The Name of the Field from which the value was extracted</param> /// <param name="Value">The Value to save. Must derive from JSSerializable</param> public JSSerializable GetValue(Save save, bool Runtime, string ObjectIdentifier, string ComponentIdentifier, string FieldName) { JSSerializable result = null; result = ((JSDictionary <JSSerializable>)((JSDictionary <JSSerializable>)save.GetByKey(Runtime ? "Runtime" : "Static") .GetValueByKey(ObjectIdentifier)).GetValueByKey(ComponentIdentifier)).GetValueByKey(FieldName); if (result == null) { if (Dbug.Is(DebugMode.WARN)) { Debug.LogWarning("There was a problem getting a value for the Autosave field at: " + ObjectIdentifier + " " + ComponentIdentifier + " " + FieldName); } } return(result); }
/// <summary> /// manipulate the given savefile by setting the value at the given path /// </summary> /// <param name="save">The save to manipulate</param> /// <param name="Runtime">True if the following Id is runtime, false if it is a scene id</param> /// <param name="ObjectIdentifier">The Id of the object to find</param> /// <param name="ComponentIdentifier">The Identifier of the Component from which this field will be saved</param> /// <param name="FieldName">The Name of the Field from which the value was extracted</param> /// <param name="Value">The Value to save. Must derive from JSSerializable</param> public bool SaveValue(Save save, bool Runtime, string ObjectIdentifier, string ComponentIdentifier, string FieldName, JSSerializable Value) { JSDictionary <JSSerializable> ToSave = Runtime ? save.Runtime : save.Static; //following the path through the Savefile, creating additional Entries if necessary, then adding or replacing the value to the field name return(((JSDictionary <JSSerializable>)(((JSDictionary <JSSerializable>)(ToSave.GetOrCreateValueByKey(ObjectIdentifier))) .GetOrCreateValueByKey(ComponentIdentifier))).AddOrReplaceValueByKey(FieldName, Value)); }