Beispiel #1
0
        /// <summary>
        /// Add support for deleting loadout with costumes.
        /// </summary>
        /// <param name="outfit"> outfit to delete. </param>
        /// <param name="__result"> Return value from <see cref="OutfitDatabase.TryDelete(Outfit)"/>. </param>
        /// <returns> Returns true if continue to execute the original method. </returns>
        public static bool Prefix(Outfit outfit, ref AcceptanceReport __result)
        {
            ValidateArg.NotNull(outfit, nameof(outfit));

            if (outfit.GetType() == typeof(AwesomeInventoryLoadout))
            {
                List <Pawn> pawns = PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_Colonists;
                foreach (var costume in (outfit as AwesomeInventoryLoadout).Costumes)
                {
                    foreach (Pawn pawn in pawns)
                    {
                        if (pawn.outfits?.CurrentOutfit == costume)
                        {
                            __result = new AcceptanceReport("OutfitInUse".Translate(pawn));
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }