first commit
This commit is contained in:
@@ -0,0 +1,288 @@
|
||||
using FunGame.Core.Api;
|
||||
using FunGame.Core.Entity;
|
||||
using FunGame.Server.Contracts.Plugins;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Milimoe.FunGameTesting.Others;
|
||||
using Milimoe.FunGameTesting.OshimaGameModules.Characters;
|
||||
using Milimoe.FunGameTesting.OshimaGameModules.Items;
|
||||
using Milimoe.FunGameTesting.OshimaGameModules.Skills;
|
||||
|
||||
namespace FunGame.Server.Modules.Oshima;
|
||||
|
||||
/// <summary>
|
||||
/// 创建实体新实例:优先无参构造;无无参构造时退化为 (Character? = null) 风格的构造(技能类惯例)<para/>
|
||||
/// 工厂委托必须返回新实例而非 Copy(),避免 Skill.Copy 内部调用 Factory.GetInstance 造成无限递归
|
||||
/// </summary>
|
||||
internal static class ModuleEntityFactory
|
||||
{
|
||||
public static T? Create<T>(Type type) where T : class
|
||||
{
|
||||
try
|
||||
{
|
||||
return (T)Activator.CreateInstance(type)!;
|
||||
}
|
||||
catch (MissingMethodException)
|
||||
{
|
||||
return (T)Activator.CreateInstance(type, (object?[]?)[null])!;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Oshima Studios 角色模组:Testing-v3(FunGameSimulation)同源内容,供 Server 加载<para/>
|
||||
/// 18 名角色(大島シヤ / 心音 / 阳 / 南甘雨 …),与 Testing-v3 的 Oshima CharacterModule 工厂(id 1-18)一一对应
|
||||
/// </summary>
|
||||
public class OshimaCharacterModule : ICharacterModule
|
||||
{
|
||||
public string Name => "oshima.characters";
|
||||
public string Version => "1.0.0";
|
||||
public string Author => "Oshima Studios";
|
||||
public string Description => "Oshima 角色模组:18 名角色(移植自 FunGame.Testing-v3 / FunGameSimulation)";
|
||||
|
||||
private IReadOnlyDictionary<string, Character>? _entities;
|
||||
|
||||
public IReadOnlyDictionary<string, Character> Entities
|
||||
{
|
||||
get
|
||||
{
|
||||
_entities ??= new Dictionary<string, Character>
|
||||
{
|
||||
["oshima_shiya"] = new OshimaShiya(),
|
||||
["xin_yin"] = new XinYin(),
|
||||
["yang"] = new Yang(),
|
||||
["nan_ganyu"] = new NanGanYu(),
|
||||
["niu_nan"] = new NiuNan(),
|
||||
["dokyo_mayor"] = new DokyoMayor(),
|
||||
["magical_girl"] = new MagicalGirl(),
|
||||
["qing_xiang"] = new QingXiang(),
|
||||
["qwqaqw"] = new QWQAQW(),
|
||||
["cold_blue"] = new ColdBlue(),
|
||||
["dddovo"] = new Dddovo(),
|
||||
["qu_duoduo"] = new Quduoduo(),
|
||||
["shi_yu"] = new ShiYu(),
|
||||
["xreouni"] = new XReouni(),
|
||||
["neptune"] = new Neptune(),
|
||||
["chaos"] = new CHAOS(),
|
||||
["ryuko"] = new Ryuko(),
|
||||
["the_god_k"] = new TheGodK()
|
||||
};
|
||||
return _entities;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnLoad(IServiceProvider services)
|
||||
{
|
||||
// 注册工厂(与 Oshima CharacterModule 工厂一致:id 1-18)
|
||||
Factory.OpenFactory.RegisterFactory<Character>((id, name, args) => id switch
|
||||
{
|
||||
1 => new OshimaShiya(),
|
||||
2 => new XinYin(),
|
||||
3 => new Yang(),
|
||||
4 => new NanGanYu(),
|
||||
5 => new NiuNan(),
|
||||
6 => new DokyoMayor(),
|
||||
7 => new MagicalGirl(),
|
||||
8 => new QingXiang(),
|
||||
9 => new QWQAQW(),
|
||||
10 => new ColdBlue(),
|
||||
11 => new Dddovo(),
|
||||
12 => new Quduoduo(),
|
||||
13 => new ShiYu(),
|
||||
14 => new XReouni(),
|
||||
15 => new Neptune(),
|
||||
16 => new CHAOS(),
|
||||
17 => new Ryuko(),
|
||||
18 => new TheGodK(),
|
||||
_ => null
|
||||
});
|
||||
}
|
||||
|
||||
public void OnUnload()
|
||||
{
|
||||
Factory.OpenFactory.UnRegisterFactory<Character>((id, name, args) => id switch
|
||||
{
|
||||
1 => new OshimaShiya(),
|
||||
2 => new XinYin(),
|
||||
3 => new Yang(),
|
||||
4 => new NanGanYu(),
|
||||
5 => new NiuNan(),
|
||||
6 => new DokyoMayor(),
|
||||
7 => new MagicalGirl(),
|
||||
8 => new QingXiang(),
|
||||
9 => new QWQAQW(),
|
||||
10 => new ColdBlue(),
|
||||
11 => new Dddovo(),
|
||||
12 => new Quduoduo(),
|
||||
13 => new ShiYu(),
|
||||
14 => new XReouni(),
|
||||
15 => new Neptune(),
|
||||
16 => new CHAOS(),
|
||||
17 => new Ryuko(),
|
||||
18 => new TheGodK(),
|
||||
_ => null
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Oshima 技能模组:基础战技 / 爆发技 / 被动 / 通用被动 / 通用爆发 / 魔法 全量注册
|
||||
/// </summary>
|
||||
public class OshimaSkillModule : ISkillModule
|
||||
{
|
||||
public string Name => "oshima.skills";
|
||||
public string Version => "1.0.0";
|
||||
public string Author => "Oshima Studios";
|
||||
public string Description => "Oshima 技能模组:基础技能 / 爆发技 / 被动 / 魔法(移植自 FunGame.Testing-v3)";
|
||||
|
||||
private IReadOnlyDictionary<string, Skill>? _entities;
|
||||
|
||||
public IReadOnlyDictionary<string, Skill> Entities
|
||||
{
|
||||
get
|
||||
{
|
||||
_entities ??= BuildEntities();
|
||||
return _entities;
|
||||
}
|
||||
}
|
||||
|
||||
private static IReadOnlyDictionary<string, Skill> BuildEntities()
|
||||
{
|
||||
Dictionary<string, Skill> skills = new();
|
||||
int seq = 0;
|
||||
Skill[] all =
|
||||
[
|
||||
// ===== 基础战技 =====
|
||||
new 疾风步(), new 助威(), new 挑拨(), new 绞丝棍(), new 金刚击(), new 旋风轮(), new 双连击(), new 绝影(), new 胧(), new 魔眼(),
|
||||
new 天堂之吻(), new 回复弹(), new 养命功(), new 镜花水月(), new 剑风闪(), new 鲨鱼锚击(), new 疾走(), new 闪现(),
|
||||
// ===== 爆发技 =====
|
||||
new 极寒渴望(), new 身心一境(), new 绝对领域(), new 零式灭杀(), new 三相灵枢(), new 变幻之心(), new 熵灭极诣(), new 残香凋零(), new 饕餮盛宴(),
|
||||
new 宿命时律(), new 千羽瞬华(), new 咒怨洪流(), new 放监(), new 归元环(), new 海王星的野望(), new 全军出击(), new 宿命之潮(), new 神之因果(),
|
||||
// ===== 角色被动 =====
|
||||
new META马(), new 心灵之弦(), new 蚀魂震击(), new 灵能反射(), new 双生流转(), new 零式崩解(), new 少女绮想(), new 暗香疏影(), new 破釜沉舟(),
|
||||
new 累积之压(), new 银隼之赐(), new 弱者猎手(), new 开宫(), new 八卦阵(), new 深海之戟(), new 雇佣兵团(), new 不息之流(), new 概念之骰(),
|
||||
// ===== 通用被动 =====
|
||||
new 征服者(), new 致命节奏(), new 强攻(), new 电刑(), new 黑暗收割(), new 迅捷步法(), new 贪欲猎手(),
|
||||
// ===== 通用爆发 =====
|
||||
new 樱花无双击(), new 漆黑之牙(), new 女王之怒(), new 裁决塔罗(), new 光明之环(), new 圣星光旋(),
|
||||
// ===== 魔法 =====
|
||||
new 冰霜攻击(), new 火之矢(), new 水之矢(), new 风之轮(), new 石之锤(), new 心灵之霞(), new 次元上升(), new 暗物质(),
|
||||
new 回复术(), new 治愈术(), new 复苏术(), new 圣灵术(), new 时间加速(), new 时间减速(), new 反魔法领域(), new 沉默十字(), new 虚弱领域(), new 混沌烙印(), new 凝胶稠絮(),
|
||||
new 大地之墙(), new 盖亚之盾(), new 风之守护(), new 结晶防护(), new 强音之力(), new 神圣祝福(), new 根源屏障(), new 灾难冲击波(), new 银色荆棘(), new 等离子之波(),
|
||||
new 地狱之门(), new 钻石星尘(), new 死亡咆哮(), new 鬼魅之痛(), new 导力停止(), new 冰狱冥嚎(), new 火山咆哮(), new 水蓝轰炸(), new 岩石之息(), new 弧形日珥(), new 苍白地狱(), new 破碎虚空(),
|
||||
new 弧光消耗(), new 回复术改(), new 回复术复(), new 治愈术复(), new 风之守护复(), new 强音之力复(), new 结晶防护复(), new 神圣祝福复(), new 时间加速改(), new 时间减速改(), new 时间加速复(), new 时间减速复()
|
||||
];
|
||||
foreach (Skill skill in all)
|
||||
{
|
||||
skills[$"oshima_skill_{++seq}"] = skill;
|
||||
}
|
||||
return skills;
|
||||
}
|
||||
|
||||
public void OnLoad(IServiceProvider services)
|
||||
{
|
||||
// 注意:工厂委托必须返回“新实例”,不能用 skill.Copy()——Copy 内部会再调 Factory.GetInstance,形成无限递归
|
||||
foreach (Skill skill in Entities.Values)
|
||||
{
|
||||
Factory.OpenFactory.RegisterFactory<Skill>((id, name, args) => skill.Id == id ? ModuleEntityFactory.Create<Skill>(skill.GetType()) : null);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnUnload()
|
||||
{
|
||||
foreach (Skill skill in Entities.Values)
|
||||
{
|
||||
Factory.OpenFactory.UnRegisterFactory<Skill>((id, name, args) => skill.Id == id ? ModuleEntityFactory.Create<Skill>(skill.GetType()) : null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Oshima 物品模组:装备(武器/防具/鞋子/饰品)+ 消耗品 + 收藏品 全量注册
|
||||
/// </summary>
|
||||
public class OshimaItemModule : IItemModule
|
||||
{
|
||||
public string Name => "oshima.items";
|
||||
public string Version => "1.0.0";
|
||||
public string Author => "Oshima Studios";
|
||||
public string Description => "Oshima 物品模组:装备 / 消耗品 / JSON 配置物品(移植自 FunGame.Testing-v3)";
|
||||
|
||||
/// <summary>JSON 配置物品数量(modules/oshima-studios/oshima.fungame.items.json)</summary>
|
||||
public static int JsonItemCount { get; private set; }
|
||||
|
||||
private IReadOnlyDictionary<string, Item>? _entities;
|
||||
|
||||
public IReadOnlyDictionary<string, Item> Entities
|
||||
{
|
||||
get
|
||||
{
|
||||
_entities ??= BuildEntities();
|
||||
return _entities;
|
||||
}
|
||||
}
|
||||
|
||||
private static IReadOnlyDictionary<string, Item> BuildEntities()
|
||||
{
|
||||
Dictionary<string, Item> items = new();
|
||||
|
||||
// ===== JSON 配置物品(EntityModuleConfig 通道:modules/oshima-studios/oshima.fungame.items.json)=====
|
||||
try
|
||||
{
|
||||
Dictionary<string, Item> jsonItems = Factory.GetGameModuleInstances<Item>(OshimaGameModuleConstant.General, OshimaGameModuleConstant.Item);
|
||||
foreach ((string key, Item item) in jsonItems)
|
||||
{
|
||||
items[$"oshima_json_{key}"] = item;
|
||||
}
|
||||
JsonItemCount = jsonItems.Count;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
JsonItemCount = -1; // JSON 缺失或解析失败(代码物品仍可用)
|
||||
}
|
||||
|
||||
// ===== 代码注册物品 =====
|
||||
int seq = 0;
|
||||
Item[] all =
|
||||
[
|
||||
// ===== 武器 =====
|
||||
new 攻击之爪10(), new 攻击之爪25(), new 攻击之爪40(), new 攻击之爪55(), new 攻击之爪70(), new 攻击之爪85(), new 糖糖一周年纪念武器(),
|
||||
// ===== 防具 =====
|
||||
new 糖糖一周年纪念防具(),
|
||||
// ===== 鞋子 =====
|
||||
new 糖糖一周年纪念鞋子(),
|
||||
// ===== 饰品 =====
|
||||
new 糖糖一周年纪念饰品1(), new 糖糖一周年纪念饰品2(),
|
||||
// ===== 消耗品 =====
|
||||
new 小经验书(), new 中经验书(), new 大经验书(), new 升华之印(), new 流光之印(), new 永恒之印(), new 技能卷轴(), new 智慧之果(), new 奥术符文(), new 混沌之核(),
|
||||
new 小回复药(), new 中回复药(), new 大回复药(), new 魔力填充剂1(), new 魔力填充剂2(), new 魔力填充剂3(), new 能量饮料1(), new 能量饮料2(), new 能量饮料3(), new 年夜饭(), new 蛇年大吉(), new 新春快乐(), new 毕业礼包(),
|
||||
new 复苏药1(), new 复苏药2(), new 复苏药3(), new 全回复药(), new 魔法卡礼包(), new 奖券(), new 十连奖券(), new 改名卡(), new 原初之印(), new 创生之印(), new 法则精粹(), new 大师锻造券(),
|
||||
new 一周年纪念礼包(), new 一周年纪念套装(), new 冬至快乐(), new 圣诞礼包(), new 元旦快乐()
|
||||
];
|
||||
foreach (Item item in all)
|
||||
{
|
||||
items[$"oshima_item_{++seq}"] = item;
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
public void OnLoad(IServiceProvider services)
|
||||
{
|
||||
ILoggerFactory? loggerFactory = services.GetService(typeof(ILoggerFactory)) as ILoggerFactory;
|
||||
ILogger? logger = loggerFactory?.CreateLogger("OshimaItemModule");
|
||||
int total = Entities.Count;
|
||||
int jsonCount = Math.Max(JsonItemCount, 0);
|
||||
logger?.LogInformation("Oshima 物品模组加载:代码物品 {CodeCount} 件 + JSON 配置物品 {JsonCount} 件", total - jsonCount, JsonItemCount);
|
||||
foreach (Item item in Entities.Values)
|
||||
{
|
||||
// 注意:工厂委托必须返回“新实例”,不能用 item.Copy()——Copy 内部会再调 Factory.GetInstance,形成无限递归
|
||||
Factory.OpenFactory.RegisterFactory<Item>((id, name, args) => item.Id == id ? ModuleEntityFactory.Create<Item>(item.GetType()) : null);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnUnload()
|
||||
{
|
||||
foreach (Item item in Entities.Values)
|
||||
{
|
||||
Factory.OpenFactory.UnRegisterFactory<Item>((id, name, args) => item.Id == id ? ModuleEntityFactory.Create<Item>(item.GetType()) : null);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user