public static void Prefix(GearItem __instance)
        {
            UnhollowerBaseLib.Il2CppArrayBase <UnityEngine.Component> components = __instance.GetComponents <UnityEngine.Component>();
            foreach (UnityEngine.Component component in components)
            {
                ModSaveBehaviour modSaveBehaviour = component.TryCast <ModSaveBehaviour>();
                if (modSaveBehaviour is null)
                {
                    continue;
                }
                //Logger.Log("Found ModSaveBaviour");
                try
                {
                    string data = modSaveBehaviour.Serialize();
                    //if (data is null) Logger.Log("Null save data for {0} of type {1}", modSaveBehaviour.name, modSaveBehaviour.GetType().ToString());
                    //if (!string.IsNullOrEmpty(data)) Logger.Log(data);
                    SaveDataManager.SetSaveData(__instance.m_InstanceID, modSaveBehaviour.GetType(), data);
                    //Logger.Log("Serialized custom save data for {0} of type {1}", modSaveBehaviour.name, modSaveBehaviour.GetType().ToString());
                }
                catch (System.Exception e)
                {
                    Logger.Log("Serializing custom save data for item {0} failed: {1}.", __instance.name, e.Message);
                }
            }

            /*ModSaveBehaviour modSaveBehaviour = __instance.GetComponent<ModSaveBehaviour>();
             * if (modSaveBehaviour is null)
             * {
             * return;
             * }
             *
             * try
             * {
             * string data = modSaveBehaviour.Serialize();
             * if (data is null) Logger.Log("Null save data for {0} of type {1}", modSaveBehaviour.name, modSaveBehaviour.GetType().ToString());
             * if (!string.IsNullOrEmpty(data)) Logger.Log(data);
             * SaveDataManager.SetSaveData(__instance.m_InstanceID, modSaveBehaviour.GetType(), data);
             * Logger.Log("Serialized custom save data for {0} of type {1}", modSaveBehaviour.name, modSaveBehaviour.GetType().ToString());
             * }
             * catch (System.Exception e)
             * {
             * Logger.Log("Serializing custom save data for item {0} failed: {1}.", __instance.name, e.Message);
             * }*/
        }
示例#2
0
        public static void Prefix(GearItem __instance)
        {
            ModSaveBehaviour modSaveBehaviour = __instance.GetComponent <ModSaveBehaviour>();

            if (modSaveBehaviour == null)
            {
                return;
            }

            try
            {
                string data = modSaveBehaviour.Serialize();
                SaveDataManager.SetSaveData(__instance.m_InstanceID, modSaveBehaviour.GetType(), data);
            }
            catch (System.Exception e)
            {
                Implementation.Log("Serializing custom save data for item {0} failed: {1}.", __instance.name, e.Message);
            }
        }