Re-organize all projects (#4166)
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Content.Client.StationEvents.Managers
|
||||
{
|
||||
public interface IStationEventManager
|
||||
{
|
||||
public IReadOnlyList<string> StationEvents { get; }
|
||||
public void Initialize();
|
||||
public event Action OnStationEventsReceived;
|
||||
public void RequestEvents();
|
||||
}
|
||||
}
|
||||
41
Content.Client/StationEvents/Managers/StationEventManager.cs
Normal file
41
Content.Client/StationEvents/Managers/StationEventManager.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.StationEvents;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Network;
|
||||
|
||||
namespace Content.Client.StationEvents.Managers
|
||||
{
|
||||
internal sealed class StationEventManager : IStationEventManager
|
||||
{
|
||||
[Dependency] private readonly IClientNetManager _netManager = default!;
|
||||
|
||||
private readonly List<string> _events = new();
|
||||
public IReadOnlyList<string> StationEvents => _events;
|
||||
public event Action? OnStationEventsReceived;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
_netManager.RegisterNetMessage<MsgRequestStationEvents>(nameof(MsgRequestStationEvents));
|
||||
_netManager.RegisterNetMessage<MsgStationEvents>(nameof(MsgStationEvents), RxStationEvents);
|
||||
_netManager.Disconnect += OnNetManagerOnDisconnect;
|
||||
}
|
||||
|
||||
private void OnNetManagerOnDisconnect(object? sender, NetDisconnectedArgs msg)
|
||||
{
|
||||
_events.Clear();
|
||||
}
|
||||
|
||||
private void RxStationEvents(MsgStationEvents msg)
|
||||
{
|
||||
_events.Clear();
|
||||
_events.AddRange(msg.Events);
|
||||
OnStationEventsReceived?.Invoke();
|
||||
}
|
||||
|
||||
public void RequestEvents()
|
||||
{
|
||||
_netManager.ClientSendMessage(_netManager.CreateNetMessage<MsgRequestStationEvents>());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user