示例#1
0
 void Start()
 {
     gameOverText.text    = "";
     reloadText.text      = "";
     timer                = gameObject.GetComponent <Timer>();
     player               = GameObject.Find("Player").GetComponent <CellCoordCameraMovement>();
     collectibleCollector = GameObject.Find("Player").GetComponent <CollectibleCollector>();
 }
示例#2
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());
            }
        }