Class Shop
Represents an in-game shop where items can be purchased. Provides high-level operations without exposing game types.
public sealed class Shop
- Inheritance
-
Shop
- Inherited Members
- Extension Methods
Properties
Name
The display name of this shop.
public string Name { get; }
Property Value
Methods
AddItem(ItemDefinition, float?)
Adds an item to this shop's inventory with automatic UI creation and event hookup. The item will appear in the shop's listing and be purchasable by the player.
public bool AddItem(ItemDefinition item, float? customPrice = null)
Parameters
itemItemDefinitionThe item definition to add to the shop.
customPricefloat?Optional custom price override. If null, uses item's BasePurchasePrice.
Returns
- bool
True if the item was added successfully, false if it already exists or addition failed.
Examples
var shop = ShopManager.GetShopByName("Hardware Store");
var customItem = ItemManager.GetItemDefinition("my_custom_tool");
shop.AddItem(customItem);
GetItemIds()
Gets all item IDs currently sold by this shop.
public string[] GetItemIds()
Returns
- string[]
Array of item IDs.
HasItem(string)
Checks if this shop currently sells an item with the specified ID.
public bool HasItem(string itemId)
Parameters
itemIdstringThe unique ID of the item to check.
Returns
- bool
True if the shop sells this item, false otherwise.
RemoveItem(string)
Removes an item from this shop's inventory.
public bool RemoveItem(string itemId)
Parameters
itemIdstringThe ID of the item to remove.
Returns
- bool
True if the item was removed, false if it wasn't found.
SellsCategory(ItemCategory)
Checks if this shop sells items in the specified category.
public bool SellsCategory(ItemCategory category)
Parameters
categoryItemCategoryThe item category to check.
Returns
- bool
True if the shop sells at least one item in this category.