예제 #1
0
 public void OnButtonPressed(object sender, ButtonPressedEventArgs args)
 {
     if (!Context.IsWorldReady)
     {
         return;
     }
     if (args.Button == Conf.ToggleAfkFishing)
     {
         AutoFisher.ToggleAfkFishing();
     }
     if (!Context.IsPlayerFree || Game1.activeClickableMenu != null)
     {
         return;
     }
     if (args.Button == Conf.ButtonShowMenu)
     {
         //Open Up Menu
         JoeMenu.OpenMenu();
     }
     else if (args.Button == Conf.ButtonToggleBlackList)
     {
         HarvestAutomation.ToggleBlacklistUnderCursor();
     }
     else if (args.Button == Conf.ButtonToggleFlowerColorUnification)
     {
         FlowerColorUnifier.ToggleFlowerColorUnification();
     }
 }
예제 #2
0
        public void OnEveryUpdate()
        {
            if (!Context.IsWorldReady)
            {
                return;
            }

            IdlePause.OnTickUpdate();

            Farmer player = Game1.player;

            if (Conf.AutoGate)
            {
                FenceGateAutomation.TryToggleGate(player);
            }

            if (player.CurrentTool is FishingRod rod)
            {
                FishingProbabilitiesBox.UpdateProbabilities(rod);

                AutoFisher.AfkFishing();
            }

            GiftInformationTooltip.UpdateTooltip();
        }
예제 #3
0
 private void Start()
 {
     foreach (var autoFisher in autoFisherTypes)
     {
         AutoFisher newAutofisher = Instantiate(autoFisherPrefab);
         newAutofisher.transform.SetParent(transform);
         newAutofisher.Setup(autoFisher);
     }
 }
예제 #4
0
 public void OnPostRenderGui(object sender, RenderedActiveMenuEventArgs args)
 {
     if (Game1.activeClickableMenu is BobberBar bar)
     {
         if (Conf.FishingInfo)
         {
             FishInformationHud.DrawFishingInfoBox(Game1.spriteBatch, bar, Game1.dialogueFont);
         }
         if (Conf.AutoFishing)
         {
             AutoFisher.AutoFishing(bar);
         }
     }
     if (Conf.EstimateShippingPrice && Game1.activeClickableMenu is ItemGrabMenu menu)
     {
         ShippingEstimationInfoBox.DrawShippingPrice(menu, Game1.dialogueFont);
     }
 }
예제 #5
0
        private void OnGameEighthUpdate()
        {
            if (Game1.currentGameTime == null)
            {
                return;
            }

            if (Conf.CloseTreasureWhenAllLooted && Game1.activeClickableMenu is ItemGrabMenu menu)
            {
                InventoryAutomation.TryCloseItemGrabMenu(menu);
            }

            if (!Context.IsWorldReady || !Context.IsPlayerFree)
            {
                return;
            }

            Farmer       player   = Game1.player;
            GameLocation location = Game1.currentLocation;

            try
            {
                if (Conf.AutoReelRod)
                {
                    AutoFisher.AutoReelRod();
                }
                if (Game1.currentLocation is MineShaft shaft)
                {
                    bool isFallingDownShaft = InstanceHolder.Reflection.GetField <bool>(shaft, "isFallingDownShaft").GetValue();
                    if (isFallingDownShaft)
                    {
                        return;
                    }
                }
                if (!Context.CanPlayerMove)
                {
                    return;
                }
                if (Conf.UnifyFlowerColors)
                {
                    FlowerColorUnifier.UnifyFlowerColors();
                }

                _ticks = (_ticks + 1) % 8;
                if (Conf.BalancedMode && _ticks != 0)
                {
                    return;
                }
                FarmCleaner.OnEighthUpdate();
                if (Conf.AutoEat)
                {
                    FoodAutomation.TryToEatIfNeeded(player);
                }
                if (Conf.AutoPickUpTrash)
                {
                    TrashCanScavenger.ScavengeTrashCan();
                }
                if (Conf.AutoWaterNearbyCrops)
                {
                    HarvestAutomation.WaterNearbyCrops();
                }
                if (Conf.AutoPetNearbyAnimals)
                {
                    AnimalAutomation.PetNearbyAnimals();
                }

                if (Conf.AutoShearingAndMilking)
                {
                    AnimalAutomation.ShearingAndMilking(player);
                }
                if (Conf.AutoPullMachineResult)
                {
                    MachineOperator.PullMachineResult();
                }
                if (Conf.AutoDepositIngredient)
                {
                    MachineOperator.DepositIngredientsToMachines();
                }
                if (Conf.AutoHarvest)
                {
                    HarvestAutomation.HarvestNearbyCrops(player);
                }
                if (Conf.AutoDestroyDeadCrops)
                {
                    HarvestAutomation.DestroyNearDeadCrops(player);
                }
                if (Conf.AutoRefillWateringCan)
                {
                    WateringCanRefiller.RefillWateringCan();
                }
                if (Conf.AutoCollectCollectibles)
                {
                    CollectibleCollector.CollectNearbyCollectibles(location);
                }
                if (Conf.AutoDigArtifactSpot)
                {
                    ArtifactSpotDigger.DigNearbyArtifactSpots();
                }
                if (Conf.AutoShakeFruitedPlants)
                {
                    HarvestAutomation.ShakeNearbyFruitedTree();
                    HarvestAutomation.ShakeNearbyFruitedBush();
                }
                if (Conf.AutoAnimalDoor && !DayEnded && Game1.timeOfDay >= 1900)
                {
                    DayEnded = true;
                    EventHolder.Save.OnBeforeSave(null, null);
                }
                if (Conf.AutoPetNearbyPets)
                {
                    AnimalAutomation.PetNearbyPets();
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Source);
                Logger.Error(ex.ToString());
            }
        }