♻️ plugin api
This commit is contained in:
@@ -22,44 +22,44 @@ namespace Ragon.Server.Plugin;
|
||||
|
||||
public class BaseRoomPlugin: IRoomPlugin
|
||||
{
|
||||
private IRagonRoom _ragonRoom;
|
||||
|
||||
public RagonRoomPlayer GetPlayerById(string id)
|
||||
{
|
||||
var player = _ragonRoom.GetPlayerById(id);
|
||||
return player;
|
||||
}
|
||||
|
||||
public RagonRoomPlayer GetPlayerByConnection(INetworkConnection connection)
|
||||
{
|
||||
var player = _ragonRoom.GetPlayerByConnection(connection);
|
||||
return player;
|
||||
}
|
||||
public IRagonRoom Room { get; private set; }
|
||||
|
||||
public virtual void OnAttached(IRagonRoom room)
|
||||
{
|
||||
_ragonRoom = room;
|
||||
Room = room;
|
||||
}
|
||||
|
||||
public virtual void OnDetached()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#region VIRTUAL
|
||||
|
||||
#region VIRTUAL
|
||||
|
||||
public virtual bool OnPlayerJoined(RagonRoomPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual bool OnPlayerLeaved(RagonRoomPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void Tick(float dt)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual bool OnEntityCreate(RagonRoomPlayer creator, RagonEntity entity)
|
||||
public virtual bool OnEntityCreate(RagonRoomPlayer creator, IRagonEntity entity)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual bool OnEntityRemove(RagonRoomPlayer remover, RagonEntity entity)
|
||||
public virtual bool OnEntityRemove(RagonRoomPlayer remover, IRagonEntity entity)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,26 +22,14 @@ namespace Ragon.Server.Plugin;
|
||||
|
||||
public class BaseServerPlugin: IServerPlugin
|
||||
{
|
||||
private IRagonServer _ragonServer;
|
||||
public IRagonServer Server { get; protected set; }
|
||||
|
||||
public RagonLobbyPlayer? GetPlayerById(string id)
|
||||
public virtual void OnAttached(IRagonServer server)
|
||||
{
|
||||
var context = _ragonServer.ResolveContext(id);
|
||||
return context?.LobbyPlayer;
|
||||
Server = server;
|
||||
}
|
||||
|
||||
public RagonLobbyPlayer? GetPlayerByConnection(INetworkConnection connection)
|
||||
{
|
||||
var context = _ragonServer.ResolveContext(connection);
|
||||
return context?.LobbyPlayer;
|
||||
}
|
||||
|
||||
public void OnAttached(IRagonServer server)
|
||||
{
|
||||
_ragonServer = server;
|
||||
}
|
||||
|
||||
public void OnDetached()
|
||||
public virtual void OnDetached()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -56,16 +44,6 @@ public class BaseServerPlugin: IServerPlugin
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual bool OnRoomLeave(RagonRoomPlayer player, RagonRoom room)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual bool OnRoomJoin(RagonRoomPlayer player, RagonRoom room)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual bool OnCommand(string command, string payload)
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -24,6 +24,8 @@ public interface IRoomPlugin
|
||||
void Tick(float dt);
|
||||
void OnAttached(IRagonRoom room);
|
||||
void OnDetached();
|
||||
bool OnEntityCreate(RagonRoomPlayer creator, RagonEntity entity);
|
||||
bool OnEntityRemove(RagonRoomPlayer remover, RagonEntity entity);
|
||||
bool OnPlayerJoined(RagonRoomPlayer player);
|
||||
bool OnPlayerLeaved(RagonRoomPlayer player);
|
||||
bool OnEntityCreate(RagonRoomPlayer player, IRagonEntity entity);
|
||||
bool OnEntityRemove(RagonRoomPlayer player, IRagonEntity entity);
|
||||
}
|
||||
@@ -26,8 +26,6 @@ public interface IServerPlugin
|
||||
void OnDetached();
|
||||
bool OnRoomCreate(RagonLobbyPlayer player, RagonRoom room);
|
||||
bool OnRoomRemove(RagonLobbyPlayer player, RagonRoom room);
|
||||
bool OnRoomLeave(RagonRoomPlayer player, RagonRoom room);
|
||||
bool OnRoomJoin(RagonRoomPlayer player, RagonRoom room);
|
||||
bool OnCommand(string command, string payload);
|
||||
IRoomPlugin CreateRoomPlugin(RoomInformation information);
|
||||
}
|
||||
Reference in New Issue
Block a user