public unsafe void *GetPtr(object key) { switch (key) { case Type type when type.IsComponentDataType(): { var typeIndex = TypeManager.GetTypeIndex(type); if (TypeManager.IsZeroSized(typeIndex)) { throw new ArgumentException($"GetComponentData<{type}> can not be called with a zero sized component."); } return(Chunk.GetComponentDataWithTypeRW(Index, typeIndex, GlobalSystemVersion)); } case ulong componentStableHash: { var typeIndex = TypeManager.GetTypeIndexFromStableTypeHash(componentStableHash); if (TypeManager.IsZeroSized(typeIndex)) { throw new ArgumentException("GetComponentData can not be called with a zero sized component."); } return(Chunk.GetComponentDataWithTypeRW(Index, typeIndex, GlobalSystemVersion)); } default: throw new NotImplementedException(); } }
public unsafe void SetComponentData <T>(T value) where T : struct, IComponentData { var typeIndex = TypeManager.GetTypeIndex <T>(); if (TypeManager.IsZeroSized(typeIndex)) { throw new ArgumentException($"SetComponentData<{typeof(T)}> can not be called with a zero sized component."); } UnsafeUtilityEx.AsRef <T>(Chunk.GetComponentDataWithTypeRW(Index, typeIndex, GlobalSystemVersion)) = value; }
private unsafe void *GetPtrByTypeIndexRW(int typeIndex) { return(Chunk.GetComponentDataWithTypeRW(Index, typeIndex, GlobalSystemVersion)); }