public static void Patch_Pawn_EquipmentTracker_MakeRoomFor(Pawn_EquipmentTracker __instance, ref ThingWithComps eq)
        {
            CompShield shieldComp = eq.TryGetComp <CompShield>();

            if (shieldComp != null)
            {
                //Unequip any existing shield.
                ThingWithComps shield = __instance.GetShield();
                if (shield != null)
                {
                    Pawn           pawn = EquipmentTracker_GetPawn(__instance);
                    ThingWithComps thingWithComps;

                    if (__instance.TryDropEquipment(shield, out thingWithComps, pawn.Position, true))
                    {
                        if (thingWithComps != null)
                        {
                            thingWithComps.SetForbidden(false, true);
                        }
                    }
                    else
                    {
                        Log.Error(pawn + " couldn't make room for shield " + eq);
                    }
                }
            }
        }
Пример #2
0
        public static void SubvertBiocodedGear(Pawn target, Pawn subverter)
        {
            Pawn_EquipmentTracker eqTracker = target.equipment;

            foreach (Thing eq in eqTracker.AllEquipmentListForReading)
            {
                // if biocodable and biocoded, code to subverter
                CompBiocodable biocode = eq.TryGetComp <CompBiocodable>();
                if (biocode != null && biocode.Biocoded)
                {
                    biocode.CodeFor(subverter);
                    eqTracker.TryDropEquipment(eqTracker.Primary, out ThingWithComps dontcare, target.Position);
                }
            }
            Pawn_ApparelTracker apTracker = target.apparel;

            foreach (Apparel ap in apTracker.WornApparel)
            {
                CompBiocodable biocode = ap.TryGetComp <CompBiocodable>();
                if (biocode != null && biocode.Biocoded)
                {
                    biocode.CodeFor(subverter);
                    apTracker.TryDrop(ap);
                }
            }
        }
Пример #3
0
 public static void MakeRoomForOffHand(this Pawn_EquipmentTracker instance, ThingWithComps eq)
 {
     instance.TryGetOffHandEquipment(out ThingWithComps currentOffHand);
     if (currentOffHand != null)
     {
         ThingWithComps thingWithComps;
         if (instance.TryDropEquipment(currentOffHand, out thingWithComps, instance.pawn.Position, true))
         {
             if (thingWithComps != null)
             {
                 thingWithComps.SetForbidden(false, true);
             }
         }
         else
         {
             Log.Error(instance.pawn + " couldn't make room for equipment " + eq, false);
         }
     }
 }
Пример #4
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);
                    }
                }
            }
Пример #5
0
 private static void DropOffHand(Pawn_EquipmentTracker __instance, ThingWithComps eq, ThingWithComps offHand)
 {
     if (__instance.TryDropEquipment(offHand, out ThingWithComps resultingEq, __instance.pawn.Position))
     {
         resultingEq?.SetForbidden(value: false);
     }