예제 #1
0
        // allow gyro upgrades to be 1 slot and still only be added once
        internal static void ValidateAdd(
            MechComponentDef newComponentDef,
            List <MechLabItemSlotElement> localInventory,
            ref string dropErrorMessage,
            ref bool result)
        {
            try
            {
                if (!result)
                {
                    return;
                }

                if (!newComponentDef.IsHeadUpgrade())
                {
                    return;
                }

                if (localInventory.Select(x => x.ComponentRef).All(x => x == null || !x.Def.IsHeadUpgrade()))
                {
                    return;
                }

                dropErrorMessage = String.Format("Cannot add {0}: A cockpit is already installed", newComponentDef.Description.Name);
                result           = false;
            }
            catch (Exception e)
            {
                Control.mod.Logger.LogError(e);
            }
        }