internal InstantiateCommandBufferUntyped(Allocator allocator, FixedList64 <ComponentType> componentTypesWithData, int disposeSentinalStackDepth) { int dataPayloadSize = 0; FixedListInt64 typesSizes = new FixedListInt64(); FixedListInt64 typesWithData = new FixedListInt64(); for (int i = 0; i < componentTypesWithData.Length; i++) { var size = TypeManager.GetTypeInfo(componentTypesWithData[i].TypeIndex).ElementSize; dataPayloadSize += size; typesSizes.Add(size); typesWithData.Add(componentTypesWithData[i].TypeIndex); } CheckComponentTypesValid(BuildComponentTypesFromFixedList(typesWithData)); m_prefabSortkeyBlockList = (UnsafeParallelBlockList *)UnsafeUtility.Malloc(UnsafeUtility.SizeOf <UnsafeParallelBlockList>(), UnsafeUtility.AlignOf <UnsafeParallelBlockList>(), allocator); m_componentDataBlockList = (UnsafeParallelBlockList *)UnsafeUtility.Malloc(UnsafeUtility.SizeOf <UnsafeParallelBlockList>(), UnsafeUtility.AlignOf <UnsafeParallelBlockList>(), allocator); m_state = (State *)UnsafeUtility.Malloc(UnsafeUtility.SizeOf <State>(), UnsafeUtility.AlignOf <State>(), allocator); *m_prefabSortkeyBlockList = new UnsafeParallelBlockList(UnsafeUtility.SizeOf <PrefabSortkey>(), 256, allocator); *m_componentDataBlockList = new UnsafeParallelBlockList(dataPayloadSize, 256, allocator); *m_state = new State { typesWithData = typesWithData, tagsToAdd = default,
public void FixedListInt128ToFixedListInt64() { var a = new FixedListInt128(); for (var i = 0; i < 31; ++i) { a.Add((int)i); } Assert.Throws <IndexOutOfRangeException> (() => { var b = new FixedListInt64(a); }); }
internal EntityQueryBuilder(ComponentSystem system) { m_System = system; m_Any = new FixedListInt64(); m_None = new FixedListInt64(); m_All = new FixedListInt64(); m_AnyWritableBitField = m_AllWritableBitField = 0; m_Options = EntityQueryOptions.Default; m_Query = null; }
public void FixedListInt64HasExpectedCapacity() { var list = new FixedListInt64(); var expectedCapacity = 15; for (int i = 0; i < expectedCapacity; ++i) { list.Add((int)i); } Assert.Throws <IndexOutOfRangeException> (() => { list.Add((int)expectedCapacity); }); }
public void FixedListInt64Sort() { var list = new FixedListInt64(); for (var i = 0; i < 5; ++i) { list.Add((int)(4 - i)); } list.Sort(); for (var i = 0; i < 5; ++i) { Assert.AreEqual(i, list[i]); } }
public void FixedListInt64ToFixedListInt128() { var a = new FixedListInt64(); for (var i = 0; i < 15; ++i) { a.Add((int)i); } var b = new FixedListInt128(a); for (var i = 0; i < 15; ++i) { Assert.AreEqual((int)i, b[i]); } }
public void FixedListInt64RemoveRange() { var list = new FixedListInt64(); list.Add(0); list.Add(3); list.Add(3); list.Add(1); list.Add(2); list.RemoveRange(1, 2); for (var i = 0; i < 3; ++i) { Assert.AreEqual(i, list[i]); } }
public void FixedListInt64InsertRange() { var list = new FixedListInt64(); list.Add(0); list.Add(3); list.Add(4); list.InsertRange(1, 2); list[1] = 1; list[2] = 2; for (var i = 0; i < 5; ++i) { Assert.AreEqual(i, list[i]); } }
void ParseAnsi(ref FixedListByte32 escape, ref ColorIndex fg, ref ColorIndex bg) { if (escape.Length < 4) { return; } if (escape[0] != 0x1b || escape[1] != '[') { return; } int offset = 2; FixedListInt64 numbers = default; int number = 0; while (offset < escape.Length) { switch ((char)escape[offset]) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': number *= 10; number += escape[offset] - '0'; break; case ';': numbers.Add(number); number = 0; break; case 'm': numbers.Add(number); ParseAnsiColor(ref numbers, ref fg, ref bg); return; } ++offset; } }
public void FixedListInt64HasExpectedLayout() { var actual = new FixedListInt64(); for (var i = 0; i < 15; ++i) { actual.Add((int)i); } unsafe { var e = stackalloc byte[64]; e[0] = (byte)((15 >> 0) & 0xFF); e[1] = (byte)((15 >> 8) & 0xFF); for (var i = 0; i < 15; ++i) { var s = (int)i; UnsafeUtility.MemCpy(e + 2 + sizeof(int) * i, &s, sizeof(int)); } Assert.AreEqual(0, UnsafeUtility.MemCmp(e, &actual.length, 64)); } }
void ParseAnsiColor(ref FixedListInt64 numbers, ref ColorIndex fg, ref ColorIndex bg) { for (var i = 0; i < numbers.Length; ++i) { var code = numbers[i]; switch (code) { case 0: fg.value = 15; bg.value = 0; break; case 1: fg.value |= 8; break; case 30: case 31: case 32: case 33: case 34: case 35: case 36: case 37: fg.value &= 8; fg.value |= code - 30; break; case 40: case 41: case 42: case 43: case 44: case 45: case 46: case 47: bg.value = code - 40; break; case 90: case 91: case 92: case 93: case 94: case 95: case 96: case 97: fg.value = 8 | (code - 90); break; case 100: case 101: case 102: case 103: case 104: case 105: case 106: case 107: bg.value = code - 100; break; } } }