Пример #1
0
        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 + "].");
            }
        }
Пример #2
0
        static void Postfix(Pawn __instance, ref State __state)
        {
            if (__instance.Dead && __instance.IsColonist && __instance.apparel?.LockedApparel?.Count == 0 && __state.Weapon != null)
            {
                if (WorldComp.Add(__state.Weapon))
                {
                    __instance.equipment?.Remove(__state.Weapon);
                }

                if (WorldComp.TryGetAssignedWeapons(__instance, out AssignedWeaponContainer c))
                {
                    WorldComp.RemoveAssignedWeapons(__instance);

                    foreach (ThingWithComps w in c.Weapons)
                    {
                        if (!WorldComp.Add(w))
                        {
                            BuildingUtil.DropSingleThing(w, __instance.Position, __state.Map);
                        }
                    }
                }
            }
        }