mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
* Ray -> Box intersection works. * Turret AI finished. * Turret Works :D * Light masks can now be rotated. * Shoddy angle MoveTowards works. * Shoddy Vector2 MoveTowards works. * And pretty broken Quaternion version.. * Slept on it, rotation works good enough now. * Fixed nuget dependencies. * Moved AimShootLifeProcessor.cs to content.
64 lines
1.9 KiB
C#
64 lines
1.9 KiB
C#
using System;
|
|
using Lidgren.Network;
|
|
using SS14.Shared.Interfaces.Network;
|
|
|
|
namespace SS14.Shared.Network
|
|
{
|
|
/// <summary>
|
|
/// A network connection from this local peer to a remote peer.
|
|
/// </summary>
|
|
internal class NetChannel : INetChannel
|
|
{
|
|
private readonly NetManager _manager;
|
|
private readonly NetConnection _connection;
|
|
|
|
/// <inheritdoc />
|
|
public long ConnectionId => _connection.RemoteUniqueIdentifier;
|
|
|
|
/// <inheritdoc />
|
|
public INetManager NetPeer => _manager;
|
|
|
|
/// <inheritdoc />
|
|
public short Ping => (short) Math.Round(_connection.AverageRoundtripTime * 1000);
|
|
|
|
/// <inheritdoc />
|
|
public string RemoteAddress => _connection.RemoteEndPoint.Address.ToString();
|
|
|
|
/// <summary>
|
|
/// Exposes the lidgren connection.
|
|
/// </summary>
|
|
public NetConnection Connection => _connection;
|
|
|
|
/// <summary>
|
|
/// Creates a new instance of a NetChannel.
|
|
/// </summary>
|
|
/// <param name="manager">The server this channel belongs to.</param>
|
|
/// <param name="connection">The raw NetConnection to the remote peer.</param>
|
|
internal NetChannel(NetManager manager, NetConnection connection)
|
|
{
|
|
_manager = manager;
|
|
_connection = connection;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public T CreateNetMessage<T>()
|
|
where T : NetMessage
|
|
{
|
|
return _manager.CreateNetMessage<T>();
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void SendMessage(NetMessage message)
|
|
{
|
|
_manager.ServerSendMessage(message, this);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void Disconnect(string reason)
|
|
{
|
|
if (_connection.Status == NetConnectionStatus.Connected)
|
|
_connection.Disconnect(reason);
|
|
}
|
|
}
|
|
}
|