diff --git a/Api/Utility/GameModeLoader.cs b/Api/Utility/GameModeLoader.cs
index 3ccd0b1..be5a7d0 100644
--- a/Api/Utility/GameModeLoader.cs
+++ b/Api/Utility/GameModeLoader.cs
@@ -1,4 +1,5 @@
-using Milimoe.FunGame.Core.Entity;
+using System.Collections;
+using Milimoe.FunGame.Core.Entity;
using Milimoe.FunGame.Core.Library.Common.Addon;
using Milimoe.FunGame.Core.Library.Constant;
using Milimoe.FunGame.Core.Service;
@@ -52,7 +53,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
/// 用于构建
/// 其他需要传入给插件初始化的对象
///
- public static GameModeLoader LoadGameModes(FunGameInfo.FunGame runtime, Delegate[] delegates, params object[] otherobjs)
+ public static GameModeLoader LoadGameModes(FunGameInfo.FunGame runtime, Hashtable delegates, params object[] otherobjs)
{
GameModeLoader loader = new();
if (runtime == FunGameInfo.FunGame.FunGame_Desktop)
diff --git a/Api/Utility/PluginLoader.cs b/Api/Utility/PluginLoader.cs
index b13738e..5a78cc7 100644
--- a/Api/Utility/PluginLoader.cs
+++ b/Api/Utility/PluginLoader.cs
@@ -1,4 +1,5 @@
-using Milimoe.FunGame.Core.Library.Common.Addon;
+using System.Collections;
+using Milimoe.FunGame.Core.Library.Common.Addon;
using Milimoe.FunGame.Core.Library.Common.Event;
using Milimoe.FunGame.Core.Service;
@@ -23,7 +24,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
/// 用于构建
/// 其他需要传入给插件初始化的对象
///
- public static PluginLoader LoadPlugins(Delegate[] delegates, params object[] otherobjs)
+ public static PluginLoader LoadPlugins(Hashtable delegates, params object[] otherobjs)
{
PluginLoader loader = new();
AddonManager.LoadPlugins(loader.Plugins, delegates, otherobjs);
diff --git a/Controller/AddonController.cs b/Controller/AddonController.cs
index feda96f..052d03a 100644
--- a/Controller/AddonController.cs
+++ b/Controller/AddonController.cs
@@ -1,4 +1,5 @@
-using Milimoe.FunGame.Core.Api.Transmittal;
+using System.Collections;
+using Milimoe.FunGame.Core.Api.Transmittal;
using Milimoe.FunGame.Core.Interface;
using Milimoe.FunGame.Core.Library.Constant;
@@ -11,7 +12,12 @@ namespace Milimoe.FunGame.Core.Controller
///
/// 输出系统消息
///
- private Action MaskMethod_WriteLine { get; set; } = new(msg => Console.Write("\r" + msg + "\n\r> "));
+ private Action MaskMethod_WriteLine { get; set; }
+
+ ///
+ /// 输出错误消息
+ ///
+ private Action MaskMethod_Error { get; set; }
///
/// 基于本地已连接的Socket创建新的数据请求
@@ -23,11 +29,6 @@ namespace Milimoe.FunGame.Core.Controller
///
private Func MaskMethod_NewLongRunningDataRequest { get; set; }
- ///
- /// 输出错误消息
- ///
- private Action MaskMethod_Error { get; set; } = new(e => Console.Write("\r" + e + "\n\r> "));
-
///
/// 输出系统消息
///
@@ -35,6 +36,13 @@ namespace Milimoe.FunGame.Core.Controller
///
public void WriteLine(string msg) => MaskMethod_WriteLine(msg);
+ ///
+ /// 输出错误消息
+ ///
+ ///
+ ///
+ public void Error(Exception e) => MaskMethod_Error(e);
+
///
/// 基于本地已连接的Socket创建新的数据请求
/// 请勿在 中调用此方法
@@ -51,29 +59,28 @@ namespace Milimoe.FunGame.Core.Controller
///
public DataRequest NewLongRunningDataRequest(DataRequestType type) => MaskMethod_NewLongRunningDataRequest(type);
- ///
- /// 输出错误消息
- ///
- ///
- ///
- public void Error(Exception e) => MaskMethod_Error(e);
-
///
/// 新建一个AddonController
///
///
///
- public AddonController(IAddon Addon, Delegate[] delegates)
+ public AddonController(IAddon Addon, Hashtable delegates)
{
this.Addon = Addon;
- if (delegates.Length > 0) MaskMethod_WriteLine = (Action)delegates[0];
- if (delegates.Length > 1) MaskMethod_NewDataRequest = (Func)delegates[1];
- if (delegates.Length > 2) MaskMethod_NewLongRunningDataRequest = (Func)delegates[2];
- if (delegates.Length > 3) MaskMethod_Error = (Action)delegates[3];
+ if (delegates.ContainsKey("WriteLine")) MaskMethod_WriteLine = delegates["WriteLine"] != null ? (Action)delegates["WriteLine"]! : new(DefaultPrint);
+ if (delegates.ContainsKey("Error")) MaskMethod_Error = delegates["Error"] != null ? (Action)delegates["Error"]! : new(DefaultPrint);
+ if (delegates.ContainsKey("NewDataRequest")) MaskMethod_NewDataRequest = delegates["NewDataRequest"] != null ? (Func)delegates["NewDataRequest"]! : new(DefaultNewDataRequest);
+ if (delegates.ContainsKey("NewLongRunningDataRequest")) MaskMethod_NewLongRunningDataRequest = delegates["NewLongRunningDataRequest"] != null ? (Func)delegates["NewLongRunningDataRequest"]! : new(DefaultNewDataRequest);
+ MaskMethod_WriteLine ??= new(DefaultPrint);
+ MaskMethod_Error ??= new(DefaultPrint);
MaskMethod_NewDataRequest ??= new(DefaultNewDataRequest);
MaskMethod_NewLongRunningDataRequest ??= new(DefaultNewDataRequest);
}
+ private void DefaultPrint(string msg) => Console.Write("\r" + msg + "\n\r> ");
+
+ private void DefaultPrint(Exception e) => DefaultPrint(e.ToString());
+
private DataRequest DefaultNewDataRequest(DataRequestType type)
{
if (Addon is IGameModeServer) throw new NotSupportedException("请勿在GameModeServer类中调用此方法");
diff --git a/Docs/FunGame.Core.xml b/Docs/FunGame.Core.xml
index ae04447..47c3adb 100644
--- a/Docs/FunGame.Core.xml
+++ b/Docs/FunGame.Core.xml
@@ -361,7 +361,7 @@
物品表
-
+
传入 类型来创建指定端的模组读取器
runtime = 时,仅读取
@@ -768,7 +768,7 @@
key 是
-
+
构建一个插件读取器并读取插件
@@ -965,6 +965,11 @@
输出系统消息
+
+
+ 输出错误消息
+
+
基于本地已连接的Socket创建新的数据请求
@@ -975,11 +980,6 @@
基于本地已连接的Socket创建长时间运行的数据请求
-
-
- 输出错误消息
-
-
输出系统消息
@@ -987,6 +987,13 @@
+
+
+ 输出错误消息
+
+
+
+
基于本地已连接的Socket创建新的数据请求
@@ -1003,14 +1010,7 @@
-
-
- 输出错误消息
-
-
-
-
-
+
新建一个AddonController
@@ -2320,7 +2320,7 @@
所处的房间
-
+
从plugins目录加载所有插件
@@ -2329,7 +2329,7 @@
-
+
从gamemodes目录加载所有模组
@@ -2341,7 +2341,7 @@
-
+
从gamemodes目录加载所有适用于服务器的模组
diff --git a/Service/AddonManager.cs b/Service/AddonManager.cs
index 75abb9b..b700c3a 100644
--- a/Service/AddonManager.cs
+++ b/Service/AddonManager.cs
@@ -1,4 +1,5 @@
-using System.Reflection;
+using System.Collections;
+using System.Reflection;
using Milimoe.FunGame.Core.Entity;
using Milimoe.FunGame.Core.Library.Common.Addon;
using Milimoe.FunGame.Core.Library.Constant;
@@ -14,7 +15,7 @@ namespace Milimoe.FunGame.Core.Service
///
///
///
- internal static Dictionary LoadPlugins(Dictionary plugins, Delegate[] delegates, params object[] otherobjs)
+ internal static Dictionary LoadPlugins(Dictionary plugins, Hashtable delegates, params object[] otherobjs)
{
if (!Directory.Exists(ReflectionSet.PluginFolderPath)) return plugins;
@@ -50,7 +51,7 @@ namespace Milimoe.FunGame.Core.Service
///
///
///
- internal static Dictionary LoadGameModes(Dictionary gamemodes, List characters, List skills, List- items, Delegate[] delegates, params object[] otherobjs)
+ internal static Dictionary LoadGameModes(Dictionary gamemodes, List characters, List skills, List
- items, Hashtable delegates, params object[] otherobjs)
{
if (!Directory.Exists(ReflectionSet.GameModeFolderPath)) return gamemodes;
@@ -111,7 +112,7 @@ namespace Milimoe.FunGame.Core.Service
///
///
///
- internal static Dictionary LoadGameModesForServer(Dictionary gamemodes, List characters, List skills, List
- items, Delegate[] delegates, params object[] otherobjs)
+ internal static Dictionary LoadGameModesForServer(Dictionary gamemodes, List characters, List skills, List
- items, Hashtable delegates, params object[] otherobjs)
{
if (!Directory.Exists(ReflectionSet.GameModeFolderPath)) return gamemodes;