Пример #1
0
 public void RestoreCurrentSceneData()
 {
     //loop through all ISaveable objects and trigger restore scene data for each
     foreach (ISaveable ISaveableObject in iSaveableObjectList)
     {
         ISaveableObject.ISaveableRestoreScene(SceneManager.GetActiveScene().name);
     }
 }
Пример #2
0
 public static void AssignIfDifferent(this string str, string strNewValue, ISaveableObject parent)
 {
     if (str != strNewValue)
     {
         str          = strNewValue;
         parent.Dirty = true;
     }
 }
Пример #3
0
        public static int FindSaveableObjectVersion(ISaveableObject SaveableObject)
        {
            var attributes = SaveableObject.GetType().GetCustomAttributes(false);

            foreach (var attribute in attributes.OfType <SaveableObjectAttribute>())
            {
                return(attribute.Version);
            }
            return(0);
        }
 static SerializableSaveObject GetSaveObject(ISaveableObject saveableObject)
 {
     try {
         return(saveableObject.GetSaveObject());
     }
     catch (Exception e) {
         Debug.LogError($"Could not get serialized save object for: {saveableObject.ID}, {saveableObject}. Details:\n{e}");
         return(null);
     }
 }
Пример #5
0
    bool HasValidId(ISaveableObject obj)
    {
        try {
            string s = obj.ID;

            return(!string.IsNullOrEmpty(s));
        }
        catch {
            return(false);
        }
    }
Пример #6
0
 private static void StoreProperty(ISaveableObject parent, ref SecureString ss, string encryptedString)
 {
     using (EncryptionKey key = EncryptionKey.Load())
     {
         var decryptedString  = key.DecryptString(encryptedString);
         var tempSecureString = decryptedString.ConvertToSecureString();
         if (tempSecureString.ConvertToUnsecureString() != ss.ConvertToUnsecureString())
         {
             ss           = tempSecureString;
             parent.Dirty = true;
         }
     }
 }
Пример #7
0
        protected void OnObjectLoad(C loadedObject, ISaveableObject <S> loadedObjectAsSaveableObject, S savedObject)
        {
            loadedObject.transform.WarpTo(savedObject.position, savedObject.rotation);
            loadedObjectAsSaveableObject.LoadFromSavedObject(savedObject);

            // load all saveable information to attached scripts,
            // maybe a scene item has an inventory or otehr ocmponents thhat need to save their states
            ISaveableAttachment[] saveables = loadedObject.GetComponents <ISaveableAttachment>();
            for (int i = 0; i < saveables.Length; i++)
            {
                Type saveableType = saveables[i].AttachmentType();
                for (int x = 0; x < savedObject.attachmentStates.Length; x++)
                {
                    if (saveableType == savedObject.attachmentStates[x].type)
                    {
                        saveables[i].OnLoaded(savedObject.attachmentStates[x].state);
                        break;
                    }
                }
            }
        }
Пример #8
0
 public static void AssignIfDifferent(this SecureString str, string strNewValue, ISaveableObject parent)
 {
     if (str.ConvertToUnsecureString() != strNewValue)
     {
         str.Clear();
         foreach (char c in strNewValue)
         {
             str.AppendChar(c);
         }
         parent.Dirty = true;
     }
 }