Exemplo n.º 1
0
        private void OnAmmoUpdate(InventorySlotAmmo item, int clipleft)
        {
            if (!VRConfig.configUseBhaptics.Value)
            {
                return;
            }

            if (ItemEquippableEvents.IsCurrentItemShootableWeapon() &&
                ItemEquippableEvents.currentItem.ItemDataBlock.inventorySlot.Equals(item.Slot))
            {
                AmmoType ammoType = item.AmmoType;
                if (ammoType == AmmoType.Standard || ammoType == AmmoType.Special)
                {
                    if (clipleft == 0)
                    {
                        if (Controllers.mainControllerType == HandType.Left || Controllers.aimingTwoHanded)
                        {
                            m_hapticPlayer.SubmitRegistered(ARMS_OUT_OF_AMMO_L_KEY);
                        }

                        if (Controllers.mainControllerType == HandType.Right || Controllers.aimingTwoHanded)
                        {
                            m_hapticPlayer.SubmitRegistered(ARMS_OUT_OF_AMMO_R_KEY);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        // Handle selection effect and grid updates
        private void ItemSwitched(ItemEquippable item)
        {
            DividedBarShaderController UIBar = null;

            foreach (DividedBarShaderController d in UIMappings.Values)
            {
                d.SetUnselected();
            }
            UIMappings.TryGetValue(item.ItemDataBlock.inventorySlot, out UIBar);

            if (UIBar)
            {
                UIBar.SetSelected();
            }

            if (ItemEquippableEvents.IsCurrentItemShootableWeapon())
            {
                //Debug.Log("Item changed event: " + "MaxAmmo: " + item.GetMaxClip() + " Current ammo: " + item.GetCurrentClip() + " Inventory slot: " + item.ItemDataBlock.inventorySlot);
                BulletsInMag.maxAmmo     = item.GetMaxClip();
                BulletsInMag.currentAmmo = item.GetCurrentClip();
                BulletsInMag.UpdateAmmoGridDivisions();
                BulletsInMag.inventorySlot = item.ItemDataBlock.inventorySlot;
            }
            else
            {
                BulletsInMag.currentAmmo = 0;
                BulletsInMag.UpdateShaderVals(1, 1);
            }
        }
Exemplo n.º 3
0
        // Listen for values in respective classes ( PUI_Inventory )
        private void UiUpdate(InventorySlotAmmo item, int clipLeft)
        {
            DividedBarShaderController bar = null;

            UIMappings.TryGetValue(item.Slot, out bar);

            if (ItemEquippableEvents.currentItem != null &&
                ItemEquippableEvents.currentItem.ItemDataBlock.inventorySlot.Equals(item.Slot) &&
                ItemEquippableEvents.IsCurrentItemShootableWeapon())
            {
                //Debug.Log("Ammo update event (main or sub weapon): " + "MaxAmmo: " + item.BulletClipSize + " Current ammo: " + clipLeft + " Inventory slot: " + item.Slot);
                BulletsInMag.maxAmmo = item.BulletClipSize;
                BulletsInMag.UpdateCurrentAmmo(clipLeft);
                BulletsInMag.UpdateAmmoGridDivisions();
                BulletsInMag.inventorySlot = item.Slot;
            }


            if (bar)
            {
                //Debug.Log("Ammo update event: " + "MaxAmmo: " + item.BulletClipSize + " Current ammo: " + clipLeft + " maxCap: " + item.BulletsMaxCap + " RelInPack " + item.RelInPack + " Inventory slot: " + item.Slot);
                bar.maxAmmo     = item.BulletsMaxCap;
                bar.currentAmmo = (int)(bar.maxAmmo * item.RelInPack);
                bar.SetFill(item.RelInPack);

                if (item.Slot.Equals(InventorySlot.Consumable) || item.Slot.Equals(InventorySlot.ResourcePack) || item.Slot.Equals(InventorySlot.ConsumableHeavy))
                {
                    bar.UpdatePackOrConsumableDivisions();
                }
            }
        }
Exemplo n.º 4
0
 private void FixHeadAttachedFlashlightPos()
 {
     if (FocusStateEvents.currentState == eFocusState.FPS && !ItemEquippableEvents.CurrentItemHasFlashlight())
     {
         Transform flashlight = m_fpsCamera.m_owner.Inventory.m_flashlight.transform;
         flashlight.position = HMD.Hmd.transform.TransformPoint(m_fpsCamera.m_owner.Inventory.m_flashlightCameraOffset + new Vector3(0, 0, -.1f));
     }
 }
Exemplo n.º 5
0
 private void AmmoUpdate(InventorySlotAmmo item, int clipLeft)
 {
     if (ItemEquippableEvents.IsCurrentItemShootableWeapon() &&
         ItemEquippableEvents.currentItem.ItemDataBlock.inventorySlot.Equals(item.Slot))
     {
         SetText(clipLeft.ToString());
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Returns the camera's position or the controller's or weapons' if the player is
        /// holding a weapon that has a flashlight (and by an extension a lasersight)
        /// </summary>
        /// <returns></returns>

        public static Vector3 GetVRInteractionFromPosition()
        {
            if (ItemEquippableEvents.CurrentItemHasFlashlight())
            {
                return(Controllers.GetAimFromPos());
            }
            else
            {
                return(Hmd.transform.position);
            }
        }
Exemplo n.º 7
0
 public static Vector3 GetVRInteractionLookDir()
 {
     if (ItemEquippableEvents.CurrentItemHasFlashlight())
     {
         return(Controllers.GetAimForward());
     }
     else
     {
         return(hmd.transform.forward);
     }
 }
Exemplo n.º 8
0
 private void ChangedWeapon(ItemEquippable e)
 {
     if (ItemEquippableEvents.IsCurrentItemShootableWeapon() && PlayerLocomotionEvents.InControllablePLOCState())
     {
         Toggle(true);
     }
     else
     {
         Toggle(false);
     }
 }
Exemplo n.º 9
0
 internal void UpdateTransform()
 {
     if (ItemEquippableEvents.IsCurrentItemShootableWeapon())
     {
         ItemEquippable current = ItemEquippableEvents.currentItem;
         m_holoHolder.transform.rotation = Quaternion.LookRotation(current.MuzzleAlign.forward, current.MuzzleAlign.up);
         Vector3 posOffset      = VRConfig.configUseLeftHand.Value ? -offset : offset;
         float   muzzleDistance = (current.transform.position - current.MuzzleAlign.position).magnitude;
         m_holoHolder.transform.position = current.transform.TransformPoint(posOffset + new Vector3(0, 0, muzzleDistance * .5f));
     }
 }
Exemplo n.º 10
0
 public static Quaternion GetRotationFromFiringPoint()
 {
     if (ItemEquippableEvents.IsCurrentItemShootableWeapon())
     {
         return(ItemEquippableEvents.currentItem.MuzzleAlign.rotation);
     }
     if (!mainController)
     {
         return(Quaternion.identity);
     }
     return(mainController.transform.rotation);
 }
Exemplo n.º 11
0
 public static Vector3 GetAimFromPos()
 {
     if (ItemEquippableEvents.IsCurrentItemShootableWeapon())
     {
         return(ItemEquippableEvents.currentItem.MuzzleAlign.position);
     }
     if (!mainController)
     {
         return(HMD.GetWorldPosition());
     }
     return(mainController.transform.position);
 }
Exemplo n.º 12
0
 public static Vector3 GetAimForward()
 {
     if (ItemEquippableEvents.IsCurrentItemShootableWeapon())
     {
         return(ItemEquippableEvents.currentItem.MuzzleAlign.forward);
     }
     if (!mainController)
     {
         return(HMD.Hmd.transform.forward);
     }
     return(mainController.transform.rotation * Vector3.forward);
 }
Exemplo n.º 13
0
        private void UpdateBulletDisplayAmount(InventorySlotAmmo item, int clipLeft)
        {
            if (ItemEquippableEvents.IsCurrentItemShootableWeapon() &&
                ItemEquippableEvents.currentItem.ItemDataBlock.inventorySlot.Equals(item.Slot))
            {
                m_numberBulletsInMagDisplay.text = clipLeft + "\n----\n" + ((int)(item.BulletsMaxCap * item.RelInPack)).ToString();
                m_numberBulletsInMagDisplay.ForceMeshUpdate(false);

                m_bulletsInMagDisplay.MaxValue = Mathf.Max(item.BulletClipSize, 1);
                m_bulletsInMagDisplay.UpdateCurrentAmmo(clipLeft);
                m_bulletsInMagDisplay.UpdateAmmoGridDivisions();
            }
        }
Exemplo n.º 14
0
        private void UpdateBulletGridDivisions(ItemEquippable item)
        {
            if (ItemEquippableEvents.IsCurrentItemShootableWeapon())
            {
                if (!VRConfig.configUseNumbersForAmmoDisplay.Value)
                {
                    m_bulletsInMagDisplay.MaxValue     = item.GetMaxClip();
                    m_bulletsInMagDisplay.CurrentValue = item.GetCurrentClip();
                    m_bulletsInMagDisplay.UpdateAmmoGridDivisions();
                }
            }
            else
            {
                m_bulletsInMagDisplay.CurrentValue = 0;
                m_bulletsInMagDisplay.UpdateShaderVals(1, 1);

                m_numberBulletsInMagDisplay.text = "";
                m_numberBulletsInMagDisplay.ForceMeshUpdate(false);
            }
        }
Exemplo n.º 15
0
        public static float VRDetectionMod(Vector3 dir, float distance, float m_flashLightRange, float m_flashlight_spotAngle)
        {
            if (distance > m_flashLightRange)
            {
                return(0.0f);
            }
            Vector3 VRLookDir = fpscamera.Forward;

            if (ItemEquippableEvents.CurrentItemHasFlashlight() && VRSettings.UseVRControllers)
            {
                VRLookDir = Controllers.GetAimForward();
            }
            float angleDiff          = Vector3.Angle(dir, -VRLookDir);
            float spotlightAngleSize = m_flashlight_spotAngle * 0.5f;

            if (angleDiff > spotlightAngleSize)
            {
                return(0.0f);
            }
            float distanceMultiplier = 1.0f - distance / m_flashLightRange;

            return(Mathf.Min((1.0f - angleDiff / spotlightAngleSize) * distanceMultiplier, 0.2f));
        }
Exemplo n.º 16
0
        private bool AreControllersWithinDoubleHandStartDistance()
        {
            if (ItemEquippableEvents.IsCurrentItemShootableWeapon())
            {
                ItemEquippable currentHeldItem = ItemEquippableEvents.currentItem;
                if (currentHeldItem.LeftHandGripTrans)
                {
                    Vector3 correctedGripPosition = ItemEquippableEvents.GetCorrectedGripPosition();

                    if (GTFO_VR_Plugin.DEBUG_ENABLED)
                    {
                        if (VRConfig.configDebugShowTwoHHitboxes.Value)
                        {
                            DebugDraw3D.DrawSphere(correctedGripPosition, m_doubleHandStartDistance, ColorExt.Blue(0.2f));
                        }
                    }

                    return(Vector3.Distance(offhandController.transform.position, ItemEquippableEvents.GetCorrectedGripPosition()) < m_doubleHandStartDistance);
                }
            }

            return(Vector3.Distance(mainController.transform.position, offhandController.transform.position) < m_doubleHandStartDistance);
        }
Exemplo n.º 17
0
 private bool AreControllersOutsideOfDoubleHandExitDistance()
 {
     if (ItemEquippableEvents.IsCurrentItemShootableWeapon())
     {
         ItemEquippable currentHeldItem = ItemEquippableEvents.currentItem;
         if (currentHeldItem.IsReloading)
         {
             return(false);
         }
         if (currentHeldItem.LeftHandGripTrans)
         {
             Vector3 correctedGripPosition = ItemEquippableEvents.GetCorrectedGripPosition();
             if (GTFO_VR_Plugin.DEBUG_ENABLED)
             {
                 if (VRConfig.configDebugShowTwoHHitboxes.Value)
                 {
                     DebugDraw3D.DrawSphere(correctedGripPosition, m_doubleHandLeaveDistance, ColorExt.Red(0.1f));
                 }
             }
             return(Vector3.Distance(offhandController.transform.position, ItemEquippableEvents.GetCorrectedGripPosition()) > m_doubleHandLeaveDistance);
         }
     }
     return(Vector3.Distance(mainController.transform.position, offhandController.transform.position) > m_doubleHandLeaveDistance);
 }
 private static void Postfix(ItemEquippable __instance)
 {
     ItemEquippableEvents.ItemEquipped(__instance);
 }