Skip to main content

GymnasiumCraftingIngredientSpawner

A class in Root.Township, the global namespace.

Gymnasium test helper: docking a recipe page in one dock spawns that recipe's ingredients into a row of other docks.

Constructors​

MemberWhat it is
GymnasiumCraftingIngredientSpawner()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

4 private and internal fields
MemberWhat it is
private int dockCountNumber of ingredient docks, cached in Awake.
private NetworkEntity entityThe network entity on this object; its chunk is used for items that don't fit in a dock.
private PickupDock[] ingredientDocksDocks that the ingredients are spawned into, in order.
private PickupDock recipeDockDock the player puts the recipe page in.

Methods​

6 private and internal methods
MemberWhat it is
private void Awake()Hooks OnDockRecipe to the recipe dock and counts the ingredient docks.
private void OnDestroy()Unhooks OnDockRecipe from the recipe dock.
private void OnDockRecipe(Interactor interactor, Pickup pickup, PickupDock dock)Runs when a pickup is docked; if it is a page with an ICraftingIngredientProvider, spawns its ingredients, else logs why not.
private bool PrefabIsStackable(uint prefabHash)True if the prefab's item is stackable, so a whole quantity can go in one dock.
private void Spawn(int currentDockIndex, uint prefabHash, int count)Empties the dock at the given index and spawns the items docked there, or spawns one loose above the object once docks run out.
private void SpawnItems(Dictionary<uint, int> ingredientDictionary)Spawns each ingredient: stackable or single items get one dock each, other items get one dock per unit.