新的AddonController构造方法 (#32)

This commit is contained in:
yeziuku 2023-12-09 17:03:37 +08:00 committed by GitHub
parent 9c1bf43fdf
commit c66b25c21d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 6 deletions

View File

@ -1,4 +1,5 @@
using Milimoe.FunGame;
using System.Collections;
using Milimoe.FunGame;
using Milimoe.FunGame.Core.Api.Utility;
using Milimoe.FunGame.Core.Library.Common.Addon;
using Milimoe.FunGame.Core.Library.Common.Network;
@ -156,7 +157,12 @@ bool GetGameModeList()
{
// 同时读取Implement预设的模组和gamemods目录下的模组最后合成一个总的列表
List<string> supported = [];
Config.GameModeLoader = GameModeLoader.LoadGameModes(Config.FunGameType, [new Action<string>(msg => ServerHelper.WriteLine(msg, InvokeMessageType.GameMode))]);
// 构建AddonController
Hashtable delegates = [];
delegates.Add("WriteLine", new Action<string>(msg => ServerHelper.WriteLine(msg, InvokeMessageType.GameMode)));
delegates.Add("Error", new Action<Exception>(ServerHelper.Error));
// 开始读取
Config.GameModeLoader = GameModeLoader.LoadGameModes(Config.FunGameType, delegates);
string[] mods = (string[]?)Implement.GetFunGameImplValue(InterfaceType.IServer, InterfaceMethod.GameModeList, false) ?? [];
if (mods.Length > 0)
{

View File

@ -387,7 +387,7 @@ namespace Milimoe.FunGame.Server.Model
{
NowGamingServer = Config.GameModeLoader.GetServerMode(room.GameMode);
Dictionary<string, IServerModel> others = Server.UserList.Cast<IServerModel>().Where(model => usernames.Contains(model.User.Username) && model.User.Username != UserName).ToDictionary(k => k.User.Username, v => v);
if (NowGamingServer.StartServer(room.GameMode, room, users, this, others, new Action<string>(msg => ServerHelper.WriteLine(msg))))
if (NowGamingServer.StartServer(room.GameMode, room, users, this, others))
{
foreach (ServerModel serverTask in Server.UserList.Cast<ServerModel>().Where(model => usernames.Contains(model.User.Username)))
{

View File

@ -11,11 +11,11 @@ namespace Milimoe.FunGame.Server.Utility
{
public static string GetPrefix(InvokeMessageType type)
{
string prefix = "";
string prefix;
switch (type)
{
case InvokeMessageType.Core:
Console.ForegroundColor = ConsoleColor.Yellow;
Console.ForegroundColor = ConsoleColor.Cyan;
prefix = "[Core] ";
break;
case InvokeMessageType.Error:
@ -31,7 +31,7 @@ namespace Milimoe.FunGame.Server.Utility
prefix = "[Interface] ";
break;
case InvokeMessageType.DataRequest:
Console.ForegroundColor = ConsoleColor.Cyan;
Console.ForegroundColor = ConsoleColor.Green;
prefix = "[DataRequest] ";
break;
case InvokeMessageType.Plugin: