Просмотр исходного кода

Merge pull request #1 from egametang/master

1
Yinmany 7 лет назад
Родитель
Сommit
aaacb3fd20
33 измененных файлов с 998 добавлено и 704 удалено
  1. 1 1
      Config/StartConfig/LocalAllServer.txt
  2. 5 5
      Proto/InnerMessage.proto
  3. 3 0
      README.md
  4. 1 1
      Server/App/Program.cs
  5. 41 47
      Server/Hotfix/Module/Http/HttpTest.cs
  6. 159 0
      Server/Model/Base/MultiMap.cs
  7. 1 1
      Server/Model/Component/BenchmarkComponent.cs
  8. 327 297
      Server/Model/Module/Http/HttpComponent.cs
  9. 42 42
      Server/Model/Module/Http/HttpHandlerAttribute.cs
  10. 10 10
      Server/Model/Module/Http/IHttpHandler.cs
  11. 0 1
      Server/Model/Server.Model.csproj
  12. 8 2
      Unity/Assets/Scripts/Base/MultiMap.cs
  13. 1 1
      Unity/Assets/Scripts/Component/Config/HttpConfig.cs
  14. 23 20
      Unity/Assets/Scripts/Component/TimerComponent.cs
  15. 5 0
      Unity/Assets/Scripts/Helper/ResourcesHelper.cs
  16. 1 1
      Unity/Assets/Scripts/Module/Config/ConfigHelper.cs
  17. 14 40
      Unity/Assets/Scripts/Module/FrameSync/ClientFrameComponent.cs
  18. 37 21
      Unity/Assets/Scripts/Module/Message/Network/KCP/KService.cs
  19. 60 60
      Unity/Assets/Scripts/Module/Message/Network/KCP/Kcp.cs
  20. 1 1
      Unity/Assets/Scripts/UI/UILoading/Factory/UILoadingFactory.cs
  21. 7 5
      Unity/Assets/ThirdParty/ILRuntime/Generated/CLRBindings.cs
  22. 53 0
      Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_ComponentWithId_Binding.cs
  23. 2 2
      Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_ComponentWithId_Binding.cs.meta
  24. 31 0
      Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_Component_Binding.cs
  25. 0 20
      Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_Disposer_Binding.cs
  26. 26 4
      Unity/Assets/ThirdParty/ILRuntime/Generated/System_Collections_Generic_Dictionary_2_Int64_ILTypeInstance_B_t.cs
  27. 19 19
      Unity/Assets/ThirdParty/ILRuntime/Generated/System_Collections_Generic_Queue_1_ILTypeInstance_Binding.cs
  28. 107 0
      Unity/Assets/ThirdParty/ILRuntime/Generated/System_Collections_Generic_Queue_1_Int64_Binding.cs
  29. 2 2
      Unity/Assets/ThirdParty/ILRuntime/Generated/System_Collections_Generic_Queue_1_Int64_Binding.cs.meta
  30. 2 20
      Unity/Assets/ThirdParty/ILRuntime/Generated/System_Object_Binding.cs
  31. 0 55
      Unity/Assets/ThirdParty/ILRuntime/Generated/UnityEngine_Resources_Binding.cs
  32. 0 14
      Unity/Hotfix/Module/Config/ConfigHelper.cs
  33. 9 12
      Unity/Unity.csproj

+ 1 - 1
Config/StartConfig/LocalAllServer.txt

@@ -1 +1 @@
-{ "_t" : "StartConfig", "_id" : NumberLong("98547768819754"), "components" : [{ "_t" : "OuterConfig", "Host" : "127.0.0.1", "Port" : 10002, "Host2" : "127.0.0.1" }, { "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20000 }, { "_t" : "HttpConfig", "Url" : "http://*/", "AppId" : 0, "AppKey" : "", "ManagerSystemUrl" : "" }, { "_t" : "DBConfig", "ConnectionString" : null, "DBName" : null }], "AppId" : 1, "AppType" : "AllServer", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("98547768819754"), "components" : [{ "_t" : "OuterConfig", "Host" : "127.0.0.1", "Port" : 10002, "Host2" : "127.0.0.1" }, { "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20000 }, { "_t" : "HttpConfig", "Url" : "http://*:8080/", "AppId" : 0, "AppKey" : "", "ManagerSystemUrl" : "" }, { "_t" : "DBConfig", "ConnectionString" : null, "DBName" : null }], "AppId" : 1, "AppType" : "AllServer", "ServerIP" : "*" }

+ 5 - 5
Proto/InnerMessage.proto

@@ -44,7 +44,7 @@
 
 		required string CollectionName = 2;
 
-		required Component Component = 3;
+		required ComponentWithId Component = 3;
 	}
 
 
@@ -56,7 +56,7 @@
 	{
 		required bool NeedCache = 1;
 		required string CollectionName = 2;
-		repeated Component Components = 3;
+		repeated ComponentWithId Components = 3;
 	}
 
 	message DBSaveResponse // IResponse
@@ -72,7 +72,7 @@
 
 	message DBQueryResponse // IResponse
 	{
-		required Component Component = 1;
+		required ComponentWithId Component = 1;
 	}
 
 	message DBQueryBatchRequest // IRequest
@@ -84,7 +84,7 @@
 
 	message DBQueryBatchResponse // IResponse
 	{
-		repeated Component Components = 1;
+		repeated ComponentWithId Components = 1;
 	}
 
 	message DBQueryJsonRequest // IRequest
@@ -96,7 +96,7 @@
 
 	message DBQueryJsonResponse // IResponse
 	{
-		repeated Component Components = 1;
+		repeated ComponentWithId Components = 1;
 	}
 
 	message ObjectAddRequest // IRequest

+ 3 - 0
README.md

@@ -69,6 +69,9 @@ ET框架的服务端是一个强大灵活的分布式服务端架构,完全可
 [组件式设计](https://github.com/egametang/Egametang/blob/master/Doc/%E7%BB%84%E4%BB%B6%E8%AE%BE%E8%AE%A1.md)   
 [网络层设计](https://github.com/egametang/Egametang/blob/master/Doc/%E7%BD%91%E7%BB%9C%E5%B1%82%E8%AE%BE%E8%AE%A1.md)   
 
+有自己觉得写得不错的Module可以pr提交到下面的库中,造福大家!  
+[module共享仓库](https://github.com/egametang/ET-Modules)   
+
 群友分享:  
 [框架服务端运行流程](http://www.cnblogs.com/fancybit/p/et1.html)   
 [ET启动配置](http://www.cnblogs.com/fancybit/p/et2.html)   

+ 1 - 1
Server/App/Program.cs

@@ -105,7 +105,7 @@ namespace App
 						Game.Scene.AddComponent<ConfigComponent>();
 						Game.Scene.AddComponent<ServerFrameComponent>();
 						Game.Scene.AddComponent<ActorManagerComponent>();
-            Game.Scene.AddComponent<HttpComponent>();
+						//Game.Scene.AddComponent<HttpComponent>();
 						break;
 					case AppType.Benchmark:
 						Game.Scene.AddComponent<NetOuterComponent>();

+ 41 - 47
Server/Hotfix/Module/Http/HttpTest.cs

@@ -1,55 +1,49 @@
-using ETModel;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Net;
-using System.Text;
+using System.Net;
+using ETModel;
 
 namespace ETHotfix
 {
+	public class AccountInfo
+	{
+		public string name;
+		public string pwd;
+	}
 
-  public class AccountInfo
-  {
-    public string name;
-    public string pwd;
-  }
+	[HttpHandler(AppType.Gate, "/")]
+	public class HttpTest: AHttpHandler
+	{
+		[Get] // url-> /Login?name=11&age=1111
+		public string Login(string name, int age, HttpListenerRequest req, HttpListenerResponse resp)
+		{
+			Log.Info(name);
+			Log.Info($"{age}");
+			return "ok";
+		}
 
-  [HttpHandler(AppType.Gate, "/")]
-  public class HttpTest : AHttpHandler
-  {
-    [Get] // url-> /Login?name=11&age=1111
-    public string Login(string name, int age, HttpListenerRequest req, HttpListenerResponse resp)
-    {
-      Log.Info(name);
-      Log.Info($"{age}");
-      return "ok";
-    }
+		[Get("t")] // url-> /t
+		public int Test()
+		{
+			return 1;
+		}
 
-    [Get("t")] // url-> /t
-    public int Test()
-    {
-      return 1;
-    }
+		[Post] // url-> /Test1
+		public int Test1(HttpListenerRequest req)
+		{
+			return 1;
+		}
 
-    [Post] // url-> /Test1
-    public int Test1(HttpListenerRequest req)
-    {
-      return 1;
-    }
+		[Get] // url-> /Test2
+		public int Test2(HttpListenerResponse resp)
+		{
+			return 1;
+		}
 
-    [Get] // url-> /Test2
-    public int Test2(HttpListenerResponse resp)
-    {
-      return 1;
-    }
-
-    [Post] 
-    public object Test3(HttpListenerResponse resp, HttpListenerRequest req, string postBody, AccountInfo accountInfo)
-    {
-      Log.Info(postBody);
-      Log.Info(JsonHelper.ToJson(accountInfo));
-      return new { name = "1111" };
-    }
-  }
-}
- 
+		[Post]
+		public object Test3(HttpListenerResponse resp, HttpListenerRequest req, string postBody, AccountInfo accountInfo)
+		{
+			Log.Info(postBody);
+			Log.Info(JsonHelper.ToJson(accountInfo));
+			return new { name = "1111" };
+		}
+	}
+}

+ 159 - 0
Server/Model/Base/MultiMap.cs

@@ -0,0 +1,159 @@
+using System.Collections.Generic;
+using System.Linq;
+
+namespace ETModel
+{
+	public class MultiMap<T, K>
+	{
+		private readonly SortedDictionary<T, List<K>> dictionary = new SortedDictionary<T, List<K>>();
+
+		// 重用list
+		private readonly Queue<List<K>> queue = new Queue<List<K>>();
+
+		public SortedDictionary<T, List<K>> GetDictionary()
+		{
+			return this.dictionary;
+		}
+
+		public void Add(T t, K k)
+		{
+			List<K> list;
+			this.dictionary.TryGetValue(t, out list);
+			if (list == null)
+			{
+				list = this.FetchList();
+			}
+			list.Add(k);
+			this.dictionary[t] = list;
+		}
+
+		public KeyValuePair<T, List<K>> First()
+		{
+			return this.dictionary.First();
+		}
+
+		public T FirstKey()
+		{
+			return this.dictionary.Keys.First();
+		}
+
+		public int Count
+		{
+			get
+			{
+				return this.dictionary.Count;
+			}
+		}
+
+		private List<K> FetchList()
+		{
+			if (this.queue.Count > 0)
+			{
+				List<K> list = this.queue.Dequeue();
+				list.Clear();
+				return list;
+			}
+			return new List<K>();
+		}
+
+		private void RecycleList(List<K> list)
+		{
+			// 防止暴涨
+			if (this.queue.Count > 100)
+			{
+				return;
+			}
+			list.Clear();
+			this.queue.Enqueue(list);
+		}
+
+		public bool Remove(T t, K k)
+		{
+			List<K> list;
+			this.dictionary.TryGetValue(t, out list);
+			if (list == null)
+			{
+				return false;
+			}
+			if (!list.Remove(k))
+			{
+				return false;
+			}
+			if (list.Count == 0)
+			{
+				this.RecycleList(list);
+				this.dictionary.Remove(t);
+			}
+			return true;
+		}
+
+		public bool Remove(T t)
+		{
+			List<K> list = null;
+			this.dictionary.TryGetValue(t, out list);
+			if (list != null)
+			{
+				this.RecycleList(list);
+			}
+			return this.dictionary.Remove(t);
+		}
+
+		/// <summary>
+		/// 不返回内部的list,copy一份出来
+		/// </summary>
+		/// <param name="t"></param>
+		/// <returns></returns>
+		public K[] GetAll(T t)
+		{
+			List<K> list;
+			this.dictionary.TryGetValue(t, out list);
+			if (list == null)
+			{
+				return new K[0];
+			}
+			return list.ToArray();
+		}
+
+		/// <summary>
+		/// 返回内部的list
+		/// </summary>
+		/// <param name="t"></param>
+		/// <returns></returns>
+		public List<K> this[T t]
+		{
+			get
+			{
+				List<K> list;
+				this.dictionary.TryGetValue(t, out list);
+				return list;
+			}
+		}
+
+		public K GetOne(T t)
+		{
+			List<K> list;
+			this.dictionary.TryGetValue(t, out list);
+			if (list != null && list.Count > 0)
+			{
+				return list[0];
+			}
+			return default(K);
+		}
+
+		public bool Contains(T t, K k)
+		{
+			List<K> list;
+			this.dictionary.TryGetValue(t, out list);
+			if (list == null)
+			{
+				return false;
+			}
+			return list.Contains(k);
+		}
+
+		public bool ContainsKey(T t)
+		{
+			return this.dictionary.ContainsKey(t);
+		}
+	}
+}

+ 1 - 1
Server/Model/Component/BenchmarkComponent.cs

@@ -24,7 +24,7 @@ namespace ETModel
 			try
 			{
 				NetOuterComponent networkComponent = Game.Scene.GetComponent<NetOuterComponent>();
-				for (int i = 0; i < 100; i++)
+				for (int i = 0; i < 1000; i++)
 				{
 					this.TestAsync(networkComponent, ipEndPoint, i);
 				}

+ 327 - 297
Server/Model/Module/Http/HttpComponent.cs

@@ -1,305 +1,335 @@
 using System;
 using System.Collections.Generic;
+using System.IO;
 using System.Net;
 using System.Reflection;
-using System.IO;
 
 namespace ETModel
 {
-  [ObjectSystem]
-  public class HttpComponentComponentAwakeSystem : AwakeSystem<HttpComponent>
-  {
-    public override void Awake(HttpComponent self)
-    {
-      self.Awake();
-    }
-  }
-
-  [ObjectSystem]
-  public class HttpComponentComponentLoadSystem : LoadSystem<HttpComponent>
-  {
-    public override void Load(HttpComponent self)
-    {
-      self.Load();
-    }
-  }
-
-  /// <summary>
-  /// http请求分发器
-  /// </summary>
-  public class HttpComponent : Component
-  {
-    public AppType appType;
-    public HttpListener listener;
-    public HttpConfig HttpConfig;
-    public Dictionary<string, IHttpHandler> dispatcher;
-
-    // 处理方法
-    private Dictionary<MethodInfo, IHttpHandler> handlersMapping;
-
-    // Get处理
-    private Dictionary<string, MethodInfo> getHandlers;
-    private Dictionary<string, MethodInfo> postHandlers;
-
-    public void Awake()
-    {
-      StartConfig startConfig = Game.Scene.GetComponent<StartConfigComponent>().StartConfig;
-      this.appType = startConfig.AppType;
-      this.HttpConfig = startConfig.GetComponent<HttpConfig>();
-
-      this.Load();
-
-      try
-      {
-        this.listener = new HttpListener();
-
-        if (this.HttpConfig.Url == null)
-        {
-          this.HttpConfig.Url = "";
-        }
-        foreach (string s in this.HttpConfig.Url.Split(';'))
-        {
-          if (s.Trim() == "")
-          {
-            continue;
-          }
-          this.listener.Prefixes.Add(s);
-        }
-
-        this.listener.Start();
-
-        this.Accept();
-      }
-      catch (HttpListenerException e)
-      {
-        throw new Exception($"http server error: {e.ErrorCode}", e);
-      }
-    }
-
-    public void Load()
-    {
-      this.dispatcher = new Dictionary<string, IHttpHandler>();
-      this.handlersMapping = new Dictionary<MethodInfo, IHttpHandler>();
-      this.getHandlers = new Dictionary<string, MethodInfo>();
-      this.postHandlers = new Dictionary<string, MethodInfo>();
-
-      Type[] types = DllHelper.GetMonoTypes();
-
-      foreach (Type type in types)
-      {
-        object[] attrs = type.GetCustomAttributes(typeof(HttpHandlerAttribute), false);
-        if (attrs.Length == 0)
-        {
-          continue;
-        }
-
-        HttpHandlerAttribute httpHandlerAttribute = (HttpHandlerAttribute)attrs[0];
-        if (!httpHandlerAttribute.AppType.Is(this.appType))
-        {
-          continue;
-        }
-
-        object obj = Activator.CreateInstance(type);
-
-        IHttpHandler ihttpHandler = obj as IHttpHandler;
-        if (ihttpHandler == null)
-        {
-          throw new Exception($"HttpHandler handler not inherit IHttpHandler class: {obj.GetType().FullName}");
-        }
-
-        this.dispatcher.Add(httpHandlerAttribute.Path, ihttpHandler);
-
-        LoadMethod(type, httpHandlerAttribute, ihttpHandler);
-      }
-    }
-
-    public void LoadMethod(Type type, HttpHandlerAttribute httpHandlerAttribute, IHttpHandler httpHandler)
-    {
-      // 扫描这个类里面的方法
-      MethodInfo[] methodInfos = type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.InvokeMethod | BindingFlags.Instance);
-      foreach (var method in methodInfos)
-      {
-        object[] getAttrs = method.GetCustomAttributes(typeof(GetAttribute), false);
-        if (getAttrs.Length != 0)
-        {
-          GetAttribute get = (GetAttribute)getAttrs[0];
-
-          string path = method.Name;
-          if (!string.IsNullOrEmpty(get.Path))
-            path = get.Path;
-
-          getHandlers.Add(httpHandlerAttribute.Path + path, method);
-          Log.Debug($"add handler[{httpHandler.ToString()}.{method.Name}] path {httpHandlerAttribute.Path + path}");
-        }
-
-        object[] postAttrs = method.GetCustomAttributes(typeof(PostAttribute), false);
-        if (postAttrs.Length != 0)
-        {
-          // Post处理方法
-          PostAttribute post = (PostAttribute)postAttrs[0];
-
-          string path = method.Name;
-          if (!string.IsNullOrEmpty(post.Path))
-            path = post.Path;
-
-          postHandlers.Add(httpHandlerAttribute.Path + path, method);
-          Log.Debug($"add handler[{httpHandler.ToString()}.{method.Name}] path {httpHandlerAttribute.Path + path}");
-        }
-
-        if (getAttrs.Length == 0 && postAttrs.Length == 0) continue;
-
-        handlersMapping.Add(method, httpHandler);
-      }
-    }
-
-    public async void Accept()
-    {
-      while (true)
-      {
-        if (this.IsDisposed)
-        {
-          return;
-        }
-
-        HttpListenerContext context = await this.listener.GetContextAsync();
-        InvokeHandler(context);
-        context.Response.Close();
-      }
-    }
-
-    /// <summary>
-    /// 调用处理方法
-    /// </summary>
-    /// <param name="context"></param>
-    private void InvokeHandler(HttpListenerContext context)
-    {
-      context.Response.StatusCode = 404;
-
-      MethodInfo methodInfo = null;
-      IHttpHandler httpHandler = null;
-      string postbody = "";
-      if (context.Request.HttpMethod == "GET")
-      {
-        this.getHandlers.TryGetValue(context.Request.Url.AbsolutePath, out methodInfo);
-        if (methodInfo != null)
-          this.handlersMapping.TryGetValue(methodInfo, out httpHandler);
-      }
-      else if (context.Request.HttpMethod == "POST")
-      {
-        this.postHandlers.TryGetValue(context.Request.Url.AbsolutePath, out methodInfo);
-        if (methodInfo != null)
-        {
-          this.handlersMapping.TryGetValue(methodInfo, out httpHandler);
-
-          using (StreamReader sr = new StreamReader(context.Request.InputStream))
-          {
-            postbody = sr.ReadToEnd();
-          }
-        }
-      }
-      else
-      {
-        context.Response.StatusCode = 405;
-      }
-
-      if (httpHandler != null)
-      {
-        object[] args = InjectParameters(context, methodInfo, postbody);
-
-        // 自动把返回值,以json方式响应。
-        object resp = methodInfo?.Invoke(httpHandler, args);
-        if (resp != null)
-        {
-          using (StreamWriter sw = new StreamWriter(context.Response.OutputStream))
-          {
-            if (resp.GetType() == typeof(string))
-            {
-              sw.Write(resp.ToString());
-            }
-            else
-            {
-              sw.Write(JsonHelper.ToJson(resp));
-            }
-          }
-        }
-      }
-    }
-
-    /// <summary>
-    /// 注入参数
-    /// </summary>
-    /// <param name="context"></param>
-    /// <param name="methodInfo"></param>
-    /// <param name="postbody"></param>
-    /// <returns></returns>
-    private static object[] InjectParameters(HttpListenerContext context, MethodInfo methodInfo, string postbody)
-    {
-      context.Response.StatusCode = 200;
-      ParameterInfo[] parameterInfos = methodInfo.GetParameters();
-      object[] args = new object[parameterInfos.Length];
-      for (int i = 0; i < parameterInfos.Length; i++)
-      {
-        ParameterInfo item = parameterInfos[i];
-
-        if (item.ParameterType == typeof(HttpListenerRequest))
-        {
-          args[i] = context.Request;
-        }
-        else if (item.ParameterType == typeof(HttpListenerResponse))
-        {
-          args[i] = context.Response;
-        }
-        else
-        {
-          try
-          {
-            if (context.Request.HttpMethod == "POST") //TODO 扩展一些,Http Entity 自动转换 的功能
-            {
-              if (item.Name == "postBody") // 约定参数名称为postBody,只传string类型。本来是byte[],有需求可以改。
-              {
-                args[i] = postbody;
-              }
-              else if (item.ParameterType.IsClass && item.ParameterType != typeof(string) && !string.IsNullOrEmpty(postbody))
-              {
-                object entity = JsonHelper.FromJson(item.ParameterType, postbody);
-                args[i] = entity;
-              }
-            }
-            else if (context.Request.HttpMethod == "GET")
-            {
-              string query = context.Request.QueryString[item.Name];
-              if (query != null)
-              {
-                object value = Convert.ChangeType(query, item.ParameterType);
-                args[i] = value;
-              }
-            }
-            else
-            {
-              args[i] = null;
-            }
-          }
-          catch (Exception e)
-          {
-            Log.Debug(e.ToString());
-            args[i] = null;
-          }
-        }
-      }
-      return args;
-    }
-
-    public override void Dispose()
-    {
-      if (this.IsDisposed)
-      {
-        return;
-      }
-
-      base.Dispose();
-
-      this.listener.Stop();
-      this.listener.Close();
-    }
-  }
+	[ObjectSystem]
+	public class HttpComponentComponentAwakeSystem: AwakeSystem<HttpComponent>
+	{
+		public override void Awake(HttpComponent self)
+		{
+			self.Awake();
+		}
+	}
+
+	[ObjectSystem]
+	public class HttpComponentComponentLoadSystem: LoadSystem<HttpComponent>
+	{
+		public override void Load(HttpComponent self)
+		{
+			self.Load();
+		}
+	}
+
+	[ObjectSystem]
+	public class HttpComponentComponentStartSystem : StartSystem<HttpComponent>
+	{
+		public override void Start(HttpComponent self)
+		{
+			self.Start();
+		}
+	}
+
+	/// <summary>
+	/// http请求分发器
+	/// </summary>
+	public class HttpComponent: Component
+	{
+		public AppType appType;
+		public HttpListener listener;
+		public HttpConfig HttpConfig;
+		public Dictionary<string, IHttpHandler> dispatcher;
+
+		// 处理方法
+		private Dictionary<MethodInfo, IHttpHandler> handlersMapping;
+
+		// Get处理
+		private Dictionary<string, MethodInfo> getHandlers;
+		private Dictionary<string, MethodInfo> postHandlers;
+
+		public void Awake()
+		{
+			StartConfig startConfig = Game.Scene.GetComponent<StartConfigComponent>().StartConfig;
+			this.appType = startConfig.AppType;
+			this.HttpConfig = startConfig.GetComponent<HttpConfig>();
+
+			this.Load();
+		}
+
+		public void Load()
+		{
+			this.dispatcher = new Dictionary<string, IHttpHandler>();
+			this.handlersMapping = new Dictionary<MethodInfo, IHttpHandler>();
+			this.getHandlers = new Dictionary<string, MethodInfo>();
+			this.postHandlers = new Dictionary<string, MethodInfo>();
+
+			Type[] types = DllHelper.GetMonoTypes();
+
+			foreach (Type type in types)
+			{
+				object[] attrs = type.GetCustomAttributes(typeof(HttpHandlerAttribute), false);
+				if (attrs.Length == 0)
+				{
+					continue;
+				}
+
+				HttpHandlerAttribute httpHandlerAttribute = (HttpHandlerAttribute) attrs[0];
+				if (!httpHandlerAttribute.AppType.Is(this.appType))
+				{
+					continue;
+				}
+
+				object obj = Activator.CreateInstance(type);
+
+				IHttpHandler ihttpHandler = obj as IHttpHandler;
+				if (ihttpHandler == null)
+				{
+					throw new Exception($"HttpHandler handler not inherit IHttpHandler class: {obj.GetType().FullName}");
+				}
+
+				this.dispatcher.Add(httpHandlerAttribute.Path, ihttpHandler);
+
+				LoadMethod(type, httpHandlerAttribute, ihttpHandler);
+			}
+		}
+
+		public void Start()
+		{
+			try
+			{
+				this.listener = new HttpListener();
+
+				if (this.HttpConfig.Url == null)
+				{
+					this.HttpConfig.Url = "";
+				}
+
+				foreach (string s in this.HttpConfig.Url.Split(';'))
+				{
+					if (s.Trim() == "")
+					{
+						continue;
+					}
+
+					this.listener.Prefixes.Add(s);
+				}
+
+				this.listener.Start();
+
+				this.Accept();
+			}
+			catch (HttpListenerException e)
+			{
+				throw new Exception($"http server error: {e.ErrorCode}", e);
+			}
+		}
+
+		public void LoadMethod(Type type, HttpHandlerAttribute httpHandlerAttribute, IHttpHandler httpHandler)
+		{
+			// 扫描这个类里面的方法
+			MethodInfo[] methodInfos = type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.InvokeMethod | BindingFlags.Instance);
+			foreach (MethodInfo method in methodInfos)
+			{
+				object[] getAttrs = method.GetCustomAttributes(typeof(GetAttribute), false);
+				if (getAttrs.Length != 0)
+				{
+					GetAttribute get = (GetAttribute) getAttrs[0];
+
+					string path = method.Name;
+					if (!string.IsNullOrEmpty(get.Path))
+					{
+						path = get.Path;
+					}
+
+					getHandlers.Add(httpHandlerAttribute.Path + path, method);
+					//Log.Debug($"add handler[{httpHandler}.{method.Name}] path {httpHandlerAttribute.Path + path}");
+				}
+
+				object[] postAttrs = method.GetCustomAttributes(typeof(PostAttribute), false);
+				if (postAttrs.Length != 0)
+				{
+					// Post处理方法
+					PostAttribute post = (PostAttribute) postAttrs[0];
+
+					string path = method.Name;
+					if (!string.IsNullOrEmpty(post.Path))
+					{
+						path = post.Path;
+					}
+
+					postHandlers.Add(httpHandlerAttribute.Path + path, method);
+					//Log.Debug($"add handler[{httpHandler}.{method.Name}] path {httpHandlerAttribute.Path + path}");
+				}
+
+				if (getAttrs.Length == 0 && postAttrs.Length == 0)
+				{
+					continue;
+				}
+
+				handlersMapping.Add(method, httpHandler);
+			}
+		}
+
+		public async void Accept()
+		{
+			while (true)
+			{
+				if (this.IsDisposed)
+				{
+					return;
+				}
+
+				HttpListenerContext context = await this.listener.GetContextAsync();
+				InvokeHandler(context);
+				context.Response.Close();
+			}
+		}
+
+		/// <summary>
+		/// 调用处理方法
+		/// </summary>
+		/// <param name="context"></param>
+		private void InvokeHandler(HttpListenerContext context)
+		{
+			context.Response.StatusCode = 404;
+
+			MethodInfo methodInfo = null;
+			IHttpHandler httpHandler = null;
+			string postbody = "";
+			switch (context.Request.HttpMethod)
+			{
+				case "GET":
+					this.getHandlers.TryGetValue(context.Request.Url.AbsolutePath, out methodInfo);
+					if (methodInfo != null)
+					{
+						this.handlersMapping.TryGetValue(methodInfo, out httpHandler);
+					}
+					break;
+				case "POST":
+					this.postHandlers.TryGetValue(context.Request.Url.AbsolutePath, out methodInfo);
+					if (methodInfo != null)
+					{
+						this.handlersMapping.TryGetValue(methodInfo, out httpHandler);
+
+						using (StreamReader sr = new StreamReader(context.Request.InputStream))
+						{
+							postbody = sr.ReadToEnd();
+						}
+					}
+					break;
+				default:
+					context.Response.StatusCode = 405;
+					break;
+			}
+
+			if (httpHandler != null)
+			{
+				object[] args = InjectParameters(context, methodInfo, postbody);
+
+				// 自动把返回值,以json方式响应。
+				object resp = methodInfo.Invoke(httpHandler, args);
+
+				if (resp == null)
+				{
+					return;
+				}
+
+				using (StreamWriter sw = new StreamWriter(context.Response.OutputStream))
+				{
+					if (resp is string)
+					{
+						sw.Write(resp.ToString());
+					}
+					else
+					{
+						sw.Write(JsonHelper.ToJson(resp));
+					}
+				}
+			}
+		}
+
+		/// <summary>
+		/// 注入参数
+		/// </summary>
+		/// <param name="context"></param>
+		/// <param name="methodInfo"></param>
+		/// <param name="postbody"></param>
+		/// <returns></returns>
+		private static object[] InjectParameters(HttpListenerContext context, MethodInfo methodInfo, string postbody)
+		{
+			context.Response.StatusCode = 200;
+			ParameterInfo[] parameterInfos = methodInfo.GetParameters();
+			object[] args = new object[parameterInfos.Length];
+			for (int i = 0; i < parameterInfos.Length; i++)
+			{
+				ParameterInfo item = parameterInfos[i];
+
+				if (item.ParameterType == typeof(HttpListenerRequest))
+				{
+					args[i] = context.Request;
+					continue;
+				}
+
+				if (item.ParameterType == typeof(HttpListenerResponse))
+				{
+					args[i] = context.Response;
+					continue;
+				}
+
+				try
+				{
+					switch (context.Request.HttpMethod)
+					{
+						case "POST":
+							if (item.Name == "postBody") // 约定参数名称为postBody,只传string类型。本来是byte[],有需求可以改。
+							{
+								args[i] = postbody;
+							}
+							else if (item.ParameterType.IsClass && item.ParameterType != typeof(string) && !string.IsNullOrEmpty(postbody))
+							{
+								object entity = JsonHelper.FromJson(item.ParameterType, postbody);
+								args[i] = entity;
+							}
+
+							break;
+						case "GET":
+							string query = context.Request.QueryString[item.Name];
+							if (query != null)
+							{
+								object value = Convert.ChangeType(query, item.ParameterType);
+								args[i] = value;
+							}
+
+							break;
+						default:
+							args[i] = null;
+							break;
+					}
+				}
+				catch (Exception e)
+				{
+					Log.Error(e);
+					args[i] = null;
+				}
+			}
+
+			return args;
+		}
+
+		public override void Dispose()
+		{
+			if (this.IsDisposed)
+			{
+				return;
+			}
+
+			base.Dispose();
+
+			this.listener.Stop();
+			this.listener.Close();
+		}
+	}
 }

+ 42 - 42
Server/Model/Module/Http/HttpHandlerAttribute.cs

@@ -2,46 +2,46 @@
 
 namespace ETModel
 {
-  public class HttpHandlerAttribute : Attribute
-  {
-    public AppType AppType { get; }
-
-    public string Path { get; }
-
-    public HttpHandlerAttribute(AppType appType, string path)
-    {
-      this.AppType = appType;
-      this.Path = path;
-    }
-  }
-
-  [AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)]
-  public class GetAttribute : Attribute
-  {
-    public string Path { get; }
-    public GetAttribute()
-    {
-
-    }
-
-    public GetAttribute(string path)
-    {
-      this.Path = path;
-    }
-  }
-
-  [AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)]
-  public class PostAttribute : Attribute
-  {
-    public string Path { get; }
-    public PostAttribute()
-    {
-
-    }
-
-    public PostAttribute(string path)
-    {
-      this.Path = path;
-    }
-  }
+	public class HttpHandlerAttribute: Attribute
+	{
+		public AppType AppType { get; }
+
+		public string Path { get; }
+
+		public HttpHandlerAttribute(AppType appType, string path)
+		{
+			this.AppType = appType;
+			this.Path = path;
+		}
+	}
+
+	[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)]
+	public class GetAttribute: Attribute
+	{
+		public string Path { get; }
+
+		public GetAttribute()
+		{
+		}
+
+		public GetAttribute(string path)
+		{
+			this.Path = path;
+		}
+	}
+
+	[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)]
+	public class PostAttribute: Attribute
+	{
+		public string Path { get; }
+
+		public PostAttribute()
+		{
+		}
+
+		public PostAttribute(string path)
+		{
+			this.Path = path;
+		}
+	}
 }

+ 10 - 10
Server/Model/Module/Http/IHttpHandler.cs

@@ -2,15 +2,15 @@
 
 namespace ETModel
 {
-  public interface IHttpHandler
-  {
-    void Handle(HttpListenerContext context);
-  }
+	public interface IHttpHandler
+	{
+		void Handle(HttpListenerContext context);
+	}
 
-  public abstract class AHttpHandler : IHttpHandler
-  {
-    public virtual void Handle(HttpListenerContext context)
-    {
-    }
-  }
+	public abstract class AHttpHandler: IHttpHandler
+	{
+		public virtual void Handle(HttpListenerContext context)
+		{
+		}
+	}
 }

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

@@ -40,7 +40,6 @@
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Helper\StringHelper.cs" Link="Base\Helper\StringHelper.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Helper\TimeHelper.cs" Link="Base\Helper\TimeHelper.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Helper\ZipHelper.cs" Link="Base\Helper\ZipHelper.cs" />
-    <Compile Include="..\..\Unity\Assets\Scripts\Base\MultiMap.cs" Link="Base\MultiMap.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\Component.cs" Link="Base\Object\Component.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\ComponentFactory.cs" Link="Base\Object\ComponentFactory.cs" />
     <Compile Include="..\..\Unity\Assets\Scripts\Base\Object\ComponentWithId.cs" Link="Base\Object\ComponentWithId.cs" />

+ 8 - 2
Unity/Assets/Scripts/Base/MultiMap.cs

@@ -5,12 +5,13 @@ namespace ETModel
 {
 	public class MultiMap<T, K>
 	{
-		private readonly SortedDictionary<T, List<K>> dictionary = new SortedDictionary<T, List<K>>();
+		// 客户端用SortedList,因为unity用SortedDictionary在取firstkey的时候有gc,再者客户端的插入删除并不多
+		private readonly SortedList<T, List<K>> dictionary = new SortedList<T, List<K>>();
 
 		// 重用list
 		private readonly Queue<List<K>> queue = new Queue<List<K>>();
 
-		public SortedDictionary<T, List<K>> GetDictionary()
+		public SortedList<T, List<K>> GetDictionary()
 		{
 			return this.dictionary;
 		}
@@ -32,6 +33,11 @@ namespace ETModel
 			return this.dictionary.First();
 		}
 
+		public T FirstKey()
+		{
+			return this.dictionary.Keys[0];
+		}
+
 		public int Count
 		{
 			get

+ 1 - 1
Unity/Assets/Scripts/Component/Config/HttpConfig.cs

@@ -3,7 +3,7 @@
 namespace ETModel
 {
 	[BsonIgnoreExtraElements]
-	public class HttpConfig : AConfigComponent
+	public class HttpConfig: AConfigComponent
 	{
 		public string Url { get; set; } = "";
 		public int AppId { get; set; }

+ 23 - 20
Unity/Assets/Scripts/Component/TimerComponent.cs

@@ -33,35 +33,38 @@ namespace ETModel
 
 		public void Update()
 		{
+			if (this.timeId.Count == 0)
+			{
+				return;
+			}
+
 			long timeNow = TimeHelper.Now();
 
-			while (true)
+			timeOutId.Clear();
+
+			while (this.timeId.Count > 0)
 			{
-				if (this.timeId.Count <= 0)
+				long k = this.timeId.FirstKey();
+				if (k > timeNow)
 				{
-					return;
+					break;
 				}
-				var kv = this.timeId.First();
-				if (kv.Key > timeNow)
+				foreach (long ll in this.timeId[k])
 				{
-					break;
+					this.timeOutId.Add(ll);
 				}
+				this.timeId.Remove(k);
+			}
 
-				timeOutId.Clear();
-				timeOutId.AddRange(kv.Value);
-
-				this.timeId.Remove(kv.Key);
-				
-				foreach (long id in timeOutId)
+			foreach (long k in this.timeOutId)
+			{
+				Timer timer;
+				if (!this.timers.TryGetValue(k, out timer))
 				{
-					Timer timer;
-					if (!this.timers.TryGetValue(id, out timer))
-					{
-						continue;
-					}
-					this.timers.Remove(id);
-					timer.tcs.SetResult(true);
-				}				
+					continue;
+				}
+				this.timers.Remove(k);
+				timer.tcs.SetResult(true);
 			}
 		}
 

+ 5 - 0
Unity/Assets/Scripts/Helper/ResourcesHelper.cs

@@ -12,6 +12,11 @@ namespace ETModel
 {
 	public static class ResourcesHelper
 	{
+		public static UnityEngine.Object Load(string path)
+		{
+			return Resources.Load(path);
+		}
+
 		public static string[] GetDependencies(string assetBundleName)
 		{
 			string[] dependencies = new string[0];

+ 1 - 1
Unity/Assets/Scripts/Module/Config/ConfigHelper.cs

@@ -23,7 +23,7 @@ namespace ETModel
 		{
 			try
 			{
-				GameObject config = (GameObject)Resources.Load("KV");
+				GameObject config = (GameObject)ResourcesHelper.Load("KV");
 				string configStr = config.Get<TextAsset>("GlobalProto").text;
 				return configStr;
 			}

+ 14 - 40
Unity/Assets/Scripts/Module/FrameSync/ClientFrameComponent.cs

@@ -9,14 +9,16 @@ namespace ETModel
         public FrameMessage FrameMessage;
     }
     
-    [ObjectSystem]
-    public class ClientFrameComponentStartSystem : StartSystem<ClientFrameComponent>
-    {
-	    public override void Start(ClientFrameComponent t)
-	    {
-		    t.Start();
-	    }
-    }
+	[ObjectSystem]
+	public class ClientFrameComponentUpdateSystem : UpdateSystem<ClientFrameComponent>
+	{
+		public override void Update(ClientFrameComponent self)
+		{
+			self.Update();
+		}
+	}
+
+
 	public class ClientFrameComponent: Component
     {
         public int Frame;
@@ -24,47 +26,19 @@ namespace ETModel
         public Queue<SessionFrameMessage> Queue = new Queue<SessionFrameMessage>();
 
         public int count = 1;
-        
-        public int waitTime;
 
-        public const int maxWaitTime = 100;
+	    public int waitTime = 100;
 
-        public void Start()
-        {
-            UpdateAsync();
-        }
+        public const int maxWaitTime = 100;
 
         public void Add(Session session, FrameMessage frameMessage)
         {
             this.Queue.Enqueue(new SessionFrameMessage() {Session = session, FrameMessage = frameMessage});
         }
 
-        public async void UpdateAsync()
-        {
-	        try
-	        {
-		        TimerComponent timerComponent = Game.Scene.GetComponent<TimerComponent>();
-		        while (true)
-		        {
-			        await timerComponent.WaitAsync(waitTime);
-
-			        if (this.IsDisposed)
-			        {
-				        return;
-			        }
-
-			        this.UpdateFrame();
-		        }
-			}
-	        catch (Exception e)
-	        {
-		        Log.Error(e);
-	        }
-        }
-
-        private void UpdateFrame()
+        public void Update()
         {
-            if (this.Queue.Count == 0)
+			if (this.Queue.Count == 0)
             {
                 return;
             }

+ 37 - 21
Unity/Assets/Scripts/Module/Message/Network/KCP/KService.cs

@@ -32,7 +32,9 @@ namespace ETModel
 		private readonly HashSet<long> updateChannels = new HashSet<long>();
 
 		// 下次时间更新的channel
-		private readonly MultiMap<long, long> timerMap = new MultiMap<long, long>();
+		private readonly MultiMap<long, long> timerId = new MultiMap<long, long>();
+
+		private readonly List<long> timeOutId = new List<long>();
 
 		public KService(IPEndPoint ipEndPoint)
 		{
@@ -240,7 +242,7 @@ namespace ETModel
 
 		public void AddToNextTimeUpdate(long time, long id)
 		{
-			this.timerMap.Add(time, id);
+			this.timerId.Add(time, id);
 		}
 
 		public override AChannel GetChannel(long id)
@@ -280,26 +282,8 @@ namespace ETModel
 
 		public override void Update()
 		{
-			this.TimeNow = (uint)TimeHelper.Now();
+			this.TimerOut();
 
-			while (true)
-			{
-				if (this.timerMap.Count <= 0)
-				{
-					break;
-				}
-				var kv = this.timerMap.First();
-				if (kv.Key > TimeNow)
-				{
-					break;
-				}
-				List<long> timeOutId = kv.Value;
-				foreach (long id in timeOutId)
-				{
-					this.updateChannels.Add(id);
-				}
-				this.timerMap.Remove(kv.Key);
-			}
 			foreach (long id in updateChannels)
 			{
 				KChannel kChannel;
@@ -325,5 +309,37 @@ namespace ETModel
 				this.idChannels.Remove(id);
 			}
 		}
+
+		// 计算到期需要update的channel
+		private void TimerOut()
+		{
+			if (this.timerId.Count == 0)
+			{
+				return;
+			}
+
+			this.TimeNow = (uint)TimeHelper.ClientNow();
+
+			timeOutId.Clear();
+
+			while (this.timerId.Count > 0)
+			{
+				long k = this.timerId.FirstKey();
+				if (k > this.TimeNow)
+				{
+					break;
+				}
+				foreach (long ll in this.timerId[k])
+				{
+					this.timeOutId.Add(ll);
+				}
+				this.timerId.Remove(k);
+			}
+
+			foreach (long k in this.timeOutId)
+			{
+				this.updateChannels.Add(k);
+			}
+		}
 	}
 }

+ 60 - 60
Unity/Assets/Scripts/Module/Message/Network/KCP/Kcp.cs

@@ -88,8 +88,8 @@ public class Kcp
 	public static T[] slice<T>(T[] p, int start, int stop)
 	{
 		var arr = new T[stop - start];
-		var index = 0;
-		for (var i = start; i < stop; i++)
+		int index = 0;
+		for (int i = start; i < stop; i++)
 		{
 			arr[index] = p[i];
 			index++;
@@ -109,7 +109,7 @@ public class Kcp
 	public static T[] append<T>(T[] p, T c)
 	{
 		var arr = new T[p.Length + 1];
-		for (var i = 0; i < p.Length; i++)
+		for (int i = 0; i < p.Length; i++)
 			arr[i] = p[i];
 		arr[p.Length] = c;
 		return arr;
@@ -118,9 +118,9 @@ public class Kcp
 	public static T[] append<T>(T[] p, T[] cs)
 	{
 		var arr = new T[p.Length + cs.Length];
-		for (var i = 0; i < p.Length; i++)
+		for (int i = 0; i < p.Length; i++)
 			arr[i] = p[i];
-		for (var i = 0; i < cs.Length; i++)
+		for (int i = 0; i < cs.Length; i++)
 			arr[p.Length + i] = cs[i];
 		return arr;
 	}
@@ -169,7 +169,7 @@ public class Kcp
 		// encode a segment into buffer
 		internal int encode(byte[] ptr, int offset)
 		{
-			var offset_ = offset;
+			int offset_ = offset;
 
 			offset += ikcp_encode32u(ptr, offset, conv);
 			offset += ikcp_encode8u(ptr, offset, (byte)cmd);
@@ -259,7 +259,7 @@ public class Kcp
 		if (0 == rcv_queue.Length)
 			return -1;
 
-		var seq = rcv_queue[0];
+		Segment seq = rcv_queue[0];
 
 		if (0 == seq.frg)
 			return seq.data.Length;
@@ -269,7 +269,7 @@ public class Kcp
 
 		int length = 0;
 
-		foreach (var item in rcv_queue)
+		foreach (Segment item in rcv_queue)
 		{
 			length += item.data.Length;
 			if (0 == item.frg)
@@ -285,21 +285,21 @@ public class Kcp
 		if (0 == rcv_queue.Length)
 			return -1;
 
-		var peekSize = PeekSize();
+		int peekSize = PeekSize();
 		if (0 > peekSize)
 			return -2;
 
 		if (peekSize > buffer.Length)
 			return -3;
 
-		var fast_recover = false;
+		bool fast_recover = false;
 		if (rcv_queue.Length >= rcv_wnd)
 			fast_recover = true;
 
 		// merge fragment.
-		var count = 0;
-		var n = 0;
-		foreach (var seg in rcv_queue)
+		int count = 0;
+		int n = 0;
+		foreach (Segment seg in rcv_queue)
 		{
 			Array.Copy(seg.data, 0, buffer, n, seg.data.Length);
 			n += seg.data.Length;
@@ -313,7 +313,7 @@ public class Kcp
 
 		// move available data from rcv_buf -> rcv_queue
 		count = 0;
-		foreach (var seg in rcv_buf)
+		foreach (Segment seg in rcv_buf)
 			if (seg.sn == this.rcv_nxt && this.rcv_queue.Length < this.rcv_wnd)
 			{
 				this.rcv_queue = append(this.rcv_queue, seg);
@@ -346,7 +346,7 @@ public class Kcp
 			return -1;
 		}
 
-		var count = 0;
+		int count = 0;
 
 		if (length < mss)
 			count = 1;
@@ -359,17 +359,17 @@ public class Kcp
 		if (0 == count)
 			count = 1;
 
-		var offset = 0;
+		int offset = 0;
 
-		for (var i = 0; i < count; i++)
+		for (int i = 0; i < count; i++)
 		{
-			var size = 0;
+			int size = 0;
 			if (length - offset > mss)
 				size = (int)mss;
 			else
 				size = length - offset;
 
-			var seg = new Segment(size);
+			Segment seg = new Segment(size);
 			Array.Copy(bytes, offset + index, seg.data, 0, size);
 			offset += size;
 			seg.frg = (UInt32)(count - i - 1);
@@ -399,7 +399,7 @@ public class Kcp
 				rx_srtt = 1;
 		}
 
-		var rto = (int)(rx_srtt + _imax_(1, 4 * rx_rttval));
+		int rto = (int)(rx_srtt + _imax_(1, 4 * rx_rttval));
 		rx_rto = _ibound_(rx_minrto, (UInt32)rto, IKCP_RTO_MAX);
 	}
 
@@ -416,8 +416,8 @@ public class Kcp
 		if (_itimediff(sn, snd_una) < 0 || _itimediff(sn, snd_nxt) >= 0)
 			return;
 
-		var index = 0;
-		foreach (var seg in snd_buf)
+		int index = 0;
+		foreach (Segment seg in snd_buf)
 		{
 			if (sn == seg.sn)
 			{
@@ -432,8 +432,8 @@ public class Kcp
 
 	private void parse_una(UInt32 una)
 	{
-		var count = 0;
-		foreach (var seg in snd_buf)
+		int count = 0;
+		foreach (Segment seg in snd_buf)
 			if (_itimediff(una, seg.sn) > 0)
 				count++;
 			else
@@ -456,16 +456,16 @@ public class Kcp
 
 	private void parse_data(Segment newseg)
 	{
-		var sn = newseg.sn;
+		uint sn = newseg.sn;
 		if (_itimediff(sn, rcv_nxt + rcv_wnd) >= 0 || _itimediff(sn, rcv_nxt) < 0)
 			return;
 
-		var n = rcv_buf.Length - 1;
-		var after_idx = -1;
-		var repeat = false;
-		for (var i = n; i >= 0; i--)
+		int n = rcv_buf.Length - 1;
+		int after_idx = -1;
+		bool repeat = false;
+		for (int i = n; i >= 0; i--)
 		{
-			var seg = rcv_buf[i];
+			Segment seg = rcv_buf[i];
 			if (seg.sn == sn)
 			{
 				repeat = true;
@@ -487,8 +487,8 @@ public class Kcp
 									  append(new Segment[1] { newseg }, slice(this.rcv_buf, after_idx + 1, this.rcv_buf.Length)));
 
 		// move available data from rcv_buf -> rcv_queue
-		var count = 0;
-		foreach (var seg in rcv_buf)
+		int count = 0;
+		foreach (Segment seg in rcv_buf)
 			if (seg.sn == this.rcv_nxt && this.rcv_queue.Length < this.rcv_wnd)
 			{
 				this.rcv_queue = append(this.rcv_queue, seg);
@@ -507,11 +507,11 @@ public class Kcp
 	// when you received a low level packet (eg. UDP packet), call it
 	public int Input(byte[] data)
 	{
-		var s_una = snd_una;
+		uint s_una = snd_una;
 		if (data.Length < IKCP_OVERHEAD)
 			return 0;
 
-		var offset = 0;
+		int offset = 0;
 
 		while (true)
 		{
@@ -575,7 +575,7 @@ public class Kcp
 					ack_push(sn, ts);
 					if (_itimediff(sn, rcv_nxt) >= 0)
 					{
-						var seg = new Segment((int)length);
+						Segment seg = new Segment((int)length);
 						seg.conv = conv_;
 						seg.cmd = cmd;
 						seg.frg = frg;
@@ -612,7 +612,7 @@ public class Kcp
 		if (_itimediff(snd_una, s_una) > 0)
 			if (this.cwnd < this.rmt_wnd)
 			{
-				var mss_ = this.mss;
+				uint mss_ = this.mss;
 				if (this.cwnd < this.ssthresh)
 				{
 					this.cwnd++;
@@ -646,24 +646,24 @@ public class Kcp
 	// flush pending data
 	private void flush()
 	{
-		var current_ = current;
+		uint current_ = current;
 		var buffer_ = buffer;
-		var change = 0;
-		var lost = 0;
+		int change = 0;
+		int lost = 0;
 
 		if (0 == updated)
 			return;
 
-		var seg = new Segment(0);
+		Segment seg = new Segment(0);
 		seg.conv = conv;
 		seg.cmd = IKCP_CMD_ACK;
 		seg.wnd = (UInt32)wnd_unused();
 		seg.una = rcv_nxt;
 
 		// flush acknowledges
-		var count = acklist.Length / 2;
-		var offset = 0;
-		for (var i = 0; i < count; i++)
+		int count = acklist.Length / 2;
+		int offset = 0;
+		for (int i = 0; i < count; i++)
 		{
 			if (offset + IKCP_OVERHEAD > mtu)
 			{
@@ -720,17 +720,17 @@ public class Kcp
 		probe = 0;
 
 		// calculate window size
-		var cwnd_ = _imin_(snd_wnd, rmt_wnd);
+		uint cwnd_ = _imin_(snd_wnd, rmt_wnd);
 		if (0 == nocwnd)
 			cwnd_ = _imin_(cwnd, cwnd_);
 
 		count = 0;
-		for (var k = 0; k < snd_queue.Length; k++)
+		for (int k = 0; k < snd_queue.Length; k++)
 		{
 			if (_itimediff(snd_nxt, snd_una + cwnd_) >= 0)
 				break;
 
-			var newseg = snd_queue[k];
+			Segment newseg = snd_queue[k];
 			newseg.conv = conv;
 			newseg.cmd = IKCP_CMD_PUSH;
 			newseg.wnd = seg.wnd;
@@ -750,18 +750,18 @@ public class Kcp
 			this.snd_queue = slice(this.snd_queue, count, this.snd_queue.Length);
 
 		// calculate resent
-		var resent = (UInt32)fastresend;
+		uint resent = (UInt32)fastresend;
 		if (fastresend <= 0)
 			resent = 0xffffffff;
-		var rtomin = rx_rto >> 3;
+		uint rtomin = rx_rto >> 3;
 		if (nodelay != 0)
 			rtomin = 0;
 
 		// flush data segments
-		foreach (var segment in snd_buf)
+		foreach (Segment segment in snd_buf)
 		{
-			var needsend = false;
-			var debug = _itimediff(current_, segment.resendts);
+			bool needsend = false;
+			int debug = _itimediff(current_, segment.resendts);
 			if (0 == segment.xmit)
 			{
 				needsend = true;
@@ -796,7 +796,7 @@ public class Kcp
 				segment.wnd = seg.wnd;
 				segment.una = rcv_nxt;
 
-				var need = IKCP_OVERHEAD + segment.data.Length;
+				int need = IKCP_OVERHEAD + segment.data.Length;
 				if (offset + need > mtu)
 				{
 					output(buffer, offset);
@@ -827,7 +827,7 @@ public class Kcp
 		// update ssthresh
 		if (change != 0)
 		{
-			var inflight = snd_nxt - snd_una;
+			uint inflight = snd_nxt - snd_una;
 			ssthresh = inflight / 2;
 			if (ssthresh < IKCP_THRESH_MIN)
 				ssthresh = IKCP_THRESH_MIN;
@@ -864,7 +864,7 @@ public class Kcp
 			ts_flush = current;
 		}
 
-		var slap = _itimediff(current, ts_flush);
+		int slap = _itimediff(current, ts_flush);
 
 		if (slap >= 10000 || slap < -10000)
 		{
@@ -893,10 +893,10 @@ public class Kcp
 		if (0 == updated)
 			return current_;
 
-		var ts_flush_ = ts_flush;
-		var tm_flush_ = 0x7fffffff;
-		var tm_packet = 0x7fffffff;
-		var minimal = 0;
+		uint ts_flush_ = ts_flush;
+		int tm_flush_ = 0x7fffffff;
+		int tm_packet = 0x7fffffff;
+		int minimal = 0;
 
 		if (_itimediff(current_, ts_flush_) >= 10000 || _itimediff(current_, ts_flush_) < -10000)
 			ts_flush_ = current_;
@@ -906,9 +906,9 @@ public class Kcp
 
 		tm_flush_ = _itimediff(ts_flush_, current_);
 
-		foreach (var seg in snd_buf)
+		foreach (Segment seg in snd_buf)
 		{
-			var diff = _itimediff(seg.resendts, current_);
+			int diff = _itimediff(seg.resendts, current_);
 			if (diff <= 0)
 				return current_;
 			if (diff < tm_packet)

+ 1 - 1
Unity/Assets/Scripts/UI/UILoading/Factory/UILoadingFactory.cs

@@ -10,7 +10,7 @@ namespace ETModel
         {
 	        try
 	        {
-				GameObject bundleGameObject = ((GameObject)Resources.Load("KV")).Get<GameObject>(type);
+				GameObject bundleGameObject = ((GameObject)ResourcesHelper.Load("KV")).Get<GameObject>(type);
 				GameObject go = UnityEngine.Object.Instantiate(bundleGameObject);
 				go.layer = LayerMask.NameToLayer(LayerNames.UI);
 				UI ui = ComponentFactory.Create<UI, GameObject>(go);

+ 7 - 5
Unity/Assets/ThirdParty/ILRuntime/Generated/CLRBindings.cs

@@ -42,6 +42,7 @@ namespace ILRuntime.Runtime.Generated
             VInt3_Binding.Register(app);
             ETModel_PlayerComponent_Binding.Register(app);
             ETModel_Player_Binding.Register(app);
+            ETModel_ComponentWithId_Binding.Register(app);
             ETModel_CameraComponent_Binding.Register(app);
             System_IDisposable_Binding.Register(app);
             ETModel_Actor_Test_Binding.Register(app);
@@ -53,22 +54,23 @@ namespace ILRuntime.Runtime.Generated
             System_Activator_Binding.Register(app);
             ETModel_GameObjectHelper_Binding.Register(app);
             UnityEngine_TextAsset_Binding.Register(app);
-            //UnityEngine_Resources_Binding.Register(app);
-            System_Object_Binding.Register(app);
+            ETModel_IdGenerater_Binding.Register(app);
             System_Collections_Generic_HashSet_1_ILTypeInstance_Binding.Register(app);
+            System_Object_Binding.Register(app);
             System_Linq_Enumerable_Binding.Register(app);
             System_Collections_Generic_HashSet_1_ILTypeInstance_Binding_Enumerator_Binding.Register(app);
-            ETModel_IdGenerater_Binding.Register(app);
             System_Collections_Generic_List_1_Object_Binding.Register(app);
             System_Collections_Generic_Dictionary_2_String_List_1_ILTypeInstance_Binding.Register(app);
             System_Collections_Generic_List_1_ILTypeInstance_Binding.Register(app);
+            System_Collections_Generic_Dictionary_2_Int64_ILTypeInstance_Binding.Register(app);
             ETModel_UnOrderMultiMap_2_Type_ILTypeInstance_Binding.Register(app);
-            System_Collections_Generic_Queue_1_ILTypeInstance_Binding.Register(app);
+            System_Collections_Generic_Queue_1_Int64_Binding.Register(app);
             System_Collections_Generic_List_1_ILTypeInstance_Binding_Enumerator_Binding.Register(app);
             ETModel_AEventAttribute_Binding.Register(app);
             ETModel_EventProxy_Binding.Register(app);
             ETModel_EventSystem_Binding.Register(app);
             System_Collections_Generic_Dictionary_2_Type_Queue_1_ILTypeInstance_Binding.Register(app);
+            System_Collections_Generic_Queue_1_ILTypeInstance_Binding.Register(app);
             ETModel_Packet_Binding.Register(app);
             ETModel_ProtobufHelper_Binding.Register(app);
             System_Collections_Generic_Dictionary_2_Int32_Action_1_ILTypeInstance_Binding.Register(app);
@@ -90,6 +92,7 @@ namespace ILRuntime.Runtime.Generated
             ETModel_CanvasConfig_Binding.Register(app);
             UnityEngine_Transform_Binding.Register(app);
             System_Collections_Generic_List_1_String_Binding.Register(app);
+            ETModel_Component_Binding.Register(app);
             ETModel_Scene_Binding.Register(app);
             UnityEngine_Object_Binding.Register(app);
             System_Collections_Generic_Dictionary_2_String_ILTypeInstance_Binding_ValueCollection_Binding.Register(app);
@@ -109,7 +112,6 @@ namespace ILRuntime.Runtime.Generated
             UnityEngine_UI_InputField_Binding.Register(app);
             ETModel_NetworkComponent_Binding.Register(app);
             ETModel_ComponentFactory_Binding.Register(app);
-            System_Collections_Generic_Dictionary_2_Int64_ILTypeInstance_Binding.Register(app);
         }
     }
 }

+ 53 - 0
Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_ComponentWithId_Binding.cs

@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+using ILRuntime.CLR.TypeSystem;
+using ILRuntime.CLR.Method;
+using ILRuntime.Runtime.Enviorment;
+using ILRuntime.Runtime.Intepreter;
+using ILRuntime.Runtime.Stack;
+using ILRuntime.Reflection;
+using ILRuntime.CLR.Utils;
+
+namespace ILRuntime.Runtime.Generated
+{
+    unsafe class ETModel_ComponentWithId_Binding
+    {
+        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
+        {
+            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
+            MethodBase method;
+            FieldInfo field;
+            Type[] args;
+            Type type = typeof(ETModel.ComponentWithId);
+            args = new Type[]{};
+            method = type.GetMethod("get_Id", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, get_Id_0);
+
+
+        }
+
+
+        static StackObject* get_Id_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* ptr_of_this_method;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 1);
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
+            ETModel.ComponentWithId instance_of_this_method;
+            instance_of_this_method = (ETModel.ComponentWithId)typeof(ETModel.ComponentWithId).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            __intp.Free(ptr_of_this_method);
+
+            var result_of_this_method = instance_of_this_method.Id;
+
+            __ret->ObjectType = ObjectTypes.Long;
+            *(long*)&__ret->Value = result_of_this_method;
+            return __ret + 1;
+        }
+
+
+
+    }
+}

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_Disposer_Binding.cs.meta → Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_ComponentWithId_Binding.cs.meta

@@ -1,6 +1,6 @@
 fileFormatVersion: 2
-guid: d61ffdec0a7f0264ab9932cf164ba5cb
-timeCreated: 1520320314
+guid: b812c5d2e1eabc140882336a19577ae3
+timeCreated: 1521630297
 licenseType: Free
 MonoImporter:
   serializedVersion: 2

+ 31 - 0
Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_Component_Binding.cs

@@ -15,6 +15,37 @@ namespace ILRuntime.Runtime.Generated
 {
     unsafe class ETModel_Component_Binding
     {
+        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
+        {
+            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
+            MethodBase method;
+            FieldInfo field;
+            Type[] args;
+            Type type = typeof(ETModel.Component);
+            args = new Type[]{};
+            method = type.GetMethod("Dispose", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, Dispose_0);
+
+
+        }
+
+
+        static StackObject* Dispose_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* ptr_of_this_method;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 1);
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
+            ETModel.Component instance_of_this_method;
+            instance_of_this_method = (ETModel.Component)typeof(ETModel.Component).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            __intp.Free(ptr_of_this_method);
+
+            instance_of_this_method.Dispose();
+
+            return __ret;
+        }
+
+
 
     }
 }

+ 0 - 20
Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_Disposer_Binding.cs

@@ -1,20 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-using ILRuntime.CLR.TypeSystem;
-using ILRuntime.CLR.Method;
-using ILRuntime.Runtime.Enviorment;
-using ILRuntime.Runtime.Intepreter;
-using ILRuntime.Runtime.Stack;
-using ILRuntime.Reflection;
-using ILRuntime.CLR.Utils;
-
-namespace ILRuntime.Runtime.Generated
-{
-    unsafe class ETModel_Disposer_Binding
-    {
-
-    }
-}

+ 26 - 4
Unity/Assets/ThirdParty/ILRuntime/Generated/System_Collections_Generic_Dictionary_2_Int64_ILTypeInstance_B_t.cs

@@ -25,12 +25,15 @@ namespace ILRuntime.Runtime.Generated
             args = new Type[]{typeof(System.Int64), typeof(ILRuntime.Runtime.Intepreter.ILTypeInstance)};
             method = type.GetMethod("Add", flag, null, args, null);
             app.RegisterCLRMethodRedirection(method, Add_0);
+            args = new Type[]{typeof(System.Int64)};
+            method = type.GetMethod("Remove", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, Remove_1);
             args = new Type[]{typeof(System.Int64), typeof(ILRuntime.Runtime.Intepreter.ILTypeInstance).MakeByRefType()};
             method = type.GetMethod("TryGetValue", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, TryGetValue_1);
+            app.RegisterCLRMethodRedirection(method, TryGetValue_2);
             args = new Type[]{};
             method = type.GetMethod("get_Values", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, get_Values_2);
+            app.RegisterCLRMethodRedirection(method, get_Values_3);
 
             args = new Type[]{};
             method = type.GetConstructor(flag, null, args, null);
@@ -59,7 +62,26 @@ namespace ILRuntime.Runtime.Generated
             return __ret;
         }
 
-        static StackObject* TryGetValue_1(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        static StackObject* Remove_1(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* ptr_of_this_method;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 2);
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
+            System.Int64 key = *(long*)&ptr_of_this_method->Value;
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
+            System.Collections.Generic.Dictionary<System.Int64, ILRuntime.Runtime.Intepreter.ILTypeInstance> instance_of_this_method;
+            instance_of_this_method = (System.Collections.Generic.Dictionary<System.Int64, ILRuntime.Runtime.Intepreter.ILTypeInstance>)typeof(System.Collections.Generic.Dictionary<System.Int64, ILRuntime.Runtime.Intepreter.ILTypeInstance>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            __intp.Free(ptr_of_this_method);
+
+            var result_of_this_method = instance_of_this_method.Remove(key);
+
+            __ret->ObjectType = ObjectTypes.Integer;
+            __ret->Value = result_of_this_method ? 1 : 0;
+            return __ret + 1;
+        }
+
+        static StackObject* TryGetValue_2(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
         {
             ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
             StackObject* ptr_of_this_method;
@@ -135,7 +157,7 @@ namespace ILRuntime.Runtime.Generated
             return __ret + 1;
         }
 
-        static StackObject* get_Values_2(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        static StackObject* get_Values_3(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
         {
             ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
             StackObject* ptr_of_this_method;

+ 19 - 19
Unity/Assets/ThirdParty/ILRuntime/Generated/System_Collections_Generic_Queue_1_ILTypeInstance_Binding.cs

@@ -22,15 +22,15 @@ namespace ILRuntime.Runtime.Generated
             FieldInfo field;
             Type[] args;
             Type type = typeof(System.Collections.Generic.Queue<ILRuntime.Runtime.Intepreter.ILTypeInstance>);
-            args = new Type[]{typeof(ILRuntime.Runtime.Intepreter.ILTypeInstance)};
-            method = type.GetMethod("Enqueue", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, Enqueue_0);
+            args = new Type[]{};
+            method = type.GetMethod("get_Count", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, get_Count_0);
             args = new Type[]{};
             method = type.GetMethod("Dequeue", flag, null, args, null);
             app.RegisterCLRMethodRedirection(method, Dequeue_1);
-            args = new Type[]{};
-            method = type.GetMethod("get_Count", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, get_Count_2);
+            args = new Type[]{typeof(ILRuntime.Runtime.Intepreter.ILTypeInstance)};
+            method = type.GetMethod("Enqueue", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, Enqueue_2);
 
             args = new Type[]{};
             method = type.GetConstructor(flag, null, args, null);
@@ -39,22 +39,21 @@ namespace ILRuntime.Runtime.Generated
         }
 
 
-        static StackObject* Enqueue_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        static StackObject* get_Count_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
         {
             ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
             StackObject* ptr_of_this_method;
-            StackObject* __ret = ILIntepreter.Minus(__esp, 2);
+            StackObject* __ret = ILIntepreter.Minus(__esp, 1);
             ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
-            ILRuntime.Runtime.Intepreter.ILTypeInstance item = (ILRuntime.Runtime.Intepreter.ILTypeInstance)typeof(ILRuntime.Runtime.Intepreter.ILTypeInstance).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
-            __intp.Free(ptr_of_this_method);
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
             System.Collections.Generic.Queue<ILRuntime.Runtime.Intepreter.ILTypeInstance> instance_of_this_method;
             instance_of_this_method = (System.Collections.Generic.Queue<ILRuntime.Runtime.Intepreter.ILTypeInstance>)typeof(System.Collections.Generic.Queue<ILRuntime.Runtime.Intepreter.ILTypeInstance>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
             __intp.Free(ptr_of_this_method);
 
-            instance_of_this_method.Enqueue(item);
+            var result_of_this_method = instance_of_this_method.Count;
 
-            return __ret;
+            __ret->ObjectType = ObjectTypes.Integer;
+            __ret->Value = result_of_this_method;
+            return __ret + 1;
         }
 
         static StackObject* Dequeue_1(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
@@ -72,21 +71,22 @@ namespace ILRuntime.Runtime.Generated
             return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
         }
 
-        static StackObject* get_Count_2(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        static StackObject* Enqueue_2(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
         {
             ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
             StackObject* ptr_of_this_method;
-            StackObject* __ret = ILIntepreter.Minus(__esp, 1);
+            StackObject* __ret = ILIntepreter.Minus(__esp, 2);
             ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
+            ILRuntime.Runtime.Intepreter.ILTypeInstance item = (ILRuntime.Runtime.Intepreter.ILTypeInstance)typeof(ILRuntime.Runtime.Intepreter.ILTypeInstance).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            __intp.Free(ptr_of_this_method);
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
             System.Collections.Generic.Queue<ILRuntime.Runtime.Intepreter.ILTypeInstance> instance_of_this_method;
             instance_of_this_method = (System.Collections.Generic.Queue<ILRuntime.Runtime.Intepreter.ILTypeInstance>)typeof(System.Collections.Generic.Queue<ILRuntime.Runtime.Intepreter.ILTypeInstance>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
             __intp.Free(ptr_of_this_method);
 
-            var result_of_this_method = instance_of_this_method.Count;
+            instance_of_this_method.Enqueue(item);
 
-            __ret->ObjectType = ObjectTypes.Integer;
-            __ret->Value = result_of_this_method;
-            return __ret + 1;
+            return __ret;
         }
 
 

+ 107 - 0
Unity/Assets/ThirdParty/ILRuntime/Generated/System_Collections_Generic_Queue_1_Int64_Binding.cs

@@ -0,0 +1,107 @@
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+using ILRuntime.CLR.TypeSystem;
+using ILRuntime.CLR.Method;
+using ILRuntime.Runtime.Enviorment;
+using ILRuntime.Runtime.Intepreter;
+using ILRuntime.Runtime.Stack;
+using ILRuntime.Reflection;
+using ILRuntime.CLR.Utils;
+
+namespace ILRuntime.Runtime.Generated
+{
+    unsafe class System_Collections_Generic_Queue_1_Int64_Binding
+    {
+        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
+        {
+            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
+            MethodBase method;
+            FieldInfo field;
+            Type[] args;
+            Type type = typeof(System.Collections.Generic.Queue<System.Int64>);
+            args = new Type[]{typeof(System.Int64)};
+            method = type.GetMethod("Enqueue", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, Enqueue_0);
+            args = new Type[]{};
+            method = type.GetMethod("Dequeue", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, Dequeue_1);
+            args = new Type[]{};
+            method = type.GetMethod("get_Count", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, get_Count_2);
+
+            args = new Type[]{};
+            method = type.GetConstructor(flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, Ctor_0);
+
+        }
+
+
+        static StackObject* Enqueue_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* ptr_of_this_method;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 2);
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
+            System.Int64 item = *(long*)&ptr_of_this_method->Value;
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
+            System.Collections.Generic.Queue<System.Int64> instance_of_this_method;
+            instance_of_this_method = (System.Collections.Generic.Queue<System.Int64>)typeof(System.Collections.Generic.Queue<System.Int64>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            __intp.Free(ptr_of_this_method);
+
+            instance_of_this_method.Enqueue(item);
+
+            return __ret;
+        }
+
+        static StackObject* Dequeue_1(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* ptr_of_this_method;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 1);
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
+            System.Collections.Generic.Queue<System.Int64> instance_of_this_method;
+            instance_of_this_method = (System.Collections.Generic.Queue<System.Int64>)typeof(System.Collections.Generic.Queue<System.Int64>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            __intp.Free(ptr_of_this_method);
+
+            var result_of_this_method = instance_of_this_method.Dequeue();
+
+            __ret->ObjectType = ObjectTypes.Long;
+            *(long*)&__ret->Value = result_of_this_method;
+            return __ret + 1;
+        }
+
+        static StackObject* get_Count_2(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* ptr_of_this_method;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 1);
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
+            System.Collections.Generic.Queue<System.Int64> instance_of_this_method;
+            instance_of_this_method = (System.Collections.Generic.Queue<System.Int64>)typeof(System.Collections.Generic.Queue<System.Int64>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            __intp.Free(ptr_of_this_method);
+
+            var result_of_this_method = instance_of_this_method.Count;
+
+            __ret->ObjectType = ObjectTypes.Integer;
+            __ret->Value = result_of_this_method;
+            return __ret + 1;
+        }
+
+
+        static StackObject* Ctor_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* ptr_of_this_method;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 0);
+
+            var result_of_this_method = new System.Collections.Generic.Queue<System.Int64>();
+
+            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
+        }
+
+
+    }
+}

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/Generated/UnityEngine_Resources_Binding.cs.meta → Unity/Assets/ThirdParty/ILRuntime/Generated/System_Collections_Generic_Queue_1_Int64_Binding.cs.meta

@@ -1,6 +1,6 @@
 fileFormatVersion: 2
-guid: 668a581bb061d7f4eb90186f63b77872
-timeCreated: 1520320313
+guid: 6a5a679b70528584d831b66117f59557
+timeCreated: 1521630297
 licenseType: Free
 MonoImporter:
   serializedVersion: 2

+ 2 - 20
Unity/Assets/ThirdParty/ILRuntime/Generated/System_Object_Binding.cs

@@ -23,32 +23,14 @@ namespace ILRuntime.Runtime.Generated
             Type[] args;
             Type type = typeof(System.Object);
             args = new Type[]{};
-            method = type.GetMethod("ToString", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, ToString_0);
-            args = new Type[]{};
             method = type.GetMethod("GetType", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, GetType_1);
+            app.RegisterCLRMethodRedirection(method, GetType_0);
 
 
         }
 
 
-        static StackObject* ToString_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
-        {
-            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
-            StackObject* ptr_of_this_method;
-            StackObject* __ret = ILIntepreter.Minus(__esp, 1);
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
-            System.Object instance_of_this_method;
-            instance_of_this_method = (System.Object)typeof(System.Object).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
-            __intp.Free(ptr_of_this_method);
-
-            var result_of_this_method = instance_of_this_method.ToString();
-
-            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
-        }
-
-        static StackObject* GetType_1(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        static StackObject* GetType_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
         {
             ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
             StackObject* ptr_of_this_method;

+ 0 - 55
Unity/Assets/ThirdParty/ILRuntime/Generated/UnityEngine_Resources_Binding.cs

@@ -1,55 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-using ILRuntime.CLR.TypeSystem;
-using ILRuntime.CLR.Method;
-using ILRuntime.Runtime.Enviorment;
-using ILRuntime.Runtime.Intepreter;
-using ILRuntime.Runtime.Stack;
-using ILRuntime.Reflection;
-using ILRuntime.CLR.Utils;
-
-namespace ILRuntime.Runtime.Generated
-{
-    unsafe class UnityEngine_Resources_Binding
-    {
-        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
-        {
-            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
-            MethodBase method;
-            FieldInfo field;
-            Type[] args;
-            Type type = typeof(UnityEngine.Resources);
-            args = new Type[]{typeof(System.String)};
-            method = type.GetMethod("Load", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, Load_0);
-
-
-        }
-
-
-        static StackObject* Load_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
-        {
-            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
-            StackObject* ptr_of_this_method;
-            StackObject* __ret = ILIntepreter.Minus(__esp, 1);
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
-            System.String path = (System.String)typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
-            __intp.Free(ptr_of_this_method);
-
-            var result_of_this_method = UnityEngine.Resources.Load(path);
-
-            object obj_result_of_this_method = result_of_this_method;
-            if(obj_result_of_this_method is CrossBindingAdaptorType)
-            {    
-                return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance);
-            }
-            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
-        }
-
-
-
-    }
-}

+ 0 - 14
Unity/Hotfix/Module/Config/ConfigHelper.cs

@@ -19,20 +19,6 @@ namespace ETHotfix
 				throw new Exception($"load config file fail, key: {key}", e);
 			}
 		}
-		
-		public static string GetGlobal()
-		{
-			try
-			{
-				GameObject config = (GameObject)Resources.Load("KV");
-				string configStr = config.Get<TextAsset>("GlobalProto").text;
-				return configStr;
-			}
-			catch (Exception e)
-			{
-				throw new Exception($"load global config file fail", e);
-			}
-		}
 
 		public static T ToObject<T>(string str)
 		{

+ 9 - 12
Unity/Unity.csproj

@@ -12,15 +12,12 @@
     <ProjectTypeGuids>{E097FAD1-6243-4DAD-9C02-E9B9EFC3FFC1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
     <TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
     <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
-    <TargetFrameworkProfile>
-    </TargetFrameworkProfile>
-    <CompilerResponseFile>
-    </CompilerResponseFile>
+    <TargetFrameworkProfile></TargetFrameworkProfile>
+    <CompilerResponseFile></CompilerResponseFile>
     <UnityProjectType>Game:1</UnityProjectType>
     <UnityBuildTarget>StandaloneWindows:5</UnityBuildTarget>
     <UnityVersion>2017.1.1p4</UnityVersion>
-    <RootNamespace>
-    </RootNamespace>
+    <RootNamespace></RootNamespace>
     <LangVersion>6</LangVersion>
   </PropertyGroup>
   <PropertyGroup>
@@ -156,11 +153,11 @@
     <Compile Include="Assets\Scripts\Base\Math\VLine.cs" />
     <Compile Include="Assets\Scripts\Base\Math\VRect.cs" />
     <Compile Include="Assets\Scripts\Base\MultiMap.cs" />
-    <Compile Include="Assets\Scripts\Base\Object\ComponentWithIdAttribute.cs" />
-    <Compile Include="Assets\Scripts\Base\Object\ComponentWithId.cs" />
     <Compile Include="Assets\Scripts\Base\Object\Component.cs" />
     <Compile Include="Assets\Scripts\Base\Object\ComponentAttribute.cs" />
     <Compile Include="Assets\Scripts\Base\Object\ComponentFactory.cs" />
+    <Compile Include="Assets\Scripts\Base\Object\ComponentWithId.cs" />
+    <Compile Include="Assets\Scripts\Base\Object\ComponentWithIdAttribute.cs" />
     <Compile Include="Assets\Scripts\Base\Object\Entity.cs" />
     <Compile Include="Assets\Scripts\Base\Object\EntityAttribute.cs" />
     <Compile Include="Assets\Scripts\Base\Object\EntityEventAttribute.cs" />
@@ -168,8 +165,8 @@
     <Compile Include="Assets\Scripts\Base\Object\EventProxy.cs" />
     <Compile Include="Assets\Scripts\Base\Object\EventSystem.cs" />
     <Compile Include="Assets\Scripts\Base\Object\IAwakeSystem.cs" />
-    <Compile Include="Assets\Scripts\Base\Object\ILateUpdateSystem.cs" />
     <Compile Include="Assets\Scripts\Base\Object\IDestroySystem.cs" />
+    <Compile Include="Assets\Scripts\Base\Object\ILateUpdateSystem.cs" />
     <Compile Include="Assets\Scripts\Base\Object\ILoadSystem.cs" />
     <Compile Include="Assets\Scripts\Base\Object\ISerializeToEntity.cs" />
     <Compile Include="Assets\Scripts\Base\Object\IStartSystem.cs" />
@@ -357,7 +354,7 @@
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_CanvasConfig_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_Component_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_ComponentFactory_Binding.cs" />
-    <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_Disposer_Binding.cs" />
+    <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_ComponentWithId_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_DoubleMap_2_UInt16_Type_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_Entity_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\ETModel_EventProxy_Binding.cs" />
@@ -416,6 +413,7 @@
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\System_Collections_Generic_List_1_UnitInfo_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\System_Collections_Generic_List_1_UnitInfo_Binding_Enumerator__t.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\System_Collections_Generic_Queue_1_ILTypeInstance_Binding.cs" />
+    <Compile Include="Assets\ThirdParty\ILRuntime\Generated\System_Collections_Generic_Queue_1_Int64_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\System_Collections_IDictionary_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\System_Exception_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\System_IDisposable_Binding.cs" />
@@ -440,7 +438,6 @@
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\UnityEngine_Object_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\UnityEngine_Physics_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\UnityEngine_RaycastHit_Binding.cs" />
-    <Compile Include="Assets\ThirdParty\ILRuntime\Generated\UnityEngine_Resources_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\UnityEngine_TextAsset_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\UnityEngine_Transform_Binding.cs" />
     <Compile Include="Assets\ThirdParty\ILRuntime\Generated\UnityEngine_UI_Button_Binding.cs" />
@@ -785,4 +782,4 @@
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Target Name="GenerateTargetFrameworkMonikerAttribute" />
-</Project>
+</Project>