Shops

This is the full list of what the API gives you.

BaseShops the static class for base shops

Use All to list the shops in the scene, SetMoney and Restock to change a shop, and Buy and Sell to trade furniture with one.

public static class BaseShops
{
    public static List<BaseShopInfo> All();
    public static bool SetMoney(string id, int oc, int rm);
    public static bool Restock(string id);
    public static BaseShopBuyResult Buy(string id, string furnitureId, int count);
    public static BaseShopSellResult Sell(string id, string furnitureId, int count);
    public static event Action<BaseShopBoughtArgs> Bought;
    public static event Action<BaseShopSoldArgs> Sold;
}
Method Returns What it does
All() List<BaseShopInfo> Every shop in the scene you are in.
SetMoney(id, oc, rm) bool Sets how much money the shop holds. true when it was set.
Restock(id) bool Makes the shop restock now. true when it was told to.
Buy(id, furnitureId, count) BaseShopBuyResult Buys furniture from a shop for the player. See Buying.
Sell(id, furnitureId, count) BaseShopSellResult Sells furniture from the player to a shop. See Selling.
Event Gives you When it fires
Bought BaseShopBoughtArgs The player bought furniture through Buy.
Sold BaseShopSoldArgs The player sold furniture through Sell.

BaseShopInfo a snapshot of one shop

All gives you one of these for each shop. Pass its Id to the other calls.

public sealed class BaseShopInfo
{
    public string Id { get; }
    public string Kind { get; }
    public int Oc { get; }
    public int Rm { get; }
    public bool RestockDaily { get; }
}
Property Type What it means
Id string The shop’s id. Pass it to the other calls.
Kind string The type of shop, such as FurnitureShop or TrainShop.
Oc int How many OC the shop holds.
Rm int How many RM the shop holds.
RestockDaily bool true when the shop restocks every day. false when it restocks on a timer.

Things to know

  • All() lists the shops that are switched on in the scene you are in. A shop in another scene, or one the game has hidden, is not listed. With no save loaded you get an empty list. (It searches the active objects of the active scene for BaseShop. Kind is the C# type name.)
  • A shop id is a piece of text that names one shop. All() gives it to you, and it is stable as long as the scene does not change. A null or empty id finds nothing. (The id is the shop’s save GUID when it has one, otherwise its scene path.)
  • SetMoney(id, oc, rm) sets how much money the shop holds. The shop pays the player out of this money when it buys furniture, so the new amounts limit what it can pay.
  • SetMoney returns false for a negative amount, for an unknown shop, and while a save is loading or being written. A shop screen that is already open can show the old amounts until it refreshes. (It writes currentOcMoney and currentRmMoney directly, because the game has no setter. The sale checks read those fields.)
  • Restock(id) makes the shop restock now. It draws new amounts of money for the shop and refreshes its stock.
  • Restock does not reset the shop’s restock timer, so the next restock the game planned still happens when it was planned. It returns false for an unknown shop and while a save is loading or being written. (It calls the game’s Restock(), which draws new OC and RM amounts in the shop’s ranges and then calls UpdateShopItems(), which a subclass overrides. timeToRestock and restockedDay keep their values. For a furniture shop this runs the framework’s furniture changes on UpdateShopItems.)
  • RestockDaily tells you when the shop restocks by itself. When it is true, the shop restocks at the start of each new day. Otherwise it restocks on its own timer, after a time chosen between its smallest and largest restock time. (The daily restock happens on the first minute tick of a new day. The timer runs between minRestockingTime and maxRestockingTime seconds.)
  • The list of what a shop has in stock belongs to each kind of shop, and furniture stock is on the furniture page. The price percentages and the stock amount ranges are not available. (Each subclass owns its stock list, for example FurnitureShop.availableFurnitures. The percentages are sellPercent and buyPercent.)