@@ -10,18 +10,24 @@ namespace GameFrameX.Hotfix.Common.Events;
1010
1111public static class EventDispatcherExtensions
1212{
13- public static void Dispatch ( this IComponentAgent agent , int evtId , Param args = null )
13+ /// <summary>
14+ /// 分发事件
15+ /// </summary>
16+ /// <param name="agent">代理对象</param>
17+ /// <param name="eventId">事件ID</param>
18+ /// <param name="args">事件参数,可以为null</param>
19+ public static void Dispatch ( this IComponentAgent agent , int eventId , Param args = null )
1420 {
15- var evt = new Event
21+ var gameEventArgs = new GameEventArgs
1622 {
17- EventId = evtId ,
23+ EventId = eventId ,
1824 Data = args ,
1925 } ;
2026
2127 // 自己处理
22- SelfHandle ( agent , evtId , evt ) ;
28+ SelfHandle ( agent , eventId , gameEventArgs ) ;
2329
24- if ( ( EventId ) evtId > EventId . RoleSeparator && agent . OwnerType > GlobalConst . ActorTypeSeparator )
30+ if ( ( EventId ) eventId > EventId . RoleSeparator && agent . OwnerType > GlobalConst . ActorTypeSeparator )
2531 {
2632 // 全局非玩家事件,抛给所有玩家
2733 agent . Tell ( ( )
@@ -30,13 +36,13 @@ public static void Dispatch(this IComponentAgent agent, int evtId, Param args =
3036 return ServerComponentAgent . OnlineRoleForeach ( role
3137 =>
3238 {
33- role . Dispatch ( evtId , args ) ;
39+ role . Dispatch ( eventId , args ) ;
3440 } ) ;
3541 } ) ;
3642 }
3743 }
3844
39- private static void SelfHandle ( IComponentAgent agent , int evtId , Event evt )
45+ private static void SelfHandle ( IComponentAgent agent , int evtId , GameEventArgs evt )
4046 {
4147 agent . Tell ( async ( ) =>
4248 {
@@ -63,8 +69,14 @@ private static void SelfHandle(IComponentAgent agent, int evtId, Event evt)
6369 } ) ;
6470 }
6571
66- public static void Dispatch ( this IComponentAgent agent , EventId evtId , Param args = null )
72+ /// <summary>
73+ /// 分发事件
74+ /// </summary>
75+ /// <param name="agent">代理对象</param>
76+ /// <param name="eventId">事件ID</param>
77+ /// <param name="args">事件参数</param>
78+ public static void Dispatch ( this IComponentAgent agent , EventId eventId , Param args = null )
6779 {
68- Dispatch ( agent , ( int ) evtId , args ) ;
80+ Dispatch ( agent , ( int ) eventId , args ) ;
6981 }
7082}
0 commit comments