예제 #1
0
        /// <summary>
        /// Set Pawn's loadout. Called by a harmony patch, Pawn_OutfitTracker_CurrentOutfit.
        /// </summary>
        /// <param name="pawn"> Set loadout on this <paramref name="pawn"/>. </param>
        /// <param name="loadout"> Loadout to assign to <paramref name="pawn"/>. </param>
        /// <param name="delay"> If true, put jobs for changing apparel in job queue, otherwise, execute jobs immediately. </param>
        /// <param name="forced"> If true, update pawn's comp for <paramref name="loadout"/> even though it is the same as current loadout. </param>
        public static void SetLoadout(this Pawn pawn, AwesomeInventoryLoadout loadout, bool delay = false, bool forced = false)
        {
            if (pawn.TryGetComp <CompAwesomeInventoryLoadout>() is CompAwesomeInventoryLoadout comp)
            {
                if (comp.Loadout == loadout && !forced)
                {
                    return;
                }

                ApparelOptionUtility.StopDressingJobs(pawn);
                comp.UpdateForNewLoadout(loadout, delay, forced: forced);

                if (loadout == pawn.outfits.CurrentOutfit)
                {
                    return;
                }

                pawn.outfits.CurrentOutfit = loadout;

                if (!comp.HotSwapCostume?.InSameLoadoutTree(loadout) ?? true)
                {
                    comp.HotSwapCostume       = null;
                    comp.LoadoutBeforeHotSwap = null;
                    comp.HotswapState         = CompAwesomeInventoryLoadout.HotSwapState.Inactive;
                }
            }
        }
예제 #2
0
        public static void Postfix(bool value, Pawn_DraftController __instance)
        {
            ValidateArg.NotNull(__instance, nameof(__instance));

            if (!value)
            {
                CompAwesomeInventoryLoadout comp = __instance.pawn.TryGetComp <CompAwesomeInventoryLoadout>();
                if (comp != null && comp.HotswapState != CompAwesomeInventoryLoadout.HotSwapState.Inactive && comp.HotSwapCostume != null && comp.Loadout == comp.HotSwapCostume)
                {
                    if (comp.LoadoutBeforeHotSwap != null && comp.LoadoutBeforeHotSwap != comp.HotSwapCostume)
                    {
                        ApparelOptionUtility.StopDressingJobs(__instance.pawn);
                        __instance.pawn.SetLoadout(comp.LoadoutBeforeHotSwap);
                        comp.LoadoutBeforeHotSwap = null;
                        comp.HotswapState         = CompAwesomeInventoryLoadout.HotSwapState.Inactive;
                    }
                }
            }
        }