GameserverConstructor -> GameServerFactory
This commit is contained in:
parent
94fc8a025e
commit
fe0bb9e04a
|
@ -707,7 +707,7 @@ namespace BattleBitAPI.Server
|
|||
}
|
||||
|
||||
// ---- Static ----
|
||||
public static TGameServer CreateInstance<TGameServer>(Internal @internal, GameserverConstructor<TGameServer, TPlayer> constructor) where TGameServer : GameServer<TPlayer>
|
||||
public static TGameServer CreateInstance<TGameServer>(Internal @internal, GameServerFactory<TGameServer, TPlayer> constructor) where TGameServer : GameServer<TPlayer>
|
||||
{
|
||||
var gameServer = constructor.Create();
|
||||
gameServer.mInternal = @internal;
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
namespace BattleBitAPI.Server;
|
||||
|
||||
public class GameserverConstructor<TGameServer, TPlayer>
|
||||
public class GameServerFactory<TGameServer, TPlayer>
|
||||
where TGameServer: GameServer<TPlayer>
|
||||
where TPlayer: Player<TPlayer>
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Create a new gameserver instance.
|
||||
/// This will be whatever type you want to handle incoming
|
||||
/// events for a connecting gameserver.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual TGameServer Create()
|
||||
{
|
||||
TGameServer gameServer = (TGameServer)Activator.CreateInstance(typeof(TGameServer));
|
|
@ -67,10 +67,10 @@ namespace BattleBitAPI.Server
|
|||
private mInstances<TPlayer, TGameServer> mInstanceDatabase;
|
||||
|
||||
// --- Construction ---
|
||||
public ServerListener(GameserverConstructor<TGameServer, TPlayer> constructor = null)
|
||||
public ServerListener(GameServerFactory<TGameServer, TPlayer> constructor = null)
|
||||
{
|
||||
this.mActiveConnections = new Dictionary<ulong, (TGameServer, GameServer<TPlayer>.Internal)>(16);
|
||||
this.mInstanceDatabase = new mInstances<TPlayer, TGameServer>(constructor ?? new GameserverConstructor<TGameServer, TPlayer>());
|
||||
this.mInstanceDatabase = new mInstances<TPlayer, TGameServer>(constructor ?? new GameServerFactory<TGameServer, TPlayer>());
|
||||
}
|
||||
|
||||
// --- Starting ---
|
||||
|
@ -1059,9 +1059,9 @@ namespace BattleBitAPI.Server
|
|||
{
|
||||
private Dictionary<ulong, (TGameServer, GameServer<TPlayer>.Internal)> mGameServerInstances;
|
||||
private Dictionary<ulong, TPlayer> mPlayerInstances;
|
||||
private GameserverConstructor<TGameServer, TPlayer> _constructor;
|
||||
private GameServerFactory<TGameServer, TPlayer> _constructor;
|
||||
|
||||
public mInstances(GameserverConstructor<TGameServer, TPlayer> constructor)
|
||||
public mInstances(GameServerFactory<TGameServer, TPlayer> constructor)
|
||||
{
|
||||
_constructor = constructor;
|
||||
this.mGameServerInstances = new Dictionary<ulong, (TGameServer, GameServer<TPlayer>.Internal)>(64);
|
||||
|
|
Loading…
Reference in New Issue