static void Postfix(WitchHut.WitchHutSaveData __instance, ref WitchHut __result, WitchHut obj) { System.Reflection.FieldInfo fieldInfo = typeof(WitchHut).GetField("spellData", BindingFlags.NonPublic | BindingFlags.Instance); ICollection spellDataCollection = fieldInfo.GetValue(__result) as ICollection; List <WitchHut.SpellData> spellDataList = new List <WitchHut.SpellData>(); foreach (object spellDataObject in spellDataCollection) { spellDataList.Add((WitchHut.SpellData)spellDataObject); } fieldInfo = typeof(WitchHut).GetField("currSpellCooldown", BindingFlags.NonPublic | BindingFlags.Instance); ICollection cooldownCollection = fieldInfo.GetValue(__result) as ICollection; List <int> cooldownList = new List <int>(); foreach (object cooldownObject in cooldownCollection) { cooldownList.Add((int)cooldownObject); } List <int> cooldownListAdjusted = new List <int>(); for (int cooldownIndex = 0; cooldownIndex < cooldownList.Count; cooldownIndex++) { if (cooldownIndex < spellDataList.Count) { cooldownListAdjusted.Add(cooldownList[cooldownIndex]); } else { break; } } for (int spellIndex = 0; spellIndex < spellDataList.Count - cooldownList.Count; spellIndex++) { cooldownListAdjusted.Add(0); } int[] cooldownArray = new int[cooldownListAdjusted.Count]; for (int cooldownIndex = 0; cooldownIndex < cooldownListAdjusted.Count; cooldownIndex++) { cooldownArray[cooldownIndex] = cooldownListAdjusted[cooldownIndex]; } fieldInfo.SetValue(__result, cooldownArray); }
static void Postfix(WitchHut.WitchHutSaveData __instance, ref WitchHut __result) { witchHut = __result; }