-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCameraRaycaster.cs
More file actions
34 lines (31 loc) · 1.12 KB
/
Copy pathCameraRaycaster.cs
File metadata and controls
34 lines (31 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using Game.Common;
using Game.Net;
using Game.Rendering;
using Game.Tools;
using Unity.Entities;
namespace FirstPersonCamera
{
/// <summary>
/// Raycasting utility for the camera
/// </summary>
internal class CameraRaycaster
{
private readonly EntityManager _entityManager;
private readonly ToolRaycastSystem _raycastSystem;
internal CameraRaycaster( )
{
var world = World.DefaultGameObjectInjectionWorld;
_entityManager = world.EntityManager;
_raycastSystem = world.GetOrCreateSystemManaged<ToolRaycastSystem>( );
}
/// <summary>
/// Performs a raycast with the default parameters.
/// </summary>
/// <param name="hitInfo">The result of the raycast, including the hit entity and collision information.</param>
/// <returns>True if the raycast hits an entity, false otherwise.</returns>
public bool TryRaycast( out RaycastResult hitInfo )
{
return _raycastSystem.GetRaycastResult( out hitInfo ) && !_entityManager.HasComponent<Deleted>( hitInfo.m_Owner );
}
}
}