From 543887881a6eb22cd47368d8359ba9a0534a5856 Mon Sep 17 00:00:00 2001
From: milimoe <110188673+milimoe@users.noreply.github.com>
Date: Mon, 27 Nov 2023 00:30:00 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0GameMode,=20GameMap,=20GameMo?=
=?UTF-8?q?deLoader=20(#62)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* 添加GameMode, GameMap; 优化了Plugin和RoomType等
* 添加GameModeLoader,重构GameMode和GameMap
* 添加Gaming事件接口
* 添加IGameModeSupported接口
* 为GameMode添加Implement接口
* 为BeforeConnect添加参数
---
Api/Factory/RoomFactory.cs | 4 +-
Api/Utility/Factory.cs | 20 +-
Api/Utility/GameModeLoader.cs | 586 +++++++++++++++
Api/Utility/General.cs | 2 +-
Api/Utility/Implement.cs | 53 +-
Api/Utility/PluginLoader.cs | 18 +-
Controller/RunTimeController.cs | 31 +-
Docs/api.xml | 455 +++++++++---
Entity/System/Room.cs | 7 +-
Interface/Base/IAddon.cs | 12 +
Interface/Base/IGameMap.cs | 7 +
Interface/Base/IGameMode.cs | 9 +
Interface/Base/IPlugin.cs | 7 +-
Interface/Event/Events.cs | 4 +-
Interface/Event/GamingEventHandlers.cs | 237 ++++++
Interface/Event/GamingEvents.cs | 141 ++++
Interface/General/IClient.cs | 3 +
Interface/General/IGameModeSupported.cs | 11 +
.../Example.cs => Addon/ExamplePlugin.cs} | 6 +-
Library/Common/Addon/GameMap.cs | 86 +++
Library/Common/Addon/GameMode.cs | 687 ++++++++++++++++++
.../{Plugin/BasePlugin.cs => Addon/Plugin.cs} | 4 +-
Library/Common/Event/GamingEventArgs.cs | 11 +
Library/Common/Event/RoomEventArgs.cs | 54 +-
Library/Constant/ConstantSet.cs | 116 +--
Library/Constant/FunGameInfo.cs | 20 +-
Library/Constant/General.cs | 61 +-
Library/Constant/MethodEnum.cs | 7 +-
Library/Constant/TypeEnum.cs | 58 +-
Library/SQLScript/Entity/RoomQuery.cs | 16 +-
Model/FunGameConfig.cs | 4 +-
Service/AddonManager.cs | 73 +-
32 files changed, 2527 insertions(+), 283 deletions(-)
create mode 100644 Api/Utility/GameModeLoader.cs
create mode 100644 Interface/Base/IAddon.cs
create mode 100644 Interface/Base/IGameMap.cs
create mode 100644 Interface/Base/IGameMode.cs
create mode 100644 Interface/Event/GamingEventHandlers.cs
create mode 100644 Interface/Event/GamingEvents.cs
create mode 100644 Interface/General/IGameModeSupported.cs
rename Library/Common/{Plugin/Example.cs => Addon/ExamplePlugin.cs} (83%)
create mode 100644 Library/Common/Addon/GameMap.cs
create mode 100644 Library/Common/Addon/GameMode.cs
rename Library/Common/{Plugin/BasePlugin.cs => Addon/Plugin.cs} (99%)
create mode 100644 Library/Common/Event/GamingEventArgs.cs
diff --git a/Api/Factory/RoomFactory.cs b/Api/Factory/RoomFactory.cs
index eb3400a..5bb1b33 100644
--- a/Api/Factory/RoomFactory.cs
+++ b/Api/Factory/RoomFactory.cs
@@ -13,9 +13,9 @@ namespace Milimoe.FunGame.Core.Api.Factory
return RoomFactory.Create();
}
- public static Room Create(long Id = 0, string Roomid = "-1", DateTime? CreateTime = null, User? RoomMaster = null, RoomType RoomType = RoomType.All, RoomState RoomState = RoomState.Created, string Password = "")
+ public static Room Create(long Id = 0, string Roomid = "-1", DateTime? CreateTime = null, User? RoomMaster = null, RoomType RoomType = RoomType.All, string GameMode = "", string GameMap = "", RoomState RoomState = RoomState.Created, string Password = "")
{
- return new Room(Id, Roomid, CreateTime, RoomMaster, RoomType, RoomState, Password);
+ return new Room(Id, Roomid, CreateTime, RoomMaster, RoomType, GameMode, GameMap, RoomState, Password);
}
}
}
diff --git a/Api/Utility/Factory.cs b/Api/Utility/Factory.cs
index fc5ec4f..96ff2d5 100644
--- a/Api/Utility/Factory.cs
+++ b/Api/Utility/Factory.cs
@@ -69,12 +69,14 @@ namespace Milimoe.FunGame.Core.Api.Utility
/// 创建时间
/// 房主
/// 房间类型
+ /// 游戏模组
+ ///
/// 房间状态
/// 房间密码
///
- public static Room GetRoom(long Id = 0, string Roomid = "-1", DateTime? CreateTime = null, User? RoomMaster = null, RoomType RoomType = RoomType.All, RoomState RoomState = RoomState.Created, string Password = "")
+ public static Room GetRoom(long Id = 0, string Roomid = "-1", DateTime? CreateTime = null, User? RoomMaster = null, RoomType RoomType = RoomType.All, string GameMode = "", string GameMap = "", RoomState RoomState = RoomState.Created, string Password = "")
{
- return RoomFactory.Create(Id, Roomid, CreateTime, RoomMaster, RoomType, RoomState, Password);
+ return RoomFactory.Create(Id, Roomid, CreateTime, RoomMaster, RoomType, GameMode, GameMap, RoomState, Password);
}
///
@@ -93,9 +95,11 @@ namespace Milimoe.FunGame.Core.Api.Utility
DateTime CreateTime = (DateTime)DrRoom[RoomQuery.Column_CreateTime];
User RoomMaster = User;
RoomType RoomType = (RoomType)Convert.ToInt32(DrRoom[RoomQuery.Column_RoomType]);
+ string GameMode = (string)DrRoom[RoomQuery.Column_GameMode];
+ string GameMap = (string)DrRoom[RoomQuery.Column_GameMap];
RoomState RoomState = (RoomState)Convert.ToInt32(DrRoom[RoomQuery.Column_RoomState]);
string Password = (string)DrRoom[RoomQuery.Column_Password];
- room = GetRoom(Id, Roomid, CreateTime, RoomMaster, RoomType, RoomState, Password);
+ room = GetRoom(Id, Roomid, CreateTime, RoomMaster, RoomType, GameMode, GameMap, RoomState, Password);
}
return room;
}
@@ -108,10 +112,10 @@ namespace Milimoe.FunGame.Core.Api.Utility
///
public static List GetRooms(DataSet DsRoom, DataSet DsUser)
{
- List list = new()
- {
+ List list =
+ [
General.HallInstance
- };
+ ];
if (DsRoom != null && DsRoom.Tables[0].Rows.Count > 0)
{
foreach (DataRow DrRoom in DsRoom.Tables[0].Rows)
@@ -129,9 +133,11 @@ namespace Milimoe.FunGame.Core.Api.Utility
}
}
RoomType RoomType = (RoomType)Convert.ToInt32(DrRoom[RoomQuery.Column_RoomType]);
+ string GameMode = (string)DrRoom[RoomQuery.Column_GameMode];
+ string GameMap = (string)DrRoom[RoomQuery.Column_GameMap];
RoomState RoomState = (RoomState)Convert.ToInt32(DrRoom[RoomQuery.Column_RoomState]);
string Password = (string)DrRoom[RoomQuery.Column_Password];
- list.Add(GetRoom(Id, Roomid, CreateTime, RoomMaster, RoomType, RoomState, Password));
+ list.Add(GetRoom(Id, Roomid, CreateTime, RoomMaster, RoomType, GameMode, GameMap, RoomState, Password));
}
}
return list;
diff --git a/Api/Utility/GameModeLoader.cs b/Api/Utility/GameModeLoader.cs
new file mode 100644
index 0000000..663fc87
--- /dev/null
+++ b/Api/Utility/GameModeLoader.cs
@@ -0,0 +1,586 @@
+using Milimoe.FunGame.Core.Library.Common.Addon;
+using Milimoe.FunGame.Core.Library.Common.Event;
+using Milimoe.FunGame.Core.Service;
+
+namespace Milimoe.FunGame.Core.Api.Utility
+{
+ public class GameModeLoader
+ {
+ public Dictionary Modes { get; } = [];
+ public Dictionary Maps { get; } = [];
+
+ private GameModeLoader()
+ {
+
+ }
+
+ public static GameModeLoader LoadGameModes(params object[] objs)
+ {
+ GameModeLoader loader = new();
+ AddonManager.LoadGameModes(loader.Modes, objs);
+ AddonManager.LoadGameMaps(loader.Maps, objs);
+ return loader;
+ }
+
+ public GameMode this[string name]
+ {
+ get
+ {
+ return Modes[name];
+ }
+ set
+ {
+ Modes.TryAdd(name, value);
+ }
+ }
+
+ public GameMap GetGameMap(string name)
+ {
+ return Maps[name];
+ }
+
+ public void OnBeforeConnectEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnBeforeGamingConnectEvent(sender, e);
+ });
+ }
+
+ public void OnAfterConnectEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnAfterGamingConnectEvent(sender, e);
+ });
+ }
+
+ public void OnSucceedConnectEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnSucceedGamingConnectEvent(sender, e);
+ });
+ }
+
+ public void OnFailedConnectEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnFailedGamingConnectEvent(sender, e);
+ });
+ }
+
+ public void OnBeforeDisonnectEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnBeforeGamingDisconnectEvent(sender, e);
+ });
+ }
+
+ public void OnAfterDisconnectEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnAfterGamingDisconnectEvent(sender, e);
+ });
+ }
+
+ public void OnSucceedDisconnectEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnSucceedGamingDisconnectEvent(sender, e);
+ });
+ }
+
+ public void OnFailedDisconnectEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnFailedGamingDisconnectEvent(sender, e);
+ });
+ }
+
+ public void OnBeforeReconnectEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnBeforeGamingReconnectEvent(sender, e);
+ });
+ }
+
+ public void OnAfterReconnectEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnAfterGamingReconnectEvent(sender, e);
+ });
+ }
+
+ public void OnSucceedReconnectEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnSucceedGamingReconnectEvent(sender, e);
+ });
+ }
+
+ public void OnFailedReconnectEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnFailedGamingReconnectEvent(sender, e);
+ });
+ }
+
+ public void OnBeforeBanCharacterEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnBeforeGamingBanCharacterEvent(sender, e);
+ });
+ }
+
+ public void OnAfterBanCharacterEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnAfterGamingBanCharacterEvent(sender, e);
+ });
+ }
+
+ public void OnSucceedBanCharacterEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnSucceedGamingBanCharacterEvent(sender, e);
+ });
+ }
+
+ public void OnFailedBanCharacterEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnFailedGamingBanCharacterEvent(sender, e);
+ });
+ }
+
+ public void OnBeforePickCharacterEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnBeforeGamingPickCharacterEvent(sender, e);
+ });
+ }
+
+ public void OnAfterPickCharacterEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnAfterGamingPickCharacterEvent(sender, e);
+ });
+ }
+
+ public void OnSucceedPickCharacterEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnSucceedGamingPickCharacterEvent(sender, e);
+ });
+ }
+
+ public void OnFailedPickCharacterEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnFailedGamingPickCharacterEvent(sender, e);
+ });
+ }
+
+ public void OnBeforeRandomEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnBeforeGamingRandomEvent(sender, e);
+ });
+ }
+
+ public void OnAfterRandomEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnAfterGamingRandomEvent(sender, e);
+ });
+ }
+
+ public void OnSucceedRandomEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnSucceedGamingRandomEvent(sender, e);
+ });
+ }
+
+ public void OnFailedRandomEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnFailedGamingRandomEvent(sender, e);
+ });
+ }
+
+ public void OnBeforeMoveEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnBeforeGamingMoveEvent(sender, e);
+ });
+ }
+
+ public void OnAfterMoveEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnAfterGamingMoveEvent(sender, e);
+ });
+ }
+
+ public void OnSucceedMoveEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnSucceedGamingMoveEvent(sender, e);
+ });
+ }
+
+ public void OnFailedMoveEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnFailedGamingMoveEvent(sender, e);
+ });
+ }
+
+ public void OnBeforeAttackEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnBeforeGamingAttackEvent(sender, e);
+ });
+ }
+
+ public void OnAfterAttackEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnAfterGamingAttackEvent(sender, e);
+ });
+ }
+
+ public void OnSucceedAttackEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnSucceedGamingAttackEvent(sender, e);
+ });
+ }
+
+ public void OnFailedAttackEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnFailedGamingAttackEvent(sender, e);
+ });
+ }
+
+ public void OnBeforeSkillEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnBeforeGamingSkillEvent(sender, e);
+ });
+ }
+
+ public void OnAfterSkillEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnAfterGamingSkillEvent(sender, e);
+ });
+ }
+
+ public void OnSucceedSkillEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnSucceedGamingSkillEvent(sender, e);
+ });
+ }
+
+ public void OnFailedSkillEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnFailedGamingSkillEvent(sender, e);
+ });
+ }
+
+ public void OnBeforeItemEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnBeforeGamingItemEvent(sender, e);
+ });
+ }
+
+ public void OnAfterItemEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnAfterGamingItemEvent(sender, e);
+ });
+ }
+
+ public void OnSucceedItemEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnSucceedGamingItemEvent(sender, e);
+ });
+ }
+
+ public void OnFailedItemEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnFailedGamingItemEvent(sender, e);
+ });
+ }
+
+ public void OnBeforeMagicEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnBeforeGamingMagicEvent(sender, e);
+ });
+ }
+
+ public void OnAfterMagicEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnAfterGamingMagicEvent(sender, e);
+ });
+ }
+
+ public void OnSucceedMagicEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnSucceedGamingMagicEvent(sender, e);
+ });
+ }
+
+ public void OnFailedMagicEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnFailedGamingMagicEvent(sender, e);
+ });
+ }
+
+ public void OnBeforeBuyEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnBeforeGamingBuyEvent(sender, e);
+ });
+ }
+
+ public void OnAfterBuyEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnAfterGamingBuyEvent(sender, e);
+ });
+ }
+
+ public void OnSucceedBuyEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnSucceedGamingBuyEvent(sender, e);
+ });
+ }
+
+ public void OnFailedBuyEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnFailedGamingBuyEvent(sender, e);
+ });
+ }
+
+ public void OnBeforeSuperSkillEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnBeforeGamingSuperSkillEvent(sender, e);
+ });
+ }
+
+ public void OnAfterSuperSkillEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnAfterGamingSuperSkillEvent(sender, e);
+ });
+ }
+
+ public void OnSucceedSuperSkillEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnSucceedGamingSuperSkillEvent(sender, e);
+ });
+ }
+
+ public void OnFailedSuperSkillEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnFailedGamingSuperSkillEvent(sender, e);
+ });
+ }
+
+ public void OnBeforePauseEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnBeforeGamingPauseEvent(sender, e);
+ });
+ }
+
+ public void OnAfterPauseEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnAfterGamingPauseEvent(sender, e);
+ });
+ }
+
+ public void OnSucceedPauseEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnSucceedGamingPauseEvent(sender, e);
+ });
+ }
+
+ public void OnFailedPauseEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnFailedGamingPauseEvent(sender, e);
+ });
+ }
+
+ public void OnBeforeUnpauseEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnBeforeGamingUnpauseEvent(sender, e);
+ });
+ }
+
+ public void OnAfterUnpauseEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnAfterGamingUnpauseEvent(sender, e);
+ });
+ }
+
+ public void OnSucceedUnpauseEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnSucceedGamingUnpauseEvent(sender, e);
+ });
+ }
+
+ public void OnFailedUnpauseEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnFailedGamingUnpauseEvent(sender, e);
+ });
+ }
+
+ public void OnBeforeSurrenderEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnBeforeGamingSurrenderEvent(sender, e);
+ });
+ }
+
+ public void OnAfterSurrenderEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnAfterGamingSurrenderEvent(sender, e);
+ });
+ }
+
+ public void OnSucceedSurrenderEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnSucceedGamingSurrenderEvent(sender, e);
+ });
+ }
+
+ public void OnFailedSurrenderEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnFailedGamingSurrenderEvent(sender, e);
+ });
+ }
+
+ public void OnBeforeUpdateInfoEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnBeforeGamingUpdateInfoEvent(sender, e);
+ });
+ }
+
+ public void OnAfterUpdateInfoEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnAfterGamingUpdateInfoEvent(sender, e);
+ });
+ }
+
+ public void OnSucceedUpdateInfoEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnSucceedGamingUpdateInfoEvent(sender, e);
+ });
+ }
+
+ public void OnFailedUpdateInfoEvent(object sender, GamingEventArgs e)
+ {
+ Parallel.ForEach(Modes.Values, mode =>
+ {
+ mode.OnFailedGamingUpdateInfoEvent(sender, e);
+ });
+ }
+ }
+}
diff --git a/Api/Utility/General.cs b/Api/Utility/General.cs
index 853a98e..c3d2514 100644
--- a/Api/Utility/General.cs
+++ b/Api/Utility/General.cs
@@ -49,7 +49,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
for (int i = 0; i < str.Length; i++)
{
char c = str[i];
- if (c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '0' && c <= '9') length++;
+ if (c is >= 'A' and <= 'Z' or >= 'a' and <= 'z' or >= '0' and <= '9') length++;
else length += 2;
}
return length;
diff --git a/Api/Utility/Implement.cs b/Api/Utility/Implement.cs
index f7bd923..30c4bbf 100644
--- a/Api/Utility/Implement.cs
+++ b/Api/Utility/Implement.cs
@@ -4,7 +4,7 @@ using Milimoe.FunGame.Core.Library.Constant;
namespace Milimoe.FunGame.Core.Api.Utility
{
///
- /// See: , ,
+ /// See: , ,
///
public class Implement
{
@@ -43,12 +43,13 @@ namespace Milimoe.FunGame.Core.Api.Utility
{
InterfaceType.IClient => InterfaceSet.Type.IClient,
InterfaceType.IServer => InterfaceSet.Type.IServer,
+ InterfaceType.IGameModeSupported => InterfaceSet.Type.IGameModeSupported,
_ => ""
};
}
///
- /// 获取接口方法名
+ /// 获取接口方法名(支持属性)
///
/// 方法
///
@@ -59,34 +60,54 @@ namespace Milimoe.FunGame.Core.Api.Utility
InterfaceMethod.RemoteServerIP => InterfaceSet.Method.RemoteServerIP,
InterfaceMethod.DBConnection => InterfaceSet.Method.DBConnection,
InterfaceMethod.GetServerSettings => InterfaceSet.Method.GetServerSettings,
+ InterfaceMethod.GameModeList => InterfaceSet.Method.GameModeList,
+ InterfaceMethod.GameMapList => InterfaceSet.Method.GameMapList,
_ => ""
};
}
///
- /// 公开方法:获取FunGame.Implement.DLL中指定方法的返回值
+ /// 公开方法:获取FunGame.Implement.DLL中指定方法(属性)的返回值
///
/// 接口代号
- /// 方法代号
+ /// 方法代号(支持属性)
+ /// 是否是方法(如是属性请传入false)
///
- public static object? GetFunGameImplValue(InterfaceType Interface, InterfaceMethod Method)
+ public static object? GetFunGameImplValue(InterfaceType Interface, InterfaceMethod Method, bool IsMethod = true)
{
MethodInfo? MethodInfo;
+ PropertyInfo? PropertyInfo;
+ // 反射读取程序集
Assembly? Assembly = System.Reflection.Assembly.LoadFile(ReflectionSet.EXEFolderPath + ReflectionSet.FUNGAME_IMPL + ".dll");
- Type? Type = GetFunGameImplementType(Assembly, Interface); // 通过类名获取命名空间+类名称
- string MethodName = GetImplementMethodName(Method); // 获取方法名
+ // 通过类名获取命名空间+类名称
+ Type? Type = GetFunGameImplementType(Assembly, Interface);
- if (Assembly != null && Type != null) MethodInfo = Type.GetMethod(MethodName); // 从Type中查找方法名
- else return null;
-
- object? Instance = Assembly.CreateInstance(Type.Namespace + "." + Type.Name);
- if (Instance != null && MethodInfo != null)
+ if (Assembly != null && Type != null)
{
- object? value = MethodInfo.Invoke(Instance, Array.Empty
/// 连接服务器后返回的一些数据,可以使用也可以修改它们
///
- public virtual void AfterConnect(object[] ConnectArgs)
+ public virtual void AfterConnect(ArrayList ConnectArgs)
{
}
@@ -342,7 +351,7 @@ namespace Milimoe.FunGame.Core.Controller
case SocketMessageType.EndGame:
SocketHandler_EndGame(ServerMessage);
break;
-
+
case SocketMessageType.Gaming:
SocketHandler_Gaming(ServerMessage);
break;
@@ -408,7 +417,7 @@ namespace Milimoe.FunGame.Core.Controller
///
///
protected abstract void SocketHandler_StartGame(SocketObject ServerMessage);
-
+
///
/// 客户端接收到游戏结束信息后的处理方法
///
diff --git a/Docs/api.xml b/Docs/api.xml
index c9df2b3..7b3ec74 100644
--- a/Docs/api.xml
+++ b/Docs/api.xml
@@ -235,7 +235,7 @@
-
+
获取房间实例
@@ -244,6 +244,8 @@
创建时间
房主
房间类型
+ 游戏模组
+
房间状态
房间密码
@@ -561,7 +563,7 @@
- See: , ,
+ See: , ,
@@ -581,17 +583,18 @@
- 获取接口方法名
+ 获取接口方法名(支持属性)
方法
-
+
- 公开方法:获取FunGame.Implement.DLL中指定方法的返回值
+ 公开方法:获取FunGame.Implement.DLL中指定方法(属性)的返回值
接口代号
- 方法代号
+ 方法代号(支持属性)
+ 是否是方法(如是属性请传入false)
@@ -902,16 +905,17 @@
string:IP地址;int:端口号
-
+
此方法将在连接服务器前触发
客户端可以重写此方法
-
-
+ 服务器IP
+ 服务器端口
+ 重写时可以提供额外的连接参数
false:中止连接
-
+
此方法将在连接服务器后触发(Connect结果返回前)
客户端可以重写此方法
@@ -1110,9 +1114,240 @@
窗体继承这些接口便能实现事件,或为插件预留。
-
+
- 插件需要实现什么事件就继承什么接口
+ 局内事件的接口,与 配套使用
+
+
+
+
+ 这是最基本的接口,要求客户端实现
+
+
+
+
+ 服务端和客户端都应该实现这个接口,用于初始化支持的Mod列表
+
+
+
+
+ 必须继承基类:
+ 继承事件接口并实现其方法来使插件生效。例如继承:
+
+
+
+
+ 地图名称
+
+
+
+
+ 地图描述
+
+
+
+
+ 地图版本
+
+
+
+
+ 地图作者
+
+
+
+
+ 宽度
+
+
+
+
+ 高度
+
+
+
+
+ 格子大小
+
+
+
+
+ 加载标记
+
+
+
+
+ 加载地图
+
+
+
+
+
+
+ 加载后需要做的事
+
+
+
+
+ 允许返回false来阻止加载此地图
+
+
+
+
+
+ 模组名称
+
+
+
+
+ 模组描述
+
+
+
+
+ 模组版本
+
+
+
+
+ 模组作者
+
+
+
+
+ 模组所使用的地图
+
+
+
+
+ 加载标记
+
+
+
+
+ 加载模组
+
+
+
+
+ 模组加载后需要做的事
+
+
+
+
+ 允许返回false来阻止加载此模组
+
+
+
+
+
+ 传递委托以便让模组调用
+
+
+
+
+ 输出系统消息
+
+
+
+
+ 基于本地已连接的Socket创建新的数据请求
+
+
+
+
+ 基于本地已连接的Socket创建长时间运行的数据请求
+
+
+
+
+ Session对象
+
+
+
+
+ Config对象
+
+
+
+
+ 绑定事件。在后触发
+
+
+
+
+ 插件名称
+
+
+
+
+ 插件描述
+
+
+
+
+ 插件版本
+
+
+
+
+ 插件作者
+
+
+
+
+ 加载标记
+
+
+
+
+ 加载插件
+
+
+
+
+ 插件加载后需要做的事
+
+
+
+
+ 允许返回false来阻止加载此插件
+
+
+
+
+
+ 传递委托以便让插件调用
+
+
+
+
+ 输出系统消息
+
+
+
+
+ 基于本地已连接的Socket创建新的数据请求
+
+
+
+
+ 基于本地已连接的Socket创建长时间运行的数据请求
+
+
+
+
+ Session对象
+
+
+
+
+ Config对象
+
+
+
+
+ 绑定事件。在后触发
@@ -1332,86 +1567,9 @@
类型的参数
索引超过数组上限
-
+
- 插件名称
-
-
-
-
- 插件描述
-
-
-
-
- 插件版本
-
-
-
-
- 插件作者
-
-
-
-
- 加载标记
-
-
-
-
- 加载插件
-
-
-
-
- 插件加载后需要做的事
-
-
-
-
- 允许返回false来阻止加载此插件
-
-
-
-
-
- 传递委托以便让插件调用
-
-
-
-
- 输出系统消息
-
-
-
-
- 基于本地已连接的Socket创建新的数据请求
-
-
-
-
- 基于本地已连接的Socket创建长时间运行的数据请求
-
-
-
-
- Session对象
-
-
-
-
- Config对象
-
-
-
-
- 绑定事件。在后触发
-
-
-
-
- 必须继承基类:
- 继承事件接口并实现其方法来使插件生效。例如继承:
+ 配合 使用,也别忘了修改
@@ -1446,7 +1604,7 @@
Room
-
+
Gaming
@@ -1456,14 +1614,21 @@
-
+
获取Type的等效字符串
-
+
+
+ 获取Type的等效字符串
+
+
+
+
+
获取字符串对应的枚举
@@ -1476,6 +1641,86 @@
目前支持禁用心跳检测功能
+
+
+ 此类保存常用的对象常量
+
+
+
+
+ 空的实体类 用于object返回
+
+
+
+
+ 默认的未知用户
+
+
+
+
+ 大厅(空房间)实例
+
+
+
+
+ 默认的字符编码
+
+
+
+
+ 默认的时间格式
+
+
+
+
+ 默认的时间值(1970年8月1日8点0分0秒)
+
+
+
+
+ 最多自动重试连接次数
+
+
+
+
+ 1C2G推荐的任务数量
+
+
+
+
+ 2C2G推荐的任务数量
+
+
+
+
+ 4C4G推荐的任务数量
+
+
+
+
+ 默认Socket数据包大小
+
+
+
+
+ 默认Stream传输大小
+
+
+
+
+ 配合 使用,也别忘了修改
+
+
+
+
+ 配合 使用,也别忘了修改
+
+
+
+
+ 配合 使用
+
+
需要同步更新
@@ -1524,9 +1769,9 @@
是否在房间中
-
+
- 当前游戏模式
+ 当前所处的房间类型
@@ -1589,7 +1834,7 @@
所处的房间
-
+
从plugins目录加载所有插件
@@ -1597,6 +1842,22 @@
+
+
+ 从gamemodes目录加载所有模组
+
+
+
+
+
+
+
+ 从gamemaps目录加载所有地图
+
+
+
+
+
默认的序列化选项
diff --git a/Entity/System/Room.cs b/Entity/System/Room.cs
index 237718d..4917bfe 100644
--- a/Entity/System/Room.cs
+++ b/Entity/System/Room.cs
@@ -10,8 +10,11 @@ namespace Milimoe.FunGame.Core.Entity
public string Roomid { get; set; } = "-1";
public DateTime CreateTime { get; set; } = General.DefaultTime;
public User RoomMaster { get; set; } = General.UnknownUserInstance;
- public RoomType RoomType { get; set; }
+ public RoomType RoomType { get; set; } = RoomType.All;
+ public string GameMode { get; set; } = "";
+ public string GameMap { get; set; } = "";
public RoomState RoomState { get; set; }
+ public bool IsRank { get; set; } = false;
public bool HasPass => Password.Trim() != "";
public string Password { get; set; } = "";
public GameStatistics Statistics { get; set; }
@@ -21,7 +24,7 @@ namespace Milimoe.FunGame.Core.Entity
Statistics = new(this);
}
- internal Room(long Id = 0, string Roomid = "-1", DateTime? CreateTime = null, User? RoomMaster = null, RoomType RoomType = RoomType.All, RoomState RoomState = RoomState.Created, string Password = "")
+ internal Room(long Id = 0, string Roomid = "-1", DateTime? CreateTime = null, User? RoomMaster = null, RoomType RoomType = RoomType.All, string GameMode = "", string GameMap = "", RoomState RoomState = RoomState.Created, string Password = "")
{
this.Id = Id;
this.Roomid = Roomid;
diff --git a/Interface/Base/IAddon.cs b/Interface/Base/IAddon.cs
new file mode 100644
index 0000000..d27ab52
--- /dev/null
+++ b/Interface/Base/IAddon.cs
@@ -0,0 +1,12 @@
+namespace Milimoe.FunGame.Core.Interface
+{
+ public interface IAddon
+ {
+ public string Name { get; }
+ public string Description { get; }
+ public string Version { get; }
+ public string Author { get; }
+
+ public bool Load(params object[] objs);
+ }
+}
diff --git a/Interface/Base/IGameMap.cs b/Interface/Base/IGameMap.cs
new file mode 100644
index 0000000..0110057
--- /dev/null
+++ b/Interface/Base/IGameMap.cs
@@ -0,0 +1,7 @@
+namespace Milimoe.FunGame.Core.Interface
+{
+ public interface IGameMap : IAddon
+ {
+
+ }
+}
diff --git a/Interface/Base/IGameMode.cs b/Interface/Base/IGameMode.cs
new file mode 100644
index 0000000..69309d3
--- /dev/null
+++ b/Interface/Base/IGameMode.cs
@@ -0,0 +1,9 @@
+namespace Milimoe.FunGame.Core.Interface
+{
+ public interface IGameMode : IAddon, IGamingConnectEventHandler, IGamingDisconnectEventHandler, IGamingReconnectEventHandler, IGamingBanCharacterEventHandler, IGamingPickCharacterEventHandler,
+ IGamingRandomEventHandler, IGamingMoveEventHandler, IGamingAttackEventHandler, IGamingSkillEventHandler, IGamingItemEventHandler, IGamingMagicEventHandler, IGamingBuyEventHandler,
+ IGamingSuperSkillEventHandler, IGamingPauseEventHandler, IGamingUnpauseEventHandler, IGamingSurrenderEventHandler, IGamingUpdateInfoEventHandler
+ {
+
+ }
+}
diff --git a/Interface/Base/IPlugin.cs b/Interface/Base/IPlugin.cs
index b4954d8..415a436 100644
--- a/Interface/Base/IPlugin.cs
+++ b/Interface/Base/IPlugin.cs
@@ -1,14 +1,9 @@
namespace Milimoe.FunGame.Core.Interface
{
- public interface IPlugin : IConnectEventHandler, IDisconnectEventHandler, ILoginEventHandler, ILogoutEventHandler, IRegEventHandler, IIntoRoomEventHandler, ISendTalkEventHandler,
+ public interface IPlugin : IAddon, IConnectEventHandler, IDisconnectEventHandler, ILoginEventHandler, ILogoutEventHandler, IRegEventHandler, IIntoRoomEventHandler, ISendTalkEventHandler,
ICreateRoomEventHandler, IQuitRoomEventHandler, IChangeRoomSettingEventHandler, IStartMatchEventHandler, IStartGameEventHandler, IChangeProfileEventHandler, IChangeAccountSettingEventHandler,
IOpenInventoryEventHandler, ISignInEventHandler, IOpenStoreEventHandler, IBuyItemEventHandler, IShowRankingEventHandler, IUseItemEventHandler, IEndGameEventHandler
{
- public string Name { get; }
- public string Description { get; }
- public string Version { get; }
- public string Author { get; }
- public bool Load(params object[] objs);
}
}
diff --git a/Interface/Event/Events.cs b/Interface/Event/Events.cs
index 4fc5a7c..eaee217 100644
--- a/Interface/Event/Events.cs
+++ b/Interface/Event/Events.cs
@@ -1,10 +1,8 @@
using Milimoe.FunGame.Core.Library.Common.Event;
+// 插件需要实现什么事件就继承什么接口
namespace Milimoe.FunGame.Core.Interface
{
- ///
- /// 插件需要实现什么事件就继承什么接口
- ///
public interface IConnectEvent
{
public void BeforeConnectEvent(object sender, ConnectEventArgs e);
diff --git a/Interface/Event/GamingEventHandlers.cs b/Interface/Event/GamingEventHandlers.cs
new file mode 100644
index 0000000..6f2e144
--- /dev/null
+++ b/Interface/Event/GamingEventHandlers.cs
@@ -0,0 +1,237 @@
+using Milimoe.FunGame.Core.Library.Common.Addon;
+using Milimoe.FunGame.Core.Library.Common.Event;
+
+namespace Milimoe.FunGame.Core.Interface
+{
+ ///
+ /// 局内事件的接口,与 配套使用
+ ///
+ public interface IGamingEventHandler
+ {
+ public delegate void BeforeEventHandler(object sender, GamingEventArgs e);
+ public delegate void AfterEventHandler(object sender, GamingEventArgs e);
+ public delegate void SucceedEventHandler(object sender, GamingEventArgs e);
+ public delegate void FailedEventHandler(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingConnectEventHandler : IGamingEventHandler
+ {
+ public event BeforeEventHandler? BeforeGamingConnect;
+ public event AfterEventHandler? AfterGamingConnect;
+ public event SucceedEventHandler? SucceedGamingConnect;
+ public event FailedEventHandler? FailedGamingConnect;
+
+ public void OnBeforeGamingConnectEvent(object sender, GamingEventArgs e);
+ public void OnAfterGamingConnectEvent(object sender, GamingEventArgs e);
+ public void OnSucceedGamingConnectEvent(object sender, GamingEventArgs e);
+ public void OnFailedGamingConnectEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingDisconnectEventHandler : IGamingEventHandler
+ {
+ public event BeforeEventHandler? BeforeGamingDisconnect;
+ public event AfterEventHandler? AfterGamingDisconnect;
+ public event SucceedEventHandler? SucceedGamingDisconnect;
+ public event FailedEventHandler? FailedGamingDisconnect;
+
+ public void OnBeforeGamingDisconnectEvent(object sender, GamingEventArgs e);
+ public void OnAfterGamingDisconnectEvent(object sender, GamingEventArgs e);
+ public void OnSucceedGamingDisconnectEvent(object sender, GamingEventArgs e);
+ public void OnFailedGamingDisconnectEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingReconnectEventHandler : IGamingEventHandler
+ {
+ public event BeforeEventHandler? BeforeGamingReconnect;
+ public event AfterEventHandler? AfterGamingReconnect;
+ public event SucceedEventHandler? SucceedGamingReconnect;
+ public event FailedEventHandler? FailedGamingReconnect;
+
+ public void OnBeforeGamingReconnectEvent(object sender, GamingEventArgs e);
+ public void OnAfterGamingReconnectEvent(object sender, GamingEventArgs e);
+ public void OnSucceedGamingReconnectEvent(object sender, GamingEventArgs e);
+ public void OnFailedGamingReconnectEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingBanCharacterEventHandler : IGamingEventHandler
+ {
+ public event BeforeEventHandler? BeforeGamingBanCharacter;
+ public event AfterEventHandler? AfterGamingBanCharacter;
+ public event SucceedEventHandler? SucceedGamingBanCharacter;
+ public event FailedEventHandler? FailedGamingBanCharacter;
+
+ public void OnBeforeGamingBanCharacterEvent(object sender, GamingEventArgs e);
+ public void OnAfterGamingBanCharacterEvent(object sender, GamingEventArgs e);
+ public void OnSucceedGamingBanCharacterEvent(object sender, GamingEventArgs e);
+ public void OnFailedGamingBanCharacterEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingPickCharacterEventHandler : IGamingEventHandler
+ {
+ public event BeforeEventHandler? BeforeGamingPickCharacter;
+ public event AfterEventHandler? AfterGamingPickCharacter;
+ public event SucceedEventHandler? SucceedGamingPickCharacter;
+ public event FailedEventHandler? FailedGamingPickCharacter;
+
+ public void OnBeforeGamingPickCharacterEvent(object sender, GamingEventArgs e);
+ public void OnAfterGamingPickCharacterEvent(object sender, GamingEventArgs e);
+ public void OnSucceedGamingPickCharacterEvent(object sender, GamingEventArgs e);
+ public void OnFailedGamingPickCharacterEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingRandomEventHandler : IGamingEventHandler
+ {
+ public event BeforeEventHandler? BeforeGamingRandom;
+ public event AfterEventHandler? AfterGamingRandom;
+ public event SucceedEventHandler? SucceedGamingRandom;
+ public event FailedEventHandler? FailedGamingRandom;
+
+ public void OnBeforeGamingRandomEvent(object sender, GamingEventArgs e);
+ public void OnAfterGamingRandomEvent(object sender, GamingEventArgs e);
+ public void OnSucceedGamingRandomEvent(object sender, GamingEventArgs e);
+ public void OnFailedGamingRandomEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingMoveEventHandler : IGamingEventHandler
+ {
+ public event BeforeEventHandler? BeforeGamingMove;
+ public event AfterEventHandler? AfterGamingMove;
+ public event SucceedEventHandler? SucceedGamingMove;
+ public event FailedEventHandler? FailedGamingMove;
+
+ public void OnBeforeGamingMoveEvent(object sender, GamingEventArgs e);
+ public void OnAfterGamingMoveEvent(object sender, GamingEventArgs e);
+ public void OnSucceedGamingMoveEvent(object sender, GamingEventArgs e);
+ public void OnFailedGamingMoveEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingAttackEventHandler : IGamingEventHandler
+ {
+ public event BeforeEventHandler? BeforeGamingAttack;
+ public event AfterEventHandler? AfterGamingAttack;
+ public event SucceedEventHandler? SucceedGamingAttack;
+ public event FailedEventHandler? FailedGamingAttack;
+
+ public void OnBeforeGamingAttackEvent(object sender, GamingEventArgs e);
+ public void OnAfterGamingAttackEvent(object sender, GamingEventArgs e);
+ public void OnSucceedGamingAttackEvent(object sender, GamingEventArgs e);
+ public void OnFailedGamingAttackEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingSkillEventHandler : IGamingEventHandler
+ {
+ public event BeforeEventHandler? BeforeGamingSkill;
+ public event AfterEventHandler? AfterGamingSkill;
+ public event SucceedEventHandler? SucceedGamingSkill;
+ public event FailedEventHandler? FailedGamingSkill;
+
+ public void OnBeforeGamingSkillEvent(object sender, GamingEventArgs e);
+ public void OnAfterGamingSkillEvent(object sender, GamingEventArgs e);
+ public void OnSucceedGamingSkillEvent(object sender, GamingEventArgs e);
+ public void OnFailedGamingSkillEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingItemEventHandler : IGamingEventHandler
+ {
+ public event BeforeEventHandler? BeforeGamingItem;
+ public event AfterEventHandler? AfterGamingItem;
+ public event SucceedEventHandler? SucceedGamingItem;
+ public event FailedEventHandler? FailedGamingItem;
+
+ public void OnBeforeGamingItemEvent(object sender, GamingEventArgs e);
+ public void OnAfterGamingItemEvent(object sender, GamingEventArgs e);
+ public void OnSucceedGamingItemEvent(object sender, GamingEventArgs e);
+ public void OnFailedGamingItemEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingMagicEventHandler : IGamingEventHandler
+ {
+ public event BeforeEventHandler? BeforeGamingMagic;
+ public event AfterEventHandler? AfterGamingMagic;
+ public event SucceedEventHandler? SucceedGamingMagic;
+ public event FailedEventHandler? FailedGamingMagic;
+
+ public void OnBeforeGamingMagicEvent(object sender, GamingEventArgs e);
+ public void OnAfterGamingMagicEvent(object sender, GamingEventArgs e);
+ public void OnSucceedGamingMagicEvent(object sender, GamingEventArgs e);
+ public void OnFailedGamingMagicEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingBuyEventHandler : IGamingEventHandler
+ {
+ public event BeforeEventHandler? BeforeGamingBuy;
+ public event AfterEventHandler? AfterGamingBuy;
+ public event SucceedEventHandler? SucceedGamingBuy;
+ public event FailedEventHandler? FailedGamingBuy;
+
+ public void OnBeforeGamingBuyEvent(object sender, GamingEventArgs e);
+ public void OnAfterGamingBuyEvent(object sender, GamingEventArgs e);
+ public void OnSucceedGamingBuyEvent(object sender, GamingEventArgs e);
+ public void OnFailedGamingBuyEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingSuperSkillEventHandler : IGamingEventHandler
+ {
+ public event BeforeEventHandler? BeforeGamingSuperSkill;
+ public event AfterEventHandler? AfterGamingSuperSkill;
+ public event SucceedEventHandler? SucceedGamingSuperSkill;
+ public event FailedEventHandler? FailedGamingSuperSkill;
+
+ public void OnBeforeGamingSuperSkillEvent(object sender, GamingEventArgs e);
+ public void OnAfterGamingSuperSkillEvent(object sender, GamingEventArgs e);
+ public void OnSucceedGamingSuperSkillEvent(object sender, GamingEventArgs e);
+ public void OnFailedGamingSuperSkillEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingPauseEventHandler : IGamingEventHandler
+ {
+ public event BeforeEventHandler? BeforeGamingPause;
+ public event AfterEventHandler? AfterGamingPause;
+ public event SucceedEventHandler? SucceedGamingPause;
+ public event FailedEventHandler? FailedGamingPause;
+
+ public void OnBeforeGamingPauseEvent(object sender, GamingEventArgs e);
+ public void OnAfterGamingPauseEvent(object sender, GamingEventArgs e);
+ public void OnSucceedGamingPauseEvent(object sender, GamingEventArgs e);
+ public void OnFailedGamingPauseEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingUnpauseEventHandler : IGamingEventHandler
+ {
+ public event BeforeEventHandler? BeforeGamingUnpause;
+ public event AfterEventHandler? AfterGamingUnpause;
+ public event SucceedEventHandler? SucceedGamingUnpause;
+ public event FailedEventHandler? FailedGamingUnpause;
+
+ public void OnBeforeGamingUnpauseEvent(object sender, GamingEventArgs e);
+ public void OnAfterGamingUnpauseEvent(object sender, GamingEventArgs e);
+ public void OnSucceedGamingUnpauseEvent(object sender, GamingEventArgs e);
+ public void OnFailedGamingUnpauseEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingSurrenderEventHandler : IGamingEventHandler
+ {
+ public event BeforeEventHandler? BeforeGamingSurrender;
+ public event AfterEventHandler? AfterGamingSurrender;
+ public event SucceedEventHandler? SucceedGamingSurrender;
+ public event FailedEventHandler? FailedGamingSurrender;
+
+ public void OnBeforeGamingSurrenderEvent(object sender, GamingEventArgs e);
+ public void OnAfterGamingSurrenderEvent(object sender, GamingEventArgs e);
+ public void OnSucceedGamingSurrenderEvent(object sender, GamingEventArgs e);
+ public void OnFailedGamingSurrenderEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingUpdateInfoEventHandler : IGamingEventHandler
+ {
+ public event BeforeEventHandler? BeforeGamingUpdateInfo;
+ public event AfterEventHandler? AfterGamingUpdateInfo;
+ public event SucceedEventHandler? SucceedGamingUpdateInfo;
+ public event FailedEventHandler? FailedGamingUpdateInfo;
+
+ public void OnBeforeGamingUpdateInfoEvent(object sender, GamingEventArgs e);
+ public void OnAfterGamingUpdateInfoEvent(object sender, GamingEventArgs e);
+ public void OnSucceedGamingUpdateInfoEvent(object sender, GamingEventArgs e);
+ public void OnFailedGamingUpdateInfoEvent(object sender, GamingEventArgs e);
+ }
+}
diff --git a/Interface/Event/GamingEvents.cs b/Interface/Event/GamingEvents.cs
new file mode 100644
index 0000000..9dd10be
--- /dev/null
+++ b/Interface/Event/GamingEvents.cs
@@ -0,0 +1,141 @@
+using Milimoe.FunGame.Core.Library.Common.Event;
+
+// 模组需要实现什么事件就继承什么接口
+namespace Milimoe.FunGame.Core.Interface
+{
+ public interface IGamingConnectEvent
+ {
+ public void BeforeGamingConnectEvent(object sender, GamingEventArgs e);
+ public void AfterGamingConnectEvent(object sender, GamingEventArgs e);
+ public void SucceedGamingConnectEvent(object sender, GamingEventArgs e);
+ public void FailedGamingConnectEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingDisconnectEvent
+ {
+ public void BeforeGamingDisconnectEvent(object sender, GamingEventArgs e);
+ public void AfterGamingDisconnectEvent(object sender, GamingEventArgs e);
+ public void SucceedGamingDisconnectEvent(object sender, GamingEventArgs e);
+ public void FailedGamingDisconnectEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingReconnectEvent
+ {
+ public void BeforeGamingReconnectEvent(object sender, GamingEventArgs e);
+ public void AfterGamingReconnectEvent(object sender, GamingEventArgs e);
+ public void SucceedGamingReconnectEvent(object sender, GamingEventArgs e);
+ public void FailedGamingReconnectEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingBanCharacterEvent
+ {
+ public void BeforeGamingBanCharacterEvent(object sender, GamingEventArgs e);
+ public void AfterGamingBanCharacterEvent(object sender, GamingEventArgs e);
+ public void SucceedGamingBanCharacterEvent(object sender, GamingEventArgs e);
+ public void FailedGamingBanCharacterEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingPickCharacterEvent
+ {
+ public void BeforeGamingPickCharacterEvent(object sender, GamingEventArgs e);
+ public void AfterGamingPickCharacterEvent(object sender, GamingEventArgs e);
+ public void SucceedGamingPickCharacterEvent(object sender, GamingEventArgs e);
+ public void FailedGamingPickCharacterEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingRandomEvent
+ {
+ public void BeforeGamingRandomEvent(object sender, GamingEventArgs e);
+ public void AfterGamingRandomEvent(object sender, GamingEventArgs e);
+ public void SucceedGamingRandomEvent(object sender, GamingEventArgs e);
+ public void FailedGamingRandomEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingMoveEvent
+ {
+ public void BeforeGamingMoveEvent(object sender, GamingEventArgs e);
+ public void AfterGamingMoveEvent(object sender, GamingEventArgs e);
+ public void SucceedGamingMoveEvent(object sender, GamingEventArgs e);
+ public void FailedGamingMoveEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingAttackEvent
+ {
+ public void BeforeGamingAttackEvent(object sender, GamingEventArgs e);
+ public void AfterGamingAttackEvent(object sender, GamingEventArgs e);
+ public void SucceedGamingAttackEvent(object sender, GamingEventArgs e);
+ public void FailedGamingAttackEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingSkillEvent
+ {
+ public void BeforeGamingSkillEvent(object sender, GamingEventArgs e);
+ public void AfterGamingSkillEvent(object sender, GamingEventArgs e);
+ public void SucceedGamingSkillEvent(object sender, GamingEventArgs e);
+ public void FailedGamingSkillEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingItemEvent
+ {
+ public void BeforeGamingItemEvent(object sender, GamingEventArgs e);
+ public void AfterGamingItemEvent(object sender, GamingEventArgs e);
+ public void SucceedGamingItemEvent(object sender, GamingEventArgs e);
+ public void FailedGamingItemEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingMagicEvent
+ {
+ public void BeforeGamingMagicEvent(object sender, GamingEventArgs e);
+ public void AfterGamingMagicEvent(object sender, GamingEventArgs e);
+ public void SucceedGamingMagicEvent(object sender, GamingEventArgs e);
+ public void FailedGamingMagicEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingBuyEvent
+ {
+ public void BeforeGamingBuyEvent(object sender, GamingEventArgs e);
+ public void AfterGamingBuyEvent(object sender, GamingEventArgs e);
+ public void SucceedGamingBuyEvent(object sender, GamingEventArgs e);
+ public void FailedGamingBuyEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingSuperSkillEvent
+ {
+ public void BeforeGamingSuperSkillEvent(object sender, GamingEventArgs e);
+ public void AfterGamingSuperSkillEvent(object sender, GamingEventArgs e);
+ public void SucceedGamingSuperSkillEvent(object sender, GamingEventArgs e);
+ public void FailedGamingSuperSkillEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingPauseEvent
+ {
+ public void BeforeGamingPauseEvent(object sender, GamingEventArgs e);
+ public void AfterGamingPauseEvent(object sender, GamingEventArgs e);
+ public void SucceedGamingPauseEvent(object sender, GamingEventArgs e);
+ public void FailedGamingPauseEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingUnpauseEvent
+ {
+ public void BeforeGamingUnpauseEvent(object sender, GamingEventArgs e);
+ public void AfterGamingUnpauseEvent(object sender, GamingEventArgs e);
+ public void SucceedGamingUnpauseEvent(object sender, GamingEventArgs e);
+ public void FailedGamingUnpauseEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingSurrenderEvent
+ {
+ public void BeforeGamingSurrenderEvent(object sender, GamingEventArgs e);
+ public void AfterGamingSurrenderEvent(object sender, GamingEventArgs e);
+ public void SucceedGamingSurrenderEvent(object sender, GamingEventArgs e);
+ public void FailedGamingSurrenderEvent(object sender, GamingEventArgs e);
+ }
+
+ public interface IGamingUpdateInfoEvent
+ {
+ public void BeforeGamingUpdateInfoEvent(object sender, GamingEventArgs e);
+ public void AfterGamingUpdateInfoEvent(object sender, GamingEventArgs e);
+ public void SucceedGamingUpdateInfoEvent(object sender, GamingEventArgs e);
+ public void FailedGamingUpdateInfoEvent(object sender, GamingEventArgs e);
+ }
+}
diff --git a/Interface/General/IClient.cs b/Interface/General/IClient.cs
index 4ad5b76..252da5e 100644
--- a/Interface/General/IClient.cs
+++ b/Interface/General/IClient.cs
@@ -1,5 +1,8 @@
namespace Milimoe.FunGame.Core.Interface
{
+ ///
+ /// 这是最基本的接口,要求客户端实现
+ ///
public interface IClient
{
public string FunGameIcon { get; }
diff --git a/Interface/General/IGameModeSupported.cs b/Interface/General/IGameModeSupported.cs
new file mode 100644
index 0000000..79e368e
--- /dev/null
+++ b/Interface/General/IGameModeSupported.cs
@@ -0,0 +1,11 @@
+namespace Milimoe.FunGame.Core.Interface
+{
+ ///
+ /// 服务端和客户端都应该实现这个接口,用于初始化支持的Mod列表
+ ///
+ public interface IGameModeSupported
+ {
+ public string[] GameModeList { get; }
+ public string[] GameMapList { get; }
+ }
+}
diff --git a/Library/Common/Plugin/Example.cs b/Library/Common/Addon/ExamplePlugin.cs
similarity index 83%
rename from Library/Common/Plugin/Example.cs
rename to Library/Common/Addon/ExamplePlugin.cs
index dfda4e4..e7b0657 100644
--- a/Library/Common/Plugin/Example.cs
+++ b/Library/Common/Addon/ExamplePlugin.cs
@@ -1,13 +1,13 @@
using Milimoe.FunGame.Core.Interface;
using Milimoe.FunGame.Core.Library.Common.Event;
-namespace Milimoe.FunGame.Core.Library.Common.Plugin
+namespace Milimoe.FunGame.Core.Library.Common.Addon
{
///
- /// 必须继承基类:
+ /// 必须继承基类:
/// 继承事件接口并实现其方法来使插件生效。例如继承:
///
- public class Example : BasePlugin, ILoginEvent
+ public class ExamplePlugin : Plugin, ILoginEvent
{
public override string Name => "FunGame Example Plugin";
diff --git a/Library/Common/Addon/GameMap.cs b/Library/Common/Addon/GameMap.cs
new file mode 100644
index 0000000..01d703a
--- /dev/null
+++ b/Library/Common/Addon/GameMap.cs
@@ -0,0 +1,86 @@
+using Milimoe.FunGame.Core.Interface;
+
+namespace Milimoe.FunGame.Core.Library.Common.Addon
+{
+ public abstract class GameMap : IGameMap
+ {
+ ///
+ /// 地图名称
+ ///
+ public abstract string Name { get; }
+
+ ///
+ /// 地图描述
+ ///
+ public abstract string Description { get; }
+
+ ///
+ /// 地图版本
+ ///
+ public abstract string Version { get; }
+
+ ///
+ /// 地图作者
+ ///
+ public abstract string Author { get; }
+
+ ///
+ /// 宽度
+ ///
+ public abstract float Width { get; }
+
+ ///
+ /// 高度
+ ///
+ public abstract float Height { get; }
+
+ ///
+ /// 格子大小
+ ///
+ public abstract float Size { get; }
+
+ ///
+ /// 加载标记
+ ///
+ private bool IsLoaded = false;
+
+ ///
+ /// 加载地图
+ ///
+ ///
+ ///
+ public bool Load(params object[] objs)
+ {
+ if (IsLoaded)
+ {
+ return false;
+ }
+ // BeforeLoad可以阻止加载此地图
+ if (BeforeLoad())
+ {
+ // 地图加载后,不允许再次加载此地图
+ IsLoaded = true;
+ // 如果加载后需要执行代码,请重写AfterLoad方法
+ AfterLoad();
+ }
+ return IsLoaded;
+ }
+
+ ///
+ /// 加载后需要做的事
+ ///
+ protected virtual void AfterLoad()
+ {
+ // override
+ }
+
+ ///
+ /// 允许返回false来阻止加载此地图
+ ///
+ ///
+ protected virtual bool BeforeLoad()
+ {
+ return true;
+ }
+ }
+}
diff --git a/Library/Common/Addon/GameMode.cs b/Library/Common/Addon/GameMode.cs
new file mode 100644
index 0000000..0ef5269
--- /dev/null
+++ b/Library/Common/Addon/GameMode.cs
@@ -0,0 +1,687 @@
+using Milimoe.FunGame.Core.Api.Transmittal;
+using Milimoe.FunGame.Core.Interface;
+using Milimoe.FunGame.Core.Library.Common.Event;
+using Milimoe.FunGame.Core.Library.Constant;
+using Milimoe.FunGame.Core.Model;
+
+namespace Milimoe.FunGame.Core.Library.Common.Addon
+{
+ public abstract class GameMode : IGameMode
+ {
+ ///
+ /// 模组名称
+ ///
+ public abstract string Name { get; }
+
+ ///
+ /// 模组描述
+ ///
+ public abstract string Description { get; }
+
+ ///
+ /// 模组版本
+ ///
+ public abstract string Version { get; }
+
+ ///
+ /// 模组作者
+ ///
+ public abstract string Author { get; }
+
+ ///
+ /// 模组所使用的地图
+ ///
+ public abstract string Map { get; }
+
+ ///
+ /// 加载标记
+ ///
+ private bool IsLoaded = false;
+
+ ///
+ /// 加载模组
+ ///
+ public bool Load(params object[] objs)
+ {
+ if (IsLoaded)
+ {
+ return false;
+ }
+ // BeforeLoad可以阻止加载此模组
+ if (BeforeLoad())
+ {
+ // 模组加载后,不允许再次加载此模组
+ IsLoaded = true;
+ // 初始化此模组(传入委托或者Model)
+ Init(objs);
+ // 触发绑定事件
+ BindEvent();
+ // 如果加载后需要执行代码,请重写AfterLoad方法
+ AfterLoad();
+ }
+ return IsLoaded;
+ }
+
+ ///
+ /// 模组加载后需要做的事
+ ///
+ protected virtual void AfterLoad()
+ {
+ // override
+ }
+
+ ///
+ /// 允许返回false来阻止加载此模组
+ ///
+ ///
+ protected virtual bool BeforeLoad()
+ {
+ return true;
+ }
+
+ ///
+ /// 传递委托以便让模组调用
+ ///
+ private void Init(params object[] objs)
+ {
+ if (objs.Length > 0) WritelnSystemInfo = (Action)objs[0];
+ if (objs.Length > 1) NewDataRequest = (Func)objs[1];
+ if (objs.Length > 2) NewLongRunningDataRequest = (Func)objs[2];
+ if (objs.Length > 3) Session = (Session)objs[3];
+ if (objs.Length > 4) Config = (FunGameConfig)objs[4];
+ }
+
+ ///
+ /// 输出系统消息
+ ///
+ protected Action WritelnSystemInfo = new(msg => Console.Write("\r" + msg + "\n\r> "));
+
+ ///
+ /// 基于本地已连接的Socket创建新的数据请求
+ ///
+ protected Func NewDataRequest = new(type => throw new ConnectFailedException());
+
+ ///
+ /// 基于本地已连接的Socket创建长时间运行的数据请求
+ ///
+ protected Func NewLongRunningDataRequest = new(type => throw new ConnectFailedException());
+
+ ///
+ /// Session对象
+ ///
+ protected Session Session = new();
+
+ ///
+ /// Config对象
+ ///
+ protected FunGameConfig Config = new();
+
+ ///
+ /// 绑定事件。在后触发
+ ///
+ private void BindEvent()
+ {
+ if (this is IGamingConnectEvent)
+ {
+ IGamingConnectEvent bind = (IGamingConnectEvent)this;
+ BeforeGamingConnect += bind.BeforeGamingConnectEvent;
+ AfterGamingConnect += bind.AfterGamingConnectEvent;
+ SucceedGamingConnect += bind.SucceedGamingConnectEvent;
+ FailedGamingConnect += bind.FailedGamingConnectEvent;
+ }
+
+ if (this is IGamingDisconnectEvent)
+ {
+ IGamingDisconnectEvent bind = (IGamingDisconnectEvent)this;
+ BeforeGamingDisconnect += bind.BeforeGamingDisconnectEvent;
+ AfterGamingDisconnect += bind.AfterGamingDisconnectEvent;
+ SucceedGamingDisconnect += bind.SucceedGamingDisconnectEvent;
+ FailedGamingDisconnect += bind.FailedGamingDisconnectEvent;
+ }
+
+ if (this is IGamingReconnectEvent)
+ {
+ IGamingReconnectEvent bind = (IGamingReconnectEvent)this;
+ BeforeGamingReconnect += bind.BeforeGamingReconnectEvent;
+ AfterGamingReconnect += bind.AfterGamingReconnectEvent;
+ SucceedGamingReconnect += bind.SucceedGamingReconnectEvent;
+ FailedGamingReconnect += bind.FailedGamingReconnectEvent;
+ }
+
+ if (this is IGamingBanCharacterEvent)
+ {
+ IGamingBanCharacterEvent bind = (IGamingBanCharacterEvent)this;
+ BeforeGamingBanCharacter += bind.BeforeGamingBanCharacterEvent;
+ AfterGamingBanCharacter += bind.AfterGamingBanCharacterEvent;
+ SucceedGamingBanCharacter += bind.SucceedGamingBanCharacterEvent;
+ FailedGamingBanCharacter += bind.FailedGamingBanCharacterEvent;
+ }
+
+ if (this is IGamingPickCharacterEvent)
+ {
+ IGamingPickCharacterEvent bind = (IGamingPickCharacterEvent)this;
+ BeforeGamingPickCharacter += bind.BeforeGamingPickCharacterEvent;
+ AfterGamingPickCharacter += bind.AfterGamingPickCharacterEvent;
+ SucceedGamingPickCharacter += bind.SucceedGamingPickCharacterEvent;
+ FailedGamingPickCharacter += bind.FailedGamingPickCharacterEvent;
+ }
+
+ if (this is IGamingRandomEvent)
+ {
+ IGamingRandomEvent bind = (IGamingRandomEvent)this;
+ BeforeGamingRandom += bind.BeforeGamingRandomEvent;
+ AfterGamingRandom += bind.AfterGamingRandomEvent;
+ SucceedGamingRandom += bind.SucceedGamingRandomEvent;
+ FailedGamingRandom += bind.FailedGamingRandomEvent;
+ }
+
+ if (this is IGamingMoveEvent)
+ {
+ IGamingMoveEvent bind = (IGamingMoveEvent)this;
+ BeforeGamingMove += bind.BeforeGamingMoveEvent;
+ AfterGamingMove += bind.AfterGamingMoveEvent;
+ SucceedGamingMove += bind.SucceedGamingMoveEvent;
+ FailedGamingMove += bind.FailedGamingMoveEvent;
+ }
+
+ if (this is IGamingAttackEvent)
+ {
+ IGamingAttackEvent bind = (IGamingAttackEvent)this;
+ BeforeGamingAttack += bind.BeforeGamingAttackEvent;
+ AfterGamingAttack += bind.AfterGamingAttackEvent;
+ SucceedGamingAttack += bind.SucceedGamingAttackEvent;
+ FailedGamingAttack += bind.FailedGamingAttackEvent;
+ }
+
+ if (this is IGamingSkillEvent)
+ {
+ IGamingSkillEvent bind = (IGamingSkillEvent)this;
+ BeforeGamingSkill += bind.BeforeGamingSkillEvent;
+ AfterGamingSkill += bind.AfterGamingSkillEvent;
+ SucceedGamingSkill += bind.SucceedGamingSkillEvent;
+ FailedGamingSkill += bind.FailedGamingSkillEvent;
+ }
+
+ if (this is IGamingItemEvent)
+ {
+ IGamingItemEvent bind = (IGamingItemEvent)this;
+ BeforeGamingItem += bind.BeforeGamingItemEvent;
+ AfterGamingItem += bind.AfterGamingItemEvent;
+ SucceedGamingItem += bind.SucceedGamingItemEvent;
+ FailedGamingItem += bind.FailedGamingItemEvent;
+ }
+
+ if (this is IGamingMagicEvent)
+ {
+ IGamingMagicEvent bind = (IGamingMagicEvent)this;
+ BeforeGamingMagic += bind.BeforeGamingMagicEvent;
+ AfterGamingMagic += bind.AfterGamingMagicEvent;
+ SucceedGamingMagic += bind.SucceedGamingMagicEvent;
+ FailedGamingMagic += bind.FailedGamingMagicEvent;
+ }
+
+ if (this is IGamingBuyEvent)
+ {
+ IGamingBuyEvent bind = (IGamingBuyEvent)this;
+ BeforeGamingBuy += bind.BeforeGamingBuyEvent;
+ AfterGamingBuy += bind.AfterGamingBuyEvent;
+ SucceedGamingBuy += bind.SucceedGamingBuyEvent;
+ FailedGamingBuy += bind.FailedGamingBuyEvent;
+ }
+
+ if (this is IGamingSuperSkillEvent)
+ {
+ IGamingSuperSkillEvent bind = (IGamingSuperSkillEvent)this;
+ BeforeGamingSuperSkill += bind.BeforeGamingSuperSkillEvent;
+ AfterGamingSuperSkill += bind.AfterGamingSuperSkillEvent;
+ SucceedGamingSuperSkill += bind.SucceedGamingSuperSkillEvent;
+ FailedGamingSuperSkill += bind.FailedGamingSuperSkillEvent;
+ }
+
+ if (this is IGamingPauseEvent)
+ {
+ IGamingPauseEvent bind = (IGamingPauseEvent)this;
+ BeforeGamingPause += bind.BeforeGamingPauseEvent;
+ AfterGamingPause += bind.AfterGamingPauseEvent;
+ SucceedGamingPause += bind.SucceedGamingPauseEvent;
+ FailedGamingPause += bind.FailedGamingPauseEvent;
+ }
+
+ if (this is IGamingUnpauseEvent)
+ {
+ IGamingUnpauseEvent bind = (IGamingUnpauseEvent)this;
+ BeforeGamingUnpause += bind.BeforeGamingUnpauseEvent;
+ AfterGamingUnpause += bind.AfterGamingUnpauseEvent;
+ SucceedGamingUnpause += bind.SucceedGamingUnpauseEvent;
+ FailedGamingUnpause += bind.FailedGamingUnpauseEvent;
+ }
+
+ if (this is IGamingSurrenderEvent)
+ {
+ IGamingSurrenderEvent bind = (IGamingSurrenderEvent)this;
+ BeforeGamingSurrender += bind.BeforeGamingSurrenderEvent;
+ AfterGamingSurrender += bind.AfterGamingSurrenderEvent;
+ SucceedGamingSurrender += bind.SucceedGamingSurrenderEvent;
+ FailedGamingSurrender += bind.FailedGamingSurrenderEvent;
+ }
+
+ if (this is IGamingUpdateInfoEvent)
+ {
+ IGamingUpdateInfoEvent bind = (IGamingUpdateInfoEvent)this;
+ BeforeGamingUpdateInfo += bind.BeforeGamingUpdateInfoEvent;
+ AfterGamingUpdateInfo += bind.AfterGamingUpdateInfoEvent;
+ SucceedGamingUpdateInfo += bind.SucceedGamingUpdateInfoEvent;
+ FailedGamingUpdateInfo += bind.FailedGamingUpdateInfoEvent;
+ }
+ }
+
+ public event IGamingEventHandler.BeforeEventHandler? BeforeGamingConnect;
+ public event IGamingEventHandler.AfterEventHandler? AfterGamingConnect;
+ public event IGamingEventHandler.SucceedEventHandler? SucceedGamingConnect;
+ public event IGamingEventHandler.FailedEventHandler? FailedGamingConnect;
+ public event IGamingEventHandler.BeforeEventHandler? BeforeGamingDisconnect;
+ public event IGamingEventHandler.AfterEventHandler? AfterGamingDisconnect;
+ public event IGamingEventHandler.SucceedEventHandler? SucceedGamingDisconnect;
+ public event IGamingEventHandler.FailedEventHandler? FailedGamingDisconnect;
+ public event IGamingEventHandler.BeforeEventHandler? BeforeGamingReconnect;
+ public event IGamingEventHandler.AfterEventHandler? AfterGamingReconnect;
+ public event IGamingEventHandler.SucceedEventHandler? SucceedGamingReconnect;
+ public event IGamingEventHandler.FailedEventHandler? FailedGamingReconnect;
+ public event IGamingEventHandler.BeforeEventHandler? BeforeGamingBanCharacter;
+ public event IGamingEventHandler.AfterEventHandler? AfterGamingBanCharacter;
+ public event IGamingEventHandler.SucceedEventHandler? SucceedGamingBanCharacter;
+ public event IGamingEventHandler.FailedEventHandler? FailedGamingBanCharacter;
+ public event IGamingEventHandler.BeforeEventHandler? BeforeGamingPickCharacter;
+ public event IGamingEventHandler.AfterEventHandler? AfterGamingPickCharacter;
+ public event IGamingEventHandler.SucceedEventHandler? SucceedGamingPickCharacter;
+ public event IGamingEventHandler.FailedEventHandler? FailedGamingPickCharacter;
+ public event IGamingEventHandler.BeforeEventHandler? BeforeGamingRandom;
+ public event IGamingEventHandler.AfterEventHandler? AfterGamingRandom;
+ public event IGamingEventHandler.SucceedEventHandler? SucceedGamingRandom;
+ public event IGamingEventHandler.FailedEventHandler? FailedGamingRandom;
+ public event IGamingEventHandler.BeforeEventHandler? BeforeGamingMove;
+ public event IGamingEventHandler.AfterEventHandler? AfterGamingMove;
+ public event IGamingEventHandler.SucceedEventHandler? SucceedGamingMove;
+ public event IGamingEventHandler.FailedEventHandler? FailedGamingMove;
+ public event IGamingEventHandler.BeforeEventHandler? BeforeGamingAttack;
+ public event IGamingEventHandler.AfterEventHandler? AfterGamingAttack;
+ public event IGamingEventHandler.SucceedEventHandler? SucceedGamingAttack;
+ public event IGamingEventHandler.FailedEventHandler? FailedGamingAttack;
+ public event IGamingEventHandler.BeforeEventHandler? BeforeGamingSkill;
+ public event IGamingEventHandler.AfterEventHandler? AfterGamingSkill;
+ public event IGamingEventHandler.SucceedEventHandler? SucceedGamingSkill;
+ public event IGamingEventHandler.FailedEventHandler? FailedGamingSkill;
+ public event IGamingEventHandler.BeforeEventHandler? BeforeGamingItem;
+ public event IGamingEventHandler.AfterEventHandler? AfterGamingItem;
+ public event IGamingEventHandler.SucceedEventHandler? SucceedGamingItem;
+ public event IGamingEventHandler.FailedEventHandler? FailedGamingItem;
+ public event IGamingEventHandler.BeforeEventHandler? BeforeGamingMagic;
+ public event IGamingEventHandler.AfterEventHandler? AfterGamingMagic;
+ public event IGamingEventHandler.SucceedEventHandler? SucceedGamingMagic;
+ public event IGamingEventHandler.FailedEventHandler? FailedGamingMagic;
+ public event IGamingEventHandler.BeforeEventHandler? BeforeGamingBuy;
+ public event IGamingEventHandler.AfterEventHandler? AfterGamingBuy;
+ public event IGamingEventHandler.SucceedEventHandler? SucceedGamingBuy;
+ public event IGamingEventHandler.FailedEventHandler? FailedGamingBuy;
+ public event IGamingEventHandler.BeforeEventHandler? BeforeGamingSuperSkill;
+ public event IGamingEventHandler.AfterEventHandler? AfterGamingSuperSkill;
+ public event IGamingEventHandler.SucceedEventHandler? SucceedGamingSuperSkill;
+ public event IGamingEventHandler.FailedEventHandler? FailedGamingSuperSkill;
+ public event IGamingEventHandler.BeforeEventHandler? BeforeGamingPause;
+ public event IGamingEventHandler.AfterEventHandler? AfterGamingPause;
+ public event IGamingEventHandler.SucceedEventHandler? SucceedGamingPause;
+ public event IGamingEventHandler.FailedEventHandler? FailedGamingPause;
+ public event IGamingEventHandler.BeforeEventHandler? BeforeGamingUnpause;
+ public event IGamingEventHandler.AfterEventHandler? AfterGamingUnpause;
+ public event IGamingEventHandler.SucceedEventHandler? SucceedGamingUnpause;
+ public event IGamingEventHandler.FailedEventHandler? FailedGamingUnpause;
+ public event IGamingEventHandler.BeforeEventHandler? BeforeGamingSurrender;
+ public event IGamingEventHandler.AfterEventHandler? AfterGamingSurrender;
+ public event IGamingEventHandler.SucceedEventHandler? SucceedGamingSurrender;
+ public event IGamingEventHandler.FailedEventHandler? FailedGamingSurrender;
+ public event IGamingEventHandler.BeforeEventHandler? BeforeGamingUpdateInfo;
+ public event IGamingEventHandler.AfterEventHandler? AfterGamingUpdateInfo;
+ public event IGamingEventHandler.SucceedEventHandler? SucceedGamingUpdateInfo;
+ public event IGamingEventHandler.FailedEventHandler? FailedGamingUpdateInfo;
+
+ public void OnBeforeGamingConnectEvent(object sender, GamingEventArgs e)
+ {
+ BeforeGamingConnect?.Invoke(sender, e);
+ }
+
+ public void OnAfterGamingConnectEvent(object sender, GamingEventArgs e)
+ {
+ AfterGamingConnect?.Invoke(sender, e);
+ }
+
+ public void OnSucceedGamingConnectEvent(object sender, GamingEventArgs e)
+ {
+ SucceedGamingConnect?.Invoke(sender, e);
+ }
+
+ public void OnFailedGamingConnectEvent(object sender, GamingEventArgs e)
+ {
+ FailedGamingConnect?.Invoke(sender, e);
+ }
+
+ public void OnBeforeGamingDisconnectEvent(object sender, GamingEventArgs e)
+ {
+ BeforeGamingDisconnect?.Invoke(sender, e);
+ }
+
+ public void OnAfterGamingDisconnectEvent(object sender, GamingEventArgs e)
+ {
+ AfterGamingDisconnect?.Invoke(sender, e);
+ }
+
+ public void OnSucceedGamingDisconnectEvent(object sender, GamingEventArgs e)
+ {
+ SucceedGamingDisconnect?.Invoke(sender, e);
+ }
+
+ public void OnFailedGamingDisconnectEvent(object sender, GamingEventArgs e)
+ {
+ FailedGamingDisconnect?.Invoke(sender, e);
+ }
+
+ public void OnBeforeGamingReconnectEvent(object sender, GamingEventArgs e)
+ {
+ BeforeGamingReconnect?.Invoke(sender, e);
+ }
+
+ public void OnAfterGamingReconnectEvent(object sender, GamingEventArgs e)
+ {
+ AfterGamingReconnect?.Invoke(sender, e);
+ }
+
+ public void OnSucceedGamingReconnectEvent(object sender, GamingEventArgs e)
+ {
+ SucceedGamingReconnect?.Invoke(sender, e);
+ }
+
+ public void OnFailedGamingReconnectEvent(object sender, GamingEventArgs e)
+ {
+ FailedGamingReconnect?.Invoke(sender, e);
+ }
+
+ public void OnBeforeGamingBanCharacterEvent(object sender, GamingEventArgs e)
+ {
+ BeforeGamingBanCharacter?.Invoke(sender, e);
+ }
+
+ public void OnAfterGamingBanCharacterEvent(object sender, GamingEventArgs e)
+ {
+ AfterGamingBanCharacter?.Invoke(sender, e);
+ }
+
+ public void OnSucceedGamingBanCharacterEvent(object sender, GamingEventArgs e)
+ {
+ SucceedGamingBanCharacter?.Invoke(sender, e);
+ }
+
+ public void OnFailedGamingBanCharacterEvent(object sender, GamingEventArgs e)
+ {
+ FailedGamingBanCharacter?.Invoke(sender, e);
+ }
+
+ public void OnBeforeGamingPickCharacterEvent(object sender, GamingEventArgs e)
+ {
+ BeforeGamingPickCharacter?.Invoke(sender, e);
+ }
+
+ public void OnAfterGamingPickCharacterEvent(object sender, GamingEventArgs e)
+ {
+ AfterGamingPickCharacter?.Invoke(sender, e);
+ }
+
+ public void OnSucceedGamingPickCharacterEvent(object sender, GamingEventArgs e)
+ {
+ SucceedGamingPickCharacter?.Invoke(sender, e);
+ }
+
+ public void OnFailedGamingPickCharacterEvent(object sender, GamingEventArgs e)
+ {
+ FailedGamingPickCharacter?.Invoke(sender, e);
+ }
+
+ public void OnBeforeGamingRandomEvent(object sender, GamingEventArgs e)
+ {
+ BeforeGamingRandom?.Invoke(sender, e);
+ }
+
+ public void OnAfterGamingRandomEvent(object sender, GamingEventArgs e)
+ {
+ AfterGamingRandom?.Invoke(sender, e);
+ }
+
+ public void OnSucceedGamingRandomEvent(object sender, GamingEventArgs e)
+ {
+ SucceedGamingRandom?.Invoke(sender, e);
+ }
+
+ public void OnFailedGamingRandomEvent(object sender, GamingEventArgs e)
+ {
+ FailedGamingRandom?.Invoke(sender, e);
+ }
+
+ public void OnBeforeGamingMoveEvent(object sender, GamingEventArgs e)
+ {
+ BeforeGamingMove?.Invoke(sender, e);
+ }
+
+ public void OnAfterGamingMoveEvent(object sender, GamingEventArgs e)
+ {
+ AfterGamingMove?.Invoke(sender, e);
+ }
+
+ public void OnSucceedGamingMoveEvent(object sender, GamingEventArgs e)
+ {
+ SucceedGamingMove?.Invoke(sender, e);
+ }
+
+ public void OnFailedGamingMoveEvent(object sender, GamingEventArgs e)
+ {
+ FailedGamingMove?.Invoke(sender, e);
+ }
+
+ public void OnBeforeGamingAttackEvent(object sender, GamingEventArgs e)
+ {
+ BeforeGamingAttack?.Invoke(sender, e);
+ }
+
+ public void OnAfterGamingAttackEvent(object sender, GamingEventArgs e)
+ {
+ AfterGamingAttack?.Invoke(sender, e);
+ }
+
+ public void OnSucceedGamingAttackEvent(object sender, GamingEventArgs e)
+ {
+ SucceedGamingAttack?.Invoke(sender, e);
+ }
+
+ public void OnFailedGamingAttackEvent(object sender, GamingEventArgs e)
+ {
+ FailedGamingAttack?.Invoke(sender, e);
+ }
+
+ public void OnBeforeGamingSkillEvent(object sender, GamingEventArgs e)
+ {
+ BeforeGamingSkill?.Invoke(sender, e);
+ }
+
+ public void OnAfterGamingSkillEvent(object sender, GamingEventArgs e)
+ {
+ AfterGamingSkill?.Invoke(sender, e);
+ }
+
+ public void OnSucceedGamingSkillEvent(object sender, GamingEventArgs e)
+ {
+ SucceedGamingSkill?.Invoke(sender, e);
+ }
+
+ public void OnFailedGamingSkillEvent(object sender, GamingEventArgs e)
+ {
+ FailedGamingSkill?.Invoke(sender, e);
+ }
+
+ public void OnBeforeGamingItemEvent(object sender, GamingEventArgs e)
+ {
+ BeforeGamingItem?.Invoke(sender, e);
+ }
+
+ public void OnAfterGamingItemEvent(object sender, GamingEventArgs e)
+ {
+ AfterGamingItem?.Invoke(sender, e);
+ }
+
+ public void OnSucceedGamingItemEvent(object sender, GamingEventArgs e)
+ {
+ SucceedGamingItem?.Invoke(sender, e);
+ }
+
+ public void OnFailedGamingItemEvent(object sender, GamingEventArgs e)
+ {
+ FailedGamingItem?.Invoke(sender, e);
+ }
+
+ public void OnBeforeGamingMagicEvent(object sender, GamingEventArgs e)
+ {
+ BeforeGamingMagic?.Invoke(sender, e);
+ }
+
+ public void OnAfterGamingMagicEvent(object sender, GamingEventArgs e)
+ {
+ AfterGamingMagic?.Invoke(sender, e);
+ }
+
+ public void OnSucceedGamingMagicEvent(object sender, GamingEventArgs e)
+ {
+ SucceedGamingMagic?.Invoke(sender, e);
+ }
+
+ public void OnFailedGamingMagicEvent(object sender, GamingEventArgs e)
+ {
+ FailedGamingMagic?.Invoke(sender, e);
+ }
+
+ public void OnBeforeGamingBuyEvent(object sender, GamingEventArgs e)
+ {
+ BeforeGamingBuy?.Invoke(sender, e);
+ }
+
+ public void OnAfterGamingBuyEvent(object sender, GamingEventArgs e)
+ {
+ AfterGamingBuy?.Invoke(sender, e);
+ }
+
+ public void OnSucceedGamingBuyEvent(object sender, GamingEventArgs e)
+ {
+ SucceedGamingBuy?.Invoke(sender, e);
+ }
+
+ public void OnFailedGamingBuyEvent(object sender, GamingEventArgs e)
+ {
+ FailedGamingBuy?.Invoke(sender, e);
+ }
+
+ public void OnBeforeGamingSuperSkillEvent(object sender, GamingEventArgs e)
+ {
+ BeforeGamingSuperSkill?.Invoke(sender, e);
+ }
+
+ public void OnAfterGamingSuperSkillEvent(object sender, GamingEventArgs e)
+ {
+ AfterGamingSuperSkill?.Invoke(sender, e);
+ }
+
+ public void OnSucceedGamingSuperSkillEvent(object sender, GamingEventArgs e)
+ {
+ SucceedGamingSuperSkill?.Invoke(sender, e);
+ }
+
+ public void OnFailedGamingSuperSkillEvent(object sender, GamingEventArgs e)
+ {
+ FailedGamingSuperSkill?.Invoke(sender, e);
+ }
+
+ public void OnBeforeGamingPauseEvent(object sender, GamingEventArgs e)
+ {
+ BeforeGamingPause?.Invoke(sender, e);
+ }
+
+ public void OnAfterGamingPauseEvent(object sender, GamingEventArgs e)
+ {
+ AfterGamingPause?.Invoke(sender, e);
+ }
+
+ public void OnSucceedGamingPauseEvent(object sender, GamingEventArgs e)
+ {
+ SucceedGamingPause?.Invoke(sender, e);
+ }
+
+ public void OnFailedGamingPauseEvent(object sender, GamingEventArgs e)
+ {
+ FailedGamingPause?.Invoke(sender, e);
+ }
+
+ public void OnBeforeGamingUnpauseEvent(object sender, GamingEventArgs e)
+ {
+ BeforeGamingUnpause?.Invoke(sender, e);
+ }
+
+ public void OnAfterGamingUnpauseEvent(object sender, GamingEventArgs e)
+ {
+ AfterGamingUnpause?.Invoke(sender, e);
+ }
+
+ public void OnSucceedGamingUnpauseEvent(object sender, GamingEventArgs e)
+ {
+ SucceedGamingUnpause?.Invoke(sender, e);
+ }
+
+ public void OnFailedGamingUnpauseEvent(object sender, GamingEventArgs e)
+ {
+ FailedGamingUnpause?.Invoke(sender, e);
+ }
+
+ public void OnBeforeGamingSurrenderEvent(object sender, GamingEventArgs e)
+ {
+ BeforeGamingSurrender?.Invoke(sender, e);
+ }
+
+ public void OnAfterGamingSurrenderEvent(object sender, GamingEventArgs e)
+ {
+ AfterGamingSurrender?.Invoke(sender, e);
+ }
+
+ public void OnSucceedGamingSurrenderEvent(object sender, GamingEventArgs e)
+ {
+ SucceedGamingSurrender?.Invoke(sender, e);
+ }
+
+ public void OnFailedGamingSurrenderEvent(object sender, GamingEventArgs e)
+ {
+ FailedGamingSurrender?.Invoke(sender, e);
+ }
+
+ public void OnBeforeGamingUpdateInfoEvent(object sender, GamingEventArgs e)
+ {
+ BeforeGamingUpdateInfo?.Invoke(sender, e);
+ }
+
+ public void OnAfterGamingUpdateInfoEvent(object sender, GamingEventArgs e)
+ {
+ AfterGamingUpdateInfo?.Invoke(sender, e);
+ }
+
+ public void OnSucceedGamingUpdateInfoEvent(object sender, GamingEventArgs e)
+ {
+ SucceedGamingUpdateInfo?.Invoke(sender, e);
+ }
+
+ public void OnFailedGamingUpdateInfoEvent(object sender, GamingEventArgs e)
+ {
+ FailedGamingUpdateInfo?.Invoke(sender, e);
+ }
+ }
+}
diff --git a/Library/Common/Plugin/BasePlugin.cs b/Library/Common/Addon/Plugin.cs
similarity index 99%
rename from Library/Common/Plugin/BasePlugin.cs
rename to Library/Common/Addon/Plugin.cs
index 98b78d2..ae189c1 100644
--- a/Library/Common/Plugin/BasePlugin.cs
+++ b/Library/Common/Addon/Plugin.cs
@@ -4,9 +4,9 @@ using Milimoe.FunGame.Core.Library.Common.Event;
using Milimoe.FunGame.Core.Library.Constant;
using Milimoe.FunGame.Core.Model;
-namespace Milimoe.FunGame.Core.Library.Common.Plugin
+namespace Milimoe.FunGame.Core.Library.Common.Addon
{
- public abstract class BasePlugin : IPlugin
+ public abstract class Plugin : IPlugin
{
///
/// 插件名称
diff --git a/Library/Common/Event/GamingEventArgs.cs b/Library/Common/Event/GamingEventArgs.cs
new file mode 100644
index 0000000..b468caa
--- /dev/null
+++ b/Library/Common/Event/GamingEventArgs.cs
@@ -0,0 +1,11 @@
+using Milimoe.FunGame.Core.Entity;
+
+namespace Milimoe.FunGame.Core.Library.Common.Event
+{
+ public class GamingEventArgs(Room room, List users, List characters) : GeneralEventArgs
+ {
+ public Room Room { get; } = room;
+ public List Users { get; } = users;
+ public List Characters { get; } = characters;
+ }
+}
diff --git a/Library/Common/Event/RoomEventArgs.cs b/Library/Common/Event/RoomEventArgs.cs
index 7cc0c39..273aff9 100644
--- a/Library/Common/Event/RoomEventArgs.cs
+++ b/Library/Common/Event/RoomEventArgs.cs
@@ -9,45 +9,47 @@ namespace Milimoe.FunGame.Core.Library.Common.Event
public Room Room { get; set; } = General.HallInstance;
public string RoomID { get; set; } = "";
public long RoomMaster { get; set; } = 0;
- public string RoomTypeString { get; set; } = GameMode.All;
+ public string RoomTypeString { get; set; } = RoomSet.All;
public RoomType RoomType { get; set; } = RoomType.All;
+ public string GameMode { get; set; } = "";
+ public string GameMap { get; set; } = "";
public RoomState RoomState { get; set; } = RoomState.Created;
public bool HasPassword => Password.Trim() != "";
public string Password { get; set; } = "";
- public RoomEventArgs(string RoomType, string Password)
+ public RoomEventArgs(string type, string password)
{
- RoomTypeString = RoomType;
- this.RoomType = RoomType switch
+ RoomTypeString = type;
+ RoomType = type switch
{
- GameMode.Mix => Constant.RoomType.Mix,
- GameMode.Team => Constant.RoomType.Team,
- GameMode.MixHasPass => Constant.RoomType.MixHasPass,
- GameMode.TeamHasPass => Constant.RoomType.TeamHasPass,
- GameMode.AllHasPass => Constant.RoomType.AllHasPass,
- _ => Constant.RoomType.All
+ RoomSet.Mix => RoomType.Mix,
+ RoomSet.Team => RoomType.Team,
+ RoomSet.FastAuto => RoomType.FastAuto,
+ RoomSet.Custom => RoomType.Custom,
+ _ => RoomType.All
};
- this.Password = Password;
- Room = Factory.GetRoom(RoomType: this.RoomType, Password: this.Password);
+ Password = password;
+ Room = Factory.GetRoom(RoomType: RoomType, Password: Password);
}
- public RoomEventArgs(Room Room)
+ public RoomEventArgs(Room room)
{
- this.Room = Room;
- RoomID = Room.Roomid;
- RoomMaster = Room.RoomMaster != null ? Room.RoomMaster.Id : 0;
- RoomType = Room.RoomType;
- RoomTypeString = Room.RoomType switch
+ Room = room;
+ RoomID = room.Roomid;
+ RoomMaster = room.RoomMaster != null ? room.RoomMaster.Id : 0;
+ RoomType = room.RoomType;
+ GameMode = room.GameMode;
+ GameMap = room.GameMap;
+ RoomTypeString = room.RoomType switch
{
- RoomType.Mix => GameMode.Mix,
- RoomType.Team => GameMode.Team,
- RoomType.MixHasPass => GameMode.MixHasPass,
- RoomType.TeamHasPass => GameMode.TeamHasPass,
- RoomType.AllHasPass => GameMode.AllHasPass,
- _ => GameMode.All
+ RoomType.Mix => RoomSet.Mix,
+ RoomType.Team => RoomSet.Team,
+ RoomType.FastAuto => RoomSet.FastAuto,
+ RoomType.Custom => RoomSet.Custom,
+ _ => RoomSet.All
};
- RoomState = Room.RoomState;
- Password = Room.Password;
+ RoomState = room.RoomState;
+ Password = room.Password;
}
}
}
diff --git a/Library/Constant/ConstantSet.cs b/Library/Constant/ConstantSet.cs
index e404d3d..8af0320 100644
--- a/Library/Constant/ConstantSet.cs
+++ b/Library/Constant/ConstantSet.cs
@@ -3,12 +3,16 @@
*/
namespace Milimoe.FunGame.Core.Library.Constant
{
+ ///
+ /// 配合 使用,也别忘了修改
+ ///
public class InterfaceSet
{
public class Type
{
public const string IClient = "IClientImpl";
public const string IServer = "IServerImpl";
+ public const string IGameModeSupported = "IGameModeSupported";
}
public class Method
@@ -16,6 +20,8 @@ namespace Milimoe.FunGame.Core.Library.Constant
public const string RemoteServerIP = "RemoteServerIP";
public const string DBConnection = "DBConnection";
public const string GetServerSettings = "GetServerSettings";
+ public const string GameModeList = "GameModeList";
+ public const string GameMapList = "GameMapList";
}
}
@@ -112,23 +118,7 @@ namespace Milimoe.FunGame.Core.Library.Constant
/**
* Gaming
*/
- public const string Gaming_Connect = "Gaming::Connect";
- public const string Gaming_Disconnect = "Gaming::Disconnect";
- public const string Gaming_Reconnect = "Gaming::Reconnect";
- public const string Gaming_Ban = "Gaming::Ban";
- public const string Gaming_Pick = "Gaming::Pick";
- public const string Gaming_Random = "Gaming::Random";
- public const string Gaming_Move = "Gaming::Move";
- public const string Gaming_Attack = "Gaming::Attack";
- public const string Gaming_Skill = "Gaming::Skill";
- public const string Gaming_Item = "Gaming::Item";
- public const string Gaming_Magic = "Gaming::Magic";
- public const string Gaming_Buy = "Gaming::Buy";
- public const string Gaming_SuperSkill = "Gaming::SuperSkill";
- public const string Gaming_Pause = "Gaming::Pause";
- public const string Gaming_Unpause = "Gaming::Unpause";
- public const string Gaming_Surrender = "Gaming::Surrender";
- public const string Gaming_UpdateUserInfo = "Gaming::UpdateUserInfo";
+ public const string Gaming = "Gaming";
///
/// 获取Type的等效字符串
@@ -157,27 +147,62 @@ namespace Milimoe.FunGame.Core.Library.Constant
DataRequestType.Room_GetRoomSettings => Room_GetRoomSettings,
DataRequestType.Room_GetRoomPlayerCount => Room_GetRoomPlayerCount,
DataRequestType.Room_UpdateRoomMaster => Room_UpdateRoomMaster,
- DataRequestType.Gaming_Connect => Gaming_Connect,
- DataRequestType.Gaming_Disconnect => Gaming_Disconnect,
- DataRequestType.Gaming_Reconnect => Gaming_Reconnect,
- DataRequestType.Gaming_Ban => Gaming_Ban,
- DataRequestType.Gaming_Pick => Gaming_Pick,
- DataRequestType.Gaming_Random => Gaming_Random,
- DataRequestType.Gaming_Move => Gaming_Move,
- DataRequestType.Gaming_Attack => Gaming_Attack,
- DataRequestType.Gaming_Skill => Gaming_Skill,
- DataRequestType.Gaming_Item => Gaming_Item,
- DataRequestType.Gaming_Magic => Gaming_Magic,
- DataRequestType.Gaming_Buy => Gaming_Buy,
- DataRequestType.Gaming_SuperSkill => Gaming_SuperSkill,
- DataRequestType.Gaming_Pause => Gaming_Pause,
- DataRequestType.Gaming_Unpause => Gaming_Unpause,
- DataRequestType.Gaming_Surrender => Gaming_Surrender,
- DataRequestType.Gaming_UpdateUserInfo => Gaming_UpdateUserInfo,
+ DataRequestType.Gaming => Gaming,
_ => UnKnown
};
}
+ }
+ public class GamingSet
+ {
+ public const string None = "Gaming::None";
+ public const string Connect = "Gaming::Connect";
+ public const string Disconnect = "Gaming::Disconnect";
+ public const string Reconnect = "Gaming::Reconnect";
+ public const string BanCharacter = "Gaming::BanCharacter";
+ public const string PickCharacter = "Gaming::PickCharacter";
+ public const string Random = "Gaming::Random";
+ public const string Move = "Gaming::Move";
+ public const string Attack = "Gaming::Attack";
+ public const string Skill = "Gaming::Skill";
+ public const string Item = "Gaming::Item";
+ public const string Magic = "Gaming::Magic";
+ public const string Buy = "Gaming::Buy";
+ public const string SuperSkill = "Gaming::SuperSkill";
+ public const string Pause = "Gaming::Pause";
+ public const string Unpause = "Gaming::Unpause";
+ public const string Surrender = "Gaming::Surrender";
+ public const string UpdateInfo = "Gaming::UpdateInfo";
+
+ ///
+ /// 获取Type的等效字符串
+ ///
+ ///
+ ///
+ public static string GetTypeString(GamingType type)
+ {
+ return type switch
+ {
+ GamingType.Connect => Connect,
+ GamingType.Disconnect => Disconnect,
+ GamingType.Reconnect => Reconnect,
+ GamingType.BanCharacter => BanCharacter,
+ GamingType.PickCharacter => PickCharacter,
+ GamingType.Random => Random,
+ GamingType.Move => Move,
+ GamingType.Attack => Attack,
+ GamingType.Skill => Skill,
+ GamingType.Item => Item,
+ GamingType.Magic => Magic,
+ GamingType.Buy => Buy,
+ GamingType.SuperSkill => SuperSkill,
+ GamingType.Pause => Pause,
+ GamingType.Unpause => Unpause,
+ GamingType.Surrender => Surrender,
+ GamingType.UpdateInfo => UpdateInfo,
+ _ => None
+ };
+ }
}
public class ReflectionSet
@@ -185,6 +210,8 @@ namespace Milimoe.FunGame.Core.Library.Constant
public const string FUNGAME_IMPL = "FunGame.Implement";
public static string EXEFolderPath { get; } = Environment.CurrentDirectory.ToString() + "\\"; // 程序目录
public static string PluginFolderPath { get; } = Environment.CurrentDirectory.ToString() + "\\plugins\\"; // 插件目录
+ public static string GameModeFolderPath { get; } = Environment.CurrentDirectory.ToString() + "\\gamemods\\"; // 游戏模组目录
+ public static string GameMapFolderPath { get; } = Environment.CurrentDirectory.ToString() + "\\maps\\"; // 游戏地图目录
}
public class FormSet
@@ -198,14 +225,14 @@ namespace Milimoe.FunGame.Core.Library.Constant
public const string UserCenter = "UserCenter";
}
- public class GameMode
+ public class RoomSet
{
- public const string All = "所有模式";
- public const string AllHasPass = "带密码的所有模式";
+ public const string All = "全部";
public const string Mix = "混战模式";
- public const string MixHasPass = "带密码的混战模式";
public const string Team = "团队模式";
- public const string TeamHasPass = "带密码的团队模式";
+ public const string Solo = "对弈模式";
+ public const string FastAuto = "快速自走模式";
+ public const string Custom = "自定义模式";
///
/// 获取Type的等效字符串
@@ -218,9 +245,9 @@ namespace Milimoe.FunGame.Core.Library.Constant
{
RoomType.Mix => Mix,
RoomType.Team => Team,
- RoomType.MixHasPass => MixHasPass,
- RoomType.TeamHasPass => TeamHasPass,
- RoomType.AllHasPass => AllHasPass,
+ RoomType.Solo => Solo,
+ RoomType.FastAuto => FastAuto,
+ RoomType.Custom => Custom,
_ => All
};
}
@@ -236,9 +263,8 @@ namespace Milimoe.FunGame.Core.Library.Constant
{
Mix => RoomType.Mix,
Team => RoomType.Team,
- MixHasPass => RoomType.MixHasPass,
- TeamHasPass => RoomType.TeamHasPass,
- AllHasPass => RoomType.AllHasPass,
+ FastAuto => RoomType.FastAuto,
+ Custom => RoomType.Custom,
_ => RoomType.All
};
}
diff --git a/Library/Constant/FunGameInfo.cs b/Library/Constant/FunGameInfo.cs
index 0d7009b..4fb463a 100644
--- a/Library/Constant/FunGameInfo.cs
+++ b/Library/Constant/FunGameInfo.cs
@@ -19,14 +19,14 @@
///
public static bool FunGame_DebugMode { get; set; } = false;
- private const string FunGame_Core = "FunGame Core";
- private const string FunGame_Core_Api = "FunGame Core Api";
- private const string FunGame_Console = "FunGame Console";
- private const string FunGame_Desktop = "FunGame Desktop";
- private const string FunGame_Server = "FunGame Server Console";
+ public const string FunGame_Core = "FunGame Core";
+ public const string FunGame_Core_Api = "FunGame Core Api";
+ public const string FunGame_Console = "FunGame Console";
+ public const string FunGame_Desktop = "FunGame Desktop";
+ public const string FunGame_Server = "FunGame Server Console";
- private const string FunGame_Version = "v1.0";
- private const string FunGame_VersionPatch = "";
+ public const string FunGame_Version = "v1.0";
+ public const string FunGame_VersionPatch = "";
public static string GetInfo(FunGame FunGameType)
{
@@ -41,11 +41,5 @@
};
return type + " [ 版本: " + FunGame_Version + FunGame_VersionPatch + " ]\n" + (type.Equals(FunGame_Desktop) ? @"©" : "(C)") + "2023 Milimoe. 保留所有权利\n";
}
-
- /**
- * 更新日志
- *
- *
- */
}
}
diff --git a/Library/Constant/General.cs b/Library/Constant/General.cs
index f5b815f..e124ad4 100644
--- a/Library/Constant/General.cs
+++ b/Library/Constant/General.cs
@@ -1,28 +1,79 @@
using System.Text;
using Milimoe.FunGame.Core.Entity;
-/**
- * 此文件保存常用的对象常量
- */
namespace Milimoe.FunGame.Core.Library.Constant
{
+ ///
+ /// 此类保存常用的对象常量
+ ///
public class General
{
- // Static Variable
+ #region Static Variable
+
+ ///
+ /// 空的实体类 用于object返回
+ ///
public static Empty EntityInstance => new();
+
+ ///
+ /// 默认的未知用户
+ ///
public static User UnknownUserInstance => new();
+
+ ///
+ /// 大厅(空房间)实例
+ ///
public static Room HallInstance => new();
+
+ ///
+ /// 默认的字符编码
+ ///
public static Encoding DefaultEncoding => Encoding.Unicode;
+
+ ///
+ /// 默认的时间格式
+ ///
public static string GeneralDateTimeFormat => "yyyy-MM-dd HH:mm:ss.fff";
+
+ ///
+ /// 默认的时间值(1970年8月1日8点0分0秒)
+ ///
public static DateTime DefaultTime => new(1970, 1, 1, 8, 0, 0);
- // Const
+ #endregion
+
+ #region Const
+
+ ///
+ /// 最多自动重试连接次数
+ ///
public const int MaxRetryTimes = 20;
+
+ ///
+ /// 1C2G推荐的任务数量
+ ///
public const int MaxTask_1C2G = 10;
+
+ ///
+ /// 2C2G推荐的任务数量
+ ///
public const int MaxTask_2C2G = 20;
+
+ ///
+ /// 4C4G推荐的任务数量
+ ///
public const int MaxTask_4C4G = 40;
+ ///
+ /// 默认Socket数据包大小
+ ///
public const int SocketByteSize = 512 * 1024;
+
+ ///
+ /// 默认Stream传输大小
+ ///
public const int StreamByteSize = 2048;
+
+ #endregion
}
}
diff --git a/Library/Constant/MethodEnum.cs b/Library/Constant/MethodEnum.cs
index edbfc57..c3b0bc8 100644
--- a/Library/Constant/MethodEnum.cs
+++ b/Library/Constant/MethodEnum.cs
@@ -3,10 +3,15 @@
*/
namespace Milimoe.FunGame.Core.Library.Constant
{
+ ///
+ /// ʹãҲ
+ ///
public enum InterfaceMethod
{
RemoteServerIP,
DBConnection,
- GetServerSettings
+ GetServerSettings,
+ GameModeList,
+ GameMapList
}
}
diff --git a/Library/Constant/TypeEnum.cs b/Library/Constant/TypeEnum.cs
index b01ce46..9a3fe5d 100644
--- a/Library/Constant/TypeEnum.cs
+++ b/Library/Constant/TypeEnum.cs
@@ -21,20 +21,27 @@ namespace Milimoe.FunGame.Core.Library.Constant
Dialog
}
+ ///
+ /// 配合 使用,也别忘了修改
+ ///
public enum InterfaceType
{
IClient,
- IServer
+ IServer,
+ IGameModeSupported
}
+ ///
+ /// 配合 使用
+ ///
public enum RoomType
{
All,
Mix,
Team,
- AllHasPass,
- MixHasPass,
- TeamHasPass
+ Solo,
+ FastAuto,
+ Custom
}
public enum MessageButtonType
@@ -97,24 +104,31 @@ namespace Milimoe.FunGame.Core.Library.Constant
Room_GetRoomSettings,
Room_GetRoomPlayerCount,
Room_UpdateRoomMaster,
- Gaming_Connect,
- Gaming_Disconnect,
- Gaming_Reconnect,
- Gaming_Ban,
- Gaming_Pick,
- Gaming_Random,
- Gaming_Move,
- Gaming_Attack,
- Gaming_Skill,
- Gaming_Item,
- Gaming_Magic,
- Gaming_Buy,
- Gaming_SuperSkill,
- Gaming_Pause,
- Gaming_Unpause,
- Gaming_Surrender,
- Gaming_UpdateUserInfo,
- Gaming_Punish
+ Gaming,
+ }
+
+ public enum GamingType
+ {
+ None,
+ Connect,
+ Disconnect,
+ Reconnect,
+ BanCharacter,
+ PickCharacter,
+ Random,
+ LevelUp,
+ Move,
+ Attack,
+ Skill,
+ Item,
+ Magic,
+ Buy,
+ SuperSkill,
+ Pause,
+ Unpause,
+ Surrender,
+ UpdateInfo,
+ Punish
}
public enum SocketRuntimeType
diff --git a/Library/SQLScript/Entity/RoomQuery.cs b/Library/SQLScript/Entity/RoomQuery.cs
index f882c91..6759f47 100644
--- a/Library/SQLScript/Entity/RoomQuery.cs
+++ b/Library/SQLScript/Entity/RoomQuery.cs
@@ -9,23 +9,21 @@
public const string Column_RoomMaster = "RoomMaster";
public const string Column_RoomMasterName = "RoomMasterName";
public const string Column_RoomType = "RoomType";
+ public const string Column_GameMode = "GameMode";
+ public const string Column_GameMap = "GameMap";
public const string Column_RoomState = "RoomState";
public const string Column_HasPass = "HasPass";
public const string Column_Password = "Password";
public const string Select_Rooms = $"{Command_Select} {TableName}.{Command_All}, {UserQuery.TableName}.{UserQuery.Column_Username} {Command_As} {Column_RoomMasterName} " +
$"{Command_From} {TableName} {Command_LeftJoin} {UserQuery.TableName} {Command_On} {UserQuery.TableName}.{UserQuery.Column_UID} = {TableName}.{Column_RoomMaster}";
- public static string Insert_CreateRoom(string RoomID, long RoomMaster, Library.Constant.RoomType RoomType, string Password)
+ public static string Insert_CreateRoom(string RoomID, long RoomMaster, Library.Constant.RoomType RoomType, string GameMode, string GameMap, string Password)
{
Library.Constant.RoomState RoomState = Library.Constant.RoomState.Created;
DateTime NowTime = DateTime.Now;
- bool HasPass = false;
- if (Password.Trim() != "")
- {
- HasPass = true;
- }
- return $"{Command_Insert} {Command_Into} {TableName} ({Column_RoomID}, {Column_CreateTime}, {Column_RoomMaster}, {Column_RoomType}, {Column_RoomState}, {Column_HasPass}, {Column_Password})" +
- $" {Command_Values} ('{RoomID}', '{NowTime}', {RoomMaster}, {(int)RoomType}, {(int)RoomState}, {(HasPass ? 1 : 0)}, '{Password}')";
+ bool HasPass = Password.Trim() != "";
+ return $"{Command_Insert} {Command_Into} {TableName} ({Column_RoomID}, {Column_CreateTime}, {Column_RoomMaster}, {Column_RoomType}, {Column_GameMode}, {Column_GameMap}, {Column_RoomState}, {Column_HasPass}, {Column_Password})" +
+ $" {Command_Values} ('{RoomID}', '{NowTime}', {RoomMaster}, {(int)RoomType}, '{GameMode}', '{GameMap}', {(int)RoomState}, {(HasPass ? 1 : 0)}, '{Password}')";
}
public static string Delete_Rooms(params string[] roomids)
@@ -37,7 +35,7 @@
}
return $"{Command_Delete} {Command_From} {TableName}";
}
-
+
public static string Delete_QuitRoom(string RoomID, long RoomMaster)
{
return $"{Command_Delete} {Command_From} {TableName} {Command_Where} {Column_RoomID} = '{RoomID}' {Command_And} {Column_RoomMaster} = {RoomMaster}";
diff --git a/Model/FunGameConfig.cs b/Model/FunGameConfig.cs
index 97641c1..7a21f57 100644
--- a/Model/FunGameConfig.cs
+++ b/Model/FunGameConfig.cs
@@ -40,9 +40,9 @@ namespace Milimoe.FunGame.Core.Model
public bool FunGame_isInRoom { get; set; } = false;
///
- /// 当前游戏模式
+ /// 当前所处的房间类型
///
- public string FunGame_GameMode { get; set; } = GameMode.Mix;
+ public string FunGame_RoomType { get; set; } = RoomSet.All;
///
/// 服务器名称
diff --git a/Service/AddonManager.cs b/Service/AddonManager.cs
index 20b47ec..fe17d44 100644
--- a/Service/AddonManager.cs
+++ b/Service/AddonManager.cs
@@ -1,5 +1,6 @@
using System.Reflection;
-using Milimoe.FunGame.Core.Library.Common.Plugin;
+using Milimoe.FunGame.Core.Library.Common.Addon;
+using Milimoe.FunGame.Core.Library.Constant;
namespace Milimoe.FunGame.Core.Service
{
@@ -11,21 +12,21 @@ namespace Milimoe.FunGame.Core.Service
///
///
///
- internal static Dictionary LoadPlugins(Dictionary plugins, params object[] objs)
+ internal static Dictionary LoadPlugins(Dictionary plugins, params object[] objs)
{
- if (!Directory.Exists("plugins")) return plugins;
+ if (!Directory.Exists(ReflectionSet.PluginFolderPath)) return plugins;
- string[] dlls = Directory.GetFiles("plugins", "*.dll");
+ string[] dlls = Directory.GetFiles(ReflectionSet.PluginFolderPath, "*.dll");
foreach (string dll in dlls)
{
// 加载目录下所有的DLL
Assembly assembly = Assembly.LoadFrom(dll);
- // 遍历DLL中继承了BasePlugin的类型
- foreach (Type type in assembly.GetTypes().AsEnumerable().Where(type => type.IsSubclassOf(typeof(BasePlugin))))
+ // 遍历DLL中继承了Plugin的类型
+ foreach (Type type in assembly.GetTypes().AsEnumerable().Where(type => type.IsSubclassOf(typeof(Plugin))))
{
- BasePlugin? instance = (BasePlugin?)Activator.CreateInstance(type);
+ Plugin? instance = (Plugin?)Activator.CreateInstance(type);
if (instance != null && instance.Load(objs))
{
plugins.TryAdd(instance.Name, instance);
@@ -35,5 +36,63 @@ namespace Milimoe.FunGame.Core.Service
return plugins;
}
+
+ ///
+ /// 从gamemodes目录加载所有模组
+ ///
+ ///
+ ///
+ ///
+ internal static Dictionary LoadGameModes(Dictionary gamemodes, params object[] objs)
+ {
+ if (!Directory.Exists(ReflectionSet.GameModeFolderPath)) return gamemodes;
+
+ string[] dlls = Directory.GetFiles(ReflectionSet.GameModeFolderPath, "*.dll");
+
+ foreach (string dll in dlls)
+ {
+ Assembly assembly = Assembly.LoadFrom(dll);
+
+ foreach (Type type in assembly.GetTypes().AsEnumerable().Where(type => type.IsSubclassOf(typeof(GameMode))))
+ {
+ GameMode? instance = (GameMode?)Activator.CreateInstance(type);
+ if (instance != null && instance.Load(objs))
+ {
+ gamemodes.TryAdd(instance.Name, instance);
+ }
+ }
+ }
+
+ return gamemodes;
+ }
+
+ ///
+ /// 从gamemaps目录加载所有地图
+ ///
+ ///
+ ///
+ ///
+ internal static Dictionary LoadGameMaps(Dictionary gamemaps, params object[] objs)
+ {
+ if (!Directory.Exists(ReflectionSet.GameMapFolderPath)) return gamemaps;
+
+ string[] dlls = Directory.GetFiles(ReflectionSet.GameMapFolderPath, "*.dll");
+
+ foreach (string dll in dlls)
+ {
+ Assembly assembly = Assembly.LoadFrom(dll);
+
+ foreach (Type type in assembly.GetTypes().AsEnumerable().Where(type => type.IsSubclassOf(typeof(GameMap))))
+ {
+ GameMap? instance = (GameMap?)Activator.CreateInstance(type);
+ if (instance != null && instance.Load(objs))
+ {
+ gamemaps.TryAdd(instance.Name, instance);
+ }
+ }
+ }
+
+ return gamemaps;
+ }
}
}
\ No newline at end of file