diff --git a/README.md b/README.md
index 1f71b2c6..ae340b38 100644
--- a/README.md
+++ b/README.md
@@ -14,16 +14,15 @@ The code is reasonably clean but documentation and examples are sparse. Feel fre
⚠️ We welcome PRs and bug reports but making this repo a public success is not our priority. No promises on when it will be addressed!
# Dependencies
-- [Unity 2021.3.5+](https://unity.com/)
+- [Unity 2022.3.15+](https://unity.com/)
- [anvil-csharp-core (main...usually 😬)](https://github.com/decline-cookies/anvil-csharp-core)
- [anvil-unity-core (main...usually 😬)](https://github.com/decline-cookies/anvil-unity-core)
- *DOTS Packages*
- - [com.unity.entities (0.50.1-preview2)](https://docs.unity3d.com/Packages/com.unity.entities@0.50/manual/index.html)
- - [com.unity.rendering.hybrid (0.50.0-preview.44)](https://docs.unity3d.com/Packages/com.unity.rendering.hybrid@0.50/manual/index.html)
- - [com.unity.burst (1.6.4)](https://docs.unity3d.com/Packages/com.unity.burst@1.6/manual/index.html)
- - [com.unity.collections (1.2.3)](https://docs.unity3d.com/Packages/com.unity.collections@1.2/manual/index.html)
- - [com.unity.jobs (0.50.0-preview.9)](https://docs.unity3d.com/Packages/com.unity.jobs@0.50/manual/index.html)
- - [com.unity.mathematics (1.2.5)](https://docs.unity3d.com/Packages/com.unity.mathematics@1.2/manual/index.html)
+ - [com.unity.entities (1.0.16)](https://docs.unity3d.com/Packages/com.unity.entities@1.0/manual/index.html)
+ - [com.unity.entities.graphics (1.0.16)](https://docs.unity3d.com/Packages/com.unity.entities.graphics@1.0/manual/index.html)
+ - [com.unity.burst (1.8.11)](https://docs.unity3d.com/Packages/com.unity.burst@1.8/manual/index.html)
+ - [com.unity.collections (2.1.4)](https://docs.unity3d.com/Packages/com.unity.collections@2.1/manual/index.html)
+ - [com.unity.mathematics (1.2.6)](https://docs.unity3d.com/Packages/com.unity.mathematics@1.2/manual/index.html)
At this point in time, all DOTS related functionality is in this one repository. In the future, we may split the functionality into specialized repositories. Maintaining a repository per Unity DOTS package seems overly tedious at the moment.
diff --git a/Scripts/AssemblyInjections/Unity.Collections/FixedListInternalExtension.cs b/Scripts/AssemblyInjections/Unity.Collections/FixedListInternalExtension.cs
index 549b3004..1a529872 100644
--- a/Scripts/AssemblyInjections/Unity.Collections/FixedListInternalExtension.cs
+++ b/Scripts/AssemblyInjections/Unity.Collections/FixedListInternalExtension.cs
@@ -12,7 +12,6 @@ namespace Anvil.Unity.Collections
/// A collection of extension methods for (and friends) that require internal
/// access to function.
///
- [BurstCompatible]
public static unsafe class FixedListInternalExtension
{
///
@@ -153,7 +152,6 @@ public static int IndexOf(this in FixedList4096Bytes
/// ///
/// This is a copy of that supports elements
///
- [BurstCompatible(GenericTypeArguments = new[] { typeof(int), typeof(int) })]
public static bool Contains(this in FixedList32Bytes list, TUnderlying value)
where TEnum : unmanaged, Enum
where TUnderlying : unmanaged, IEquatable
@@ -174,7 +172,6 @@ public static bool Contains(this in FixedList32Bytes
/// ///
/// This is a copy of that supports elements
///
- [BurstCompatible(GenericTypeArguments = new[] { typeof(int), typeof(int) })]
public static bool Contains(this in FixedList64Bytes list, TUnderlying value)
where TEnum : unmanaged, Enum
where TUnderlying : unmanaged, IEquatable
@@ -195,7 +192,6 @@ public static bool Contains(this in FixedList64Bytes
/// ///
/// This is a copy of that supports elements
///
- [BurstCompatible(GenericTypeArguments = new[] { typeof(int), typeof(int) })]
public static bool Contains(this in FixedList128Bytes list, TUnderlying value)
where TEnum : unmanaged, Enum
where TUnderlying : unmanaged, IEquatable
@@ -216,7 +212,6 @@ public static bool Contains(this in FixedList128Bytes
/// ///
/// This is a copy of that supports elements
///
- [BurstCompatible(GenericTypeArguments = new[] { typeof(int), typeof(int) })]
public static bool Contains(this in FixedList512Bytes list, TUnderlying value)
where TEnum : unmanaged, Enum
where TUnderlying : unmanaged, IEquatable
@@ -237,7 +232,6 @@ public static bool Contains(this in FixedList512Bytes
/// ///
/// This is a copy of that supports elements
///
- [BurstCompatible(GenericTypeArguments = new[] { typeof(int), typeof(int) })]
public static bool Contains(this in FixedList4096Bytes list, TUnderlying value)
where TEnum : unmanaged, Enum
where TUnderlying : unmanaged, IEquatable
diff --git a/Scripts/AssemblyInjections/Unity.Collections/NativeParallelHashMapInternalExtension.cs b/Scripts/AssemblyInjections/Unity.Collections/NativeParallelHashMapInternalExtension.cs
index 5148b317..a792466b 100644
--- a/Scripts/AssemblyInjections/Unity.Collections/NativeParallelHashMapInternalExtension.cs
+++ b/Scripts/AssemblyInjections/Unity.Collections/NativeParallelHashMapInternalExtension.cs
@@ -19,8 +19,8 @@ public static class NativeParallelHashMapInternalExtension
/// The value type.
/// The .
public static Allocator GetAllocator(this NativeParallelHashMap map)
- where TKey : struct, IEquatable
- where TValue : struct
+ where TKey : unmanaged, IEquatable
+ where TValue : unmanaged
{
return map.m_HashMapData.GetAllocator();
}
@@ -34,8 +34,8 @@ public static Allocator GetAllocator(this NativeParallelHashMapThe key type.
/// The value type.
public static void GetKeyArray(this NativeParallelHashMap map, NativeArray result)
- where TKey : struct, IEquatable
- where TValue : struct
+ where TKey : unmanaged, IEquatable
+ where TValue : unmanaged
{
map.m_HashMapData.GetKeyArray(result);
}
@@ -49,8 +49,8 @@ public static void GetKeyArray(this NativeParallelHashMapThe key type.
/// The value type.
public static void GetValueArray(this NativeParallelHashMap map, NativeArray result)
- where TKey : struct, IEquatable
- where TValue : struct
+ where TKey : unmanaged, IEquatable
+ where TValue : unmanaged
{
map.m_HashMapData.GetValueArray(result);
}
@@ -64,8 +64,8 @@ public static void GetValueArray(this NativeParallelHashMapThe key type
/// The value type
public static void GetKeyValueArrays(this NativeParallelHashMap map, NativeKeyValueArrays result)
- where TKey : struct, IEquatable
- where TValue : struct
+ where TKey : unmanaged, IEquatable
+ where TValue : unmanaged
{
map.m_HashMapData.GetKeyValueArrays(result);
}
diff --git a/Scripts/AssemblyInjections/Unity.Collections/UnsafeParallelHashMapInternalExtension.cs b/Scripts/AssemblyInjections/Unity.Collections/UnsafeParallelHashMapInternalExtension.cs
index 2db1f7c1..72f417b7 100644
--- a/Scripts/AssemblyInjections/Unity.Collections/UnsafeParallelHashMapInternalExtension.cs
+++ b/Scripts/AssemblyInjections/Unity.Collections/UnsafeParallelHashMapInternalExtension.cs
@@ -20,8 +20,8 @@ public static class UnsafeParallelHashMapInternalExtension
/// The value type.
/// The .
public static Allocator GetAllocator(this UnsafeParallelHashMap map)
- where TKey : struct, IEquatable
- where TValue : struct
+ where TKey : unmanaged, IEquatable
+ where TValue : unmanaged
{
return map.m_AllocatorLabel.ToAllocator;
}
@@ -35,8 +35,8 @@ public static Allocator GetAllocator(this UnsafeParallelHashMapThe key type.
/// The value type.
public static unsafe void GetKeyArray(this UnsafeParallelHashMap map, NativeArray result)
- where TKey : struct, IEquatable
- where TValue : struct
+ where TKey : unmanaged, IEquatable
+ where TValue : unmanaged
{
UnsafeParallelHashMapData.GetKeyArray(map.m_Buffer, result);
}
@@ -50,8 +50,8 @@ public static unsafe void GetKeyArray(this UnsafeParallelHashMapThe key type.
/// The value type.
public static unsafe void GetValueArray(this UnsafeParallelHashMap map, NativeArray result)
- where TKey : struct, IEquatable
- where TValue : struct
+ where TKey : unmanaged, IEquatable
+ where TValue : unmanaged
{
UnsafeParallelHashMapData.GetValueArray(map.m_Buffer, result);
}
@@ -65,8 +65,8 @@ public static unsafe void GetValueArray(this UnsafeParallelHashMap
/// The key type
/// The value type
public static unsafe void GetKeyValueArrays(this UnsafeParallelHashMap map, NativeKeyValueArrays result)
- where TKey : struct, IEquatable
- where TValue : struct
+ where TKey : unmanaged, IEquatable
+ where TValue : unmanaged
{
UnsafeParallelHashMapData.GetKeyValueArrays(map.m_Buffer, result);
}
diff --git a/Scripts/AssemblyInjections/Unity.Entities/ComponentTypeDependencyExtension.cs b/Scripts/AssemblyInjections/Unity.Entities/ComponentTypeDependencyExtension.cs
index c9f00cc2..7bc3f13d 100644
--- a/Scripts/AssemblyInjections/Unity.Entities/ComponentTypeDependencyExtension.cs
+++ b/Scripts/AssemblyInjections/Unity.Entities/ComponentTypeDependencyExtension.cs
@@ -11,11 +11,10 @@
/// A collection of extension methods to help calculate and modify the dependencies on s
/// directly.
///
-[BurstCompatible]
public static class ComponentTypeDependencyExtension
{
- private static UnsafeList s_WriteTypeList_ScratchPad;
- private static UnsafeList s_ReadTypeList_ScratchPad;
+ private static UnsafeList s_WriteTypeList_ScratchPad;
+ private static UnsafeList s_ReadTypeList_ScratchPad;
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
private static void Init()
@@ -24,13 +23,13 @@ private static void Init()
{
s_WriteTypeList_ScratchPad.Dispose();
}
- s_WriteTypeList_ScratchPad = new UnsafeList(0, Allocator.Persistent);
+ s_WriteTypeList_ScratchPad = new UnsafeList(0, Allocator.Persistent);
if (s_ReadTypeList_ScratchPad.IsCreated)
{
s_ReadTypeList_ScratchPad.Dispose();
}
- s_ReadTypeList_ScratchPad = new UnsafeList(0, Allocator.Persistent);
+ s_ReadTypeList_ScratchPad = new UnsafeList(0, Allocator.Persistent);
}
@@ -55,7 +54,6 @@ public static unsafe JobHandle GetDependency(this EntityManager manager, Compone
/// The 's .
/// The component types to calculate the dependency of.
/// The combined dependency for the component types
- [NotBurstCompatible]
public static unsafe JobHandle GetDependency(this EntityManager manager, params ComponentType[] componentTypes)
{
return GetDependency(manager.GetCheckedEntityDataAccess()->DependencyManager, componentTypes);
@@ -70,7 +68,6 @@ public static unsafe JobHandle GetDependency(this EntityManager manager, params
/// The 's .
/// The component types to calculate the dependency of.
/// The combined dependency for the component types
- [NotBurstCompatible]
public static unsafe JobHandle GetDependency(this EntityManager manager, T componentTypes)
where T : class, IEnumerable
{
@@ -110,7 +107,6 @@ public static unsafe JobHandle GetDependency(this ComponentType componentType, E
/// The component types to calculate the dependency of.
/// The 's .
/// The combined dependency for the component types
- [NotBurstCompatible]
public static unsafe JobHandle GetDependency(this T componentTypes, EntityManager manager)
where T : class, IEnumerable
{
@@ -124,7 +120,6 @@ public static unsafe JobHandle GetDependency(this T componentTypes, EntityMan
/// The component types to calculate the dependency of.
/// The 's .
/// The combined dependency for the component types
- [NotBurstCompatible]
public static unsafe JobHandle GetDependency(this ref NativeArray componentTypes, EntityManager manager)
{
return GetDependency(manager.GetCheckedEntityDataAccess()->DependencyManager, ref componentTypes);
@@ -151,7 +146,6 @@ public static unsafe void AddDependency(this EntityManager manager, JobHandle de
/// The 's .
/// The handle that represents when the consuming job is complete.
/// The component types to set the dependency of.
- [NotBurstCompatible]
public static unsafe void AddDependency(this EntityManager manager, JobHandle dependency, params ComponentType[] componentTypes)
{
AddDependency(manager.GetCheckedEntityDataAccess()->DependencyManager, dependency, componentTypes);
@@ -166,7 +160,6 @@ public static unsafe void AddDependency(this EntityManager manager, JobHandle de
/// The 's .
/// The handle that represents when the consuming job is complete.
/// The component types to set the dependency of.
- [NotBurstCompatible]
public static unsafe void AddDependency(this EntityManager manager, JobHandle dependency, T componentTypes)
where T : class, IEnumerable
{
@@ -206,7 +199,6 @@ public static unsafe void AddDependency(this ComponentType componentType, JobHan
/// The component types to set the dependency of.
/// The handle that represents when the consuming job is complete.
/// The 's .
- [NotBurstCompatible]
public static unsafe void AddDependency(this T componentTypes, JobHandle dependency, EntityManager manager)
where T : class, IEnumerable
{
@@ -220,7 +212,6 @@ public static unsafe void AddDependency(this T componentTypes, JobHandle depe
/// The component types to set the dependency of.
/// The handle that represents when the consuming job is complete.
/// The 's .
- [NotBurstCompatible]
public static unsafe void AddDependency(this ref NativeArray componentTypes, JobHandle dependency, EntityManager manager)
{
AddDependency(manager.GetCheckedEntityDataAccess()->DependencyManager, dependency, ref componentTypes);
@@ -235,7 +226,7 @@ private static unsafe JobHandle GetDependency(ComponentDependencyManager* depend
// 1. Get the pointer to the one type index.
// 2. Use the pointer for both the reader and writer parameters
// 3. Calculate the reader/writer count based on the component type's access mode.
- int* typeIndexPtr = (int*)UnsafeUtility.AddressOf(ref componentType.TypeIndex);
+ TypeIndex* typeIndexPtr = (TypeIndex*)UnsafeUtility.AddressOf(ref componentType.TypeIndex);
int writerCount = componentType.AccessModeType == ComponentType.AccessMode.ReadWrite ? 1 : 0;
int readerCount = 1 - writerCount;
@@ -243,7 +234,6 @@ private static unsafe JobHandle GetDependency(ComponentDependencyManager* depend
->GetDependency(typeIndexPtr, readerCount, typeIndexPtr, writerCount);
}
- [NotBurstCompatible]
private static unsafe JobHandle GetDependency(ComponentDependencyManager* dependencyManager, T componentTypes)
where T : class, IEnumerable
{
@@ -266,7 +256,7 @@ private static unsafe void AddDependency(ComponentDependencyManager* dependencyM
// 1. Get the pointer to the one type index.
// 2. Use the pointer for both the reader and writer parameters
// 3. Calculate the reader/writer count based on the component type's access mode.
- int* typeIndexPtr = (int*)UnsafeUtility.AddressOf(ref componentType.TypeIndex);
+ TypeIndex* typeIndexPtr = (TypeIndex*)UnsafeUtility.AddressOf(ref componentType.TypeIndex);
int writerCount = componentType.AccessModeType == ComponentType.AccessMode.ReadWrite ? 1 : 0;
int readerCount = 1 - writerCount;
@@ -274,7 +264,6 @@ private static unsafe void AddDependency(ComponentDependencyManager* dependencyM
->AddDependency(typeIndexPtr, readerCount, typeIndexPtr, writerCount, dependency);
}
- [NotBurstCompatible]
private static unsafe void AddDependency(ComponentDependencyManager* dependencyManager, JobHandle dependency, T componentTypes)
where T : class, IEnumerable
{
@@ -290,7 +279,6 @@ private static unsafe void AddDependency(ComponentDependencyManager* dependencyM
->AddDependency(s_ReadTypeList_ScratchPad.Ptr, s_ReadTypeList_ScratchPad.Length, s_WriteTypeList_ScratchPad.Ptr, s_WriteTypeList_ScratchPad.Length, dependency);
}
- [NotBurstCompatible]
private static void BuildTypeLists(T componentTypes)
where T : class, IEnumerable
{
@@ -313,4 +301,4 @@ private static void BuildTypeLists(ref NativeArray componentTypes
CalculateReaderWriterDependency.Add(componentType, ref s_ReadTypeList_ScratchPad, ref s_WriteTypeList_ScratchPad);
}
}
-}
\ No newline at end of file
+}
diff --git a/Scripts/AssemblyInjections/Unity.Entities/WorldInternal.cs b/Scripts/AssemblyInjections/Unity.Entities/WorldInternal.cs
index 764efe0a..182c602b 100644
--- a/Scripts/AssemblyInjections/Unity.Entities/WorldInternal.cs
+++ b/Scripts/AssemblyInjections/Unity.Entities/WorldInternal.cs
@@ -8,30 +8,6 @@ namespace Anvil.Unity.DOTS.Entities
///
public static class WorldInternal
{
- ///
- /// Dispatched after a world is created.
- ///
- ///
- /// This is a proxy for the internal static event that Unity has made internal.
- ///
- public static event Action OnWorldCreated
- {
- add => World.WorldCreated += value;
- remove => World.WorldCreated -= value;
- }
-
- ///
- /// Dispatched before a world is destroyed.
- ///
- ///
- /// This is a proxy for the internal static event that Unity has made internal.
- ///
- public static event Action OnWorldDestroyed
- {
- add => World.WorldDestroyed += value;
- remove => World.WorldDestroyed -= value;
- }
-
///
/// Dispatched after a system is created.
///
diff --git a/Scripts/Editor/Tests/Entities/Transform/TransformUtilTests.cs b/Scripts/Editor/Tests/Entities/Transform/TransformUtilTests.cs
index 15f510c3..21210957 100644
--- a/Scripts/Editor/Tests/Entities/Transform/TransformUtilTests.cs
+++ b/Scripts/Editor/Tests/Entities/Transform/TransformUtilTests.cs
@@ -61,9 +61,9 @@ public static void AddMissingStandardComponentsTest_NoComponents()
TransformUtil.AddMissingStandardComponents(entity, entityManager);
- Assert.That(entityManager.GetComponentData(entity).Value, Is.EqualTo(float3.zero));
- Assert.That(entityManager.GetComponentData(entity).Value, Is.EqualTo(quaternion.identity));
- Assert.That(entityManager.GetComponentData(entity).Value, Is.EqualTo(1f));
+ Assert.That(entityManager.GetComponentData(entity).Position, Is.EqualTo(float3.zero));
+ Assert.That(entityManager.GetComponentData(entity).Rotation, Is.EqualTo(quaternion.identity));
+ Assert.That(entityManager.GetComponentData(entity).Scale, Is.EqualTo(1f));
}
[Test]
@@ -73,37 +73,14 @@ public static void AddMissingStandardComponentsTest_AllComponents()
using World world = new World(nameof(TransformUtilTests) + "World");
EntityManager entityManager = world.EntityManager;
- Entity entity = entityManager.CreateEntity(typeof(Translation), typeof(Rotation), typeof(Scale));
+ Entity entity = entityManager.CreateEntity(typeof(LocalTransform));
- entityManager.SetComponentData(entity, new Translation() { Value = new float3(5f) });
- entityManager.SetComponentData(entity, new Rotation() { Value = quaternion.Euler(45f, 45f, 0f) });
- entityManager.SetComponentData(entity, new Scale() { Value = 5f });
+ entityManager.SetComponentData(entity, LocalTransform.FromPositionRotationScale(new float3(5f), quaternion.Euler(45f, 45f, 0f), 5f));
TransformUtil.AddMissingStandardComponents(entity, entityManager);
- Assert.That(entityManager.GetComponentData(entity).Value, Is.EqualTo(new float3(5f)));
- Assert.That(entityManager.GetComponentData(entity).Value, Is.EqualTo(quaternion.Euler(45f, 45f, 0f)));
- Assert.That(entityManager.GetComponentData(entity).Value, Is.EqualTo(5f));
- }
-
- [Test]
- public static void AddMissingStandardComponentsTest_AllAltComponents()
- {
- Assert.That(nameof(AddMissingStandardComponentsTest_AllAltComponents), Does.StartWith(nameof(TransformUtil.AddMissingStandardComponents) + "Test"));
-
- using World world = new World(nameof(TransformUtilTests) + "World");
- EntityManager entityManager = world.EntityManager;
- Entity entity = entityManager.CreateEntity(typeof(Translation), typeof(CompositeRotation), typeof(NonUniformScale));
-
- entityManager.SetComponentData(entity, new Translation() { Value = new float3(5f) });
- entityManager.SetComponentData(entity, new CompositeRotation() { Value = float4x4.RotateX(45f) });
- entityManager.SetComponentData(entity, new NonUniformScale() { Value = new float3(1f, 2f, 3f) });
- TransformUtil.AddMissingStandardComponents(entity, entityManager);
-
- Assert.That(entityManager.GetComponentData(entity).Value, Is.EqualTo(new float3(5f)));
- Assert.That(entityManager.GetComponentData(entity).Value, Is.EqualTo(float4x4.RotateX(45f)));
- Assert.That(entityManager.GetComponentData(entity).Value, Is.EqualTo(new float3(1f, 2f, 3f)));
- Assert.That(entityManager.HasComponent(entity), Is.False);
- Assert.That(entityManager.HasComponent(entity), Is.False);
+ Assert.That(entityManager.GetComponentData(entity).Position, Is.EqualTo(new float3(5f)));
+ Assert.That(entityManager.GetComponentData(entity).Rotation, Is.EqualTo(quaternion.Euler(45f, 45f, 0f)));
+ Assert.That(entityManager.GetComponentData(entity).Scale, Is.EqualTo(5f));
}
// ----- ConvertWorldToLocalPoint ----- //
diff --git a/Scripts/Editor/anvil-unity-dots-editor.asmdef b/Scripts/Editor/anvil-unity-dots-editor.asmdef
index 5a108704..e16ffd51 100644
--- a/Scripts/Editor/anvil-unity-dots-editor.asmdef
+++ b/Scripts/Editor/anvil-unity-dots-editor.asmdef
@@ -8,7 +8,6 @@
"Unity.Burst",
"Unity.Collections",
"Unity.Entities",
- "Unity.Jobs",
"Unity.Mathematics"
],
"includePlatforms": [],
diff --git a/Scripts/Runtime/Data/BurstableAtomicIDProvider.cs b/Scripts/Runtime/Data/BurstableAtomicIDProvider.cs
index f6265383..612bd846 100644
--- a/Scripts/Runtime/Data/BurstableAtomicIDProvider.cs
+++ b/Scripts/Runtime/Data/BurstableAtomicIDProvider.cs
@@ -12,7 +12,6 @@ namespace Anvil.Unity.DOTS.Data
/// An that is compatible with Burst and will get the next ID atomically so it is
/// safe to use in threaded context.
///
- [BurstCompatible]
public readonly unsafe struct BurstableAtomicIDProvider
{
public const uint DEFAULT_SUPPLY_WARNING_THRESHOLD = uint.MaxValue - 1_000_000;
diff --git a/Scripts/Runtime/Data/Collections/DeferredNativeArray.cs b/Scripts/Runtime/Data/Collections/DeferredNativeArray.cs
index 33990504..b9bec22a 100644
--- a/Scripts/Runtime/Data/Collections/DeferredNativeArray.cs
+++ b/Scripts/Runtime/Data/Collections/DeferredNativeArray.cs
@@ -69,15 +69,13 @@ internal DeferredNativeArrayScheduleInfo(void* bufferPtr)
/// The type to contain in the
[StructLayout(LayoutKind.Sequential)]
[NativeContainer]
- [BurstCompatible]
public struct DeferredNativeArray : INativeDisposable
where T : unmanaged
{
//*************************************************************************************************************
// INTERNAL STRUCTS
//*************************************************************************************************************
-
- [BurstCompatible]
+
[StructLayout(LayoutKind.Sequential)]
private unsafe struct BufferInfo
{
diff --git a/Scripts/Runtime/Data/Collections/UnsafeTypedStream.cs b/Scripts/Runtime/Data/Collections/UnsafeTypedStream.cs
index 98e90366..c0a2efa6 100644
--- a/Scripts/Runtime/Data/Collections/UnsafeTypedStream.cs
+++ b/Scripts/Runtime/Data/Collections/UnsafeTypedStream.cs
@@ -30,13 +30,11 @@ namespace Anvil.Unity.DOTS.Data
/// fill up the buffer.
///
/// The type of elements to store in the collection.
- [BurstCompatible]
public unsafe struct UnsafeTypedStream : INativeDisposable where T : unmanaged
{
///
/// Information about the itself.
///
- [BurstCompatible]
internal struct BufferInfo
{
public static readonly int SIZE = UnsafeUtility.SizeOf();
@@ -57,7 +55,6 @@ internal struct BufferInfo
///
/// Unity will refer to this as a "foreachindex" which is a little bit confusing.
///
- [BurstCompatible]
[StructLayout(LayoutKind.Sequential, Size = 64)]
internal struct LaneInfo
{
@@ -77,7 +74,6 @@ internal struct LaneInfo
/// Contains the pointer to where the "block" begins and a pointer to another instance
/// for the next "block" in the linked list.
///
- [BurstCompatible]
internal struct BlockInfo
{
public static readonly int SIZE = UnsafeUtility.SizeOf();
@@ -508,7 +504,6 @@ public NativeArray ToNativeArray(Allocator allocator)
///
/// A lightweight struct to allow for writing to the collection
///
- [BurstCompatible]
public readonly struct Writer
{
internal static Writer ReinterpretFromPointer(void* ptr)
@@ -582,7 +577,6 @@ public LaneWriter AsLaneWriter(int laneIndex)
///
/// A lightweight writer instance that is locked to a specific lane
///
- [BurstCompatible]
public readonly struct LaneWriter
{
[NativeDisableUnsafePtrRestriction] private readonly BufferInfo* m_BufferInfo;
@@ -678,7 +672,6 @@ private void CheckForNewBlock()
///
/// A lightweight struct to allow for reader from the collection
///
- [BurstCompatible]
public readonly struct Reader
{
[NativeDisableUnsafePtrRestriction] private readonly BufferInfo* m_BufferInfo;
@@ -778,7 +771,6 @@ public NativeArray ToNativeArray(Allocator allocator)
/// 's manage their own state so that multiple readers can read from a given lane at
/// the same time.
///
- [BurstCompatible]
public struct LaneReader
{
[NativeDisableUnsafePtrRestriction] private readonly BufferInfo* m_BufferInfo;
diff --git a/Scripts/Runtime/Data/Collections/Util/EnumEnumerableToFixedStringExtension.cs b/Scripts/Runtime/Data/Collections/Util/EnumEnumerableToFixedStringExtension.cs
index d5c04754..00718f90 100644
--- a/Scripts/Runtime/Data/Collections/Util/EnumEnumerableToFixedStringExtension.cs
+++ b/Scripts/Runtime/Data/Collections/Util/EnumEnumerableToFixedStringExtension.cs
@@ -32,7 +32,7 @@ public static class EnumEnumerableToFixedStringExtension
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TOutputString ToFixedString(in this UnsafeList collection)
where TElement : unmanaged, Enum
- where TOutputString : struct, INativeList, IUTF8Bytes
+ where TOutputString : unmanaged, INativeList, IUTF8Bytes
{
var collectionAsRef = UnsafeUtilityExtensions.AsRef(in collection);
return UnsafeUtility.As, UnsafeList>>(ref collectionAsRef)
@@ -55,7 +55,7 @@ public static TOutputString ToFixedString(in this Unsaf
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TOutputString ToFixedString(in this NativeList collection)
where TElement : unmanaged, Enum
- where TOutputString : struct, INativeList, IUTF8Bytes
+ where TOutputString : unmanaged, INativeList, IUTF8Bytes
{
var collectionAsRef = UnsafeUtilityExtensions.AsRef(in collection);
return UnsafeUtility.As, NativeList>>(ref collectionAsRef)
@@ -77,7 +77,7 @@ public static TOutputString ToFixedString(in this Nativ
///
public static TOutputString ToFixedString(in this UnsafeArray collection)
where TElement : unmanaged, Enum
- where TOutputString : struct, INativeList, IUTF8Bytes
+ where TOutputString : unmanaged, INativeList, IUTF8Bytes
{
var collectionAsRef = UnsafeUtilityExtensions.AsRef(in collection);
return UnsafeUtility.As, UnsafeArray>>(ref collectionAsRef)
@@ -99,7 +99,7 @@ public static TOutputString ToFixedString(in this Unsaf
///
public static TOutputString ToFixedString(in this NativeArray collection)
where TElement : unmanaged, Enum
- where TOutputString : struct, INativeList, IUTF8Bytes
+ where TOutputString : unmanaged, INativeList, IUTF8Bytes
{
var collectionAsRef = UnsafeUtilityExtensions.AsRef(in collection);
return UnsafeUtility.As, NativeArray>>(ref collectionAsRef)
@@ -121,7 +121,7 @@ public static TOutputString ToFixedString(in this Nativ
///
public static TOutputString ToFixedString(in this NativeArray.ReadOnly collection)
where TElement : unmanaged, Enum
- where TOutputString : struct, INativeList, IUTF8Bytes
+ where TOutputString : unmanaged, INativeList, IUTF8Bytes
{
var collectionAsRef = UnsafeUtilityExtensions.AsRef(in collection);
return UnsafeUtility.As.ReadOnly, NativeArray>.ReadOnly>(ref collectionAsRef)
@@ -144,7 +144,7 @@ public static TOutputString ToFixedString(in this Nativ
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TOutputString ToFixedString(in this FixedList32Bytes collection)
where TElement : unmanaged, Enum
- where TOutputString : struct, INativeList, IUTF8Bytes
+ where TOutputString : unmanaged, INativeList, IUTF8Bytes
{
var collectionAsRef = UnsafeUtilityExtensions.AsRef(in collection);
return UnsafeUtility.As, FixedList32Bytes>>(ref collectionAsRef)
@@ -167,7 +167,7 @@ public static TOutputString ToFixedString(in this Fixed
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TOutputString ToFixedString(in this FixedList64Bytes collection)
where TElement : unmanaged, Enum
- where TOutputString : struct, INativeList, IUTF8Bytes
+ where TOutputString : unmanaged, INativeList, IUTF8Bytes
{
var collectionAsRef = UnsafeUtilityExtensions.AsRef(in collection);
return UnsafeUtility.As, FixedList64Bytes>>(ref collectionAsRef)
@@ -190,7 +190,7 @@ public static TOutputString ToFixedString(in this Fixed
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TOutputString ToFixedString(in this FixedList128Bytes collection)
where TElement : unmanaged, Enum
- where TOutputString : struct, INativeList, IUTF8Bytes
+ where TOutputString : unmanaged, INativeList, IUTF8Bytes
{
var collectionAsRef = UnsafeUtilityExtensions.AsRef(in collection);
return UnsafeUtility.As, FixedList128Bytes>>(ref collectionAsRef)
@@ -213,7 +213,7 @@ public static TOutputString ToFixedString(in this Fixed
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TOutputString ToFixedString(in this FixedList512Bytes collection)
where TElement : unmanaged, Enum
- where TOutputString : struct, INativeList, IUTF8Bytes
+ where TOutputString : unmanaged, INativeList, IUTF8Bytes
{
var collectionAsRef = UnsafeUtilityExtensions.AsRef(in collection);
return UnsafeUtility.As, FixedList512Bytes>>(ref collectionAsRef)
@@ -236,7 +236,7 @@ public static TOutputString ToFixedString(in this Fixed
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TOutputString ToFixedString(in this FixedList4096Bytes collection)
where TElement : unmanaged, Enum
- where TOutputString : struct, INativeList, IUTF8Bytes
+ where TOutputString : unmanaged, INativeList, IUTF8Bytes
{
var collectionAsRef = UnsafeUtilityExtensions.AsRef(in collection);
return UnsafeUtility.As, FixedList4096Bytes>>(ref collectionAsRef)
diff --git a/Scripts/Runtime/Data/Collections/Util/EnumerableToFixedStringExtension.cs b/Scripts/Runtime/Data/Collections/Util/EnumerableToFixedStringExtension.cs
index 54cbb8b0..5a233374 100644
--- a/Scripts/Runtime/Data/Collections/Util/EnumerableToFixedStringExtension.cs
+++ b/Scripts/Runtime/Data/Collections/Util/EnumerableToFixedStringExtension.cs
@@ -30,7 +30,7 @@ public static class EnumerableToFixedStringExtension
public static TOutputString ToFixedString(in this UnsafeParallelHashSet collection)
where TElement : unmanaged, IToFixedString, IEquatable
where TElementString : struct, INativeList, IUTF8Bytes
- where TOutputString : struct, INativeList, IUTF8Bytes
+ where TOutputString : unmanaged, INativeList, IUTF8Bytes
{
ref var collectionAsRef = ref UnsafeUtilityExtensions.AsRef(in collection);
UnsafeParallelHashSet.Enumerator enumerator = collectionAsRef.GetEnumerator();
@@ -53,7 +53,7 @@ public static TOutputString ToFixedString(in this NativeParallelHashSet collection)
where TElement : unmanaged, IToFixedString, IEquatable
where TElementString : struct, INativeList, IUTF8Bytes
- where TOutputString : struct, INativeList, IUTF8Bytes
+ where TOutputString : unmanaged, INativeList, IUTF8Bytes
{
ref var collectionAsRef = ref UnsafeUtilityExtensions.AsRef(in collection);
NativeParallelHashSet.Enumerator enumerator = collectionAsRef.GetEnumerator();
@@ -76,7 +76,7 @@ public static TOutputString ToFixedString(in this UnsafeList collection)
where TElement : unmanaged, IToFixedString
where TElementString : struct, INativeList, IUTF8Bytes
- where TOutputString : struct, INativeList, IUTF8Bytes
+ where TOutputString : unmanaged, INativeList, IUTF8Bytes
{
ref var collectionAsRef = ref UnsafeUtilityExtensions.AsRef(in collection);
UnsafeList.Enumerator enumerator = collectionAsRef.GetEnumerator();
@@ -99,7 +99,7 @@ public static TOutputString ToFixedString(in this NativeList collection)
where TElement : unmanaged, IToFixedString
where TElementString : struct, INativeList, IUTF8Bytes
- where TOutputString : struct, INativeList, IUTF8Bytes
+ where TOutputString : unmanaged, INativeList, IUTF8Bytes
{
ref var collectionAsRef = ref UnsafeUtilityExtensions.AsRef(in collection);
NativeArray.Enumerator enumerator = collectionAsRef.GetEnumerator();
@@ -122,7 +122,7 @@ public static TOutputString ToFixedString(in this UnsafeArray collection)
where TElement : unmanaged, IToFixedString
where TElementString : struct, INativeList, IUTF8Bytes
- where TOutputString : struct, INativeList, IUTF8Bytes
+ where TOutputString : unmanaged, INativeList, IUTF8Bytes
{
ref var collectionAsRef = ref UnsafeUtilityExtensions.AsRef(in collection);
UnsafeArray.Enumerator enumerator = collectionAsRef.GetEnumerator();
@@ -145,7 +145,7 @@ public static TOutputString ToFixedString(in this NativeArray collection)
where TElement : unmanaged, IToFixedString
where TElementString : struct, INativeList, IUTF8Bytes
- where TOutputString : struct, INativeList, IUTF8Bytes
+ where TOutputString : unmanaged, INativeList, IUTF8Bytes
{
ref var collectionAsRef = ref UnsafeUtilityExtensions.AsRef(in collection);
NativeArray.Enumerator enumerator = collectionAsRef.GetEnumerator();
@@ -168,7 +168,7 @@ public static TOutputString ToFixedString(in this NativeArray.ReadOnly collection)
where TElement : unmanaged, IToFixedString
where TElementString : struct, INativeList, IUTF8Bytes
- where TOutputString : struct, INativeList, IUTF8Bytes
+ where TOutputString : unmanaged, INativeList, IUTF8Bytes
{
ref var collectionAsRef = ref UnsafeUtilityExtensions.AsRef(in collection);
NativeArray.ReadOnly.Enumerator enumerator = collectionAsRef.GetEnumerator();
@@ -191,7 +191,7 @@ public static TOutputString ToFixedString(in this FixedList32Bytes collection)
where TElement : unmanaged, IToFixedString
where TElementString : struct, INativeList, IUTF8Bytes
- where TOutputString : struct, INativeList, IUTF8Bytes
+ where TOutputString : unmanaged, INativeList, IUTF8Bytes
{
ref var collectionAsRef = ref UnsafeUtilityExtensions.AsRef(in collection);
FixedList32Bytes.Enumerator enumerator = collectionAsRef.GetEnumerator();
@@ -214,7 +214,7 @@ public static TOutputString ToFixedString(in this FixedList64Bytes collection)
where TElement : unmanaged, IToFixedString
where TElementString : struct, INativeList, IUTF8Bytes
- where TOutputString : struct, INativeList, IUTF8Bytes
+ where TOutputString : unmanaged, INativeList, IUTF8Bytes
{
ref var collectionAsRef = ref UnsafeUtilityExtensions.AsRef(in collection);
FixedList64Bytes.Enumerator enumerator = collectionAsRef.GetEnumerator();
@@ -237,7 +237,7 @@ public static TOutputString ToFixedString(in this FixedList128Bytes collection)
where TElement : unmanaged, IToFixedString
where TElementString : struct, INativeList, IUTF8Bytes
- where TOutputString : struct, INativeList, IUTF8Bytes
+ where TOutputString : unmanaged, INativeList, IUTF8Bytes
{
ref var collectionAsRef = ref UnsafeUtilityExtensions.AsRef(in collection);
FixedList128Bytes.Enumerator enumerator = collectionAsRef.GetEnumerator();
@@ -260,7 +260,7 @@ public static TOutputString ToFixedString(in this FixedList512Bytes collection)
where TElement : unmanaged, IToFixedString
where TElementString : struct, INativeList, IUTF8Bytes
- where TOutputString : struct, INativeList, IUTF8Bytes
+ where TOutputString : unmanaged, INativeList, IUTF8Bytes
{
ref var collectionAsRef = ref UnsafeUtilityExtensions.AsRef(in collection);
FixedList512Bytes.Enumerator enumerator = collectionAsRef.GetEnumerator();
@@ -283,7 +283,7 @@ public static TOutputString ToFixedString(in this FixedList4096Bytes collection)
where TElement : unmanaged, IToFixedString
where TElementString : struct, INativeList, IUTF8Bytes
- where TOutputString : struct, INativeList, IUTF8Bytes
+ where TOutputString : unmanaged, INativeList, IUTF8Bytes
{
ref var collectionAsRef = ref UnsafeUtilityExtensions.AsRef(in collection);
FixedList4096Bytes.Enumerator enumerator = collectionAsRef.GetEnumerator();
@@ -307,7 +307,7 @@ public static unsafe TOutputString ToFixedString
where TElement : struct, IToFixedString
where TElementString : struct, INativeList, IUTF8Bytes
- where TOutputString : struct, INativeList, IUTF8Bytes
+ where TOutputString : unmanaged, INativeList, IUTF8Bytes
{
TOutputString output = default;
output.Append('[');
diff --git a/Scripts/Runtime/Data/Collections/Util/NativeParallelHashMapExtension.cs b/Scripts/Runtime/Data/Collections/Util/NativeParallelHashMapExtension.cs
index c57b725b..c9c9b1a9 100644
--- a/Scripts/Runtime/Data/Collections/Util/NativeParallelHashMapExtension.cs
+++ b/Scripts/Runtime/Data/Collections/Util/NativeParallelHashMapExtension.cs
@@ -18,8 +18,8 @@ public static class NativeParallelHashMapExtension
/// The value type.
/// True if a key-value pair was removed.
public static bool Remove(this NativeParallelHashMap map, TKey key, out TValue value)
- where TKey : struct, IEquatable
- where TValue : struct
+ where TKey : unmanaged, IEquatable
+ where TValue : unmanaged
{
return map.TryGetValue(key, out value) && map.Remove(key);
}
diff --git a/Scripts/Runtime/Data/Collections/Util/NativeParallelHashSetExtension.cs b/Scripts/Runtime/Data/Collections/Util/NativeParallelHashSetExtension.cs
index 732df158..e7d5ff54 100644
--- a/Scripts/Runtime/Data/Collections/Util/NativeParallelHashSetExtension.cs
+++ b/Scripts/Runtime/Data/Collections/Util/NativeParallelHashSetExtension.cs
@@ -8,6 +8,7 @@ namespace Anvil.Unity.DOTS.Data
///
/// A collection of extension methods for .
///
+ [BurstCompile]
public static class NativeParallelHashSetExtension
{
///
@@ -66,4 +67,4 @@ public static void CopyFrom(this NativeParallelHashSet destination, IEnume
}
}
}
-}
+}
\ No newline at end of file
diff --git a/Scripts/Runtime/Data/Collections/Util/UnsafeParallelHashMapExtension.cs b/Scripts/Runtime/Data/Collections/Util/UnsafeParallelHashMapExtension.cs
index 69e598c7..1b9d8a08 100644
--- a/Scripts/Runtime/Data/Collections/Util/UnsafeParallelHashMapExtension.cs
+++ b/Scripts/Runtime/Data/Collections/Util/UnsafeParallelHashMapExtension.cs
@@ -18,8 +18,8 @@ public static class UnsafeParallelHashMapExtension
/// The value type.
/// True if a key-value pair was removed.
public static bool Remove(this UnsafeParallelHashMap map, TKey key, out TValue value)
- where TKey : struct, IEquatable
- where TValue : struct
+ where TKey : unmanaged, IEquatable
+ where TValue : unmanaged
{
return map.TryGetValue(key, out value) && map.Remove(key);
}
diff --git a/Scripts/Runtime/Entities/AbstractAnvilSystemBase.cs b/Scripts/Runtime/Entities/AbstractAnvilSystemBase.cs
index 16b54db3..adc2069f 100644
--- a/Scripts/Runtime/Entities/AbstractAnvilSystemBase.cs
+++ b/Scripts/Runtime/Entities/AbstractAnvilSystemBase.cs
@@ -86,7 +86,8 @@ private void EnsureSystemIsInUpdateGroup()
m_UpdateInGroupType = updateInGroupAttribute.GroupType;
//We'll get or create the system specified in the attribute. It SHOULD be a Group, but might not be so...
- ComponentSystemBase componentSystemBase = World.GetOrCreateSystem(m_UpdateInGroupType);
+ ComponentSystemBase componentSystemBase = World.GetOrCreateSystemManaged(m_UpdateInGroupType);
+
if (componentSystemBase is not ComponentSystemGroup componentSystemGroup)
{
//We'll rightly complain about it.
diff --git a/Scripts/Runtime/Entities/AccessControl.meta b/Scripts/Runtime/Entities/AccessControl.meta
deleted file mode 100644
index f440e2ec..00000000
--- a/Scripts/Runtime/Entities/AccessControl.meta
+++ /dev/null
@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: 13cde9bd371af472b837b3582b4aa1a3
-folderAsset: yes
-DefaultImporter:
- externalObjects: {}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Scripts/Runtime/Entities/AccessControl/DynamicBufferSharedWriteController.cs b/Scripts/Runtime/Entities/AccessControl/DynamicBufferSharedWriteController.cs
deleted file mode 100644
index 70ff4eca..00000000
--- a/Scripts/Runtime/Entities/AccessControl/DynamicBufferSharedWriteController.cs
+++ /dev/null
@@ -1,378 +0,0 @@
-using Anvil.CSharp.Core;
-using System;
-using System.Collections.Generic;
-using Unity.Entities;
-using Unity.Jobs;
-using UnityEngine;
-
-namespace Anvil.Unity.DOTS.Entities
-{
- internal interface IDynamicBufferSharedWriteController : IDisposable
- {
- ///
- /// Registers a as a system that will shared write to
- /// the .
- ///
- /// The that shared writes.
- void RegisterSystemForSharedWrite(ComponentSystemBase system);
-
- ///
- /// Unregisters a as a system that will shared write to
- /// the .
- ///
- /// The that shared writes.
- void UnregisterSystemForSharedWrite(ComponentSystemBase system);
-
- ///
- /// Gets a to be used to schedule the jobs that will shared writing to the
- /// .
- ///
- /// The that is doing the shared writing.
- /// The incoming Dependency for the
- /// The to schedule shared writing jobs
- JobHandle GetSharedWriteDependency(SystemBase callingSystem, JobHandle callingSystemDependency);
-
- ///
- /// Sets the shared write dependency to the passed in
- ///
- /// The to set to
- void ForceSetSharedWriteDependency(JobHandle dependsOn);
- }
-
- ///
- /// A utility class that handles managing access for shared writing (multiple job types writing at the same time)
- /// so that jobs can be scheduled easily.
- ///
- /// ****IMPORTANT NOTE****
- /// Using this class is very helpful for the specific task of writing to a in
- /// parallel from multiple job types. This class DOES NOT prevent multiple threads from writing to the same element.
- /// Typically, this means that the use case should guarantee that there is no overlap in buffer element access.
- /// For example, element ranges (1-n) are dedicated to specific worker indices.
- /// (Worker 0 writes to element 0, Worker 3 writes to element 3, etc...)
- ///
- /// In order to achieve this functionality the class tracks the World's system order to the best of its ability.
- /// There are cases where this isn't perfect and your won't get the results you expect.
- /// These cases are outlined below to aid in debugging if needed.
- ///
- /// ALL OF THESE SHOULD BE VERY RARE
- ///
- /// - The checks to see if it should be rebuilt by the number of systems in each
- /// . If the system count between checks does not change
- /// (system reorder or balanced adds/removes) the will not get automatically updated
- /// and therefore is unable to correctly infer system dependencies. To work around this limitation
- /// call after adding, removing or re-ordering systems.
- ///
- /// - If you are using s that your Systems aren't aware of.
- /// Ex. Queries created with will not detect jobs that touch your
- /// . Always use the function.
- ///
- /// - If you are scheduling jobs outside of a System that operate on this class
- /// will not be aware of it and may lead to a dependency conflict. Consider using a
- /// to handle this instead.
- ///
- /// - If you are scheduling multiple jobs in a System that operates on the where
- /// one uses the Shared Write handle and the other(s) try and do an exclusive write or read, we treat that
- /// System as only using the Shared Write handle.
- ///
- /// - If you are calling that operates on the
- /// outside of your , this
- /// class may not be aware of the query until the is rebuilt.
- /// This means that a write or read operation may sneak in between two shared writes which would lead to a
- /// dependency conflict. It is best practice to create all queries in the or
- /// if you must create the query later, manually rebuild the .
- ///
- /// - You may get a false positive if you have a System that has two or more queries in it. One that operates on
- /// your (QueryA) and one that doesn't (QueryB). If the logic has the QueryB
- /// execute but QueryA doesn't, we still see the system as having executed and we'll count it as a point to move
- /// the handle up when in reality it could have been ignored.
- ///
- ///
- ///
- /// This is similar to the but for specific use with a
- /// where shared writing is desired.
- ///
- ///
- /// The type this instance is associated with.
- internal class DynamicBufferSharedWriteController : AbstractAnvilBase, IDynamicBufferSharedWriteController
- where T : IBufferElementData
- {
- //*************************************************************************************************************
- // INTERNAL HELPER
- //*************************************************************************************************************
-
- ///
- /// Handles our specific cached view of the
- ///
- private class LocalCache : AbstractCache
- {
- private readonly WorldCache m_WorldCache;
- private readonly HashSet m_QueryComponentTypes;
- private readonly List m_OrderedSystems = new List();
- private readonly List m_ExecutedOrderedSystems = new List();
- private readonly Dictionary m_ExecutedOrderedSystemsLookup = new Dictionary();
- private readonly Dictionary m_OrderedSystemsVersions = new Dictionary();
-
- private int m_OrderedSystemsIndexForExecution;
- private int m_LastRebuildCheckFrameCount;
-
- internal LocalCache(
- WorldCache worldCache,
- ComponentType componentType)
- {
- m_WorldCache = worldCache;
- m_QueryComponentTypes = new HashSet
- {
- componentType
- };
- }
-
- internal int GetExecutionOrderOf(ComponentSystemBase callingSystem)
- {
- return !m_ExecutedOrderedSystemsLookup.TryGetValue(callingSystem, out int order)
- ? m_ExecutedOrderedSystems.Count
- : order;
- }
-
- internal ComponentSystemBase GetSystemAtExecutionOrder(int executionOrder)
- {
-#if ENABLE_UNITY_COLLECTIONS_CHECKS
- if (executionOrder <= 0 || executionOrder > m_ExecutedOrderedSystems.Count)
- {
- throw new InvalidOperationException($"Invalid execution order of {executionOrder}.{nameof(m_ExecutedOrderedSystems)} Count is {m_ExecutedOrderedSystems.Count}");
- }
-#endif
-
- return m_ExecutedOrderedSystems[executionOrder];
- }
-
- internal void RebuildIfNeeded()
- {
- //TODO: #27 Move to AbstractCache?
- //This might be called many times a frame by many different callers.
- //We only want to do this check once per frame.
- int currentFrameCount = Time.frameCount;
- if (m_LastRebuildCheckFrameCount == currentFrameCount)
- {
- return;
- }
-
- m_LastRebuildCheckFrameCount = currentFrameCount;
-
- //Once per frame we want to reset our execution order since some systems may not have executed.
- ResetExecutionOrder();
-
- //Rebuild the world cache if it needs to be
- m_WorldCache.RebuildIfNeeded();
-
- //If our local cache doesn't match the latest world cache, we need to update
- if (Version == m_WorldCache.Version)
- {
- return;
- }
-
- //Find all the systems that have queries that match our IBufferElementData
- RebuildMatchingSystems();
-
- //Ensure we're not going to do this again until the World changes.
- Version = m_WorldCache.Version;
- }
-
- private void RebuildMatchingSystems()
- {
- //Build up our internal model of a list (in order) of systems that will operate on our IBufferElementData
- m_OrderedSystemsVersions.Clear();
- m_WorldCache.RefreshSystemsWithQueriesFor(m_QueryComponentTypes, m_OrderedSystems);
- //Initialize a lookup with the last version these systems ran at
- foreach (ComponentSystemBase system in m_OrderedSystems)
- {
- m_OrderedSystemsVersions[system] = system.LastSystemVersion;
- }
- }
-
- private void ResetExecutionOrder()
- {
- m_OrderedSystemsIndexForExecution = 0;
- m_ExecutedOrderedSystems.Clear();
- m_ExecutedOrderedSystemsLookup.Clear();
- }
-
- internal void UpdateExecutedSystems(ComponentSystemBase callingSystem)
- {
- //Once a frame we'll end up iterating through all the OrderedSystems but there's no need to iterate
- //the whole list each time. Instead, we'll track the progress through the frame and only iterate up
- //to the system that is currently executing and thus checking when it can shared write.
- for (; m_OrderedSystemsIndexForExecution < m_OrderedSystems.Count; ++m_OrderedSystemsIndexForExecution)
- {
- ComponentSystemBase system = m_OrderedSystems[m_OrderedSystemsIndexForExecution];
-
- //If we're the calling system, the loop is done, we should exit.
- if (callingSystem == system)
- {
- break;
- }
-
- //Internally, Systems will execute if they are enabled, set to AlwaysUpdate or have any queries
- //that will return entities. The systems do this check via ShouldRunSystem and Enabled.
- //While we could reflect and call that again, it seems inefficient to do so especially since it
- //has already been done. Instead we can check if a system HAS run this frame by comparing the
- //LastSystemVersion with our cached version. If the versions are the same, the system didn't run
- //for any number of reasons and we can exclude it from our order. If it is enabled the next frame
- //the versions won't match and we'll add it back to our executed list.
- if (!DidSystemExecuteSinceLastCheck(system))
- {
- continue;
- }
-
- m_OrderedSystemsVersions[system] = system.LastSystemVersion;
- m_ExecutedOrderedSystems.Add(system);
- m_ExecutedOrderedSystemsLookup[system] = m_OrderedSystemsIndexForExecution;
- }
- }
-
- private bool DidSystemExecuteSinceLastCheck(ComponentSystemBase system)
- {
- uint cachedSystemVersion = m_OrderedSystemsVersions[system];
-#if ENABLE_UNITY_COLLECTIONS_CHECKS
- if (cachedSystemVersion > system.LastSystemVersion)
- {
- throw new InvalidOperationException($"Investigate. Cached System Version {cachedSystemVersion} is larger than the last recorded version {system.LastSystemVersion}");
- }
-#endif
- return system.LastSystemVersion > cachedSystemVersion;
- }
- }
-
-
- //*************************************************************************************************************
- // PUBLIC CLASS
- //*************************************************************************************************************
-
- private readonly HashSet m_SharedWriteSystems = new HashSet();
-
- private readonly World m_World;
- private readonly LocalCache m_LocalCache;
- private readonly DynamicBufferSharedWriteDataSystem.LookupByComponentType m_LookupByComponentType;
-
- private JobHandle m_SharedWriteDependency;
- private int m_ExecutionOrderOfLastSharedWriteDependency;
-
- ///
- /// The of this instance is associated with.
- ///
- public ComponentType ComponentType { get; }
-
- internal DynamicBufferSharedWriteController(
- ComponentType type,
- World world,
- DynamicBufferSharedWriteDataSystem.LookupByComponentType lookupByComponentType)
- {
- ComponentType = type;
- m_World = world;
- m_LookupByComponentType = lookupByComponentType;
- WorldCacheDataSystem worldCacheDataSystem = m_World.GetOrCreateSystem();
- m_LocalCache = new LocalCache(worldCacheDataSystem.WorldCache, ComponentType);
- }
-
- protected override void DisposeSelf()
- {
- // NOTE: If these asserts trigger we should think about calling Complete() on these job handles.
-#if ENABLE_UNITY_COLLECTIONS_CHECKS
- if (!m_SharedWriteDependency.IsCompleted)
- {
- throw new InvalidOperationException("The shared write access dependency is not completed");
- }
-#endif
-
- //Remove ourselves from the chain
- m_LookupByComponentType.Remove();
-
- base.DisposeSelf();
- }
-
-
- ///
- public void RegisterSystemForSharedWrite(ComponentSystemBase system)
- {
-#if ENABLE_UNITY_COLLECTIONS_CHECKS
- if (system.World != m_World)
- {
- throw new InvalidOperationException($"System {system} is not part of the same world as this {nameof(DynamicBufferSharedWriteController)}");
- }
-#endif
- m_SharedWriteSystems.Add(system);
- }
-
- ///
- public void UnregisterSystemForSharedWrite(ComponentSystemBase system)
- {
-#if ENABLE_UNITY_COLLECTIONS_CHECKS
- if (system.World != m_World)
- {
- throw new InvalidOperationException($"System {system} is not part of the same world as this {nameof(DynamicBufferSharedWriteController)}");
- }
-#endif
- m_SharedWriteSystems.Remove(system);
- }
-
- ///
- public JobHandle GetSharedWriteDependency(SystemBase callingSystem, JobHandle callingSystemDependency)
- {
-#if ENABLE_UNITY_COLLECTIONS_CHECKS
- if (!m_SharedWriteSystems.Contains(callingSystem))
- {
- throw new InvalidOperationException($"Trying to get the shared write handle but {callingSystem} hasn't been registered. Did you call {nameof(RegisterSystemForSharedWrite)}?");
- }
-#endif
-
- //Rebuild our local cache if we need to. Will trigger a world cache rebuild if necessary too.
- m_LocalCache.RebuildIfNeeded();
-
- //Ensure our local cache has the right order of systems that actually executed this frame
- m_LocalCache.UpdateExecutedSystems(callingSystem);
-
- //Find out when our system executed in the order
- int callingSystemOrder = m_LocalCache.GetExecutionOrderOf(callingSystem);
-
- //If we're the first system to go in a frame, we're the first start point for shared writing.
- if (callingSystemOrder == 0)
- {
- m_SharedWriteDependency = callingSystemDependency;
- m_ExecutionOrderOfLastSharedWriteDependency = callingSystemOrder;
- }
- //Otherwise we want to check the system(s) that executed before us to see what kind of lock they had
- //on our IBufferElementData
- else
- {
- //We want to loop backwards to see if an exclusive write or shared read was inserted
- //in the case where a shared write system DOESN'T call this GetSharedWriteDependency
- for (int i = callingSystemOrder - 1; i > m_ExecutionOrderOfLastSharedWriteDependency; --i)
- {
- //If that system was a shared writable system, we don't want to move our dependency up so that we
- //can also share the write. If not, we move it up.
- if (IsSystemAtExecutionOrderSharedWritable(i))
- {
- continue;
- }
-
- m_SharedWriteDependency = callingSystemDependency;
- m_ExecutionOrderOfLastSharedWriteDependency = callingSystemOrder;
- break;
- }
- }
-
- return m_SharedWriteDependency;
- }
-
- private bool IsSystemAtExecutionOrderSharedWritable(int executionOrder)
- {
- ComponentSystemBase system = m_LocalCache.GetSystemAtExecutionOrder(executionOrder);
- return m_SharedWriteSystems.Contains(system);
- }
-
- ///
- public void ForceSetSharedWriteDependency(JobHandle dependsOn)
- {
- m_SharedWriteDependency = dependsOn;
- }
- }
-}
\ No newline at end of file
diff --git a/Scripts/Runtime/Entities/AccessControl/DynamicBufferSharedWriteController.cs.meta b/Scripts/Runtime/Entities/AccessControl/DynamicBufferSharedWriteController.cs.meta
deleted file mode 100644
index 14d98f6e..00000000
--- a/Scripts/Runtime/Entities/AccessControl/DynamicBufferSharedWriteController.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 5c11fd8cdc7d848ee99a4b1f7ec8ccb6
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Scripts/Runtime/Entities/AccessControl/DynamicBufferSharedWriteDataSystem.cs b/Scripts/Runtime/Entities/AccessControl/DynamicBufferSharedWriteDataSystem.cs
deleted file mode 100644
index fc550885..00000000
--- a/Scripts/Runtime/Entities/AccessControl/DynamicBufferSharedWriteDataSystem.cs
+++ /dev/null
@@ -1,94 +0,0 @@
-using Unity.Entities;
-using Anvil.CSharp.Data;
-
-namespace Anvil.Unity.DOTS.Entities
-{
- ///
- /// Data System (no update) for managing access control to a that you want to
- /// write to in parallel from multiple different types of jobs.
- ///
- ///
- /// Unity by default treats a parallel job (JobTypeA run in parallel) as one job that can run over multiple
- /// threads at the same time. If you want to have more than one job such as JobTypeA and JobTypeB, Unity
- /// will not allow it unless you specify the on
- /// your .
- ///
- /// Doing so means that you can now write to the from multiple job types
- /// but it assumes that you have taken the necessary precautions to ensure your jobs can't conflict with
- /// each other. Typically this means only writing to an index that matches your
- /// or
- ///
- /// Unity's internal read and write handles for scheduling jobs assumes that all jobs are either a shared
- /// read or exclusive write. Since we want both job types to start at the same time, this
- /// facilitates getting that start point while working
- /// nicely in tandem with Unity's built in system that know nothing about your shared writing.
- ///
- /// This can be accomplished with a but it requires
- /// ALL systems in the project who touch the in question to use the
- /// which isn't always feasible.
- ///
- public partial class DynamicBufferSharedWriteDataSystem : AbstractDataSystem
- {
- private LookupByComponentType m_LookupByComponentType;
-
- internal DynamicBufferSharedWriteController GetOrCreate()
- where T : IBufferElementData
- {
- return m_LookupByComponentType.GetOrCreate();
- }
-
- protected override void OnCreate()
- {
- base.OnCreate();
-
- m_LookupByComponentType = new LookupByComponentType(World);
- }
-
- protected override void OnDestroy()
- {
- m_LookupByComponentType.Dispose();
- base.OnDestroy();
- }
-
-
- //*************************************************************************************************************
- // INTERNAL HELPER
- //*************************************************************************************************************
-
- ///
- /// Lookup based on a specific
- ///
- internal class LookupByComponentType : AbstractLookup
- {
- internal LookupByComponentType(World context) : base(context) { }
-
- internal void Remove()
- where T : IBufferElementData
- {
- ComponentType componentType = ComponentType.ReadWrite();
- if (!ContainsKey(componentType))
- {
- return;
- }
-
- LookupRemove(componentType);
- }
-
- // ReSharper disable once MemberHidesStaticFromOuterClass
- internal DynamicBufferSharedWriteController GetOrCreate()
- where T : IBufferElementData
- {
- ComponentType componentType = ComponentType.ReadWrite();
- IDynamicBufferSharedWriteController controller = LookupGetOrCreate(componentType, CreationFunction);
-
- return (DynamicBufferSharedWriteController)controller;
- }
-
- private IDynamicBufferSharedWriteController CreationFunction(ComponentType componentType)
- where T : IBufferElementData
- {
- return new DynamicBufferSharedWriteController(componentType, Context, this);
- }
- }
- }
-}
diff --git a/Scripts/Runtime/Entities/AccessControl/DynamicBufferSharedWriteDataSystem.cs.meta b/Scripts/Runtime/Entities/AccessControl/DynamicBufferSharedWriteDataSystem.cs.meta
deleted file mode 100644
index 58efd174..00000000
--- a/Scripts/Runtime/Entities/AccessControl/DynamicBufferSharedWriteDataSystem.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 39c290f8517fa4d13b3ab5de80a0f2f1
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Scripts/Runtime/Entities/AccessControl/DynamicBufferSharedWriteHandle.cs b/Scripts/Runtime/Entities/AccessControl/DynamicBufferSharedWriteHandle.cs
deleted file mode 100644
index 4819222d..00000000
--- a/Scripts/Runtime/Entities/AccessControl/DynamicBufferSharedWriteHandle.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-using Anvil.CSharp.Core;
-using Unity.Entities;
-using Unity.Jobs;
-
-namespace Anvil.Unity.DOTS.Entities
-{
- ///
- /// A handle to allow for figuring out the dependency of scheduling a job that will shared write to a
- ///