Skip to content
This repository was archived by the owner on Jul 1, 2022. It is now read-only.

Commit e1d2b9f

Browse files
committed
Distinct comparer now also looks at display name
1 parent f471522 commit e1d2b9f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Shop expander provides some functions through `Mod.Call` that you can use in you
3636
| --- | --- |
3737
| `Mod.Call("SetProvisionSize", object obj, int size);` | Returns `null`. `obj` should be an instance of `ModNPC` or `GlobalNPC`. Changes the size of the inventory given to `obj` to `size`. The default value is `40`. |
3838
| `Mod.Call("SetModifier", object obj);` | Returns `null`. `obj` should be an instance of `GlobalNPC`. Specifies, that `obj` wishes to modify existing items in a shop and won't add any new ones. `obj.SetupShop` will only be called once every other non-modifier object is processed. Instead of a new empty inventory, it will receive the full contents of the Extended shop. `nextSlot` will be set to the length of this shop.
39-
| `Mod.Call("SetNoDistinct", object obj);` | Returns `null`. `obj` should be an instance of `ModNPC` or `GlobalNPC`. Every item provided by `obj` will be added to the Expanded shop, even if it already contains one of the same type. This may be useful, if a mod wishes to add items to a shop that have the same type, but different `ModItem` extra data.
39+
| `Mod.Call("SetNoDistinct", object obj);` | Returns `null`. `obj` should be an instance of `ModNPC` or `GlobalNPC`. Every item provided by `obj` will be added to the Expanded shop, even if it already contains one of the same type and display name. This may be useful, if a mod wishes to add items to a shop that have the same type, but different `ModItem` extra data.
4040
| `Mod.Call("GetLastShopExpanded");` | Returns the full contents of the last opened shop as an `Item[]`. May return `null` if no shop has been opened yet. |
4141

4242
You can see an example of these in [SillyDaftMod](SillyDaftMod/SillyDaftMod.cs). If you wish to add or modify items in the open shop outside of `SetupShop`, add Shop Expander as reference and use the members of `ShopExpander.Instance.LastShopExpanded`.

ShopExpander/ShoppingList.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ private class ItemSameType : IEqualityComparer<Item>
2626
{
2727
public bool Equals(Item x, Item y)
2828
{
29-
return x.type == y.type;
29+
return x.Name == y.Name && x.type == y.type;
3030
}
3131

3232
public int GetHashCode(Item obj)
3333
{
34-
return obj.type;
34+
return obj.Name.GetHashCode() ^ obj.type;
3535
}
3636
}
3737

0 commit comments

Comments
 (0)