static void ShowHandslotInfo(HandSlot handSlot)
        {
            GUILayout.BeginHorizontal();
            var pItem = handSlot != null && handSlot.HasItem ? handSlot.Item : null;

            GUILayout.Label(string.Format("Slot {0}, {1}, Active {2}",
                                          pItem?.Name, pItem?.GetType(), handSlot?.Active), GUILayout.Width(500));
            if (GUILayout.Button("Remove", GUILayout.ExpandWidth(false)))
            {
                handSlot.RemoveItem();
            }
            GUILayout.EndHorizontal();
        }
Example #2
0
        static bool Prefix(HandSlot __instance)
        {
            var unit_part = __instance.Owner?.Get <UnitPartCanHold2hWeaponIn1h>();

            if (unit_part == null)
            {
                return(true);
            }

            if (!__instance.IsPrimaryHand)
            {
                HandSlot         primaryHand = __instance.HandsEquipmentSet.PrimaryHand;
                ItemEntityWeapon maybeItem   = primaryHand.MaybeItem as ItemEntityWeapon;
                if (maybeItem != null && ((maybeItem.Blueprint.IsTwoHanded && !unit_part.canBeUsedOn(maybeItem)) || maybeItem.Blueprint.Double))
                {
                    primaryHand.RemoveItem();
                }
            }
            ItemEntityWeapon maybeItem1 = __instance.MaybeItem as ItemEntityWeapon;

            if (maybeItem1 != null && ((maybeItem1.Blueprint.IsTwoHanded && !unit_part.canBeUsedOn(maybeItem1)) || maybeItem1.Blueprint.Double))
            {
                if (__instance.IsPrimaryHand)
                {
                    __instance.PairSlot.RemoveItem();
                }
                else
                {
                    __instance.RemoveItem();
                    __instance.PairSlot.InsertItem((ItemEntity)maybeItem1);
                }
            }
            __instance.IsDirty = true;

            return(false);
        }