private static void addNewHatchedAnimal(string name) { Building building = parentAnimal.home; FarmAnimal farmAnimal = new FarmAnimal(parentAnimal.type.Value, DataLoader.Helper.Multiplayer.GetNewID(), (long)Game1.player.UniqueMultiplayerID) { Name = name, displayName = name, home = building, }; farmAnimal.parentId.Value = parentAnimal.myID.Value; farmAnimal.homeLocation.Value = new Vector2((float)building.tileX.Value, (float)building.tileY.Value); farmAnimal.setRandomPosition(farmAnimal.home.indoors.Value); (building.indoors.Value as AnimalHouse).animals.Add(farmAnimal.myID.Value, farmAnimal); (building.indoors.Value as AnimalHouse).animalsThatLiveHere.Add(farmAnimal.myID.Value); PregnancyItem pregnacyItem = PregnancyController.GetPregnancyItem(parentAnimal.myID.Value); parentAnimal.allowReproduction.Value = pregnacyItem.AllowReproductionBeforeInsemination; PregnancyController.RemovePregnancyItem(pregnacyItem.Id); parentAnimal = null; Game1.exitActiveMenu(); }
public static FarmAnimal GetAnimal(long id) { FarmAnimal animal = Utility.getAnimal(id); if (animal != null) { return(animal); } else { AnimalHusbandryModEntry.monitor.Log($"The animal id '{id}' was not found in the game and its pregnancy data is being discarted.", LogLevel.Warn); PregnancyController.RemovePregnancyItem(id); return(null); } }