private static void HandleHatchling(
            ref Decorators.AnimalHouse moddedAnimalHouse,
            string name,
            Farmer moddedPlayer)
        {
            if (moddedAnimalHouse.IsFull())
            {
                return;
            }
            var withEggReadyToHatch = moddedAnimalHouse.GetIncubatorWithEggReadyToHatch();

            if (withEggReadyToHatch == null)
            {
                return;
            }
            string type;

            type = new Incubator(withEggReadyToHatch)
                   .GetRandomType(FarmAnimals.GroupTypesByCategory()
                                  .ToDictionary
                                      (kvp => kvp.Key,
                                      kvp => moddedPlayer.SanitizeBlueChickens(kvp.Value)));

            var building   = moddedAnimalHouse.GetBuilding();
            var farmAnimal = new Decorators.FarmAnimal(moddedPlayer.CreateFarmAnimal(type, name, building));

            farmAnimal.AddToBuilding(building);
            moddedAnimalHouse.ResetIncubator(withEggReadyToHatch);
            farmAnimal.SetCurrentProduce(-1);
        }
        private static void HandleNewborn(
            ref Decorators.AnimalHouse moddedAnimalHouse,
            string name,
            ref QuestionEvent questionEvent,
            Farmer moddedPlayer)
        {
            var withEggReadyToHatch = moddedAnimalHouse.GetIncubatorWithEggReadyToHatch();
            var moddedParent        = new Decorators.FarmAnimal(questionEvent.animal);
            var dictionary          = FarmAnimals.GroupTypesByCategory().Where(kvp => kvp.Value.Contains(moddedParent.GetTypeString()))
                                      .ToDictionary(kvp => kvp.Key, kvp => moddedPlayer.SanitizeBlueChickens(kvp.Value));
            var randomTypeFromProduce = moddedParent.GetRandomTypeFromProduce(dictionary);
            var building   = moddedAnimalHouse.GetBuilding();
            var farmAnimal = new Decorators.FarmAnimal(moddedPlayer.CreateFarmAnimal(randomTypeFromProduce, name, building));

            farmAnimal.AssociateParent(questionEvent.animal);
            farmAnimal.AddToBuilding(building);
            farmAnimal.SetCurrentProduce(-1);
            Event.ForceQuestionEventToProceed(questionEvent);
        }
        private static bool HandleOnFarm(
            ref Decorators.PurchaseAnimalsMenu moddedMenu,
            int x,
            int y,
            Farmer moddedPlayer)
        {
            if (moddedMenu.IsNamingAnimal())
            {
                return(true);
            }
            var viewport   = Game.GetViewport();
            var buildingAt = Game.GetFarm().getBuildingAt(new Vector2((x + viewport.X) / 64, (y + viewport.Y) / 64));

            if (buildingAt == null)
            {
                return(true);
            }
            var animalBeingPurchased = moddedMenu.GetAnimalBeingPurchased();
            var moddedAnimal         = new Decorators.FarmAnimal(animalBeingPurchased);

            if (!moddedAnimal.CanLiveIn(buildingAt) || new Building(buildingAt).IsFull() || !moddedAnimal.CanBeNamed())
            {
                return(true);
            }
            var priceOfAnimal = moddedMenu.GetPriceOfAnimal();

            if (!moddedPlayer.CanAfford(priceOfAnimal))
            {
                return(true);
            }
            moddedAnimal.AddToBuilding(buildingAt);
            moddedMenu.SetAnimalBeingPurchased(animalBeingPurchased);
            moddedMenu.SetNewAnimalHome(null);
            moddedMenu.SetNamingAnimal(false);
            moddedPlayer.SpendMoney(priceOfAnimal);
            PurchasedAnimalBellsAndWhistles(moddedAnimal);
            return(false);
        }