示例#1
0
        // Public methods
        ///////////////////////////

        public EntityId RegisterDataType <T>()
        {
            var type      = typeof(T);
            var component = tracker.Create();

            index.Register(component, type);
            var typeIndex = TypeId.Get <T>();

            if (dataTypes.Length <= typeIndex)
            {
                var newSize = dataTypes.Length * 2;
                while (newSize <= typeIndex)
                {
                    newSize *= 2;
                }
                Array.Resize(ref dataTypes, newSize);
            }
            dataTypes[typeIndex] = component;
            return(component);
        }