Ejemplo n.º 1
0
        public void CreateFromIncubator(StardewValley.AnimalHouse animalHouse, string name)
        {
            Incubator incubator;

            try
            {
                incubator = new Incubator(animalHouse);
            }
            catch
            {
                // Could not find an incubator; do nothing.
                return;
            }

            List <string> types = this.DetermineHatchlingTypes(incubator);

            // Remove types that should not be here
            types = this.Sanitize(types);

            // Create the animal if we could pull the type
            this.CreateRandomBaby(name, types, animalHouse);

            // Reset the incubator regardless if a baby was hatched or not
            incubator.ResetIncubatingItem();
        }
Ejemplo n.º 2
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;
             }
         }
     }
 }
Ejemplo n.º 3
0
 public static SDV.Event GetIncubatorHatchEvent(
     SDV.AnimalHouse animalHouse,
     string message = null)
 {
     return(new SDV.Event("none/-1000 -1000/farmer 2 9 0/pause 250/message \"" +
                          (message ?? Content.LoadString(
                               "Strings\\Locations:AnimalHouse_Incubator_Hatch_RegularEgg")) +
                          "\"/pause 500/animalNaming/pause 500/end"));
 }
Ejemplo n.º 4
0
 public static void AddAnimal(SDV.AnimalHouse animalHouse, SDV.FarmAnimal animal)
 {
     animalHouse.animals.Add(animal.myID.Value, animal);
     if (animalHouse.animalsThatLiveHere.Contains(animal.myID.Value))
     {
         return;
     }
     animalHouse.animalsThatLiveHere.Add(animal.myID.Value);
 }
Ejemplo n.º 5
0
        private FarmAnimals.FarmAnimal CreateBaby(string name, string type, StardewValley.AnimalHouse animalHouse, long parentID = FarmAnimals.FarmAnimal.PARENT_ID_DEFAULT)
        {
            FarmAnimals.FarmAnimal baby = new FarmAnimals.FarmAnimal(type, this.Farmer.GetNewID(), this.Farmer.MyID);

            baby.SynchronizeNames(name);
            baby.AssignParent(parentID);
            baby.RandomizeLocation(animalHouse);
            baby.AddToAnimalHouse(animalHouse);

            return(baby);
        }
Ejemplo n.º 6
0
 public static void ResetIncubator(SDV.AnimalHouse animalHouse, SDV.Object incubator)
 {
     incubator.heldObject.Value = null;
     if (animalHouse.getBuilding() is Barn _)
     {
         incubator.ParentSheetIndex = OstrichIncubatorItemIndex;
     }
     else
     {
         incubator.ParentSheetIndex = DefaultIncubatorItemIndex;
     }
     ResetIncubator(animalHouse);
 }
Ejemplo n.º 7
0
        private void CreateRandomBaby(string name, List <string> types, StardewValley.AnimalHouse animalHouse, long parentID = FarmAnimals.FarmAnimal.PARENT_ID_DEFAULT)
        {
            if (types.Count < 1)
            {
                return;
            }

            // Randomize an eligible animal type
            string type = types.ElementAt(Game1.random.Next(types.Count));

            // Create the baby!
            this.CreateBaby(name, type, animalHouse, parentID);
        }
Ejemplo n.º 8
0
 public static bool IsFull(SDV.AnimalHouse animalHouse)
 {
     return(animalHouse.isFull());
 }
Ejemplo n.º 9
0
 public static void ResetIncubator(SDV.AnimalHouse animalHouse)
 {
     animalHouse.incubatingEgg.X = 0;
     animalHouse.incubatingEgg.Y = -1;
 }
Ejemplo n.º 10
0
        public static SDV.Object GetIncubatorWithEggReadyToHatch(SDV.AnimalHouse animalHouse)
        {
            var incubators = GetIncubators(animalHouse);

            return(!incubators.Any() ? null : incubators.FirstOrDefault(o => Object.IsHoldingObject(o) && Object.IsReady(o)));
        }
Ejemplo n.º 11
0
 public static List <SDV.Object> GetIncubators(SDV.AnimalHouse animalHouse)
 {
     return(animalHouse.objects.Values.Where(o => Object.IsIncubator(o))
            .ToList());
 }
Ejemplo n.º 12
0
 public static SDV.Event GetCurrentEvent(SDV.AnimalHouse animalHouse)
 {
     return(animalHouse.currentEvent);
 }
Ejemplo n.º 13
0
 public static void SetCurrentEvent(SDV.AnimalHouse animalHouse, SDV.Event currentEvent)
 {
     animalHouse.currentEvent = currentEvent;
 }
Ejemplo n.º 14
0
 public static Building GetBuilding(SDV.AnimalHouse animalHouse)
 {
     return(animalHouse.getBuilding());
 }
Ejemplo n.º 15
0
 public static bool IsEggReadyToHatch(SDV.AnimalHouse animalHouse)
 {
     return(animalHouse.incubatingEgg.Y > 0 || animalHouse.incubatingEgg.X - 1 <= 0);
 }
Ejemplo n.º 16
0
 public void AutoGrabFromAnimals(StardewValley.AnimalHouse animalHouse)
 {
     Paritee.StardewValley.Core.Locations.AnimalHouse.AutoGrabFromAnimals(animalHouse, GetOriginal());
 }
Ejemplo n.º 17
0
 public AnimalHouse(StardewValley.AnimalHouse original)
     : base(original)
 {
 }
Ejemplo n.º 18
0
        public static void SetIncubatorHatchEvent(SDV.AnimalHouse animalHouse)
        {
            var incubatorHatchEvent = GetIncubatorHatchEvent(animalHouse);

            SetCurrentEvent(animalHouse, incubatorHatchEvent);
        }