Refactor and stuff

This commit is contained in:
John Gross
2016-12-23 13:24:58 -08:00
parent c381439ea1
commit 2695cda5fa
29 changed files with 513 additions and 182 deletions

View File

@@ -0,0 +1,18 @@
using System;
namespace Torch.API
{
/// <summary>
/// Identifies a player's current connection state.
/// </summary>
[Flags]
public enum ConnectionState
{
Unknown,
Connected = 1,
Left = 2,
Disconnected = 4,
Kicked = 8,
Banned = 16,
}
}

View File

@@ -6,9 +6,10 @@ using System.Threading.Tasks;
namespace Torch.API
{
public interface ITorchServer
public interface IChatItem
{
void Start();
void Stop();
IPlayer Player { get; }
string Message { get; }
DateTime Time { get; }
}
}

View File

@@ -1,13 +0,0 @@
namespace Torch.API
{
public interface IEnvironmentInfo
{
EnvironmentType Type { get; }
}
public enum EnvironmentType
{
DedicatedServer,
GameClient
}
}

18
Torch.API/IMultiplayer.cs Normal file
View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace Torch.API
{
public interface IMultiplayer
{
event Action<IPlayer> PlayerJoined;
event Action<IPlayer> PlayerLeft;
event Action<IChatItem> MessageReceived;
Dictionary<ulong, IPlayer> Players { get; }
List<IChatItem> Chat { get; }
void SendMessage(string message);
void KickPlayer(ulong id);
void BanPlayer(ulong id, bool banned = true);
}
}

18
Torch.API/IPlayer.cs Normal file
View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Torch.API
{
public interface IPlayer
{
ulong SteamId { get; }
List<ulong> IdentityIds { get; }
string Name { get; }
ConnectionState State { get; }
DateTime LastConnected { get; }
void SetConnectionState(ConnectionState state);
}
}

View File

@@ -0,0 +1,21 @@
using System;
using VRage.Collections;
using VRage.Plugins;
namespace Torch.API
{
public interface IPluginManager
{
ListReader<IPlugin> Plugins { get; }
string[] GetPluginFolders();
string GetPluginName(Type pluginType);
void LoadAllPlugins();
void LoadPlugin(IPlugin plugin);
void LoadPluginFolder(string folderName);
void ReloadAll();
void ReloadPlugin(IPlugin plugin, bool forceNonPiston = false);
bool UnblockDll(string fileName);
void UnloadPlugin(IPlugin plugin);
}
}

31
Torch.API/ITorchBase.cs Normal file
View File

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Torch.API
{
public interface ITorchBase
{
event Action SessionLoaded;
IMultiplayer Multiplayer { get; }
IPluginManager Plugins { get; }
void GameAction(Action action);
void BeginGameAction(Action action, Action<object> callback = null, object state = null);
void Start();
void Stop();
void Init();
}
public interface ITorchServer : ITorchBase
{
bool IsRunning { get; }
string[] RunArgs { get; set; }
}
public interface ITorchClient : ITorchBase
{
}
}

View File

@@ -10,7 +10,7 @@ namespace Torch.API
{
public interface ITorchPlugin : IPlugin
{
void Init(ITorchServer server);
void Init(ITorchBase torch);
void Reload();
}
}

View File

@@ -45,13 +45,20 @@
<Reference Include="VRage">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\VRage.dll</HintPath>
</Reference>
<Reference Include="VRage.Library, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\VRage.Library.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="IEnvironmentInfo.cs" />
<Compile Include="ConnectionState.cs" />
<Compile Include="IChatItem.cs" />
<Compile Include="IMultiplayer.cs" />
<Compile Include="IPlayer.cs" />
<Compile Include="IPluginManager.cs" />
<Compile Include="ITorchPlugin.cs" />
<Compile Include="IServerControls.cs" />
<Compile Include="ITorchServer.cs" />
<Compile Include="TorchAPI.cs" />
<Compile Include="ITorchBase.cs" />
<Compile Include="PluginAttribute.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

View File

@@ -1,11 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
namespace Torch.API
{
}