Selaa lähdekoodia

增加faststream数据转发功能:收到战斗服推送后,转发给相关的客户端

大爷 2 vuotta sitten
vanhempi
commit
7394c7bee2
23 muutettua tiedostoa jossa 281 lisäystä ja 75 poistoa
  1. 8 0
      Config/Proto/ServerPush_CS_40001.proto
  2. 25 13
      DotNet/Hotfix/Demo/Scenes/Gate/Handler/C2G_EnterMapHandler.cs
  3. 37 1
      DotNet/Hotfix/Demo/Scenes/Gate/PlayerComponentSystem.cs
  4. 1 2
      DotNet/Hotfix/Demo/Scenes/Map/Transfer/M2M_UnitTransferRequestHandler.cs
  5. 2 2
      DotNet/Hotfix/Demo/Scenes/Map/Transfer/TransferHelper.cs
  6. 1 2
      DotNet/Hotfix/Demo/Scenes/Map/Unit/UnitFactory.cs
  7. 2 0
      DotNet/Hotfix/Demo/Scenes/Realm/Handler/C2R_LoginHandler.cs
  8. 1 0
      DotNet/Hotfix/DotNet.Hotfix.csproj
  9. 48 28
      DotNet/Hotfix/FastStream/FastStreamComponentSystem.cs
  10. 19 0
      DotNet/Hotfix/IceBattle/BattleIceAgentComponentSystem.cs
  11. 4 1
      DotNet/Model/Demo/Gate/PlayerComponent.cs
  12. 1 0
      DotNet/Model/DotNet.Model.csproj
  13. 23 0
      DotNet/Model/Generate/Message/ServerPush_CS_40001.cs
  14. 4 1
      DotNet/Model/Module/FastStream/FastStreamComponent.cs
  15. 47 0
      DotNet/Model/Module/FastStream/FastStreamMessageDecoder.cs
  16. 0 1
      DotNet/Model/Plugins/Example/ModelServer.cs
  17. 1 13
      Unity/Assets/Scripts/Codes/Hotfix/Share/Module/Unit/UnitComponentSystem.cs
  18. 11 2
      Unity/Assets/Scripts/Codes/Hotfix/Share/Module/Unit/UnitSystem.cs
  19. 23 0
      Unity/Assets/Scripts/Codes/Model/Client/Generate/Message/ServerPush_CS_40001.cs
  20. 11 0
      Unity/Assets/Scripts/Codes/Model/Client/Generate/Message/ServerPush_CS_40001.cs.meta
  21. 8 1
      Unity/Assets/Scripts/Codes/Model/Share/Const/ConstValue.cs
  22. 2 7
      Unity/Assets/Scripts/Codes/Model/Share/Module/Unit/Unit.cs
  23. 2 1
      Unity/Assets/Scripts/Codes/Model/Share/Module/Unit/UnitComponent.cs

+ 8 - 0
Config/Proto/ServerPush_CS_40001.proto

@@ -0,0 +1,8 @@
+syntax = "proto3";
+
+//战斗服发给游戏服后,游戏服推送给客户端
+message BattleEventPush // IActorMessage
+{
+  uint16 key = 1;
+  bytes data = 2;
+} 

+ 25 - 13
DotNet/Hotfix/Demo/Scenes/Gate/Handler/C2G_EnterMapHandler.cs

@@ -4,6 +4,7 @@ using System;
 using System.Collections.Generic;
 using System.Security.AccessControl;
 using System.Threading.Tasks;
+using Unity.Mathematics;
 using static ICSharpCode.SharpZipLib.Zip.ExtendedUnixData;
 
 
@@ -17,6 +18,7 @@ namespace ET.Server
         {
             if(BattleIceAgentComponent.Instance == null)
             {
+                Log.Error("Battle ice is null");
                 response.Error = (int)ErrorCode.EnterMap.BattleSvrErr;
                 reply();
                 return;
@@ -31,17 +33,32 @@ namespace ET.Server
             }
 
             Player player = session.GetComponent<SessionPlayerComponent>().GetMyPlayer();
+            var gatemap = player.GetComponent<GateMapComponent>();
+            if (gatemap != null)
+            {
+                player.RemoveComponent<GateMapComponent>();
+            }
+            GateMapComponent gateMapComponent = player.AddComponent<GateMapComponent>();
 
+            //TODO: 先从所有map scene中查找是不是已经存在
+            //TODO: 判断找到的scene人数是否已满等限制
             // 在Gate上动态创建一个Map Scene,把Unit从DB中加载放进来,然后传送到真正的Map中,这样登陆跟传送的逻辑就完全一样了
-            GateMapComponent gateMapComponent = player.AddComponent<GateMapComponent>();
-            gateMapComponent.Scene = await SceneFactory.CreateServerScene(gateMapComponent, player.Id, IdGenerater.Instance.GenerateInstanceId(), gateMapComponent.DomainZone(), "GateMap", SceneType.Map);
-            Scene scene = gateMapComponent.Scene;
+            var scene = await SceneFactory.CreateServerScene(gateMapComponent, player.Id, IdGenerater.Instance.GenerateInstanceId(), gateMapComponent.DomainZone(), "GateMap", SceneType.Map);
+            var scnInstance = scene.InstanceId.ToString();
+            gateMapComponent.Scene = scene;
 
-            // 这里可以从DB中加载Unit
-            Unit unit = Server.UnitFactory.Create(scene, player.Id, UnitType.Player);
+            //TODO: 这里需要从DB中加载Unit
+            UnitComponent unitComponent = scene.GetComponent<UnitComponent>();
+            Unit unit = unitComponent.AddChildWithId<Unit, int>(player.Id, 1001);
+            unit.AddComponent<MoveComponent>();
+            unit.Position = new float3(-10, 0, -10);
+            NumericComponent numericComponent = unit.AddComponent<NumericComponent>();
+            numericComponent.Set(NumericType.Speed, 6f); // 速度是6米每秒
+            numericComponent.Set(NumericType.AOI, 15000); // 视野15米
+            unit.AddComponent<AOIEntity, int, float3>(9 * 1000, unit.Position);
             unit.AddComponent<UnitGateComponent, long>(session.InstanceId);
 
-            var scnInstance = scene.InstanceId.ToString();
+
             //战斗服===================
             //通知战斗服创建副本
             var IceZone = BattleIceAgentComponent.Instance.IceZoneManager;
@@ -49,12 +66,7 @@ namespace ET.Server
             Log.Info($"Battle ice createZoneRequest ret: {ret}");
 
             //player进入副本,把player基本信息上报给战斗服
-            if (BattleIceAgentComponent.Instance == null)
-            {
-                Log.Error("Battle ice is null");
-                return;
-            }
-            IceZone.begin_playerEnterRequest(player.Id.ToString(), scnInstance, toJSON4EnterScene(ref player)).whenCompleted((Ice.Exception ex) => {
+            IceZone.begin_playerEnterRequest(unit.Id.ToString(), scnInstance, toJSON4EnterScene(ref unit)).whenCompleted((Ice.Exception ex) => {
                 Log.Error(ex.Message);
             });
 
@@ -88,7 +100,7 @@ namespace ET.Server
 
         //TODO:按照hotfix--model框架,这段逻辑应该放到modelComponet对应的ComponetSystem中
         //对应WNPlayer.java/toJSON4EnterScene
-        private string toJSON4EnterScene(ref Player info)
+        private string toJSON4EnterScene(ref Unit info)
         {
             var json = new
             {

+ 37 - 1
DotNet/Hotfix/Demo/Scenes/Gate/PlayerComponentSystem.cs

@@ -2,6 +2,28 @@
 
 namespace ET.Server
 {
+    public class PlayerComponentAwakeSystem : AwakeSystem<PlayerComponent>
+    {
+        protected override void Awake(PlayerComponent self)
+        {
+            PlayerComponent.PlayerComponentList.Add(self);
+        }
+    }
+    public class PlayerComponentDestroySystem : DestroySystem<PlayerComponent>
+    {
+        protected override void Destroy(PlayerComponent self)
+        {
+            foreach(var player in PlayerComponent.PlayerComponentList)
+            {
+                if(player == self)
+                {
+                    PlayerComponent.PlayerComponentList.Remove(player);
+                    return;
+                }
+            }
+        }
+    }
+
     [FriendOf(typeof(PlayerComponent))]
     public static class PlayerComponentSystem
     {
@@ -25,5 +47,19 @@ namespace ET.Server
         {
             return self.idPlayers.Values.ToArray();
         }
+
+        //从所有scene的 Playerlist中找到某个player
+        public static Player SearchAll(long id)
+        {
+            foreach(var component in PlayerComponent.PlayerComponentList)
+            {
+                var player = component.Get(id);
+                if(player != null)
+                {
+                    return player;
+                }
+            }
+            return null;
+        }
     }
-}
+}

+ 1 - 2
DotNet/Hotfix/Demo/Scenes/Map/Transfer/M2M_UnitTransferRequestHandler.cs

@@ -14,7 +14,6 @@ namespace ET.Server
 			Unit unit = MongoHelper.Deserialize<Unit>(request.Unit);
 			
 			unitComponent.AddChild(unit);
-			unitComponent.Add(unit);
 
 			foreach (byte[] bytes in request.Entitys)
 			{
@@ -44,4 +43,4 @@ namespace ET.Server
 			await LocationProxyComponent.Instance.UnLock(unit.Id, request.OldInstanceId, unit.InstanceId);
 		}
 	}
-}
+}

+ 2 - 2
DotNet/Hotfix/Demo/Scenes/Map/Transfer/TransferHelper.cs

@@ -21,10 +21,10 @@ namespace ET.Server
                     request.Entitys.Add(entity.ToBson());
                 }
             }
-            unit.Dispose();
+            //unit.Dispose();
             
             await LocationProxyComponent.Instance.Lock(unitId, unitInstanceId);
             await ActorMessageSenderComponent.Instance.Call(sceneInstanceId, request);
         }
     }
-}
+}

+ 1 - 2
DotNet/Hotfix/Demo/Scenes/Map/Unit/UnitFactory.cs

@@ -20,7 +20,6 @@ namespace ET.Server
                     numericComponent.Set(NumericType.Speed, 6f); // 速度是6米每秒
                     numericComponent.Set(NumericType.AOI, 15000); // 视野15米
                     
-                    unitComponent.Add(unit);
                     // 加入aoi
                     unit.AddComponent<AOIEntity, int, float3>(9 * 1000, unit.Position);
                     return unit;
@@ -30,4 +29,4 @@ namespace ET.Server
             }
         }
     }
-}
+}

+ 2 - 0
DotNet/Hotfix/Demo/Scenes/Realm/Handler/C2R_LoginHandler.cs

@@ -125,6 +125,8 @@ namespace ET.Server
             // 绑定session
             session.AddChild(userInfo);
 
+            //TODO: 服务器列表 & 角色列表
+
             // 随机分配一个Gate
             StartSceneConfig config = RealmGateAddressHelper.GetGate(session.DomainZone());
             Log.Debug($"随机一个网关地址: {MongoHelper.ToJson(config)}");

+ 1 - 0
DotNet/Hotfix/DotNet.Hotfix.csproj

@@ -29,6 +29,7 @@
     </ItemGroup>
     <ItemGroup>
       <PackageReference Include="SuperSocket.ClientEngine" Version="0.10.0" />
+      <PackageReference Include="SuperSocket.ProtoBase" Version="1.7.0.17" />
     </ItemGroup>
     <ItemGroup>
         <ProjectReference Include="..\..\Share\Analyzer\Share.Analyzer.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />

+ 48 - 28
DotNet/Hotfix/FastStream/FastStreamComponentSystem.cs

@@ -1,8 +1,9 @@
 using SuperSocket.ClientEngine;
+using SuperSocket.ProtoBase;
 using System;
+using System.Linq;
 using System.Net;
-using System.Reflection;
-using System.Threading;
+using ET;
 
 namespace ET.Server
 {
@@ -15,20 +16,20 @@ namespace ET.Server
             {
                 FastStreamComponent.Instance = self;
 
-                var session = new AsyncTcpSession();
-                self.Session = session;
-                session.NoDelay = true;
-                session.ReceiveBufferSize = 10* 1024;
+                var client = new EasyClient();
+                self.FastStreamClient = client;
+                client.Initialize<FastStreamBuffer>(new FastStreamMessageDecoder(FastStreamMessageDecoder.LEN_HEAD), (package) => { OnSessionDataReceived(package); });
+                client.NoDelay = true;
+                client.ReceiveBufferSize = 10* 1024 * 1024;
 
-                session.Connected += new EventHandler(OnSessionConnected);
-                session.Error += new EventHandler<ErrorEventArgs>(OnSessionError);
-                session.Closed += new EventHandler(OnSessionClosed);
-                session.DataReceived += new EventHandler<DataEventArgs>(OnSessionDataReceived);
+                client.Connected += new EventHandler(OnSessionConnected);
+                client.Error += new EventHandler<ErrorEventArgs>(OnSessionError);
+                client.Closed += new EventHandler(OnSessionClosed);
 
                 //IPAddress ipAddress = Dns.GetHostAddresses("localhost")[0];
                 IPAddress ip = IPAddress.Parse("127.0.0.1");
                 IPEndPoint endpoint = new IPEndPoint(ip, 3370);
-                session.Connect(endpoint);
+                client.ConnectAsync(endpoint);
             }
         }
 
@@ -37,12 +38,12 @@ namespace ET.Server
             protected override void Destroy(FastStreamComponent self)
             {
                 Log.Info($"Ice component destroyed");
-                self.Session?.Close();
-                self.Session = null;
+                self.FastStreamClient?.Close();
+                self.FastStreamClient = null;
             }
         }
 
-        public static void SendData(TcpClientSession session, string key, string value)
+        public static void SendData(EasyClient session, string key, string value)
         {
             ByteBuffer buff = ByteBuffer.Allocate(64, true);
             buff.WriteShort((short)key.Length);
@@ -55,38 +56,57 @@ namespace ET.Server
         private static void OnSessionConnected(object sender, EventArgs e)
         {
             Log.Debug("fast stream session connected");
-            SendData(sender as AsyncTcpSession, "connetorId", "bs-" + Global.GameServerId.ToString());
+            SendData(sender as EasyClient, "connetorId", "bs-" + Global.GameServerId.ToString());
         }
 
-        private static void OnSessionDataReceived(object sender, DataEventArgs e)
+        private static void OnSessionDataReceived(FastStreamBuffer pack)
         {
-            var len = e.Length;
-            Log.Debug($"receive fast stream data: len({len})");
-            Log.Debug("======================================");
-            var buff = ByteBuffer.Allocate(len, true);
-            var keylen = buff.ReadShort();
-            var vallen = buff.ReadInt();
-            if(keylen + vallen > len)
+            var usrid = (long)pack.Key;
+            var data = pack.Data;
+            Log.Debug($"receive fast stream data, uid({usrid}), msglen:{data.Length}");
+
+            //找到此unit对应的Player(instance id相同)
+            //TODO: 有点绕,可以直接在所有scene的UnitComponent里找
+            var player = PlayerComponentSystem.SearchAll(usrid);
+            if(player != null )
             {
-                Log.Debug("unknow content");
+                var gatemap = player.GetComponent<GateMapComponent>();
+                if(gatemap == null)
+                {
+                    Log.Error($"player({usrid}) not entermap");
+                    return;
+                }
+
+                var unitcomponet = gatemap.Scene.GetComponent<UnitComponent>();
+                var unit = unitcomponet.GetChild<Unit>(usrid);
+                if(unit != null)
+                {
+                    MessageHelper.SendToClient(unit, new BattleEventPush() { key = (ushort)BattlePushCnst.FastStreamPush, data = data});
+                }
+                else
+                {
+                    Log.Error($"unit({usrid}) not exist @scene");
+                }
             }
             else
             {
-                var key = buff.ReadString(keylen);
-                var val = buff.ReadString(vallen);
-                Log.Debug($"{key} = {val}");
+                Log.Error($"Not found player({usrid}) @faststream data");
+                return;
             }
-            Log.Debug("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
         }
 
         private static void OnSessionError(object sender, ErrorEventArgs e)
         {
             Log.Warning("fast stream session error");
+
+            var self = FastStreamComponent.Instance;
+            //TODO: ReConnect战斗服
         }
 
         private static void OnSessionClosed(object sender, EventArgs e)
         {
             Log.Warning("fast stream session closed");
+            //TODO: ReConnect战斗服
         }
     }
 

+ 19 - 0
DotNet/Hotfix/IceBattle/BattleIceAgentComponentSystem.cs

@@ -100,6 +100,25 @@ namespace ET.Server
             {
                 Log.Debug("======================================");
                 Log.Debug($"battleServer zone notify: type({eventType}), msg({msg})");
+                Log.Debug("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
+
+                //TODO:GWorld.java @ battleServerEvent
+                if(eventType == "areaEvent" || eventType == "zoneEvent")
+                {
+                    
+                }
+                else if(eventType == "playerEvent")
+                {
+
+                }
+                else if(eventType == "mapNotify")
+                {
+
+                }
+                else if(eventType == "taskEvent")
+                {
+
+                }
             }
         }
     }

+ 4 - 1
DotNet/Model/Demo/Gate/PlayerComponent.cs

@@ -7,5 +7,8 @@ namespace ET.Server
 	public class PlayerComponent : Entity, IAwake, IDestroy
 	{
 		public readonly Dictionary<long, Player> idPlayers = new Dictionary<long, Player>();
+
+        [StaticField]
+        public static List<PlayerComponent> PlayerComponentList = new List<PlayerComponent>();
 	}
-}
+}

+ 1 - 0
DotNet/Model/DotNet.Model.csproj

@@ -31,6 +31,7 @@
     </ItemGroup>
     <ItemGroup>
       <PackageReference Include="SuperSocket.ClientEngine" Version="0.10.0" />
+      <PackageReference Include="SuperSocket.ProtoBase" Version="1.7.0.17" />
     </ItemGroup> 
     <ItemGroup> 
         <ProjectReference Include="..\..\Share\Analyzer\Share.Analyzer.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />

+ 23 - 0
DotNet/Model/Generate/Message/ServerPush_CS_40001.cs

@@ -0,0 +1,23 @@
+using ET;
+using ProtoBuf;
+using System.Collections.Generic;
+namespace ET
+{
+//战斗服发给游戏服后,游戏服推送给客户端
+	[Message(ServerPush.BattleEventPush)]
+	[ProtoContract]
+	public partial class BattleEventPush: ProtoObject, IActorMessage
+	{
+		[ProtoMember(1)]
+		public ushort key { get; set; }
+
+		[ProtoMember(2)]
+		public byte[] data { get; set; }
+
+	}
+
+	public static class ServerPush
+	{
+		 public const ushort BattleEventPush = 40002;
+	}
+}

+ 4 - 1
DotNet/Model/Module/FastStream/FastStreamComponent.cs

@@ -9,6 +9,9 @@ namespace ET.Server
         [StaticField]
         public static FastStreamComponent Instance;
 
-        public AsyncTcpSession Session;
+        public EasyClient FastStreamClient;
+
     }
+
+    
 }

+ 47 - 0
DotNet/Model/Module/FastStream/FastStreamMessageDecoder.cs

@@ -0,0 +1,47 @@
+using SuperSocket.ProtoBase;
+using System.Collections.Generic;
+using System;
+using System.Text;
+
+namespace ET.Server
+{
+    [ChildOf(typeof(FastStreamComponent))]
+    public class FastStreamMessageDecoder : FixedHeaderReceiveFilter<FastStreamBuffer>
+    {
+        public const int LEN_HEAD = 5;
+
+        private int uidLen;
+        private int msgLen;
+        public FastStreamMessageDecoder(int headerSize) : base(headerSize)
+        {
+        }
+
+        public override FastStreamBuffer ResolvePackage(IBufferStream bufferStream)
+        {
+            bufferStream.Skip(LEN_HEAD);
+            var uid = bufferStream.ReadString(uidLen, Encoding.UTF8);
+            var data = new byte[msgLen];
+            bufferStream.Read(data, 0, msgLen);
+            return new FastStreamBuffer(Convert.ToUInt64(uid, 10), ref data);
+        }
+
+        protected override int GetBodyLengthFromHeader(IBufferStream buffer, int headerSize)
+        {
+            uidLen = buffer.ReadByte();
+            msgLen = (int)buffer.ReadUInt32(true);
+            return uidLen + msgLen;
+        }
+    }
+
+    public class FastStreamBuffer : IPackageInfo<ulong>
+    {
+        public ulong Key { get; private set; }
+        public byte[] Data;
+
+        public FastStreamBuffer(ulong key, ref byte[] data)
+        {
+            this.Key = key;
+            this.Data = data;
+        }
+    }
+}

+ 0 - 1
DotNet/Model/Plugins/Example/ModelServer.cs

@@ -1 +0,0 @@
-

+ 1 - 13
Unity/Assets/Scripts/Codes/Hotfix/Share/Module/Unit/UnitComponentSystem.cs

@@ -5,6 +5,7 @@
 	{
 		protected override void Awake(UnitComponent self)
 		{
+            UnitComponent.Instance = self;
 		}
 	}
 	
@@ -19,19 +20,6 @@
     [FriendOfAttribute(typeof(ET.UnitComponent))]
     public static class UnitComponentSystem
     {
-        public static void Add(this UnitComponent self, Unit unit)
-        {
-            if (unit.IsActor)
-            {
-                self.IDActor = unit.Id;
-            }
-        }
-
-        public static Unit GetActor(this UnitComponent self)
-        {
-            return self.GetChild<Unit>(self.IDActor);
-        }
-
         public static Unit Get(this UnitComponent self, long id)
         {
             Unit unit = self.GetChild<Unit>(id);

+ 11 - 2
Unity/Assets/Scripts/Codes/Hotfix/Share/Module/Unit/UnitSystem.cs

@@ -1,4 +1,4 @@
-namespace ET
+namespace ET
 {
     [ObjectSystem]
     public class UnitSystem: AwakeSystem<Unit, int>
@@ -8,4 +8,13 @@ namespace ET
             self.ConfigId = configId;
         }
     }
-}
+
+    [ObjectSystem]
+    public class UnitDestroySystem : DestroySystem<Unit>
+    {
+        protected override void Destroy(Unit self)
+        {
+            //TODO: 
+        }
+    }
+}

+ 23 - 0
Unity/Assets/Scripts/Codes/Model/Client/Generate/Message/ServerPush_CS_40001.cs

@@ -0,0 +1,23 @@
+using ET;
+using ProtoBuf;
+using System.Collections.Generic;
+namespace ET
+{
+//战斗服发给游戏服后,游戏服推送给客户端
+	[Message(ServerPush.BattleEventPush)]
+	[ProtoContract]
+	public partial class BattleEventPush: ProtoObject, IActorMessage
+	{
+		[ProtoMember(1)]
+		public ushort key { get; set; }
+
+		[ProtoMember(2)]
+		public byte[] data { get; set; }
+
+	}
+
+	public static class ServerPush
+	{
+		 public const ushort BattleEventPush = 40002;
+	}
+}

+ 11 - 0
Unity/Assets/Scripts/Codes/Model/Client/Generate/Message/ServerPush_CS_40001.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: fef13a104ed8b3f4c9e93e91bf2fca0d
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 8 - 1
Unity/Assets/Scripts/Codes/Model/Share/Const/ConstValue.cs

@@ -1,4 +1,4 @@
-namespace ET
+namespace ET
 {
     /**
      * 静态常量值
@@ -12,4 +12,11 @@ namespace ET
         /** session过期时间 **/
         public const int SessionTimeoutTime = 30 * 1000;
     }
+
+    public enum BattlePushCnst
+    {
+        FastStreamPush = 1,
+        BattleClear
+    }
 }
+

+ 2 - 7
Unity/Assets/Scripts/Codes/Model/Share/Module/Unit/Unit.cs

@@ -6,7 +6,7 @@ namespace ET
 {
     [ChildOf(typeof(UnitComponent))]
     [DebuggerDisplay("ViewName,nq")]
-    public class Unit: Entity, IAwake<int>
+    public class Unit: Entity, IAwake<int>, IDestroy
     {
         public int ConfigId { get; set; } //配置表id
 
@@ -14,11 +14,6 @@ namespace ET
         public UnitConfig Config => UnitConfigCategory.Instance.Get(this.ConfigId);
 
         public UnitType Type => (UnitType)UnitConfigCategory.Instance.Get(this.ConfigId).Type;
-        [BsonIgnore]
-        public bool IsActor
-        {
-            get; set;
-        }
 
         [BsonElement]
         private float3 position; //坐标
@@ -64,4 +59,4 @@ namespace ET
             }
         }
     }
-}
+}

+ 2 - 1
Unity/Assets/Scripts/Codes/Model/Share/Module/Unit/UnitComponent.cs

@@ -3,6 +3,7 @@
 	[ComponentOf(typeof(Scene))]
 	public class UnitComponent: Entity, IAwake, IDestroy
 	{
-        public long IDActor = 0;
+        [StaticField]
+        public static UnitComponent Instance;
 	}
 }