Bläddra i källkod

【增加】Xmds扩展事件-向游戏服发送战报,增加单位模板id字段,用于统计贡献榜

johnclot69 1 år sedan
förälder
incheckning
aa3af6a2f3

+ 6 - 0
XmdsCommonServer/Message/BattleMessageB2R.cs

@@ -253,6 +253,10 @@ namespace XmdsCommonServer.Message
         /// </summary>
         public string PlayerUUID = null;
         /// <summary>
+        /// 单位模板id
+        /// </summary>
+        public int TemplateID = 0;
+        /// <summary>
         /// 总伤害.
         /// </summary>
         public long TotalDamage = 0;
@@ -264,6 +268,7 @@ namespace XmdsCommonServer.Message
         public void ReadExternal(IInputStream input)
         {
             PlayerUUID = input.GetUTF();
+            TemplateID = input.GetS32();
             TotalDamage = input.GetS64();
             TotalHealing = input.GetS64();
         }
@@ -271,6 +276,7 @@ namespace XmdsCommonServer.Message
         public void WriteExternal(IOutputStream output)
         {
             output.PutUTF(PlayerUUID);
+            output.PutS32(TemplateID);
             output.PutS64(TotalDamage);
             output.PutS64(TotalHealing);
         }

+ 13 - 13
XmdsCommonServer/Plugin/Editor/EventsClientScript.cs

@@ -290,25 +290,25 @@ namespace XmdsCommonServer.Plugin.Editor
 
         public override void DoAction(EventTriggerAdapter api, EventArguments args)
         {
-            var e = new BattleReportEventB2R();
-            e.instanceId = api.ZoneAPI.UUID;
+            var e = new BattleReportEventB2R
+            {
+                instanceId = api.ZoneAPI.UUID
+            };
 
-            using (var a = ListObjectPool<InstancePlayer>.AllocAutoRelease(api.ZoneAPI.AllPlayers))
+            // using (var a = ListObjectPool<InstancePlayer>.AllocAutoRelease(api.ZoneAPI.AllPlayers))
+            using (var a = ListObjectPool<InstanceUnit>.AllocAutoRelease(api.ZoneAPI.AllUnits))
             {
                 e.data = new List<UnitBattleReportDetail>();
 
-                foreach (var b in a)
+                foreach (var b in a.Where(b => b.Statistic.TotalDamage > 0 || b.Statistic.TotalHealing > 0))
                 {
-                    if(b.Statistic.TotalDamage>0 || b.Statistic.TotalHealing > 0)
+                    e.data.Add(new UnitBattleReportDetail()
                     {
-                        e.data.Add(new UnitBattleReportDetail()
-                        {
-                            PlayerUUID = b.PlayerUUID,
-                            TotalDamage = (int)b.Statistic.TotalDamage,
-                            TotalHealing = (int)b.Statistic.TotalHealing,
-                        });
-                    }
-                    
+                        PlayerUUID = b.PlayerUUID,
+                        TemplateID = b.Info.TemplateID,
+                        TotalDamage = (int)b.Statistic.TotalDamage,
+                        TotalHealing = (int)b.Statistic.TotalHealing,
+                    });
                 }
             }
             api.ZoneAPI.queueEvent(e);