Re-organize all projects (#4166)
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
using Content.Server.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Content.Server.GameObjects.EntitySystems.DeviceNetwork
|
||||
namespace Content.Server.DeviceNetwork.Connections
|
||||
{
|
||||
public abstract class BaseNetworkConnection : IDeviceNetworkConnection
|
||||
{
|
||||
@@ -1,8 +1,7 @@
|
||||
using Content.Server.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Content.Server.GameObjects.EntitySystems.DeviceNetwork
|
||||
namespace Content.Server.DeviceNetwork.Connections
|
||||
{
|
||||
public class DeviceNetworkConnection : IDeviceNetworkConnection
|
||||
{
|
||||
@@ -0,0 +1,28 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Content.Server.DeviceNetwork.Connections
|
||||
{
|
||||
public interface IDeviceNetworkConnection
|
||||
{
|
||||
public int Frequency { get; }
|
||||
/// <summary>
|
||||
/// Sends a package to a specific device
|
||||
/// </summary>
|
||||
/// <param name="frequency">The frequency the package should be send on</param>
|
||||
/// <param name="address">The target devices address</param>
|
||||
/// <param name="payload"></param>
|
||||
/// <returns></returns>
|
||||
public bool Send(int frequency, string address, Dictionary<string, string> payload);
|
||||
/// <see cref="Send(int, string, Dictionary{string, string})"/>
|
||||
public bool Send(string address, Dictionary<string, string> payload);
|
||||
/// <summary>
|
||||
/// Sends a package to all devices
|
||||
/// </summary>
|
||||
/// <param name="frequency">The frequency the package should be send on</param>
|
||||
/// <param name="payload"></param>
|
||||
/// <returns></returns>
|
||||
public bool Broadcast(int frequency, Dictionary<string, string> payload);
|
||||
/// <see cref="Broadcast(int, Dictionary{string, string})"/>
|
||||
public bool Broadcast(Dictionary<string, string> payload);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Server.GameObjects.Components.NodeContainer;
|
||||
using Content.Server.GameObjects.Components.NodeContainer.NodeGroups;
|
||||
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
|
||||
using Content.Server.NodeContainer;
|
||||
using Content.Server.NodeContainer.NodeGroups;
|
||||
using Content.Server.Power.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.GameObjects.EntitySystems.DeviceNetwork
|
||||
namespace Content.Server.DeviceNetwork.Connections
|
||||
{
|
||||
public class WiredNetworkConnection : BaseNetworkConnection
|
||||
{
|
||||
@@ -1,9 +1,9 @@
|
||||
using Robust.Shared.Maths;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Server.GameObjects.EntitySystems.DeviceNetwork
|
||||
namespace Content.Server.DeviceNetwork.Connections
|
||||
{
|
||||
public class WirelessNetworkConnection : BaseNetworkConnection
|
||||
{
|
||||
@@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Server.Interfaces;
|
||||
using Content.Server.DeviceNetwork.Connections;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.GameObjects.EntitySystems.DeviceNetwork
|
||||
namespace Content.Server.DeviceNetwork
|
||||
{
|
||||
public delegate void OnReceiveNetMessage(int frequency, string sender, IReadOnlyDictionary<string, string> payload, Metadata metadata, bool broadcast);
|
||||
|
||||
|
||||
18
Content.Server/DeviceNetwork/DeviceNetworkSystem.cs
Normal file
18
Content.Server/DeviceNetwork/DeviceNetworkSystem.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.DeviceNetwork
|
||||
{
|
||||
[UsedImplicitly]
|
||||
internal sealed class DeviceNetworkSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IDeviceNetwork _network = default!;
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
_network.Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
24
Content.Server/DeviceNetwork/IDeviceNetwork.cs
Normal file
24
Content.Server/DeviceNetwork/IDeviceNetwork.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Content.Server.DeviceNetwork.Connections;
|
||||
|
||||
namespace Content.Server.DeviceNetwork
|
||||
{
|
||||
/// <summary>
|
||||
/// Package based device network allowing devices to communicate with eachother
|
||||
/// </summary>
|
||||
public interface IDeviceNetwork
|
||||
{
|
||||
/// <summary>
|
||||
/// Registers a device with the device network
|
||||
/// </summary>
|
||||
/// <param name="netId"><see cref="NetworkUtils"/>The id of the network to register with</param>
|
||||
/// <param name="frequency">The frequency the device receives packages on. Wired networks use frequency 0</param>
|
||||
/// <param name="messageHandler">The delegate that gets called when the device receives a message</param>
|
||||
/// <param name="receiveAll">If the device should receive all packages on its frequency or only ones addressed to itself</param>
|
||||
/// <returns></returns>
|
||||
public DeviceNetworkConnection Register(int netId, int frequency, OnReceiveNetMessage messageHandler, bool receiveAll = false);
|
||||
/// <see cref="Register(int, int, OnReceiveNetMessage, bool)"/>
|
||||
public DeviceNetworkConnection Register(int netId, OnReceiveNetMessage messageHandler, bool receiveAll = false);
|
||||
|
||||
public void Update();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Content.Server.GameObjects.EntitySystems.DeviceNetwork
|
||||
namespace Content.Server.DeviceNetwork
|
||||
{
|
||||
public class Metadata : Dictionary<string, object>
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Content.Server.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.DeviceNetwork.Connections;
|
||||
|
||||
namespace Content.Server.GameObjects.EntitySystems.DeviceNetwork
|
||||
namespace Content.Server.DeviceNetwork
|
||||
{
|
||||
/// <summary>
|
||||
/// A collection of utilities to help with using device networks
|
||||
|
||||
Reference in New Issue
Block a user