mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-04-22 03:59:35 +08:00

* 添加GameModeServer * Addon系列大修改 * RuntimeController添加发送结束游戏反馈的方法 * 将GamingMessageHandler返回值修改为Hashtable * 添加马甲方法,隐藏委托 * 更新AddonController注释 --------- Co-authored-by: yeziuku <53083103+yeziuku@users.noreply.github.com> Co-authored-by: yeziuku <yezi@wrss.org>
71 lines
2.9 KiB
C#
71 lines
2.9 KiB
C#
using Milimoe.FunGame.Core.Api.Transmittal;
|
|
using Milimoe.FunGame.Core.Interface;
|
|
using Milimoe.FunGame.Core.Library.Constant;
|
|
|
|
namespace Milimoe.FunGame.Core.Controller
|
|
{
|
|
public class AddonController
|
|
{
|
|
private IAddon Addon { get; }
|
|
|
|
/// <summary>
|
|
/// 输出系统消息
|
|
/// </summary>
|
|
private Action<string> MaskMethod_WriteLine { get; set; } = new(msg => Console.Write("\r" + msg + "\n\r> "));
|
|
|
|
/// <summary>
|
|
/// 基于本地已连接的Socket创建新的数据请求
|
|
/// </summary>
|
|
private Func<DataRequestType, DataRequest> MaskMethod_NewDataRequest { get; set; }
|
|
|
|
/// <summary>
|
|
/// 基于本地已连接的Socket创建长时间运行的数据请求
|
|
/// </summary>
|
|
private Func<DataRequestType, DataRequest> MaskMethod_NewLongRunningDataRequest { get; set; }
|
|
|
|
/// <summary>
|
|
/// 输出系统消息
|
|
/// </summary>
|
|
/// <param name="msg"></param>
|
|
/// <returns></returns>
|
|
public void WriteLine(string msg) => MaskMethod_WriteLine(msg);
|
|
|
|
/// <summary>
|
|
/// 基于本地已连接的Socket创建新的数据请求
|
|
/// <para>请勿在 <see cref="Library.Common.Addon.GameModeServer"/> 中调用此方法</para>
|
|
/// </summary>
|
|
/// <param name="type"></param>
|
|
/// <returns></returns>
|
|
public DataRequest NewDataRequest(DataRequestType type) => MaskMethod_NewDataRequest(type);
|
|
|
|
/// <summary>
|
|
/// 基于本地已连接的Socket创建长时间运行的数据请求
|
|
/// <para>请勿在 <see cref="Library.Common.Addon.GameModeServer"/> 中调用此方法</para>
|
|
/// </summary>
|
|
/// <param name="type"></param>
|
|
/// <returns></returns>
|
|
public DataRequest NewLongRunningDataRequest(DataRequestType type) => MaskMethod_NewLongRunningDataRequest(type);
|
|
|
|
/// <summary>
|
|
/// 新建一个AddonController
|
|
/// </summary>
|
|
/// <param name="Addon"></param>
|
|
/// <param name="delegates"></param>
|
|
public AddonController(IAddon Addon, Delegate[] delegates)
|
|
{
|
|
this.Addon = Addon;
|
|
if (delegates.Length > 0) MaskMethod_WriteLine = (Action<string>)delegates[0];
|
|
if (delegates.Length > 1) MaskMethod_NewDataRequest = (Func<DataRequestType, DataRequest>)delegates[1];
|
|
if (delegates.Length > 2) MaskMethod_NewLongRunningDataRequest = (Func<DataRequestType, DataRequest>)delegates[2];
|
|
MaskMethod_NewDataRequest ??= new(DefaultNewDataRequest);
|
|
MaskMethod_NewLongRunningDataRequest ??= new(DefaultNewDataRequest);
|
|
}
|
|
|
|
private DataRequest DefaultNewDataRequest(DataRequestType type)
|
|
{
|
|
if (Addon is IGameModeServer) throw new NotSupportedException("请勿在GameModeServer类中调用此方法");
|
|
else throw new ConnectFailedException();
|
|
}
|
|
}
|
|
}
|