/// <summary>Get the fields to display for the trash bear.</summary> /// <param name="trashBear">The trash bear for which to show info.</param> /// <remarks>Derived from <see cref="TrashBear.checkAction"/>.</remarks> private IEnumerable <ICustomField> GetDataForTrashBear(TrashBear trashBear) { // get number of quests completed const int maxQuests = 4; int questsDone = 0; if (NetWorldState.checkAnywhereForWorldStateID("trashBear1")) { questsDone = 1; } if (NetWorldState.checkAnywhereForWorldStateID("trashBear2")) { questsDone = 2; } if (NetWorldState.checkAnywhereForWorldStateID("trashBear3")) { questsDone = 3; } if (NetWorldState.checkAnywhereForWorldStateID("trashBearDone")) { questsDone = 4; } // show item wanted if (questsDone < maxQuests) { this.Reflection.GetMethod(trashBear, "updateItemWanted").Invoke(); int itemWantedIndex = this.Reflection.GetField <int>(trashBear, "itemWantedIndex").GetValue(); yield return(new ItemIconField(this.GameHelper, L10n.TrashBear.ItemWanted(), new SObject(itemWantedIndex, 1))); } // show progress yield return(new GenericField(this.GameHelper, L10n.TrashBear.QuestProgress(), L10n.Generic.Ratio(questsDone, maxQuests))); }
/// <summary>Get the data to display for this subject.</summary> public override IEnumerable <ICustomField> GetData() { NPC npc = this.Target; return(this.TargetType switch { SubjectType.Monster => this.GetDataForMonster((Monster)npc), SubjectType.Pet => this.GetDataForPet((Pet)npc), SubjectType.Villager => npc switch { Child child => this.GetDataForChild(child), TrashBear trashBear => this.GetDataForTrashBear(trashBear), _ => this.GetDataForVillager(npc) },
internal static bool updateItemWanted(TrashBear __instance) { int num1 = 0; if (NetWorldState.checkAnywhereForWorldStateID("trashBear1")) { num1 = 1; } if (NetWorldState.checkAnywhereForWorldStateID("trashBear2")) { num1 = 2; } if (NetWorldState.checkAnywhereForWorldStateID("trashBear3")) { num1 = 3; } int randomSeedAddition = 777111 + num1; var itemWantedIndex = DataLoader.Helper.Reflection.GetField <int>(__instance, "itemWantedIndex"); itemWantedIndex.SetValue(Utility.getRandomPureSeasonalItem(Game1.currentSeason, randomSeedAddition)); if (num1 <= 1) { return(false); } int num2 = new Random((int)Game1.uniqueIDForThisGame + randomSeedAddition).Next(CraftingRecipe.cookingRecipes.Count); int num3 = 0; foreach (string str in CraftingRecipe.cookingRecipes.Values) { if (num3 == num2) { itemWantedIndex.SetValue(Convert.ToInt32(str.Split('/')[2].Split(' ')[0])); break; } ++num3; } return(false); }