static void Postfix(ref bool __result, ref Pawn __state, ThingWithComps eq) { if (__state != null) { if (WorldComp.TryGetAssignedWeapons(__state, out AssignedWeaponContainer c) && c.Contains(eq)) { if (!Settings.AllowPawnsToDropWeapon) { if (!WorldComp.Add(eq)) { Log.Warning($"unable to find weapon storage that can hold {eq.ThingID} so it will be dropped."); WorldComp.Drop(eq); } } else { if (c.Remove(eq)) { if (eq.def.IsRangedWeapon) { if (!HarmonyPatchUtil.EquipRanged(c)) { HarmonyPatchUtil.EquipMelee(c); } } else { if (!HarmonyPatchUtil.EquipMelee(c)) { HarmonyPatchUtil.EquipRanged(c); } } } if (Settings.PlaceDroppedWeaponsInStorage) { if (!WorldComp.Add(eq)) { Log.Warning($"unable to find weapon storage that can hold {eq.ThingID} so it will be dropped."); WorldComp.Drop(eq); } } } } else { foreach (SharedWeaponFilter swf in WorldComp.SharedWeaponFilter) { if (swf.Allows(eq) && !WorldComp.Add(eq)) { Log.Warning($"unable to find weapon storage that can hold {eq.ThingID} so it will be dropped."); WorldComp.Drop(eq); break; } } } } }