//------------------------------------------------- // Called every Update() while a Hand is hovering over this object //------------------------------------------------- private void HandHoverUpdate(ValveVR.Hand hand) { ValveVR.GrabTypes startingGrabType = hand.GetGrabStarting(); bool isGrabEnding = hand.IsGrabEnding(this.gameObject); if (interactable.attachedToHand == null && startingGrabType != ValveVR.GrabTypes.None) { // Save our position/rotation so that we can restore it when we detach //oldPosition = transform.position; //oldRotation = transform.rotation; // Call this to continue receiving HandHoverUpdate messages, // and prevent the hand from hovering over anything else hand.HoverLock(interactable); // Attach this object to the hand hand.AttachObject(gameObject, startingGrabType, attachmentFlags); } else if (isGrabEnding) { // Detach this object from the hand hand.DetachObject(gameObject); // Call this to undo HoverLock hand.HoverUnlock(interactable); // Restore position/rotation //transform.position = oldPosition; //transform.rotation = oldRotation; } }
//------------------------------------------------- private void ShowPointer(Hand newPointerHand, Hand oldPointerHand) { if (!visible) { pointedAtTeleportMarker = null; pointerShowStartTime = Time.time; visible = true; meshFading = true; teleportPointerObject.SetActive(false); teleportArc.Show(); foreach (TeleportMarkerBase teleportMarker in teleportMarkers) { if (teleportMarker.markerActive && teleportMarker.ShouldActivate(player.feetPositionGuess)) { teleportMarker.gameObject.SetActive(true); teleportMarker.Highlight(false); } } startingFeetOffset = player.trackingOriginTransform.position - player.feetPositionGuess; movedFeetFarEnough = false; if (onDeactivateObjectTransform.gameObject.activeSelf) { onDeactivateObjectTransform.gameObject.SetActive(false); } onActivateObjectTransform.gameObject.SetActive(true); loopingAudioSource.clip = pointerLoopSound; loopingAudioSource.loop = true; loopingAudioSource.Play(); loopingAudioSource.volume = 0.0f; } if (oldPointerHand) { if (ShouldOverrideHoverLock()) { //Restore the original hovering interactable on the hand if (originalHoverLockState == true) { oldPointerHand.HoverLock(originalHoveringInteractable); } else { oldPointerHand.HoverUnlock(null); } } } pointerHand = newPointerHand; if (visible && oldPointerHand != pointerHand) { PlayAudioClip(pointerAudioSource, pointerStartSound); } if (pointerHand) { pointerStartTransform = GetPointerStartTransform(pointerHand); if (pointerHand.currentAttachedObject != null) { allowTeleportWhileAttached = pointerHand.currentAttachedObject.GetComponent <AllowTeleportWhileAttachedToHand>(); } //Keep track of any existing hovering interactable on the hand originalHoverLockState = pointerHand.hoverLocked; originalHoveringInteractable = pointerHand.hoveringInteractable; if (ShouldOverrideHoverLock()) { pointerHand.HoverLock(null); } pointerAudioSource.transform.SetParent(pointerStartTransform); pointerAudioSource.transform.localPosition = Vector3.zero; loopingAudioSource.transform.SetParent(pointerStartTransform); loopingAudioSource.transform.localPosition = Vector3.zero; } }
//------------------------------------------------- private void HandAttachedUpdate(Hand hand) { if (bow == null) { FindBow(); } if (bow == null) { return; } if (allowArrowSpawn && (currentArrow == null)) // If we're allowed to have an active arrow in hand but don't yet, spawn one { currentArrow = InstantiateArrow(); arrowSpawnSound.Play(); } float distanceToNockPosition = Vector3.Distance(transform.parent.position, bow.nockTransform.position); // If there's an arrow spawned in the hand and it's not nocked yet if (!nocked) { // If we're close enough to nock position that we want to start arrow rotation lerp, do so if (distanceToNockPosition < rotationLerpThreshold) { float lerp = Util.RemapNumber(distanceToNockPosition, rotationLerpThreshold, lerpCompleteDistance, 0, 1); arrowNockTransform.rotation = Quaternion.Lerp(arrowNockTransform.parent.rotation, bow.nockRestTransform.rotation, lerp); } else // Not close enough for rotation lerp, reset rotation { arrowNockTransform.localRotation = Quaternion.identity; } // If we're close enough to the nock position that we want to start arrow position lerp, do so if (distanceToNockPosition < positionLerpThreshold) { float posLerp = Util.RemapNumber(distanceToNockPosition, positionLerpThreshold, lerpCompleteDistance, 0, 1); posLerp = Mathf.Clamp(posLerp, 0f, 1f); arrowNockTransform.position = Vector3.Lerp(arrowNockTransform.parent.position, bow.nockRestTransform.position, posLerp); } else // Not close enough for position lerp, reset position { arrowNockTransform.position = arrowNockTransform.parent.position; } // Give a haptic tick when lerp is visually complete if (distanceToNockPosition < lerpCompleteDistance) { if (!arrowLerpComplete) { arrowLerpComplete = true; hand.TriggerHapticPulse(500); } } else { if (arrowLerpComplete) { arrowLerpComplete = false; } } // Allow nocking the arrow when controller is close enough if (distanceToNockPosition < nockDistance) { if (!inNockRange) { inNockRange = true; bow.ArrowInPosition(); } } else { if (inNockRange) { inNockRange = false; } } GrabTypes bestGrab = hand.GetBestGrabbingType(GrabTypes.Pinch, true); // If arrow is close enough to the nock position and we're pressing the trigger, and we're not nocked yet, Nock if ((distanceToNockPosition < nockDistance) && bestGrab != GrabTypes.None && !nocked) { if (currentArrow == null) { currentArrow = InstantiateArrow(); } nocked = true; nockedWithType = bestGrab; bow.StartNock(this); hand.HoverLock(GetComponent <Interactable>()); allowTeleport.teleportAllowed = false; currentArrow.transform.parent = bow.nockTransform; Util.ResetTransform(currentArrow.transform); Util.ResetTransform(arrowNockTransform); } } // If arrow is nocked, and we release the trigger if (nocked && hand.IsGrabbingWithType(nockedWithType) == false) { if (bow.pulled) // If bow is pulled back far enough, fire arrow, otherwise reset arrow in arrowhand { FireArrow(); } else { arrowNockTransform.rotation = currentArrow.transform.rotation; currentArrow.transform.parent = arrowNockTransform; Util.ResetTransform(currentArrow.transform); nocked = false; nockedWithType = GrabTypes.None; bow.ReleaseNock(); hand.HoverUnlock(GetComponent <Interactable>()); allowTeleport.teleportAllowed = true; } bow.StartRotationLerp(); // Arrow is releasing from the bow, tell the bow to lerp back to controller rotation } }
// Token: 0x06002200 RID: 8704 RVA: 0x000A8BFC File Offset: 0x000A6DFC private void ShowPointer(Hand newPointerHand, Hand oldPointerHand) { if (!this.visible) { this.pointedAtTeleportMarker = null; this.pointerShowStartTime = Time.time; this.visible = true; this.meshFading = true; this.teleportPointerObject.SetActive(false); this.teleportArc.Show(); foreach (TeleportMarkerBase teleportMarkerBase in this.teleportMarkers) { if (teleportMarkerBase.markerActive && teleportMarkerBase.ShouldActivate(this.player.feetPositionGuess)) { teleportMarkerBase.gameObject.SetActive(true); teleportMarkerBase.Highlight(false); } } this.startingFeetOffset = this.player.trackingOriginTransform.position - this.player.feetPositionGuess; this.movedFeetFarEnough = false; if (this.onDeactivateObjectTransform.gameObject.activeSelf) { this.onDeactivateObjectTransform.gameObject.SetActive(false); } this.onActivateObjectTransform.gameObject.SetActive(true); this.loopingAudioSource.clip = this.pointerLoopSound; this.loopingAudioSource.loop = true; this.loopingAudioSource.Play(); this.loopingAudioSource.volume = 0f; } if (oldPointerHand && this.ShouldOverrideHoverLock()) { if (this.originalHoverLockState) { oldPointerHand.HoverLock(this.originalHoveringInteractable); } else { oldPointerHand.HoverUnlock(null); } } this.pointerHand = newPointerHand; if (this.visible && oldPointerHand != this.pointerHand) { this.PlayAudioClip(this.pointerAudioSource, this.pointerStartSound); } if (this.pointerHand) { this.pointerStartTransform = this.GetPointerStartTransform(this.pointerHand); if (this.pointerHand.currentAttachedObject != null) { this.allowTeleportWhileAttached = this.pointerHand.currentAttachedObject.GetComponent <AllowTeleportWhileAttachedToHand>(); } this.originalHoverLockState = this.pointerHand.hoverLocked; this.originalHoveringInteractable = this.pointerHand.hoveringInteractable; if (this.ShouldOverrideHoverLock()) { this.pointerHand.HoverLock(null); } this.pointerAudioSource.transform.SetParent(this.pointerStartTransform); this.pointerAudioSource.transform.localPosition = Vector3.zero; this.loopingAudioSource.transform.SetParent(this.pointerStartTransform); this.loopingAudioSource.transform.localPosition = Vector3.zero; } }
protected virtual void OnAttachedToHand(Hand hand) { onPickUp.Invoke(); hand.HoverLock(null); }
// Token: 0x06005DA4 RID: 23972 RVA: 0x0020BDD0 File Offset: 0x0020A1D0 private void HandAttachedUpdate(Hand hand) { if (this.bow == null) { this.FindBow(); } if (this.bow == null) { return; } if (this.allowArrowSpawn && this.currentArrow == null) { this.currentArrow = this.InstantiateArrow(); this.arrowSpawnSound.Play(); } float num = Vector3.Distance(base.transform.parent.position, this.bow.nockTransform.position); if (!this.nocked) { if (num < this.rotationLerpThreshold) { float t = Util.RemapNumber(num, this.rotationLerpThreshold, this.lerpCompleteDistance, 0f, 1f); this.arrowNockTransform.rotation = Quaternion.Lerp(this.arrowNockTransform.parent.rotation, this.bow.nockRestTransform.rotation, t); } else { this.arrowNockTransform.localRotation = Quaternion.identity; } if (num < this.positionLerpThreshold) { float num2 = Util.RemapNumber(num, this.positionLerpThreshold, this.lerpCompleteDistance, 0f, 1f); num2 = Mathf.Clamp(num2, 0f, 1f); this.arrowNockTransform.position = Vector3.Lerp(this.arrowNockTransform.parent.position, this.bow.nockRestTransform.position, num2); } else { this.arrowNockTransform.position = this.arrowNockTransform.parent.position; } if (num < this.lerpCompleteDistance) { if (!this.arrowLerpComplete) { this.arrowLerpComplete = true; hand.controller.TriggerHapticPulse(500, EVRButtonId.k_EButton_Axis0); } } else if (this.arrowLerpComplete) { this.arrowLerpComplete = false; } if (num < this.nockDistance) { if (!this.inNockRange) { this.inNockRange = true; this.bow.ArrowInPosition(); } } else if (this.inNockRange) { this.inNockRange = false; } if (num < this.nockDistance && hand.controller.GetPress(8589934592UL) && !this.nocked) { if (this.currentArrow == null) { this.currentArrow = this.InstantiateArrow(); } this.nocked = true; this.bow.StartNock(this); hand.HoverLock(base.GetComponent <Interactable>()); this.allowTeleport.teleportAllowed = false; this.currentArrow.transform.parent = this.bow.nockTransform; Util.ResetTransform(this.currentArrow.transform, true); Util.ResetTransform(this.arrowNockTransform, true); } } if (this.nocked && (!hand.controller.GetPress(8589934592UL) || hand.controller.GetPressUp(8589934592UL))) { if (this.bow.pulled) { this.FireArrow(); } else { this.arrowNockTransform.rotation = this.currentArrow.transform.rotation; this.currentArrow.transform.parent = this.arrowNockTransform; Util.ResetTransform(this.currentArrow.transform, true); this.nocked = false; this.bow.ReleaseNock(); hand.HoverUnlock(base.GetComponent <Interactable>()); this.allowTeleport.teleportAllowed = true; } this.bow.StartRotationLerp(); } }
//------------------------------------------------- private void HandHoverUpdate(Hand hand) { // ebaender worldPlaneNormal = new Vector3(0f, 0f, 0f); worldPlaneNormal[(int)axisOfRotation] = 1.0f; // ebaender if (transform.parent) { worldPlaneNormal = transform.parent.localToWorldMatrix.MultiplyVector(worldPlaneNormal).normalized; } GrabTypes startingGrabType = hand.GetGrabStarting(); bool isGrabEnding = hand.IsGrabbingWithType(grabbedWithType) == false; // ebaender - only allow left hand grip if (grabbedWithType == GrabTypes.None && hand == Player.instance.leftHand) { if (startingGrabType == GrabTypes.Grip || (startingGrabType == GrabTypes.Pinch && Book.coverMapping.value < Book.lockThreshold)) { grabbedWithType = startingGrabType; // Trigger was just pressed lastHandProjected = ComputeToTransformProjected(hand.hoverSphereTransform); if (hoverLock) { hand.HoverLock(interactable); handHoverLocked = hand; } driving = true; // ebaender - attach hand hand.AttachObject(gameObject, startingGrabType, attachmentFlags); // do this after attaching ComputeSimpleAngle(hand); UpdateAll(); hand.HideGrabHint(); } else if (startingGrabType == GrabTypes.Pinch) { if (hand.LastCollider.GetComponent <BookHandle>() == Book.lowerCoverHandle) { hand.LastCollider = Book.coverPageHandle.GetComponent <Collider>(); if (hand.LastCollider.GetComponent <PageHandle>().IsActive()) { hand.LastCollider.GetComponentInParent <PageDrive>().SendMessage("HandHoverUpdate", hand); } } } } else if (grabbedWithType != GrabTypes.None && isGrabEnding) { // Trigger was just released if (hoverLock) { hand.HoverUnlock(interactable); handHoverLocked = null; } driving = false; grabbedWithType = GrabTypes.None; // ebaender - detach hand hand.DetachObject(gameObject); } if (driving && isGrabEnding == false && hand.hoveringInteractable == this.interactable) { ComputeSimpleAngle(hand); UpdateAll(); } }
//------------------------------------------------- // Called every Update() while a Hand is hovering over this object //------------------------------------------------- private void HandHoverUpdate(Hand hand) { //Debug.DrawLine(transform.position, transform.position + transform.forward, Color.blue); //Debug.DrawLine(transform.position, transform.position + transform.up, Color.green); //Debug.DrawLine(transform.position, transform.position + transform.right, Color.red); GrabTypes startingGrabType = hand.GetGrabStarting(); GrabTypes endingGrabType = hand.GetGrabEnding(); bool isGrabEnding = hand.IsGrabEnding(this.gameObject); if (interactable.attachedToHand == null) { if (startingGrabType != GrabTypes.None) { hand.HoverLock(interactable); hand.AttachObject(gameObject, startingGrabType, attachmentFlags); } } else { if (startingGrabType == GrabTypes.Pinch) { magicCircle = Instantiate(magicCirclePrefab, transform.position + transform.up * 3, Quaternion.identity); magicCircle.transform.LookAt(transform.position); point = Instantiate(pointPrefab, magicCircle.transform.position, Quaternion.identity); } if (hand.IsGrabbingWithType(GrabTypes.Pinch)) { // 마법 발동? 그리기 // holy 12365416851651561651456561561shit magicEffect.SetActive(true); if (Physics.Raycast(transform.position, transform.up, out RaycastHit hit, Mathf.Infinity)) { Debug.Log(hit.transform.name); if (hit.transform.CompareTag("paint") || hit.transform.CompareTag("paintTrigger")) { point.transform.position = hit.point; if (hit.transform.CompareTag("paintTrigger") && !isPointTrigger) { isPointTrigger = true; hand.hapticAction.Execute(0, 0.1f, 1, 30, hand.handType); line.positionCount++; line.SetPosition(line.positionCount - 1, hit.transform.position + hit.transform.forward * 0.1f); } else if (hit.transform.CompareTag("paint") && isPointTrigger) { isPointTrigger = false; } } } } if (endingGrabType == GrabTypes.Pinch) { magicEffect.SetActive(false); Destroy(magicCircle.gameObject); Destroy(point.gameObject); line.positionCount = 0; } if (startingGrabType == GrabTypes.Grip) { // 내려놓기 // 굳이 없어도 될듯? hand.DetachObject(gameObject); hand.HoverUnlock(interactable); } } }
//------------------------------------------------- private void ShowPointer(Hand newPointerHand, Hand oldPointerHand) { if (!visible) { pointedAtTeleportMarker = null; pointerShowStartTime = Time.time; visible = true; meshFading = true; teleportPointerObject.SetActive(false); teleportArc.Show(); //MJ20170525 Never disabling teleportPoints for them to be able to detect collision with vision foreach (TeleportMarkerBase teleportMarker in teleportMarkers) { if (teleportMarker.markerActive && teleportMarker.ShouldActivate(player.feetPositionGuess)) { //teleportMarker.gameObject.SetActive( true ); teleportMarker.Highlight(false); // //MJ20170526 Necessary not to have alpha back to maximum temporarily --------------- // individualFullTintAlpha = teleportMarker.gameObject.transform.Find ("teleport_marker_mesh").GetComponent<TeleportVisionController> ().fullTintAlpha; // individualMeshAlphaPercent = teleportMarker.gameObject.transform.Find ("teleport_marker_mesh").GetComponent<TeleportVisionController> ().meshAlphaPercent; // teleportMarker.SetAlpha( individualFullTintAlpha * individualMeshAlphaPercent, individualMeshAlphaPercent ); } } startingFeetOffset = player.trackingOriginTransform.position - player.feetPositionGuess; movedFeetFarEnough = false; if (onDeactivateObjectTransform.gameObject.activeSelf) { onDeactivateObjectTransform.gameObject.SetActive(false); } onActivateObjectTransform.gameObject.SetActive(true); loopingAudioSource.clip = pointerLoopSound; loopingAudioSource.loop = true; loopingAudioSource.Play(); loopingAudioSource.volume = 0.0f; } if (oldPointerHand) { if (ShouldOverrideHoverLock()) { //Restore the original hovering interactable on the hand if (originalHoverLockState == true) { oldPointerHand.HoverLock(originalHoveringInteractable); } else { oldPointerHand.HoverUnlock(null); } } } pointerHand = newPointerHand; if (visible && oldPointerHand != pointerHand) { PlayAudioClip(pointerAudioSource, pointerStartSound); } if (pointerHand) { pointerStartTransform = GetPointerStartTransform(pointerHand); if (pointerHand.currentAttachedObject != null) { allowTeleportWhileAttached = pointerHand.currentAttachedObject.GetComponent <AllowTeleportWhileAttachedToHand>(); } //Keep track of any existing hovering interactable on the hand originalHoverLockState = pointerHand.hoverLocked; originalHoveringInteractable = pointerHand.hoveringInteractable; if (ShouldOverrideHoverLock()) { pointerHand.HoverLock(null); } pointerAudioSource.transform.SetParent(pointerStartTransform); pointerAudioSource.transform.localPosition = Vector3.zero; loopingAudioSource.transform.SetParent(pointerStartTransform); loopingAudioSource.transform.localPosition = Vector3.zero; } }