Esempio n. 1
0
        public BufferFromEntity <T> GetBufferFromEntity <T>(int typeIndex, bool isReadOnly = false)
            where T : struct, IBufferElementData
        {
#if ENABLE_UNITY_COLLECTIONS_CHECKS
            return(new BufferFromEntity <T>(typeIndex, Entities, isReadOnly,
                                            ComponentJobSafetyManager.GetSafetyHandle(typeIndex, isReadOnly),
                                            ComponentJobSafetyManager.GetBufferSafetyHandle(typeIndex)));
#else
            return(new BufferFromEntity <T>(typeIndex, m_Entities, isReadOnly));
#endif
        }
Esempio n. 2
0
        public ArchetypeChunkBufferType <T> GetArchetypeChunkBufferType <T>(bool isReadOnly)
            where T : struct, IBufferElementData
        {
#if ENABLE_UNITY_COLLECTIONS_CHECKS
            var typeIndex = TypeManager.GetTypeIndex <T>();
            return(new ArchetypeChunkBufferType <T>(
                       ComponentJobSafetyManager.GetSafetyHandle(typeIndex, isReadOnly),
                       ComponentJobSafetyManager.GetBufferSafetyHandle(typeIndex),
                       isReadOnly, GlobalSystemVersion));
#else
            return(new ArchetypeChunkBufferType <T>(isReadOnly, GlobalSystemVersion));
#endif
        }
Esempio n. 3
0
        internal AtomicSafetyHandle GetBufferSafetyHandle(int indexInComponentGroup)
        {
            var type = m_GroupData->RequiredComponents + indexInComponentGroup;

            return(m_SafetyManager.GetBufferSafetyHandle(type->TypeIndex));
        }
Esempio n. 4
0
        public DynamicBuffer <T> GetBuffer <T>(Entity entity) where T : struct, IBufferElementData
        {
            var typeIndex = TypeManager.GetTypeIndex <T>();

#if ENABLE_UNITY_COLLECTIONS_CHECKS
            Entities->AssertEntityHasComponent(entity, typeIndex);
            if (TypeManager.GetTypeInfo <T>().Category != TypeManager.TypeCategory.BufferData)
            {
                throw new ArgumentException(
                          $"GetBuffer<{typeof(T)}> may not be IComponentData or ISharedComponentData; currently {TypeManager.GetTypeInfo<T>().Category}");
            }
#endif

            ComponentJobSafetyManager.CompleteReadAndWriteDependency(typeIndex);

            BufferHeader *header = (BufferHeader *)Entities->GetComponentDataWithTypeRW(entity, typeIndex, Entities->GlobalSystemVersion);

#if ENABLE_UNITY_COLLECTIONS_CHECKS
            return(new DynamicBuffer <T>(header, ComponentJobSafetyManager.GetSafetyHandle(typeIndex, false), ComponentJobSafetyManager.GetBufferSafetyHandle(typeIndex), false));
#else
            return(new DynamicBuffer <T>(header));
#endif
        }