mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
1、修复了MongoDB在2.18.0以后需要自定义注册ObjectSerializer的问题。 2、Addressable的AddAddressable接口增加isLock参数、用来决定是否需要添加携程锁。 3、修复了APackInfo因为网络多线程的原因导致线程安全的问题。
1、修复了MongoDB在2.18.0以后需要自定义注册ObjectSerializer的问题。 2、Addressable的AddAddressable接口增加isLock参数、用来决定是否需要添加携程锁。 3、修复了APackInfo因为网络多线程的原因导致线程安全的问题。
This commit is contained in:
@@ -13,6 +13,7 @@ using Newtonsoft.Json;
|
||||
|
||||
// ReSharper disable SuspiciousTypeConversion.Global
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
@@ -401,11 +402,54 @@ namespace TEngine
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#if TENGINE_NET
|
||||
#region ForEach
|
||||
public IEnumerable<Entity> ForEachSingleCollection
|
||||
{
|
||||
get
|
||||
{
|
||||
foreach (var (_, treeEntity) in _tree)
|
||||
{
|
||||
if (treeEntity is not ISupportedSingleCollection)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
yield return treeEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
public IEnumerable<Entity> ForEachTransfer
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_tree != null)
|
||||
{
|
||||
foreach (var (_, treeEntity) in _tree)
|
||||
{
|
||||
if (treeEntity is ISupportedSingleCollection || treeEntity is ISupportedTransfer)
|
||||
{
|
||||
yield return treeEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_multiDb != null)
|
||||
{
|
||||
foreach (var treeEntity in _multiDb)
|
||||
{
|
||||
if (treeEntity is not ISupportedTransfer)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
yield return treeEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endif
|
||||
|
||||
#region GetComponent
|
||||
|
||||
public DictionaryPool<Type, Entity> GetTree => _tree;
|
||||
|
||||
public T GetComponent<T>() where T : Entity, new()
|
||||
{
|
||||
return GetComponent(typeof(T)) as T;
|
||||
|
30
Assets/GameScripts/DotNet/Core/Entitas/EntityReference.cs
Normal file
30
Assets/GameScripts/DotNet/Core/Entitas/EntityReference.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
// ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
|
||||
namespace TEngine
|
||||
{
|
||||
public readonly struct EntityReference<T> where T : Entity
|
||||
{
|
||||
private readonly T _entity;
|
||||
private readonly long _runTimeId;
|
||||
|
||||
private EntityReference(T t)
|
||||
{
|
||||
_entity = t;
|
||||
_runTimeId = t.RuntimeId;
|
||||
}
|
||||
|
||||
public static implicit operator EntityReference<T>(T t)
|
||||
{
|
||||
return new EntityReference<T>(t);
|
||||
}
|
||||
|
||||
public static implicit operator T(EntityReference<T> v)
|
||||
{
|
||||
if (v._entity == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return v._entity.RuntimeId != v._runTimeId ? null : v._entity;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c827c6f914b64f5d9eb0a1f29cc2c018
|
||||
timeCreated: 1691083017
|
@@ -0,0 +1,8 @@
|
||||
#if TENGINE_NET
|
||||
namespace TEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Entity支持传送。
|
||||
/// </summary>
|
||||
public interface ISupportedTransfer { }
|
||||
#endif
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 06770f37cdfc480fb0c270ea93a10d26
|
||||
timeCreated: 1691083054
|
@@ -91,7 +91,7 @@ namespace TEngine
|
||||
}
|
||||
#else
|
||||
/// <summary>
|
||||
/// 创建一个Scene、但这个Scene是在某个Scene下面的Scene。
|
||||
/// 创建一个Scene。
|
||||
/// </summary>
|
||||
/// <param name="scene"></param>
|
||||
/// <param name="sceneType"></param>
|
||||
@@ -101,24 +101,24 @@ namespace TEngine
|
||||
public static async FTask<T> Create<T>(Scene scene, int sceneType, int sceneSubType) where T : Scene, new()
|
||||
{
|
||||
var newScene = Create<T>(scene);
|
||||
newScene.Scene = scene;
|
||||
newScene.Scene = newScene;
|
||||
newScene.Parent = scene;
|
||||
newScene.SceneType = sceneType;
|
||||
newScene.SceneSubType = sceneSubType;
|
||||
newScene.Server = scene.Server;
|
||||
newScene.LocationId = scene.Server.Id;
|
||||
|
||||
if (scene.World !=null)
|
||||
if (scene.World != null)
|
||||
{
|
||||
newScene.World = scene.World;
|
||||
}
|
||||
|
||||
if (sceneType > 0)
|
||||
{
|
||||
await EventSystem.Instance.PublishAsync(new OnCreateScene(scene));
|
||||
await EventSystem.Instance.PublishAsync(new OnCreateScene(newScene));
|
||||
}
|
||||
|
||||
Scenes.Add(scene);
|
||||
Scenes.Add(newScene);
|
||||
return newScene;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user