Example #1
0
        public static void Patch_Pawn_EquipmentTracker_MakeRoomFor(Pawn_EquipmentTracker __instance, Pawn ___pawn, ThingWithComps eq)
        {
            var shieldComp = eq.GetCompShield();

            if (shieldComp != null)
            {
                //Unequip any existing shield.
                var shield = __instance.GetShield();
                if (shield != null)
                {
                    if (__instance.TryDropEquipment(shield, out var thingWithComps, ___pawn.Position, true))
                    {
                        thingWithComps?.SetForbidden(false, true);
                    }
                    else
                    {
                        Log.Error(___pawn + " couldn't make room for shield " + eq);
                    }
                }
            }