Esempio n. 1
0
        public override bool canBeUsedOn(HandSlot primary_hand_slot, HandSlot secondary_hand_slot, bool use_two_handed)
        {
            if (use_two_handed)
            {
                return(false);
            }

            var weapon  = primary_hand_slot?.MaybeWeapon;
            var weapon2 = secondary_hand_slot?.MaybeWeapon;

            if (weapon == null || weapon.EnchantmentsCollection == null)
            {
                return(false);
            }

            if (weapon.Blueprint.Double && weapon.EnchantmentsCollection.HasFact(required_enchant))
            {
                return(true);
            }

            if (weapon2 == null || weapon2.EnchantmentsCollection == null)
            {
                return(false);
            }

            return(weapon.EnchantmentsCollection.HasFact(required_enchant) && weapon2.EnchantmentsCollection.HasFact(required_enchant));
        }
Esempio n. 2
0
        public override bool canBeUsedOn(ItemEntityWeapon weapon)
        {
            if (!weapon.Blueprint.IsTwoHanded)
            {
                return(false);
            }
            HandSlot holding_slot = weapon?.HoldingSlot as HandSlot;

            if (holding_slot == null)
            {
                return(false);
            }

            if (!holding_slot.PairSlot.HasItem)
            {
                return(false);
            }

            if (holding_slot.PairSlot.MaybeShield == null)
            {
                return(false);
            }

            var shield_proficiency = holding_slot.PairSlot.MaybeShield.ArmorComponent.Blueprint.ProficiencyGroup;

            if (shield_proficiency == Kingmaker.Blueprints.Items.Armors.ArmorProficiencyGroup.Buckler)
            {
                return(false);
            }

            return(weapon.Blueprint.FighterGroup == WeaponFighterGroup.Spears || weapon.Blueprint.FighterGroup == WeaponFighterGroup.Polearms);
        }
Esempio n. 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="performer">The gameobject of the player performing the aimed interaction</param>
 /// <param name="handObject">Object in the player's active hand. Null if player's hand is empty.</param>
 /// <param name="handSlot">slot of the active hand</param>
 /// <param name="buttonState">state of the mouse button, indicating whether it is being initiated
 /// or ending.</param>
 /// <param name="targetVector">vector pointing from shooter to the spot they are targeting - should NOT be normalized. Set to
 /// Vector2.zero if aiming at self.</param>
 private AimApply(GameObject performer, GameObject handObject, HandSlot handSlot, MouseButtonState buttonState, Vector2 targetVector) :
     base(performer, handObject)
 {
     this.targetVector     = targetVector;
     this.handSlot         = handSlot;
     this.mouseButtonState = buttonState;
 }
Esempio n. 4
0
        internal static bool has2hWeapon(HandSlot hand_slot)
        {
            if (hand_slot == null)
            {
                return(false);
            }
            if (!hand_slot.HasItem)
            {
                return(false);
            }

            var weapon = hand_slot.MaybeWeapon;

            if (weapon == null)
            {
                return(false);
            }

            if (weapon.Blueprint.IsTwoHanded)
            {
                return(true);
            }

            return(weapon.Blueprint.Double);
        }
Esempio n. 5
0
        public bool canBeUsedAs2h(ItemEntityWeapon weapon)
        {
            bool can_use_at_all = false;

            foreach (var b in buffs)
            {
                bool can_use = false;
                bool can_2h  = false;
                b.CallComponents <CanUse2hWeaponAs1hBase>(c => { can_2h = c.canBeUsedAs2h(weapon); can_use = c.canBeUsedOn(weapon); });
                if (can_use && can_2h)
                {
                    return(true);
                }
                can_use_at_all = can_use_at_all || can_use;
            }

            if (!can_use_at_all)
            {
                HandSlot pair_slot = (weapon?.HoldingSlot as HandSlot)?.PairSlot;
                if (pair_slot != null)
                {
                    return(!pair_slot.HasItem);
                }
                return(false);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 6
0
    void Start()
    {
        player     = GameObject.FindWithTag("Player");
        handslot   = FindObjectOfType <HandSlot>();
        itemDetail = GameObject.Find("itemDetail");

        inputAmountUI = FindObjectOfType <InputAmountUI>();
    }
Esempio n. 7
0
    private GameObject item;        // item in hand slot

    private void Awake()
    {
        if (instance != null)
        {
            Debug.LogWarning("More than one instance of handslot");
            return;
        }
        instance = this; // instantiates itself
    }
Esempio n. 8
0
 void Start()
 {
     inventoryUI           = InventoryUI.instance;
     handSlot              = HandSlot.instance;
     status_script         = this.GetComponent <player_status>();
     inventory_script      = this.GetComponent <inventory>();
     fartherOrCloserFactor = 1.0f;
     itemPlaced            = 0;
     itemExist             = 0;
 }
        public override bool canBeUsedOn(HandSlot primary_hand_slot, HandSlot secondary_hand_slot, bool use_two_handed)
        {
            if (use_two_handed)
            {
                return(false);
            }

            var shield = secondary_hand_slot?.MaybeShield;

            return(shield != null);
        }
Esempio n. 10
0
        public override bool canBeUsedAs2h(ItemEntityWeapon weapon)
        {
            HandSlot holding_slot = weapon?.HoldingSlot as HandSlot;

            if (holding_slot == null)
            {
                return(false);
            }

            return(Helpers.hasFreeHand(holding_slot.PairSlot));
        }
    public override IEnumerator Process()
    {
        yield return(WaitFor(ProcessorObject));

        var processorObj = NetworkObject;
        var performerObj = SentByPlayer.GameObject;
        //look up item in active hand slot
        var clientPNA       = SentByPlayer.Script.playerNetworkActions;
        var handSlot        = HandSlot.ForName(clientPNA.activeHand);
        var activatedObject = clientPNA.Inventory[handSlot.equipSlot].Item;

        ProcessActivate(activatedObject, processorObj, performerObj, handSlot);
    }
        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();
        }
    public override IEnumerator Process()
    {
        //look up item in active hand slot
        var clientPNA  = SentByPlayer.Script.playerNetworkActions;
        var usedSlot   = HandSlot.ForName(clientPNA.activeHand);
        var usedObject = clientPNA.Inventory[usedSlot.equipSlot].Item;

        yield return(WaitFor(ProcessorObject));

        var processorObj = NetworkObject;
        var performerObj = SentByPlayer.GameObject;

        ProcessAimApply(usedObject, TargetVector, processorObj, performerObj, usedSlot, MouseButtonState);
    }
Esempio n. 14
0
        internal static bool hasFreeHandOr1hWeapon(HandSlot hand_slot)
        {
            if (hasFreeHand(hand_slot))
            {
                return(true);
            }

            var weapon = hand_slot.Weapon;

            if (weapon == null)
            {
                return(true);
            }
            return(!weapon.Blueprint.IsTwoHanded && (!weapon.Blueprint.Double));
        }
Esempio n. 15
0
        internal static bool hasFreeHand(HandSlot hand_slot)
        {
            if (!hand_slot.HasItem)
            {
                return(true);
            }

            var shield = hand_slot.MaybeShield;

            if (shield == null)
            {
                return(false);
            }
            return(shield.ArmorComponent.Blueprint.ProficiencyGroup == Kingmaker.Blueprints.Items.Armors.ArmorProficiencyGroup.Buckler && hand_slot.Owner.HasFact(NewFeats.unhindering_shield));
        }
    public override IEnumerator Process()
    {
        //look up item in active hand slot
        var clientPNA  = SentByPlayer.Script.playerNetworkActions;
        var usedSlot   = HandSlot.ForName(clientPNA.activeHand);
        var usedObject = clientPNA.Inventory[usedSlot.SlotName].Item;

        yield return(WaitFor(TargetObject, ProcessorObject));

        var targetObj    = NetworkObjects[0];
        var processorObj = NetworkObjects[1];
        var performerObj = SentByPlayer.GameObject;

        ProcessHandApply(usedObject, targetObj, processorObj, performerObj, usedSlot);
    }
    private void ProcessCombine(HandSlot usedSlot, GameObject handObject, InventorySlot targetSlot, GameObject processorObj, GameObject performerObj)
    {
        //try to look up the components on the processor that can handle this interaction
        var processorComponents = InteractionMessageUtils.TryGetProcessors <InventoryApply>(processorObj);
        //invoke each component that can handle this interaction
        var combine = InventoryApply.ByClient(performerObj, targetSlot, handObject, usedSlot);

        foreach (var processorComponent in processorComponents)
        {
            if (processorComponent.ServerProcessInteraction(combine))
            {
                //something happened, don't check further components
                return;
            }
        }
    }
Esempio n. 18
0
        public override bool canBeUsedOn(HandSlot primary_hand_slot, HandSlot secondary_hand_slot, bool use_two_handed)
        {
            var weapon = primary_hand_slot?.MaybeWeapon;

            if (weapon == null || weapon.EnchantmentsCollection == null)
            {
                return(false);
            }

            if (secondary_hand_slot != null && !Helpers.hasFreeHand(secondary_hand_slot))
            {
                return(false);
            }

            return(weapon.EnchantmentsCollection.HasFact(required_enchant));
        }
    private void ProcessAimApply(GameObject handObject, Vector2 targetVector, GameObject processorObj,
                                 GameObject performerObj, HandSlot usedSlot, MouseButtonState buttonState)
    {
        //try to look up the components on the processor that can handle this interaction
        var processorComponents = InteractionMessageUtils.TryGetProcessors <AimApply>(processorObj);
        //invoke each component that can handle this interaction
        var aimApply = AimApply.ByClient(performerObj, targetVector, handObject, usedSlot, buttonState);

        foreach (var processorComponent in processorComponents)
        {
            if (processorComponent.ServerProcessInteraction(aimApply))
            {
                //something happened, don't check further components
                return;
            }
        }
    }
Esempio n. 20
0
    void PlaySlot(int slotIndex)
    {
        HandSlot handSlotAtIndex = this.handSlots[slotIndex];

        if (!handSlotAtIndex.HasObject())
        {
            return;
        }

        ClothesLine._instance.HangUpLaundryItem(handSlotAtIndex.GetObject());

        if (!this.isSuspended && GameManager._instance.AreNoCardsLeft())
        {
            // Game hasn't ended, but no cards left in play
            // There are cards on the Clothesline
            GameManager._instance.LevelSuccess();
        }
    }
Esempio n. 21
0
    void Start()
    {
        // Instantiate references
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible   = false;

        inv = inventory.instance;
        // When inventory changes, add an update request to UI
        inv.onItemChangedCallback += UpdateUI;

        handSlot = HandSlot.instance;
        // Set slots to children of the parent class
        slots = itemsParent.GetComponentsInChildren <InventorySlot>();

        player_situation = player.GetComponent <player_status>();

        UIActive = false;
    }
        static bool Prefix(UnitViewHandsEquipment __instance, HandSlot slot, ItemEntity previousItem)
        {
            var tr = Harmony12.Traverse.Create(__instance);

            if (!tr.Property("Active").GetValue <bool>() || tr.Method("GetSlotData", slot).GetValue <UnitViewHandSlotData>() == null)
            {
                return(true);
            }


            if (Helpers.isSummoned(slot.MaybeWeapon) || Helpers.isSummoned(previousItem) &&
                __instance.InCombat && (__instance.Owner.Descriptor.State.CanAct || __instance.IsDollRoom) && slot.Active)
            {
                tr.Method("ChangeEquipmentWithoutAnimation").GetValue();
                return(false);
            }

            return(true);
        }
Esempio n. 23
0
        public bool canBeUsedOn(HandSlot primary_hand, HandSlot secondary_hand, bool use_two_handed)
        {
            if (buffs.Empty())
            {
                return(false);
            }

            foreach (var b in buffs)
            {
                bool result = false;
                b.CallComponents <CanUseSpellCombatBase>(c => result = c.canBeUsedOn(primary_hand, secondary_hand, use_two_handed));
                if (result)
                {
                    return(true);
                }
            }

            return(false);
        }
        static bool Prefix(UnitViewHandsEquipment __instance, HandSlot slot, ItemEntity previousItem)
        {
            MethodInfo           getHandSlotMethod = __instance.GetType().GetMethod("GetSlotData", BindingFlags.NonPublic | BindingFlags.Instance);
            UnitViewHandSlotData slotDataCheck     = (UnitViewHandSlotData)getHandSlotMethod.Invoke(__instance, new object[] { slot });

            if (!(bool)unitViewHandsEquipment_get_Active(__instance) || slotDataCheck == null)
            {
                return(true);
            }

            if (__instance.Owner.IsFreeEquipmentChange() && __instance.InCombat && (__instance.Owner.Descriptor.State.CanAct || __instance.IsDollRoom) && slot.Active)
            {
                MethodInfo changeEquipmentWithoutAnimation = __instance.GetType().GetMethod("ChangeEquipmentWithoutAnimation", BindingFlags.NonPublic | BindingFlags.Instance);
                changeEquipmentWithoutAnimation.Invoke(__instance, new object[0]);
                return(false);
            }

            return(true);
        }
Esempio n. 25
0
        internal static bool hasFreeHandOrBuckler(HandSlot hand_slot)
        {
            if (hand_slot == null)
            {
                return(true);
            }
            if (!hand_slot.HasItem)
            {
                return(true);
            }

            var shield = hand_slot.MaybeShield;

            if (shield == null)
            {
                return(false);
            }
            return(shield.ArmorComponent.Blueprint.ProficiencyGroup == Kingmaker.Blueprints.Items.Armors.ArmorProficiencyGroup.Buckler);
        }
Esempio n. 26
0
        public override bool canBeUsedOn(ItemEntityWeapon weapon)
        {
            HandSlot holding_slot = weapon?.HoldingSlot as HandSlot;

            if (holding_slot == null)
            {
                return(false);
            }

            if (!holding_slot.PairSlot.HasItem)
            {
                return(false);
            }

            if (holding_slot.PairSlot.MaybeShield == null)
            {
                return(false);
            }

            return(holding_slot.PairSlot.MaybeShield.ArmorComponent.Blueprint.ProficiencyGroup == Kingmaker.Blueprints.Items.Armors.ArmorProficiencyGroup.Buckler);
        }
        /*static IEnumerable<Harmony12.CodeInstruction> Transpiler(IEnumerable<Harmony12.CodeInstruction> instructions)
         * {
         *  var codes = instructions.ToList();
         *  var check_is_unarmed = codes.FindIndex(x => x.opcode == System.Reflection.Emit.OpCodes.Callvirt && x.operand.ToString().Contains("IsUnarmed")); //checking is unarmed on weapon on primary hand
         *
         *  codes[check_is_unarmed] = new Harmony12.CodeInstruction(System.Reflection.Emit.OpCodes.Ldarg_0);
         *  codes.Insert(check_is_unarmed + 1, new Harmony12.CodeInstruction(System.Reflection.Emit.OpCodes.Call, new Func<BlueprintItemWeapon, RuleCalculateAttacksCount, bool>(considerUnarmedAndIgnore).Method));
         *
         *  check_is_unarmed = codes.IndexOf(codes.FindAll(x => x.opcode == System.Reflection.Emit.OpCodes.Callvirt && x.operand.ToString().Contains("IsUnarmed"))[2]);
         *  codes[check_is_unarmed] = new Harmony12.CodeInstruction(System.Reflection.Emit.OpCodes.Ldarg_0);
         *  codes.Insert(check_is_unarmed + 1, new Harmony12.CodeInstruction(System.Reflection.Emit.OpCodes.Call, new Func<BlueprintItemWeapon, RuleCalculateAttacksCount, bool>(considerUnarmedAndIgnoreOffHand).Method));
         *  return codes.AsEnumerable();
         * }*/

        static bool Prefix(RuleCalculateAttacksCount __instance, RulebookEventContext context)
        {
            int                 bab = (int)__instance.Initiator.Stats.BaseAttackBonus;
            int                 num_penalized_attacks = Math.Min(Math.Max(0, bab / 5 - (bab % 5 == 0 ? 1 : 0)), 3);
            HandSlot            primary_hand          = __instance.Initiator.Body.PrimaryHand;
            HandSlot            secondary_hand        = __instance.Initiator.Body.SecondaryHand;
            BlueprintItemWeapon blueprint1            = primary_hand.MaybeWeapon?.Blueprint;
            BlueprintItemWeapon blueprint2            = secondary_hand.MaybeShield != null ? ((bool)__instance.Initiator.Descriptor.State.Features.ShieldBash ? secondary_hand.MaybeShield.WeaponComponent?.Blueprint : null) : secondary_hand.MaybeWeapon?.Blueprint;
            int                 num = primary_hand.MaybeWeapon == null ? 0 : (primary_hand.MaybeWeapon.HoldInTwoHands ? 1 : 0);

            if ((secondary_hand.MaybeWeapon?.HoldInTwoHands).GetValueOrDefault() == false &&
                (blueprint1 != null) &&
                (!considerUnarmedAndIgnore(blueprint1, __instance) || blueprint2 == null || blueprint2.IsUnarmed)
                )
            {
                ++__instance.PrimaryHand.MainAttacks;
                if (!blueprint1.IsNatural || (bool)__instance.Initiator.Descriptor.State.Features.IterativeNaturalAttacks || __instance.ForceIterativeNaturealAttacks || blueprint1.IsUnarmed)
                {
                    __instance.PrimaryHand.PenalizedAttacks += Math.Max(0, num_penalized_attacks);
                }
            }
            if ((secondary_hand.MaybeWeapon?.HoldInTwoHands).GetValueOrDefault() == true ||
                (blueprint2 == null) ||
                considerUnarmedAndIgnoreOffHand(blueprint2, __instance) && (blueprint1 != null) ||
                (primary_hand.MaybeWeapon?.HoldInTwoHands).GetValueOrDefault() == true
                )
            {
                return(false);
            }
            ++__instance.SecondaryHand.MainAttacks;
            if (blueprint1 == null || !considerUnarmedAndIgnore(blueprint1, __instance) &&
                (blueprint1 == null || !blueprint1.IsNatural || !(bool)__instance.Initiator.Descriptor.State.Features.IterativeNaturalAttacks && !__instance.ForceIterativeNaturealAttacks) ||
                (blueprint2.IsUnarmed)
                )
            {
                return(false);
            }
            __instance.SecondaryHand.PenalizedAttacks += Math.Max(0, num_penalized_attacks);
            return(false);
        }
Esempio n. 28
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);
        }
    public override IEnumerator Process()
    {
        yield return(WaitFor(ProcessorObject));

        var processorObj = NetworkObject;
        var performerObj = SentByPlayer.GameObject;
        //look up item in active hand slot
        var clientPNA  = SentByPlayer.Script.playerNetworkActions;
        var usedSlot   = HandSlot.ForName(clientPNA.activeHand);
        var usedObject = clientPNA.Inventory[usedSlot.SlotName].Item;
        var targetSlot = InventoryManager.GetSlotFromUUID(TargetSlotUUID, true);

        //can only combine in their own slots
        if (targetSlot.Owner.gameObject != performerObj)
        {
            Logger.LogWarningFormat("Player {0} attempted to InventoryApply to a slot that isn't theirs! Possible" +
                                    " hacking attempt. targetSlot {1} (owner {2})", Category.Security,
                                    SentByPlayer.Name, targetSlot.SlotName, targetSlot.Owner.playerName);
        }
        else
        {
            ProcessCombine(usedSlot, usedObject, targetSlot, processorObj, performerObj);
        }
    }
Esempio n. 30
0
 static bool DontCostAction(HandSlot slot, ItemEntity previousItem)
 {
     return(Mod.Enabled && FixActionTypeOfKineticBlade &&
            ((slot.MaybeItem.IsKineticBlast() && previousItem == null) ||
             (slot.MaybeItem == null && previousItem.IsKineticBlast())));
 }