From 4968032a6412f0d5b891d905dab282523684cfd1 Mon Sep 17 00:00:00 2001 From: tanghai Date: Thu, 22 Jun 2017 16:04:42 +0800 Subject: [PATCH] =?UTF-8?q?mono=E5=B1=82=E5=92=8Chotfix=E5=B1=82=E5=88=86?= =?UTF-8?q?=E5=88=AB=E5=88=9B=E5=BB=BA=E4=B8=80=E4=BB=BDEntity=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=EF=BC=8C=E5=8F=AA=E4=BD=BF=E7=94=A8=E5=91=BD=E5=90=8D?= =?UTF-8?q?=E7=A9=BA=E9=97=B4=E5=8C=BA=E5=88=86=EF=BC=8C=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E9=9A=8F=E6=97=B6=E5=B0=86Entity=E5=92=8CComponent=E6=94=BE?= =?UTF-8?q?=E5=9C=A8=E4=BB=BB=E4=BD=95=E4=B8=80=E5=B1=82=E4=B8=8A=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Unity/Assets/Scripts/Component.meta | 9 + Unity/Assets/Scripts/Component/Config.meta | 9 + .../Scripts}/Component/Config/ClientConfig.cs | 2 +- .../Component/Config/ClientConfig.cs.meta | 12 ++ .../Scripts}/Component/Config/InnerConfig.cs | 2 +- .../Component/Config/InnerConfig.cs.meta | 12 ++ .../Scripts}/Component/Config/OuterConfig.cs | 2 +- .../Component/Config/OuterConfig.cs.meta | 12 ++ .../Component/Config/RunServerConfig.cs | 2 +- .../Component/Config/RunServerConfig.cs.meta | 12 ++ .../Scripts/Component/EventComponent.cs | 126 ++++++++++++ .../Scripts/Component/EventComponent.cs.meta | 12 ++ .../Component/MessageDispatherComponent.cs | 7 +- .../MessageDispatherComponent.cs.meta | 12 ++ .../Scripts}/Component/NetInnerComponent.cs | 3 +- .../Component/NetInnerComponent.cs.meta | 12 ++ .../Scripts}/Component/NetOuterComponent.cs | 4 +- .../Component/NetOuterComponent.cs.meta | 12 ++ .../Scripts}/Component/NetworkComponent.cs | 5 +- .../Component/NetworkComponent.cs.meta | 12 ++ .../Scripts/Component/TimerComponent.cs | 105 ++++++++++ .../Scripts/Component/TimerComponent.cs.meta | 12 ++ Unity/Assets/Scripts/Config.meta | 9 + .../Scripts}/Config/ACategory.cs | 2 +- .../Scripts}/Config/ACategory.cs.meta | 0 .../Scripts}/Config/AConfig.cs | 4 +- .../Scripts}/Config/AConfig.cs.meta | 0 .../Scripts}/Config/AConfigComponent.cs | 4 +- .../Scripts}/Config/AConfigComponent.cs.meta | 0 .../Scripts}/Config/ConfigAttribute.cs | 2 +- .../Scripts}/Config/ConfigAttribute.cs.meta | 0 .../Scripts}/Config/ConfigHelper.cs | 2 +- .../Scripts}/Config/ConfigHelper.cs.meta | 0 .../Scripts}/Config/ICategory.cs | 2 +- .../Scripts}/Config/ICategory.cs.meta | 0 Unity/{Hotfix => Assets/Scripts}/DllHelper.cs | 2 +- Unity/Assets/Scripts/DllHelper.cs.meta | 12 ++ Unity/Assets/Scripts/Entity.meta | 9 + .../Scripts}/Entity/AssetBundleLoaderAsync.cs | 4 +- .../Entity/AssetBundleLoaderAsync.cs.meta | 12 ++ Unity/Assets/Scripts/Entity/Config.meta | 9 + .../Scripts}/Entity/Config/BuffConfig.cs | 2 +- .../Scripts/Entity/Config/BuffConfig.cs.meta | 12 ++ .../Scripts}/Entity/Config/StartConfig.cs | 2 +- .../Scripts/Entity/Config/StartConfig.cs.meta | 12 ++ Unity/Assets/Scripts/Entity/Game.cs | 28 +++ Unity/Assets/Scripts/Entity/Game.cs.meta | 12 ++ Unity/Assets/Scripts/Entity/Scene.cs | 44 +++++ Unity/Assets/Scripts/Entity/Scene.cs.meta | 12 ++ .../Scripts}/Entity/Session.cs | 5 +- Unity/Assets/Scripts/Entity/Session.cs.meta | 12 ++ .../Scripts}/Entity/WWWAsync.cs | 4 +- Unity/Assets/Scripts/Entity/WWWAsync.cs.meta | 12 ++ Unity/Assets/Scripts/Event.meta | 9 + Unity/Assets/Scripts/Event/AEventAttribute.cs | 15 ++ .../Scripts/Event/AEventAttribute.cs.meta | 12 ++ Unity/Assets/Scripts/Event/Env.cs | 91 +++++++++ Unity/Assets/Scripts/Event/Env.cs.meta | 12 ++ Unity/Assets/Scripts/Event/EnvKey.cs | 10 + Unity/Assets/Scripts/Event/EnvKey.cs.meta | 12 ++ Unity/Assets/Scripts/Event/EventAttribute.cs | 9 + .../Scripts/Event/EventAttribute.cs.meta | 12 ++ Unity/Assets/Scripts/Event/EventIdType.cs | 18 ++ .../Assets/Scripts/Event/EventIdType.cs.meta | 12 ++ Unity/Assets/Scripts/Event/IEvent.cs | 37 ++++ Unity/Assets/Scripts/Event/IEvent.cs.meta | 12 ++ .../Scripts}/Helper/GameObjectHelper.cs | 2 +- .../Scripts/Helper/GameObjectHelper.cs.meta | 12 ++ .../Scripts}/Helper/JsonHelper.cs | 4 +- .../Assets/Scripts/Helper/JsonHelper.cs.meta | 12 ++ Unity/Assets/Scripts/Helper/ResourceHelper.cs | 2 +- Unity/Assets/Scripts/IL/ILBindingAttribute.cs | 2 +- Unity/Assets/Scripts/Init.cs | 2 + Unity/Assets/Scripts/Message.meta | 9 + .../Scripts}/Message/AMHandler.cs | 2 +- .../Scripts}/Message/AMHandler.cs.meta | 0 .../Scripts}/Message/AMessage.cs | 2 +- .../Scripts}/Message/AMessage.cs.meta | 0 .../Scripts}/Message/AppType.cs | 2 +- .../Scripts}/Message/AppType.cs.meta | 0 .../Scripts}/Message/ErrorCode.cs | 2 +- .../Scripts}/Message/ErrorCode.cs.meta | 0 .../Scripts}/Message/IMHandler.cs | 2 +- .../Scripts}/Message/IMHandler.cs.meta | 0 .../Scripts}/Message/MessageAttribute.cs | 2 +- .../Scripts}/Message/MessageAttribute.cs.meta | 0 .../Message/MessageHandlerAttribute.cs | 2 +- .../Message/MessageHandlerAttribute.cs.meta | 0 .../Scripts}/Message/MessageInfo.cs | 2 +- .../Scripts}/Message/MessageInfo.cs.meta | 0 .../Scripts}/Message/OpcodeHelper.cs | 2 +- .../Scripts}/Message/OpcodeHelper.cs.meta | 0 .../Scripts}/Message/RpcException.cs | 2 +- .../Scripts}/Message/RpcException.cs.meta | 0 Unity/Assets/Scripts/Object.meta | 9 + Unity/Assets/Scripts/Object/Component.cs | 40 ++++ Unity/Assets/Scripts/Object/Component.cs.meta | 12 ++ Unity/Assets/Scripts/Object/Disposer.cs | 21 ++ Unity/Assets/Scripts/Object/Disposer.cs.meta | 12 ++ Unity/Assets/Scripts/Object/Entity.cs | 186 ++++++++++++++++++ Unity/Assets/Scripts/Object/Entity.cs.meta | 12 ++ .../Scripts}/Object/EntityEventAttribute.cs | 2 +- .../Object/EntityEventAttribute.cs.meta | 12 ++ Unity/Assets/Scripts/Object/EntityEventId.cs | 30 +++ .../Scripts/Object/EntityEventId.cs.meta | 12 ++ Unity/Assets/Scripts/Object/EntityType.cs | 12 ++ .../Assets/Scripts/Object/EntityType.cs.meta | 12 ++ Unity/Assets/Scripts/Object/IAwake.cs | 22 +++ Unity/Assets/Scripts/Object/IAwake.cs.meta | 12 ++ Unity/Assets/Scripts/Object/ILoad.cs | 7 + Unity/Assets/Scripts/Object/ILoad.cs.meta | 12 ++ Unity/Assets/Scripts/Object/IUpdate.cs | 7 + Unity/Assets/Scripts/Object/IUpdate.cs.meta | 12 ++ Unity/Assets/Scripts/Object/Object.cs | 23 +++ Unity/Assets/Scripts/Object/Object.cs.meta | 12 ++ .../Scripts/Object/ObjectEventAttribute.cs | 15 ++ .../Object/ObjectEventAttribute.cs.meta | 12 ++ Unity/Assets/Scripts/Object/ObjectEvents.cs | 98 +++++++++ .../Scripts/Object/ObjectEvents.cs.meta | 12 ++ Unity/Hotfix/Component/BenchmarkComponent.cs | 79 -------- Unity/Hotfix/Component/ConfigComponent.cs | 3 +- Unity/Hotfix/Component/EventComponent.cs | 4 +- Unity/Hotfix/Component/GameObjectComponent.cs | 4 +- Unity/Hotfix/Component/KVComponent.cs | 2 +- Unity/Hotfix/Component/ResourcesComponent.cs | 4 +- Unity/Hotfix/Component/RobotComponent.cs | 4 +- Unity/Hotfix/Component/TimeComponent.cs | 2 +- Unity/Hotfix/Component/TimerComponent.cs | 4 +- Unity/Hotfix/Component/UIComponent.cs | 4 +- Unity/Hotfix/Component/UnitComponent.cs | 4 +- Unity/Hotfix/Entity/Scene.cs | 2 +- Unity/Hotfix/Entity/UI.cs | 2 +- Unity/Hotfix/Entity/Unit.cs | 2 +- Unity/Hotfix/HotfixInit.cs | 2 - .../{HotfixComponent.cs => Component.cs} | 13 +- .../Object/{HotfixEntity.cs => Entity.cs} | 42 ++-- Unity/Hotfix/Object/ObjectEventAttribute.cs | 15 ++ .../UI/UILobby/Component/UILobbyComponent.cs | 8 +- Unity/Hotfix/Unity.Hotfix.csproj | 43 +--- Unity/Unity.csproj | 55 ++++++ Unity/Unity.csproj.user | 6 + 141 files changed, 1651 insertions(+), 221 deletions(-) create mode 100644 Unity/Assets/Scripts/Component.meta create mode 100644 Unity/Assets/Scripts/Component/Config.meta rename Unity/{Hotfix => Assets/Scripts}/Component/Config/ClientConfig.cs (93%) create mode 100644 Unity/Assets/Scripts/Component/Config/ClientConfig.cs.meta rename Unity/{Hotfix => Assets/Scripts}/Component/Config/InnerConfig.cs (94%) create mode 100644 Unity/Assets/Scripts/Component/Config/InnerConfig.cs.meta rename Unity/{Hotfix => Assets/Scripts}/Component/Config/OuterConfig.cs (94%) create mode 100644 Unity/Assets/Scripts/Component/Config/OuterConfig.cs.meta rename Unity/{Hotfix => Assets/Scripts}/Component/Config/RunServerConfig.cs (89%) create mode 100644 Unity/Assets/Scripts/Component/Config/RunServerConfig.cs.meta create mode 100644 Unity/Assets/Scripts/Component/EventComponent.cs create mode 100644 Unity/Assets/Scripts/Component/EventComponent.cs.meta rename Unity/{Hotfix => Assets/Scripts}/Component/MessageDispatherComponent.cs (93%) create mode 100644 Unity/Assets/Scripts/Component/MessageDispatherComponent.cs.meta rename Unity/{Hotfix => Assets/Scripts}/Component/NetInnerComponent.cs (97%) create mode 100644 Unity/Assets/Scripts/Component/NetInnerComponent.cs.meta rename Unity/{Hotfix => Assets/Scripts}/Component/NetOuterComponent.cs (91%) create mode 100644 Unity/Assets/Scripts/Component/NetOuterComponent.cs.meta rename Unity/{Hotfix => Assets/Scripts}/Component/NetworkComponent.cs (96%) create mode 100644 Unity/Assets/Scripts/Component/NetworkComponent.cs.meta create mode 100644 Unity/Assets/Scripts/Component/TimerComponent.cs create mode 100644 Unity/Assets/Scripts/Component/TimerComponent.cs.meta create mode 100644 Unity/Assets/Scripts/Config.meta rename Unity/{Hotfix => Assets/Scripts}/Config/ACategory.cs (98%) rename Unity/{Hotfix => Assets/Scripts}/Config/ACategory.cs.meta (100%) rename Unity/{Hotfix => Assets/Scripts}/Config/AConfig.cs (76%) rename Unity/{Hotfix => Assets/Scripts}/Config/AConfig.cs.meta (100%) rename Unity/{Hotfix => Assets/Scripts}/Config/AConfigComponent.cs (75%) rename Unity/{Hotfix => Assets/Scripts}/Config/AConfigComponent.cs.meta (100%) rename Unity/{Hotfix => Assets/Scripts}/Config/ConfigAttribute.cs (92%) rename Unity/{Hotfix => Assets/Scripts}/Config/ConfigAttribute.cs.meta (100%) rename Unity/{Hotfix => Assets/Scripts}/Config/ConfigHelper.cs (95%) rename Unity/{Hotfix => Assets/Scripts}/Config/ConfigHelper.cs.meta (100%) rename Unity/{Hotfix => Assets/Scripts}/Config/ICategory.cs (87%) rename Unity/{Hotfix => Assets/Scripts}/Config/ICategory.cs.meta (100%) rename Unity/{Hotfix => Assets/Scripts}/DllHelper.cs (98%) create mode 100644 Unity/Assets/Scripts/DllHelper.cs.meta create mode 100644 Unity/Assets/Scripts/Entity.meta rename Unity/{Hotfix => Assets/Scripts}/Entity/AssetBundleLoaderAsync.cs (92%) create mode 100644 Unity/Assets/Scripts/Entity/AssetBundleLoaderAsync.cs.meta create mode 100644 Unity/Assets/Scripts/Entity/Config.meta rename Unity/{Hotfix => Assets/Scripts}/Entity/Config/BuffConfig.cs (95%) create mode 100644 Unity/Assets/Scripts/Entity/Config/BuffConfig.cs.meta rename Unity/{Hotfix => Assets/Scripts}/Entity/Config/StartConfig.cs (94%) create mode 100644 Unity/Assets/Scripts/Entity/Config/StartConfig.cs.meta create mode 100644 Unity/Assets/Scripts/Entity/Game.cs create mode 100644 Unity/Assets/Scripts/Entity/Game.cs.meta create mode 100644 Unity/Assets/Scripts/Entity/Scene.cs create mode 100644 Unity/Assets/Scripts/Entity/Scene.cs.meta rename Unity/{Hotfix => Assets/Scripts}/Entity/Session.cs (98%) create mode 100644 Unity/Assets/Scripts/Entity/Session.cs.meta rename Unity/{Hotfix => Assets/Scripts}/Entity/WWWAsync.cs (97%) create mode 100644 Unity/Assets/Scripts/Entity/WWWAsync.cs.meta create mode 100644 Unity/Assets/Scripts/Event.meta create mode 100644 Unity/Assets/Scripts/Event/AEventAttribute.cs create mode 100644 Unity/Assets/Scripts/Event/AEventAttribute.cs.meta create mode 100644 Unity/Assets/Scripts/Event/Env.cs create mode 100644 Unity/Assets/Scripts/Event/Env.cs.meta create mode 100644 Unity/Assets/Scripts/Event/EnvKey.cs create mode 100644 Unity/Assets/Scripts/Event/EnvKey.cs.meta create mode 100644 Unity/Assets/Scripts/Event/EventAttribute.cs create mode 100644 Unity/Assets/Scripts/Event/EventAttribute.cs.meta create mode 100644 Unity/Assets/Scripts/Event/EventIdType.cs create mode 100644 Unity/Assets/Scripts/Event/EventIdType.cs.meta create mode 100644 Unity/Assets/Scripts/Event/IEvent.cs create mode 100644 Unity/Assets/Scripts/Event/IEvent.cs.meta rename Unity/{Hotfix => Assets/Scripts}/Helper/GameObjectHelper.cs (95%) create mode 100644 Unity/Assets/Scripts/Helper/GameObjectHelper.cs.meta rename Unity/{Hotfix => Assets/Scripts}/Helper/JsonHelper.cs (93%) create mode 100644 Unity/Assets/Scripts/Helper/JsonHelper.cs.meta create mode 100644 Unity/Assets/Scripts/Message.meta rename Unity/{Hotfix => Assets/Scripts}/Message/AMHandler.cs (98%) rename Unity/{Hotfix => Assets/Scripts}/Message/AMHandler.cs.meta (100%) rename Unity/{Hotfix => Assets/Scripts}/Message/AMessage.cs (93%) rename Unity/{Hotfix => Assets/Scripts}/Message/AMessage.cs.meta (100%) rename Unity/{Hotfix => Assets/Scripts}/Message/AppType.cs (96%) rename Unity/{Hotfix => Assets/Scripts}/Message/AppType.cs.meta (100%) rename Unity/{Hotfix => Assets/Scripts}/Message/ErrorCode.cs (94%) rename Unity/{Hotfix => Assets/Scripts}/Message/ErrorCode.cs.meta (100%) rename Unity/{Hotfix => Assets/Scripts}/Message/IMHandler.cs (88%) rename Unity/{Hotfix => Assets/Scripts}/Message/IMHandler.cs.meta (100%) rename Unity/{Hotfix => Assets/Scripts}/Message/MessageAttribute.cs (91%) rename Unity/{Hotfix => Assets/Scripts}/Message/MessageAttribute.cs.meta (100%) rename Unity/{Hotfix => Assets/Scripts}/Message/MessageHandlerAttribute.cs (93%) rename Unity/{Hotfix => Assets/Scripts}/Message/MessageHandlerAttribute.cs.meta (100%) rename Unity/{Hotfix => Assets/Scripts}/Message/MessageInfo.cs (96%) rename Unity/{Hotfix => Assets/Scripts}/Message/MessageInfo.cs.meta (100%) rename Unity/{Hotfix => Assets/Scripts}/Message/OpcodeHelper.cs (95%) rename Unity/{Hotfix => Assets/Scripts}/Message/OpcodeHelper.cs.meta (100%) rename Unity/{Hotfix => Assets/Scripts}/Message/RpcException.cs (96%) rename Unity/{Hotfix => Assets/Scripts}/Message/RpcException.cs.meta (100%) create mode 100644 Unity/Assets/Scripts/Object.meta create mode 100644 Unity/Assets/Scripts/Object/Component.cs create mode 100644 Unity/Assets/Scripts/Object/Component.cs.meta create mode 100644 Unity/Assets/Scripts/Object/Disposer.cs create mode 100644 Unity/Assets/Scripts/Object/Disposer.cs.meta create mode 100644 Unity/Assets/Scripts/Object/Entity.cs create mode 100644 Unity/Assets/Scripts/Object/Entity.cs.meta rename Unity/{Hotfix => Assets/Scripts}/Object/EntityEventAttribute.cs (93%) create mode 100644 Unity/Assets/Scripts/Object/EntityEventAttribute.cs.meta create mode 100644 Unity/Assets/Scripts/Object/EntityEventId.cs create mode 100644 Unity/Assets/Scripts/Object/EntityEventId.cs.meta create mode 100644 Unity/Assets/Scripts/Object/EntityType.cs create mode 100644 Unity/Assets/Scripts/Object/EntityType.cs.meta create mode 100644 Unity/Assets/Scripts/Object/IAwake.cs create mode 100644 Unity/Assets/Scripts/Object/IAwake.cs.meta create mode 100644 Unity/Assets/Scripts/Object/ILoad.cs create mode 100644 Unity/Assets/Scripts/Object/ILoad.cs.meta create mode 100644 Unity/Assets/Scripts/Object/IUpdate.cs create mode 100644 Unity/Assets/Scripts/Object/IUpdate.cs.meta create mode 100644 Unity/Assets/Scripts/Object/Object.cs create mode 100644 Unity/Assets/Scripts/Object/Object.cs.meta create mode 100644 Unity/Assets/Scripts/Object/ObjectEventAttribute.cs create mode 100644 Unity/Assets/Scripts/Object/ObjectEventAttribute.cs.meta create mode 100644 Unity/Assets/Scripts/Object/ObjectEvents.cs create mode 100644 Unity/Assets/Scripts/Object/ObjectEvents.cs.meta delete mode 100644 Unity/Hotfix/Component/BenchmarkComponent.cs rename Unity/Hotfix/Object/{HotfixComponent.cs => Component.cs} (52%) rename Unity/Hotfix/Object/{HotfixEntity.cs => Entity.cs} (74%) create mode 100644 Unity/Hotfix/Object/ObjectEventAttribute.cs create mode 100644 Unity/Unity.csproj.user diff --git a/Unity/Assets/Scripts/Component.meta b/Unity/Assets/Scripts/Component.meta new file mode 100644 index 00000000..5876c4c5 --- /dev/null +++ b/Unity/Assets/Scripts/Component.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 2a558a9c1a99ead44867c6b71472566f +folderAsset: yes +timeCreated: 1498117616 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Component/Config.meta b/Unity/Assets/Scripts/Component/Config.meta new file mode 100644 index 00000000..3438c954 --- /dev/null +++ b/Unity/Assets/Scripts/Component/Config.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: e98bd4118f88e1c428e3af0983722aa8 +folderAsset: yes +timeCreated: 1498118075 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Hotfix/Component/Config/ClientConfig.cs b/Unity/Assets/Scripts/Component/Config/ClientConfig.cs similarity index 93% rename from Unity/Hotfix/Component/Config/ClientConfig.cs rename to Unity/Assets/Scripts/Component/Config/ClientConfig.cs index aced1bb1..81455fd1 100644 --- a/Unity/Hotfix/Component/Config/ClientConfig.cs +++ b/Unity/Assets/Scripts/Component/Config/ClientConfig.cs @@ -1,6 +1,6 @@ using MongoDB.Bson.Serialization.Attributes; -namespace Hotfix +namespace Model { [BsonIgnoreExtraElements] public class ClientConfig: AConfigComponent diff --git a/Unity/Assets/Scripts/Component/Config/ClientConfig.cs.meta b/Unity/Assets/Scripts/Component/Config/ClientConfig.cs.meta new file mode 100644 index 00000000..8d8eb8a9 --- /dev/null +++ b/Unity/Assets/Scripts/Component/Config/ClientConfig.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: befeb8cfbdbfc5b4ea5f967c200d4751 +timeCreated: 1498118076 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Hotfix/Component/Config/InnerConfig.cs b/Unity/Assets/Scripts/Component/Config/InnerConfig.cs similarity index 94% rename from Unity/Hotfix/Component/Config/InnerConfig.cs rename to Unity/Assets/Scripts/Component/Config/InnerConfig.cs index 282e7b09..a5e03817 100644 --- a/Unity/Hotfix/Component/Config/InnerConfig.cs +++ b/Unity/Assets/Scripts/Component/Config/InnerConfig.cs @@ -1,6 +1,6 @@ using MongoDB.Bson.Serialization.Attributes; -namespace Hotfix +namespace Model { [BsonIgnoreExtraElements] public class InnerConfig: AConfigComponent diff --git a/Unity/Assets/Scripts/Component/Config/InnerConfig.cs.meta b/Unity/Assets/Scripts/Component/Config/InnerConfig.cs.meta new file mode 100644 index 00000000..321faff3 --- /dev/null +++ b/Unity/Assets/Scripts/Component/Config/InnerConfig.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 35f166fd86ee5e44aaec9326bb0a5454 +timeCreated: 1498118076 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Hotfix/Component/Config/OuterConfig.cs b/Unity/Assets/Scripts/Component/Config/OuterConfig.cs similarity index 94% rename from Unity/Hotfix/Component/Config/OuterConfig.cs rename to Unity/Assets/Scripts/Component/Config/OuterConfig.cs index fb83fa7c..82446c74 100644 --- a/Unity/Hotfix/Component/Config/OuterConfig.cs +++ b/Unity/Assets/Scripts/Component/Config/OuterConfig.cs @@ -1,6 +1,6 @@ using MongoDB.Bson.Serialization.Attributes; -namespace Hotfix +namespace Model { [BsonIgnoreExtraElements] public class OuterConfig: AConfigComponent diff --git a/Unity/Assets/Scripts/Component/Config/OuterConfig.cs.meta b/Unity/Assets/Scripts/Component/Config/OuterConfig.cs.meta new file mode 100644 index 00000000..c06888eb --- /dev/null +++ b/Unity/Assets/Scripts/Component/Config/OuterConfig.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 31224cfdac2f28c42bd641d5a2e80fe8 +timeCreated: 1498118075 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Hotfix/Component/Config/RunServerConfig.cs b/Unity/Assets/Scripts/Component/Config/RunServerConfig.cs similarity index 89% rename from Unity/Hotfix/Component/Config/RunServerConfig.cs rename to Unity/Assets/Scripts/Component/Config/RunServerConfig.cs index 9a73190a..0c2d0268 100644 --- a/Unity/Hotfix/Component/Config/RunServerConfig.cs +++ b/Unity/Assets/Scripts/Component/Config/RunServerConfig.cs @@ -1,6 +1,6 @@ using MongoDB.Bson.Serialization.Attributes; -namespace Hotfix +namespace Model { [BsonIgnoreExtraElements] public class RunServerConfig: AConfigComponent diff --git a/Unity/Assets/Scripts/Component/Config/RunServerConfig.cs.meta b/Unity/Assets/Scripts/Component/Config/RunServerConfig.cs.meta new file mode 100644 index 00000000..d37a8505 --- /dev/null +++ b/Unity/Assets/Scripts/Component/Config/RunServerConfig.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: bceb49362f439a248b806059721da628 +timeCreated: 1498118076 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Component/EventComponent.cs b/Unity/Assets/Scripts/Component/EventComponent.cs new file mode 100644 index 00000000..8af5d540 --- /dev/null +++ b/Unity/Assets/Scripts/Component/EventComponent.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using Model; + +namespace Model +{ + [EntityEvent(EntityEventId.EventComponent)] + public class EventComponent : Component, IAwake + { + private Dictionary> allEvents; + + public void Awake() + { + this.Load(); + } + + public void Load() + { + this.allEvents = new Dictionary>(); + + Type[] types = DllHelper.GetAllTypes(); + foreach (Type type in types) + { + object[] attrs = type.GetCustomAttributes(typeof(EventAttribute), false); + + foreach (object attr in attrs) + { + EventAttribute aEventAttribute = (EventAttribute)attr; + object obj = Activator.CreateInstance(type); + if (!this.allEvents.ContainsKey(aEventAttribute.Type)) + { + this.allEvents.Add(aEventAttribute.Type, new List()); + } + this.allEvents[aEventAttribute.Type].Add(obj); + } + } + } + + public void Run(int type) + { + List iEvents = null; + if (!this.allEvents.TryGetValue(type, out iEvents)) + { + return; + } + foreach (object obj in iEvents) + { + try + { + IEvent iEvent = (IEvent)obj; + iEvent.Run(); + } + catch (Exception e) + { + Log.Error(e.ToString()); + } + } + } + + public void Run(int type, A a) + { + List iEvents = null; + if (!this.allEvents.TryGetValue(type, out iEvents)) + { + return; + } + + foreach (object obj in iEvents) + { + try + { + IEvent iEvent = (IEvent)obj; + iEvent.Run(a); + } + catch (Exception err) + { + Log.Error(err.ToString()); + } + } + } + + public void Run(int type, A a, B b) + { + List iEvents = null; + if (!this.allEvents.TryGetValue(type, out iEvents)) + { + return; + } + + foreach (object obj in iEvents) + { + try + { + IEvent iEvent = (IEvent)obj; + iEvent.Run(a, b); + } + catch (Exception err) + { + Log.Error(err.ToString()); + } + } + } + + public void Run(int type, A a, B b, C c) + { + List iEvents = null; + if (!this.allEvents.TryGetValue(type, out iEvents)) + { + return; + } + + foreach (object obj in iEvents) + { + try + { + IEvent iEvent = (IEvent)obj; + iEvent.Run(a, b, c); + } + catch (Exception err) + { + Log.Error(err.ToString()); + } + } + } + } +} \ No newline at end of file diff --git a/Unity/Assets/Scripts/Component/EventComponent.cs.meta b/Unity/Assets/Scripts/Component/EventComponent.cs.meta new file mode 100644 index 00000000..5a6f1bbe --- /dev/null +++ b/Unity/Assets/Scripts/Component/EventComponent.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: fdeabd62f7ad9414fa74891de319729f +timeCreated: 1498117617 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Hotfix/Component/MessageDispatherComponent.cs b/Unity/Assets/Scripts/Component/MessageDispatherComponent.cs similarity index 93% rename from Unity/Hotfix/Component/MessageDispatherComponent.cs rename to Unity/Assets/Scripts/Component/MessageDispatherComponent.cs index f5d9e335..a137851f 100644 --- a/Unity/Hotfix/Component/MessageDispatherComponent.cs +++ b/Unity/Assets/Scripts/Component/MessageDispatherComponent.cs @@ -1,14 +1,13 @@ using System; using System.Collections.Generic; -using Model; -namespace Hotfix +namespace Model { /// /// 消息分发组件 /// - [EntityEvent(EntityEventId.MessageDispatherComponent)] - public class MessageDispatherComponent: HotfixComponent, IAwake, ILoad + [ObjectEvent(EntityEventId.MessageDispatherComponent)] + public class MessageDispatherComponent: Component, IAwake, ILoad { private AppType AppType; private Dictionary> handlers; diff --git a/Unity/Assets/Scripts/Component/MessageDispatherComponent.cs.meta b/Unity/Assets/Scripts/Component/MessageDispatherComponent.cs.meta new file mode 100644 index 00000000..b3a18117 --- /dev/null +++ b/Unity/Assets/Scripts/Component/MessageDispatherComponent.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 8e97599ee372f6f40aaa5e743851a74c +timeCreated: 1498117781 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Hotfix/Component/NetInnerComponent.cs b/Unity/Assets/Scripts/Component/NetInnerComponent.cs similarity index 97% rename from Unity/Hotfix/Component/NetInnerComponent.cs rename to Unity/Assets/Scripts/Component/NetInnerComponent.cs index da7001ba..17434a9f 100644 --- a/Unity/Hotfix/Component/NetInnerComponent.cs +++ b/Unity/Assets/Scripts/Component/NetInnerComponent.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; -using Model; -namespace Hotfix +namespace Model { [EntityEvent(EntityEventId.NetInnerComponent)] public class NetInnerComponent: NetworkComponent diff --git a/Unity/Assets/Scripts/Component/NetInnerComponent.cs.meta b/Unity/Assets/Scripts/Component/NetInnerComponent.cs.meta new file mode 100644 index 00000000..0ecfbd66 --- /dev/null +++ b/Unity/Assets/Scripts/Component/NetInnerComponent.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1ab11b2f08956d1499373e40ab1eba6b +timeCreated: 1498117616 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Hotfix/Component/NetOuterComponent.cs b/Unity/Assets/Scripts/Component/NetOuterComponent.cs similarity index 91% rename from Unity/Hotfix/Component/NetOuterComponent.cs rename to Unity/Assets/Scripts/Component/NetOuterComponent.cs index 0ff9eb20..5cf54b52 100644 --- a/Unity/Hotfix/Component/NetOuterComponent.cs +++ b/Unity/Assets/Scripts/Component/NetOuterComponent.cs @@ -1,6 +1,4 @@ -using Model; - -namespace Hotfix +namespace Model { [EntityEvent(EntityEventId.NetOuterComponent)] public class NetOuterComponent: NetworkComponent, IAwake, IAwake, IUpdate diff --git a/Unity/Assets/Scripts/Component/NetOuterComponent.cs.meta b/Unity/Assets/Scripts/Component/NetOuterComponent.cs.meta new file mode 100644 index 00000000..29f8a599 --- /dev/null +++ b/Unity/Assets/Scripts/Component/NetOuterComponent.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2540893057b627148a6fe09470765227 +timeCreated: 1498117616 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Hotfix/Component/NetworkComponent.cs b/Unity/Assets/Scripts/Component/NetworkComponent.cs similarity index 96% rename from Unity/Hotfix/Component/NetworkComponent.cs rename to Unity/Assets/Scripts/Component/NetworkComponent.cs index 890266c3..f1d3baa8 100644 --- a/Unity/Hotfix/Component/NetworkComponent.cs +++ b/Unity/Assets/Scripts/Component/NetworkComponent.cs @@ -2,11 +2,10 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Model; -namespace Hotfix +namespace Model { - public abstract class NetworkComponent: HotfixComponent + public abstract class NetworkComponent: Component { private AService Service; diff --git a/Unity/Assets/Scripts/Component/NetworkComponent.cs.meta b/Unity/Assets/Scripts/Component/NetworkComponent.cs.meta new file mode 100644 index 00000000..0076457a --- /dev/null +++ b/Unity/Assets/Scripts/Component/NetworkComponent.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 151d2db7aab5bc8438bc039443ba0e3b +timeCreated: 1498117616 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Component/TimerComponent.cs b/Unity/Assets/Scripts/Component/TimerComponent.cs new file mode 100644 index 00000000..71fc9cf7 --- /dev/null +++ b/Unity/Assets/Scripts/Component/TimerComponent.cs @@ -0,0 +1,105 @@ +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Model; + +namespace Model +{ + public class Timer + { + public long Id { get; set; } + public long Time { get; set; } + public TaskCompletionSource tcs; + } + + [EntityEvent(EntityEventId.TimerComponent)] + public class TimerComponent: Component, IUpdate + { + private readonly Dictionary timers = new Dictionary(); + + /// + /// key: time, value: timer id + /// + private readonly MultiMap timeId = new MultiMap(); + + private readonly Queue timeoutTimer = new Queue(); + + public void Update() + { + long timeNow = TimeHelper.Now(); + foreach (long time in this.timeId.Keys) + { + if (time > timeNow) + { + break; + } + this.timeoutTimer.Enqueue(time); + } + + while (this.timeoutTimer.Count > 0) + { + long key = this.timeoutTimer.Dequeue(); + long[] timeOutId = this.timeId.GetAll(key); + foreach (long id in timeOutId) + { + Timer timer; + if (!this.timers.TryGetValue(id, out timer)) + { + continue; + } + this.Remove(id); + timer.tcs.SetResult(true); + } + } + } + + private void Remove(long id) + { + Timer timer; + if (!this.timers.TryGetValue(id, out timer)) + { + return; + } + this.timers.Remove(id); + this.timeId.Remove(timer.Time, timer.Id); + } + + public Task WaitTillAsync(long tillTime, CancellationToken cancellationToken) + { + TaskCompletionSource tcs = new TaskCompletionSource(); + Timer timer = new Timer { Id = IdGenerater.GenerateId(), Time = tillTime, tcs = tcs }; + this.timers[timer.Id] = timer; + this.timeId.Add(timer.Time, timer.Id); + cancellationToken.Register(() => { this.Remove(timer.Id); }); + return tcs.Task; + } + + public Task WaitTillAsync(long tillTime) + { + TaskCompletionSource tcs = new TaskCompletionSource(); + Timer timer = new Timer { Id = IdGenerater.GenerateId(), Time = tillTime, tcs = tcs }; + this.timers[timer.Id] = timer; + this.timeId.Add(timer.Time, timer.Id); + return tcs.Task; + } + + public Task WaitAsync(long time, CancellationToken cancellationToken) + { + TaskCompletionSource tcs = new TaskCompletionSource(); + Timer timer = new Timer { Id = IdGenerater.GenerateId(), Time = TimeHelper.Now() + time, tcs = tcs }; + this.timers[timer.Id] = timer; + this.timeId.Add(timer.Time, timer.Id); + cancellationToken.Register(() => { this.Remove(timer.Id); }); + return tcs.Task; + } + + public Task WaitAsync(long time) + { + TaskCompletionSource tcs = new TaskCompletionSource(); + Timer timer = new Timer { Id = IdGenerater.GenerateId(), Time = TimeHelper.Now() + time, tcs = tcs }; + this.timers[timer.Id] = timer; + this.timeId.Add(timer.Time, timer.Id); + return tcs.Task; + } + } +} \ No newline at end of file diff --git a/Unity/Assets/Scripts/Component/TimerComponent.cs.meta b/Unity/Assets/Scripts/Component/TimerComponent.cs.meta new file mode 100644 index 00000000..08464c88 --- /dev/null +++ b/Unity/Assets/Scripts/Component/TimerComponent.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2f4a73ac996f1404aa1866a86140fe38 +timeCreated: 1498117617 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Config.meta b/Unity/Assets/Scripts/Config.meta new file mode 100644 index 00000000..416d9eaa --- /dev/null +++ b/Unity/Assets/Scripts/Config.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: d574f09c5596d2440b51164c43606464 +folderAsset: yes +timeCreated: 1498118203 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Hotfix/Config/ACategory.cs b/Unity/Assets/Scripts/Config/ACategory.cs similarity index 98% rename from Unity/Hotfix/Config/ACategory.cs rename to Unity/Assets/Scripts/Config/ACategory.cs index a54703d8..77287b6d 100644 --- a/Unity/Hotfix/Config/ACategory.cs +++ b/Unity/Assets/Scripts/Config/ACategory.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; -namespace Hotfix +namespace Model { /// /// 管理该所有的配置 diff --git a/Unity/Hotfix/Config/ACategory.cs.meta b/Unity/Assets/Scripts/Config/ACategory.cs.meta similarity index 100% rename from Unity/Hotfix/Config/ACategory.cs.meta rename to Unity/Assets/Scripts/Config/ACategory.cs.meta diff --git a/Unity/Hotfix/Config/AConfig.cs b/Unity/Assets/Scripts/Config/AConfig.cs similarity index 76% rename from Unity/Hotfix/Config/AConfig.cs rename to Unity/Assets/Scripts/Config/AConfig.cs index a72696d2..a3691c5e 100644 --- a/Unity/Hotfix/Config/AConfig.cs +++ b/Unity/Assets/Scripts/Config/AConfig.cs @@ -1,9 +1,9 @@ -namespace Hotfix +namespace Model { /// /// 每个Config的基类 /// - public abstract class AConfig: HotfixEntity + public abstract class AConfig: Entity { protected AConfig(EntityType entityType): base(entityType) { diff --git a/Unity/Hotfix/Config/AConfig.cs.meta b/Unity/Assets/Scripts/Config/AConfig.cs.meta similarity index 100% rename from Unity/Hotfix/Config/AConfig.cs.meta rename to Unity/Assets/Scripts/Config/AConfig.cs.meta diff --git a/Unity/Hotfix/Config/AConfigComponent.cs b/Unity/Assets/Scripts/Config/AConfigComponent.cs similarity index 75% rename from Unity/Hotfix/Config/AConfigComponent.cs rename to Unity/Assets/Scripts/Config/AConfigComponent.cs index fc2fd740..102d00b9 100644 --- a/Unity/Hotfix/Config/AConfigComponent.cs +++ b/Unity/Assets/Scripts/Config/AConfigComponent.cs @@ -1,6 +1,6 @@ using MongoDB.Bson.Serialization.Attributes; -namespace Hotfix +namespace Model { /// /// 每个Config的基类 @@ -8,7 +8,7 @@ namespace Hotfix [BsonKnownTypes(typeof (ClientConfig))] [BsonKnownTypes(typeof (InnerConfig))] [BsonKnownTypes(typeof (OuterConfig))] - public abstract class AConfigComponent: HotfixComponent + public abstract class AConfigComponent: Component { } } \ No newline at end of file diff --git a/Unity/Hotfix/Config/AConfigComponent.cs.meta b/Unity/Assets/Scripts/Config/AConfigComponent.cs.meta similarity index 100% rename from Unity/Hotfix/Config/AConfigComponent.cs.meta rename to Unity/Assets/Scripts/Config/AConfigComponent.cs.meta diff --git a/Unity/Hotfix/Config/ConfigAttribute.cs b/Unity/Assets/Scripts/Config/ConfigAttribute.cs similarity index 92% rename from Unity/Hotfix/Config/ConfigAttribute.cs rename to Unity/Assets/Scripts/Config/ConfigAttribute.cs index 2956dc36..cbfa0bed 100644 --- a/Unity/Hotfix/Config/ConfigAttribute.cs +++ b/Unity/Assets/Scripts/Config/ConfigAttribute.cs @@ -1,6 +1,6 @@ using System; -namespace Hotfix +namespace Model { [AttributeUsage(AttributeTargets.Class)] public class ConfigAttribute: Attribute diff --git a/Unity/Hotfix/Config/ConfigAttribute.cs.meta b/Unity/Assets/Scripts/Config/ConfigAttribute.cs.meta similarity index 100% rename from Unity/Hotfix/Config/ConfigAttribute.cs.meta rename to Unity/Assets/Scripts/Config/ConfigAttribute.cs.meta diff --git a/Unity/Hotfix/Config/ConfigHelper.cs b/Unity/Assets/Scripts/Config/ConfigHelper.cs similarity index 95% rename from Unity/Hotfix/Config/ConfigHelper.cs rename to Unity/Assets/Scripts/Config/ConfigHelper.cs index 097844a5..893c16ff 100644 --- a/Unity/Hotfix/Config/ConfigHelper.cs +++ b/Unity/Assets/Scripts/Config/ConfigHelper.cs @@ -2,7 +2,7 @@ using Model; using UnityEngine; -namespace Hotfix +namespace Model { public static class ConfigHelper { diff --git a/Unity/Hotfix/Config/ConfigHelper.cs.meta b/Unity/Assets/Scripts/Config/ConfigHelper.cs.meta similarity index 100% rename from Unity/Hotfix/Config/ConfigHelper.cs.meta rename to Unity/Assets/Scripts/Config/ConfigHelper.cs.meta diff --git a/Unity/Hotfix/Config/ICategory.cs b/Unity/Assets/Scripts/Config/ICategory.cs similarity index 87% rename from Unity/Hotfix/Config/ICategory.cs rename to Unity/Assets/Scripts/Config/ICategory.cs index d2734942..a745f2f2 100644 --- a/Unity/Hotfix/Config/ICategory.cs +++ b/Unity/Assets/Scripts/Config/ICategory.cs @@ -1,7 +1,7 @@ using System; using System.ComponentModel; -namespace Hotfix +namespace Model { public interface ICategory: ISupportInitialize { diff --git a/Unity/Hotfix/Config/ICategory.cs.meta b/Unity/Assets/Scripts/Config/ICategory.cs.meta similarity index 100% rename from Unity/Hotfix/Config/ICategory.cs.meta rename to Unity/Assets/Scripts/Config/ICategory.cs.meta diff --git a/Unity/Hotfix/DllHelper.cs b/Unity/Assets/Scripts/DllHelper.cs similarity index 98% rename from Unity/Hotfix/DllHelper.cs rename to Unity/Assets/Scripts/DllHelper.cs index 034b1efb..276fac74 100644 --- a/Unity/Hotfix/DllHelper.cs +++ b/Unity/Assets/Scripts/DllHelper.cs @@ -7,7 +7,7 @@ using ILRuntime.CLR.TypeSystem; using Model; using UnityEngine; -namespace Hotfix +namespace Model { public static class DllHelper { diff --git a/Unity/Assets/Scripts/DllHelper.cs.meta b/Unity/Assets/Scripts/DllHelper.cs.meta new file mode 100644 index 00000000..fadf9a55 --- /dev/null +++ b/Unity/Assets/Scripts/DllHelper.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 20fbd2b0398f14a4d89abd01726d5d25 +timeCreated: 1498118075 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Entity.meta b/Unity/Assets/Scripts/Entity.meta new file mode 100644 index 00000000..6e7b608b --- /dev/null +++ b/Unity/Assets/Scripts/Entity.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: d2b1f66f808fc9a4ba043d89e5d982f9 +folderAsset: yes +timeCreated: 1498117616 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Hotfix/Entity/AssetBundleLoaderAsync.cs b/Unity/Assets/Scripts/Entity/AssetBundleLoaderAsync.cs similarity index 92% rename from Unity/Hotfix/Entity/AssetBundleLoaderAsync.cs rename to Unity/Assets/Scripts/Entity/AssetBundleLoaderAsync.cs index 2660f494..3368ef3e 100644 --- a/Unity/Hotfix/Entity/AssetBundleLoaderAsync.cs +++ b/Unity/Assets/Scripts/Entity/AssetBundleLoaderAsync.cs @@ -1,9 +1,9 @@ using System.Threading.Tasks; using UnityEngine; -namespace Hotfix +namespace Model { - public class AssetBundleLoaderAsync : HotfixEntity + public class AssetBundleLoaderAsync : Entity { private AssetBundle assetBundle; diff --git a/Unity/Assets/Scripts/Entity/AssetBundleLoaderAsync.cs.meta b/Unity/Assets/Scripts/Entity/AssetBundleLoaderAsync.cs.meta new file mode 100644 index 00000000..1e37ca41 --- /dev/null +++ b/Unity/Assets/Scripts/Entity/AssetBundleLoaderAsync.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3884a45c24f76244aa0697dcb9d95d15 +timeCreated: 1498117617 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Entity/Config.meta b/Unity/Assets/Scripts/Entity/Config.meta new file mode 100644 index 00000000..6f00f0b2 --- /dev/null +++ b/Unity/Assets/Scripts/Entity/Config.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 1136de56973a671409ed0bf599b1f478 +folderAsset: yes +timeCreated: 1498118075 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Hotfix/Entity/Config/BuffConfig.cs b/Unity/Assets/Scripts/Entity/Config/BuffConfig.cs similarity index 95% rename from Unity/Hotfix/Entity/Config/BuffConfig.cs rename to Unity/Assets/Scripts/Entity/Config/BuffConfig.cs index 3b093dd7..f54cf212 100644 --- a/Unity/Hotfix/Entity/Config/BuffConfig.cs +++ b/Unity/Assets/Scripts/Entity/Config/BuffConfig.cs @@ -1,6 +1,6 @@ using MongoDB.Bson.Serialization.Attributes; -namespace Hotfix +namespace Model { [BsonIgnoreExtraElements] public class BuffConfig: AConfig diff --git a/Unity/Assets/Scripts/Entity/Config/BuffConfig.cs.meta b/Unity/Assets/Scripts/Entity/Config/BuffConfig.cs.meta new file mode 100644 index 00000000..621af5db --- /dev/null +++ b/Unity/Assets/Scripts/Entity/Config/BuffConfig.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 8433bdafcbe56e140b3fe0c93722e0cf +timeCreated: 1498118076 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Hotfix/Entity/Config/StartConfig.cs b/Unity/Assets/Scripts/Entity/Config/StartConfig.cs similarity index 94% rename from Unity/Hotfix/Entity/Config/StartConfig.cs rename to Unity/Assets/Scripts/Entity/Config/StartConfig.cs index ae8b9e60..610d11dc 100644 --- a/Unity/Hotfix/Entity/Config/StartConfig.cs +++ b/Unity/Assets/Scripts/Entity/Config/StartConfig.cs @@ -1,7 +1,7 @@ using MongoDB.Bson; using MongoDB.Bson.Serialization.Attributes; -namespace Hotfix +namespace Model { public class StartConfig: AConfig { diff --git a/Unity/Assets/Scripts/Entity/Config/StartConfig.cs.meta b/Unity/Assets/Scripts/Entity/Config/StartConfig.cs.meta new file mode 100644 index 00000000..2265f473 --- /dev/null +++ b/Unity/Assets/Scripts/Entity/Config/StartConfig.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c181dc38f15288746960812611a7767e +timeCreated: 1498118076 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Entity/Game.cs b/Unity/Assets/Scripts/Entity/Game.cs new file mode 100644 index 00000000..7d7a015e --- /dev/null +++ b/Unity/Assets/Scripts/Entity/Game.cs @@ -0,0 +1,28 @@ +namespace Model +{ + public static class Game + { + private static Scene scene; + + public static Scene Scene + { + get + { + if (scene != null) + { + return scene; + } + scene = new Scene(); + scene.AddComponent(); + scene.AddComponent(); + return scene; + } + } + + public static void Close() + { + scene.Dispose(); + scene = null; + } + } +} \ No newline at end of file diff --git a/Unity/Assets/Scripts/Entity/Game.cs.meta b/Unity/Assets/Scripts/Entity/Game.cs.meta new file mode 100644 index 00000000..ef3e41aa --- /dev/null +++ b/Unity/Assets/Scripts/Entity/Game.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0e531b523752fbc4a837e52d4ba093dc +timeCreated: 1498117616 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Entity/Scene.cs b/Unity/Assets/Scripts/Entity/Scene.cs new file mode 100644 index 00000000..25ed10dd --- /dev/null +++ b/Unity/Assets/Scripts/Entity/Scene.cs @@ -0,0 +1,44 @@ +namespace Model +{ + public enum SceneType + { + Share, + Game, + Login, + Lobby, + Map, + Launcher, + Robot, + BehaviorTreeScene, + RobotClient, + + Realm + } + + public sealed class Scene: Entity + { + public Scene Parent { get; set; } + + public string Name { get; set; } + + public SceneType SceneType { get; private set; } + + public Scene(): base(EntityType.Scene) + { + } + + public Scene(long id): base(id, EntityType.Scene) + { + } + + public override void Dispose() + { + if (this.Id == 0) + { + return; + } + + base.Dispose(); + } + } +} \ No newline at end of file diff --git a/Unity/Assets/Scripts/Entity/Scene.cs.meta b/Unity/Assets/Scripts/Entity/Scene.cs.meta new file mode 100644 index 00000000..20902bef --- /dev/null +++ b/Unity/Assets/Scripts/Entity/Scene.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6a74878a3e383af45bac4995de1e0f53 +timeCreated: 1498117617 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Hotfix/Entity/Session.cs b/Unity/Assets/Scripts/Entity/Session.cs similarity index 98% rename from Unity/Hotfix/Entity/Session.cs rename to Unity/Assets/Scripts/Entity/Session.cs index ad85ba8c..a783e3c0 100644 --- a/Unity/Hotfix/Entity/Session.cs +++ b/Unity/Assets/Scripts/Entity/Session.cs @@ -2,13 +2,12 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using LitJson; using Model; using MongoDB.Bson; -namespace Hotfix +namespace Model { - public sealed class Session : HotfixEntity + public sealed class Session : Entity { private static uint RpcId { get; set; } private readonly NetworkComponent network; diff --git a/Unity/Assets/Scripts/Entity/Session.cs.meta b/Unity/Assets/Scripts/Entity/Session.cs.meta new file mode 100644 index 00000000..d7496d2e --- /dev/null +++ b/Unity/Assets/Scripts/Entity/Session.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 73d149d0c325fa24d91a94843bd520b8 +timeCreated: 1498117617 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Hotfix/Entity/WWWAsync.cs b/Unity/Assets/Scripts/Entity/WWWAsync.cs similarity index 97% rename from Unity/Hotfix/Entity/WWWAsync.cs rename to Unity/Assets/Scripts/Entity/WWWAsync.cs index 37a073f4..bd513545 100644 --- a/Unity/Hotfix/Entity/WWWAsync.cs +++ b/Unity/Assets/Scripts/Entity/WWWAsync.cs @@ -3,10 +3,10 @@ using System.Threading; using System.Threading.Tasks; using UnityEngine; -namespace Hotfix +namespace Model { [EntityEvent(EntityEventId.WWWAsync)] - public class WWWAsync: HotfixEntity + public class WWWAsync: Entity { public WWW www; diff --git a/Unity/Assets/Scripts/Entity/WWWAsync.cs.meta b/Unity/Assets/Scripts/Entity/WWWAsync.cs.meta new file mode 100644 index 00000000..b6cf0dc3 --- /dev/null +++ b/Unity/Assets/Scripts/Entity/WWWAsync.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4d789ae4ba23a73469b228352499a1d0 +timeCreated: 1498117617 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Event.meta b/Unity/Assets/Scripts/Event.meta new file mode 100644 index 00000000..47756cd4 --- /dev/null +++ b/Unity/Assets/Scripts/Event.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: f4a531a7e2c04874fb0e829ae1773978 +folderAsset: yes +timeCreated: 1498117616 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Event/AEventAttribute.cs b/Unity/Assets/Scripts/Event/AEventAttribute.cs new file mode 100644 index 00000000..3634dff9 --- /dev/null +++ b/Unity/Assets/Scripts/Event/AEventAttribute.cs @@ -0,0 +1,15 @@ +using System; + +namespace Model +{ + [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] + public abstract class AEventAttribute: Attribute + { + public int Type { get; private set; } + + protected AEventAttribute(int type) + { + this.Type = type; + } + } +} \ No newline at end of file diff --git a/Unity/Assets/Scripts/Event/AEventAttribute.cs.meta b/Unity/Assets/Scripts/Event/AEventAttribute.cs.meta new file mode 100644 index 00000000..97571ef7 --- /dev/null +++ b/Unity/Assets/Scripts/Event/AEventAttribute.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 288485f014836824b89d9a901bc5dcca +timeCreated: 1477377275 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Event/Env.cs b/Unity/Assets/Scripts/Event/Env.cs new file mode 100644 index 00000000..58bf2b03 --- /dev/null +++ b/Unity/Assets/Scripts/Event/Env.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using MongoDB.Bson.Serialization.Attributes; + +namespace Model +{ + public class Env + { + [BsonElement, BsonIgnoreIfNull] + private Dictionary values = new Dictionary(); + + public object this[EnvKey key] + { + get + { + return this.values[key]; + } + set + { + if (this.values == null) + { + this.values = new Dictionary(); + } + this.values[key] = value; + } + } + + public T Get(EnvKey key) + { + if (this.values == null || !this.values.ContainsKey(key)) + { + return default(T); + } + object value = values[key]; + try + { + return (T) value; + } + catch (InvalidCastException e) + { + throw new Exception($"不能把{value.GetType()}转换为{typeof (T)}", e); + } + } + + public void Set(EnvKey key, object obj) + { + if (this.values == null) + { + this.values = new Dictionary(); + } + this.values[key] = obj; + } + + public bool ContainKey(EnvKey key) + { + if (this.values == null) + { + return false; + } + return this.values.ContainsKey(key); + } + + public void Remove(EnvKey key) + { + if (this.values == null) + { + return; + } + this.values.Remove(key); + if (this.values.Count == 0) + { + this.values = null; + } + } + + public void Add(EnvKey key, object value) + { + if (this.values == null) + { + this.values = new Dictionary(); + } + this.values[key] = value; + } + + public IEnumerator GetEnumerator() + { + return this.values.GetEnumerator(); + } + } +} \ No newline at end of file diff --git a/Unity/Assets/Scripts/Event/Env.cs.meta b/Unity/Assets/Scripts/Event/Env.cs.meta new file mode 100644 index 00000000..f7962611 --- /dev/null +++ b/Unity/Assets/Scripts/Event/Env.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 414e43d5bdd3d75458b86b1cf07ad175 +timeCreated: 1477377275 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Event/EnvKey.cs b/Unity/Assets/Scripts/Event/EnvKey.cs new file mode 100644 index 00000000..3f07d80d --- /dev/null +++ b/Unity/Assets/Scripts/Event/EnvKey.cs @@ -0,0 +1,10 @@ +namespace Model +{ + /// + /// 一般使用事件名+变量名 + /// + public enum EnvKey + { + ChannelError + } +} \ No newline at end of file diff --git a/Unity/Assets/Scripts/Event/EnvKey.cs.meta b/Unity/Assets/Scripts/Event/EnvKey.cs.meta new file mode 100644 index 00000000..dc27aa3e --- /dev/null +++ b/Unity/Assets/Scripts/Event/EnvKey.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c6db3274f6a56f44eaaa14e0f2eecf54 +timeCreated: 1476427109 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Event/EventAttribute.cs b/Unity/Assets/Scripts/Event/EventAttribute.cs new file mode 100644 index 00000000..87f3d085 --- /dev/null +++ b/Unity/Assets/Scripts/Event/EventAttribute.cs @@ -0,0 +1,9 @@ +namespace Model +{ + public class EventAttribute: AEventAttribute + { + public EventAttribute(int type): base(type) + { + } + } +} \ No newline at end of file diff --git a/Unity/Assets/Scripts/Event/EventAttribute.cs.meta b/Unity/Assets/Scripts/Event/EventAttribute.cs.meta new file mode 100644 index 00000000..79c15caa --- /dev/null +++ b/Unity/Assets/Scripts/Event/EventAttribute.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 46c83a3a046e502409ed650e1f3bc238 +timeCreated: 1477377275 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Event/EventIdType.cs b/Unity/Assets/Scripts/Event/EventIdType.cs new file mode 100644 index 00000000..66a2bad1 --- /dev/null +++ b/Unity/Assets/Scripts/Event/EventIdType.cs @@ -0,0 +1,18 @@ +namespace Model +{ + public static class EventIdType + { + public const int InitSceneStart = 1; + + public const int BehaviorTreeRunTreeEvent = 2; + public const int BehaviorTreeOpenEditor = 3; + public const int BehaviorTreeClickNode = 4; + public const int BehaviorTreeAfterChangeNodeType = 5; + public const int BehaviorTreeCreateNode = 6; + public const int BehaviorTreePropertyDesignerNewCreateClick = 7; + public const int BehaviorTreeMouseInNode = 8; + public const int BehaviorTreeConnectState = 9; + public const int BehaviorTreeReplaceClick = 10; + public const int BehaviorTreeRightDesignerDrag = 11; + } +} \ No newline at end of file diff --git a/Unity/Assets/Scripts/Event/EventIdType.cs.meta b/Unity/Assets/Scripts/Event/EventIdType.cs.meta new file mode 100644 index 00000000..34feb383 --- /dev/null +++ b/Unity/Assets/Scripts/Event/EventIdType.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 50aff527fd963e44fbce24e2ef3c1287 +timeCreated: 1476421726 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Event/IEvent.cs b/Unity/Assets/Scripts/Event/IEvent.cs new file mode 100644 index 00000000..fe32f565 --- /dev/null +++ b/Unity/Assets/Scripts/Event/IEvent.cs @@ -0,0 +1,37 @@ +namespace Model +{ + public interface IEvent + { + void Run(); + } + + public interface IEvent + { + void Run(A uid); + } + + public interface IEvent + { + void Run(A a, B b); + } + + public interface IEvent + { + void Run(A a, B b, C c); + } + + public interface IEvent + { + void Run(A a, B b, C c, D d); + } + + public interface IEvent + { + void Run(A a, B b, C c, D d, E e); + } + + public interface IEvent + { + void Run(A a, B b, C c, D d, E e, F f); + } +} \ No newline at end of file diff --git a/Unity/Assets/Scripts/Event/IEvent.cs.meta b/Unity/Assets/Scripts/Event/IEvent.cs.meta new file mode 100644 index 00000000..3f6f2c30 --- /dev/null +++ b/Unity/Assets/Scripts/Event/IEvent.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: dab16cc3acc616f4880a9cd714ba9be0 +timeCreated: 1477377275 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Hotfix/Helper/GameObjectHelper.cs b/Unity/Assets/Scripts/Helper/GameObjectHelper.cs similarity index 95% rename from Unity/Hotfix/Helper/GameObjectHelper.cs rename to Unity/Assets/Scripts/Helper/GameObjectHelper.cs index 4d267e53..e93a8329 100644 --- a/Unity/Hotfix/Helper/GameObjectHelper.cs +++ b/Unity/Assets/Scripts/Helper/GameObjectHelper.cs @@ -1,7 +1,7 @@ using System; using UnityEngine; -namespace Hotfix +namespace Model { public static class GameObjectHelper { diff --git a/Unity/Assets/Scripts/Helper/GameObjectHelper.cs.meta b/Unity/Assets/Scripts/Helper/GameObjectHelper.cs.meta new file mode 100644 index 00000000..99bbfc9b --- /dev/null +++ b/Unity/Assets/Scripts/Helper/GameObjectHelper.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: aae5801bb8dddb648b2347dc09067765 +timeCreated: 1498118314 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Hotfix/Helper/JsonHelper.cs b/Unity/Assets/Scripts/Helper/JsonHelper.cs similarity index 93% rename from Unity/Hotfix/Helper/JsonHelper.cs rename to Unity/Assets/Scripts/Helper/JsonHelper.cs index bc857399..d04f552b 100644 --- a/Unity/Hotfix/Helper/JsonHelper.cs +++ b/Unity/Assets/Scripts/Helper/JsonHelper.cs @@ -1,8 +1,6 @@ using System; -using LitJson; -using Model; -namespace Hotfix +namespace Model { public static class JsonHelper { diff --git a/Unity/Assets/Scripts/Helper/JsonHelper.cs.meta b/Unity/Assets/Scripts/Helper/JsonHelper.cs.meta new file mode 100644 index 00000000..7f637597 --- /dev/null +++ b/Unity/Assets/Scripts/Helper/JsonHelper.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 25b701814ea3740488abe9098cd34040 +timeCreated: 1498118586 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Helper/ResourceHelper.cs b/Unity/Assets/Scripts/Helper/ResourceHelper.cs index c518ad66..9634b409 100644 --- a/Unity/Assets/Scripts/Helper/ResourceHelper.cs +++ b/Unity/Assets/Scripts/Helper/ResourceHelper.cs @@ -5,7 +5,7 @@ namespace Model { public static class ResourceHelper { - public static Object LoadResource(string bundleName, string prefab) + public static UnityEngine.Object LoadResource(string bundleName, string prefab) { string[] realPath = AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(bundleName.ToLower() + ".unity3d", prefab); UnityEngine.Object resource = AssetDatabase.LoadAssetAtPath(realPath[0], typeof(GameObject)); diff --git a/Unity/Assets/Scripts/IL/ILBindingAttribute.cs b/Unity/Assets/Scripts/IL/ILBindingAttribute.cs index bf2c93f9..ed220b74 100644 --- a/Unity/Assets/Scripts/IL/ILBindingAttribute.cs +++ b/Unity/Assets/Scripts/IL/ILBindingAttribute.cs @@ -1,6 +1,6 @@ using System; -namespace Hotfix +namespace Model { [AttributeUsage(AttributeTargets.Class, Inherited = false)] public class ILBindingAttribute : Attribute diff --git a/Unity/Assets/Scripts/Init.cs b/Unity/Assets/Scripts/Init.cs index 75d691b4..cd59408f 100644 --- a/Unity/Assets/Scripts/Init.cs +++ b/Unity/Assets/Scripts/Init.cs @@ -50,6 +50,8 @@ namespace Model private void Update() { + ObjectEvents.Instance.Update(); + this.AppDomain.Invoke(this.update, null, this.param0); } diff --git a/Unity/Assets/Scripts/Message.meta b/Unity/Assets/Scripts/Message.meta new file mode 100644 index 00000000..153edd9f --- /dev/null +++ b/Unity/Assets/Scripts/Message.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 2fafa040b653b9847a9348a31a0233af +folderAsset: yes +timeCreated: 1498117781 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Hotfix/Message/AMHandler.cs b/Unity/Assets/Scripts/Message/AMHandler.cs similarity index 98% rename from Unity/Hotfix/Message/AMHandler.cs rename to Unity/Assets/Scripts/Message/AMHandler.cs index 11ae97a2..e85408d1 100644 --- a/Unity/Hotfix/Message/AMHandler.cs +++ b/Unity/Assets/Scripts/Message/AMHandler.cs @@ -1,7 +1,7 @@ using System; using Model; -namespace Hotfix +namespace Model { public abstract class AMHandler: IMHandler where Message : AMessage { diff --git a/Unity/Hotfix/Message/AMHandler.cs.meta b/Unity/Assets/Scripts/Message/AMHandler.cs.meta similarity index 100% rename from Unity/Hotfix/Message/AMHandler.cs.meta rename to Unity/Assets/Scripts/Message/AMHandler.cs.meta diff --git a/Unity/Hotfix/Message/AMessage.cs b/Unity/Assets/Scripts/Message/AMessage.cs similarity index 93% rename from Unity/Hotfix/Message/AMessage.cs rename to Unity/Assets/Scripts/Message/AMessage.cs index 1ec10d79..ac65ba25 100644 --- a/Unity/Hotfix/Message/AMessage.cs +++ b/Unity/Assets/Scripts/Message/AMessage.cs @@ -1,4 +1,4 @@ -namespace Hotfix +namespace Model { public abstract class AMessage { diff --git a/Unity/Hotfix/Message/AMessage.cs.meta b/Unity/Assets/Scripts/Message/AMessage.cs.meta similarity index 100% rename from Unity/Hotfix/Message/AMessage.cs.meta rename to Unity/Assets/Scripts/Message/AMessage.cs.meta diff --git a/Unity/Hotfix/Message/AppType.cs b/Unity/Assets/Scripts/Message/AppType.cs similarity index 96% rename from Unity/Hotfix/Message/AppType.cs rename to Unity/Assets/Scripts/Message/AppType.cs index da8417ea..274789f6 100644 --- a/Unity/Hotfix/Message/AppType.cs +++ b/Unity/Assets/Scripts/Message/AppType.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace Hotfix +namespace Model { [Flags] public enum AppType diff --git a/Unity/Hotfix/Message/AppType.cs.meta b/Unity/Assets/Scripts/Message/AppType.cs.meta similarity index 100% rename from Unity/Hotfix/Message/AppType.cs.meta rename to Unity/Assets/Scripts/Message/AppType.cs.meta diff --git a/Unity/Hotfix/Message/ErrorCode.cs b/Unity/Assets/Scripts/Message/ErrorCode.cs similarity index 94% rename from Unity/Hotfix/Message/ErrorCode.cs rename to Unity/Assets/Scripts/Message/ErrorCode.cs index bfb31f89..6d5caf3e 100644 --- a/Unity/Hotfix/Message/ErrorCode.cs +++ b/Unity/Assets/Scripts/Message/ErrorCode.cs @@ -1,4 +1,4 @@ -namespace Hotfix +namespace Model { public static class ErrorCode { diff --git a/Unity/Hotfix/Message/ErrorCode.cs.meta b/Unity/Assets/Scripts/Message/ErrorCode.cs.meta similarity index 100% rename from Unity/Hotfix/Message/ErrorCode.cs.meta rename to Unity/Assets/Scripts/Message/ErrorCode.cs.meta diff --git a/Unity/Hotfix/Message/IMHandler.cs b/Unity/Assets/Scripts/Message/IMHandler.cs similarity index 88% rename from Unity/Hotfix/Message/IMHandler.cs rename to Unity/Assets/Scripts/Message/IMHandler.cs index 8a7ae9e9..6dc4b30e 100644 --- a/Unity/Hotfix/Message/IMHandler.cs +++ b/Unity/Assets/Scripts/Message/IMHandler.cs @@ -1,6 +1,6 @@ using System; -namespace Hotfix +namespace Model { public interface IMHandler { diff --git a/Unity/Hotfix/Message/IMHandler.cs.meta b/Unity/Assets/Scripts/Message/IMHandler.cs.meta similarity index 100% rename from Unity/Hotfix/Message/IMHandler.cs.meta rename to Unity/Assets/Scripts/Message/IMHandler.cs.meta diff --git a/Unity/Hotfix/Message/MessageAttribute.cs b/Unity/Assets/Scripts/Message/MessageAttribute.cs similarity index 91% rename from Unity/Hotfix/Message/MessageAttribute.cs rename to Unity/Assets/Scripts/Message/MessageAttribute.cs index 95d5a832..0e80ee5a 100644 --- a/Unity/Hotfix/Message/MessageAttribute.cs +++ b/Unity/Assets/Scripts/Message/MessageAttribute.cs @@ -1,6 +1,6 @@ using System; -namespace Hotfix +namespace Model { public class MessageAttribute: Attribute { diff --git a/Unity/Hotfix/Message/MessageAttribute.cs.meta b/Unity/Assets/Scripts/Message/MessageAttribute.cs.meta similarity index 100% rename from Unity/Hotfix/Message/MessageAttribute.cs.meta rename to Unity/Assets/Scripts/Message/MessageAttribute.cs.meta diff --git a/Unity/Hotfix/Message/MessageHandlerAttribute.cs b/Unity/Assets/Scripts/Message/MessageHandlerAttribute.cs similarity index 93% rename from Unity/Hotfix/Message/MessageHandlerAttribute.cs rename to Unity/Assets/Scripts/Message/MessageHandlerAttribute.cs index a374b9bf..ea4d5760 100644 --- a/Unity/Hotfix/Message/MessageHandlerAttribute.cs +++ b/Unity/Assets/Scripts/Message/MessageHandlerAttribute.cs @@ -1,6 +1,6 @@ using System; -namespace Hotfix +namespace Model { /// /// 搭配MessageComponent用来分发消息 diff --git a/Unity/Hotfix/Message/MessageHandlerAttribute.cs.meta b/Unity/Assets/Scripts/Message/MessageHandlerAttribute.cs.meta similarity index 100% rename from Unity/Hotfix/Message/MessageHandlerAttribute.cs.meta rename to Unity/Assets/Scripts/Message/MessageHandlerAttribute.cs.meta diff --git a/Unity/Hotfix/Message/MessageInfo.cs b/Unity/Assets/Scripts/Message/MessageInfo.cs similarity index 96% rename from Unity/Hotfix/Message/MessageInfo.cs rename to Unity/Assets/Scripts/Message/MessageInfo.cs index 11271403..9fe4b234 100644 --- a/Unity/Hotfix/Message/MessageInfo.cs +++ b/Unity/Assets/Scripts/Message/MessageInfo.cs @@ -1,4 +1,4 @@ -namespace Hotfix +namespace Model { public class MessageInfo { diff --git a/Unity/Hotfix/Message/MessageInfo.cs.meta b/Unity/Assets/Scripts/Message/MessageInfo.cs.meta similarity index 100% rename from Unity/Hotfix/Message/MessageInfo.cs.meta rename to Unity/Assets/Scripts/Message/MessageInfo.cs.meta diff --git a/Unity/Hotfix/Message/OpcodeHelper.cs b/Unity/Assets/Scripts/Message/OpcodeHelper.cs similarity index 95% rename from Unity/Hotfix/Message/OpcodeHelper.cs rename to Unity/Assets/Scripts/Message/OpcodeHelper.cs index 4843a747..0776c680 100644 --- a/Unity/Hotfix/Message/OpcodeHelper.cs +++ b/Unity/Assets/Scripts/Message/OpcodeHelper.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace Hotfix +namespace Model { public static class OpcodeHelper { diff --git a/Unity/Hotfix/Message/OpcodeHelper.cs.meta b/Unity/Assets/Scripts/Message/OpcodeHelper.cs.meta similarity index 100% rename from Unity/Hotfix/Message/OpcodeHelper.cs.meta rename to Unity/Assets/Scripts/Message/OpcodeHelper.cs.meta diff --git a/Unity/Hotfix/Message/RpcException.cs b/Unity/Assets/Scripts/Message/RpcException.cs similarity index 96% rename from Unity/Hotfix/Message/RpcException.cs rename to Unity/Assets/Scripts/Message/RpcException.cs index b7707ce0..eea5f7cc 100644 --- a/Unity/Hotfix/Message/RpcException.cs +++ b/Unity/Assets/Scripts/Message/RpcException.cs @@ -1,6 +1,6 @@ using System; -namespace Hotfix +namespace Model { /// /// RPC异常,带ErrorCode diff --git a/Unity/Hotfix/Message/RpcException.cs.meta b/Unity/Assets/Scripts/Message/RpcException.cs.meta similarity index 100% rename from Unity/Hotfix/Message/RpcException.cs.meta rename to Unity/Assets/Scripts/Message/RpcException.cs.meta diff --git a/Unity/Assets/Scripts/Object.meta b/Unity/Assets/Scripts/Object.meta new file mode 100644 index 00000000..9b9bbae7 --- /dev/null +++ b/Unity/Assets/Scripts/Object.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 600c9bb417aba1641897df52e4ea0eeb +folderAsset: yes +timeCreated: 1498116852 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Object/Component.cs b/Unity/Assets/Scripts/Object/Component.cs new file mode 100644 index 00000000..ca4c5432 --- /dev/null +++ b/Unity/Assets/Scripts/Object/Component.cs @@ -0,0 +1,40 @@ +using MongoDB.Bson.Serialization.Attributes; + +namespace Model +{ + public abstract class Component: Disposer + { + [BsonIgnore] + public Entity Owner { get; set; } + + public T GetOwner() where T : Entity + { + return this.Owner as T; + } + + protected Component() + { + } + + protected Component(long id): base(id) + { + } + + public T GetComponent() where T : Component + { + return this.Owner.GetComponent(); + } + + public override void Dispose() + { + if (this.Id == 0) + { + return; + } + + base.Dispose(); + + this.Owner.RemoveComponent(this.GetType()); + } + } +} \ No newline at end of file diff --git a/Unity/Assets/Scripts/Object/Component.cs.meta b/Unity/Assets/Scripts/Object/Component.cs.meta new file mode 100644 index 00000000..dde966cf --- /dev/null +++ b/Unity/Assets/Scripts/Object/Component.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 596cc447d1a588e47b6105622727b588 +timeCreated: 1498116852 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Object/Disposer.cs b/Unity/Assets/Scripts/Object/Disposer.cs new file mode 100644 index 00000000..36dc4c68 --- /dev/null +++ b/Unity/Assets/Scripts/Object/Disposer.cs @@ -0,0 +1,21 @@ +namespace Model +{ + public abstract class Disposer: Object + { + protected Disposer(): base(IdGenerater.GenerateId()) + { + ObjectEvents.Instance.Add(this); + } + + protected Disposer(long id): base(id) + { + ObjectEvents.Instance.Add(this); + } + + public override void Dispose() + { + this.Id = 0; + ObjectEvents.Instance.Remove(this); + } + } +} \ No newline at end of file diff --git a/Unity/Assets/Scripts/Object/Disposer.cs.meta b/Unity/Assets/Scripts/Object/Disposer.cs.meta new file mode 100644 index 00000000..ca9e5ecb --- /dev/null +++ b/Unity/Assets/Scripts/Object/Disposer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 785b1815942ba374b9cea238401cd506 +timeCreated: 1498116853 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Object/Entity.cs b/Unity/Assets/Scripts/Object/Entity.cs new file mode 100644 index 00000000..5eb2bf9e --- /dev/null +++ b/Unity/Assets/Scripts/Object/Entity.cs @@ -0,0 +1,186 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Model +{ + public class Entity: Disposer + { + public EntityType Type { get; set; } + + private HashSet components = new HashSet(); + + private readonly Dictionary componentDict = new Dictionary(); + + protected Entity() + { + this.Type = EntityType.None; + } + + protected Entity(EntityType entityType) + { + this.Type = entityType; + } + + protected Entity(long id, EntityType entityType): base(id) + { + this.Type = entityType; + } + + public override void Dispose() + { + if (this.Id == 0) + { + return; + } + + base.Dispose(); + + foreach (Component component in this.GetComponents()) + { + try + { + component.Dispose(); + } + catch (Exception e) + { + Log.Error(e.ToString()); + } + } + } + + public K AddComponent() where K : Component, new() + { + K component = (K) Activator.CreateInstance(typeof (K)); + component.Owner = this; + if (this.componentDict.ContainsKey(component.GetType())) + { + throw new Exception($"AddComponent, component already exist, id: {this.Id}, component: {typeof (K).Name}"); + } + if (this.components == null) + { + this.components = new HashSet(); + } + this.components.Add(component); + this.componentDict.Add(component.GetType(), component); + IAwake awake = component as IAwake; + awake?.Awake(); + return component; + } + + public K AddComponent(P1 p1) where K : Component, new() + { + K component = (K) Activator.CreateInstance(typeof (K)); + component.Owner = this; + + if (this.componentDict.ContainsKey(component.GetType())) + { + throw new Exception($"AddComponent, component already exist, id: {this.Id}, component: {typeof (K).Name}"); + } + + if (this.components == null) + { + this.components = new HashSet(); + } + + this.components.Add(component); + this.componentDict.Add(component.GetType(), component); + IAwake awake = component as IAwake; + awake?.Awake(p1); + return component; + } + + public K AddComponent(P1 p1, P2 p2) where K : Component, new() + { + K component = (K) Activator.CreateInstance(typeof (K)); + component.Owner = this; + + if (this.componentDict.ContainsKey(component.GetType())) + { + throw new Exception($"AddComponent, component already exist, id: {this.Id}, component: {typeof (K).Name}"); + } + + if (this.components == null) + { + this.components = new HashSet(); + } + + this.components.Add(component); + this.componentDict.Add(component.GetType(), component); + IAwake awake = component as IAwake; + awake?.Awake(p1, p2); + return component; + } + + public K AddComponent(P1 p1, P2 p2, P3 p3) where K : Component, new() + { + K component = (K) Activator.CreateInstance(typeof (K)); + component.Owner = this; + + if (this.componentDict.ContainsKey(component.GetType())) + { + throw new Exception($"AddComponent, component already exist, id: {this.Id}, component: {typeof (K).Name}"); + } + + if (this.components == null) + { + this.components = new HashSet(); + } + + this.components.Add(component); + this.componentDict.Add(component.GetType(), component); + IAwake awake = component as IAwake; + awake?.Awake(p1, p2, p3); + return component; + } + + public void RemoveComponent() where K : Component + { + Component component; + if (!this.componentDict.TryGetValue(typeof (K), out component)) + { + return; + } + + this.components.Remove(component); + this.componentDict.Remove(typeof (K)); + if (this.components.Count == 0) + { + this.components = null; + } + component.Dispose(); + } + + public void RemoveComponent(Type type) + { + Component component; + if (!this.componentDict.TryGetValue(type, out component)) + { + return; + } + + this.components.Remove(component); + this.componentDict.Remove(type); + if (this.components.Count == 0) + { + this.components = null; + } + component.Dispose(); + } + + public K GetComponent() where K : Component + { + Component component; + if (!this.componentDict.TryGetValue(typeof (K), out component)) + { + return default(K); + } + return (K) component; + } + + public Component[] GetComponents() + { + return components.ToArray(); + } + } +} \ No newline at end of file diff --git a/Unity/Assets/Scripts/Object/Entity.cs.meta b/Unity/Assets/Scripts/Object/Entity.cs.meta new file mode 100644 index 00000000..8b700159 --- /dev/null +++ b/Unity/Assets/Scripts/Object/Entity.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5bb5f664ee9566b40a7fad24bab21d2f +timeCreated: 1498116852 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Hotfix/Object/EntityEventAttribute.cs b/Unity/Assets/Scripts/Object/EntityEventAttribute.cs similarity index 93% rename from Unity/Hotfix/Object/EntityEventAttribute.cs rename to Unity/Assets/Scripts/Object/EntityEventAttribute.cs index b32928c3..47befe73 100644 --- a/Unity/Hotfix/Object/EntityEventAttribute.cs +++ b/Unity/Assets/Scripts/Object/EntityEventAttribute.cs @@ -1,6 +1,6 @@ using System; -namespace Hotfix +namespace Model { [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] public class EntityEventAttribute: Attribute diff --git a/Unity/Assets/Scripts/Object/EntityEventAttribute.cs.meta b/Unity/Assets/Scripts/Object/EntityEventAttribute.cs.meta new file mode 100644 index 00000000..77611b23 --- /dev/null +++ b/Unity/Assets/Scripts/Object/EntityEventAttribute.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: eb0dcb40ecd1ec948b3eb4720cfa739f +timeCreated: 1498116853 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Object/EntityEventId.cs b/Unity/Assets/Scripts/Object/EntityEventId.cs new file mode 100644 index 00000000..74b963e0 --- /dev/null +++ b/Unity/Assets/Scripts/Object/EntityEventId.cs @@ -0,0 +1,30 @@ +namespace Model +{ + public static class EntityEventId + { + public const int TimerComponent = 1; + public const int ClientConfigComponent = 2; + public const int EventComponent = 3; + public const int GameObjectComponent = 4; + public const int ILEventComponent = 5; + public const int MessageDispatherComponent = 6; + public const int NetInnerComponent = 7; + public const int NetOuterComponent = 8; + public const int RobotComponent = 9; + public const int UIComponent = 10; + public const int WWWAsync = 11; + public const int ILRuntimeComponent = 12; + public const int ResourcesComponent = 13; + public const int UnitComponent = 14; + + public const int AppManagerComponent = 15; + public const int GateSessionKeyComponent = 16; + public const int OptionComponent = 17; + public const int StartConfigComponent = 18; + public const int LockComponent = 19; + public const int MasterComponent = 20; + public const int RealmGateAddressComponent = 21; + public const int UILobbyComponent = 22; + public const int BehaviorTreeComponent = 23; + } +} diff --git a/Unity/Assets/Scripts/Object/EntityEventId.cs.meta b/Unity/Assets/Scripts/Object/EntityEventId.cs.meta new file mode 100644 index 00000000..4f0eadee --- /dev/null +++ b/Unity/Assets/Scripts/Object/EntityEventId.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5899ef72e43a3354dbda95717ae3d73a +timeCreated: 1498117617 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Object/EntityType.cs b/Unity/Assets/Scripts/Object/EntityType.cs new file mode 100644 index 00000000..b8c26cab --- /dev/null +++ b/Unity/Assets/Scripts/Object/EntityType.cs @@ -0,0 +1,12 @@ +namespace Model +{ + public enum EntityType + { + None, + Scene, + Session, + UI, + Config, + Unit + } +} \ No newline at end of file diff --git a/Unity/Assets/Scripts/Object/EntityType.cs.meta b/Unity/Assets/Scripts/Object/EntityType.cs.meta new file mode 100644 index 00000000..ba9fb997 --- /dev/null +++ b/Unity/Assets/Scripts/Object/EntityType.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a8f6aec364235394fa87b26ff5b476cf +timeCreated: 1498116853 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Object/IAwake.cs b/Unity/Assets/Scripts/Object/IAwake.cs new file mode 100644 index 00000000..572e09da --- /dev/null +++ b/Unity/Assets/Scripts/Object/IAwake.cs @@ -0,0 +1,22 @@ +namespace Model +{ + public interface IAwake + { + void Awake(); + } + + public interface IAwake + { + void Awake(A a); + } + + public interface IAwake + { + void Awake(A a, B b); + } + + public interface IAwake + { + void Awake(A a, B b, C c); + } +} diff --git a/Unity/Assets/Scripts/Object/IAwake.cs.meta b/Unity/Assets/Scripts/Object/IAwake.cs.meta new file mode 100644 index 00000000..c2c71c1b --- /dev/null +++ b/Unity/Assets/Scripts/Object/IAwake.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a7feda966d039a549bdc1e2a1642ebe3 +timeCreated: 1498116853 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Object/ILoad.cs b/Unity/Assets/Scripts/Object/ILoad.cs new file mode 100644 index 00000000..9d28347a --- /dev/null +++ b/Unity/Assets/Scripts/Object/ILoad.cs @@ -0,0 +1,7 @@ +namespace Model +{ + public interface ILoad + { + void Load(); + } +} diff --git a/Unity/Assets/Scripts/Object/ILoad.cs.meta b/Unity/Assets/Scripts/Object/ILoad.cs.meta new file mode 100644 index 00000000..285fe9e3 --- /dev/null +++ b/Unity/Assets/Scripts/Object/ILoad.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3d3f1fc44e847304b8be1451226eefc0 +timeCreated: 1498116852 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Object/IUpdate.cs b/Unity/Assets/Scripts/Object/IUpdate.cs new file mode 100644 index 00000000..36a96acd --- /dev/null +++ b/Unity/Assets/Scripts/Object/IUpdate.cs @@ -0,0 +1,7 @@ +namespace Model +{ + public interface IUpdate + { + void Update(); + } +} diff --git a/Unity/Assets/Scripts/Object/IUpdate.cs.meta b/Unity/Assets/Scripts/Object/IUpdate.cs.meta new file mode 100644 index 00000000..783d1b78 --- /dev/null +++ b/Unity/Assets/Scripts/Object/IUpdate.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 05d4c34d4c555654292fef8368e97322 +timeCreated: 1498116852 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Object/Object.cs b/Unity/Assets/Scripts/Object/Object.cs new file mode 100644 index 00000000..6986cd3b --- /dev/null +++ b/Unity/Assets/Scripts/Object/Object.cs @@ -0,0 +1,23 @@ +using System; + +namespace Model +{ + public abstract class Object: IDisposable + { + public long Id { get; protected set; } + + protected Object() + { + Id = IdGenerater.GenerateId(); + } + + protected Object(long id) + { + this.Id = id; + } + + public virtual void Dispose() + { + } + } +} \ No newline at end of file diff --git a/Unity/Assets/Scripts/Object/Object.cs.meta b/Unity/Assets/Scripts/Object/Object.cs.meta new file mode 100644 index 00000000..7f403a45 --- /dev/null +++ b/Unity/Assets/Scripts/Object/Object.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 75b4e4c782482aa4d87675b28e60ca49 +timeCreated: 1498116853 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Object/ObjectEventAttribute.cs b/Unity/Assets/Scripts/Object/ObjectEventAttribute.cs new file mode 100644 index 00000000..5ad4810e --- /dev/null +++ b/Unity/Assets/Scripts/Object/ObjectEventAttribute.cs @@ -0,0 +1,15 @@ +using System; + +namespace Model +{ + [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] + public class ObjectEventAttribute: Attribute + { + public int ClassType; + + public ObjectEventAttribute(int classType) + { + this.ClassType = classType; + } + } +} \ No newline at end of file diff --git a/Unity/Assets/Scripts/Object/ObjectEventAttribute.cs.meta b/Unity/Assets/Scripts/Object/ObjectEventAttribute.cs.meta new file mode 100644 index 00000000..40062bf1 --- /dev/null +++ b/Unity/Assets/Scripts/Object/ObjectEventAttribute.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c4c9985e05d1b164582c7a2321c43800 +timeCreated: 1498117841 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Object/ObjectEvents.cs b/Unity/Assets/Scripts/Object/ObjectEvents.cs new file mode 100644 index 00000000..79df6bef --- /dev/null +++ b/Unity/Assets/Scripts/Object/ObjectEvents.cs @@ -0,0 +1,98 @@ +using System.Collections.Generic; + +namespace Model +{ + public sealed class ObjectEvents + { + private static ObjectEvents instance; + + public Queue adds = new Queue(); + public Queue removes = new Queue(); + + public HashSet updates = new HashSet(); + public HashSet loads = new HashSet(); + + public static ObjectEvents Instance + { + get + { + return instance ?? (instance = new ObjectEvents()); + } + } + + public void Add(Disposer disposer) + { + adds.Enqueue(disposer); + } + + public void Remove(Disposer disposer) + { + removes.Enqueue(disposer); + } + + public void Update() + { + while(adds.Count > 0) + { + Disposer disposer = adds.Dequeue(); + + IUpdate update = disposer as IUpdate; + if (update == null) + { + continue; + } + updates.Add(update); + + ILoad load = disposer as ILoad; + if (load == null) + { + continue; + } + loads.Add(load); + } + + while (removes.Count > 0) + { + Disposer disposer = removes.Dequeue(); + + IUpdate update = disposer as IUpdate; + if (update == null) + { + continue; + } + updates.Remove(update); + + ILoad load = disposer as ILoad; + if (load == null) + { + continue; + } + loads.Remove(load); + } + + + foreach(IUpdate update in updates) + { + Disposer disposer = (Disposer)update; + if (removes.Contains(disposer)) + { + continue; + } + update.Update(); + } + } + + public void Load() + { + foreach (ILoad load in loads) + { + Disposer disposer = (Disposer)load; + if (removes.Contains(disposer)) + { + continue; + } + load.Load(); + } + } + } +} \ No newline at end of file diff --git a/Unity/Assets/Scripts/Object/ObjectEvents.cs.meta b/Unity/Assets/Scripts/Object/ObjectEvents.cs.meta new file mode 100644 index 00000000..ace0d490 --- /dev/null +++ b/Unity/Assets/Scripts/Object/ObjectEvents.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9053a11c1bcabe04d8a2b53044ae0682 +timeCreated: 1498116853 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Hotfix/Component/BenchmarkComponent.cs b/Unity/Hotfix/Component/BenchmarkComponent.cs deleted file mode 100644 index 5e0ea8ac..00000000 --- a/Unity/Hotfix/Component/BenchmarkComponent.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System; -using Model; - -namespace Hotfix -{ - public class BenchmarkComponent: HotfixComponent - { - private int k; - - private long time1 = TimeHelper.ClientNow(); - - private async void Awake(string address) - { - try - { - NetOuterComponent networkComponent = Hotfix.Scene.GetComponent(); - - for (int i = 0; i < 100; i++) - { - await Hotfix.Scene.GetComponent().WaitAsync(10); - this.TestAsync(networkComponent, address, i); - } - } - catch (Exception e) - { - Log.Error(e.ToString()); - } - } - - public async void TestAsync(NetOuterComponent networkComponent, string address, int j) - { - Session session = null; - try - { - session = networkComponent.Create(address); - int i = 0; - while (i < 10000000) - { - ++i; - await session.Call(new C2R_Ping()); - - ++this.k; - - if (this.k % 100000 != 0) - { - continue; - } - - long time2 = TimeHelper.ClientNow(); - long time = time2 - this.time1; - this.time1 = time2; - Log.Info($"{j} Benchmark k: {this.k} 每10W次耗时: {time} ms"); - } - } - catch (RpcException e) - { - Log.Error(e.ToString()); - } - catch (Exception e) - { - Log.Error(e.ToString()); - } - finally - { - session.Dispose(); - } - } - - public override void Dispose() - { - if (this.Id == 0) - { - return; - } - - base.Dispose(); - } - } -} \ No newline at end of file diff --git a/Unity/Hotfix/Component/ConfigComponent.cs b/Unity/Hotfix/Component/ConfigComponent.cs index 7b3f096a..3413c29a 100644 --- a/Unity/Hotfix/Component/ConfigComponent.cs +++ b/Unity/Hotfix/Component/ConfigComponent.cs @@ -1,9 +1,10 @@ using System; using System.Collections.Generic; +using Model; namespace Hotfix { - public class ConfigComponent: HotfixComponent + public class ConfigComponent: Component { private Dictionary allConfig; diff --git a/Unity/Hotfix/Component/EventComponent.cs b/Unity/Hotfix/Component/EventComponent.cs index 21ee1ee8..6e4e8fce 100644 --- a/Unity/Hotfix/Component/EventComponent.cs +++ b/Unity/Hotfix/Component/EventComponent.cs @@ -4,8 +4,8 @@ using Model; namespace Hotfix { - [EntityEvent(EntityEventId.EventComponent)] - public class EventComponent : HotfixComponent, IAwake + [ObjectEvent(EntityEventId.EventComponent)] + public class EventComponent : Component, IAwake { private Dictionary> allEvents; diff --git a/Unity/Hotfix/Component/GameObjectComponent.cs b/Unity/Hotfix/Component/GameObjectComponent.cs index 925a23bc..5d918d67 100644 --- a/Unity/Hotfix/Component/GameObjectComponent.cs +++ b/Unity/Hotfix/Component/GameObjectComponent.cs @@ -2,8 +2,8 @@ namespace Hotfix { - [EntityEvent(EntityEventId.GameObjectComponent)] - public class GameObjectComponent: HotfixComponent + [ObjectEvent(EntityEventId.GameObjectComponent)] + public class GameObjectComponent: Component { public GameObject GameObject { get; private set; } diff --git a/Unity/Hotfix/Component/KVComponent.cs b/Unity/Hotfix/Component/KVComponent.cs index bdce8630..aa5aaaf1 100644 --- a/Unity/Hotfix/Component/KVComponent.cs +++ b/Unity/Hotfix/Component/KVComponent.cs @@ -6,7 +6,7 @@ namespace Hotfix /// /// Key Value组件用于保存一些数据 /// - public class KVComponent: HotfixComponent + public class KVComponent: Component { [BsonElement] private readonly Dictionary kv = new Dictionary(); diff --git a/Unity/Hotfix/Component/ResourcesComponent.cs b/Unity/Hotfix/Component/ResourcesComponent.cs index c1a46359..e3304d16 100644 --- a/Unity/Hotfix/Component/ResourcesComponent.cs +++ b/Unity/Hotfix/Component/ResourcesComponent.cs @@ -6,8 +6,8 @@ using UnityEngine; namespace Hotfix { - [EntityEvent(EntityEventId.ResourcesComponent)] - public class ResourcesComponent: HotfixComponent + [ObjectEvent(EntityEventId.ResourcesComponent)] + public class ResourcesComponent: Component { public static AssetBundleManifest AssetBundleManifestObject { get; set; } diff --git a/Unity/Hotfix/Component/RobotComponent.cs b/Unity/Hotfix/Component/RobotComponent.cs index 97d4ed13..5265d8ee 100644 --- a/Unity/Hotfix/Component/RobotComponent.cs +++ b/Unity/Hotfix/Component/RobotComponent.cs @@ -1,7 +1,7 @@ namespace Hotfix { - [EntityEvent(EntityEventId.RobotComponent)] - public class RobotComponent: HotfixComponent + [ObjectEvent(EntityEventId.RobotComponent)] + public class RobotComponent: Component { public override void Dispose() { diff --git a/Unity/Hotfix/Component/TimeComponent.cs b/Unity/Hotfix/Component/TimeComponent.cs index 0126ee44..36ccc333 100644 --- a/Unity/Hotfix/Component/TimeComponent.cs +++ b/Unity/Hotfix/Component/TimeComponent.cs @@ -5,7 +5,7 @@ namespace Hotfix /// /// 用于同步服务端和客户端时间 /// - public class TimeComponent: HotfixComponent + public class TimeComponent: Component { private long syncTime; diff --git a/Unity/Hotfix/Component/TimerComponent.cs b/Unity/Hotfix/Component/TimerComponent.cs index 4cd0c77e..8bdd586e 100644 --- a/Unity/Hotfix/Component/TimerComponent.cs +++ b/Unity/Hotfix/Component/TimerComponent.cs @@ -12,8 +12,8 @@ namespace Hotfix public TaskCompletionSource tcs; } - [EntityEvent(EntityEventId.TimerComponent)] - public class TimerComponent: HotfixComponent, IUpdate + [ObjectEvent(EntityEventId.TimerComponent)] + public class TimerComponent: Component, IUpdate { private readonly Dictionary timers = new Dictionary(); diff --git a/Unity/Hotfix/Component/UIComponent.cs b/Unity/Hotfix/Component/UIComponent.cs index 8facb057..0be2ec38 100644 --- a/Unity/Hotfix/Component/UIComponent.cs +++ b/Unity/Hotfix/Component/UIComponent.cs @@ -30,8 +30,8 @@ namespace Hotfix /// /// 管理所有UI /// - [EntityEvent(EntityEventId.UIComponent)] - public class UIComponent: HotfixComponent, IAwake, ILoad + [ObjectEvent(EntityEventId.UIComponent)] + public class UIComponent: Component, IAwake, ILoad { private UI Root; private Dictionary UiTypes; diff --git a/Unity/Hotfix/Component/UnitComponent.cs b/Unity/Hotfix/Component/UnitComponent.cs index ebf2fe17..a885fd89 100644 --- a/Unity/Hotfix/Component/UnitComponent.cs +++ b/Unity/Hotfix/Component/UnitComponent.cs @@ -2,8 +2,8 @@ namespace Hotfix { - [EntityEvent(EntityEventId.UnitComponent)] - public class UnitComponent: HotfixComponent + [ObjectEvent(EntityEventId.UnitComponent)] + public class UnitComponent: Component { private readonly Dictionary idUnits = new Dictionary(); diff --git a/Unity/Hotfix/Entity/Scene.cs b/Unity/Hotfix/Entity/Scene.cs index 01695aba..33fb5d68 100644 --- a/Unity/Hotfix/Entity/Scene.cs +++ b/Unity/Hotfix/Entity/Scene.cs @@ -15,7 +15,7 @@ Realm } - public sealed class Scene: HotfixEntity + public sealed class Scene: Entity { public Scene Parent { get; set; } diff --git a/Unity/Hotfix/Entity/UI.cs b/Unity/Hotfix/Entity/UI.cs index 10cc9168..068a1f94 100644 --- a/Unity/Hotfix/Entity/UI.cs +++ b/Unity/Hotfix/Entity/UI.cs @@ -3,7 +3,7 @@ using UnityEngine; namespace Hotfix { - public sealed class UI: HotfixEntity + public sealed class UI: Entity { public Scene Scene { get; set; } diff --git a/Unity/Hotfix/Entity/Unit.cs b/Unity/Hotfix/Entity/Unit.cs index 28c63cec..b5b353da 100644 --- a/Unity/Hotfix/Entity/Unit.cs +++ b/Unity/Hotfix/Entity/Unit.cs @@ -6,7 +6,7 @@ Npc } - public sealed class Unit: HotfixEntity + public sealed class Unit: Entity { public UnitType UnitType { get; } diff --git a/Unity/Hotfix/HotfixInit.cs b/Unity/Hotfix/HotfixInit.cs index da8f8311..c8d922cc 100644 --- a/Unity/Hotfix/HotfixInit.cs +++ b/Unity/Hotfix/HotfixInit.cs @@ -12,8 +12,6 @@ namespace Hotfix Hotfix.Scene.AddComponent(); Hotfix.Scene.AddComponent(); Hotfix.Scene.AddComponent(); - Hotfix.Scene.AddComponent(AppType.Client); - Hotfix.Scene.AddComponent(); Hotfix.Scene.GetComponent().Run(EventIdType.InitSceneStart); } catch (Exception e) diff --git a/Unity/Hotfix/Object/HotfixComponent.cs b/Unity/Hotfix/Object/Component.cs similarity index 52% rename from Unity/Hotfix/Object/HotfixComponent.cs rename to Unity/Hotfix/Object/Component.cs index 0d2b3149..a66fdf40 100644 --- a/Unity/Hotfix/Object/HotfixComponent.cs +++ b/Unity/Hotfix/Object/Component.cs @@ -2,26 +2,25 @@ namespace Hotfix { - [BsonKnownTypes(typeof (AConfigComponent))] - public abstract class HotfixComponent: Disposer + public abstract class Component: Disposer { [BsonIgnore] - public HotfixEntity Owner { get; set; } + public Entity Owner { get; set; } - public T GetOwner() where T : HotfixEntity + public T GetOwner() where T : Entity { return this.Owner as T; } - protected HotfixComponent() + protected Component() { } - protected HotfixComponent(long id): base(id) + protected Component(long id): base(id) { } - public T GetComponent() where T : HotfixComponent + public T GetComponent() where T : Component { return this.Owner.GetComponent(); } diff --git a/Unity/Hotfix/Object/HotfixEntity.cs b/Unity/Hotfix/Object/Entity.cs similarity index 74% rename from Unity/Hotfix/Object/HotfixEntity.cs rename to Unity/Hotfix/Object/Entity.cs index a6fd2e29..c7746884 100644 --- a/Unity/Hotfix/Object/HotfixEntity.cs +++ b/Unity/Hotfix/Object/Entity.cs @@ -5,25 +5,25 @@ using Model; namespace Hotfix { - public class HotfixEntity: Disposer + public class Entity: Disposer { public EntityType Type { get; set; } - private HashSet components = new HashSet(); + private HashSet components = new HashSet(); - private readonly Dictionary componentDict = new Dictionary(); + private readonly Dictionary componentDict = new Dictionary(); - protected HotfixEntity() + protected Entity() { this.Type = EntityType.None; } - protected HotfixEntity(EntityType entityType) + protected Entity(EntityType entityType) { this.Type = entityType; } - protected HotfixEntity(long id, EntityType entityType): base(id) + protected Entity(long id, EntityType entityType): base(id) { this.Type = entityType; } @@ -37,7 +37,7 @@ namespace Hotfix base.Dispose(); - foreach (HotfixComponent component in this.GetComponents()) + foreach (Component component in this.GetComponents()) { try { @@ -50,7 +50,7 @@ namespace Hotfix } } - public K AddComponent() where K : HotfixComponent, new() + public K AddComponent() where K : Component, new() { K component = (K) Activator.CreateInstance(typeof (K)); component.Owner = this; @@ -60,7 +60,7 @@ namespace Hotfix } if (this.components == null) { - this.components = new HashSet(); + this.components = new HashSet(); } this.components.Add(component); this.componentDict.Add(component.GetType(), component); @@ -69,7 +69,7 @@ namespace Hotfix return component; } - public K AddComponent(P1 p1) where K : HotfixComponent, new() + public K AddComponent(P1 p1) where K : Component, new() { K component = (K) Activator.CreateInstance(typeof (K)); component.Owner = this; @@ -81,7 +81,7 @@ namespace Hotfix if (this.components == null) { - this.components = new HashSet(); + this.components = new HashSet(); } this.components.Add(component); @@ -91,7 +91,7 @@ namespace Hotfix return component; } - public K AddComponent(P1 p1, P2 p2) where K : HotfixComponent, new() + public K AddComponent(P1 p1, P2 p2) where K : Component, new() { K component = (K) Activator.CreateInstance(typeof (K)); component.Owner = this; @@ -103,7 +103,7 @@ namespace Hotfix if (this.components == null) { - this.components = new HashSet(); + this.components = new HashSet(); } this.components.Add(component); @@ -113,7 +113,7 @@ namespace Hotfix return component; } - public K AddComponent(P1 p1, P2 p2, P3 p3) where K : HotfixComponent, new() + public K AddComponent(P1 p1, P2 p2, P3 p3) where K : Component, new() { K component = (K) Activator.CreateInstance(typeof (K)); component.Owner = this; @@ -125,7 +125,7 @@ namespace Hotfix if (this.components == null) { - this.components = new HashSet(); + this.components = new HashSet(); } this.components.Add(component); @@ -135,9 +135,9 @@ namespace Hotfix return component; } - public void RemoveComponent() where K : HotfixComponent + public void RemoveComponent() where K : Component { - HotfixComponent component; + Component component; if (!this.componentDict.TryGetValue(typeof (K), out component)) { return; @@ -154,7 +154,7 @@ namespace Hotfix public void RemoveComponent(Type type) { - HotfixComponent component; + Component component; if (!this.componentDict.TryGetValue(type, out component)) { return; @@ -169,9 +169,9 @@ namespace Hotfix component.Dispose(); } - public K GetComponent() where K : HotfixComponent + public K GetComponent() where K : Component { - HotfixComponent component; + Component component; if (!this.componentDict.TryGetValue(typeof (K), out component)) { return default(K); @@ -179,7 +179,7 @@ namespace Hotfix return (K) component; } - public HotfixComponent[] GetComponents() + public Component[] GetComponents() { return components.ToArray(); } diff --git a/Unity/Hotfix/Object/ObjectEventAttribute.cs b/Unity/Hotfix/Object/ObjectEventAttribute.cs new file mode 100644 index 00000000..2672a774 --- /dev/null +++ b/Unity/Hotfix/Object/ObjectEventAttribute.cs @@ -0,0 +1,15 @@ +using System; + +namespace Hotfix +{ + [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] + public class ObjectEventAttribute: Attribute + { + public int ClassType; + + public ObjectEventAttribute(int classType) + { + this.ClassType = classType; + } + } +} \ No newline at end of file diff --git a/Unity/Hotfix/UI/UILobby/Component/UILobbyComponent.cs b/Unity/Hotfix/UI/UILobby/Component/UILobbyComponent.cs index c045c249..b6f5c9a6 100644 --- a/Unity/Hotfix/UI/UILobby/Component/UILobbyComponent.cs +++ b/Unity/Hotfix/UI/UILobby/Component/UILobbyComponent.cs @@ -5,8 +5,8 @@ using UnityEngine.UI; namespace Hotfix { - [EntityEvent(EntityEventId.UILobbyComponent)] - public class UILobbyComponent: HotfixComponent, IAwake + [ObjectEvent(EntityEventId.UILobbyComponent)] + public class UILobbyComponent: Component, IAwake { public void Awake() { @@ -22,9 +22,9 @@ namespace Hotfix Session session = null; try { - session = Hotfix.Scene.GetComponent().Create("127.0.0.1:10001"); + session = Game.Scene.GetComponent().Create("127.0.0.1:10001"); R2C_Login r2CLogin = await session.Call(new C2R_Login() { Account = "abcdef", Password = "111111" }); - Session gateSession = Hotfix.Scene.GetComponent().Create(r2CLogin.Address); + Session gateSession = Game.Scene.GetComponent().Create(r2CLogin.Address); G2C_LoginGate g2CLoginGate = await gateSession.Call(new C2G_LoginGate(r2CLogin.Key)); Log.Info("登陆gate成功!"); diff --git a/Unity/Hotfix/Unity.Hotfix.csproj b/Unity/Hotfix/Unity.Hotfix.csproj index 8de5012a..42f2ff2b 100644 --- a/Unity/Hotfix/Unity.Hotfix.csproj +++ b/Unity/Hotfix/Unity.Hotfix.csproj @@ -55,8 +55,6 @@ - - @@ -68,19 +66,10 @@ - - - - - - - - - @@ -92,45 +81,23 @@ - - - - - - - - - - - - - - - - - - - - - - - + - - + + @@ -153,7 +120,9 @@ Unity.Plugins - + + + echo FA | xcopy $(TargetName).dll $(SolutionDir)Assets\Res\Code\$(TargetName).dll.bytes diff --git a/Unity/Unity.csproj b/Unity/Unity.csproj index f04b522f..1eb466b0 100644 --- a/Unity/Unity.csproj +++ b/Unity/Unity.csproj @@ -368,9 +368,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -380,9 +412,32 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Unity/Unity.csproj.user b/Unity/Unity.csproj.user new file mode 100644 index 00000000..6cbe5889 --- /dev/null +++ b/Unity/Unity.csproj.user @@ -0,0 +1,6 @@ + + + + ProjectFiles + + \ No newline at end of file -- GitLab