private string GetAct(AnimalContestItem animalContestInfo, bool isFirstTime) { StringBuilder jasAct = new StringBuilder(); string babyAnimalName = AnimalExtension.GetBabyAnimalNameByType(GetJasAnimal(animalContestInfo.MarnieAnimal)); jasAct.Append("/emote Lewis 40"); if (isFirstTime) { jasAct.Append($"/speak Lewis \"{GetDialog("Lewis.FirstTime1")}\""); jasAct.Append($"/speak Jas \"{GetDialog("Jas.FirstTime1")}\""); jasAct.Append($"/speak Lewis \"{GetDialog("Lewis.FirstTime2")}\""); jasAct.Append($"/speak Jas \"{GetDialog("Jas.FirstTime2")}\""); jasAct.Append($"/speak Lewis \"{GetDialog("Lewis.FirstTime3")}\""); jasAct.Append($"/speak Marnie \"{GetDialog("Marnie.FirstTime")}\""); jasAct.Append($"/speak Lewis \"{GetDialog("Lewis.FirstTime4", new { babyAnimalName })}\""); jasAct.Append($"/pause 1500/speak Lewis \"{GetDialog("Lewis.FirstTime5")}\""); jasAct.Append($"/emote Jas 20/speak Lewis \"{GetDialog("Lewis.FirstTime6")}\""); } else { jasAct.Append($"/speak Lewis \"{GetDialog("Lewis.OtherTimes1")}\""); jasAct.Append($"/speak Jas \"{GetDialog("Jas.OtherTimes1")}\""); jasAct.Append($"/speak Lewis \"{GetDialog("Lewis.OtherTimes2", new { babyAnimalName })}\""); jasAct.Append($"/pause 1500/speak Lewis \"{GetDialog("Lewis.OtherTimes3")}\""); jasAct.Append($"/emote Jas 20/speak Jas \"{GetDialog("Jas.OtherTimes2")}\""); jasAct.Append($"/jump Lewis/emote Lewis 16/speak Lewis \"{GetDialog("Lewis.OtherTimes4")}\""); } return(jasAct.ToString()); }
public bool CheckCorrectProduct(FarmAnimal animal, StardewValley.Object @object) { switch (AnimalExtension.GetAnimalFromType(animal.type.Value)) { case Animal.Cow: case Animal.Goat: return(animal.defaultProduceIndex.Value == @object.ParentSheetIndex || animal.deluxeProduceIndex.Value == @object.ParentSheetIndex); default: return(animal.defaultProduceIndex.Value == @object.ParentSheetIndex); } }
public bool IsEggAnimal(FarmAnimal animal) { switch (AnimalExtension.GetAnimalFromType(animal.type.Value)) { case Animal.Duck: case Animal.Chicken: case Animal.Dinosaur: return(true); default: return(false); } }
public AnimalItem GetAnimalItem(String farmAnimalType) { Animal?animalEnum = AnimalExtension.GetAnimalFromType(farmAnimalType); switch (animalEnum) { case Animal.Cow: return(Cow); case Animal.Pig: return(Pig); case Animal.Chicken: return(Chicken); case Animal.Duck: return(Duck); case Animal.Rabbit: return(Rabbit); case Animal.Sheep: return(Sheep); case Animal.Goat: return(Goat); case Animal.Ostrich: return(Ostrich); case Animal.Dinosaur: return(Dinosaur); case Animal.CustomAnimal: return(CustomAnimals.Find(a => farmAnimalType.Contains(a.Name))); default: return(null); } }
public override void DoFunction(GameLocation location, int x, int y, int power, StardewValley.Farmer who) { this.lastUser = who; Game1.recentMultiplayerRandom = new Random((int)(short)Game1.random.Next((int)short.MinValue, 32768)); this.CurrentParentTileIndex = InitialParentTileIndex; this.indexOfMenuItemView.Value = IndexOfMenuItemView; if (this._animal != null) { Animal?foundAnimal = AnimalExtension.GetAnimalFromType(this._animal.type.Value); who.Stamina -= ((float)4f - (float)who.FarmingLevel * 0.2f); int daysUtillBirth = (DataLoader.AnimalData.getAnimalItem((Animal)foundAnimal) as ImpregnatableAnimalItem).MinimumDaysUtillBirth; PregnancyController.AddPregancy(new PregnancyItem(this._animal.myID.Value, daysUtillBirth, this._animal.allowReproduction.Value)); this._animal.allowReproduction.Value = false; --this.attachments[0].Stack; if (this.attachments[0].Stack <= 0) { Game1.showGlobalMessage(DataLoader.i18n.Get("Tool.InseminationSyringe.ItemConsumed", new { itemName = this.attachments[0].DisplayName })); this.attachments[0] = (StardewValley.Object)null; } this._animal = (FarmAnimal)null; } if (Game1.activeClickableMenu == null) { who.CanMove = true; who.completelyStopAnimatingOrDoingAction(); } else { who.Halt(); } who.UsingTool = false; who.canReleaseTool = true; DataLoader.Helper.Reflection.GetMethod(this, "finish").Invoke(); }
public static bool beginUsing(MilkPail __instance, GameLocation location, int x, int y, StardewValley.Farmer who, ref bool __result) { if (!IsInseminationSyringe(__instance)) { return(true); } string inseminationSyringeId = __instance.modData[InseminationSyringeKey]; x = (int)who.GetToolLocation(false).X; y = (int)who.GetToolLocation(false).Y; Rectangle rectangle = new Rectangle(x - Game1.tileSize / 2, y - Game1.tileSize / 2, Game1.tileSize, Game1.tileSize); if (!DataLoader.ModConfig.DisablePregnancy) { if (location is Farm) { foreach (FarmAnimal farmAnimal in (location as Farm).animals.Values) { if (farmAnimal.GetBoundingBox().Intersects(rectangle)) { Animals[inseminationSyringeId] = farmAnimal; break; } } } else if (location is AnimalHouse) { foreach (FarmAnimal farmAnimal in (location as AnimalHouse).animals.Values) { if (farmAnimal.GetBoundingBox().Intersects(rectangle)) { Animals[inseminationSyringeId] = farmAnimal; break; } } } } Animals.TryGetValue(inseminationSyringeId, out FarmAnimal animal); if (animal != null) { string dialogue = ""; if (__instance.attachments[0] == null) { Game1.showRedMessage(DataLoader.i18n.Get("Tool.InseminationSyringe.Empty")); Animals[inseminationSyringeId] = null; } else if (AnimalExtension.GetAnimalFromType(animal.type.Value) == null) { dialogue = DataLoader.i18n.Get("Tool.InseminationSyringe.CantBeInseminated", new { animalName = animal.displayName }); } else if (IsEggAnimal(animal)) { dialogue = DataLoader.i18n.Get("Tool.InseminationSyringe.EggAnimal", new { animalName = animal.displayName }); } else if (!((ImpregnatableAnimalItem)DataLoader.AnimalData.GetAnimalItem(animal)).MinimumDaysUtillBirth.HasValue) { dialogue = DataLoader.i18n.Get("Tool.InseminationSyringe.CantBeInseminated", new { animalName = animal.displayName }); } else if (animal.isBaby()) { dialogue = DataLoader.i18n.Get("Tool.InseminationSyringe.TooYoung", new { animalName = animal.displayName }); } else if (PregnancyController.IsAnimalPregnant(animal)) { int daysUntilBirth = animal.GetDaysUntilBirth().Value; if (daysUntilBirth > 1) { dialogue = DataLoader.i18n.Get("Tool.InseminationSyringe.AlreadyPregnant", new { animalName = animal.displayName, numberOfDays = daysUntilBirth }); } else { dialogue = DataLoader.i18n.Get("Tool.InseminationSyringe.ReadyForBirth", new { animalName = animal.displayName }); } } else if (!CheckCorrectProduct(animal, __instance.attachments[0])) { var data = DataLoader.Helper.Content.Load <Dictionary <int, string> >(@"Data\ObjectInformation.xnb", ContentSource.GameContent); string produceName = data[animal.defaultProduceIndex.Value].Split('/')[4]; dialogue = DataLoader.i18n.Get("Tool.InseminationSyringe.CorrectItem", new { itemName = produceName }); } else if (PregnancyController.CheckBuildingLimit(animal)) { dialogue = DataLoader.i18n.Get("Tool.InseminationSyringe.BuildingLimit", new { buildingType = animal.displayHouse }); } else { animal.doEmote(16, true); if (who != null && Game1.player.Equals(who)) { if (animal.sound.Value != null) { ICue animalSound = Game1.soundBank.GetCue(animal.sound.Value); animalSound.Play(); } DelayedAction.playSoundAfterDelay("fishingRodBend", 300, location); DelayedAction.playSoundAfterDelay("fishingRodBend", 1200, location); } animal.pauseTimer = 1500; } if (dialogue.Length > 0) { if (who != null && Game1.player.Equals(who)) { DelayedAction.showDialogueAfterDelay(dialogue, 150); } Animals[inseminationSyringeId] = null; } } who.Halt(); int currentFrame = who.FarmerSprite.currentFrame; if (animal != null) { who.FarmerSprite.animateOnce(287 + who.FacingDirection, 50f, 4); } else { who.FarmerSprite.animateOnce(new FarmerSprite.AnimationFrame[1] { new FarmerSprite.AnimationFrame(currentFrame, 0, false, who.FacingDirection == 3, new AnimatedSprite.endOfAnimationBehavior(StardewValley.Farmer.useTool), true) }); } who.FarmerSprite.oldFrame = currentFrame; who.UsingTool = true; who.CanMove = false; __result = true; return(false); }
public override bool beginUsing(GameLocation location, int x, int y, StardewValley.Farmer who) { x = (int)who.GetToolLocation(false).X; y = (int)who.GetToolLocation(false).Y; Rectangle rectangle = new Rectangle(x - Game1.tileSize / 2, y - Game1.tileSize / 2, Game1.tileSize, Game1.tileSize); if (Context.IsMainPlayer && !DataLoader.ModConfig.DisablePregnancy) { if (location is Farm) { foreach (FarmAnimal farmAnimal in (location as Farm).animals.Values) { if (farmAnimal.GetBoundingBox().Intersects(rectangle)) { this._animal = farmAnimal; break; } } } else if (location is AnimalHouse) { foreach (FarmAnimal farmAnimal in (location as AnimalHouse).animals.Values) { if (farmAnimal.GetBoundingBox().Intersects(rectangle)) { this._animal = farmAnimal; break; } } } } if (this._animal != null) { string dialogue = ""; if (this.attachments[0] == null) { Game1.showRedMessage(DataLoader.i18n.Get("Tool.InseminationSyringe.Empty")); this._animal = null; } else if (AnimalExtension.GetAnimalFromType(this._animal.type.Value) == null) { dialogue = DataLoader.i18n.Get("Tool.InseminationSyringe.CantBeInseminated", new { animalName = this._animal.displayName }); } else if (IsEggAnimal(this._animal)) { dialogue = DataLoader.i18n.Get("Tool.InseminationSyringe.EggAnimal", new { animalName = this._animal.displayName }); } else if (this._animal.isBaby()) { dialogue = DataLoader.i18n.Get("Tool.InseminationSyringe.TooYoung", new { animalName = this._animal.displayName }); } else if (PregnancyController.IsAnimalPregnant(this._animal.myID.Value)) { int daysUtillBirth = PregnancyController.GetPregnancyItem(this._animal.myID.Value).DaysUntilBirth; if (daysUtillBirth > 1) { dialogue = DataLoader.i18n.Get("Tool.InseminationSyringe.AlreadyPregnant", new { animalName = this._animal.displayName, numberOfDays = daysUtillBirth }); } else { dialogue = DataLoader.i18n.Get("Tool.InseminationSyringe.ReadyForBirth", new { animalName = this._animal.displayName }); } } else if (!CheckCorrectProduct(this._animal, this.attachments[0])) { var data = DataLoader.Helper.Content.Load <Dictionary <int, string> >(@"Data\ObjectInformation.xnb", ContentSource.GameContent); string produceName = data[this._animal.defaultProduceIndex.Value].Split('/')[4]; dialogue = DataLoader.i18n.Get("Tool.InseminationSyringe.CorrectItem", new { itemName = produceName }); } else if (PregnancyController.CheckBuildingLimit(this._animal)) { dialogue = DataLoader.i18n.Get("Tool.InseminationSyringe.BuildingLimit", new { buildingType = this._animal.displayHouse }); } else { this._animal.doEmote(16, true); if (this._animal.sound.Value != null) { Cue animalSound = Game1.soundBank.GetCue(this._animal.sound.Value); animalSound.Play(); } DelayedAction.playSoundAfterDelay("fishingRodBend", 300); DelayedAction.playSoundAfterDelay("fishingRodBend", 1200); this._animal.pauseTimer = 1500; } if (dialogue.Length > 0) { DelayedAction.showDialogueAfterDelay(dialogue, 150); this._animal = null; } } who.Halt(); int currentFrame = who.FarmerSprite.currentFrame; if (this._animal != null) { who.FarmerSprite.animateOnce(287 + who.FacingDirection, 50f, 4); } else { who.FarmerSprite.animateOnce(new FarmerSprite.AnimationFrame[1] { new FarmerSprite.AnimationFrame(currentFrame, 0, false, who.FacingDirection == 3, new AnimatedSprite.endOfAnimationBehavior(StardewValley.Farmer.useTool), true) }); } who.FarmerSprite.oldFrame = currentFrame; who.UsingTool = true; who.CanMove = false; return(true); }