Exemple #1
0
 public static void AutoGrabFromAnimals(SDV.AnimalHouse animalHouse, SDV.Object autoGrabber)
 {
     foreach (var pair in animalHouse.animals.Pairs)
     {
         if (FarmAnimal.IsAProducer(pair.Value) && FarmAnimal.RequiresToolForHarvest(pair.Value) &&
             FarmAnimal.IsCurrentlyProducing(pair.Value) && !FarmAnimal.CanFindProduce(pair.Value) &&
             autoGrabber.heldObject.Value != null && autoGrabber.heldObject.Value is Chest chest)
         {
             SDV.Item obj = new SDV.Object(Vector2.Zero, FarmAnimal.GetCurrentProduce(pair.Value), null, false, true,
                                           false, false)
             {
                 Quality = FarmAnimal.GetProduceQuality(pair.Value)
             };
             if (chest.addItem(obj) == null)
             {
                 FarmAnimal.SetCurrentProduce(pair.Value, -1);
                 if (FarmAnimal.IsSheared(pair.Value))
                 {
                     FarmAnimal.ReloadSpriteTexture(pair.Value);
                 }
                 autoGrabber.showNextIndex.Value = true;
             }
         }
     }
 }