Re-organize all projects (#4166)
This commit is contained in:
69
Content.Server/Notification/Managers/ServerNotifyManager.cs
Normal file
69
Content.Server/Notification/Managers/ServerNotifyManager.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using Content.Shared;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Notification.Managers
|
||||
{
|
||||
public class ServerNotifyManager : SharedNotifyManager, IServerNotifyManager
|
||||
{
|
||||
[Dependency] private readonly IServerNetManager _netManager = default!;
|
||||
|
||||
private bool _initialized;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
DebugTools.Assert(!_initialized);
|
||||
|
||||
_netManager.RegisterNetMessage<MsgDoNotifyCursor>(nameof(MsgDoNotifyCursor));
|
||||
_netManager.RegisterNetMessage<MsgDoNotifyCoordinates>(nameof(MsgDoNotifyCoordinates));
|
||||
_netManager.RegisterNetMessage<MsgDoNotifyEntity>(nameof(MsgDoNotifyEntity));
|
||||
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
public override void PopupMessage(IEntity source, IEntity viewer, string message)
|
||||
{
|
||||
if (!viewer.TryGetComponent(out ActorComponent? actor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var netMessage = _netManager.CreateNetMessage<MsgDoNotifyEntity>();
|
||||
netMessage.Entity = source.Uid;
|
||||
netMessage.Message = message;
|
||||
|
||||
_netManager.ServerSendMessage(netMessage, actor.PlayerSession.ConnectedClient);
|
||||
}
|
||||
|
||||
public override void PopupMessage(EntityCoordinates coordinates, IEntity viewer, string message)
|
||||
{
|
||||
if (!viewer.TryGetComponent(out ActorComponent? actor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var netMessage = _netManager.CreateNetMessage<MsgDoNotifyCoordinates>();
|
||||
netMessage.Coordinates = coordinates;
|
||||
netMessage.Message = message;
|
||||
|
||||
_netManager.ServerSendMessage(netMessage, actor.PlayerSession.ConnectedClient);
|
||||
}
|
||||
|
||||
public override void PopupMessageCursor(IEntity viewer, string message)
|
||||
{
|
||||
if (!viewer.TryGetComponent(out ActorComponent? actor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var netMessage = _netManager.CreateNetMessage<MsgDoNotifyCursor>();
|
||||
netMessage.Message = message;
|
||||
|
||||
_netManager.ServerSendMessage(netMessage, actor.PlayerSession.ConnectedClient);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user