move item repo secret note + flavored object logic into methods
This commit is contained in:
parent
bca9e599cc
commit
6b9c9be2b6
|
@ -139,15 +139,8 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework
|
||||||
{
|
{
|
||||||
if (ShouldGet(ItemType.Object))
|
if (ShouldGet(ItemType.Object))
|
||||||
{
|
{
|
||||||
foreach (int secretNoteId in this.TryLoad<int, string>("Data\\SecretNotes").Keys)
|
foreach (SearchableItem secretNote in this.GetSecretNotes())
|
||||||
{
|
yield return secretNote;
|
||||||
yield return this.TryCreate(ItemType.Object, this.CustomIDOffset + secretNoteId, _ =>
|
|
||||||
{
|
|
||||||
SObject note = new SObject(79, 1);
|
|
||||||
note.name = $"{note.name} #{secretNoteId}";
|
|
||||||
return note;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,58 +169,94 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework
|
||||||
// flavored items
|
// flavored items
|
||||||
if (includeVariants)
|
if (includeVariants)
|
||||||
{
|
{
|
||||||
|
foreach (SearchableItem variant in this.GetFlavoredObjectVariants(item))
|
||||||
|
yield return variant;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return GetAllRaw().Where(p => p != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*********
|
||||||
|
** Private methods
|
||||||
|
*********/
|
||||||
|
/// <summary>Get the individual secret note items, if any.</summary>
|
||||||
|
/// <remarks>Derived from <see cref="GameLocation.tryToCreateUnseenSecretNote"/>.</remarks>
|
||||||
|
private IEnumerable<SearchableItem> GetSecretNotes()
|
||||||
|
{
|
||||||
|
foreach (int secretNoteId in this.TryLoad<int, string>("Data\\SecretNotes").Keys)
|
||||||
|
{
|
||||||
|
yield return this.TryCreate(ItemType.Object, this.CustomIDOffset + secretNoteId, _ =>
|
||||||
|
{
|
||||||
|
SObject note = new(79, 1);
|
||||||
|
note.name = $"{note.name} #{secretNoteId}";
|
||||||
|
return note;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Get flavored variants of a base item (like Blueberry Wine for Blueberry), if any.</summary>
|
||||||
|
/// <param name="item">A sample of the base item.</param>
|
||||||
|
private IEnumerable<SearchableItem> GetFlavoredObjectVariants(SObject item)
|
||||||
|
{
|
||||||
|
int id = item.ParentSheetIndex;
|
||||||
|
|
||||||
switch (item.Category)
|
switch (item.Category)
|
||||||
{
|
{
|
||||||
// fruit products
|
// fruit products
|
||||||
case SObject.FruitsCategory:
|
case SObject.FruitsCategory:
|
||||||
// wine
|
// wine
|
||||||
yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 2 + item.ParentSheetIndex, _ => new SObject(348, 1)
|
yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 2 + id, _ => new SObject(348, 1)
|
||||||
{
|
{
|
||||||
Name = $"{item.Name} Wine",
|
Name = $"{item.Name} Wine",
|
||||||
Price = item.Price * 3,
|
Price = item.Price * 3,
|
||||||
preserve = { SObject.PreserveType.Wine },
|
preserve = { SObject.PreserveType.Wine },
|
||||||
preservedParentSheetIndex = { item.ParentSheetIndex }
|
preservedParentSheetIndex = { id }
|
||||||
});
|
});
|
||||||
|
|
||||||
// jelly
|
// jelly
|
||||||
yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 3 + item.ParentSheetIndex, _ => new SObject(344, 1)
|
yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 3 + id, _ => new SObject(344, 1)
|
||||||
{
|
{
|
||||||
Name = $"{item.Name} Jelly",
|
Name = $"{item.Name} Jelly",
|
||||||
Price = 50 + item.Price * 2,
|
Price = 50 + item.Price * 2,
|
||||||
preserve = { SObject.PreserveType.Jelly },
|
preserve = { SObject.PreserveType.Jelly },
|
||||||
preservedParentSheetIndex = { item.ParentSheetIndex }
|
preservedParentSheetIndex = { id }
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// vegetable products
|
// vegetable products
|
||||||
case SObject.VegetableCategory:
|
case SObject.VegetableCategory:
|
||||||
// juice
|
// juice
|
||||||
yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 4 + item.ParentSheetIndex, _ => new SObject(350, 1)
|
yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 4 + id, _ => new SObject(350, 1)
|
||||||
{
|
{
|
||||||
Name = $"{item.Name} Juice",
|
Name = $"{item.Name} Juice",
|
||||||
Price = (int)(item.Price * 2.25d),
|
Price = (int)(item.Price * 2.25d),
|
||||||
preserve = { SObject.PreserveType.Juice },
|
preserve = { SObject.PreserveType.Juice },
|
||||||
preservedParentSheetIndex = { item.ParentSheetIndex }
|
preservedParentSheetIndex = { id }
|
||||||
});
|
});
|
||||||
|
|
||||||
// pickled
|
// pickled
|
||||||
yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 5 + item.ParentSheetIndex, _ => new SObject(342, 1)
|
yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 5 + id, _ => new SObject(342, 1)
|
||||||
{
|
{
|
||||||
Name = $"Pickled {item.Name}",
|
Name = $"Pickled {item.Name}",
|
||||||
Price = 50 + item.Price * 2,
|
Price = 50 + item.Price * 2,
|
||||||
preserve = { SObject.PreserveType.Pickle },
|
preserve = { SObject.PreserveType.Pickle },
|
||||||
preservedParentSheetIndex = { item.ParentSheetIndex }
|
preservedParentSheetIndex = { id }
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// flower honey
|
// flower honey
|
||||||
case SObject.flowersCategory:
|
case SObject.flowersCategory:
|
||||||
yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 5 + item.ParentSheetIndex, _ =>
|
yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 5 + id, _ =>
|
||||||
{
|
{
|
||||||
SObject honey = new SObject(Vector2.Zero, 340, $"{item.Name} Honey", false, true, false, false)
|
SObject honey = new SObject(Vector2.Zero, 340, $"{item.Name} Honey", false, true, false, false)
|
||||||
{
|
{
|
||||||
Name = $"{item.Name} Honey",
|
Name = $"{item.Name} Honey",
|
||||||
preservedParentSheetIndex = { item.ParentSheetIndex }
|
preservedParentSheetIndex = { id }
|
||||||
};
|
};
|
||||||
honey.Price += item.Price * 2;
|
honey.Price += item.Price * 2;
|
||||||
return honey;
|
return honey;
|
||||||
|
@ -235,7 +264,7 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// roe and aged roe (derived from FishPond.GetFishProduce)
|
// roe and aged roe (derived from FishPond.GetFishProduce)
|
||||||
case SObject.sellAtFishShopCategory when item.ParentSheetIndex == 812:
|
case SObject.sellAtFishShopCategory when id == 812:
|
||||||
{
|
{
|
||||||
this.GetRoeContextTagLookups(out HashSet<string> simpleTags, out List<List<string>> complexTags);
|
this.GetRoeContextTagLookups(out HashSet<string> simpleTags, out List<List<string>> complexTags);
|
||||||
|
|
||||||
|
@ -254,7 +283,7 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework
|
||||||
// yield roe
|
// yield roe
|
||||||
SObject roe = null;
|
SObject roe = null;
|
||||||
Color color = this.GetRoeColor(input);
|
Color color = this.GetRoeColor(input);
|
||||||
yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 7 + item.ParentSheetIndex, _ =>
|
yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 7 + id, _ =>
|
||||||
{
|
{
|
||||||
roe = new ColoredObject(812, 1, color)
|
roe = new ColoredObject(812, 1, color)
|
||||||
{
|
{
|
||||||
|
@ -269,7 +298,7 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework
|
||||||
// aged roe
|
// aged roe
|
||||||
if (roe != null && pair.Key != 698) // aged sturgeon roe is caviar, which is a separate item
|
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 + item.ParentSheetIndex, _ => new ColoredObject(447, 1, color)
|
yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 7 + id, _ => new ColoredObject(447, 1, color)
|
||||||
{
|
{
|
||||||
name = $"Aged {input.Name} Roe",
|
name = $"Aged {input.Name} Roe",
|
||||||
Category = -27,
|
Category = -27,
|
||||||
|
@ -283,18 +312,7 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return GetAllRaw().Where(p => p != null);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*********
|
|
||||||
** Private methods
|
|
||||||
*********/
|
|
||||||
/// <summary>Get optimized lookups to match items which produce roe in a fish pond.</summary>
|
/// <summary>Get optimized lookups to match items which produce roe in a fish pond.</summary>
|
||||||
/// <param name="simpleTags">A lookup of simple singular tags which match a roe-producing fish.</param>
|
/// <param name="simpleTags">A lookup of simple singular tags which match a roe-producing fish.</param>
|
||||||
/// <param name="complexTags">A list of tag sets which match roe-producing fish.</param>
|
/// <param name="complexTags">A list of tag sets which match roe-producing fish.</param>
|
||||||
|
|
Loading…
Reference in New Issue