public override void Entry(IModHelper helper) { instance = this; Log.Monitor = Monitor; Helper.Events.GameLoop.UpdateTicked += UpdateAnimations; Action updateTargets = () => { foreach (var screen in screenState.GetActiveValues()) { screen.Value.findTargetsCounter = 1; } }; Helper.Events.GameLoop.SaveCreated += (s, e) => updateTargets(); Helper.Events.GameLoop.SaveLoaded += (s, e) => updateTargets(); Helper.Events.GameLoop.DayStarted += (s, e) => updateTargets(); helper.Content.AssetEditors.Add(watcher = new WatchForUpdatesAssetEditor()); helper.ConsoleCommands.Add("cpa", "...", OnCommand); }
/// <summary>Raised after the game state is updated (≈60 times per second).</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private static void OnUpdateTicked(object sender, UpdateTickedEventArgs e) { if (Game1.dialogueUp || Game1.fadeToBlackAlpha > 0) { return; } if (!Game1.messagePause) { Game1.messagePause = true; } if (animalsWithBirthTomorrow.Count > 0) { if (animalsWithBirthTomorrow.Count() > 1) { string animalsString = string.Join(", ", animalsWithBirthTomorrow.Take(animalsWithBirthTomorrow.Count() - 1)) + " and " + animalsWithBirthTomorrow.Last(); Game1.drawObjectDialogue(DataLoader.i18n.Get("Tool.InseminationSyringe.BirthsTomorrow", new { animalNames = animalsString })); } else if (animalsWithBirthTomorrow.Count() == 1) { Game1.drawObjectDialogue(DataLoader.i18n.Get("Tool.InseminationSyringe.BirthTomorrow", new { animalName = animalsWithBirthTomorrow.FirstOrDefault() })); } animalsWithBirthTomorrow.Clear(); } else if (parentAnimal.Value == null) { if (parentAnimals.Value.Count > 0) { parentAnimal.Value = parentAnimals.Value.Dequeue(); if ((parentAnimal.Value.home.indoors.Value as AnimalHouse).isFull()) { if (!DataLoader.ModConfig.DisableFullBuildingForBirthNotification) { Game1.drawObjectDialogue(DataLoader.i18n.Get("Tool.InseminationSyringe.FullBuilding", new { animalName = parentAnimal.Value.displayName, buildingType = parentAnimal.Value.displayHouse })); } parentAnimal.Value = null; } else { Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\Events:AnimalBirth", (object)parentAnimal.Value.displayName, (object)parentAnimal.Value.shortDisplayType())); } } else { Game1.messagePause = false; if (parentAnimals.GetActiveValues().All(q => q.Value.Count == 0)) { events.GameLoop.UpdateTicked -= OnUpdateTicked; } } } else if (Game1.activeClickableMenu == null) { if (parentAnimal.Value.ownerID.Value == Game1.player.UniqueMultiplayerID || (AnimalHusbandryModEntry.ModHelper.Multiplayer.GetConnectedPlayer(parentAnimal.Value.ownerID.Value) == null && Context.IsMainPlayer)) { NamingMenu.doneNamingBehavior b = new NamingMenu.doneNamingBehavior(addNewHatchedAnimal); string title = Game1.content.LoadString("Strings\\Events:AnimalNamingTitle", (object)parentAnimal.Value.displayType); Game1.activeClickableMenu = (IClickableMenu) new NamingMenu(b, title, (string)null); } else { parentAnimal.Value = null; } } }