public InsideForEach(EntityManager manager)
            {
                m_Manager = manager;
                EntityDataAccess *g = manager.GetCheckedEntityDataAccess();

                m_InsideForEachSafety = g->m_InsideForEach++;
            }
Пример #2
0
        public static object GetComponentData(EntityManager entityManager, Entity entity, ComponentType componentType)
        {
            EntityDataAccess *    dataAccess           = entityManager.GetCheckedEntityDataAccess();
            EntityComponentStore *entityComponentStore = dataAccess->EntityComponentStore;
            byte *ptr = entityComponentStore->GetComponentDataWithTypeRO(entity, componentType.TypeIndex);

            return(Marshal.PtrToStructure((IntPtr)ptr, componentType.GetManagedType()));
        }
            public void Dispose()
            {
                EntityDataAccess *g = m_Manager.GetCheckedEntityDataAccess();
                int newValue        = --g->m_InsideForEach;

                if (m_InsideForEachSafety != newValue)
                {
                    throw new InvalidOperationException("for each unbalanced");
                }
            }
Пример #4
0
        private static void PlaybackChainChunk(EntityDataAccess *mgr, Unity.Collections.LowLevel.Unsafe.UnsafeList *managedReferenceIndexRemovalCount, ref EntityComponentStore.ArchetypeChanges archetypeChanges, ref ECBSharedPlaybackState playbackState, ECBChainPlaybackState *chainStates, int currentChain, int nextChain, bool isFirstPlayback, PlaybackPolicy playbackPolicy)
        {
#if !UNITY_IOS
            if (UseDelegate())
            {
                _forward_mono_PlaybackChainChunk(mgr, managedReferenceIndexRemovalCount, ref archetypeChanges, ref playbackState, chainStates, currentChain, nextChain, isFirstPlayback, playbackPolicy);
                return;
            }
#endif

            _PlaybackChainChunk(mgr, managedReferenceIndexRemovalCount, ref archetypeChanges, ref playbackState, chainStates, currentChain, nextChain, isFirstPlayback, playbackPolicy);
        }
 internal unsafe static void _RemoveManagedReferences(EntityDataAccess *mgr, int *sharedIndex, int count)
 {
     try
     {
         for (var i = 0; i < count; i++)
         {
             mgr->ManagedComponentStore.RemoveSharedComponentReference_Managed(sharedIndex[i]);
         }
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
 }
Пример #6
0
        public static void SetComponentData(EntityManager entityManager, Entity entity, int typeIndex, object componentData)
        {
            EntityDataAccess *dataAccess = entityManager.GetCheckedEntityDataAccess();

            if (!dataAccess->IsInExclusiveTransaction)
            {
                dataAccess->DependencyManager->CompleteReadAndWriteDependency(typeIndex);
            }

            EntityComponentStore *entityComponentStore = dataAccess->EntityComponentStore;

            byte *ptr = entityComponentStore->GetComponentDataWithTypeRW(entity, typeIndex, entityComponentStore->GlobalSystemVersion);

            Marshal.StructureToPtr(componentData, (IntPtr)ptr, false);
        }
Пример #7
0
        internal void DestroyInstance()
        {
#if ENABLE_UNITY_COLLECTIONS_CHECKS
            AtomicSafetyHandle.CheckWriteAndThrow(m_Safety);
#endif

            PreDisposeCheck();

            GetCheckedEntityDataAccess()->Dispose();
            UnsafeUtility.Free(m_EntityDataAccess, Allocator.Persistent);
            m_EntityDataAccess = null;

#if ENABLE_UNITY_COLLECTIONS_CHECKS
            AtomicSafetyHandle.Release(m_Safety);
            m_Safety = default;
#endif
        }
        internal static void RemoveManagedReferences(EntityDataAccess *mgr, int *sharedIndex, int count)
        {
#if !UNITY_IOS
            if (!UseDelegate())
            {
#if ENABLE_UNITY_COLLECTIONS_CHECKS
                if (_bfp_RemoveManagedReferences.Data == IntPtr.Zero)
                {
                    throw new InvalidOperationException("Burst Interop Classes must be initialized manually");
                }
#endif

                var fp = new FunctionPointer <Managed._dlg_RemoveManagedReferences>(_bfp_RemoveManagedReferences.Data);
                fp.Invoke((IntPtr)mgr, (IntPtr)sharedIndex, count);
                return;
            }
#endif
            _RemoveManagedReferences(mgr, sharedIndex, count);
        }
Пример #9
0
        internal void Initialize(World world)
        {
            TypeManager.Initialize();
            StructuralChange.Initialize();
            EntityCommandBuffer.Initialize();

#if ENABLE_UNITY_COLLECTIONS_CHECKS
            m_Safety = AtomicSafetyHandle.Create();

#if UNITY_2020_1_OR_NEWER
            if (s_staticSafetyId.Data == 0)
            {
                CreateStaticSafetyId();
            }
            AtomicSafetyHandle.SetStaticSafetyId(ref m_Safety, s_staticSafetyId.Data);
#endif

            m_JobMode = false;
#endif
            m_EntityDataAccess = (EntityDataAccess *)UnsafeUtility.Malloc(sizeof(EntityDataAccess), 16, Allocator.Persistent);
            UnsafeUtility.MemClear(m_EntityDataAccess, sizeof(EntityDataAccess));
            EntityDataAccess.Initialize(m_EntityDataAccess, world);
        }
 private static void _wrapper_RemoveManagedReferences(EntityDataAccess *mgr, int *sharedIndex, int count)
 {
     _RemoveManagedReferences(mgr, sharedIndex, count);
 }
Пример #11
0
 private static void _forward_mono_PlaybackChainChunk(EntityDataAccess *mgr, Unity.Collections.LowLevel.Unsafe.UnsafeList *managedReferenceIndexRemovalCount, ref EntityComponentStore.ArchetypeChanges archetypeChanges, ref ECBSharedPlaybackState playbackState, ECBChainPlaybackState *chainStates, int currentChain, int nextChain, bool isFirstPlayback, PlaybackPolicy playbackPolicy)
 {
     Managed._bfp_PlaybackChainChunk((IntPtr)mgr, (IntPtr)managedReferenceIndexRemovalCount, ref archetypeChanges, ref playbackState, (IntPtr)chainStates, currentChain, nextChain, isFirstPlayback, playbackPolicy);
 }