|
|
@@ -9,28 +9,30 @@ namespace Svelto.ECS.Internal |
|
|
|
public static class TypeSafeDictionaryMethods |
|
|
|
{ |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static void AddEntitiesToDictionary<Strategy1, Strategy2, Strategy3, TValue> |
|
|
|
(in SveltoDictionary<uint, TValue, Strategy1, Strategy2, Strategy3> fromDictionary |
|
|
|
, ITypeSafeDictionary<TValue> toDic |
|
|
|
public static void AddEntitiesToDictionary<Strategy1, Strategy2, Strategy3, TValue>( |
|
|
|
in SveltoDictionary<uint, TValue, Strategy1, Strategy2, Strategy3> fromDictionary |
|
|
|
, ITypeSafeDictionary<TValue> toDic |
|
|
|
#if SLOW_SVELTO_SUBMISSION |
|
|
|
, in EnginesRoot.EntityReferenceMap entityLocator |
|
|
|
, in EnginesRoot.EntityReferenceMap entityLocator |
|
|
|
#endif |
|
|
|
, ExclusiveGroupStruct toGroupID) where Strategy1 : struct, IBufferStrategy<SveltoDictionaryNode<uint>> |
|
|
|
where Strategy2 : struct, IBufferStrategy<TValue> |
|
|
|
where Strategy3 : struct, IBufferStrategy<int> |
|
|
|
where TValue : struct, _IInternalEntityComponent |
|
|
|
, ExclusiveGroupStruct toGroupID) |
|
|
|
where Strategy1 : struct, IBufferStrategy<SveltoDictionaryNode<uint>> |
|
|
|
where Strategy2 : struct, IBufferStrategy<TValue> |
|
|
|
where Strategy3 : struct, IBufferStrategy<int> |
|
|
|
where TValue : struct, _IInternalEntityComponent |
|
|
|
{ |
|
|
|
foreach (var tuple in fromDictionary) |
|
|
|
{ |
|
|
|
#if SLOW_SVELTO_SUBMISSION |
|
|
|
var egid = new EGID(tuple.key, toGroupID); |
|
|
|
var egid = new EGID(tuple.key, toGroupID); |
|
|
|
|
|
|
|
if (SlowSubmissionInfo<TValue>.hasEgid) |
|
|
|
SetEGIDWithoutBoxing<TValue>.SetIDWithoutBoxing(ref tuple.value, egid); |
|
|
|
if (SlowSubmissionInfo<TValue>.hasEgid) |
|
|
|
SetEGIDWithoutBoxing<TValue>.SetIDWithoutBoxing(ref tuple.value, egid); |
|
|
|
|
|
|
|
if (SlowSubmissionInfo<TValue>.hasReference) |
|
|
|
SetEGIDWithoutBoxing<TValue>.SetRefWithoutBoxing(ref tuple.value, |
|
|
|
entityLocator.GetEntityReference(egid)); |
|
|
|
if (SlowSubmissionInfo<TValue>.hasReference) |
|
|
|
SetEGIDWithoutBoxing<TValue>.SetRefWithoutBoxing( |
|
|
|
ref tuple.value, |
|
|
|
entityLocator.GetEntityReference(egid)); |
|
|
|
#endif |
|
|
|
try |
|
|
|
{ |
|
|
@@ -39,7 +41,9 @@ namespace Svelto.ECS.Internal |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|
Console.LogException( |
|
|
|
e, "trying to add an EntityComponent with the same ID more than once Entity: ".FastConcat(typeof(TValue).ToString()).FastConcat(", group ").FastConcat(toGroupID.ToName()).FastConcat(", id ").FastConcat(tuple.key)); |
|
|
|
e, |
|
|
|
"trying to add an EntityComponent with the same ID more than once Entity: ".FastConcat(typeof(TValue).ToString()) |
|
|
|
.FastConcat(", group ").FastConcat(toGroupID.ToName()).FastConcat(", id ").FastConcat(tuple.key)); |
|
|
|
|
|
|
|
throw; |
|
|
|
} |
|
|
@@ -50,30 +54,32 @@ namespace Svelto.ECS.Internal |
|
|
|
} |
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static void ExecuteEnginesAddCallbacks<Strategy1, Strategy2, Strategy3, TValue> |
|
|
|
(ref SveltoDictionary<uint, TValue, Strategy1, Strategy2, Strategy3> fromDictionary |
|
|
|
, ITypeSafeDictionary<TValue> todic, ExclusiveGroupStruct togroup |
|
|
|
, FasterDictionary<RefWrapperType, FasterList<ReactEngineContainer<IReactOnAdd>>> entitycomponentenginesdb |
|
|
|
, in PlatformProfiler sampler) where Strategy1 : struct, IBufferStrategy<SveltoDictionaryNode<uint>> |
|
|
|
where Strategy2 : struct, IBufferStrategy<TValue> |
|
|
|
where Strategy3 : struct, IBufferStrategy<int> |
|
|
|
where TValue : struct, _IInternalEntityComponent |
|
|
|
public static void ExecuteEnginesAddCallbacks<Strategy1, Strategy2, Strategy3, TValue>( |
|
|
|
ref SveltoDictionary<uint, TValue, Strategy1, Strategy2, Strategy3> fromDictionary |
|
|
|
, ITypeSafeDictionary<TValue> todic, ExclusiveGroupStruct togroup |
|
|
|
, FasterDictionary<RefWrapperType, FasterList<ReactEngineContainer<IReactOnAdd>>> entitycomponentenginesdb |
|
|
|
, in PlatformProfiler sampler) |
|
|
|
where Strategy1 : struct, IBufferStrategy<SveltoDictionaryNode<uint>> |
|
|
|
where Strategy2 : struct, IBufferStrategy<TValue> |
|
|
|
where Strategy3 : struct, IBufferStrategy<int> |
|
|
|
where TValue : struct, _IInternalEntityComponent |
|
|
|
{ |
|
|
|
if (entitycomponentenginesdb.TryGetValue(new RefWrapperType(TypeCache<TValue>.type) |
|
|
|
, out var entityComponentsEngines)) |
|
|
|
if (entitycomponentenginesdb.TryGetValue( |
|
|
|
new RefWrapperType(TypeCache<TValue>.type) |
|
|
|
, out var entityComponentsEngines)) |
|
|
|
{ |
|
|
|
if (entityComponentsEngines.count == 0) |
|
|
|
return; |
|
|
|
|
|
|
|
var dictionaryKeyEnumerator = fromDictionary.unsafeKeys; |
|
|
|
var count = fromDictionary.count; |
|
|
|
var count = fromDictionary.count; |
|
|
|
|
|
|
|
for (var i = 0; i < count; ++i) |
|
|
|
try |
|
|
|
{ |
|
|
|
var key = dictionaryKeyEnumerator[i].key; |
|
|
|
var key = dictionaryKeyEnumerator[i].key; |
|
|
|
ref var entity = ref todic.GetValueByRef(key); |
|
|
|
var egid = new EGID(key, togroup); |
|
|
|
var egid = new EGID(key, togroup); |
|
|
|
//get all the engines linked to TValue |
|
|
|
for (var j = 0; j < entityComponentsEngines.count; j++) |
|
|
|
using (sampler.Sample(entityComponentsEngines[j].name)) |
|
|
@@ -85,8 +91,7 @@ namespace Svelto.ECS.Internal |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|
Console.LogException( |
|
|
|
e, "Code crashed inside Add callback with Type ".FastConcat(TypeCache<TValue>.name)); |
|
|
|
Console.LogException(e, "Code crashed inside Add callback with Type ".FastConcat(TypeCache<TValue>.name)); |
|
|
|
|
|
|
|
throw; |
|
|
|
} |
|
|
@@ -94,14 +99,14 @@ namespace Svelto.ECS.Internal |
|
|
|
} |
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static void ExecuteEnginesDisposeCallbacks_Group<Strategy1, Strategy2, Strategy3, TValue> |
|
|
|
(ref SveltoDictionary<uint, TValue, Strategy1, Strategy2, Strategy3> fromDictionary |
|
|
|
, FasterDictionary<RefWrapperType, FasterList<ReactEngineContainer<IReactOnDispose>>> allEngines |
|
|
|
, ExclusiveGroupStruct inGroup, in PlatformProfiler sampler) |
|
|
|
where Strategy1 : struct, IBufferStrategy<SveltoDictionaryNode<uint>> |
|
|
|
where Strategy2 : struct, IBufferStrategy<TValue> |
|
|
|
where Strategy3 : struct, IBufferStrategy<int> |
|
|
|
where TValue : struct, _IInternalEntityComponent |
|
|
|
public static void ExecuteEnginesDisposeCallbacks_Group<Strategy1, Strategy2, Strategy3, TValue>( |
|
|
|
ref SveltoDictionary<uint, TValue, Strategy1, Strategy2, Strategy3> fromDictionary |
|
|
|
, FasterDictionary<RefWrapperType, FasterList<ReactEngineContainer<IReactOnDispose>>> allEngines |
|
|
|
, ExclusiveGroupStruct inGroup, in PlatformProfiler sampler) |
|
|
|
where Strategy1 : struct, IBufferStrategy<SveltoDictionaryNode<uint>> |
|
|
|
where Strategy2 : struct, IBufferStrategy<TValue> |
|
|
|
where Strategy3 : struct, IBufferStrategy<int> |
|
|
|
where TValue : struct, _IInternalEntityComponent |
|
|
|
{ |
|
|
|
if (allEngines.TryGetValue(new RefWrapperType(TypeCache<TValue>.type), out var entityComponentsEngines) |
|
|
|
== false) |
|
|
@@ -114,35 +119,34 @@ namespace Svelto.ECS.Internal |
|
|
|
{ |
|
|
|
foreach (var value in fromDictionary) |
|
|
|
{ |
|
|
|
ref var entity = ref value.value; |
|
|
|
var egid = new EGID(value.key, inGroup); |
|
|
|
var reactOnRemove = (IReactOnDispose<TValue>)entityComponentsEngines[i].engine; |
|
|
|
ref var entity = ref value.value; |
|
|
|
var egid = new EGID(value.key, inGroup); |
|
|
|
var reactOnRemove = (IReactOnDispose<TValue>)entityComponentsEngines[i].engine; |
|
|
|
reactOnRemove.Remove(ref entity, egid); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
catch |
|
|
|
{ |
|
|
|
Console.LogError( |
|
|
|
"Code crashed inside Remove callback ".FastConcat(entityComponentsEngines[i].name)); |
|
|
|
Console.LogError("Code crashed inside Remove callback ".FastConcat(entityComponentsEngines[i].name)); |
|
|
|
|
|
|
|
throw; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static void ExecuteEnginesRemoveCallbacks<Strategy1, Strategy2, Strategy3, TValue> |
|
|
|
(FasterList<(uint, string)> infostoprocess |
|
|
|
, ref SveltoDictionary<uint, TValue, Strategy1, Strategy2, Strategy3> fromDictionary |
|
|
|
, FasterDictionary<RefWrapperType, FasterList<ReactEngineContainer<IReactOnRemove>>> reactiveenginesremove |
|
|
|
, ExclusiveGroupStruct fromgroup, in PlatformProfiler profiler) |
|
|
|
where Strategy1 : struct, IBufferStrategy<SveltoDictionaryNode<uint>> |
|
|
|
where Strategy2 : struct, IBufferStrategy<TValue> |
|
|
|
where Strategy3 : struct, IBufferStrategy<int> |
|
|
|
where TValue : struct, _IInternalEntityComponent |
|
|
|
public static void ExecuteEnginesRemoveCallbacks<Strategy1, Strategy2, Strategy3, TValue>(FasterList<(uint, string)> infostoprocess |
|
|
|
, ref SveltoDictionary<uint, TValue, Strategy1, Strategy2, Strategy3> fromDictionary |
|
|
|
, FasterDictionary<RefWrapperType, FasterList<ReactEngineContainer<IReactOnRemove>>> reactiveenginesremove |
|
|
|
, ExclusiveGroupStruct fromgroup, in PlatformProfiler profiler) |
|
|
|
where Strategy1 : struct, IBufferStrategy<SveltoDictionaryNode<uint>> |
|
|
|
where Strategy2 : struct, IBufferStrategy<TValue> |
|
|
|
where Strategy3 : struct, IBufferStrategy<int> |
|
|
|
where TValue : struct, _IInternalEntityComponent |
|
|
|
{ |
|
|
|
if (reactiveenginesremove.TryGetValue(new RefWrapperType(TypeCache<TValue>.type) |
|
|
|
, out var entityComponentsEngines)) |
|
|
|
if (reactiveenginesremove.TryGetValue( |
|
|
|
new RefWrapperType(TypeCache<TValue>.type) |
|
|
|
, out var entityComponentsEngines)) |
|
|
|
{ |
|
|
|
if (entityComponentsEngines.count == 0) |
|
|
|
return; |
|
|
@@ -155,7 +159,7 @@ namespace Svelto.ECS.Internal |
|
|
|
try |
|
|
|
{ |
|
|
|
ref var entity = ref fromDictionary.GetValueByRef(entityID); |
|
|
|
var egid = new EGID(entityID, fromgroup); |
|
|
|
var egid = new EGID(entityID, fromgroup); |
|
|
|
|
|
|
|
for (var j = 0; j < entityComponentsEngines.count; j++) |
|
|
|
using (profiler.Sample(entityComponentsEngines[j].name)) |
|
|
@@ -168,7 +172,7 @@ namespace Svelto.ECS.Internal |
|
|
|
catch |
|
|
|
{ |
|
|
|
var str = "Crash while executing Remove Entity callback on ".FastConcat(TypeCache<TValue>.name) |
|
|
|
.FastConcat(" from : ", trace); |
|
|
|
.FastConcat(" from : ", trace); |
|
|
|
|
|
|
|
Console.LogError(str); |
|
|
|
|
|
|
@@ -179,19 +183,20 @@ namespace Svelto.ECS.Internal |
|
|
|
} |
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static void ExecuteEnginesRemoveCallbacks_Group<Strategy1, Strategy2, Strategy3, TValue> |
|
|
|
(ref SveltoDictionary<uint, TValue, Strategy1, Strategy2, Strategy3> fromDictionary |
|
|
|
, ITypeSafeDictionary<TValue> typeSafeDictionary |
|
|
|
, FasterDictionary<RefWrapperType, FasterList<ReactEngineContainer<IReactOnRemove>>> reactiveenginesremove |
|
|
|
, FasterDictionary<RefWrapperType, FasterList<ReactEngineContainer<IReactOnRemoveEx>>> reactiveenginesremoveex |
|
|
|
, int count, IEntityIDs entityids, ExclusiveGroupStruct group, in PlatformProfiler sampler) |
|
|
|
where Strategy1 : struct, IBufferStrategy<SveltoDictionaryNode<uint>> |
|
|
|
where Strategy2 : struct, IBufferStrategy<TValue> |
|
|
|
where Strategy3 : struct, IBufferStrategy<int> |
|
|
|
where TValue : struct, _IInternalEntityComponent |
|
|
|
public static void ExecuteEnginesRemoveCallbacks_Group<Strategy1, Strategy2, Strategy3, TValue>( |
|
|
|
ref SveltoDictionary<uint, TValue, Strategy1, Strategy2, Strategy3> fromDictionary |
|
|
|
, ITypeSafeDictionary<TValue> typeSafeDictionary |
|
|
|
, FasterDictionary<RefWrapperType, FasterList<ReactEngineContainer<IReactOnRemove>>> reactiveenginesremove |
|
|
|
, FasterDictionary<RefWrapperType, FasterList<ReactEngineContainer<IReactOnRemoveEx>>> reactiveenginesremoveex |
|
|
|
, int count, IEntityIDs entityids, ExclusiveGroupStruct group, in PlatformProfiler sampler) |
|
|
|
where Strategy1 : struct, IBufferStrategy<SveltoDictionaryNode<uint>> |
|
|
|
where Strategy2 : struct, IBufferStrategy<TValue> |
|
|
|
where Strategy3 : struct, IBufferStrategy<int> |
|
|
|
where TValue : struct, _IInternalEntityComponent |
|
|
|
{ |
|
|
|
if (reactiveenginesremove.TryGetValue(new RefWrapperType(TypeCache<TValue>.type) |
|
|
|
, out var reactiveEnginesRemovePerType)) |
|
|
|
if (reactiveenginesremove.TryGetValue( |
|
|
|
new RefWrapperType(TypeCache<TValue>.type) |
|
|
|
, out var reactiveEnginesRemovePerType)) |
|
|
|
{ |
|
|
|
var enginesCount = reactiveEnginesRemovePerType.count; |
|
|
|
|
|
|
@@ -201,7 +206,7 @@ namespace Svelto.ECS.Internal |
|
|
|
foreach (var value in fromDictionary) |
|
|
|
{ |
|
|
|
ref var entity = ref value.value; |
|
|
|
var egid = new EGID(value.key, group); |
|
|
|
var egid = new EGID(value.key, group); |
|
|
|
|
|
|
|
using (sampler.Sample(reactiveEnginesRemovePerType[i].name)) |
|
|
|
{ |
|
|
@@ -214,15 +219,15 @@ namespace Svelto.ECS.Internal |
|
|
|
} |
|
|
|
catch |
|
|
|
{ |
|
|
|
Console.LogError( |
|
|
|
"Code crashed inside Remove callback ".FastConcat(reactiveEnginesRemovePerType[i].name)); |
|
|
|
Console.LogError("Code crashed inside Remove callback ".FastConcat(reactiveEnginesRemovePerType[i].name)); |
|
|
|
|
|
|
|
throw; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (reactiveenginesremoveex.TryGetValue(new RefWrapperType(TypeCache<TValue>.type) |
|
|
|
, out var reactiveEnginesRemoveExPerType)) |
|
|
|
if (reactiveenginesremoveex.TryGetValue( |
|
|
|
new RefWrapperType(TypeCache<TValue>.type) |
|
|
|
, out var reactiveEnginesRemoveExPerType)) |
|
|
|
{ |
|
|
|
var enginesCount = reactiveEnginesRemoveExPerType.count; |
|
|
|
|
|
|
@@ -233,14 +238,14 @@ namespace Svelto.ECS.Internal |
|
|
|
{ |
|
|
|
((IReactOnRemoveEx<TValue>)reactiveEnginesRemoveExPerType[i].engine).Remove( |
|
|
|
(0, (uint)count) |
|
|
|
, new EntityCollection<TValue>(typeSafeDictionary.GetValues(out _), entityids |
|
|
|
, (uint)count), group); |
|
|
|
, new EntityCollection<TValue>( |
|
|
|
typeSafeDictionary.GetValues(out _), entityids |
|
|
|
, (uint)count), group); |
|
|
|
} |
|
|
|
} |
|
|
|
catch |
|
|
|
{ |
|
|
|
Console.LogError( |
|
|
|
"Code crashed inside Remove callback ".FastConcat(reactiveEnginesRemoveExPerType[i].name)); |
|
|
|
Console.LogError("Code crashed inside Remove callback ".FastConcat(reactiveEnginesRemoveExPerType[i].name)); |
|
|
|
|
|
|
|
throw; |
|
|
|
} |
|
|
@@ -248,15 +253,14 @@ namespace Svelto.ECS.Internal |
|
|
|
} |
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static void ExecuteEnginesSwapCallbacks<Strategy1, Strategy2, Strategy3, TValue> |
|
|
|
(FasterList<(uint, uint, string)> infostoprocess |
|
|
|
, ref SveltoDictionary<uint, TValue, Strategy1, Strategy2, Strategy3> fromDictionary |
|
|
|
, FasterList<ReactEngineContainer<IReactOnSwap>> reactiveenginesswap, ExclusiveGroupStruct togroup |
|
|
|
, ExclusiveGroupStruct fromgroup, in PlatformProfiler sampler) |
|
|
|
where Strategy1 : struct, IBufferStrategy<SveltoDictionaryNode<uint>> |
|
|
|
where Strategy2 : struct, IBufferStrategy<TValue> |
|
|
|
where Strategy3 : struct, IBufferStrategy<int> |
|
|
|
where TValue : struct, _IInternalEntityComponent |
|
|
|
public static void ExecuteEnginesSwapCallbacks<Strategy1, Strategy2, Strategy3, TValue>(FasterList<(uint, uint, string)> infostoprocess |
|
|
|
, ref SveltoDictionary<uint, TValue, Strategy1, Strategy2, Strategy3> fromDictionary |
|
|
|
, FasterList<ReactEngineContainer<IReactOnSwap>> reactiveenginesswap, ExclusiveGroupStruct togroup |
|
|
|
, ExclusiveGroupStruct fromgroup, in PlatformProfiler sampler) |
|
|
|
where Strategy1 : struct, IBufferStrategy<SveltoDictionaryNode<uint>> |
|
|
|
where Strategy2 : struct, IBufferStrategy<TValue> |
|
|
|
where Strategy3 : struct, IBufferStrategy<int> |
|
|
|
where TValue : struct, _IInternalEntityComponent |
|
|
|
{ |
|
|
|
if (reactiveenginesswap.count == 0) |
|
|
|
return; |
|
|
@@ -270,7 +274,7 @@ namespace Svelto.ECS.Internal |
|
|
|
try |
|
|
|
{ |
|
|
|
ref var entityComponent = ref fromDictionary.GetValueByRef(fromEntityID); |
|
|
|
var newEgid = new EGID(toEntityID, togroup); |
|
|
|
var newEgid = new EGID(toEntityID, togroup); |
|
|
|
for (var j = 0; j < reactiveenginesswap.count; j++) |
|
|
|
using (sampler.Sample(reactiveenginesswap[j].name)) |
|
|
|
{ |
|
|
@@ -283,7 +287,7 @@ namespace Svelto.ECS.Internal |
|
|
|
catch |
|
|
|
{ |
|
|
|
var str = "Crash while executing Swap Entity callback on ".FastConcat(TypeCache<TValue>.name) |
|
|
|
.FastConcat(" from : ", trace); |
|
|
|
.FastConcat(" from : ", trace); |
|
|
|
|
|
|
|
Console.LogError(str); |
|
|
|
|
|
|
@@ -293,21 +297,22 @@ namespace Svelto.ECS.Internal |
|
|
|
} |
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static void ExecuteEnginesSwapCallbacks_Group<Strategy1, Strategy2, Strategy3, TValue> |
|
|
|
(ref SveltoDictionary<uint, TValue, Strategy1, Strategy2, Strategy3> fromDictionary |
|
|
|
, ITypeSafeDictionary<TValue> toDic, ExclusiveGroupStruct togroup, ExclusiveGroupStruct fromgroup |
|
|
|
, ITypeSafeDictionary<TValue> typeSafeDictionary |
|
|
|
, FasterDictionary<RefWrapperType, FasterList<ReactEngineContainer<IReactOnSwap>>> reactiveenginesswap |
|
|
|
, FasterDictionary<RefWrapperType, FasterList<ReactEngineContainer<IReactOnSwapEx>>> reactiveenginesswapex |
|
|
|
, int count, IEntityIDs entityids, in PlatformProfiler sampler) |
|
|
|
where Strategy1 : struct, IBufferStrategy<SveltoDictionaryNode<uint>> |
|
|
|
where Strategy2 : struct, IBufferStrategy<TValue> |
|
|
|
where Strategy3 : struct, IBufferStrategy<int> |
|
|
|
where TValue : struct, _IInternalEntityComponent |
|
|
|
public static void ExecuteEnginesSwapCallbacks_Group<Strategy1, Strategy2, Strategy3, TValue>( |
|
|
|
ref SveltoDictionary<uint, TValue, Strategy1, Strategy2, Strategy3> fromDictionary |
|
|
|
, ITypeSafeDictionary<TValue> toDic, ExclusiveGroupStruct togroup, ExclusiveGroupStruct fromgroup |
|
|
|
, ITypeSafeDictionary<TValue> typeSafeDictionary |
|
|
|
, FasterDictionary<RefWrapperType, FasterList<ReactEngineContainer<IReactOnSwap>>> reactiveenginesswap |
|
|
|
, FasterDictionary<RefWrapperType, FasterList<ReactEngineContainer<IReactOnSwapEx>>> reactiveenginesswapex |
|
|
|
, int count, IEntityIDs entityids, in PlatformProfiler sampler) |
|
|
|
where Strategy1 : struct, IBufferStrategy<SveltoDictionaryNode<uint>> |
|
|
|
where Strategy2 : struct, IBufferStrategy<TValue> |
|
|
|
where Strategy3 : struct, IBufferStrategy<int> |
|
|
|
where TValue : struct, _IInternalEntityComponent |
|
|
|
{ |
|
|
|
//get all the engines linked to TValue |
|
|
|
if (!reactiveenginesswap.TryGetValue(new RefWrapperType(TypeCache<TValue>.type) |
|
|
|
, out var reactiveEnginesSwapPerType)) |
|
|
|
if (!reactiveenginesswap.TryGetValue( |
|
|
|
new RefWrapperType(TypeCache<TValue>.type) |
|
|
|
, out var reactiveEnginesSwapPerType)) |
|
|
|
return; |
|
|
|
|
|
|
|
var componentsEnginesCount = reactiveEnginesSwapPerType.count; |
|
|
@@ -318,7 +323,7 @@ namespace Svelto.ECS.Internal |
|
|
|
foreach (var value in fromDictionary) |
|
|
|
{ |
|
|
|
ref var entityComponent = ref toDic.GetValueByRef(value.key); |
|
|
|
var newEgid = new EGID(value.key, togroup); |
|
|
|
var newEgid = new EGID(value.key, togroup); |
|
|
|
|
|
|
|
using (sampler.Sample(reactiveEnginesSwapPerType[i].name)) |
|
|
|
{ |
|
|
@@ -331,14 +336,14 @@ namespace Svelto.ECS.Internal |
|
|
|
} |
|
|
|
catch (Exception) |
|
|
|
{ |
|
|
|
Console.LogError( |
|
|
|
"Code crashed inside MoveTo callback ".FastConcat(reactiveEnginesSwapPerType[i].name)); |
|
|
|
Console.LogError("Code crashed inside MoveTo callback ".FastConcat(reactiveEnginesSwapPerType[i].name)); |
|
|
|
|
|
|
|
throw; |
|
|
|
} |
|
|
|
|
|
|
|
if (reactiveenginesswapex.TryGetValue(new RefWrapperType(TypeCache<TValue>.type) |
|
|
|
, out var reactiveEnginesRemoveExPerType)) |
|
|
|
if (reactiveenginesswapex.TryGetValue( |
|
|
|
new RefWrapperType(TypeCache<TValue>.type) |
|
|
|
, out var reactiveEnginesRemoveExPerType)) |
|
|
|
{ |
|
|
|
var enginesCount = reactiveEnginesRemoveExPerType.count; |
|
|
|
|
|
|
@@ -349,14 +354,14 @@ namespace Svelto.ECS.Internal |
|
|
|
{ |
|
|
|
((IReactOnSwapEx<TValue>)reactiveEnginesRemoveExPerType[i].engine).MovedTo( |
|
|
|
(0, (uint)count) |
|
|
|
, new EntityCollection<TValue>(typeSafeDictionary.GetValues(out _), entityids |
|
|
|
, (uint)count), fromgroup, togroup); |
|
|
|
, new EntityCollection<TValue>( |
|
|
|
typeSafeDictionary.GetValues(out _), entityids |
|
|
|
, (uint)count), fromgroup, togroup); |
|
|
|
} |
|
|
|
} |
|
|
|
catch |
|
|
|
{ |
|
|
|
Console.LogError( |
|
|
|
"Code crashed inside Remove callback ".FastConcat(reactiveEnginesRemoveExPerType[i].name)); |
|
|
|
Console.LogError("Code crashed inside Remove callback ".FastConcat(reactiveEnginesRemoveExPerType[i].name)); |
|
|
|
|
|
|
|
throw; |
|
|
|
} |
|
|
@@ -364,14 +369,13 @@ namespace Svelto.ECS.Internal |
|
|
|
} |
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static void RemoveEntitiesFromDictionary<Strategy1, Strategy2, Strategy3, TValue> |
|
|
|
(FasterList<(uint, string)> infostoprocess |
|
|
|
, ref SveltoDictionary<uint, TValue, Strategy1, Strategy2, Strategy3> fromDictionary |
|
|
|
, FasterList<uint> entityIDsAffectedByRemoval) |
|
|
|
where Strategy1 : struct, IBufferStrategy<SveltoDictionaryNode<uint>> |
|
|
|
where Strategy2 : struct, IBufferStrategy<TValue> |
|
|
|
where Strategy3 : struct, IBufferStrategy<int> |
|
|
|
where TValue : struct, _IInternalEntityComponent |
|
|
|
public static void RemoveEntitiesFromDictionary<Strategy1, Strategy2, Strategy3, TValue>(FasterList<(uint, string)> infostoprocess |
|
|
|
, ref SveltoDictionary<uint, TValue, Strategy1, Strategy2, Strategy3> fromDictionary |
|
|
|
, FasterList<uint> entityIDsAffectedByRemoval) |
|
|
|
where Strategy1 : struct, IBufferStrategy<SveltoDictionaryNode<uint>> |
|
|
|
where Strategy2 : struct, IBufferStrategy<TValue> |
|
|
|
where Strategy3 : struct, IBufferStrategy<int> |
|
|
|
where TValue : struct, _IInternalEntityComponent |
|
|
|
{ |
|
|
|
var iterations = infostoprocess.count; |
|
|
|
|
|
|
@@ -401,7 +405,7 @@ namespace Svelto.ECS.Internal |
|
|
|
catch |
|
|
|
{ |
|
|
|
var str = "Crash while executing Remove Entity operation on ".FastConcat(TypeCache<TValue>.name) |
|
|
|
.FastConcat(" from : ", trace); |
|
|
|
.FastConcat(" from : ", trace); |
|
|
|
|
|
|
|
Console.LogError(str); |
|
|
|
|
|
|
@@ -411,15 +415,14 @@ namespace Svelto.ECS.Internal |
|
|
|
} |
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static void SwapEntitiesBetweenDictionaries<Strategy1, Strategy2, Strategy3, TValue> |
|
|
|
(FasterList<(uint, uint, string)> infostoprocess |
|
|
|
, ref SveltoDictionary<uint, TValue, Strategy1, Strategy2, Strategy3> fromDictionary |
|
|
|
, ITypeSafeDictionary<TValue> toDictionary, ExclusiveGroupStruct fromgroup, ExclusiveGroupStruct togroup |
|
|
|
, FasterList<uint> entityIDsAffectedByRemoval) |
|
|
|
where Strategy1 : struct, IBufferStrategy<SveltoDictionaryNode<uint>> |
|
|
|
where Strategy2 : struct, IBufferStrategy<TValue> |
|
|
|
where Strategy3 : struct, IBufferStrategy<int> |
|
|
|
where TValue : struct, _IInternalEntityComponent |
|
|
|
public static void SwapEntitiesBetweenDictionaries<Strategy1, Strategy2, Strategy3, TValue>(FasterList<(uint, uint, string)> infostoprocess |
|
|
|
, ref SveltoDictionary<uint, TValue, Strategy1, Strategy2, Strategy3> fromDictionary |
|
|
|
, ITypeSafeDictionary<TValue> toDictionary, ExclusiveGroupStruct fromgroup, ExclusiveGroupStruct togroup |
|
|
|
, FasterList<uint> entityIDsAffectedByRemoval) |
|
|
|
where Strategy1 : struct, IBufferStrategy<SveltoDictionaryNode<uint>> |
|
|
|
where Strategy2 : struct, IBufferStrategy<TValue> |
|
|
|
where Strategy3 : struct, IBufferStrategy<int> |
|
|
|
where TValue : struct, _IInternalEntityComponent |
|
|
|
{ |
|
|
|
var iterations = infostoprocess.count; |
|
|
|
|
|
|
@@ -430,7 +433,7 @@ namespace Svelto.ECS.Internal |
|
|
|
try |
|
|
|
{ |
|
|
|
var fromEntityGid = new EGID(fromID, fromgroup); |
|
|
|
var toEntityEgid = new EGID(toID, togroup); |
|
|
|
var toEntityEgid = new EGID(toID, togroup); |
|
|
|
|
|
|
|
Check.Require(togroup.isInvalid == false, "Invalid To Group"); |
|
|
|
|
|
|
@@ -453,7 +456,7 @@ namespace Svelto.ECS.Internal |
|
|
|
catch |
|
|
|
{ |
|
|
|
var str = "Crash while executing Swap Entity operation on ".FastConcat(TypeCache<TValue>.name) |
|
|
|
.FastConcat(" from : ", trace); |
|
|
|
.FastConcat(" from : ", trace); |
|
|
|
|
|
|
|
Console.LogError(str); |
|
|
|
|
|
|
@@ -463,15 +466,16 @@ namespace Svelto.ECS.Internal |
|
|
|
} |
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static void ExecuteEnginesAddEntityCallbacksFast<TValue> |
|
|
|
(FasterDictionary<RefWrapperType, FasterList<ReactEngineContainer<IReactOnAddEx>>> fasterDictionary |
|
|
|
, ExclusiveGroupStruct groupId, (uint, uint) rangeTuple, IEntityIDs entityids |
|
|
|
, ITypeSafeDictionary<TValue> typeSafeDictionary, PlatformProfiler profiler) |
|
|
|
where TValue : struct, _IInternalEntityComponent |
|
|
|
public static void ExecuteEnginesAddEntityCallbacksFast<TValue>( |
|
|
|
FasterDictionary<RefWrapperType, FasterList<ReactEngineContainer<IReactOnAddEx>>> fasterDictionary |
|
|
|
, ExclusiveGroupStruct groupId, (uint, uint) rangeTuple, IEntityIDs entityids |
|
|
|
, ITypeSafeDictionary<TValue> typeSafeDictionary, PlatformProfiler profiler) |
|
|
|
where TValue : struct, _IInternalEntityComponent |
|
|
|
{ |
|
|
|
//get all the engines linked to TValue |
|
|
|
if (!fasterDictionary.TryGetValue(new RefWrapperType(TypeCache<TValue>.type) |
|
|
|
, out var entityComponentsEngines)) |
|
|
|
if (!fasterDictionary.TryGetValue( |
|
|
|
new RefWrapperType(TypeCache<TValue>.type) |
|
|
|
, out var entityComponentsEngines)) |
|
|
|
return; |
|
|
|
|
|
|
|
for (var i = 0; i < entityComponentsEngines.count; i++) |
|
|
@@ -487,30 +491,28 @@ namespace Svelto.ECS.Internal |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|
Console.LogException( |
|
|
|
e, "Code crashed inside Add callback ".FastConcat(entityComponentsEngines[i].name)); |
|
|
|
Console.LogException(e, "Code crashed inside Add callback ".FastConcat(entityComponentsEngines[i].name)); |
|
|
|
|
|
|
|
throw; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static void ExecuteEnginesSwapCallbacksFast<TValue> |
|
|
|
(FasterList<ReactEngineContainer<IReactOnSwapEx>> fasterList, ExclusiveGroupStruct fromGroup |
|
|
|
, ExclusiveGroupStruct toGroup, IEntityIDs entityids, ITypeSafeDictionary<TValue> typeSafeDictionary |
|
|
|
, (uint, uint) rangeofsubmittedentitiesindicies, PlatformProfiler sampler) |
|
|
|
where TValue : struct, _IInternalEntityComponent |
|
|
|
public static void ExecuteEnginesSwapCallbacksFast<TValue>(FasterList<ReactEngineContainer<IReactOnSwapEx>> fasterList, |
|
|
|
ExclusiveGroupStruct fromGroup |
|
|
|
, ExclusiveGroupStruct toGroup, IEntityIDs entityids, ITypeSafeDictionary<TValue> typeSafeDictionary |
|
|
|
, (uint, uint) rangeofsubmittedentitiesindicies, PlatformProfiler sampler) |
|
|
|
where TValue : struct, _IInternalEntityComponent |
|
|
|
{ |
|
|
|
for (var i = 0; i < fasterList.count; i++) |
|
|
|
try |
|
|
|
{ |
|
|
|
using (sampler.Sample(fasterList[i].name)) |
|
|
|
{ |
|
|
|
((IReactOnSwapEx<TValue>)fasterList[i].engine).MovedTo(rangeofsubmittedentitiesindicies |
|
|
|
, new EntityCollection<TValue>( |
|
|
|
typeSafeDictionary.GetValues( |
|
|
|
out var count), entityids, count) |
|
|
|
, fromGroup, toGroup); |
|
|
|
((IReactOnSwapEx<TValue>)fasterList[i].engine).MovedTo( |
|
|
|
rangeofsubmittedentitiesindicies |
|
|
|
, new EntityCollection<TValue>(typeSafeDictionary.GetValues(out var count), entityids, count) |
|
|
|
, fromGroup, toGroup); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
@@ -522,10 +524,11 @@ namespace Svelto.ECS.Internal |
|
|
|
} |
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
public static void ExecuteEnginesRemoveCallbacksFast<TValue> |
|
|
|
(FasterList<ReactEngineContainer<IReactOnRemoveEx>> fasterList, ExclusiveGroupStruct exclusiveGroupStruct |
|
|
|
, (uint, uint) valueTuple, IEntityIDs entityids, ITypeSafeDictionary<TValue> typeSafeDictionary |
|
|
|
, PlatformProfiler sampler) where TValue : struct, _IInternalEntityComponent |
|
|
|
public static void ExecuteEnginesRemoveCallbacksFast<TValue>(FasterList<ReactEngineContainer<IReactOnRemoveEx>> fasterList, |
|
|
|
ExclusiveGroupStruct exclusiveGroupStruct |
|
|
|
, (uint, uint) valueTuple, IEntityIDs entityids, ITypeSafeDictionary<TValue> typeSafeDictionary |
|
|
|
, PlatformProfiler sampler) |
|
|
|
where TValue : struct, _IInternalEntityComponent |
|
|
|
{ |
|
|
|
for (var i = 0; i < fasterList.count; i++) |
|
|
|
try |
|
|
|