Example #1
0
            bool ClearEntityReferences(TypeManager.TypeInfo typeInfo, byte *address, int elementCount)
            {
                var changed = false;

                var offsets = EntityOffsetInfo + typeInfo.EntityOffsetStartIndex;

                for (var elementIndex = 0; elementIndex < elementCount; elementIndex++)
                {
                    var elementPtr = address + typeInfo.ElementSize * elementIndex;

                    for (var offsetIndex = 0; offsetIndex < typeInfo.EntityOffsetCount; offsetIndex++)
                    {
                        var offset = offsets[offsetIndex].Offset;

                        if (EntityComponentStore->Exists(*(Entity *)(elementPtr + offset)))
                        {
                            continue;
                        }

                        *(Entity *)(elementPtr + offset) = Entity.Null;
                        changed = true;
                    }
                }

                return(changed);
            }
Example #2
0
 private unsafe void ComputeMasks()
 {
     for (int i = 0; i < this.m_sorted.Length; i++)
     {
         int typeIndex = this.m_sorted[i];
         TypeManager.TypeInfo typeInfo = TypeManager.GetTypeInfo(typeIndex);
         ushort num3 = (ushort)(1 << (i & 0x1f));
         if (typeInfo.BufferCapacity >= 0)
         {
             ushort *numPtr1 = (ushort *)ref this.m_masks.m_BufferMask;
             numPtr1[0] = (ushort)(numPtr1[0] | num3);
         }
         if (typeInfo.IsSystemStateComponent)
         {
             ushort *numPtr2 = (ushort *)ref this.m_masks.m_SystemStateComponentMask;
             numPtr2[0] = (ushort)(numPtr2[0] | num3);
         }
         if (typeInfo.IsSystemStateSharedComponent)
         {
             ushort *numPtr3 = (ushort *)ref this.m_masks.m_SystemStateSharedComponentMask;
             numPtr3[0] = (ushort)(numPtr3[0] | num3);
         }
         if (TypeManager.TypeCategory.ISharedComponentData == typeInfo.Category)
         {
             ushort *numPtr4 = (ushort *)ref this.m_masks.m_SharedComponentMask;
             numPtr4[0] = (ushort)(numPtr4[0] | num3);
         }
         if (typeInfo.IsZeroSized)
         {
             ushort *numPtr5 = (ushort *)ref this.m_masks.m_ZeroSizedMask;
             numPtr5[0] = (ushort)(numPtr5[0] | num3);
         }
     }
 }
 public ComponentType(Type type, AccessMode accessModeType = 0)
 {
     this.TypeIndex = TypeManager.GetTypeIndex(type);
     TypeManager.TypeInfo typeInfo = TypeManager.GetTypeInfo(this.TypeIndex);
     this.BufferCapacity = typeInfo.BufferCapacity;
     this.AccessModeType = accessModeType;
 }
Example #4
0
        public static ComponentType FromTypeIndex(int typeIndex)
        {
            TypeManager.TypeInfo ct = TypeManager.GetTypeInfo(typeIndex);

            ComponentType type;

            type.TypeIndex      = typeIndex;
            type.AccessModeType = AccessMode.ReadWrite;
            type.BufferCapacity = ct.BufferCapacity;
            return(type);
        }
Example #5
0
        internal unsafe BufferHeader *AddEntityBufferCommand <T>(EntityCommandBufferChain *chain, int jobIndex, ECBCommand op, Entity e) where T : struct, IBufferElementData
        {
            TypeManager.TypeInfo typeInfo = TypeManager.GetTypeInfo <T>();
            int size = Align(sizeof(EntityBufferCommand) + typeInfo.SizeInChunk, 8);
            EntityBufferCommand *commandPtr = (EntityBufferCommand *)ref this.Reserve(chain, jobIndex, size);

            commandPtr->Header.Header.CommandType = (int)op;
            commandPtr->Header.Header.TotalSize   = size;
            commandPtr->Header.Header.SortIndex   = chain.m_LastSortIndex;
            commandPtr->Header.Entity             = e;
            commandPtr->ComponentTypeIndex        = TypeManager.GetTypeIndex <T>();
            commandPtr->ComponentSize             = typeInfo.SizeInChunk;
            BufferHeader.Initialize(&commandPtr->TempBuffer, typeInfo.BufferCapacity);
            return(&commandPtr->TempBuffer);
        }
        public unsafe void Add(TypeManager.TypeInfo typeInfo)
        {
            if (m_TypeInfo[typeInfo.TypeIndex & TypeManager.ClearFlagsMask].StableTypeHash != 0)
            {
                return;
            }

            m_TypeInfo[typeInfo.TypeIndex & TypeManager.ClearFlagsMask] = new Layout
            {
                ElementSize          = typeInfo.ElementSize,
                EntityOffsetCount    = typeInfo.EntityOffsetCount,
                StableTypeHash       = typeInfo.StableTypeHash,
                EntityOffsetPosition = m_EntityOffsets.Length
            };

            if (typeInfo.HasEntities)
            {
                m_EntityOffsets.AddRange(TypeManager.GetEntityOffsets(typeInfo.TypeIndex), typeInfo.EntityOffsetCount * sizeof(TypeManager.EntityOffsetInfo));
            }
        }