/// <summary> /// From the list of available Things, add the compatible subparts to the item /// </summary> /// <param name="item">The item to add the subparts to</param> /// <param name="available">The available things to add</param> /// <param name="reset">Should it reset the list of subparts in the item</param> public static void AddSubparts(ThingWithComps item, List <Thing> available, bool reset = true) { CompIncludedChildParts comp = item.TryGetComp <CompIncludedChildParts>(); if (comp != null) { if (reset) { comp.IncludedParts.Clear(); } foreach (ThingDef missing in comp.MissingParts) { Thing match = available.Find(x => x.def == missing); if (match != null) { available.Remove(match); comp.AddPart(match); } } } }