feat: plugin api for replication of data
This commit is contained in:
@@ -1,53 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using NLog;
|
||||
using Ragon.Server.Entity;
|
||||
using Ragon.Server.IO;
|
||||
using Ragon.Server.Plugin;
|
||||
using Ragon.Server.Room;
|
||||
|
||||
namespace Ragon.Relay;
|
||||
|
||||
public class RelayRoomPlugin: BaseRoomPlugin
|
||||
public class RelayRoomPlugin : BaseRoomPlugin
|
||||
{
|
||||
public void Tick(float dt)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnAttached()
|
||||
{
|
||||
Console.WriteLine("Room attached");
|
||||
}
|
||||
|
||||
public void OnDetached()
|
||||
{
|
||||
Console.WriteLine("Room detached");
|
||||
}
|
||||
|
||||
public bool OnEntityCreate(RagonRoomPlayer creator, RagonEntity entity)
|
||||
{
|
||||
Console.WriteLine($"Entity created: {entity.Id}");
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool OnEntityRemove(RagonRoomPlayer destroyer, RagonEntity entity)
|
||||
{
|
||||
Console.WriteLine($"Entity destroyed: {entity.Id}");
|
||||
return true;
|
||||
}
|
||||
private Logger _logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public override bool OnPlayerJoined(RagonRoomPlayer player)
|
||||
{
|
||||
// _logger.Trace($"Player {player.Name}|{player.Connection.Id} joined");
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool OnPlayerLeaved(RagonRoomPlayer player)
|
||||
{
|
||||
// _logger.Trace($"Player {player.Name}|{player.Connection.Id} leaved");
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool OnData(RagonRoomPlayer player, byte[] data)
|
||||
{
|
||||
Console.WriteLine("Data received");
|
||||
|
||||
// _logger.Trace($"Data received from {player.Name}|{player.Connection.Id}");
|
||||
|
||||
// All Players
|
||||
// Room.ReplicateData(new Byte[] { 30, 40, 50 }, NetworkChannel.RELIABLE);
|
||||
// Selected Player
|
||||
// Room.ReplicateData(new byte[] { 10, 30, 40 }, new List<RagonRoomPlayer> { player }, NetworkChannel.RELIABLE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user