Skip to main content

CraftingTester

A class in Root.Township, Alta.Crafting.

Server test tool that spawns crafting parts with every (or random) combination of attachments, one after another. Waits until isRunning is ticked in the inspector.

Constructors​

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

Fields​

9 private and internal fields
MemberWhat it is
private Dictionary<JointInsertType, List<CraftingPart>> insertMapAttachment prefabs grouped by insert type.
private int intervalMilliseconds between spawns.
private bool isRandomSpawn random builds instead of every variant.
private bool isRunningTick in the inspector to start the test. Reset to false at start.
private bool isSpawningWhether GetVariants actually spawns parts.
private float randomEmptyChanceChance a slot is left empty in random mode.
private List<CraftingPart> rootsPrefabs that have no insert, so they start a build.
private SpawnManager spawnerSpawn manager of the tester's entity.
private List<CraftingPart> workingRandomListScratch list of candidate attachments.

Methods​

MemberWhat it is
override async void InitializeAsServer(SpawnData spawnData)Server: waits for isRunning, sorts all non-legacy crafting prefabs into roots and attachments by insert type, then runs.
4 private and internal methods
MemberWhat it is
private async void DoAll()Spawns every variant of every root part in turn, destroying the previous one.
private async void DoRandom()Keeps spawning a random root part with random attachments, replacing the last.
private IEnumerable<CraftingPart> GetVariants(CraftingPart prefab, int slotIndex, string prefix) (iterator)Recursively builds every combination of attachments for a part's slots.
private void RandomizeSlots(CraftingPart part)Fills a part's slots with random fitting attachments, recursively, leaving some empty.