Explorar el Código

1.MonoPInvokeCallback标签只有IL2CPP才需要
2.修复客户端寻路没有使用到修正速度的bug

tanghai hace 7 años
padre
commit
9ff784f36a

+ 1 - 4
Unity/Assets/Model/Module/Demo/MoveComponent.cs

@@ -24,9 +24,6 @@ namespace ETModel
 		public Vector3 StartPos;
 
 		public long needTime;
-
-		// 当前的移动速度
-		public float Speed = 5;
 		
 		public ETTaskCompletionSource moveTcs;
 
@@ -74,7 +71,7 @@ namespace ETModel
 				return ETTask.CompletedTask;
 			}
             
-			this.needTime = (long)(distance / this.Speed * 1000);
+			this.needTime = (long)(distance / speedValue * 1000);
 			
 			this.moveTcs = new ETTaskCompletionSource();
 			

+ 6 - 10
Unity/Assets/Model/Module/Message/Network/KCP/KChannel.cs

@@ -50,10 +50,7 @@ namespace ETModel
 			this.socket = socket;
 			this.kcp = Kcp.KcpCreate(this.RemoteConn, new IntPtr(this.LocalConn));
 
-            Kcp.KcpSetoutput(
-                this.kcp,
-				Kcp_output
-            );
+            Kcp.KcpSetoutput(this.kcp, KcpOutput);
 			Kcp.KcpNodelay(this.kcp, 1, 10, 1, 1);
 			Kcp.KcpWndsize(this.kcp, 256, 256);
 			Kcp.KcpSetmtu(this.kcp, 470);
@@ -148,10 +145,7 @@ namespace ETModel
 			this.RemoteConn = remoteConn;
 
 			this.kcp = Kcp.KcpCreate(this.RemoteConn, new IntPtr(this.LocalConn));
-			Kcp.KcpSetoutput(
-				this.kcp,
-				Kcp_output
-			);
+			Kcp.KcpSetoutput(this.kcp, KcpOutput);
 			Kcp.KcpNodelay(this.kcp, 1, 10, 1, 1);
 			Kcp.KcpWndsize(this.kcp, 256, 256);
 			Kcp.KcpSetmtu(this.kcp, 470);
@@ -394,8 +388,10 @@ namespace ETModel
 			}
 		}
 
-		[AOT.MonoPInvokeCallback(typeof(kcp_output))]
-		public static int Kcp_output(IntPtr bytes, int len, IntPtr kcp, IntPtr user)
+#if ENABLE_IL2CPP
+		[AOT.MonoPInvokeCallback(typeof(KcpOutput))]
+#endif
+		public static int KcpOutput(IntPtr bytes, int len, IntPtr kcp, IntPtr user)
         {
             KService.Output(bytes, len, user);
             return len;

+ 3 - 5
Unity/Assets/Model/Module/Message/Network/KCP/Kcp.cs

@@ -3,9 +3,7 @@ using System.Runtime.InteropServices;
 
 namespace ETModel
 {
-
-    
-    public delegate int kcp_output(IntPtr buf, int len, IntPtr kcp, IntPtr user);
+    public delegate int KcpOutput(IntPtr buf, int len, IntPtr kcp, IntPtr user);
 
     public class Kcp
     {
@@ -40,7 +38,7 @@ namespace ETModel
         [DllImport(KcpDLL, CallingConvention=CallingConvention.Cdecl)]
         private static extern int ikcp_setmtu(IntPtr kcp, int mtu);
         [DllImport(KcpDLL, CallingConvention=CallingConvention.Cdecl)]
-        private static extern void ikcp_setoutput(IntPtr kcp, kcp_output output);
+        private static extern void ikcp_setoutput(IntPtr kcp, KcpOutput output);
         [DllImport(KcpDLL, CallingConvention=CallingConvention.Cdecl)]
         private static extern void ikcp_update(IntPtr kcp, uint current);
         [DllImport(KcpDLL, CallingConvention=CallingConvention.Cdecl)]
@@ -152,7 +150,7 @@ namespace ETModel
             return ikcp_setmtu(kcp, mtu);
         }
 
-        public static void KcpSetoutput(IntPtr kcp, kcp_output output)
+        public static void KcpSetoutput(IntPtr kcp, KcpOutput output)
         {
             if (kcp == IntPtr.Zero)
             {