Class TimbnItems
Finds, gives, and drops items in the loaded save. At the main menu every count is zero and nothing moves.
public static class TimbnItems
- Inheritance
-
TimbnItems
- Inherited Members
Methods
CountAnywhere(string, int)
Counts an item everywhere in the world, meaning the player's inventory, every storage and craft inventory,
and every item lying on the ground or queued to drop. It stops looking once enough is
reached, so asking "is there at least this many" is cheap.
public static int CountAnywhere(string id, int enough = 2147483647)
Parameters
idstringThe item id.
enoughintThe count at which to stop looking. The default counts everything.
Returns
- int
The count found, which is at least
enoughif it stopped early.
Examples
var hasEnough = TimbnItems.CountAnywhere("flitch", 2) >= 2;
CountOnPlayer(string)
Counts an item in the player's inventory and bags. Storage in the world does not count.
public static int CountOnPlayer(string id)
Parameters
idstringThe item id.
Returns
- int
How many the player is carrying.
DropAt(Item, string, Vector3)
Drops an item on the ground as a pickup. Nothing happens at the main menu.
public static void DropAt(Item item, string sceneId, Vector3 position)
Parameters
itemItemThe item and how many.
sceneIdstringThe scene to drop in.
positionVector3Where to drop it.
FindDrops(Func<DropData, bool>, GameSceneData?)
Finds items lying on the ground as pickups, including ones queued to drop in a scene that is not loaded right now. Drops already being picked up or removed are skipped.
public static List<(GameSceneData Scene, DropData Drop)> FindDrops(Func<DropData, bool> match, GameSceneData? scene = null)
Parameters
matchFunc<DropData, bool>Which drops to keep, such as by their Id.
sceneGameSceneDataOnly look in this scene. Leave it out to look in every scene of the world.
Returns
- List<(GameSceneData Scene, DropData Drop)>
Each matching drop with the scene it lies in, which is what RemoveDrops(IEnumerable<(GameSceneData Scene, DropData Drop)>) takes.
Examples
Every log on the ground in the player's scene.
var logs = TimbnItems.FindDrops(drop => drop.Id == "wood", TimbnPlayer.Scene);
GiveToPlayer(Item)
Puts an item into the player's inventory and bags, and drops whatever does not fit in front of the player so nothing is lost. The overflow drops the way the game drops items, so a big stack splits into several pickups. An item the game won't drop that way, such as fuel, still lands as a single pickup.
public static int GiveToPlayer(Item item)
Parameters
itemItemThe item and how many.
Returns
- int
How many went into the player's inventory.
IconId(string)
The sprite id of an item's icon, the one its inventory cell shows, for anything that takes a sprite id, such as a quest's Icon.
public static string IconId(string id)
Parameters
idstringThe item id.
Returns
- string
The sprite id, or an empty string for an item the game doesn't have.
Examples
.Icon(run => TimbnItems.IconId(run.Item("dish")))
PlayerDropPosition()
The spot in front of the player where the game itself drops things, or the player's own position when that spot is blocked.
public static Vector3 PlayerDropPosition()
Returns
- Vector3
A position in the player's current scene, or zero at the main menu.
RemoveDrops(IEnumerable<(GameSceneData Scene, DropData Drop)>)
Removes drops found with FindDrops(Func<DropData, bool>, GameSceneData?) from the ground. The items are gone.
public static int RemoveDrops(IEnumerable<(GameSceneData Scene, DropData Drop)> drops)
Parameters
dropsIEnumerable<(GameSceneData Scene, DropData Drop)>The drops and the scenes they lie in.
Returns
- int
How many items were removed, counting each drop's stack.
SalePrice(string)
What one of an item sells for, the price the town pallets and the game's orders pay, in the game's raw money units where 100 is one silver coin.
public static int SalePrice(string id)
Parameters
idstringThe item id.
Returns
- int
The price, or 0 for an item the game doesn't have or sells for nothing.
Examples
var price = TimbnItems.SalePrice("cook_muffin");
TakeFromPlayer(string, int)
Removes an item from the player's inventory and bags, up to the count asked for. The items are gone, so check CountOnPlayer(string) first when the player has to have enough.
public static int TakeFromPlayer(string id, int count)
Parameters
Returns
- int
How many were taken, which is less than
countwhen the player had fewer.