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); } } } } }
// 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); } }
// 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(); } } }
private void AmmoUpdate(InventorySlotAmmo item, int clipLeft) { if (ItemEquippableEvents.IsCurrentItemShootableWeapon() && ItemEquippableEvents.currentItem.ItemDataBlock.inventorySlot.Equals(item.Slot)) { SetText(clipLeft.ToString()); } }
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)); } }
private void ChangedWeapon(ItemEquippable e) { if (ItemEquippableEvents.IsCurrentItemShootableWeapon() && PlayerLocomotionEvents.InControllablePLOCState()) { Toggle(true); } else { Toggle(false); } }
public static Quaternion GetRotationFromFiringPoint() { if (ItemEquippableEvents.IsCurrentItemShootableWeapon()) { return(ItemEquippableEvents.currentItem.MuzzleAlign.rotation); } if (!mainController) { return(Quaternion.identity); } return(mainController.transform.rotation); }
public static Vector3 GetAimFromPos() { if (ItemEquippableEvents.IsCurrentItemShootableWeapon()) { return(ItemEquippableEvents.currentItem.MuzzleAlign.position); } if (!mainController) { return(HMD.GetWorldPosition()); } return(mainController.transform.position); }
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); }
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(); } }
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); } }
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); }
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); }