Merge remote-tracking branch 'origin/feat/inport-props' into feat/craft-discovery
# Conflicts: # Assets/External/Animated PBR Chest Demo/Materials/WoodChest.mat # Packages/com.distantlands.cozy.core/Content/Integration/Import for BiRP.unitypackage.meta # Packages/com.distantlands.cozy.core/Content/Integration/Import for HDRP.unitypackage.meta # Packages/com.distantlands.cozy.core/Content/Integration/Import for URP.unitypackage.meta
This commit is contained in:
@@ -102,13 +102,7 @@ namespace Ashwild.Player
|
||||
return;
|
||||
}
|
||||
|
||||
IInteractable raw = null;
|
||||
if (raycastOrigin != null
|
||||
&& Physics.Raycast(raycastOrigin.position, raycastOrigin.forward, out RaycastHit hit,
|
||||
interactRange, interactMask, QueryTriggerInteraction.Collide))
|
||||
{
|
||||
hit.collider.TryGetComponent(out raw);
|
||||
}
|
||||
IInteractable raw = RaycastInteractable(out _);
|
||||
|
||||
// Restart the stability timer whenever the seen target changes.
|
||||
if (!ReferenceEquals(raw, candidateHover))
|
||||
@@ -152,14 +146,40 @@ namespace Ashwild.Player
|
||||
/// </summary>
|
||||
private void OnInteractPressed()
|
||||
{
|
||||
if (PlayerEvents.InputLocked || raycastOrigin == null) return;
|
||||
if (PlayerEvents.InputLocked) return;
|
||||
|
||||
if (Physics.Raycast(raycastOrigin.position, raycastOrigin.forward, out RaycastHit hit,
|
||||
interactRange, interactMask, QueryTriggerInteraction.Collide)
|
||||
&& hit.collider.TryGetComponent(out IInteractable interactable))
|
||||
IInteractable interactable = RaycastInteractable(out _);
|
||||
if (interactable != null) interactable.Interact();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Interactable Detection
|
||||
|
||||
/// <summary>
|
||||
/// One raycast forward for an interaction target. Returns the first IInteractable under the aim
|
||||
/// ray that actually offers an interaction — a component whose InteractionPrompt is null/empty is
|
||||
/// treated as inert and skipped, so IInteractables that opt out (e.g. a Harvestable with no
|
||||
/// bare-hand gathering) never register as a hover or a valid interact. Triggers are included so
|
||||
/// walkable interactables (bushes with a trigger collider) still respond.
|
||||
///
|
||||
/// The lookup walks up from the collider (as the tool swing does) rather than reading the collider
|
||||
/// alone: an object whose colliders sit on child meshes is perfectly valid, and matching only the
|
||||
/// exact hit object made such an object silently unusable — no prompt, no interaction, no error.
|
||||
/// </summary>
|
||||
private IInteractable RaycastInteractable(out RaycastHit hit)
|
||||
{
|
||||
hit = default;
|
||||
if (raycastOrigin == null) return null;
|
||||
|
||||
if (Physics.Raycast(raycastOrigin.position, raycastOrigin.forward, out hit,
|
||||
interactRange, interactMask, QueryTriggerInteraction.Collide))
|
||||
{
|
||||
interactable.Interact();
|
||||
IInteractable interactable = hit.collider.GetComponentInParent<IInteractable>();
|
||||
if (interactable != null && !string.IsNullOrEmpty(interactable.InteractionPrompt))
|
||||
return interactable;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -175,9 +195,7 @@ namespace Ashwild.Player
|
||||
{
|
||||
Transform o = raycastOrigin != null ? raycastOrigin : transform;
|
||||
|
||||
bool hitInteractable = Physics.Raycast(o.position, o.forward, out RaycastHit hit,
|
||||
interactRange, interactMask, QueryTriggerInteraction.Collide)
|
||||
&& hit.collider.TryGetComponent(out IInteractable _);
|
||||
bool hitInteractable = RaycastInteractable(out RaycastHit hit) != null;
|
||||
|
||||
float length = hitInteractable ? hit.distance : interactRange;
|
||||
Vector3 endPoint = o.position + o.forward * length;
|
||||
|
||||
Reference in New Issue
Block a user