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.
- Listed in Crafting and making
- Inherits or implements
NetworkEntityBehaviour - Documented in Crafting
Constructors
| Member | What it is |
|---|---|
CraftingTester() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
9 private and internal fields
| Member | What it is |
|---|---|
private Dictionary<JointInsertType, List<CraftingPart>> insertMap | Attachment prefabs grouped by insert type. |
private int interval | Milliseconds between spawns. |
private bool isRandom | Spawn random builds instead of every variant. |
private bool isRunning | Tick in the inspector to start the test. Reset to false at start. |
private bool isSpawning | Whether GetVariants actually spawns parts. |
private float randomEmptyChance | Chance a slot is left empty in random mode. |
private List<CraftingPart> roots | Prefabs that have no insert, so they start a build. |
private SpawnManager spawner | Spawn manager of the tester's entity. |
private List<CraftingPart> workingRandomList | Scratch list of candidate attachments. |
Methods
| Member | What 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
| Member | What 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. |