示例#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.IsCenterTorsoUpgrade())
                {
                    return;
                }

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

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