// If spell is valid deduct gold and return true public bool PurchaseSpell() { WitchHut.SpellData outSpell = null; int num = witchHut.TryActivate((WitchHut.Spells)spellIndex, out outSpell); if (num == 0) { return(true); } return(false); }
static void Postfix(WitchHut __instance) { System.Reflection.FieldInfo fieldInfo = typeof(WitchHut).GetField("spellData", BindingFlags.NonPublic | BindingFlags.Instance); ICollection spellDataCollection = fieldInfo.GetValue(__instance) as ICollection; List <WitchHut.SpellData> spellDataList = new List <WitchHut.SpellData>(); foreach (object spellDataObject in spellDataCollection) { spellDataList.Add((WitchHut.SpellData)spellDataObject); } spellDataOriginalCount = spellDataList.Count; foreach (SpellDataCustom currentSpellData in spellData) { spellDataList.Add(currentSpellData); } WitchHut.SpellData[] spellDataArray = new WitchHut.SpellData[spellDataList.Count]; for (int spellIndex = 0; spellIndex < spellDataList.Count; spellIndex++) { spellDataArray[spellIndex] = spellDataList[spellIndex]; } fieldInfo.SetValue(__instance, spellDataArray); fieldInfo = typeof(WitchHut).GetField("currSpellCooldown", BindingFlags.NonPublic | BindingFlags.Instance); fieldInfo.SetValue(__instance, new int[spellDataArray.Length]); }