This commit is contained in:
DESKTOP-5RP3AKU\Jisol
2024-10-17 02:12:03 +08:00
parent c85f350e0a
commit dd2e0e8a46
16 changed files with 52 additions and 611 deletions

View File

@@ -7,7 +7,7 @@
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"allowUnsafeCode": true,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,

View File

@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Cysharp.Threading.Tasks;
using DotRecast.Core.Collections;
using Google.Protobuf;
using JNGame.Network.Entity;
using JNGame.Network.Util;
@@ -92,10 +91,10 @@ namespace JNGame.Network
if (hId == 0)
{
int size = 0;
_byteSize.ForEach(child =>
foreach (var child in _byteSize)
{
size += child.Value;
});
}
return size;
}
return _byteSize.GetValueOrDefault(hId, 0);

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using DotRecast.Core.Collections;
using JNGame.Runtime.System;
using JNGame.Util;
@@ -61,10 +60,10 @@ namespace JNGame.Network
int size = 0;
try
{
_byteSize.ForEach(child =>
foreach (var child in _byteSize)
{
size += child.Value;
});
}
}
catch (Exception e)
{

View File

@@ -2,7 +2,6 @@
using System;
using System.Threading.Tasks;
using Cysharp.Threading.Tasks;
using DotRecast.Core.Collections;
using Google.Protobuf;
using JNGame.Network.Action;
using JNGame.Network.Entity;
@@ -142,13 +141,13 @@ namespace JNGame.Network
public void AllSend(int hId,IMessage data = null,Func<SocketClient,bool> filter = null)
{
filter ??= (SocketClient client) => true;
service.GetClients().ForEach(client =>
foreach (var client in service.GetClients())
{
if (filter(client))
{
Send(client, hId, data);
}
});
}
}
}

View File

@@ -1,5 +1,4 @@
using System.Collections.Generic;
using DotRecast.Core.Collections;
using JNGame.Math;
using JNGame.Runtime.Util;
using JNGame.Sync.State.Tile;
@@ -38,11 +37,11 @@ namespace JNGame.Sync.Debuger
DrawContains(service.MaxContains,service.MinContains,Color.red);
//绘制连接区域
service.GetLinkTiles().ForEach(index =>
foreach (var linkTile in service.GetLinkTiles())
{
(LVector2 max, LVector2 min) = service.GetTileContains(index);
(LVector2 max, LVector2 min) = service.GetTileContains(linkTile);
DrawContains(max,min,Color.cyan);
});
}
}

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using DotRecast.Core.Collections;
using Entitas;
using JNGame.Runtime.Sync;
using JNGame.Sync.Entity;
@@ -104,13 +103,13 @@ namespace JNGame.Sync.Frame.Entity
//生效延迟销毁
public void DelayDestroy()
{
GetEntities().ForEach(child =>
foreach (var child in GetEntities())
{
if (child.IsDelayDestroy)
{
child.Destroy();
}
});
}
}
//生命周期

View File

@@ -1,6 +1,4 @@
using System;
using System.Linq;
using DotRecast.Core.Collections;
using JNGame.Math;
using JNGame.Sync.Entity.Component;
using JNGame.Sync.Frame.Entity;
@@ -107,7 +105,10 @@ namespace JNGame.Sync.Entity
public override void RemoveAllComponents()
{
GetComponents().ForEach(child => (child as JNComponent)?.OnSyncDestroy());
foreach (var child in GetComponents())
{
(child as JNComponent)?.OnSyncDestroy();
}
base.RemoveAllComponents();
}

View File

@@ -1,7 +1,5 @@
using System.Collections.Generic;
using DotRecast.Core.Collections;
using UnityEngine;
using NotImplementedException = System.NotImplementedException;
namespace JNGame.Sync.System.Data
{
@@ -102,7 +100,7 @@ namespace JNGame.Sync.System.Data
if (isServer)
{
var latest = GetLatest();
latest.Keys.ForEach(key =>
foreach (var key in latest.Keys)
{
if (Data.ContainsKey(key))
{
@@ -114,12 +112,12 @@ namespace JNGame.Sync.System.Data
//如果之前没有则添加
Add(latest[key]);
}
});
Data.ForEach(child =>
}
foreach (var child in Data)
{
//没有则删除
if (!(latest.ContainsKey(child.Key))) Delete(child.Key);
});
}
if (UBytes.Count > 0)
{
OnUByteUpdate(UBytes);
@@ -167,10 +165,10 @@ namespace JNGame.Sync.System.Data
{
var data = new Dictionary<ulong, byte[]>();
Data.ForEach(child =>
foreach (var child in Data)
{
data[child.Key] = child.Value.GetByte();
});
}
return data;

View File

@@ -1,7 +1,6 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using DotRecast.Core.Collections;
using JNGame.Math;
using JNGame.Sync.State.Tile;
using JNGame.Sync.State.Tile.Entity;
@@ -88,12 +87,12 @@ namespace JNGame.Sync.System.Data
{
entities = NodeContext.GetEntities();
}
entities.ForEach(child =>
foreach (var child in entities)
{
var entity = new T();
entity.BindEntity(child);
nodes[child.Id] = entity;
});
}
return nodes;
}
@@ -125,7 +124,7 @@ namespace JNGame.Sync.System.Data
if (isServer)
{
var latest = GetLatest();
latest.Keys.ForEach(key =>
foreach (var key in latest.Keys)
{
if (Data.ContainsKey(key))
{
@@ -137,8 +136,8 @@ namespace JNGame.Sync.System.Data
//如果之前没有则添加
Add(latest[key]);
}
});
Data.ForEach(child =>
}
foreach (var child in Data)
{
//没有则删除
if (NodeContext.Query(child.Key) is null)
@@ -152,8 +151,7 @@ namespace JNGame.Sync.System.Data
child.Value.IsActiveSyncOnce = false;
UBytes[child.Key] = child.Value.GetByte();
}
});
}
if (UBytes.Count > 0)
{
OnUByteUpdate(UBytes);
@@ -170,7 +168,7 @@ namespace JNGame.Sync.System.Data
Dictionary<ulong, byte[]> master = new Dictionary<ulong, byte[]>();
Dictionary<ulong, byte[]> slave = new Dictionary<ulong, byte[]>();
all.ForEach(keyValue =>
foreach (var keyValue in all)
{
var entity = NodeContext.Query(keyValue.Key);
//给从服务器发送数据
@@ -178,7 +176,7 @@ namespace JNGame.Sync.System.Data
{
slave[keyValue.Key] = keyValue.Value;
}
});
}
OnSendAllData(all);
OnSendMasterData(master);
@@ -220,7 +218,7 @@ namespace JNGame.Sync.System.Data
}
}
NodeContext.GetEntities().ForEach(child =>
foreach (var child in NodeContext.GetEntities())
{
//如果有则删除
if (lIsTileData.Remove(child.Id,out var data))
@@ -234,7 +232,7 @@ namespace JNGame.Sync.System.Data
if (IsSlave) data.IsActiveSyncOnce = true;
}
}
});
}
//将数据同步到实体中
foreach (var keyValue in lIsTileData)
@@ -308,10 +306,10 @@ namespace JNGame.Sync.System.Data
//需要删除的数据Id
var ids = new List<ulong>();
Data.ForEach(child =>
foreach (var child in Data)
{
if (IsTileInside(index,child.Value)) ids.Add(child.Key);
});
}
//删除数据和实体
ids.ForEach(child =>
@@ -343,14 +341,14 @@ namespace JNGame.Sync.System.Data
lock (Data)
{
Data.ForEach(child =>
foreach (var child in Data)
{
var entity = NodeContext.Query(child.Key);
if (entity is not null && entity.IsHost && filter(entity))
{
data[child.Key] = child.Value.GetByte();
}
});
}
}
return data;
@@ -366,14 +364,14 @@ namespace JNGame.Sync.System.Data
lock (Data)
{
Data.ForEach(child =>
foreach (var child in Data)
{
var entity = NodeContext.Query(child.Key);
if (IsTileInside(index,child.Value) && filter(entity))
{
data[child.Key] = child.Value.GetByte();
}
});
}
}
return data;

View File

@@ -67,38 +67,18 @@
</assembly>
<assembly fullname="System">
<type fullname="System.CodeDom.Compiler.GeneratedCodeAttribute" preserve="all" />
<type fullname="System.Collections.Concurrent.BlockingCollection`1" preserve="all" />
<type fullname="System.Collections.Generic.ISet`1" preserve="all" />
<type fullname="System.Collections.Generic.LinkedListNode`1" preserve="all" />
<type fullname="System.Collections.Generic.LinkedList`1" preserve="all" />
<type fullname="System.Collections.Generic.Queue`1" preserve="all" />
<type fullname="System.Collections.Generic.Stack`1" preserve="all" />
<type fullname="System.ComponentModel.EditorBrowsableAttribute" preserve="all" />
<type fullname="System.ComponentModel.EditorBrowsableState" preserve="all" />
<type fullname="System.Diagnostics.Process" preserve="all" />
<type fullname="System.Diagnostics.ProcessStartInfo" preserve="all" />
<type fullname="System.Diagnostics.Stopwatch" preserve="all" />
<type fullname="System.Net.Sockets.Socket" preserve="all" />
<type fullname="System.Net.Sockets.SocketFlags" preserve="all" />
<type fullname="System.Text.RegularExpressions.Capture" preserve="all" />
<type fullname="System.Text.RegularExpressions.Group" preserve="all" />
<type fullname="System.Text.RegularExpressions.GroupCollection" preserve="all" />
<type fullname="System.Text.RegularExpressions.Match" preserve="all" />
<type fullname="System.Text.RegularExpressions.Regex" preserve="all" />
</assembly>
<assembly fullname="System.Core">
<type fullname="System.Collections.Generic.HashSet`1" preserve="all" />
<type fullname="System.Collections.Generic.HashSet`1/Enumerator" preserve="all" />
<type fullname="System.Linq.Enumerable" preserve="all" />
<type fullname="System.Linq.IOrderedEnumerable`1" preserve="all" />
</assembly>
<assembly fullname="System.IO.Compression">
<type fullname="System.IO.Compression.ZipArchive" preserve="all" />
<type fullname="System.IO.Compression.ZipArchiveEntry" preserve="all" />
</assembly>
<assembly fullname="System.Numerics.Vectors">
<type fullname="System.Numerics.Vector" preserve="all" />
<type fullname="System.Numerics.Vector`1" preserve="all" />
</assembly>
<assembly fullname="TouchSocket">
<type fullname="TouchSocket.Sockets.ByteBlockEventArgs" preserve="all" />
@@ -161,17 +141,9 @@
<type fullname="Cysharp.Threading.Tasks.UnityAsyncExtensions" preserve="all" />
<type fullname="Cysharp.Threading.Tasks.UnityAsyncExtensions/UnityWebRequestAsyncOperationAwaiter" preserve="all" />
</assembly>
<assembly fullname="Unity.AI.Navigation">
<type fullname="Unity.AI.Navigation.NavMeshSurface" preserve="all" />
</assembly>
<assembly fullname="UnityEngine.AIModule">
<type fullname="UnityEngine.AI.NavMesh" preserve="all" />
<type fullname="UnityEngine.AI.NavMeshTriangulation" preserve="all" />
</assembly>
<assembly fullname="UnityEngine.CoreModule">
<type fullname="UnityEngine.Application" preserve="all" />
<type fullname="UnityEngine.Color" preserve="all" />
<type fullname="UnityEngine.CombineInstance" preserve="all" />
<type fullname="UnityEngine.Component" preserve="all" />
<type fullname="UnityEngine.Coroutine" preserve="all" />
<type fullname="UnityEngine.Debug" preserve="all" />
@@ -179,10 +151,6 @@
<type fullname="UnityEngine.GameObject" preserve="all" />
<type fullname="UnityEngine.Gizmos" preserve="all" />
<type fullname="UnityEngine.HideFlags" preserve="all" />
<type fullname="UnityEngine.LayerMask" preserve="all" />
<type fullname="UnityEngine.Matrix4x4" preserve="all" />
<type fullname="UnityEngine.Mesh" preserve="all" />
<type fullname="UnityEngine.MeshFilter" preserve="all" />
<type fullname="UnityEngine.MonoBehaviour" preserve="all" />
<type fullname="UnityEngine.Object" preserve="all" />
<type fullname="UnityEngine.Rect" preserve="all" />
@@ -193,9 +161,6 @@
<type fullname="UnityEngine.Vector3" preserve="all" />
<type fullname="UnityEngine.Vector3Int" preserve="all" />
</assembly>
<assembly fullname="UnityEngine.JSONSerializeModule">
<type fullname="UnityEngine.JsonUtility" preserve="all" />
</assembly>
<assembly fullname="UnityEngine.UnityWebRequestModule">
<type fullname="UnityEngine.Networking.DownloadHandler" preserve="all" />
<type fullname="UnityEngine.Networking.UnityWebRequest" preserve="all" />
@@ -210,10 +175,8 @@
<assembly fullname="mscorlib">
<type fullname="System.Action" preserve="all" />
<type fullname="System.Action`1" preserve="all" />
<type fullname="System.Action`3" preserve="all" />
<type fullname="System.Activator" preserve="all" />
<type fullname="System.ArgumentException" preserve="all" />
<type fullname="System.ArgumentNullException" preserve="all" />
<type fullname="System.ArgumentOutOfRangeException" preserve="all" />
<type fullname="System.Array" preserve="all" />
<type fullname="System.AsyncCallback" preserve="all" />
@@ -222,12 +185,9 @@
<type fullname="System.AttributeUsageAttribute" preserve="all" />
<type fullname="System.BitConverter" preserve="all" />
<type fullname="System.Boolean" preserve="all" />
<type fullname="System.Buffers.ArrayPool`1" preserve="all" />
<type fullname="System.Buffers.Binary.BinaryPrimitives" preserve="all" />
<type fullname="System.Byte" preserve="all" />
<type fullname="System.Collections.Concurrent.ConcurrentDictionary`2" preserve="all" />
<type fullname="System.Collections.Generic.CollectionExtensions" preserve="all" />
<type fullname="System.Collections.Generic.Comparer`1" preserve="all" />
<type fullname="System.Collections.Generic.Dictionary`2" preserve="all" />
<type fullname="System.Collections.Generic.Dictionary`2/Enumerator" preserve="all" />
<type fullname="System.Collections.Generic.Dictionary`2/KeyCollection" preserve="all" />
@@ -235,7 +195,6 @@
<type fullname="System.Collections.Generic.Dictionary`2/ValueCollection" preserve="all" />
<type fullname="System.Collections.Generic.Dictionary`2/ValueCollection/Enumerator" preserve="all" />
<type fullname="System.Collections.Generic.ICollection`1" preserve="all" />
<type fullname="System.Collections.Generic.IComparer`1" preserve="all" />
<type fullname="System.Collections.Generic.IDictionary`2" preserve="all" />
<type fullname="System.Collections.Generic.IEnumerable`1" preserve="all" />
<type fullname="System.Collections.Generic.IEnumerator`1" preserve="all" />
@@ -247,8 +206,6 @@
<type fullname="System.Collections.Generic.List`1/Enumerator" preserve="all" />
<type fullname="System.Collections.IEnumerable" preserve="all" />
<type fullname="System.Collections.IEnumerator" preserve="all" />
<type fullname="System.Comparison`1" preserve="all" />
<type fullname="System.Console" preserve="all" />
<type fullname="System.Convert" preserve="all" />
<type fullname="System.DateTime" preserve="all" />
<type fullname="System.DateTimeOffset" preserve="all" />
@@ -267,44 +224,27 @@
<type fullname="System.Func`2" preserve="all" />
<type fullname="System.Func`3" preserve="all" />
<type fullname="System.Globalization.CultureInfo" preserve="all" />
<type fullname="System.HashCode" preserve="all" />
<type fullname="System.IAsyncResult" preserve="all" />
<type fullname="System.IComparable" preserve="all" />
<type fullname="System.IComparable`1" preserve="all" />
<type fullname="System.IDisposable" preserve="all" />
<type fullname="System.IEquatable`1" preserve="all" />
<type fullname="System.IFormatProvider" preserve="all" />
<type fullname="System.IO.BinaryReader" preserve="all" />
<type fullname="System.IO.BinaryWriter" preserve="all" />
<type fullname="System.IO.Directory" preserve="all" />
<type fullname="System.IO.File" preserve="all" />
<type fullname="System.IO.FileAccess" preserve="all" />
<type fullname="System.IO.FileMode" preserve="all" />
<type fullname="System.IO.FileShare" preserve="all" />
<type fullname="System.IO.FileStream" preserve="all" />
<type fullname="System.IO.IOException" preserve="all" />
<type fullname="System.IO.MemoryStream" preserve="all" />
<type fullname="System.IO.Path" preserve="all" />
<type fullname="System.IO.SeekOrigin" preserve="all" />
<type fullname="System.IO.Stream" preserve="all" />
<type fullname="System.IO.StreamReader" preserve="all" />
<type fullname="System.IO.StreamWriter" preserve="all" />
<type fullname="System.IO.TextReader" preserve="all" />
<type fullname="System.IO.TextWriter" preserve="all" />
<type fullname="System.IndexOutOfRangeException" preserve="all" />
<type fullname="System.Int16" preserve="all" />
<type fullname="System.Int32" preserve="all" />
<type fullname="System.Int64" preserve="all" />
<type fullname="System.InvalidOperationException" preserve="all" />
<type fullname="System.MemoryExtensions" preserve="all" />
<type fullname="System.MulticastDelegate" preserve="all" />
<type fullname="System.NotImplementedException" preserve="all" />
<type fullname="System.NotSupportedException" preserve="all" />
<type fullname="System.Object" preserve="all" />
<type fullname="System.ObsoleteAttribute" preserve="all" />
<type fullname="System.ParamArrayAttribute" preserve="all" />
<type fullname="System.Predicate`1" preserve="all" />
<type fullname="System.ReadOnlySpan`1" preserve="all" />
<type fullname="System.Reflection.Assembly" preserve="all" />
<type fullname="System.Reflection.DefaultMemberAttribute" preserve="all" />
<type fullname="System.Reflection.MemberInfo" preserve="all" />
@@ -319,25 +259,21 @@
<type fullname="System.Runtime.CompilerServices.ExtensionAttribute" preserve="all" />
<type fullname="System.Runtime.CompilerServices.IAsyncStateMachine" preserve="all" />
<type fullname="System.Runtime.CompilerServices.IsReadOnlyAttribute" preserve="all" />
<type fullname="System.Runtime.CompilerServices.IsVolatile" preserve="all" />
<type fullname="System.Runtime.CompilerServices.IteratorStateMachineAttribute" preserve="all" />
<type fullname="System.Runtime.CompilerServices.RuntimeCompatibilityAttribute" preserve="all" />
<type fullname="System.Runtime.CompilerServices.RuntimeHelpers" preserve="all" />
<type fullname="System.Runtime.CompilerServices.TaskAwaiter" preserve="all" />
<type fullname="System.Runtime.CompilerServices.TaskAwaiter`1" preserve="all" />
<type fullname="System.Runtime.CompilerServices.TupleElementNamesAttribute" preserve="all" />
<type fullname="System.Runtime.InteropServices.InAttribute" preserve="all" />
<type fullname="System.Runtime.InteropServices.MemoryMarshal" preserve="all" />
<type fullname="System.Runtime.InteropServices.OSPlatform" preserve="all" />
<type fullname="System.Runtime.InteropServices.RuntimeInformation" preserve="all" />
<type fullname="System.Runtime.Serialization.Formatters.Binary.BinaryFormatter" preserve="all" />
<type fullname="System.RuntimeFieldHandle" preserve="all" />
<type fullname="System.RuntimeTypeHandle" preserve="all" />
<type fullname="System.Security.Permissions.SecurityAction" preserve="all" />
<type fullname="System.Security.Permissions.SecurityPermissionAttribute" preserve="all" />
<type fullname="System.Security.UnverifiableCodeAttribute" preserve="all" />
<type fullname="System.Single" preserve="all" />
<type fullname="System.Span`1" preserve="all" />
<type fullname="System.String" preserve="all" />
<type fullname="System.StringComparison" preserve="all" />
<type fullname="System.StringSplitOptions" preserve="all" />
<type fullname="System.Text.Encoding" preserve="all" />
<type fullname="System.Text.StringBuilder" preserve="all" />
<type fullname="System.ThreadStaticAttribute" preserve="all" />