public static void UnequipPrimaryWeapon(Pawn pawn, AssignedWeaponContainer c) { ThingWithComps weapon = pawn?.equipment?.Primary; if (weapon == null) { return; } pawn.equipment.Remove(weapon); if (c != null && c.Contains(weapon)) { c.Add(weapon); return; } if (WorldComp.Add(weapon)) { return; } if (!BuildingUtil.DropSingleThing(weapon, pawn.Position, pawn.Map, false)) { Log.Warning("Failed to drop " + pawn.Name.ToStringShort + "'s primary weapon [" + pawn.equipment.Primary.Label + "]."); } }
public static void InitializeAssignedWeapons() { if (Settings.EnableAssignWeapons && AssignedWeapons.Count == 0) { foreach (var p in Util.GetPawns(true)) { AssignedWeaponContainer a = new AssignedWeaponContainer() { Pawn = p.Pawn }; if (p.Pawn.equipment.Primary != null) { a.Add(p.Pawn.equipment.Primary); } AssignedWeapons.Add(p.Pawn, a); } } }