/* * Added by Mizzion. This method is used to get the gem color, so the junimos can be colored * I ripped this from SDV and edited it to work with this mod. */ public static Color?getGemColor(ref bool isPrismatic, JunimoHut hut) { List <Color> colorList = new List <Color>(); Chest chest = hut.output.Value; foreach (Item dye_object in chest.items) { if (dye_object != null && (dye_object.Category == MineralCategory || dye_object.Category == GemCategory)) { Color?dyeColor = TailoringMenu.GetDyeColor(dye_object); if (dye_object.Name == "Prismatic Shard") { isPrismatic = true; } if (dyeColor.HasValue) { colorList.Add(dyeColor.Value); } } } if (colorList.Count > 0) { return(new Color?(colorList[Game1.random.Next(colorList.Count)])); } return(new Color?()); }
protected Cropbeast(CropTile cropTile, bool containsPlant, bool containsPrimaryHarvest, bool containsSecondaryHarvest, string beastName = null) : base(beastName ?? cropTile.mapping.beastName, cropTile.location, Utility.PointToVector2(cropTile.tileLocation) * 64f + new Vector2(0f, -32f)) { cropTile_ = cropTile; harvestIndex.Value = cropTile.harvestIndex; giantCrop.Value = cropTile.giantCrop; tileLocation.Value = cropTile.tileLocation; this.containsPlant.Value = containsPlant; this.containsPrimaryHarvest.Value = containsPrimaryHarvest; this.containsSecondaryHarvest.Value = containsSecondaryHarvest; // Calculate the beast's coloration. primaryColor.Value = cropTile.mapping.primaryColor ?? TailoringMenu.GetDyeColor(cropTile.mapping.harvestObject) ?? Color.White; secondaryColor.Value = cropTile.mapping.secondaryColor ?? primaryColor.Value; // Scale health and damage based on combat skill of players present. // Base values in Monsters.json are for level zero. MaxHealth = Health = scaleByCombatSkill(Health, 1.2f); DamageToFarmer = scaleByCombatSkill(DamageToFarmer, 0.2f); // Calculate the normal gain of farming experience. int price = cropTile.mapping.harvestObject.Price; experienceGained.Value = (int)Math.Ceiling(8.0 * Math.Log(0.018 * (double)price + 1.0, Math.E)); }
private Color?getGemColor(ref bool isPrismatic) { List <Color> gemColors = new List <Color>(); foreach (Item item in output.Value.items) { if (item != null && (item.Category == -12 || item.Category == -2)) { Color?gemColor = TailoringMenu.GetDyeColor(item); if (item.Name == "Prismatic Shard") { isPrismatic = true; } if (gemColor.HasValue) { gemColors.Add(gemColor.Value); } } } if (gemColors.Count > 0) { return(gemColors[Game1.random.Next(gemColors.Count)]); } return(null); }
public TailorRecipeListTool() : base(Game1.uiViewport.Width / 2 - (632 + IClickableMenu.borderWidth * 2) / 2, Game1.uiViewport.Height / 2 - (600 + IClickableMenu.borderWidth * 2) / 2 - 64, 632 + IClickableMenu.borderWidth * 2, 600 + IClickableMenu.borderWidth * 2 + 64) { TailoringMenu tailoring_menu = new TailoringMenu(); Game1.player.faceDirection(2); Game1.player.FarmerSprite.StopAnimation(); recipeComponents = new List <ClickableTextureComponent>(); _recipeLookup = new Dictionary <string, KeyValuePair <Item, Item> >(); _recipeMetadata = new Dictionary <string, string>(); _recipeColors = new Dictionary <string, Color>(); Item cloth = new Object(Vector2.Zero, 428, 1); foreach (int id in Game1.objectInformation.Keys) { Item key = new Object(Vector2.Zero, id, 1); if (key.Name.Contains("Seeds") || key.Name.Contains("Floor") || key.Name.Equals("Stone") || key.Name.Contains("Weeds") || key.Name.Equals("Lumber") || key.Name.Contains("Fence") || key.Name.Equals("Gate") || key.Name.Contains("Starter") || key.Name.Contains("Twig") || key.Name.Equals("Secret Note") || key.Name.Contains("Guide") || key.Name.Contains("Path") || key.Name.Contains("Ring") || (int)key.category == -22 || key.Name.Contains("Sapling")) { continue; } Item value = tailoring_menu.CraftItem(cloth, key); TailorItemRecipe recipe = tailoring_menu.GetRecipeForItems(cloth, key); KeyValuePair <Item, Item> kvp = new KeyValuePair <Item, Item>(key, value); _recipeLookup[Utility.getStandardDescriptionFromItem(key, 1)] = kvp; string metadata = ""; Color? dye_color = TailoringMenu.GetDyeColor(key); if (dye_color.HasValue) { _recipeColors[Utility.getStandardDescriptionFromItem(key, 1)] = dye_color.Value; } if (recipe != null) { metadata = "clothes id: " + recipe.CraftedItemID + " from "; foreach (string context_tag in recipe.SecondItemTags) { metadata = metadata + context_tag + " "; } metadata.Trim(); } _recipeMetadata[Utility.getStandardDescriptionFromItem(key, 1)] = metadata; ClickableTextureComponent component = new ClickableTextureComponent(new Rectangle(0, 0, 64, 64), null, default(Rectangle), 1f) { myID = 0, name = Utility.getStandardDescriptionFromItem(key, 1), label = key.DisplayName }; recipeComponents.Add(component); } okButton = new ClickableTextureComponent("OK", new Rectangle(xPositionOnScreen + width - IClickableMenu.borderWidth - IClickableMenu.spaceToClearSideBorder - 64, yPositionOnScreen + height - IClickableMenu.borderWidth - IClickableMenu.spaceToClearTopBorder + 16, 64, 64), null, null, Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46), 1f) { upNeighborID = -99998, leftNeighborID = -99998, rightNeighborID = -99998, downNeighborID = -99998 }; RepositionElements(); }
public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, StackDrawType drawStackNumber, Color color, bool drawShadow) { if (combinedRings.Count >= 2) { float oldScaleSize = scaleSize; scaleSize = 1f; location.Y -= (oldScaleSize - 1f) * 32f; Rectangle src = Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, combinedRings[0].indexInTileSheet, 16, 16); src.X += 5; src.Y += 7; src.Width = 4; src.Height = 6; spriteBatch.Draw(Game1.objectSpriteSheet, location + new Vector2(51f, 51f) * scaleSize + new Vector2(-12f, 8f) * scaleSize, src, color * transparency, 0f, new Vector2(1.5f, 2f) * 4f * scaleSize, scaleSize * 4f, SpriteEffects.None, layerDepth); src.X++; src.Y += 4; src.Width = 3; src.Height = 1; spriteBatch.Draw(Game1.objectSpriteSheet, location + new Vector2(51f, 51f) * scaleSize + new Vector2(-8f, 4f) * scaleSize, src, color * transparency, 0f, new Vector2(1.5f, 2f) * 4f * scaleSize, scaleSize * 4f, SpriteEffects.None, layerDepth); src = Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, combinedRings[1].indexInTileSheet, 16, 16); src.X += 9; src.Y += 7; src.Width = 4; src.Height = 6; spriteBatch.Draw(Game1.objectSpriteSheet, location + new Vector2(51f, 51f) * scaleSize + new Vector2(4f, 8f) * scaleSize, src, color * transparency, 0f, new Vector2(1.5f, 2f) * 4f * scaleSize, scaleSize * 4f, SpriteEffects.None, layerDepth); src.Y += 4; src.Width = 3; src.Height = 1; spriteBatch.Draw(Game1.objectSpriteSheet, location + new Vector2(51f, 51f) * scaleSize + new Vector2(4f, 4f) * scaleSize, src, color * transparency, 0f, new Vector2(1.5f, 2f) * 4f * scaleSize, scaleSize * 4f, SpriteEffects.None, layerDepth); Color?color3 = TailoringMenu.GetDyeColor(combinedRings[0]); Color?color2 = TailoringMenu.GetDyeColor(combinedRings[1]); Color color1noNull = Color.Red; Color color2noNull = Color.Blue; if (color3.HasValue) { color1noNull = color3.Value; } if (color2.HasValue) { color2noNull = color2.Value; } base.drawInMenu(spriteBatch, location + new Vector2(-5f, -1f), scaleSize, transparency, layerDepth, drawStackNumber, Utility.Get2PhaseColor(color1noNull, color2noNull), drawShadow); spriteBatch.Draw(Game1.objectSpriteSheet, location + new Vector2(13f, 35f) * scaleSize, new Rectangle(263, 579, 4, 2), Utility.Get2PhaseColor(color1noNull, color2noNull, 0, 1f, 1125f) * transparency, -(float)Math.PI / 2f, new Vector2(2f, 1.5f) * scaleSize, scaleSize * 4f, SpriteEffects.None, layerDepth); spriteBatch.Draw(Game1.objectSpriteSheet, location + new Vector2(49f, 35f) * scaleSize, new Rectangle(263, 579, 4, 2), Utility.Get2PhaseColor(color1noNull, color2noNull, 0, 1f, 375f) * transparency, (float)Math.PI / 2f, new Vector2(2f, 1.5f) * scaleSize, scaleSize * 4f, SpriteEffects.None, layerDepth); spriteBatch.Draw(Game1.objectSpriteSheet, location + new Vector2(31f, 53f) * scaleSize, new Rectangle(263, 579, 4, 2), Utility.Get2PhaseColor(color1noNull, color2noNull, 0, 1f, 750f) * transparency, (float)Math.PI, new Vector2(2f, 1.5f) * scaleSize, scaleSize * 4f, SpriteEffects.None, layerDepth); } else { base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, color, drawShadow); } }
/********* ** Private methods *********/ /// <summary>The method to call before <see cref="TailoringMenu.GetRecipeForItems"/>.</summary> /// <returns>Returns whether to run the original method.</returns> private static bool Before_GetRecipeForItems(TailoringMenu __instance, Item left_item, Item right_item, ref TailorItemRecipe __result) { if (left_item == null || right_item == null) { return(true); } for (int i = 0; i < Mod.customTailoringRecipes.Count; ++i) { var recipe = Mod.customTailoringRecipes[i]; bool okay = true; foreach (string tag in recipe.FirstItemTags) { if (!left_item.HasContextTag(tag)) { okay = false; break; } } if (!okay) { continue; } foreach (string tag in recipe.SecondItemTags) { if (!right_item.HasContextTag(tag)) { okay = false; break; } } if (okay) { __result = new TailorItemRecipe() { FirstItemTags = recipe.FirstItemTags, SecondItemTags = recipe.SecondItemTags, SpendRightItem = recipe.ConsumeSecondItem, CraftedItemIDs = new List <string>(new[] { "DGA/TailoringRecipe/" + i }) }; return(false); } } return(true); }
#pragma warning disable IDE1006 public static bool CraftItem_Prefix(TailoringMenu __instance, ref Item __result, Item left_item, Item right_item) { try { // First/left item must be boots. if (left_item is not Boots boots) { return(true); } // Second/right item must be a prismatic shard. if (!Utility.IsNormalObjectAtParentSheetIndex(right_item, 74)) { return(true); } // Use the Prismatic Boots index with Leather Boots as fallback. int index = ModEntry.Instance.bootsSheetIndex; if (index == -1) { index = 506; } // In case the boots are already prismatic, return them // unmodified to preserve any stats already on them. if (boots.indexInTileSheet.Value != index) { // Clone the original boots as a stat source, since the stats // will change as soon as the index is changed. Boots statSource = new (boots.indexInTileSheet.Value); boots.indexInTileSheet.Value = index; boots.applyStats(statSource); // includes reloadData } // Return the modified original boots, since otherwise they // would remain unconsumed. __result = boots; return(false); } catch (Exception e) { Monitor.Log($"Failed in {nameof (CraftItem_Prefix)}:\n{e}", LogLevel.Error); Monitor.Log(e.StackTrace, LogLevel.Trace); } return(true); }
protected override void OnTarget(Mobile from, object target) { if (m_Tool.Deleted || m_Tool.RootParent != from) { return; } if (target is Cloth) { Item item = (Item)target; if (item.RootParent != from) { from.SendAsciiMessage("That must be in your pack for you to use it."); } else { if (from.Backpack.GetAmount(typeof(Cloth)) >= 2) { from.SendMenu(new TailoringMenu(from, TailoringMenu.Main(from), "Main", (BaseTool)m_Tool)); } else { from.SendAsciiMessage("You don't have the resources required to make anything from that."); } } } else if (target is Leather || target is Hides) { Item item = (Item)target; if (item.RootParent != from) { from.SendAsciiMessage("That must be in your pack for you to use it."); } else { if (from.Backpack.GetAmount(typeof(Leather)) >= 2 || from.Backpack.GetAmount(typeof(Hides)) >= 2) { from.SendMenu(new TailoringMenu(from, TailoringMenu.LeatherMain(from), "LeatherMain", (BaseTool)m_Tool)); } else { from.SendAsciiMessage("You don't have the resources required to make anything from that."); } } } }
/// <summary>The method to call before <see cref="TailoringMenu.CraftItem"/>.</summary> /// <returns>Returns whether to run the original method.</returns> private static bool Before_CraftItem(TailoringMenu __instance, Item left_item, Item right_item, ref Item __result) { if (left_item == null || right_item == null) { return(false); } var recipe = __instance.GetRecipeForItems(left_item, right_item); if (recipe != null && recipe.CraftedItemIDs != null && recipe.CraftedItemIDs.Count == 1 && recipe.CraftedItemIDs[0].StartsWith("DGA/TailoringRecipe/")) { var customRecipe = Mod.customTailoringRecipes[int.Parse(recipe.CraftedItemIDs[0].Substring("DGA/TailoringRecipe/".Length))]; __result = customRecipe.CraftedItem.Choose().Create(); return(false); } return(true); }
public static SObject GetRoeForFish(SObject fish) { Color color = TailoringMenu.GetDyeColor(fish) ?? Color.Orange; if (fish.ParentSheetIndex == 698) { color = new Color(61, 55, 42); } ColoredObject result = new(812, 1, color); result.name = fish.Name + " Roe"; result.preserve.Value = SObject.PreserveType.Roe; result.preservedParentSheetIndex.Value = fish.ParentSheetIndex; result.Price += fish.Price / 2; return(result); }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="label">A short field label.</param> /// <param name="item">The dye-producing item.</param> public ColorField(string label, Item item) : base(label) { // get color if (item.Name == "Prismatic Shard") { this.IsPrismatic = true; this.HasValue = true; } else { Color?color = TailoringMenu.GetDyeColor(item); if (color.HasValue) { this.Color = color.Value; this.HasValue = true; } } // get dye strength if (this.HasValue) { if (item.HasContextTag("dye_strong")) { this.Strength = 3; } else if (item.HasContextTag("dye_medium")) { this.Strength = 2; } else { this.Strength = 1; } } }
static void ValidateCraft(TailoringMenu __instance) { // TODO: HUD message is displayed behind tailoring menu -> store once and show when tailoring menu gets closed if (__instance.craftResultDisplay.item != null && ItemDefinitions.GetExtInfo(__instance.craftResultDisplay.item, out ExtItemInfo extInfo)) { if (extInfo.IsCraftingDisabled) { if (extInfo.SoldBy != Shop.None) { // display a hint after closing the menu where the player might buy the item TailoringPatches.AddTailoringMessage($"Hm, that did not quite work out. Maybe {extInfo.SoldBy.GetShopReferral()} sells something similar.", __instance.craftResultDisplay.item); } // indicate to the player that this is an invalid recipe now int itemId = __instance.craftResultDisplay.item.parentSheetIndex; __instance.craftResultDisplay.item = null; craftStateFieldInfo.SetValue(__instance, CraftState.InvalidRecipe); craftDisplayedDescriptionFieldInfo.SetValue(__instance, Game1.content.LoadString("Strings\\UI:Tailor_InvalidRecipe")); // delete the recipe, so that the player cannot craft the item __instance._tailoringRecipes.RemoveAll(x => x.CraftedItemID == itemId); } } }
public override void Draw(SpriteBatch batch, Vector2 location, float scale, int frame = -1, float size = 16, Color?baseColor = null, Color?overlayColor = null, float alpha = 1) { int firstIdx = Ring.combinedRings[0].indexInTileSheet.Value; int secondIdx = Ring.combinedRings[1].indexInTileSheet.Value; //location.Y -= 8 * scale; Vector2 Origin = new(2f, 1f); // Part One - Left Ring Arc Rectangle p1 = Game1.getSourceRectForStandardTileSheet(Texture, firstIdx, 16, 16); p1.X += 5; p1.Y += 7; p1.Width = 4; p1.Height = 6; batch.Draw( texture: Texture, position: location + new Vector2(5f, 7f) * scale, sourceRectangle: p1, color: Color.White, rotation: 0f, origin: Origin, scale: scale, effects: SpriteEffects.None, layerDepth: 1f ); // Part Two - Left Ring Slice p1.X++; p1.Y += 4; p1.Width = 3; p1.Height = 1; batch.Draw( texture: Texture, position: location + new Vector2(6f, 6f) * scale, sourceRectangle: p1, color: Color.White, rotation: 0f, origin: Origin, scale: scale, effects: SpriteEffects.None, layerDepth: 1f ); // Part Three - Right Ring Arc Rectangle p2 = Game1.getSourceRectForStandardTileSheet(Texture, secondIdx, 16, 16); p2.X += 9; p2.Y += 7; p2.Width = 4; p2.Height = 6; batch.Draw( texture: Texture, position: location + new Vector2(9f, 7f) * scale, sourceRectangle: p2, color: Color.White, rotation: 0f, origin: Origin, scale: scale, effects: SpriteEffects.None, layerDepth: 1f ); // Part Four - Right Ring Slice p2.Y += 4; p2.Width = 3; p2.Height = 1; batch.Draw( texture: Texture, position: location + new Vector2(9f, 6f) * scale, sourceRectangle: p2, color: Color.White, rotation: 0f, origin: Origin, scale: scale, effects: SpriteEffects.None, layerDepth: 1f ); // Dye Colors Color firstColor = TailoringMenu.GetDyeColor(Ring.combinedRings[0]) ?? Color.Red; Color secondColor = TailoringMenu.GetDyeColor(Ring.combinedRings[1]) ?? Color.Blue; // Standard Draw batch.Draw( texture: Texture, position: location, sourceRectangle: BaseSource, color: Utility.Get2PhaseColor(firstColor, secondColor), rotation: 0f, origin: new Vector2(2f, 1f), scale: scale, effects: SpriteEffects.None, layerDepth: 1f ); // Final Drawing Rectangle RING_BIT = new(263, 579, 4, 2); // Left Ring Bit batch.Draw( texture: Texture, position: location + new Vector2(2f, 8f) * scale, sourceRectangle: RING_BIT, color: Utility.Get2PhaseColor(firstColor, secondColor, timeOffset: 1125f), rotation: -1.570796f, origin: new Vector2(2f, 1f), scale: scale, effects: SpriteEffects.None, layerDepth: 1f ); // Right Ring Bit batch.Draw( texture: Texture, position: location + new Vector2(12f, 8f) * scale, sourceRectangle: RING_BIT, color: Utility.Get2PhaseColor(firstColor, secondColor, timeOffset: 375f), rotation: 1.570796f, origin: new Vector2(2f, 1f), scale: scale, effects: SpriteEffects.None, layerDepth: 1f ); // Bottom Ring Bit batch.Draw( texture: Texture, position: location + new Vector2(7f, 13f) * scale, sourceRectangle: RING_BIT, color: Utility.Get2PhaseColor(firstColor, secondColor, timeOffset: 750f), rotation: 3.141593f, origin: new Vector2(2f, 1f), scale: scale, effects: SpriteEffects.None, layerDepth: 1f ); }
/// <summary>Get the color to use a given fish's roe.</summary> /// <param name="fish">The fish whose roe to color.</param> /// <remarks>Derived from <see cref="StardewValley.Buildings.FishPond.GetFishProduce"/>.</remarks> private Color GetRoeColor(SObject fish) { return(fish.ParentSheetIndex == 698 // sturgeon ? new Color(61, 55, 42) : (TailoringMenu.GetDyeColor(fish) ?? Color.Orange)); }
internal static void TailoringMenuPatch(TailoringMenu __instance) { try { int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position string toSpeak = " "; if (__instance.leftIngredientSpot != null && __instance.leftIngredientSpot.containsPoint(x, y)) { if (__instance.leftIngredientSpot.item == null) { toSpeak = "Input cloth here"; } else { Item item = __instance.leftIngredientSpot.item; toSpeak = $"Cloth slot: {item.Stack} {item.DisplayName}"; } } else if (__instance.rightIngredientSpot != null && __instance.rightIngredientSpot.containsPoint(x, y)) { if (__instance.rightIngredientSpot.item == null) { toSpeak = "Input ingredient here"; } else { Item item = __instance.rightIngredientSpot.item; toSpeak = $"Ingredient slot: {item.Stack} {item.DisplayName}"; } } else if (__instance.startTailoringButton != null && __instance.startTailoringButton.containsPoint(x, y)) { toSpeak = "Star tailoring button"; } else if (__instance.trashCan != null && __instance.trashCan.containsPoint(x, y)) { toSpeak = "Trashcan"; } else if (__instance.okButton != null && __instance.okButton.containsPoint(x, y)) { toSpeak = "ok button"; } else if (__instance.dropItemInvisibleButton != null && __instance.dropItemInvisibleButton.containsPoint(x, y)) { toSpeak = "drop item"; } else if (__instance.equipmentIcons.Count > 0 && __instance.equipmentIcons[0].containsPoint(x, y)) { toSpeak = "Hat Slot"; if (Game1.player.hat.Value != null) { toSpeak = $"{toSpeak}: {Game1.player.hat.Value.DisplayName}"; } } else if (__instance.equipmentIcons.Count > 0 && __instance.equipmentIcons[1].containsPoint(x, y)) { toSpeak = "Shirt Slot"; if (Game1.player.shirtItem.Value != null) { toSpeak = $"{toSpeak}: {Game1.player.shirtItem.Value.DisplayName}"; } } else if (__instance.equipmentIcons.Count > 0 && __instance.equipmentIcons[2].containsPoint(x, y)) { toSpeak = "Pants Slot"; if (Game1.player.pantsItem.Value != null) { toSpeak = $"{toSpeak}: {Game1.player.pantsItem.Value.DisplayName}"; } } else { for (int i = 0; i < __instance.inventory.inventory.Count; i++) { if (!__instance.inventory.inventory[i].containsPoint(x, y)) { continue; } if (__instance.inventory.actualInventory[i] == null) { toSpeak = "Empty slot"; } else { toSpeak = $"{__instance.inventory.actualInventory[i].Stack} {__instance.inventory.actualInventory[i].DisplayName}"; } if (tailoringMenuQuery != $"{toSpeak}:{i}") { tailoringMenuQuery = $"{toSpeak}:{i}"; MainClass.ScreenReader.Say(toSpeak, true); } return; } } if (tailoringMenuQuery != toSpeak) { tailoringMenuQuery = toSpeak; MainClass.ScreenReader.Say(toSpeak, true); if (__instance.dropItemInvisibleButton != null && __instance.dropItemInvisibleButton.containsPoint(x, y)) { Game1.playSound("drop_item"); } } } catch (System.Exception e) { MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}"); } }
public IEnumerable <SearchableItem> GetAll() { IEnumerable <SearchableItem> GetAllRaw() { // get tools for (int quality = Tool.stone; quality <= Tool.iridium; quality++) { yield return(this.TryCreate(ItemType.Tool, ToolFactory.axe, () => ToolFactory.getToolFromDescription(ToolFactory.axe, quality))); yield return(this.TryCreate(ItemType.Tool, ToolFactory.hoe, () => ToolFactory.getToolFromDescription(ToolFactory.hoe, quality))); yield return(this.TryCreate(ItemType.Tool, ToolFactory.pickAxe, () => ToolFactory.getToolFromDescription(ToolFactory.pickAxe, quality))); yield return(this.TryCreate(ItemType.Tool, ToolFactory.wateringCan, () => ToolFactory.getToolFromDescription(ToolFactory.wateringCan, quality))); if (quality != Tool.iridium) { yield return(this.TryCreate(ItemType.Tool, ToolFactory.fishingRod, () => ToolFactory.getToolFromDescription(ToolFactory.fishingRod, quality))); } } yield return(this.TryCreate(ItemType.Tool, this.CustomIDOffset, () => new MilkPail())); // these don't have any sort of ID, so we'll just assign some arbitrary ones yield return(this.TryCreate(ItemType.Tool, this.CustomIDOffset + 1, () => new Shears())); yield return(this.TryCreate(ItemType.Tool, this.CustomIDOffset + 2, () => new Pan())); yield return(this.TryCreate(ItemType.Tool, this.CustomIDOffset + 3, () => new Wand())); // clothing foreach (int id in Game1.clothingInformation.Keys) { yield return(this.TryCreate(ItemType.Clothing, id, () => new Clothing(id))); } // wallpapers for (int id = 0; id < 112; id++) { yield return(this.TryCreate(ItemType.Wallpaper, id, () => new Wallpaper(id) { Category = SObject.furnitureCategory })); } // flooring for (int id = 0; id < 56; id++) { yield return(this.TryCreate(ItemType.Flooring, id, () => new Wallpaper(id, isFloor: true) { Category = SObject.furnitureCategory })); } // equipment foreach (int id in this.TryLoad <int, string>("Data\\Boots").Keys) { yield return(this.TryCreate(ItemType.Boots, id, () => new Boots(id))); } foreach (int id in this.TryLoad <int, string>("Data\\hats").Keys) { yield return(this.TryCreate(ItemType.Hat, id, () => new Hat(id))); } // weapons foreach (int id in this.TryLoad <int, string>("Data\\weapons").Keys) { yield return(this.TryCreate(ItemType.Weapon, id, () => (id >= 32 && id <= 34) ? (Item) new Slingshot(id) : new MeleeWeapon(id) )); } // furniture foreach (int id in this.TryLoad <int, string>("Data\\Furniture").Keys) { if (id == 1466 || id == 1468) { yield return(this.TryCreate(ItemType.Furniture, id, () => new TV(id, Vector2.Zero))); } else { yield return(this.TryCreate(ItemType.Furniture, id, () => new Furniture(id, Vector2.Zero))); } } // craftables foreach (int id in Game1.bigCraftablesInformation.Keys) { yield return(this.TryCreate(ItemType.BigCraftable, id, () => new SObject(Vector2.Zero, id))); } // objects foreach (int id in Game1.objectInformation.Keys) { string[] fields = Game1.objectInformation[id]?.Split('/'); // secret notes if (id == 79) { foreach (int secretNoteId in this.TryLoad <int, string>("Data\\SecretNotes").Keys) { yield return(this.TryCreate(ItemType.Object, this.CustomIDOffset + secretNoteId, () => { SObject note = new SObject(79, 1); note.name = $"{note.name} #{secretNoteId}"; return note; })); } } // ring else if (id != 801 && fields?.Length >= 4 && fields[3] == "Ring") // 801 = wedding ring, which isn't an equippable ring { yield return(this.TryCreate(ItemType.Ring, id, () => new Ring(id))); } // item else { // spawn main item SObject item = null; yield return(this.TryCreate(ItemType.Object, id, () => { return item = (id == 812 // roe ? new ColoredObject(id, 1, Color.White) : new SObject(id, 1) ); })); if (item == null) { continue; } // flavored items switch (item.Category) { // fruit products case SObject.FruitsCategory: // wine yield return(this.TryCreate(ItemType.Object, this.CustomIDOffset * 2 + id, () => new SObject(348, 1) { Name = $"{item.Name} Wine", Price = item.Price * 3, preserve = { SObject.PreserveType.Wine }, preservedParentSheetIndex = { item.ParentSheetIndex } })); // jelly yield return(this.TryCreate(ItemType.Object, this.CustomIDOffset * 3 + id, () => new SObject(344, 1) { Name = $"{item.Name} Jelly", Price = 50 + item.Price * 2, preserve = { SObject.PreserveType.Jelly }, preservedParentSheetIndex = { item.ParentSheetIndex } })); break; // vegetable products case SObject.VegetableCategory: // juice yield return(this.TryCreate(ItemType.Object, this.CustomIDOffset * 4 + id, () => new SObject(350, 1) { Name = $"{item.Name} Juice", Price = (int)(item.Price * 2.25d), preserve = { SObject.PreserveType.Juice }, preservedParentSheetIndex = { item.ParentSheetIndex } })); // pickled yield return(this.TryCreate(ItemType.Object, this.CustomIDOffset * 5 + id, () => new SObject(342, 1) { Name = $"Pickled {item.Name}", Price = 50 + item.Price * 2, preserve = { SObject.PreserveType.Pickle }, preservedParentSheetIndex = { item.ParentSheetIndex } })); break; // flower honey case SObject.flowersCategory: yield return(this.TryCreate(ItemType.Object, this.CustomIDOffset * 5 + id, () => { SObject honey = new SObject(Vector2.Zero, 340, $"{item.Name} Honey", false, true, false, false) { Name = $"{item.Name} Honey", preservedParentSheetIndex = { item.ParentSheetIndex } }; honey.Price += item.Price * 2; return honey; })); break; // roe and aged roe (derived from FishPond.GetFishProduce) case SObject.sellAtFishShopCategory when id == 812: foreach (var pair in Game1.objectInformation) { // get input SObject input = this.TryCreate(ItemType.Object, -1, () => new SObject(pair.Key, 1))?.Item as SObject; if (input == null || input.Category != SObject.FishCategory) { continue; } Color color = TailoringMenu.GetDyeColor(input) ?? Color.Orange; // yield roe SObject roe = null; yield return(this.TryCreate(ItemType.Object, this.CustomIDOffset * 7 + id, () => { roe = new ColoredObject(812, 1, color) { name = $"{input.Name} Roe", preserve = { Value = SObject.PreserveType.Roe }, preservedParentSheetIndex = { Value = input.ParentSheetIndex } }; roe.Price += input.Price / 2; return roe; })); // aged roe if (roe != null && pair.Key != 698) // aged sturgeon roe is caviar, which is a separate item { yield return(this.TryCreate(ItemType.Object, this.CustomIDOffset * 7 + id, () => new ColoredObject(447, 1, color) { name = $"Aged {input.Name} Roe", Category = -27, preserve = { Value = SObject.PreserveType.AgedRoe }, preservedParentSheetIndex = { Value = input.ParentSheetIndex }, Price = roe.Price * 2 })); } } break; } } } } return(GetAllRaw().Where(p => p != null)); }
private void GameLoop_DayStarted(object sender, DayStartedEventArgs e) { if (!Game1.player.IsMainPlayer) { if (!this.HasLoggedMultiplayerMessage) { this.Monitor.Log("Not main player, so no color changes will be attempted", LogLevel.Debug); this.HasLoggedMultiplayerMessage = true; } return; } // Because we need to account for the possibility of previously animated ponds being no longer animated due to population changes // (or no longer existing) and we are rescanning all ponds anyway, I am just gonna clear the Active Animations list every morning. Instance.ActiveAnimations.Clear(); IEnumerable <BuildableGameLocation> BuildableLocations = from loc in Game1.locations where loc is BuildableGameLocation select loc as BuildableGameLocation; foreach (BuildableGameLocation bloc in BuildableLocations) { IEnumerable <FishPond> FishPonds = from b in bloc.buildings where b is FishPond select b as FishPond; foreach (FishPond pond in FishPonds) { bool pondHasCustomColor = false; this.Monitor.Log($"Checking pond at {pond.tileX}, {pond.tileY}.", LogLevel.Trace); if (Config.Enable_Custom_Pond_Coloring) { if (pond.fishType == -1 && Data.EmptyPondColor != null) { pond.overrideWaterColor.Value = Data.EmptyPondColor; this.Monitor.Log($"Pond is empty and was recolored", LogLevel.Trace); break; } foreach (PondPainterDataEntry entry in Data.Entries) { bool match = true; //this.Monitor.Log($"Comparing with entry {entry.LogName}", LogLevel.Trace); foreach (string t in entry.Tags) { /* For now we are removing the capability to set a default color until I find a better * way to do it. * if (t.Equals("pp_default")) * { * // pp_default trumps all other tags and immediately sets the color * // I need a better way to do this, possibly moving it to a config instead of per pack. * ChangePondColor(pond, entry); * match = false; * break; * } * //*/ SObject pondFish = new SObject(pond.fishType.Value, 1, false, -1, 0); if (!pondFish.HasContextTag(t)) { match = false; } } if (match) { pondHasCustomColor = true; this.Monitor.Log($"Found a match on entry {entry.LogName} with tags {String.Join(", ", entry.Tags)}.", LogLevel.Trace); ChangePondColor(pond, entry); break; } } } if (Config.Auto_Color_Other_Ponds_by_Dye_Color_of_Inhabitants && !pondHasCustomColor) { if (pond.FishCount > 0 && pond.FishCount >= Config.Minimum_Population_For_Auto_Coloring) { // Copying similar logic to how the roe is colored, but convert // White to nearest color Snow since White means no override to the game Color?c = TailoringMenu.GetDyeColor(pond.GetFishObject()); Color?white = new Color?(Color.White); if (c.HasValue) { if (c.Equals(white)) { c = new Color?(Color.Snow); } } else { c = white; } pond.overrideWaterColor.Value = c.Value; } } } } this.Monitor.Log($"Finished Day Update. There are {Instance.ActiveAnimations.Count} active animations.", LogLevel.Trace); }
public IEnumerable <SearchableItem> GetAll() { IEnumerable <SearchableItem> GetAllRaw() { // get tools for (int quality = Tool.stone; quality <= Tool.iridium; quality++) { yield return(this.TryCreate(ItemType.Tool, ToolFactory.axe, () => ToolFactory.getToolFromDescription(ToolFactory.axe, quality))); yield return(this.TryCreate(ItemType.Tool, ToolFactory.hoe, () => ToolFactory.getToolFromDescription(ToolFactory.hoe, quality))); yield return(this.TryCreate(ItemType.Tool, ToolFactory.pickAxe, () => ToolFactory.getToolFromDescription(ToolFactory.pickAxe, quality))); yield return(this.TryCreate(ItemType.Tool, ToolFactory.wateringCan, () => ToolFactory.getToolFromDescription(ToolFactory.wateringCan, quality))); if (quality != Tool.iridium) { yield return(this.TryCreate(ItemType.Tool, ToolFactory.fishingRod, () => ToolFactory.getToolFromDescription(ToolFactory.fishingRod, quality))); } } yield return(this.TryCreate(ItemType.Tool, this.CustomIDOffset, () => new MilkPail())); // these don't have any sort of ID, so we'll just assign some arbitrary ones yield return(this.TryCreate(ItemType.Tool, this.CustomIDOffset + 1, () => new Shears())); yield return(this.TryCreate(ItemType.Tool, this.CustomIDOffset + 2, () => new Pan())); yield return(this.TryCreate(ItemType.Tool, this.CustomIDOffset + 3, () => new Wand())); // clothing foreach (int id in Game1.clothingInformation.Keys) { yield return(this.TryCreate(ItemType.Clothing, id, () => new Clothing(id))); } // wallpapers for (int id = 0; id < 112; id++) { yield return(this.TryCreate(ItemType.Wallpaper, id, () => new Wallpaper(id) { Category = SObject.furnitureCategory })); } // flooring for (int id = 0; id < 40; id++) { yield return(this.TryCreate(ItemType.Flooring, id, () => new Wallpaper(id, isFloor: true) { Category = SObject.furnitureCategory })); } // equipment foreach (int id in Game1.content.Load <Dictionary <int, string> >("Data\\Boots").Keys) { yield return(this.TryCreate(ItemType.Boots, id, () => new Boots(id))); } foreach (int id in Game1.content.Load <Dictionary <int, string> >("Data\\hats").Keys) { yield return(this.TryCreate(ItemType.Hat, id, () => new Hat(id))); } foreach (int id in Game1.objectInformation.Keys) { if (id >= Ring.ringLowerIndexRange && id <= Ring.ringUpperIndexRange) { yield return(this.TryCreate(ItemType.Ring, id, () => new Ring(id))); } } // weapons foreach (int id in Game1.content.Load <Dictionary <int, string> >("Data\\weapons").Keys) { Item weapon = (id >= 32 && id <= 34) ? (Item) new Slingshot(id) : new MeleeWeapon(id); yield return(this.TryCreate(ItemType.Weapon, id, () => weapon)); } // furniture foreach (int id in Game1.content.Load <Dictionary <int, string> >("Data\\Furniture").Keys) { if (id == 1466 || id == 1468) { yield return(this.TryCreate(ItemType.Furniture, id, () => new TV(id, Vector2.Zero))); } else { yield return(this.TryCreate(ItemType.Furniture, id, () => new Furniture(id, Vector2.Zero))); } } // craftables foreach (int id in Game1.bigCraftablesInformation.Keys) { yield return(this.TryCreate(ItemType.BigCraftable, id, () => new SObject(Vector2.Zero, id))); } // secret notes foreach (int id in Game1.content.Load <Dictionary <int, string> >("Data\\SecretNotes").Keys) { SObject note = new SObject(79, 1); note.name = $"{note.name} #{id}"; yield return(this.TryCreate(ItemType.Object, this.CustomIDOffset + id, () => note)); } // objects foreach (int id in Game1.objectInformation.Keys) { if (id == 79) { continue; // secret note handled above } if (id >= Ring.ringLowerIndexRange && id <= Ring.ringUpperIndexRange) { continue; // handled separated } // spawn main item SObject item = id == 812 ? new ColoredObject(id, 1, Color.White) : new SObject(id, 1); yield return(this.TryCreate(ItemType.Object, id, () => item)); // fruit products if (item.Category == SObject.FruitsCategory) { // wine SObject wine = new SObject(348, 1) { Name = $"{item.Name} Wine", Price = item.Price * 3 }; wine.preserve.Value = SObject.PreserveType.Wine; wine.preservedParentSheetIndex.Value = item.ParentSheetIndex; yield return(this.TryCreate(ItemType.Object, this.CustomIDOffset * 2 + id, () => wine)); // jelly SObject jelly = new SObject(344, 1) { Name = $"{item.Name} Jelly", Price = 50 + item.Price * 2 }; jelly.preserve.Value = SObject.PreserveType.Jelly; jelly.preservedParentSheetIndex.Value = item.ParentSheetIndex; yield return(this.TryCreate(ItemType.Object, this.CustomIDOffset * 3 + id, () => jelly)); } // vegetable products else if (item.Category == SObject.VegetableCategory) { // juice SObject juice = new SObject(350, 1) { Name = $"{item.Name} Juice", Price = (int)(item.Price * 2.25d) }; juice.preserve.Value = SObject.PreserveType.Juice; juice.preservedParentSheetIndex.Value = item.ParentSheetIndex; yield return(this.TryCreate(ItemType.Object, this.CustomIDOffset * 4 + id, () => juice)); // pickled SObject pickled = new SObject(342, 1) { Name = $"Pickled {item.Name}", Price = 50 + item.Price * 2 }; pickled.preserve.Value = SObject.PreserveType.Pickle; pickled.preservedParentSheetIndex.Value = item.ParentSheetIndex; yield return(this.TryCreate(ItemType.Object, this.CustomIDOffset * 5 + id, () => pickled)); } // flower honey else if (item.Category == SObject.flowersCategory) { SObject honey = new SObject(Vector2.Zero, 340, item.Name + " Honey", false, true, false, false) { Name = $"{item.Name} Honey", preservedParentSheetIndex = { item.ParentSheetIndex } }; honey.Price += item.Price * 2; yield return(this.TryCreate(ItemType.Object, this.CustomIDOffset * 6 + id, () => honey)); } // roe and aged roe (derived from FishPond.GetFishProduce) else if (id == 812) { foreach (var pair in Game1.objectInformation) { // get input SObject input = new SObject(pair.Key, 1); if (input.Category != SObject.FishCategory) { continue; } Color color = TailoringMenu.GetDyeColor(input) ?? Color.Orange; // yield roe SObject roe = new ColoredObject(812, 1, color) { name = $"{input.Name} Roe", preserve = { Value = SObject.PreserveType.Roe }, preservedParentSheetIndex = { Value = input.ParentSheetIndex } }; roe.Price += input.Price / 2; yield return(this.TryCreate(ItemType.Object, this.CustomIDOffset * 6 + 1, () => roe)); // aged roe if (pair.Key != 698) // aged sturgeon roe is caviar, which is a separate item { yield return(this.TryCreate(ItemType.Object, this.CustomIDOffset * 6 + 1, () => new ColoredObject(447, 1, color) { name = $"Aged {input.Name} Roe", Category = -27, preserve = { Value = SObject.PreserveType.AgedRoe }, preservedParentSheetIndex = { Value = input.ParentSheetIndex }, Price = roe.Price * 2 } )); } } } } } return(GetAllRaw().Where(p => p != null)); }