Add exclusion for one-time DIY indexes

Closes #523
Thanks @Zelfild for identifying the problematic indexes!

Skips over these two indexes on give-all, and skips over them when spawning a set of DIY items onto the ground.
Added control-key to set all IsNew to false instead of true (when doing GiveAll)
This commit is contained in:
Kurt
2021-11-06 13:16:52 -07:00
parent f33620e37c
commit 3e7bacb80b
4 changed files with 9 additions and 4 deletions

View File

@@ -26,18 +26,20 @@ public class RecipeBook
public bool GetIsFavorite(int recipe) => FlagUtil.GetFlag(Data, 3 * BitFlagArraySize, recipe);
public void SetIsFavorite(int recipe, bool value = true) => FlagUtil.SetFlag(Data, 3 * BitFlagArraySize, recipe, value);
public void GiveAll(IReadOnlyDictionary<ushort,ushort> recipes)
public void GiveAll(IReadOnlyDictionary<ushort,ushort> recipes, bool isNew = true)
{
foreach (var entry in recipes)
{
var index = entry.Key;
if (index is RecipeList.BridgeConstructionKit or RecipeList.CampsiteConstructionKit)
continue;
bool alreadyHave = GetIsKnown(index);
if (alreadyHave)
continue;
SetIsKnown(index);
SetIsNew(index);
SetIsNew(index, isNew);
}
}

View File

@@ -4,6 +4,9 @@ namespace NHSE.Core
{
public static class RecipeList
{
public const int BridgeConstructionKit = 0x1CA;
public const int CampsiteConstructionKit = 0x1CD;
public static readonly IReadOnlyDictionary<ushort, ushort> Recipes = new Dictionary<ushort, ushort>
{
{0x006, 02596}, // juicy-apple TV

View File

@@ -44,7 +44,7 @@ private void B_Apply_Click(object sender, EventArgs e)
var min = (ushort)NUD_DIYStart.Value;
var max = (ushort)NUD_DIYStop.Value;
var diy = RecipeList.Recipes
.Where(z => min <= z.Key && z.Key <= max)
.Where(z => z.Key is not RecipeList.BridgeConstructionKit or RecipeList.CampsiteConstructionKit && min <= z.Key && z.Key <= max)
.Select(z => z.Key)
.Select(z => new Item(Item.DIYRecipe) {FreeParam = z});

View File

@@ -76,7 +76,7 @@ private static object GetEntryText(RecipeBook recipeBook, ushort index, string i
return $"0x{index:X3} - {known} {item}";
}
private void B_All_Click(object sender, EventArgs e) => DoAll(() => Book.GiveAll(RecipeList.Recipes));
private void B_All_Click(object sender, EventArgs e) => DoAll(() => Book.GiveAll(RecipeList.Recipes, ModifierKeys != Keys.Control));
private void B_ClearAll_Click(object sender, EventArgs e) => DoAll(Book.ClearAll);
private void B_CraftAll_Click(object sender, EventArgs e) => DoAll(Book.CraftAll);