Просмотр исходного кода

【增加】添加单位接口

johnclot69 2 лет назад
Родитель
Сommit
a9bde10ed4

+ 18 - 13
Config/Proto/OuterMessage_C_10001.proto

@@ -239,37 +239,42 @@ message G2C_BindPlayer // IResponse
 	Player Player = 4;
 }
 
-message G2C_TestHotfixMessage // IMessage
-{
-	string Info = 1;
-}
-
-//ResponseType M2C_TestRobotCase
-message C2M_TestRobotCase // IActorLocationRequest
+//ResponseType G2C_AddUnitsToMap
+message C2G_AddUnitsToMap // IActorLocationRequest
 {
 	int32 RpcId = 1;
-	int32 N = 2;
+	int32 UnitId = 2;	// 单位模板ID
+	int32 Force = 3;	// 阵营信息 0-无 1-怪物 2-阵营a 3-阵营b
+	string Flag = 4;	// 编辑器配置的出生点, 为空则读xy
+	int32 X = 5;
+	int32 Y = 6;
 }
 
-message M2C_TestRobotCase // IActorLocationResponse
+message G2C_AddUnitsToMap // IActorLocationResponse
 {
 	int32 RpcId = 1;
 	int32 Error = 2;
 	string Message = 3;
-	int32 N = 4;
 }
 
-//ResponseType M2C_TransferMap
-message C2M_TransferMap // IActorLocationRequest
+message G2C_TestHotfixMessage // IMessage
+{
+	string Info = 1;
+}
+
+//ResponseType M2C_TestRobotCase
+message C2M_TestRobotCase // IActorLocationRequest
 {
 	int32 RpcId = 1;
+	int32 N = 2;
 }
 
-message M2C_TransferMap // IActorLocationResponse
+message M2C_TestRobotCase // IActorLocationResponse
 {
 	int32 RpcId = 1;
 	int32 Error = 2;
 	string Message = 3;
+	int32 N = 4;
 }
 
 //ResponseType G2C_Benchmark

+ 20 - 20
DotNet/Hotfix/Scenes/Game/GameMapComponentSystem.cs

@@ -2,33 +2,33 @@
 
 namespace ET.Server
 {
-    public class GameMapComponentAwakeSystem: AwakeSystem<GameMapComponent>
+    [FriendOf(typeof (GameMapComponent))]
+    public static class GameMapComponentSystem
     {
-        /// <summary>
-        /// 游戏服场景组件创建
-        /// </summary>
-        /// <param name="self"></param>
-        protected override void Awake(GameMapComponent self)
+        public class GameMapComponentAwakeSystem: AwakeSystem<GameMapComponent>
         {
-            // todo 添加场景销毁检测定时器
+            /// <summary>
+            /// 游戏服场景组件创建
+            /// </summary>
+            /// <param name="self"></param>
+            protected override void Awake(GameMapComponent self)
+            {
+                // todo 添加场景销毁检测定时器
+            }
         }
-    }
 
-    public class GameMapComponentDestroySystem: DestroySystem<GameMapComponent>
-    {
-        /// <summary>
-        /// 游戏服场景组件销毁
-        /// </summary>
-        /// <param name="self"></param>
-        /// <exception cref="NotImplementedException"></exception>
-        protected override void Destroy(GameMapComponent self)
+        public class GameMapComponentDestroySystem: DestroySystem<GameMapComponent>
         {
+            /// <summary>
+            /// 游戏服场景组件销毁
+            /// </summary>
+            /// <param name="self"></param>
+            /// <exception cref="NotImplementedException"></exception>
+            protected override void Destroy(GameMapComponent self)
+            {
+            }
         }
-    }
 
-    [FriendOf(typeof (GameMapComponent))]
-    public static class GameMapComponentSystem
-    {
         public static void Add(this GameMapComponent self, Map map)
         {
             self.allMaps.TryAdd(map.Id, map);

+ 18 - 18
DotNet/Hotfix/Scenes/Game/GamePlayerComponentSystem.cs

@@ -2,31 +2,31 @@
 
 namespace ET.Server
 {
-    public class PlayerComponentAwakeSystem: AwakeSystem<GamePlayerComponent>
+    [FriendOf(typeof (GamePlayerComponent))]
+    public static class GamePlayerComponentSystem
     {
-        /// <summary>
-        /// 游戏服在线玩家组件创建
-        /// </summary>
-        /// <param name="self"></param>
-        protected override void Awake(GamePlayerComponent self)
+        public class PlayerComponentAwakeSystem: AwakeSystem<GamePlayerComponent>
         {
+            /// <summary>
+            /// 游戏服在线玩家组件创建
+            /// </summary>
+            /// <param name="self"></param>
+            protected override void Awake(GamePlayerComponent self)
+            {
+            }
         }
-    }
 
-    public class PlayerComponentDestroySystem: DestroySystem<GamePlayerComponent>
-    {
-        /// <summary>
-        /// 游戏服在线玩家组件销毁
-        /// </summary>
-        /// <param name="self"></param>
-        protected override void Destroy(GamePlayerComponent self)
+        public class PlayerComponentDestroySystem: DestroySystem<GamePlayerComponent>
         {
+            /// <summary>
+            /// 游戏服在线玩家组件销毁
+            /// </summary>
+            /// <param name="self"></param>
+            protected override void Destroy(GamePlayerComponent self)
+            {
+            }
         }
-    }
 
-    [FriendOf(typeof (GamePlayerComponent))]
-    public static class GamePlayerComponentSystem
-    {
         public static void Add(this GamePlayerComponent self, long playerId, WNPlayer player)
         {
             self.idPlayers[playerId] = player;

+ 52 - 0
DotNet/Hotfix/Scenes/Game/Handler/C2G_AddUnitsToMapHandler.cs

@@ -0,0 +1,52 @@
+using System;
+
+namespace ET.Server
+{
+    /// <summary>
+    /// 向场景增加单位
+    /// </summary>
+    [MessageHandler(SceneType.Game)]
+    public class C2G_AddUnitsToMapHandler: AMRpcHandler<C2G_AddUnitsToMap, G2C_AddUnitsToMap>
+    {
+        protected override async ETTask Run(Session session, C2G_AddUnitsToMap request, G2C_AddUnitsToMap response, Action reply)
+        {
+            WNPlayer player = session.GetComponent<SessionPlayerComponent>().GetMyPlayer();
+            if (player == null)
+            {
+                Log.Debug($"操作错误, player is null");
+                response.Error = ErrorCode.ERR_OperationError;
+                reply();
+                return;
+            }
+            // 参数判断
+            if (request.UnitId <= 0 || request.Force < 0 || request.Force > (int)AreaForce.FORCEB || request.X < 0 || request.Y < 0)
+            {
+                Log.Debug($"参数错误...unitId={request.UnitId}, force={request.Force}");
+                response.Error = ErrorCode.ERR_ParameterError;
+                reply();
+                return;
+            }
+            // 配置是否能找到
+            Monster prop = MonsterCategory.Instance.Get(request.UnitId);
+            if (prop == null)
+            {
+                Log.Debug($"添加单位出错, 未找到配置...unitId={request.UnitId}, playerId={player.GetId()}");
+                response.Error = ErrorCode.ERR_ConfigError;
+                reply();
+                return;
+            }
+
+            Struct.MonsterUnit unit = new Struct.MonsterUnit();
+            unit.id = prop.Id;
+            unit.force = request.Force;
+            unit.flag = request.Flag;
+            unit.x = request.X;
+            unit.y = request.Y;
+            unit.autoGuard = true;
+
+            await player.Map.AddUnitsToMap(unit, false);
+
+            reply();
+        }
+    }
+}

+ 56 - 25
DotNet/Hotfix/Scenes/Game/Map/MapSystem.cs

@@ -1,43 +1,46 @@
 using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
 using BattleIce;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
 
 namespace ET.Server
 {
-    public class MapAwakeSystem: AwakeSystem<Map, JObject>
+    [FriendOf(typeof (Map))]
+    [FriendOf(typeof (BattleIceAgentComponent))]
+    public static class MapSystem
     {
-        /// <summary>
-        /// 本地地图场景实体创建
-        /// </summary>
-        /// <param name="self"></param>
-        protected override void Awake(Map self, JObject opts)
+        public class MapAwakeSystem: AwakeSystem<Map, JObject>
         {
-            self.createTime = TimeHelper.ServerNow();
+            /// <summary>
+            /// 本地地图场景实体创建
+            /// </summary>
+            /// <param name="self"></param>
+            /// <param name="opts"></param>
+            protected override void Awake(Map self, JObject opts)
+            {
+                self.createTime = TimeHelper.ServerNow();
 
-            Log.Debug($"create area opts:{opts}");
-            self.LogicServerId = opts.SelectToken("logicServerId") != null? Convert.ToInt32(opts.SelectToken("logicServerId")) : 0;
-            self.MapId = Convert.ToInt32(opts.SelectToken("areaId"));
-            self.Prop = MapConfigCategory.Instance.Get(self.MapId);
-            self.Type = self.Prop.Type;
+                Log.Debug($"create area opts:{opts}");
+                self.LogicServerId = opts.SelectToken("logicServerId") != null? Convert.ToInt32(opts.SelectToken("logicServerId")) : 0;
+                self.MapId = Convert.ToInt32(opts.SelectToken("areaId"));
+                self.Prop = MapConfigCategory.Instance.Get(self.MapId);
+                self.Type = self.Prop.Type;
+            }
         }
-    }
 
-    public class MapDestroySystem: DestroySystem<Map>
-    {
-        /// <summary>
-        /// 本地地图场景实体销毁
-        /// </summary>
-        /// <param name="self"></param>
-        protected override void Destroy(Map self)
+        public class MapDestroySystem: DestroySystem<Map>
         {
+            /// <summary>
+            /// 本地地图场景实体销毁
+            /// </summary>
+            /// <param name="self"></param>
+            protected override void Destroy(Map self)
+            {
+            }
         }
-    }
 
-    [FriendOf(typeof (Map))]
-    [FriendOf(typeof (BattleIceAgentComponent))]
-    public static class MapSystem
-    {
         public static ZoneManagerPrx GetZoneManager(this Map self)
         {
             return self.DomainScene().GetComponent<BattleIceAgentComponent>().IceZoneManager;
@@ -144,9 +147,37 @@ namespace ET.Server
         {
         }
 
+        /** 绑定战斗服 **/
         public static void BindBattleServer(this Map self, WNPlayer player, string serverId)
         {
             self.BattleServerId = serverId;
         }
+
+        public static async ETTask<int> AddUnits(this Map self, string instanceId, string data)
+        {
+            await ETTask.CompletedTask;
+            return self.GetXmdsManager().addUnits(instanceId.Trim(), data);
+        }
+
+        /** 创建单位 **/
+        public static async ETTask<int> AddUnitsToMap(this Map self, Struct.MonsterUnit unit, bool needReturn)
+        {
+            List<Struct.MonsterUnit> listData = new List<Struct.MonsterUnit>();
+            listData.Add(unit);
+
+            int addUnitsResult = 0;
+
+            if (needReturn) {
+                addUnitsResult = self.GetXmdsManager().addUnits(self.Id.ToString().Trim(), JsonConvert.SerializeObject(listData, Formatting.Indented));
+            } else
+            {
+                int objId = await self.AddUnits(self.Id.ToString().Trim(), "");
+                Log.Info($"addUnitsToArea: mapId={self.MapId}, instanceId={self.Id.ToString().Trim()}, objId={objId}");
+            }
+
+            Log.Info($"addUnitsToArea: mapId={self.MapId}, instanceId={self.Id.ToString().Trim()}, data={listData}, add units result={addUnitsResult}");
+
+            return addUnitsResult;
+        }
     }
 }

+ 24 - 24
DotNet/Hotfix/Scenes/Game/Player/PlayerDataComponentSystem.cs

@@ -1,36 +1,36 @@
 namespace ET.Server
 {
-    public class PlayerDataComponentaAwakeSystem: AwakeSystem<PlayerDataComponent, PlayerInfo, WNPlayer>
+    [FriendOf(typeof (PlayerDataComponent))]
+    public static class PlayerDataComponentSystem
     {
-        /// <summary>
-        /// 玩家基础数据组件创建
-        /// </summary>
-        /// <param name="self"></param>
-        /// <param name="info"></param>
-        /// <param name="player"></param>
-        protected override void Awake(PlayerDataComponent self, PlayerInfo info, WNPlayer player)
+        public class PlayerDataComponentaAwakeSystem: AwakeSystem<PlayerDataComponent, PlayerInfo, WNPlayer>
         {
-            self.Player = player;
-            self.Data = info;
+            /// <summary>
+            /// 玩家基础数据组件创建
+            /// </summary>
+            /// <param name="self"></param>
+            /// <param name="info"></param>
+            /// <param name="player"></param>
+            protected override void Awake(PlayerDataComponent self, PlayerInfo info, WNPlayer player)
+            {
+                self.Player = player;
+                self.Data = info;
+            }
         }
-    }
 
-    public class PlayerDataComponentDestroySystem: DestroySystem<PlayerDataComponent>
-    {
-        /// <summary>
-        /// 玩家基础数据组件销毁
-        /// </summary>
-        /// <param name="self"></param>
-        protected override void Destroy(PlayerDataComponent self)
+        public class PlayerDataComponentDestroySystem: DestroySystem<PlayerDataComponent>
         {
-            Log.Debug($"玩家基础数据保存");
-            self?.Save();
+            /// <summary>
+            /// 玩家基础数据组件销毁
+            /// </summary>
+            /// <param name="self"></param>
+            protected override void Destroy(PlayerDataComponent self)
+            {
+                Log.Debug($"玩家基础数据保存");
+                self?.Save();
+            }
         }
-    }
 
-    [FriendOf(typeof (PlayerDataComponent))]
-    public static class PlayerDataComponentSystem
-    {
         public static async ETTask Save(this PlayerDataComponent self)
         {
             if (self.Data != null)

+ 13 - 13
DotNet/Hotfix/Scenes/Game/Player/PlayerMoneyComponentSystem.cs

@@ -1,25 +1,25 @@
 namespace ET.Server
 {
-    public class PlayerMoneyComponentAwakeSystem: AwakeSystem<PlayerMoneyComponent, WNPlayer>
+    [FriendOf(typeof (PlayerMoneyComponent))]
+    public static class PlayerMoneyComponentSystem
     {
-        protected override void Awake(PlayerMoneyComponent self, WNPlayer player)
+        public class PlayerMoneyComponentAwakeSystem: AwakeSystem<PlayerMoneyComponent, WNPlayer>
         {
-            self.Player = player;
+            protected override void Awake(PlayerMoneyComponent self, WNPlayer player)
+            {
+                self.Player = player;
+            }
         }
-    }
 
-    public class PlayerMoneyComponentDestroySystem: DestroySystem<PlayerMoneyComponent>
-    {
-        protected override void Destroy(PlayerMoneyComponent self)
+        public class PlayerMoneyComponentDestroySystem: DestroySystem<PlayerMoneyComponent>
         {
-            Log.Debug($"玩家货币数据保存");
-            self?.Save();
+            protected override void Destroy(PlayerMoneyComponent self)
+            {
+                Log.Debug($"玩家货币数据保存");
+                self?.Save();
+            }
         }
-    }
 
-    [FriendOf(typeof (PlayerMoneyComponent))]
-    public static class PlayerMoneyComponentSystem
-    {
         public static async ETTask Save(this PlayerMoneyComponent self)
         {
             await ETTask.CompletedTask;

+ 35 - 35
DotNet/Hotfix/Scenes/Game/Player/PlayerSystem.cs

@@ -4,47 +4,47 @@ using BattleIce;
 
 namespace ET.Server
 {
-    public class PlayerAwakeSystem: AwakeSystem<WNPlayer, Session, PlayerInfo>
+    [FriendOf(typeof (WNPlayer))]
+    [FriendOf(typeof (BattleIceAgentComponent))]
+    public static class PlayerSystem
     {
-        /// <summary>
-        /// 玩家实体创建
-        /// </summary>
-        /// <param name="self"></param>
-        /// <param name="session"></param>
-        /// <param name="playerInfo"></param>
-        protected override void Awake(WNPlayer self, Session session, PlayerInfo playerInfo)
+        public class PlayerAwakeSystem: AwakeSystem<WNPlayer, Session, PlayerInfo>
         {
-            // 绑定sessionId
-            self.GameSessionActorId = session.InstanceId;
-            self.Session = session;
-            self.BasicProp = CharacterCategory.Instance.Get(playerInfo.Pro);
-            self.BornType = (int)BORN_TYPE.NORMAL;
-            self.EnterState = (int)ENTER_STATE.online;
-            // 玩家基础数据组件
-            self.AddComponent<PlayerDataComponent, PlayerInfo, WNPlayer>(playerInfo, self);
-            // 玩家临时数据组件
-            self.AddComponent<PlayerTempDataComponent, WNPlayer>(self);
-            // 玩家货币组件
-            self.AddComponent<PlayerMoneyComponent, WNPlayer>(self);
+            /// <summary>
+            /// 玩家实体创建
+            /// </summary>
+            /// <param name="self"></param>
+            /// <param name="session"></param>
+            /// <param name="playerInfo"></param>
+            protected override void Awake(WNPlayer self, Session session, PlayerInfo playerInfo)
+            {
+                // 绑定sessionId
+                self.GameSessionActorId = session.InstanceId;
+                self.Session = session;
+                self.BasicProp = CharacterCategory.Instance.Get(playerInfo.Pro);
+                self.BornType = (int)BORN_TYPE.NORMAL;
+                self.EnterState = (int)ENTER_STATE.online;
+                // 玩家基础数据组件
+                self.AddComponent<PlayerDataComponent, PlayerInfo, WNPlayer>(playerInfo, self);
+                // 玩家临时数据组件
+                self.AddComponent<PlayerTempDataComponent, WNPlayer>(self);
+                // 玩家货币组件
+                self.AddComponent<PlayerMoneyComponent, WNPlayer>(self);
+            }
         }
-    }
 
-    public class PlayerDestroySystem: DestroySystem<WNPlayer>
-    {
-        /// <summary>
-        /// 玩家实体销毁
-        /// </summary>
-        /// <param name="self"></param>
-        protected override void Destroy(WNPlayer self)
+        public class PlayerDestroySystem: DestroySystem<WNPlayer>
         {
-            Log.Info($"玩家实体销毁...");
+            /// <summary>
+            /// 玩家实体销毁
+            /// </summary>
+            /// <param name="self"></param>
+            protected override void Destroy(WNPlayer self)
+            {
+                Log.Info($"玩家实体销毁...");
+            }
         }
-    }
 
-    [FriendOf(typeof (WNPlayer))]
-    [FriendOf(typeof (BattleIceAgentComponent))]
-    public static class PlayerSystem
-    {
         /// <summary>
         /// 获取角色id
         /// </summary>
@@ -286,7 +286,7 @@ namespace ET.Server
                 addTestPetData = 0,
                 sceneData = new { allowAutoGuard = 3, },
             };
-            var retjson = System.Text.Json.JsonSerializer.Serialize(json, new JsonSerializerOptions { IncludeFields = true });
+            string retjson = JsonSerializer.Serialize(json, new JsonSerializerOptions { IncludeFields = true });
             Log.Debug("===================================");
             Log.Debug(retjson.ToString());
             Log.Debug("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");

+ 22 - 22
DotNet/Hotfix/Scenes/Game/Player/PlayerTempDataComponentSystem.cs

@@ -3,35 +3,35 @@ using BattleIce;
 
 namespace ET.Server
 {
-    public class PlayerTempDataComponentAwakeSystem: AwakeSystem<PlayerTempDataComponent, WNPlayer>
+    [FriendOf(typeof (PlayerTempDataComponent))]
+    public static class PlayerTempDataComponentSystem
     {
-        /// <summary>
-        /// 玩家临时数据组件创建
-        /// </summary>
-        /// <param name="self"></param>
-        /// <param name="player"></param>
-        protected override void Awake(PlayerTempDataComponent self, WNPlayer player)
+        public class PlayerTempDataComponentAwakeSystem: AwakeSystem<PlayerTempDataComponent, WNPlayer>
         {
-            self.Player = player;
+            /// <summary>
+            /// 玩家临时数据组件创建
+            /// </summary>
+            /// <param name="self"></param>
+            /// <param name="player"></param>
+            protected override void Awake(PlayerTempDataComponent self, WNPlayer player)
+            {
+                self.Player = player;
+            }
         }
-    }
 
-    public class PlayerTempDataComponentDestroySystem: DestroySystem<PlayerTempDataComponent>
-    {
-        /// <summary>
-        /// 玩家临时数据组件销毁
-        /// </summary>
-        /// <param name="self"></param>
-        protected override void Destroy(PlayerTempDataComponent self)
+        public class PlayerTempDataComponentDestroySystem: DestroySystem<PlayerTempDataComponent>
         {
-            Log.Debug($"玩家临时数据保存");
-            self?.Save();
+            /// <summary>
+            /// 玩家临时数据组件销毁
+            /// </summary>
+            /// <param name="self"></param>
+            protected override void Destroy(PlayerTempDataComponent self)
+            {
+                Log.Debug($"玩家临时数据保存");
+                self?.Save();
+            }
         }
-    }
 
-    [FriendOf(typeof (PlayerTempDataComponent))]
-    public static class PlayerTempDataComponentSystem
-    {
         public static async ETTask InitFromDB(this PlayerTempDataComponent self)
         {
             List<PlayerMapInfo> list = await DBManagerComponent.Instance.GetZoneDB(self.DomainZone())

+ 30 - 30
DotNet/Hotfix/Scenes/Game/Player/SessionPlayerComponentSystem.cs

@@ -3,49 +3,49 @@ using System.Linq;
 
 namespace ET.Server
 {
-    public class SessionPlayerComponentAwakeSystem: AwakeSystem<SessionPlayerComponent>
-    {
-        protected override void Awake(SessionPlayerComponent self)
+    [FriendOf(typeof (SessionPlayerComponent))]
+	public static class SessionPlayerComponentSystem
+	{
+        public class SessionPlayerComponentAwakeSystem: AwakeSystem<SessionPlayerComponent>
         {
-            self?.Init();
+            protected override void Awake(SessionPlayerComponent self)
+            {
+                self?.Init();
+            }
         }
-    }
 
-    public class SessionPlayerComponentDestroySystem: DestroySystem<SessionPlayerComponent>
-    {
-        protected override void Destroy(SessionPlayerComponent self)
+        public class SessionPlayerComponentDestroySystem: DestroySystem<SessionPlayerComponent>
         {
-            WNPlayer player = self.GetMyPlayer();
-            if (player == null)
+            protected override void Destroy(SessionPlayerComponent self)
             {
-                return;
-            }
+                WNPlayer player = self.GetMyPlayer();
+                if (player == null)
+                {
+                    return;
+                }
 
-            Log.Info($"玩家断线了, playerId={self.PlayerId}, name={player.GetName()}");
+                Log.Info($"玩家断线了, playerId={self.PlayerId}, name={player.GetName()}");
 
-            // 玩家离开
-            player.GetComponent<PlayerTempDataComponent>().MapData.ready = false;
+                // 玩家离开
+                player.GetComponent<PlayerTempDataComponent>().MapData.ready = false;
 
-            Map map = player.Map;
-            if (map != null)
-            {
-                // 记录玩家历史
-                map.SyncPlayerHistoryData(player);
-                // 场景移除玩家
-                map.RemovePlayer(player, false);
+                Map map = player.Map;
+                if (map != null)
+                {
+                    // 记录玩家历史
+                    map.SyncPlayerHistoryData(player);
+                    // 场景移除玩家
+                    map.RemovePlayer(player, false);
 
-                map.PlayerLeaveRequest(player, false);
-            }
+                    map.PlayerLeaveRequest(player, false);
+                }
 
-            self.DomainScene().GetComponent<GamePlayerComponent>().Remove(player.GetId());
+                self.DomainScene().GetComponent<GamePlayerComponent>().Remove(player.GetId());
 
-            player.Dispose();
+                player.Dispose();
+            }
         }
-    }
 
-    [FriendOf(typeof (SessionPlayerComponent))]
-	public static class SessionPlayerComponentSystem
-	{
         /// <summary>
         /// 初始化数据
         /// </summary>

+ 7 - 7
DotNet/Hotfix/Scenes/Realm/UserSessionComponentSystem.cs

@@ -1,16 +1,16 @@
 namespace ET.Server
 {
-    public class UserSessionComponentDestroySystem: DestroySystem<UserSessionComponent>
+    [FriendOf(typeof(UserSessionComponent))]
+    public static class UserSessionComponentSystem
     {
-        protected override void Destroy(UserSessionComponent self)
+        public class UserSessionComponentDestroySystem: DestroySystem<UserSessionComponent>
         {
-            self.UserSession.Clear();
+            protected override void Destroy(UserSessionComponent self)
+            {
+                self.UserSession.Clear();
+            }
         }
-    }
 
-    [FriendOf(typeof(UserSessionComponent))]
-    public static class UserSessionComponentSystem
-    {
         public static long Get(this UserSessionComponent self, long userId)
         {
             if (!self.UserSession.TryGetValue(userId, out long instanceId))

+ 42 - 27
DotNet/Model/Generate/Message/OuterMessage_C_10001.cs

@@ -491,31 +491,34 @@ namespace ET
 
 	}
 
-	[Message(OuterMessage.G2C_TestHotfixMessage)]
-	[ProtoContract]
-	public partial class G2C_TestHotfixMessage: ProtoObject, IMessage
-	{
-		[ProtoMember(1)]
-		public string Info { get; set; }
-
-	}
-
-	[ResponseType(nameof(M2C_TestRobotCase))]
-	[Message(OuterMessage.C2M_TestRobotCase)]
+	[ResponseType(nameof(G2C_AddUnitsToMap))]
+	[Message(OuterMessage.C2G_AddUnitsToMap)]
 	[ProtoContract]
-	public partial class C2M_TestRobotCase: ProtoObject, IActorLocationRequest
+	public partial class C2G_AddUnitsToMap: ProtoObject, IActorLocationRequest
 	{
 		[ProtoMember(1)]
 		public int RpcId { get; set; }
 
 		[ProtoMember(2)]
-		public int N { get; set; }
+		public int UnitId { get; set; }
+
+		[ProtoMember(3)]
+		public int Force { get; set; }
+
+		[ProtoMember(4)]
+		public string Flag { get; set; }
+
+		[ProtoMember(5)]
+		public int X { get; set; }
+
+		[ProtoMember(6)]
+		public int Y { get; set; }
 
 	}
 
-	[Message(OuterMessage.M2C_TestRobotCase)]
+	[Message(OuterMessage.G2C_AddUnitsToMap)]
 	[ProtoContract]
-	public partial class M2C_TestRobotCase: ProtoObject, IActorLocationResponse
+	public partial class G2C_AddUnitsToMap: ProtoObject, IActorLocationResponse
 	{
 		[ProtoMember(1)]
 		public int RpcId { get; set; }
@@ -526,24 +529,33 @@ namespace ET
 		[ProtoMember(3)]
 		public string Message { get; set; }
 
-		[ProtoMember(4)]
-		public int N { get; set; }
+	}
+
+	[Message(OuterMessage.G2C_TestHotfixMessage)]
+	[ProtoContract]
+	public partial class G2C_TestHotfixMessage: ProtoObject, IMessage
+	{
+		[ProtoMember(1)]
+		public string Info { get; set; }
 
 	}
 
-	[ResponseType(nameof(M2C_TransferMap))]
-	[Message(OuterMessage.C2M_TransferMap)]
+	[ResponseType(nameof(M2C_TestRobotCase))]
+	[Message(OuterMessage.C2M_TestRobotCase)]
 	[ProtoContract]
-	public partial class C2M_TransferMap: ProtoObject, IActorLocationRequest
+	public partial class C2M_TestRobotCase: ProtoObject, IActorLocationRequest
 	{
 		[ProtoMember(1)]
 		public int RpcId { get; set; }
 
+		[ProtoMember(2)]
+		public int N { get; set; }
+
 	}
 
-	[Message(OuterMessage.M2C_TransferMap)]
+	[Message(OuterMessage.M2C_TestRobotCase)]
 	[ProtoContract]
-	public partial class M2C_TransferMap: ProtoObject, IActorLocationResponse
+	public partial class M2C_TestRobotCase: ProtoObject, IActorLocationResponse
 	{
 		[ProtoMember(1)]
 		public int RpcId { get; set; }
@@ -554,6 +566,9 @@ namespace ET
 		[ProtoMember(3)]
 		public string Message { get; set; }
 
+		[ProtoMember(4)]
+		public int N { get; set; }
+
 	}
 
 	[ResponseType(nameof(G2C_Benchmark))]
@@ -631,11 +646,11 @@ namespace ET
 		 public const ushort G2C_CreatePlayer = 10032;
 		 public const ushort C2G_BindPlayer = 10033;
 		 public const ushort G2C_BindPlayer = 10034;
-		 public const ushort G2C_TestHotfixMessage = 10035;
-		 public const ushort C2M_TestRobotCase = 10036;
-		 public const ushort M2C_TestRobotCase = 10037;
-		 public const ushort C2M_TransferMap = 10038;
-		 public const ushort M2C_TransferMap = 10039;
+		 public const ushort C2G_AddUnitsToMap = 10035;
+		 public const ushort G2C_AddUnitsToMap = 10036;
+		 public const ushort G2C_TestHotfixMessage = 10037;
+		 public const ushort C2M_TestRobotCase = 10038;
+		 public const ushort M2C_TestRobotCase = 10039;
 		 public const ushort C2G_Benchmark = 10040;
 		 public const ushort G2C_Benchmark = 10041;
 		 public const ushort R2C_Disconnect = 10042;

+ 0 - 59
DotNet/Model/Scenes/Game/Struct.cs

@@ -1,59 +0,0 @@
-namespace ET.Server
-{
-    /// <summary>
-    /// 游戏服数据结构
-    /// </summary>
-    public class Struct
-    {
-
-        public class AreaData
-        {
-            public MapConfig prop { get; set; }
-            public int areaId { get; set; }
-            public long instanceId { get; set; }
-            public float targetX { get; set; }
-            public float targetY { get; set; }
-            public int logicServerId { get; set; }
-            public ENTER_TYPE enterType = ENTER_TYPE.NONE;
-
-            public AreaData(int areaId) {
-                this.prop = MapConfigCategory.Instance.Get(areaId);
-                this.areaId = areaId;
-            }
-
-            public AreaData(MapConfig prop) {
-                this.areaId = prop.Id;
-                this.prop = prop;
-            }
-
-            public AreaData(int areaId, long instanceId) {
-                this.prop = MapConfigCategory.Instance.Get(areaId);
-                this.areaId = areaId;
-                this.instanceId = instanceId;
-            }
-
-            public AreaData(int areaId, float targetX, float targetY) {
-                this.prop = MapConfigCategory.Instance.Get(areaId);
-                this.areaId = areaId;
-                this.targetX = targetX;
-                this.targetY = targetY;
-            }
-
-            public AreaData(int areaId, float targetX, float targetY, ENTER_TYPE enterType) {
-                this.prop = MapConfigCategory.Instance.Get(areaId);
-                this.areaId = areaId;
-                this.targetX = targetX;
-                this.targetY = targetY;
-                this.enterType = enterType;
-            }
-
-            public AreaData(int areaId, long instanceId, ENTER_TYPE enterType) {
-                this.prop = MapConfigCategory.Instance.Get(areaId);
-                this.areaId = areaId;
-                this.instanceId = instanceId;
-                this.enterType = enterType;
-            }
-        }
-
-    }
-}

+ 124 - 0
Unity/Assets/Scripts/Codes/Model/Share/Const/Struct.cs

@@ -0,0 +1,124 @@
+namespace ET.Server
+{
+    /// <summary>
+    /// 游戏服数据结构
+    /// </summary>
+    public class Struct
+    {
+        /// <summary>
+        /// 场景数据
+        /// </summary>
+        public class AreaData
+        {
+            public MapConfig prop { get; set; }
+            public int areaId { get; set; }
+            public long instanceId { get; set; }
+            public float targetX { get; set; }
+            public float targetY { get; set; }
+            public int logicServerId { get; set; }
+            public ENTER_TYPE enterType = ENTER_TYPE.NONE;
+
+            public AreaData(int areaId) {
+                this.prop = MapConfigCategory.Instance.Get(areaId);
+                this.areaId = areaId;
+            }
+
+            public AreaData(MapConfig prop) {
+                this.areaId = prop.Id;
+                this.prop = prop;
+            }
+
+            public AreaData(int areaId, long instanceId) {
+                this.prop = MapConfigCategory.Instance.Get(areaId);
+                this.areaId = areaId;
+                this.instanceId = instanceId;
+            }
+
+            public AreaData(int areaId, float targetX, float targetY) {
+                this.prop = MapConfigCategory.Instance.Get(areaId);
+                this.areaId = areaId;
+                this.targetX = targetX;
+                this.targetY = targetY;
+            }
+
+            public AreaData(int areaId, float targetX, float targetY, ENTER_TYPE enterType) {
+                this.prop = MapConfigCategory.Instance.Get(areaId);
+                this.areaId = areaId;
+                this.targetX = targetX;
+                this.targetY = targetY;
+                this.enterType = enterType;
+            }
+
+            public AreaData(int areaId, long instanceId, ENTER_TYPE enterType) {
+                this.prop = MapConfigCategory.Instance.Get(areaId);
+                this.areaId = areaId;
+                this.instanceId = instanceId;
+                this.enterType = enterType;
+            }
+        }
+
+        /// <summary>
+        /// 怪物单位数据
+        /// </summary>
+        public class MonsterUnit
+        {
+            /** 怪物名字 **/
+            public string name{ get; set; }
+            /** 怪物模板ID **/
+            public int id{ get; set; }
+            /** 阵营信息 **/
+            public int force{ get; set; }
+            /** 刷新点名字,为空才去读x, y **/
+            public string flag{ get; set; }
+
+            public bool autoGuard{ get; set; }
+            /** 同一个Area是否只能同时有一个怪存在 **/
+            public bool unique = false;
+            /** 坐标x **/
+            public int x{ get; set; }
+            /** 坐标y **/
+            public int y{ get; set; }
+            /** 是否是任务 共享怪 **/
+            public int shareType{ get; set; }
+            /** 动态怪物等级,战斗服根据此计算怪物的动态数值 **/
+            public int level{ get; set; }
+            /** 初始朝向 **/
+            public float birthDirection{ get; set; }
+            /** 服务器标记字段,怪物死亡时,会回传回来 **/
+            public int gsFlag{ get; set; }
+            /** 指定血量 **/
+            public int hp{ get; set; }
+            public int maxHP{ get; set; }
+            /** 指定追击玩家id(必须是无限追击怪才会联动生效) **/
+            public string attackPlayer{ get; set; }
+            /** 创建护卫怪,主人ObjectId(主人脱战或者死亡消失) **/
+            public int masterID{ get; set; }
+
+            public MonsterUnit() {
+            }
+
+            public MonsterUnit(int monsterID, int force, bool unique, int x, int y) {
+                this.id = monsterID;
+                this.force = force;
+                this.unique = unique;
+                this.x = x;
+                this.y = y;
+            }
+
+            public MonsterUnit(int monsterID, string refrushEvent, bool unique, int force) {
+                this.id = monsterID;
+                this.force = force;
+                this.unique = unique;
+                this.flag = refrushEvent;
+            }
+
+            public MonsterUnit(int monsterID, string refrushEvent, bool unique, int force, float birthDirection) {
+                this.id = monsterID;
+                this.force = force;
+                this.unique = unique;
+                this.flag = refrushEvent;
+                this.birthDirection = birthDirection;
+            }
+        }
+    }
+}

+ 2 - 0
Unity/Assets/Scripts/Codes/Model/Share/Module/Message/ErrorCode.cs

@@ -49,6 +49,8 @@
         public const int ERR_OperationToFast = 200018;
         /** 场景不存在 **/
         public const int ERR_EnterMapError = 200019;
+        /** 配置错误 **/
+        public const int ERR_ConfigError = 200020;
 
         public enum EnterMap
         {