using Milimoe.FunGame.Core.Entity;
using Milimoe.FunGame.Core.Library.Common.Addon;
using Milimoe.FunGame.Core.Library.Constant;
using Milimoe.FunGame.Core.Service;
namespace Milimoe.FunGame.Core.Api.Utility
{
public class GameModeLoader
{
///
/// 适用于客户端的模组集
///
public Dictionary Modes { get; } = [];
///
/// 适用于服务器的模组集
///
public Dictionary ServerModes { get; } = [];
///
/// 游戏地图集
///
public Dictionary Maps { get; } = [];
///
/// 角色表
///
public List Characters { get; } = [];
///
/// 技能表
///
public List Skills { get; } = [];
///
/// 物品表
///
public List- Items { get; } = [];
private GameModeLoader()
{
}
///
/// 传入 类型来创建指定端的模组读取器
/// runtime = 时,仅读取
/// runtime = 时,仅读取
/// 都会读取
///
/// 传入 类型来创建指定端的模组读取器
/// 用于构建
/// 其他需要传入给插件初始化的对象
///
public static GameModeLoader LoadGameModes(FunGameInfo.FunGame runtime, Delegate[] delegates, params object[] otherobjs)
{
GameModeLoader loader = new();
if (runtime == FunGameInfo.FunGame.FunGame_Desktop)
{
AddonManager.LoadGameModes(loader.Modes, loader.Characters, loader.Skills, loader.Items, delegates, otherobjs);
AddonManager.LoadGameMaps(loader.Maps, otherobjs);
}
else if (runtime == FunGameInfo.FunGame.FunGame_Server)
{
AddonManager.LoadGameModesForServer(loader.ServerModes, loader.Characters, loader.Skills, loader.Items, delegates, otherobjs);
AddonManager.LoadGameMaps(loader.Maps, otherobjs);
}
return loader;
}
///
/// 获取对应名称的模组实例
/// 如果需要取得服务器模组的实例,请调用
///
///
///
public GameMode this[string name]
{
get
{
return Modes[name];
}
set
{
Modes.TryAdd(name, value);
}
}
///
/// 获取对应名称的服务器模组实例
///
///
///
public GameModeServer GetServerMode(string name)
{
return ServerModes[name];
}
///
/// 获取对应名称的游戏地图
///
///
///
public GameMap GetGameMap(string name)
{
return Maps[name];
}
}
}