@@ -47,8 +47,26 @@ private void OnDestroy()
47
47
Destroy ( GetComponent < ColliderCache > ( ) ) ;
48
48
}
49
49
50
- public static bool Raycast ( Vector3 from , Vector3 direction , out RaycastHit hit ) =>
51
- Physics . Raycast ( from , direction , out hit , Builder . placeMaxDistance , Builder . placeLayerMask , QueryTriggerInteraction . Ignore ) ;
50
+ private static PlaceTool GetPlaceTool ( ) => Inventory . main ? . GetHeld ( ) ? . GetComponent < PlaceTool > ( ) ;
51
+
52
+ public static bool Raycast ( Vector3 from , Vector3 direction , out RaycastHit hit )
53
+ {
54
+ var placeTool = GetPlaceTool ( ) ;
55
+ if ( placeTool == null )
56
+ {
57
+ return Physics . Raycast ( from , direction , out hit , Builder . placeMaxDistance , Builder . placeLayerMask , QueryTriggerInteraction . Ignore ) ;
58
+ }
59
+ else
60
+ {
61
+ int max = UWE . Utils . RaycastIntoSharedBuffer ( from , direction , 5f , - 5 , QueryTriggerInteraction . UseGlobal ) ;
62
+ var hits = new ArraySegment < RaycastHit > ( UWE . Utils . sharedHitBuffer , 0 , max )
63
+ . Where ( h => ! h . collider . isTrigger && ! UWE . Utils . SharingHierarchy ( placeTool . gameObject , h . collider . gameObject ) )
64
+ . OrderBy ( h => h . distance ) ;
65
+
66
+ hit = hits . FirstOrDefault ( ) ;
67
+ return hits . Any ( ) ;
68
+ }
69
+ }
52
70
53
71
private Transform GetOrientedTransform ( Vector3 ? position = null , Vector3 ? forward = null )
54
72
{
@@ -213,7 +231,7 @@ private static RaycastHit GetWorldSpaceHit(RaycastHit hit, Transform transform =
213
231
/// <returns></returns>
214
232
private RaycastHit PopHitOntoBestSurface ( RaycastHit hit )
215
233
{
216
- if ( ! Player . main . IsInsideWalkable ( ) )
234
+ if ( ! Player . main . IsInsideWalkable ( ) || GetPlaceTool ( ) != null )
217
235
{
218
236
return hit ;
219
237
}
0 commit comments