Преглед изворни кода

1.去掉SceneType枚举,改成int,解除Core程序集对SceneType的依赖
2.SceneType不再使用Flag形式,多个Scene订阅可以加多个标签

tanghai пре 1 година
родитељ
комит
8138437981
47 измењених фајлова са 171 додато и 126 уклоњено
  1. 1 1
      Unity/Assets/Scripts/Core/Entity/EntitySceneFactory.cs
  2. 1 1
      Unity/Assets/Scripts/Core/Entity/IScene.cs
  3. 2 2
      Unity/Assets/Scripts/Core/Entity/Scene.cs
  4. 0 50
      Unity/Assets/Scripts/Core/Entity/SceneType.cs
  5. 53 0
      Unity/Assets/Scripts/Core/Entity/SceneTypeSingleton.cs
  6. 11 0
      Unity/Assets/Scripts/Core/Entity/SceneTypeSingleton.cs.meta
  7. 2 2
      Unity/Assets/Scripts/Core/Fiber/Fiber.cs
  8. 1 1
      Unity/Assets/Scripts/Core/Fiber/Module/CoroutineLock/CoroutineLockComponent.cs
  9. 4 4
      Unity/Assets/Scripts/Core/World/Module/Actor/MessageDispatcher.cs
  10. 2 2
      Unity/Assets/Scripts/Core/World/Module/Actor/MessageHandlerAttribute.cs
  11. 1 1
      Unity/Assets/Scripts/Core/World/Module/Actor/MessageLocationHandlerAttribute.cs
  12. 2 2
      Unity/Assets/Scripts/Core/World/Module/EventSystem/EventAttribute.cs
  13. 5 5
      Unity/Assets/Scripts/Core/World/Module/EventSystem/EventSystem.cs
  14. 3 3
      Unity/Assets/Scripts/Core/World/Module/Fiber/FiberManager.cs
  15. 0 6
      Unity/Assets/Scripts/Editor/ComponentViewEditor/TypeDrawer/EnumTypeDrawer.cs
  16. 1 1
      Unity/Assets/Scripts/Hotfix/Client/Module/Message/NetComponentOnReadInvoker_NetClient.cs
  17. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Benchmark/FiberInit_BenchmarkClient.cs
  18. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Benchmark/FiberInit_BenchmarkServer.cs
  19. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Benchmark/NetComponentOnReadInvoker_BenchmarkClient.cs
  20. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Benchmark/NetComponentOnReadInvoker_BenchmarkServer.cs
  21. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Demo/LockStep/Match/FiberInit_Match.cs
  22. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Demo/LockStep/Room/FiberInit_RoomRoot.cs
  23. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Demo/StateSync/Gate/FiberInit_Gate.cs
  24. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Demo/StateSync/Gate/NetComponentOnReadInvoker_Gate.cs
  25. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Demo/StateSync/Realm/FiberInit_Realm.cs
  26. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Demo/StateSync/Realm/NetComponentOnReadInvoker_Realm.cs
  27. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Demo/StateSync/Robot/FiberInit_Robot.cs
  28. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/FiberInit_Location.cs
  29. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Module/NetInner/FiberInit_NetInner.cs
  30. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Module/Router/FiberInit_Router.cs
  31. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Module/Router/FiberInit_RouterManager.cs
  32. 1 1
      Unity/Assets/Scripts/Hotfix/Share/Demo/LockStep/RoomSystem.cs
  33. 1 1
      Unity/Assets/Scripts/Hotfix/Share/FiberInit_Main.cs
  34. 1 1
      Unity/Assets/Scripts/HotfixView/Client/EntryEvent3_InitClient.cs
  35. 2 2
      Unity/Assets/Scripts/Model/Generate/ClientServer/ConfigPartial/StartSceneConfig.cs
  36. 2 2
      Unity/Assets/Scripts/Model/Generate/Server/ConfigPartial/StartSceneConfig.cs
  37. 3 3
      Unity/Assets/Scripts/Model/Server/Module/Http/HttpDispatcher.cs
  38. 2 2
      Unity/Assets/Scripts/Model/Server/Module/Http/HttpHandlerAttribute.cs
  39. 2 2
      Unity/Assets/Scripts/Model/Share/Demo/LockStep/LSWorld.cs
  40. 1 1
      Unity/Assets/Scripts/Model/Share/Demo/LockStep/Room.cs
  41. 34 0
      Unity/Assets/Scripts/Model/Share/Demo/StateSync/SceneType.cs
  42. 1 1
      Unity/Assets/Scripts/Model/Share/Demo/StateSync/SceneType.cs.meta
  43. 5 2
      Unity/Assets/Scripts/Model/Share/Entry.cs
  44. 4 4
      Unity/Assets/Scripts/Model/Share/Module/Message/MessageSessionDispatcher.cs
  45. 2 2
      Unity/Assets/Scripts/Model/Share/Module/Message/MessageSessionHandlerAttribute.cs
  46. 2 2
      Unity/Assets/Scripts/Model/Share/Module/Numeric/NumericWatcherAttribute.cs
  47. 4 4
      Unity/Assets/Scripts/Model/Share/Module/Numeric/NumericWatcherComponent.cs

+ 1 - 1
Unity/Assets/Scripts/Core/Entity/EntitySceneFactory.cs

@@ -2,7 +2,7 @@
 {
     public static class EntitySceneFactory
     {
-        public static Scene CreateScene(Entity parent, long id, long instanceId, SceneType sceneType, string name)
+        public static Scene CreateScene(Entity parent, long id, long instanceId, int sceneType, string name)
         {
             Scene scene = new(parent.Fiber(), id, instanceId, sceneType, name);
             parent?.AddChild(scene);

+ 1 - 1
Unity/Assets/Scripts/Core/Entity/IScene.cs

@@ -3,6 +3,6 @@
     public interface IScene
     {
         Fiber Fiber { get; set; }
-        SceneType SceneType { get; set; }
+        int SceneType { get; set; }
     }
 }

+ 2 - 2
Unity/Assets/Scripts/Core/Entity/Scene.cs

@@ -12,7 +12,7 @@ namespace ET
         
         public string Name { get; }
         
-        public SceneType SceneType
+        public int SceneType
         {
             get;
             set;
@@ -22,7 +22,7 @@ namespace ET
         {
         }
 
-        public Scene(Fiber fiber, long id, long instanceId, SceneType sceneType, string name)
+        public Scene(Fiber fiber, long id, long instanceId, int sceneType, string name)
         {
             this.Id = id;
             this.Name = name;

+ 0 - 50
Unity/Assets/Scripts/Core/Entity/SceneType.cs

@@ -1,50 +0,0 @@
-using System;
-
-namespace ET
-{
-	[Flags]
-	public enum SceneType: long
-	{
-		None = 0,
-		Main = 1, // 主纤程,一个进程一个, 初始化从这里开始
-		NetInner = 1 << 2, // 负责进程间消息通信
-		Realm = 1 << 3,
-		Gate = 1 << 4,
-		Http = 1 << 5,
-		Location = 1 << 6,
-		Map = 1 << 7,
-		Router = 1 << 8,
-		RouterManager = 1 << 9,
-		Robot = 1 << 10,
-		BenchmarkClient = 1 << 11,
-		BenchmarkServer = 1 << 12,
-		Match = 1 << 14,
-		Room = 1 << 15,
-		LockStepClient = 1 << 16,
-		LockStepServer = 1 << 17,
-		RoomRoot = 1 << 18,
-		Watcher = 1 << 19,
-
-		// 客户端
-		StateSync = 1 << 30,
-		Current = 1L << 31,
-		LockStep = 1L << 32,
-		LockStepView = 1L << 33,
-		StateSyncView = 1L << 34,
-		NetClient = 1L << 35,
-
-		All = long.MaxValue,
-	}
-
-	public static class SceneTypeHelper
-	{
-		public static bool HasSameFlag(this SceneType a, SceneType b)
-		{
-			if (((ulong) a & (ulong) b) == 0)
-			{
-				return false;
-			}
-			return true;
-		}
-	}
-}

+ 53 - 0
Unity/Assets/Scripts/Core/Entity/SceneTypeSingleton.cs

@@ -0,0 +1,53 @@
+using System;
+using System.Reflection;
+
+namespace ET
+{
+    public class SceneTypeSingleton: Singleton<SceneTypeSingleton>, ISingletonAwake<Type>
+    {
+        public static bool IsSame(int a, int b)
+        {
+            if (a == b)
+            {
+                return true;
+            }
+
+            if (a == 0)
+            {
+                return true;
+            }
+
+            if (b == 0)
+            {
+                return true;
+            }
+
+            return false;
+        }
+        
+        private readonly DoubleMap<int, string> sceneNames = new();
+
+        public void Awake(Type type)
+        {
+            FieldInfo[] fieldInfos = type.GetFields(BindingFlags.Static | BindingFlags.Public);
+            foreach (FieldInfo fieldInfo in fieldInfos)
+            {
+                if (fieldInfo.FieldType != typeof(int))
+                {
+                    continue;
+                }
+                this.sceneNames.Add((int)fieldInfo.GetValue(null), fieldInfo.Name);	
+            }
+        }
+		
+        public string GetSceneName(int sceneType)
+        {
+            return this.sceneNames.GetValueByKey(sceneType);
+        }
+		
+        public int GetSceneType(string sceneName)
+        {
+            return this.sceneNames.GetKeyByValue(sceneName);
+        }
+    }
+}

+ 11 - 0
Unity/Assets/Scripts/Core/Entity/SceneTypeSingleton.cs.meta

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

+ 2 - 2
Unity/Assets/Scripts/Core/Fiber/Fiber.cs

@@ -51,7 +51,7 @@ namespace ET
 
         private readonly Queue<ETTask> frameFinishTasks = new();
         
-        internal Fiber(int id, int zone, SceneType sceneType, string name)
+        internal Fiber(int id, int zone, int sceneType, string name)
         {
             this.Id = id;
             this.Zone = zone;
@@ -61,7 +61,7 @@ namespace ET
 #if UNITY
             this.Log = Logger.Instance.Log;
 #else
-            this.Log = new NLogger(sceneType.ToString(), this.Process, this.Id);
+            this.Log = new NLogger(SceneTypeSingleton.Instance.GetSceneName(sceneType), this.Process, this.Id);
 #endif
             this.Root = new Scene(this, id, 1, sceneType, name);
         }

+ 1 - 1
Unity/Assets/Scripts/Core/Fiber/Module/CoroutineLock/CoroutineLockComponent.cs

@@ -54,7 +54,7 @@ namespace ET
     public class CoroutineLockComponent: Entity, IAwake, IScene, IUpdate
     {
         public Fiber Fiber { get; set; }
-        public SceneType SceneType { get; set; }
+        public int SceneType { get; set; }
         
         public readonly Queue<(int, long, int)> nextFrameRun = new();
     }

+ 4 - 4
Unity/Assets/Scripts/Core/World/Module/Actor/MessageDispatcher.cs

@@ -5,11 +5,11 @@ namespace ET
 {
     public class MessageDispatcherInfo
     {
-        public SceneType SceneType { get; }
+        public int SceneType { get; }
         
         public IMHandler IMHandler { get; }
 
-        public MessageDispatcherInfo(SceneType sceneType, IMHandler imHandler)
+        public MessageDispatcherInfo(int sceneType, IMHandler imHandler)
         {
             this.SceneType = sceneType;
             this.IMHandler = imHandler;
@@ -93,10 +93,10 @@ namespace ET
                 throw new Exception($"not found message handler: {message} {entity.GetType().FullName}");
             }
 
-            SceneType sceneType = entity.IScene.SceneType;
+            int sceneType = entity.IScene.SceneType;
             foreach (MessageDispatcherInfo actorMessageDispatcherInfo in list)
             {
-                if (!actorMessageDispatcherInfo.SceneType.HasSameFlag(sceneType))
+                if (!SceneTypeSingleton.IsSame(actorMessageDispatcherInfo.SceneType, sceneType))
                 {
                     continue;
                 }

+ 2 - 2
Unity/Assets/Scripts/Core/World/Module/Actor/MessageHandlerAttribute.cs

@@ -4,9 +4,9 @@ namespace ET
 {
     public class MessageHandlerAttribute: BaseAttribute
     {
-        public SceneType SceneType { get; }
+        public int SceneType { get; }
 
-        public MessageHandlerAttribute(SceneType sceneType)
+        public MessageHandlerAttribute(int sceneType)
         {
             this.SceneType = sceneType;
         }

+ 1 - 1
Unity/Assets/Scripts/Core/World/Module/Actor/MessageLocationHandlerAttribute.cs

@@ -4,7 +4,7 @@ namespace ET
 {
     public class MessageLocationHandlerAttribute: MessageHandlerAttribute
     {
-        public MessageLocationHandlerAttribute(SceneType sceneType): base(sceneType)
+        public MessageLocationHandlerAttribute(int sceneType): base(sceneType)
         {
         }
     }

+ 2 - 2
Unity/Assets/Scripts/Core/World/Module/EventSystem/EventAttribute.cs

@@ -4,9 +4,9 @@ namespace ET
 {
 	public class EventAttribute: BaseAttribute
 	{
-		public SceneType SceneType { get; }
+		public int SceneType { get; }
 
-		public EventAttribute(SceneType sceneType)
+		public EventAttribute(int sceneType)
 		{
 			this.SceneType = sceneType;
 		}

+ 5 - 5
Unity/Assets/Scripts/Core/World/Module/EventSystem/EventSystem.cs

@@ -10,9 +10,9 @@ namespace ET
         {
             public IEvent IEvent { get; }
             
-            public SceneType SceneType {get; }
+            public int SceneType {get; }
 
-            public EventInfo(IEvent iEvent, SceneType sceneType)
+            public EventInfo(IEvent iEvent, int sceneType)
             {
                 this.IEvent = iEvent;
                 this.SceneType = sceneType;
@@ -95,7 +95,7 @@ namespace ET
             
             foreach (EventInfo eventInfo in iEvents)
             {
-                if (!scene.SceneType.HasSameFlag(eventInfo.SceneType))
+                if (!SceneTypeSingleton.IsSame(scene.SceneType, eventInfo.SceneType))
                 {
                     continue;
                 }
@@ -127,10 +127,10 @@ namespace ET
                 return;
             }
 
-            SceneType sceneType = scene.SceneType;
+            int sceneType = scene.SceneType;
             foreach (EventInfo eventInfo in iEvents)
             {
-                if (!sceneType.HasSameFlag(eventInfo.SceneType))
+                if (!SceneTypeSingleton.IsSame(sceneType, eventInfo.SceneType))
                 {
                     continue;
                 }

+ 3 - 3
Unity/Assets/Scripts/Core/World/Module/Fiber/FiberManager.cs

@@ -61,7 +61,7 @@ namespace ET
             this.fibers = null;
         }
 
-        public async ETTask<int> Create(SchedulerType schedulerType, int fiberId, int zone, SceneType sceneType, string name)
+        public async ETTask<int> Create(SchedulerType schedulerType, int fiberId, int zone, int sceneType, string name)
         {
             try
             {
@@ -80,7 +80,7 @@ namespace ET
                     try
                     {
                         // 根据Fiber的SceneType分发Init,必须在Fiber线程中执行
-                        await EventSystem.Instance.Invoke<FiberInit, ETTask>((long)sceneType, new FiberInit() {Fiber = fiber});
+                        await EventSystem.Instance.Invoke<FiberInit, ETTask>(sceneType, new FiberInit() {Fiber = fiber});
                         tcs.SetResult(true);
                     }
                     catch (Exception e)
@@ -98,7 +98,7 @@ namespace ET
             }
         }
         
-        public async ETTask<int> Create(SchedulerType schedulerType, int zone, SceneType sceneType, string name)
+        public async ETTask<int> Create(SchedulerType schedulerType, int zone, int sceneType, string name)
         {
             int fiberId = Interlocked.Increment(ref this.idGenerator);
             return await this.Create(schedulerType, fiberId, zone, sceneType, name);

+ 0 - 6
Unity/Assets/Scripts/Editor/ComponentViewEditor/TypeDrawer/EnumTypeDrawer.cs

@@ -13,12 +13,6 @@ namespace ET
 
         public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target)
         {
-            if (memberType == typeof (SceneType))
-            {
-                string sceneType = EditorGUILayout.DelayedTextField(memberName, value.ToString());
-                return EnumHelper.FromString<SceneType>(sceneType);
-            }
-            
             if (memberType.IsDefined(typeof (FlagsAttribute), false))
             {
                 return EditorGUILayout.EnumFlagsField(memberName, (Enum) value);

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Client/Module/Message/NetComponentOnReadInvoker_NetClient.cs

@@ -2,7 +2,7 @@
 
 namespace ET.Client
 {
-    [Invoke((long)SceneType.NetClient)]
+    [Invoke(SceneType.NetClient)]
     public class NetComponentOnReadInvoker_NetClient: AInvokeHandler<NetComponentOnRead>
     {
         public override void Handle(NetComponentOnRead args)

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Benchmark/FiberInit_BenchmarkClient.cs

@@ -4,7 +4,7 @@ using ET.Client;
 
 namespace ET.Server
 {
-    [Invoke((long)SceneType.BenchmarkClient)]
+    [Invoke(SceneType.BenchmarkClient)]
     public class FiberInit_BenchmarkClient: AInvokeHandler<FiberInit, ETTask>
     {
         public override async ETTask Handle(FiberInit fiberInit)

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Benchmark/FiberInit_BenchmarkServer.cs

@@ -4,7 +4,7 @@ using ET.Client;
 
 namespace ET.Server
 {
-    [Invoke((long)SceneType.BenchmarkServer)]
+    [Invoke(SceneType.BenchmarkServer)]
     public class FiberInit_BenchmarkServer: AInvokeHandler<FiberInit, ETTask>
     {
         public override async ETTask Handle(FiberInit fiberInit)

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Benchmark/NetComponentOnReadInvoker_BenchmarkClient.cs

@@ -2,7 +2,7 @@
 
 namespace ET.Server
 {
-    [Invoke((long)SceneType.BenchmarkClient)]
+    [Invoke(SceneType.BenchmarkClient)]
     public class NetComponentOnReadInvoker_BenchmarkClient: AInvokeHandler<NetComponentOnRead>
     {
         public override void Handle(NetComponentOnRead args)

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Benchmark/NetComponentOnReadInvoker_BenchmarkServer.cs

@@ -2,7 +2,7 @@
 
 namespace ET.Server
 {
-    [Invoke((long)SceneType.BenchmarkServer)]
+    [Invoke(SceneType.BenchmarkServer)]
     public class NetComponentOnReadInvoker_BenchmarkServer: AInvokeHandler<NetComponentOnRead>
     {
         public override void Handle(NetComponentOnRead args)

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Demo/LockStep/Match/FiberInit_Match.cs

@@ -2,7 +2,7 @@
 
 namespace ET.Server
 {
-    [Invoke((long)SceneType.Match)]
+    [Invoke(SceneType.Match)]
     public class FiberInit_Match: AInvokeHandler<FiberInit, ETTask>
     {
         public override async ETTask Handle(FiberInit fiberInit)

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Demo/LockStep/Room/FiberInit_RoomRoot.cs

@@ -2,7 +2,7 @@
 
 namespace ET.Server
 {
-    [Invoke((long)SceneType.RoomRoot)]
+    [Invoke(SceneType.RoomRoot)]
     public class FiberInit_RoomRoot: AInvokeHandler<FiberInit, ETTask>
     {
         public override async ETTask Handle(FiberInit fiberInit)

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Demo/StateSync/Gate/FiberInit_Gate.cs

@@ -2,7 +2,7 @@
 
 namespace ET.Server
 {
-    [Invoke((long)SceneType.Gate)]
+    [Invoke(SceneType.Gate)]
     public class FiberInit_Gate: AInvokeHandler<FiberInit, ETTask>
     {
         public override async ETTask Handle(FiberInit fiberInit)

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Demo/StateSync/Gate/NetComponentOnReadInvoker_Gate.cs

@@ -2,7 +2,7 @@
 
 namespace ET.Server
 {
-    [Invoke((long)SceneType.Gate)]
+    [Invoke(SceneType.Gate)]
     public class NetComponentOnReadInvoker_Gate: AInvokeHandler<NetComponentOnRead>
     {
         public override void Handle(NetComponentOnRead args)

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Demo/StateSync/Realm/FiberInit_Realm.cs

@@ -2,7 +2,7 @@
 
 namespace ET.Server
 {
-    [Invoke((long)SceneType.Realm)]
+    [Invoke(SceneType.Realm)]
     public class FiberInit_Realm: AInvokeHandler<FiberInit, ETTask>
     {
         public override async ETTask Handle(FiberInit fiberInit)

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Demo/StateSync/Realm/NetComponentOnReadInvoker_Realm.cs

@@ -2,7 +2,7 @@
 
 namespace ET.Server
 {
-    [Invoke((long)SceneType.Realm)]
+    [Invoke(SceneType.Realm)]
     public class NetComponentOnReadInvoker_Realm: AInvokeHandler<NetComponentOnRead>
     {
         public override void Handle(NetComponentOnRead args)

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Demo/StateSync/Robot/FiberInit_Robot.cs

@@ -1,6 +1,6 @@
 namespace ET.Client
 {
-    [Invoke((long)SceneType.Robot)]
+    [Invoke(SceneType.Robot)]
     public class FiberInit_Robot: AInvokeHandler<FiberInit, ETTask>
     {
         public override async ETTask Handle(FiberInit fiberInit)

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/FiberInit_Location.cs

@@ -2,7 +2,7 @@
 
 namespace ET.Server
 {
-    [Invoke((long)SceneType.Location)]
+    [Invoke(SceneType.Location)]
     public class FiberInit_Location: AInvokeHandler<FiberInit, ETTask>
     {
         public override async ETTask Handle(FiberInit fiberInit)

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Module/NetInner/FiberInit_NetInner.cs

@@ -2,7 +2,7 @@
 
 namespace ET.Server
 {
-    [Invoke((long)SceneType.NetInner)]
+    [Invoke(SceneType.NetInner)]
     public class FiberInit_NetInner: AInvokeHandler<FiberInit, ETTask>
     {
         public override async ETTask Handle(FiberInit fiberInit)

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Module/Router/FiberInit_Router.cs

@@ -2,7 +2,7 @@
 
 namespace ET.Server
 {
-    [Invoke((long)SceneType.Router)]
+    [Invoke(SceneType.Router)]
     public class FiberInit_Router: AInvokeHandler<FiberInit, ETTask>
     {
         public override async ETTask Handle(FiberInit fiberInit)

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Module/Router/FiberInit_RouterManager.cs

@@ -2,7 +2,7 @@
 
 namespace ET.Server
 {
-    [Invoke((long)SceneType.RouterManager)]
+    [Invoke(SceneType.RouterManager)]
     public class FiberInit_RouterManager: AInvokeHandler<FiberInit, ETTask>
     {
         public override async ETTask Handle(FiberInit fiberInit)

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Share/Demo/LockStep/RoomSystem.cs

@@ -53,7 +53,7 @@ namespace ET
             lsWorld.Update();
         }
         
-        public static LSWorld GetLSWorld(this Room self, SceneType sceneType, int frame)
+        public static LSWorld GetLSWorld(this Room self, int sceneType, int frame)
         {
             MemoryBuffer memoryBuffer = self.FrameBuffer.Snapshot(frame);
             memoryBuffer.Seek(0, SeekOrigin.Begin);

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Share/FiberInit_Main.cs

@@ -3,7 +3,7 @@ using MemoryPack;
 
 namespace ET
 {
-    [Invoke((long)SceneType.Main)]
+    [Invoke(SceneType.Main)]
     public class FiberInit_Main: AInvokeHandler<FiberInit, ETTask>
     {
         public override async ETTask Handle(FiberInit fiberInit)

+ 1 - 1
Unity/Assets/Scripts/HotfixView/Client/EntryEvent3_InitClient.cs

@@ -17,7 +17,7 @@ namespace ET.Client
             root.AddComponent<CurrentScenesComponent>();
             
             // 根据配置修改掉Main Fiber的SceneType
-            SceneType sceneType = EnumHelper.FromString<SceneType>(globalComponent.GlobalConfig.AppType.ToString());
+            int sceneType = SceneTypeSingleton.Instance.GetSceneType(globalComponent.GlobalConfig.AppType.ToString());
             root.SceneType = sceneType;
             
             await EventSystem.Instance.PublishAsync(root, new AppStartInitFinish());

+ 2 - 2
Unity/Assets/Scripts/Model/Generate/ClientServer/ConfigPartial/StartSceneConfig.cs

@@ -78,7 +78,7 @@ namespace ET
     {
         public ActorId ActorId;
         
-        public SceneType Type;
+        public int Type;
 
         public StartProcessConfig StartProcessConfig
         {
@@ -131,7 +131,7 @@ namespace ET
         public override void EndInit()
         {
             this.ActorId = new ActorId(this.Process, this.Id, 1);
-            this.Type = EnumHelper.FromString<SceneType>(this.SceneType);
+            this.Type = SceneTypeSingleton.Instance.GetSceneType(this.SceneType);
         }
     }
 }

+ 2 - 2
Unity/Assets/Scripts/Model/Generate/Server/ConfigPartial/StartSceneConfig.cs

@@ -78,7 +78,7 @@ namespace ET
     {
         public ActorId ActorId;
         
-        public SceneType Type;
+        public int Type;
 
         public StartProcessConfig StartProcessConfig
         {
@@ -131,7 +131,7 @@ namespace ET
         public override void EndInit()
         {
             this.ActorId = new ActorId(this.Process, this.Id, 1);
-            this.Type = EnumHelper.FromString<SceneType>(this.SceneType);
+            this.Type = SceneTypeSingleton.Instance.GetSceneType(this.SceneType);
         }
     }
 }

+ 3 - 3
Unity/Assets/Scripts/Model/Server/Module/Http/HttpDispatcher.cs

@@ -36,13 +36,13 @@ namespace ET.Server
                     this.dispatcher.Add(httpHandlerAttribute.Path, dict);
                 }
                 
-                dict.Add((int)httpHandlerAttribute.SceneType, ihttpHandler);
+                dict.Add(httpHandlerAttribute.SceneType, ihttpHandler);
             }
         }
 
-        public IHttpHandler Get(SceneType sceneType, string path)
+        public IHttpHandler Get(int sceneType, string path)
         {
-            return this.dispatcher[path][(int)sceneType];
+            return this.dispatcher[path][sceneType];
         }
     }
 }

+ 2 - 2
Unity/Assets/Scripts/Model/Server/Module/Http/HttpHandlerAttribute.cs

@@ -2,11 +2,11 @@
 {
     public class HttpHandlerAttribute: BaseAttribute
     {
-        public SceneType SceneType { get; }
+        public int SceneType { get; }
 
         public string Path { get; }
 
-        public HttpHandlerAttribute(SceneType sceneType, string path)
+        public HttpHandlerAttribute(int sceneType, string path)
         {
             this.SceneType = sceneType;
             this.Path = path;

+ 2 - 2
Unity/Assets/Scripts/Model/Share/Demo/LockStep/LSWorld.cs

@@ -34,7 +34,7 @@ namespace ET
         {
         }
         
-        public LSWorld(SceneType sceneType)
+        public LSWorld(int sceneType)
         {
             this.Id = this.GetId();
 
@@ -60,7 +60,7 @@ namespace ET
         
         [BsonIgnore]
         [MemoryPackIgnore]
-        public SceneType SceneType { get; set; }
+        public int SceneType { get; set; }
         
         public int Frame { get; set; }
 

+ 1 - 1
Unity/Assets/Scripts/Model/Share/Demo/LockStep/Room.cs

@@ -6,7 +6,7 @@ namespace ET
     public class Room: Entity, IScene, IAwake, IUpdate
     {
         public Fiber Fiber { get; set; }
-        public SceneType SceneType { get; set; } = SceneType.Room;
+        public int SceneType { get; set; } = ET.SceneType.Room;
         public string Name { get; set; }
         
         public long StartTime { get; set; }

+ 34 - 0
Unity/Assets/Scripts/Model/Share/Demo/StateSync/SceneType.cs

@@ -0,0 +1,34 @@
+namespace ET
+{
+	[UniqueId]
+	public static partial class SceneType
+	{
+		public const int All = 0;
+		public const int Main = 1; // 主纤程,一个进程一个, 初始化从这里开始
+		public const int NetInner = 2; // 负责进程间消息通信
+		public const int Realm = 3;
+		public const int Gate = 4;
+		public const int Http = 5;
+		public const int Location = 6;
+		public const int Map = 7;
+		public const int Router = 8;
+		public const int RouterManager = 9;
+		public const int Robot = 10;
+		public const int BenchmarkClient = 11;
+		public const int BenchmarkServer = 12;
+		public const int Match = 13;
+		public const int Room = 14;
+		public const int LockStepClient = 15;
+		public const int LockStepServer = 16;
+		public const int RoomRoot = 17;
+		public const int Watcher = 18;
+
+		// 客户端
+		public const int StateSync = 50;
+		public const int Current = 51;
+		public const int LockStep = 52;
+		public const int LockStepView = 53;
+		public const int StateSyncView = 54;
+		public const int NetClient = 55;
+	}
+}

+ 1 - 1
Unity/Assets/Scripts/Core/Entity/SceneType.cs.meta → Unity/Assets/Scripts/Model/Share/Demo/StateSync/SceneType.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: b36ca6be079a1bb458f59657482f6260
+guid: 2ff75e960327efe4089efe7388bee40e
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 5 - 2
Unity/Assets/Scripts/Model/Share/Entry.cs

@@ -1,4 +1,6 @@
-namespace ET
+using System;
+
+namespace ET
 {
     public struct EntryEvent1
     {
@@ -35,7 +37,8 @@
             
             // 注册Entity序列化器
             EntitySerializeRegister.Init();
-            
+
+            World.Instance.AddSingleton<SceneTypeSingleton, Type>(typeof(SceneType));
             World.Instance.AddSingleton<ObjectPool>();
             World.Instance.AddSingleton<IdGenerater>();
             World.Instance.AddSingleton<OpcodeType>();

+ 4 - 4
Unity/Assets/Scripts/Model/Share/Module/Message/MessageSessionDispatcher.cs

@@ -5,10 +5,10 @@ namespace ET
 {
     public struct MessageSessionDispatcherInfo
     {
-        public SceneType SceneType { get; }
+        public int SceneType { get; }
         public IMessageSessionHandler IMHandler { get; }
 
-        public MessageSessionDispatcherInfo(SceneType sceneType, IMessageSessionHandler imHandler)
+        public MessageSessionDispatcherInfo(int sceneType, IMessageSessionHandler imHandler)
         {
             this.SceneType = sceneType;
             this.IMHandler = imHandler;
@@ -74,10 +74,10 @@ namespace ET
                 return;
             }
 
-            SceneType sceneType = session.IScene.SceneType;
+            int sceneType = session.IScene.SceneType;
             foreach (MessageSessionDispatcherInfo ev in actions)
             {
-                if (!ev.SceneType.HasSameFlag(sceneType))
+                if (!SceneTypeSingleton.IsSame(ev.SceneType, sceneType))
                 {
                     continue;
                 }

+ 2 - 2
Unity/Assets/Scripts/Model/Share/Module/Message/MessageSessionHandlerAttribute.cs

@@ -4,9 +4,9 @@ namespace ET
 {
     public class MessageSessionHandlerAttribute: BaseAttribute
     {
-        public SceneType SceneType { get; }
+        public int SceneType { get; }
 
-        public MessageSessionHandlerAttribute(SceneType sceneType)
+        public MessageSessionHandlerAttribute(int sceneType)
         {
             this.SceneType = sceneType;
         }

+ 2 - 2
Unity/Assets/Scripts/Model/Share/Module/Numeric/NumericWatcherAttribute.cs

@@ -5,11 +5,11 @@ namespace ET
 	[AttributeUsage(AttributeTargets.Class)]
 	public class NumericWatcherAttribute : BaseAttribute
 	{
-		public SceneType SceneType { get; }
+		public int SceneType { get; }
 		
 		public int NumericType { get; }
 
-		public NumericWatcherAttribute(SceneType sceneType, int type)
+		public NumericWatcherAttribute(int sceneType, int type)
 		{
 			this.SceneType = sceneType;
 			this.NumericType = type;

+ 4 - 4
Unity/Assets/Scripts/Model/Share/Module/Numeric/NumericWatcherComponent.cs

@@ -5,10 +5,10 @@ namespace ET
 {
     public struct NumericWatcherInfo
     {
-        public SceneType SceneType { get; }
+        public int SceneType { get; }
         public INumericWatcher INumericWatcher { get; }
 
-        public NumericWatcherInfo(SceneType sceneType, INumericWatcher numericWatcher)
+        public NumericWatcherInfo(int sceneType, INumericWatcher numericWatcher)
         {
             this.SceneType = sceneType;
             this.INumericWatcher = numericWatcher;
@@ -52,10 +52,10 @@ namespace ET
                 return;
             }
 
-            SceneType unitDomainSceneType = unit.IScene.SceneType;
+            int unitDomainSceneType = unit.IScene.SceneType;
             foreach (NumericWatcherInfo numericWatcher in list)
             {
-                if (!numericWatcher.SceneType.HasSameFlag(unitDomainSceneType))
+                if (!SceneTypeSingleton.IsSame(numericWatcher.SceneType, unitDomainSceneType))
                 {
                     continue;
                 }