Files
RobustToolbox/Robust.Server/Debugging/DebugDrawingManager.cs
Acruid 2183cd7ca1 Massive Namespace Cleanup (#1544)
* Removed the Interfaces folder.
* All objects inside the GameObjects subfolders are now in the GameObjects namespace.
* Added a Resharper DotSettings file to mark the GameObjects subfolders as not providing namespaces.
* Simplified Robust.client.Graphics namespace.
* Automated remove redundant using statements.
2021-02-10 23:27:19 -08:00

39 lines
1.1 KiB
C#

using System.Diagnostics;
using Robust.Shared.IoC;
using Robust.Shared.Network;
using Robust.Shared.Network.Messages;
using Robust.Shared.Physics;
namespace Robust.Server.Debugging
{
internal class DebugDrawingManager : IDebugDrawingManager
{
[Dependency] private readonly IServerNetManager _net = default!;
[Dependency] private readonly IPhysicsManager _physics = default!;
public void Initialize()
{
_net.RegisterNetMessage<MsgRay>(MsgRay.NAME);
_physics.DebugDrawRay += data => PhysicsOnDebugDrawRay(data);
}
[Conditional("DEBUG")]
private void PhysicsOnDebugDrawRay(DebugRayData data)
{
var msg = _net.CreateNetMessage<MsgRay>();
msg.RayOrigin = data.Ray.Position;
if (data.Results != null)
{
msg.DidHit = true;
msg.RayHit = data.Results.Value.HitPos;
}
else
{
msg.RayHit = data.Ray.Position + data.Ray.Direction * data.MaxLength;
}
_net.ServerSendToAll(msg);
}
}
}