diff --git a/Config/StartConfig/LocalAllServer.txt b/Config/StartConfig/LocalAllServer.txt index 9fbc1d1da5b9fe6df70f2ab2fd9e268972bc9669..4e9a7c4ff5f9c1bedc914c3bd3d9c1fcab073a44 100644 --- a/Config/StartConfig/LocalAllServer.txt +++ b/Config/StartConfig/LocalAllServer.txt @@ -1 +1 @@ -{ "_t" : "StartConfig", "_id" : NumberLong("98547768819754"), "C" : [{ "_t" : "OuterConfig", "Address" : "127.0.0.1:10002", "Address2" : "127.0.0.1:10002" }, { "_t" : "InnerConfig", "Address" : "127.0.0.1:20000" }, { "_t" : "HttpConfig", "Url" : "http://*:8080/", "AppId" : 0, "AppKey" : "", "ManagerSystemUrl" : "" }, { "_t" : "DBConfig", "ConnectionString" : null, "DBName" : null }], "AppId" : 1, "AppType" : "AllServer", "ServerIP" : "*" } +{ "_t" : "StartConfig", "_id" : NumberLong("98547768819754"), "C" : [{ "_t" : "OuterConfig", "Address" : "127.0.0.1:10002", "Address2" : "127.0.0.1:10002" }, { "_t" : "InnerConfig", "Address" : "127.0.0.1:20000" }, { "_t" : "HttpConfig", "Url" : "http://*:8080/", "AppId" : 0, "AppKey" : "", "ManagerSystemUrl" : "" }, { "_t" : "DBConfig", "ConnectionString" : "mongodb://172.16.100.40:27017/", "DBName" : "ET" }], "AppId" : 1, "AppType" : "AllServer", "ServerIP" : "*" } diff --git a/Server/App/Program.cs b/Server/App/Program.cs index 6f74763d9ecd0c409369becd1722369ade726bd3..53e9d1918580b79d78558716003a26715ece4e60 100644 --- a/Server/App/Program.cs +++ b/Server/App/Program.cs @@ -85,9 +85,9 @@ namespace App Game.Scene.AddComponent(); Game.Scene.AddComponent(); Game.Scene.AddComponent(); - Game.Scene.AddComponent(); - Game.Scene.AddComponent(); - Game.Scene.AddComponent(); + //Game.Scene.AddComponent(); + //Game.Scene.AddComponent(); + //Game.Scene.AddComponent(); Game.Scene.AddComponent(); Game.Scene.AddComponent(); Game.Scene.AddComponent(innerConfig.Address); diff --git a/Server/Model/Entity/Scene.cs b/Server/Model/Entity/Scene.cs index 467acadf83e712e433394dbc1e4fa0a915782ead..a8f785db44fb5a2a55bd4458f545a3d2780a094a 100644 --- a/Server/Model/Entity/Scene.cs +++ b/Server/Model/Entity/Scene.cs @@ -6,12 +6,10 @@ public Scene() { - this.InstanceId = IdGenerater.GenerateId(); } public Scene(long id): base(id) { - this.InstanceId = IdGenerater.GenerateId(); } public override void Dispose() diff --git a/Server/Model/Module/DB/DBComponent.cs b/Server/Model/Module/DB/DBComponent.cs index b04c59e46f770cceafa37bd2e7c7eded326c6cce..6b17e5a677bb18f84e67911fc20ab455bf9b0006 100644 --- a/Server/Model/Module/DB/DBComponent.cs +++ b/Server/Model/Module/DB/DBComponent.cs @@ -21,10 +21,10 @@ namespace ETModel public void Awake() { - //DBConfig config = Game.Scene.GetComponent().StartConfig.GetComponent(); - //string connectionString = config.ConnectionString; - //mongoClient = new MongoClient(connectionString); - //this.database = this.mongoClient.GetDatabase(config.DBName); + DBConfig config = Game.Scene.GetComponent().StartConfig.GetComponent(); + string connectionString = config.ConnectionString; + mongoClient = new MongoClient(connectionString); + this.database = this.mongoClient.GetDatabase(config.DBName); } public IMongoCollection GetCollection(string name) diff --git a/Server/Model/Entity/Unit.cs b/Server/Model/Module/Demo/Unit.cs similarity index 88% rename from Server/Model/Entity/Unit.cs rename to Server/Model/Module/Demo/Unit.cs index 3a804f6ca50a743c8d8b5e8b62247b7b560adc5b..d658131f7c17af809db12c4a5ff9aad511b87702 100644 --- a/Server/Model/Entity/Unit.cs +++ b/Server/Model/Module/Demo/Unit.cs @@ -30,6 +30,11 @@ namespace ETModel this.UnitType = unitType; } + public override void EndDeSerialize() + { + Game.EventSystem.Add(this); + } + public override void Dispose() { if (this.IsDisposed) diff --git a/Unity/Assets/Hotfix/Base/Object/Component.cs b/Unity/Assets/Hotfix/Base/Object/Component.cs index df234803972b0f912edd1959fe5409c6a91d8bb0..32616d899d15c32afb53556aca0005afa9017cc6 100644 --- a/Unity/Assets/Hotfix/Base/Object/Component.cs +++ b/Unity/Assets/Hotfix/Base/Object/Component.cs @@ -6,7 +6,6 @@ namespace ETHotfix [BsonIgnoreExtraElements] public abstract class Component : Object, IDisposable, IComponentSerialize { - // 只有Game.EventSystem.Add方法中会设置该值,如果new出来的对象不想加入Game.EventSystem中,则需要自己在构造函数中设置 [BsonIgnore] public long InstanceId { get; protected set; } @@ -62,6 +61,7 @@ namespace ETHotfix protected Component() { + this.InstanceId = IdGenerater.GenerateId(); } public virtual void Dispose() diff --git a/Unity/Assets/Model/Base/Object/Component.cs b/Unity/Assets/Model/Base/Object/Component.cs index 591bdf70e13f3a634bec819110faae688eccba5c..205c808b3a6fb1a46b17c6dac32270ac6b512e5c 100644 --- a/Unity/Assets/Model/Base/Object/Component.cs +++ b/Unity/Assets/Model/Base/Object/Component.cs @@ -6,9 +6,8 @@ namespace ETModel [BsonIgnoreExtraElements] public abstract class Component : Object, IDisposable, IComponentSerialize { - // 只有Game.EventSystem.Add方法中会设置该值,如果new出来的对象不想加入Game.EventSystem中,则需要自己在构造函数中设置 [BsonIgnore] - public long InstanceId { get; protected set; } + public long InstanceId { get; private set; } [BsonIgnore] private bool isFromPool; @@ -62,6 +61,7 @@ namespace ETModel protected Component() { + this.InstanceId = IdGenerater.GenerateId(); } public virtual void Dispose() diff --git a/Unity/Assets/Model/Entity/Scene.cs b/Unity/Assets/Model/Entity/Scene.cs index 6d433cd9561ac314145d4369b6c46f523558de24..68433454e74a05ecf78be07e0e5359dafb9f4cd3 100644 --- a/Unity/Assets/Model/Entity/Scene.cs +++ b/Unity/Assets/Model/Entity/Scene.cs @@ -19,12 +19,10 @@ public Scene() { - this.InstanceId = IdGenerater.GenerateId(); } public Scene(long id): base(id) { - this.InstanceId = IdGenerater.GenerateId(); } public override void Dispose() diff --git a/Unity/Assets/Model/Module/AssetsBundle/ResourcesComponent.cs b/Unity/Assets/Model/Module/AssetsBundle/ResourcesComponent.cs index 274e95ef8e01d553df69b73041f321bf44b02e47..1e2aa6a111b5646fdcd5c8b5834f479299c33ce1 100644 --- a/Unity/Assets/Model/Module/AssetsBundle/ResourcesComponent.cs +++ b/Unity/Assets/Model/Module/AssetsBundle/ResourcesComponent.cs @@ -33,8 +33,6 @@ namespace ETModel public ABInfo(string name, AssetBundle ab) { - this.InstanceId = IdGenerater.GenerateId(); - this.Name = name; this.AssetBundle = ab; this.RefCount = 1; diff --git a/Unity/Assets/Model/Module/Message/Network/KCP/KChannel.cs b/Unity/Assets/Model/Module/Message/Network/KCP/KChannel.cs index 6e2225251460451535d6c8c3e0b6b30511e24492..e0218bdacb853e1e002ab504e0524599533c7840 100644 --- a/Unity/Assets/Model/Module/Message/Network/KCP/KChannel.cs +++ b/Unity/Assets/Model/Module/Message/Network/KCP/KChannel.cs @@ -42,7 +42,6 @@ namespace ETModel // accept public KChannel(uint localConn, uint remoteConn, Socket socket, IPEndPoint remoteEndPoint, KService kService) : base(kService, ChannelType.Accept) { - this.InstanceId = IdGenerater.GenerateId(); this.memoryStream = this.GetService().MemoryStreamManager.GetStream("message", ushort.MaxValue); this.LocalConn = localConn; @@ -69,7 +68,6 @@ namespace ETModel // connect public KChannel(uint localConn, Socket socket, IPEndPoint remoteEndPoint, KService kService) : base(kService, ChannelType.Connect) { - this.InstanceId = IdGenerater.GenerateId(); this.memoryStream = this.GetService().MemoryStreamManager.GetStream("message", ushort.MaxValue); this.LocalConn = localConn; diff --git a/Unity/Assets/Model/Module/Message/Network/KCP/KService.cs b/Unity/Assets/Model/Module/Message/Network/KCP/KService.cs index f9828c66382b15f684d9747e2bb105a5fa7206a2..114dacab64ca2bd774dd11381724752978ca4036 100644 --- a/Unity/Assets/Model/Module/Message/Network/KCP/KService.cs +++ b/Unity/Assets/Model/Module/Message/Network/KCP/KService.cs @@ -59,8 +59,6 @@ namespace ETModel public KService(IPEndPoint ipEndPoint, Action acceptCallback) { - this.InstanceId = ETModel.IdGenerater.GenerateId(); - this.AcceptCallback += acceptCallback; this.StartTime = TimeHelper.ClientNow(); @@ -82,8 +80,6 @@ namespace ETModel public KService() { - this.InstanceId = ETModel.IdGenerater.GenerateId(); - this.StartTime = TimeHelper.ClientNow(); this.TimeNow = (uint)(TimeHelper.ClientNow() - this.StartTime); this.socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); diff --git a/Unity/Assets/Model/Module/Message/Network/TCP/TChannel.cs b/Unity/Assets/Model/Module/Message/Network/TCP/TChannel.cs index 3dbd89d6d38a8b12f0bb37d6473a9b80044b5b02..b71655f623ea94e9d58dc2e222e95a0a48099536 100644 --- a/Unity/Assets/Model/Module/Message/Network/TCP/TChannel.cs +++ b/Unity/Assets/Model/Module/Message/Network/TCP/TChannel.cs @@ -34,7 +34,6 @@ namespace ETModel public TChannel(IPEndPoint ipEndPoint, TService service): base(service, ChannelType.Connect) { - this.InstanceId = IdGenerater.GenerateId(); this.memoryStream = this.GetService().MemoryStreamManager.GetStream("message", ushort.MaxValue); this.socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); @@ -51,7 +50,6 @@ namespace ETModel public TChannel(Socket socket, TService service): base(service, ChannelType.Accept) { - this.InstanceId = IdGenerater.GenerateId(); this.memoryStream = this.GetService().MemoryStreamManager.GetStream("message", ushort.MaxValue); this.socket = socket; diff --git a/Unity/Assets/Model/Module/Message/Network/TCP/TService.cs b/Unity/Assets/Model/Module/Message/Network/TCP/TService.cs index c8c9fcb124abdc6d9f904c50aa88a3e1a3b3e597..ad718f4aace9c139123352256af22c63eaafb7a1 100644 --- a/Unity/Assets/Model/Module/Message/Network/TCP/TService.cs +++ b/Unity/Assets/Model/Module/Message/Network/TCP/TService.cs @@ -24,7 +24,6 @@ namespace ETModel /// public TService(IPEndPoint ipEndPoint, Action acceptCallback) { - this.InstanceId = IdGenerater.GenerateId(); this.AcceptCallback += acceptCallback; this.acceptor = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); @@ -39,7 +38,6 @@ namespace ETModel public TService() { - this.InstanceId = IdGenerater.GenerateId(); } public override void Dispose() diff --git a/Unity/Assets/Model/Module/Message/Network/WebSocket/WChannel.cs b/Unity/Assets/Model/Module/Message/Network/WebSocket/WChannel.cs index 0da360707c0c71112f5b3fbd40c0a771851272a2..edea5c43800306457ea3b5f91dcf95f54294ea49 100644 --- a/Unity/Assets/Model/Module/Message/Network/WebSocket/WChannel.cs +++ b/Unity/Assets/Model/Module/Message/Network/WebSocket/WChannel.cs @@ -26,8 +26,6 @@ namespace ETModel public WChannel(HttpListenerWebSocketContext webSocketContext, AService service): base(service, ChannelType.Accept) { - this.InstanceId = IdGenerater.GenerateId(); - this.WebSocketContext = webSocketContext; this.webSocket = webSocketContext.WebSocket; @@ -40,8 +38,6 @@ namespace ETModel public WChannel(WebSocket webSocket, AService service): base(service, ChannelType.Connect) { - this.InstanceId = IdGenerater.GenerateId(); - this.webSocket = webSocket; this.memoryStream = this.GetService().MemoryStreamManager.GetStream("message", ushort.MaxValue); diff --git a/Unity/Assets/Model/Module/Message/Network/WebSocket/WService.cs b/Unity/Assets/Model/Module/Message/Network/WebSocket/WService.cs index 6c9fc40a74d4e0b1741e33a6169e57969c0249c3..71ffc64657012302fece83a0aac208132ef2dd26 100644 --- a/Unity/Assets/Model/Module/Message/Network/WebSocket/WService.cs +++ b/Unity/Assets/Model/Module/Message/Network/WebSocket/WService.cs @@ -16,8 +16,6 @@ namespace ETModel public WService(IEnumerable prefixs, Action acceptCallback) { - this.InstanceId = IdGenerater.GenerateId(); - this.AcceptCallback += acceptCallback; this.httpListener = new HttpListener(); @@ -27,7 +25,6 @@ namespace ETModel public WService() { - this.InstanceId = IdGenerater.GenerateId(); } public override AChannel GetChannel(long id) diff --git a/Unity/Unity.sln b/Unity/Unity.sln index 692fdca9e2f38aac542b439d8dc4dd33cad7cf50..8a9d5c5e83cc955e4842cbfdf179d6ee255d1d33 100644 --- a/Unity/Unity.sln +++ b/Unity/Unity.sln @@ -4,10 +4,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Model", "Unity.Model. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.ThirdParty", "Unity.ThirdParty.csproj", "{E15BADD2-3A26-309A-AB0F-DC5B08044350}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Hotfix", "Unity.Hotfix.csproj", "{1066F652-6A89-D1C4-9881-1A19DF7AB80E}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Editor", "Unity.Editor.csproj", "{CD311104-1830-B119-81B6-5DBEE2467FFB}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Hotfix", "Unity.Hotfix.csproj", "{1066F652-6A89-D1C4-9881-1A19DF7AB80E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -22,14 +22,14 @@ Global {E15BADD2-3A26-309A-AB0F-DC5B08044350}.Debug|Any CPU.Build.0 = Debug|Any CPU {E15BADD2-3A26-309A-AB0F-DC5B08044350}.Release|Any CPU.ActiveCfg = Release|Any CPU {E15BADD2-3A26-309A-AB0F-DC5B08044350}.Release|Any CPU.Build.0 = Release|Any CPU - {1066F652-6A89-D1C4-9881-1A19DF7AB80E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1066F652-6A89-D1C4-9881-1A19DF7AB80E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1066F652-6A89-D1C4-9881-1A19DF7AB80E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1066F652-6A89-D1C4-9881-1A19DF7AB80E}.Release|Any CPU.Build.0 = Release|Any CPU {CD311104-1830-B119-81B6-5DBEE2467FFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CD311104-1830-B119-81B6-5DBEE2467FFB}.Debug|Any CPU.Build.0 = Debug|Any CPU {CD311104-1830-B119-81B6-5DBEE2467FFB}.Release|Any CPU.ActiveCfg = Release|Any CPU {CD311104-1830-B119-81B6-5DBEE2467FFB}.Release|Any CPU.Build.0 = Release|Any CPU + {1066F652-6A89-D1C4-9881-1A19DF7AB80E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1066F652-6A89-D1C4-9881-1A19DF7AB80E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1066F652-6A89-D1C4-9881-1A19DF7AB80E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1066F652-6A89-D1C4-9881-1A19DF7AB80E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE