static bool Prefix(ref Humanoid __instance,
                           ref ItemDrop.ItemData ___m_hiddenLeftItem, ref ItemDrop.ItemData ___m_hiddenRightItem,
                           ref ZSyncAnimation ___m_zanim)
        {
            if (__instance != Player.m_localPlayer || !VHVRConfig.UseVrControls())
            {
                return(true);
            }

            bool leftHand  = VRPlayer.toggleShowLeftHand;
            bool rightHand = VRPlayer.toggleShowRightHand;

            VRPlayer.toggleShowRightHand = true;
            VRPlayer.toggleShowLeftHand  = true;

            if (___m_hiddenLeftItem == null && ___m_hiddenRightItem == null)
            {
                return(false);
            }

            if (leftHand)
            {
                ItemDrop.ItemData hiddenLeftItem = ___m_hiddenLeftItem;
                ___m_hiddenLeftItem = null;
                if (hiddenLeftItem != null)
                {
                    var item = ___m_hiddenRightItem;
                    __instance.EquipItem(hiddenLeftItem);
                    ___m_hiddenRightItem = item;
                    __instance.SetupVisEquipment(__instance.m_visEquipment, false);
                }
            }

            if (rightHand)
            {
                ItemDrop.ItemData hiddenRightItem = ___m_hiddenRightItem;
                ___m_hiddenRightItem = null;
                if (hiddenRightItem != null)
                {
                    var item = ___m_hiddenLeftItem;
                    __instance.EquipItem(hiddenRightItem);
                    ___m_hiddenLeftItem = item;
                    __instance.SetupVisEquipment(__instance.m_visEquipment, false);
                }
            }

            ___m_zanim.SetTrigger("equip_hip");

            return(false);
        }
예제 #2
0
 // Token: 0x060002E9 RID: 745 RVA: 0x00017C78 File Offset: 0x00015E78
 private static bool EquipAmmoItem(Humanoid character, ItemDrop.ItemData weapon)
 {
     if (!string.IsNullOrEmpty(weapon.m_shared.m_ammoType))
     {
         ItemDrop.ItemData ammoItem = character.GetAmmoItem();
         if (ammoItem != null && character.GetInventory().ContainsItem(ammoItem) && ammoItem.m_shared.m_ammoType == weapon.m_shared.m_ammoType)
         {
             return(true);
         }
         ItemDrop.ItemData ammoItem2 = character.GetInventory().GetAmmoItem(weapon.m_shared.m_ammoType);
         if (ammoItem2.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Ammo)
         {
             return(character.EquipItem(ammoItem2, true));
         }
     }
     return(true);
 }
예제 #3
0
        private static bool Postfix(bool __result, Humanoid __instance, ItemDrop.ItemData item)
        {
            if (Configuration.Current.Player.IsEnabled &&
                Configuration.Current.Player.autoEquipShield &&
                __result &&
                __instance.IsPlayer() &&
                __instance.m_rightItem?.m_shared.m_itemType == ItemDrop.ItemData.ItemType.OneHandedWeapon &&
                item.m_shared.m_itemType != ItemDrop.ItemData.ItemType.Shield)
            {
                List <ItemDrop.ItemData> inventoryItems = __instance.m_inventory.GetAllItems();

                ItemDrop.ItemData bestShield = null;
                foreach (ItemDrop.ItemData inventoryItem in inventoryItems)
                {
                    if (inventoryItem.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Shield)
                    {
                        if (bestShield == null)
                        {
                            bestShield = inventoryItem;

                            continue;
                        }

                        if (bestShield.m_shared.m_blockPower < inventoryItem.m_shared.m_blockPower)
                        {
                            bestShield = inventoryItem;

                            continue;
                        }
                    }
                }

                if (bestShield != null)
                {
                    __instance.EquipItem(bestShield, false);
                }
            }

            return(__result);
        }
예제 #4
0
        // This is an exact copy of the ingame method "Pickup" to provide a reliable way of controlling it later
        static bool Prefix(GameObject go, Humanoid __instance, Inventory ___m_inventory, ZNetView ___m_nview,
                           ItemDrop.ItemData ___m_rightItem, ItemDrop.ItemData ___m_hiddenRightItem, EffectList ___m_pickupEffects,
                           ref bool __result)
        {
            var component = go.GetComponent <ItemDrop>();

            if (component == null)
            {
                __result = false;
                return(false);
            }
            if (!component.CanPickup())
            {
                __result = false;
                return(false);
            }
            if (___m_inventory.ContainsItem(component.m_itemData))
            {
                __result = false;
                return(false);
            }
            if (component.m_itemData.m_shared.m_questItem &&
                __instance.HaveUniqueKey(component.m_itemData.m_shared.m_name))
            {
                __instance.Message(MessageHud.MessageType.Center, "$msg_cantpickup");
                __result = false;
                return(false);
            }

            var flag = ___m_inventory.AddItem(component.m_itemData);

            if (___m_nview.GetZDO() == null)
            {
                UnityEngine.Object.Destroy(go);
                __result = true;
                return(true);
            }
            if (!flag)
            {
                __instance.Message(MessageHud.MessageType.Center, "$msg_noroom");
                __result = false;
                return(false);
            }
            Longship.Instance.EventManager.DispatchEvent(new HumanoidPickupItemEvent(__instance,
                                                                                     component.m_itemData));
            if (component.m_itemData.m_shared.m_questItem)
            {
                __instance.AddUniqueKey(component.m_itemData.m_shared.m_name);
            }
            ZNetScene.instance.Destroy(go);
            if (flag && __instance.IsPlayer() && ___m_rightItem == null && ___m_hiddenRightItem == null &&
                component.m_itemData.IsWeapon())
            {
                __instance.EquipItem(component.m_itemData);
            }
            ___m_pickupEffects.Create(__instance.transform.position, Quaternion.identity);
            if (__instance.IsPlayer())
            {
                __instance.ShowPickupMessage(component.m_itemData, component.m_itemData.m_stack);
            }
            __result = flag;
            return(false);
        }