Exemple #1
0
        public static bool DetectHarvestableBerryBush(ref Bush __instance, ref bool __state)
        {
            try
            {
                // if other mods also define a __state variable of type bool they will have different values (aka harmony does not make us fight over the __state variable)
                __state = BerryBushLogic.IsHarvestableBush(__instance) && __instance.tileSheetOffset == 1;

                return(true);
            }
            catch (Exception e)
            {
                mod.ErrorLog("There was an exception in a patch", e);
                __state = false;
                return(true);
            }
        }
Exemple #2
0
        public static void FixBerryQuality(ref Bush __instance, ref bool __state)
        {
            try
            {
                // config calls are in ChangeBerryQualityAndGiveExp
                if (__state && BerryBushLogic.IsHarvestableBush(__instance) && __instance.tileSheetOffset == 0)
                {
                    var maxShake = mod.Helper.Reflection.GetField <float>(__instance, "maxShake");

                    if (maxShake.GetValue() == 0.0245436933f)
                    {
                        BerryBushLogic.ChangeBerryQualityAndGiveExp(__instance, mod);
                    }
                }
            }
            catch (Exception e)
            {
                mod.ErrorLog("There was an exception in a patch", e);
            }
        }
Exemple #3
0
        public static void PatchPostBushMachineXP(ref object __instance)
        {
            try
            {
                if (mod.Config.AutomationHarvestsGrantXP)
                {
                    var bush = mod.Helper.Reflection.GetProperty <Bush>(__instance, "Machine").GetValue();

                    if (bush.size.Value != Bush.greenTeaBush && bush.size.Value != Bush.walnutBush)
                    {
                        BerryBushLogic.RewardBerryXP(mod);
                    }
                }

                // I can't give quality because I would need to get the return value of type TrackedItem, but Harmony only gives me null if I define object __result (unlike with variables)
            }
            catch (Exception e)
            {
                mod.ErrorLog("There was an exception in a patch", e);
            }
        }