tanghai 2 жил өмнө
parent
commit
0f074f6792

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Demo/Map/Unit/UnitEnterSightRange_NotifyClient.cs

@@ -14,7 +14,7 @@
             }
 
             Unit ua = a.GetParent<Unit>();
-            if (ua.Type != UnitType.Player)
+            if (ua.Type() != UnitType.Player)
             {
                 return;
             }

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Demo/Map/Unit/UnitHelper.cs

@@ -13,7 +13,7 @@ namespace ET.Server
             NumericComponent nc = unit.GetComponent<NumericComponent>();
             unitInfo.UnitId = unit.Id;
             unitInfo.ConfigId = unit.ConfigId;
-            unitInfo.Type = (int)unit.Type;
+            unitInfo.Type = (int)unit.Type();
             unitInfo.Position = unit.Position;
             unitInfo.Forward = unit.Forward;
 

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Demo/Map/Unit/UnitLeaveSightRange_NotifyClient.cs

@@ -9,7 +9,7 @@
             await ETTask.CompletedTask;
             AOIEntity a = args.A;
             AOIEntity b = args.B;
-            if (a.Unit.Type != UnitType.Player)
+            if (a.Unit.Type() != UnitType.Player)
             {
                 return;
             }

+ 5 - 5
Unity/Assets/Scripts/Hotfix/Server/Module/AOI/AOIEntitySystem.cs

@@ -103,9 +103,9 @@ namespace ET.Server
                 return;
             }
 
-            if (self.Unit.Type == UnitType.Player)
+            if (self.Unit.Type() == UnitType.Player)
             {
-                if (enter.Unit.Type == UnitType.Player)
+                if (enter.Unit.Type() == UnitType.Player)
                 {
                     self.SeeUnits.Add(enter.Id, enter);
                     enter.BeSeeUnits.Add(self.Id, self);
@@ -122,7 +122,7 @@ namespace ET.Server
             }
             else
             {
-                if (enter.Unit.Type == UnitType.Player)
+                if (enter.Unit.Type() == UnitType.Player)
                 {
                     self.SeeUnits.Add(enter.Id, enter);
                     enter.BeSeeUnits.Add(self.Id, self);
@@ -151,13 +151,13 @@ namespace ET.Server
             }
 
             self.SeeUnits.Remove(leave.Id);
-            if (leave.Unit.Type == UnitType.Player)
+            if (leave.Unit.Type() == UnitType.Player)
             {
                 self.SeePlayers.Remove(leave.Id);
             }
 
             leave.BeSeeUnits.Remove(self.Id);
-            if (self.Unit.Type == UnitType.Player)
+            if (self.Unit.Type() == UnitType.Player)
             {
                 leave.BeSeePlayers.Remove(self.Id);
             }

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Module/AOI/AOIHelper.cs

@@ -16,7 +16,7 @@ namespace ET.Server
             leaveCell.Clear();
             int r = (aoiEntity.ViewDistance - 1) / AOIManagerComponent.CellSize + 1;
             int leaveR = r;
-            if (aoiEntity.Unit.Type == UnitType.Player)
+            if (aoiEntity.Unit.Type() == UnitType.Player)
             {
                 leaveR += 1;
             }

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Share/Module/Recast/PathfindingComponentSystem.cs

@@ -159,7 +159,7 @@ namespace ET
             int ret = Recast.RecastFindNearestPoint(self.navMesh, self.extents, self.StartPos, self.EndPos);
             if (ret == 0)
             {
-                throw new Exception($"RecastFindNearestPoint fail, 可能是位置配置有问题: sceneName:{self.Scene().Name} {pos} {self.Name} {self.GetParent<Unit>().Id} {self.GetParent<Unit>().Config.Id} {self.EndPos.ArrayToString()}");
+                throw new Exception($"RecastFindNearestPoint fail, 可能是位置配置有问题: sceneName:{self.Scene().Name} {pos} {self.Name} {self.GetParent<Unit>().Id} {self.GetParent<Unit>().ConfigId} {self.EndPos.ArrayToString()}");
             }
             
             return new float3(-self.EndPos[0], self.EndPos[1], self.EndPos[2]);

+ 10 - 0
Unity/Assets/Scripts/Hotfix/Share/Module/Unit/UnitSystem.cs

@@ -8,5 +8,15 @@ namespace ET
         {
             self.ConfigId = configId;
         }
+
+        public static UnitConfig Config(this Unit self)
+        {
+            return UnitConfigCategory.Instance.Get(self.ConfigId);
+        }
+        
+        public static UnitType Type(this Unit self)
+        {
+            return (UnitType)self.Config().Type;
+        }
     }
 }

+ 0 - 5
Unity/Assets/Scripts/Model/Share/Module/Unit/Unit.cs

@@ -10,11 +10,6 @@ namespace ET
     {
         public int ConfigId { get; set; } //配置表id
 
-        [BsonIgnore]
-        public UnitConfig Config => UnitConfigCategory.Instance.Get(this.ConfigId);
-
-        public UnitType Type => (UnitType)UnitConfigCategory.Instance.Get(this.ConfigId).Type;
-
         [BsonElement]
         private float3 position; //坐标