mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-04 11:07:12 +02:00
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using JetBrains.Annotations;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Network.Messages;
|
|
using Robust.Shared.Physics;
|
|
|
|
namespace Robust.Server.Debugging
|
|
{
|
|
[UsedImplicitly]
|
|
internal sealed class DebugDrawingManager : IDebugDrawingManager, IEntityEventSubscriber
|
|
{
|
|
[Dependency] private readonly IEntityManager _entManager = default!;
|
|
|
|
public void Initialize()
|
|
{
|
|
#if DEBUG
|
|
_entManager.EventBus.SubscribeEvent<DebugDrawRayMessage>(EventSource.Local, this, PhysicsOnDebugDrawRay);
|
|
#endif
|
|
}
|
|
|
|
private void PhysicsOnDebugDrawRay(DebugDrawRayMessage @event)
|
|
{
|
|
var data = @event.Data;
|
|
var msg = new MsgRay {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;
|
|
}
|
|
|
|
_entManager.EventBus.RaiseEvent(EventSource.Network, msg);
|
|
}
|
|
}
|
|
}
|