Added new Rocket-Processing

This commit is contained in:
2026-08-14 16:54:09 +03:00
parent 3c490bdae8
commit b5eadea728
36 changed files with 17653 additions and 1984 deletions
@@ -10,6 +10,7 @@ public sealed class PlayerInteractionController : NetworkBehaviour, IPlayerSyste
private Camera playerCamera;
private IInteractable focusedInteractable;
private IPlayerInteractionSession activeSession;
private readonly RaycastHit[] interactionHits = new RaycastHit[32];
private bool activeSessionReleaseRequested;
private bool isInitialized;
@@ -54,10 +55,57 @@ public sealed class PlayerInteractionController : NetworkBehaviour, IPlayerSyste
private IInteractable FindFocusedInteractable()
{
Ray ray = new(playerCamera.transform.position, playerCamera.transform.forward);
if (!Physics.Raycast(ray, out RaycastHit hit, interactionDistance, interactionMask, QueryTriggerInteraction.Collide))
int hitCount = Physics.RaycastNonAlloc(
ray,
interactionHits,
interactionDistance,
interactionMask,
QueryTriggerInteraction.Collide);
if (hitCount <= 0)
return null;
foreach (MonoBehaviour component in hit.collider.GetComponentsInParent<MonoBehaviour>())
IInteractable closestAvailable = null;
float closestAvailableDistance = float.PositiveInfinity;
IInteractable closestUnavailable = null;
float closestUnavailableDistance = float.PositiveInfinity;
float closestBlockingDistance = float.PositiveInfinity;
for (int hitIndex = 0; hitIndex < hitCount; hitIndex++)
{
RaycastHit hit = interactionHits[hitIndex];
IInteractable interactable = FindInteractable(hit.collider);
if (interactable == null)
{
closestBlockingDistance = Mathf.Min(closestBlockingDistance, hit.distance);
continue;
}
if (interactable.IsInteractionAvailable)
{
if (hit.distance < closestAvailableDistance)
{
closestAvailable = interactable;
closestAvailableDistance = hit.distance;
}
}
else if (hit.distance < closestUnavailableDistance)
{
closestUnavailable = interactable;
closestUnavailableDistance = hit.distance;
}
}
if (closestAvailable != null && closestAvailableDistance <= closestBlockingDistance)
return closestAvailable;
return closestUnavailable != null && closestUnavailableDistance <= closestBlockingDistance
? closestUnavailable
: null;
}
private static IInteractable FindInteractable(Collider collider)
{
foreach (MonoBehaviour component in collider.GetComponentsInParent<MonoBehaviour>())
{
if (component is IInteractable interactable)
return interactable;