internal IStructDataElement CreateStructDataElement <TComponentData, TValue>( IComponentDataElement root, string name, int index, int offset) { Assert.IsTrue( typeof(IComponentData).IsAssignableFrom(typeof(TComponentData)) || typeof(ISharedComponentData).IsAssignableFrom(typeof(TComponentData)) || typeof(IBufferElementData).IsAssignableFrom(typeof(TComponentData))); var elementSize = Unsafe.SizeOf <TComponentData>(); if (typeof(IComponentData).IsAssignableFrom(typeof(TComponentData)) || typeof(ISharedComponentData).IsAssignableFrom(typeof(TComponentData))) { var inspector = GetStructInspectorForType <TValue>(); var type = typeof(StructDataElement <,>).MakeGenericType(typeof(TComponentData), typeof(TValue)); return((IStructDataElement)Activator.CreateInstance(type, inspector, root, index, offset, elementSize, name)); } if (typeof(IBufferElementData).IsAssignableFrom(typeof(TComponentData))) { var inspector = GetStructInspectorForType <TValue>(); var type = typeof(StructDataElement <,>).MakeGenericType(typeof(DynamicBuffer <>).MakeGenericType(typeof(TComponentData)), typeof(TValue)); return((IStructDataElement)Activator.CreateInstance(type, inspector, root, index, offset, elementSize, name)); } throw new NotImplementedException(); }
internal IStructDataElement CreateStructDataElement <TValue>( IComponentDataElement root, string name, int index, int offset) { var inspector = GetStructInspectorForType <TValue>(); var type = typeof(StructItemDataElement <>).MakeGenericType(typeof(TValue)); return((IStructDataElement)Activator.CreateInstance(type, inspector, root, index, offset, name)); }
internal void MoveUp(IComponentDataElement element) { var index = m_Components.IndexOf(element); if (index < 0 || index == 0) { return; } var firstHash = TypeManager.GetTypeInfo(TypeManager.GetTypeIndex(element.ComponentType)).StableTypeHash; var secondHash = TypeManager.GetTypeInfo(TypeManager.GetTypeIndex(m_Components[index - 1].ComponentType)).StableTypeHash; PropagateToComponentOrder(firstHash, secondHash); }
private int OrderFrom(IComponentDataElement element, DynamicBuffer <ComponentOrder> order) { var hash = TypeManager.GetTypeInfo(TypeManager.GetTypeIndex(element.ComponentType)).StableTypeHash; for (var i = 0; i < order.Length; ++i) { if (order[i].StableTypeHash == hash) { return(i); } } return(int.MaxValue); }
public ComponentOffsetDataProvider(IComponentDataElement component) { Component = component; }
internal IDisposable NewStructItemInspectorFactoryScope(IComponentDataElement root, CustomInspectorManager customInspectors, Type elementType) { return((IDisposable)Activator.CreateInstance( typeof(StructInspectorFactoryScope <>).MakeGenericType(elementType), this, root, customInspectors)); }
internal StructInspectorFactoryScope <T> NewStructInspectorFactoryScope <T>(IComponentDataElement root, CustomInspectorManager customInspectors) { return(new StructInspectorFactoryScope <T>(this, root, customInspectors)); }
internal DataProviderScope NewDataProviderScope(IComponentDataElement componentElement) { return(new DataProviderScope(this, componentElement)); }
public DataProviderScope(InspectorContext context, IComponentDataElement componentElement) { Context = context; Context.DataProvider = new ComponentOffsetDataProvider(componentElement); }
public StructDataElementFactory(IComponentDataElement root, CustomInspectorManager customInspectors) { Root = root; CustomInspectors = customInspectors; }
public StructInspectorFactoryScope(InspectorContext context, IComponentDataElement root, CustomInspectorManager customInspectors) { Context = context; Context.StructElementFactory = new StructDataElementFactory <T>(root, customInspectors); }
public StructItemDataElement(IInspector <T> inspector, IComponentDataElement <DynamicBuffer <T> > root, int index, int offset, string name) : base(inspector, root, index, offset, Unsafe.SizeOf <T>(), name) { }