update item spawning code, detect ring type automatically to support custom rings, minor refactor
This commit is contained in:
parent
05d237400c
commit
139e267aaa
|
@ -8,6 +8,11 @@
|
|||
* Updated for the 'Force Off' gamepad mode added in Stardew Valley 1.4.1.
|
||||
* Fixed compatibility with Linux Mint 18 (thanks to techge!) and Arch Linux.
|
||||
* Fixed compatibility with Linux systems which have libhybris-utils installed.
|
||||
* Fixes for the bundled Console Commands mod:
|
||||
* added new clothing items;
|
||||
* fixed spawning new flooring and rings (thanks to Mizzion!);
|
||||
* fixed spawning custom rings added by mods;
|
||||
* Fixed errors when some item data is invalid.
|
||||
* Internal optimizations.
|
||||
* Updated translations. Thanks to PlussRolf (added Spanish)!
|
||||
|
||||
|
|
|
@ -46,6 +46,10 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework
|
|||
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 });
|
||||
|
@ -59,11 +63,6 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework
|
|||
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) || (id >= 810 && id <= 811))
|
||||
yield return this.TryCreate(ItemType.Ring, id, () => new Ring(id));
|
||||
}
|
||||
|
||||
// weapons
|
||||
foreach (int id in Game1.content.Load<Dictionary<int, string>>("Data\\weapons").Keys)
|
||||
|
@ -87,101 +86,91 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework
|
|||
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)
|
||||
{
|
||||
yield return this.TryCreate(ItemType.Object, this.CustomIDOffset + id, () =>
|
||||
{
|
||||
SObject note = new SObject(79, 1);
|
||||
note.name = $"{note.name} #{id}";
|
||||
return note;
|
||||
});
|
||||
}
|
||||
|
||||
// objects
|
||||
foreach (int id in Game1.objectInformation.Keys)
|
||||
{
|
||||
if (id == 79)
|
||||
continue; // secret note handled above
|
||||
if ((id >= Ring.ringLowerIndexRange && id <= Ring.ringUpperIndexRange) || (id >= 810 && id <= 811))
|
||||
continue; // handled separated
|
||||
string[] fields = Game1.objectInformation[id]?.Split('/');
|
||||
|
||||
// spawn main item
|
||||
SObject item;
|
||||
// secret notes
|
||||
if (id == 79)
|
||||
{
|
||||
SearchableItem main = this.TryCreate(ItemType.Object, id, () => id == 812
|
||||
foreach (int secretNoteId in Game1.content.Load<Dictionary<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)
|
||||
);
|
||||
yield return main;
|
||||
item = main?.Item as SObject;
|
||||
}
|
||||
});
|
||||
if (item == null)
|
||||
continue;
|
||||
|
||||
// flavored items
|
||||
switch (item.Category)
|
||||
{
|
||||
// fruit products
|
||||
if (item.Category == SObject.FruitsCategory)
|
||||
{
|
||||
case SObject.FruitsCategory:
|
||||
// wine
|
||||
yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 2 + id, () =>
|
||||
{
|
||||
SObject wine = new SObject(348, 1)
|
||||
yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 2 + id, () => new SObject(348, 1)
|
||||
{
|
||||
Name = $"{item.Name} Wine",
|
||||
Price = item.Price * 3
|
||||
};
|
||||
wine.preserve.Value = SObject.PreserveType.Wine;
|
||||
wine.preservedParentSheetIndex.Value = item.ParentSheetIndex;
|
||||
return wine;
|
||||
Price = item.Price * 3,
|
||||
preserve = { SObject.PreserveType.Wine },
|
||||
preservedParentSheetIndex = { item.ParentSheetIndex }
|
||||
});
|
||||
|
||||
// jelly
|
||||
yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 3 + id, () =>
|
||||
{
|
||||
SObject jelly = new SObject(344, 1)
|
||||
yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 3 + id, () => new SObject(344, 1)
|
||||
{
|
||||
Name = $"{item.Name} Jelly",
|
||||
Price = 50 + item.Price * 2
|
||||
};
|
||||
jelly.preserve.Value = SObject.PreserveType.Jelly;
|
||||
jelly.preservedParentSheetIndex.Value = item.ParentSheetIndex;
|
||||
return jelly;
|
||||
Price = 50 + item.Price * 2,
|
||||
preserve = { SObject.PreserveType.Jelly },
|
||||
preservedParentSheetIndex = { item.ParentSheetIndex }
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
// vegetable products
|
||||
else if (item.Category == SObject.VegetableCategory)
|
||||
{
|
||||
case SObject.VegetableCategory:
|
||||
// juice
|
||||
yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 4 + id, () =>
|
||||
{
|
||||
SObject juice = new SObject(350, 1)
|
||||
yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 4 + id, () => 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;
|
||||
return 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, () =>
|
||||
{
|
||||
SObject pickled = new SObject(342, 1)
|
||||
yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 5 + id, () => new SObject(342, 1)
|
||||
{
|
||||
Name = $"Pickled {item.Name}",
|
||||
Price = 50 + item.Price * 2
|
||||
};
|
||||
pickled.preserve.Value = SObject.PreserveType.Pickle;
|
||||
pickled.preservedParentSheetIndex.Value = item.ParentSheetIndex;
|
||||
return pickled;
|
||||
Price = 50 + item.Price * 2,
|
||||
preserve = { SObject.PreserveType.Pickle },
|
||||
preservedParentSheetIndex = { item.ParentSheetIndex }
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
// flower honey
|
||||
else if (item.Category == SObject.flowersCategory)
|
||||
{
|
||||
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)
|
||||
|
@ -192,43 +181,47 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework
|
|||
honey.Price += item.Price * 2;
|
||||
return honey;
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
// roe and aged roe (derived from FishPond.GetFishProduce)
|
||||
else if (id == 812)
|
||||
{
|
||||
case SObject.sellAtFishShopCategory when id == 812:
|
||||
foreach (var pair in Game1.objectInformation)
|
||||
{
|
||||
// get input
|
||||
SObject input = new SObject(pair.Key, 1);
|
||||
if (input.Category != SObject.FishCategory)
|
||||
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 = new ColoredObject(812, 1, color)
|
||||
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;
|
||||
yield return new SearchableItem(ItemType.Object, this.CustomIDOffset * 6 + 1, roe);
|
||||
return roe;
|
||||
});
|
||||
|
||||
// aged roe
|
||||
if (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
|
||||
{
|
||||
ColoredObject agedRoe = 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",
|
||||
Category = -27,
|
||||
preserve = { Value = SObject.PreserveType.AgedRoe },
|
||||
preservedParentSheetIndex = { Value = input.ParentSheetIndex },
|
||||
Price = roe.Price * 2
|
||||
};
|
||||
yield return new SearchableItem(ItemType.Object, this.CustomIDOffset * 6 + 1, agedRoe);
|
||||
});
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue