Skip to content

Commit 4b4a069

Browse files
committed
Refactor stuff, clean up managers
1 parent 4962c75 commit 4b4a069

51 files changed

Lines changed: 607 additions & 450 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎TestPlugin/Commands.cs‎

Lines changed: 0 additions & 29 deletions
This file was deleted.

‎TestPlugin/Plugin.cs‎

Lines changed: 0 additions & 34 deletions
This file was deleted.

‎TestPlugin/Properties/AssemblyInfo.cs‎

Lines changed: 0 additions & 36 deletions
This file was deleted.

‎TestPlugin/TestPlugin.csproj‎

Lines changed: 0 additions & 70 deletions
This file was deleted.

‎Torch.API/IPlayer.cs‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using VRage.Game.ModAPI;
7+
8+
namespace Torch.API
9+
{
10+
public interface IPlayer
11+
{
12+
string Name { get; }
13+
ulong SteamId { get; }
14+
ConnectionState State { get; }
15+
}
16+
}

‎Torch.API/ITorchBase.cs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Text;
55
using System.Threading.Tasks;
6+
using Torch.API.Managers;
67
using VRage.Game.ModAPI;
78

89
namespace Torch.API
@@ -14,7 +15,7 @@ public interface ITorchBase
1415
event Action SessionUnloading;
1516
event Action SessionUnloaded;
1617
ITorchConfig Config { get; }
17-
IMultiplayer Multiplayer { get; }
18+
IMultiplayerManager Multiplayer { get; }
1819
IPluginManager Plugins { get; }
1920
Version TorchVersion { get; }
2021
void Invoke(Action action);
@@ -25,6 +26,7 @@ public interface ITorchBase
2526
void Start();
2627
void Stop();
2728
void Init();
29+
T GetManager<T>() where T : class, IManager;
2830
}
2931

3032
public interface ITorchServer : ITorchBase

‎Torch.API/Managers/IManager.cs‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Torch.API.Managers
8+
{
9+
public interface IManager
10+
{
11+
void Init();
12+
}
13+
}
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,19 @@
44
using VRage.Game;
55
using VRage.Game.ModAPI;
66

7-
namespace Torch.API
7+
namespace Torch.API.Managers
88
{
99
public delegate void MessageReceivedDel(IChatMessage message, ref bool sendToOthers);
1010

11-
public interface IMultiplayer
11+
public interface IMultiplayerManager : IManager
1212
{
13-
event Action<ulong> PlayerJoined;
14-
event Action<ulong, ConnectionState> PlayerLeft;
13+
event Action<IPlayer> PlayerJoined;
14+
event Action<IPlayer> PlayerLeft;
1515
event MessageReceivedDel MessageReceived;
1616
void SendMessage(string message, string author = "Server", long playerId = 0, string font = MyFontEnum.Blue);
1717
void KickPlayer(ulong steamId);
1818
void BanPlayer(ulong steamId, bool banned = true);
1919
IMyPlayer GetPlayerBySteamId(ulong id);
2020
IMyPlayer GetPlayerByName(string name);
21-
List<IChatMessage> ChatHistory { get; }
2221
}
2322
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using VRage;
7+
using VRage.Library.Collections;
8+
using VRage.Network;
9+
10+
namespace Torch.API.Managers
11+
{
12+
public interface INetworkManager : IManager
13+
{
14+
void RegisterNetworkHandler(INetworkHandler handler);
15+
}
16+
17+
public interface INetworkHandler
18+
{
19+
bool CanHandle(CallSite callSite);
20+
bool Handle(ulong remoteUserId, CallSite site, BitStream stream, object obj, MyPacket packet);
21+
}
22+
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
using VRage.Collections;
55
using VRage.Plugins;
66

7-
namespace Torch.API
7+
namespace Torch.API.Managers
88
{
9-
public interface IPluginManager : IEnumerable<ITorchPlugin>
9+
public interface IPluginManager : IManager, IEnumerable<ITorchPlugin>
1010
{
1111
event Action<List<ITorchPlugin>> PluginsLoaded;
1212
List<ITorchPlugin> Plugins { get; }
1313
void UpdatePlugins();
14-
void Init();
1514
void DisposePlugins();
1615
}
1716
}

0 commit comments

Comments
 (0)