// only allow one engine part per specific location internal static void ValidateAdd( MechComponentDef newComponentDef, List <MechLabItemSlotElement> localInventory, ref string dropErrorMessage, ref bool result) { try { if (!newComponentDef.IsEnginePart()) { return; } var existingEngine = localInventory .Where(x => x != null) .Select(x => x.ComponentRef) .FirstOrDefault(x => x != null && x.Def != null && x.Def.IsEnginePart()); if (existingEngine == null) { return; } dropErrorMessage = String.Format("Cannot add {0}: An engine part is already installed", newComponentDef.Description.Name); result = false; } catch (Exception e) { Control.mod.Logger.LogError(e); } }