private BufferTarget getBufferTarget(BufferType bufferType) { switch (bufferType) { case BufferType.ArrayBuffer: return(BufferTarget.ArrayBuffer); case BufferType.ElementArrayBuffer: return(BufferTarget.ElementArrayBuffer); default: throw new NotSupportedException(bufferType.ToString()); } }
public override string ToString() { if (!BufferType.HasValue || BufferType == 0 || BufferType == 2 || BufferType == 4) { if (Timestamp.HasValue) { return($"Sample: {Timestamp.Value.ToTmString()} {Position}"); } return($"Sample: {Position}"); } return($"Sample: {BufferType.ToString() ?? "unknown"}"); }
} // InitializeSerialPort private void SaveCurrentProperties() { var sbdProperties = new StringBuilder(); sbdProperties.Append("Port " + strPort + Globals.CRLF); sbdProperties.Append("BaudRate " + intBaudRate.ToString() + Globals.CRLF); sbdProperties.Append("DataBits " + intDataBits.ToString() + Globals.CRLF); sbdProperties.Append("StopBits " + intStopBits.ToString() + Globals.CRLF); sbdProperties.Append("Parity " + intParity.ToString() + Globals.CRLF); sbdProperties.Append("Handshake " + intHandshake.ToString() + Globals.CRLF); sbdProperties.Append("WriteTimeout " + intWriteTimeout.ToString() + Globals.CRLF); sbdProperties.Append("RTSEnable " + blnRTSEnable.ToString() + Globals.CRLF); sbdProperties.Append("DTREnable " + blnDTREnable.ToString() + Globals.CRLF); sbdProperties.Append("LocalEcho " + blnLocalEcho.ToString() + Globals.CRLF); sbdProperties.Append("WordWrap " + blnWordWrap.ToString() + Globals.CRLF); sbdProperties.Append("BufferType " + enmBufferType.ToString() + Globals.CRLF); sbdProperties.Append("Top " + Top.ToString() + Globals.CRLF); sbdProperties.Append("Left " + Left.ToString() + Globals.CRLF); sbdProperties.Append("Width " + Width.ToString() + Globals.CRLF); sbdProperties.Append("Height " + Height.ToString() + Globals.CRLF); File.WriteAllText(Globals.SiteRootDirectory + @"Data\Simple Terminal.stx", sbdProperties.ToString()); } // SaveCurrentProperties
public static LMTM3AEntry ReplaceLMTM3AEntry(TreeView tree, ArcEntryWrapper node, string filename, Type filetype = null) { LMTM3AEntry m3aentry = new LMTM3AEntry(); LMTM3AEntry oldentry = new LMTM3AEntry(); tree.BeginUpdate(); var tag = node.Tag; if (tag is LMTM3AEntry) { oldentry = tag as LMTM3AEntry; } //Builds the ma3entry. m3aentry._FileType = ".m3a"; m3aentry.FileExt = m3aentry._FileType; m3aentry.FullData = System.IO.File.ReadAllBytes(filename); m3aentry.AnimationID = oldentry.AnimationID; m3aentry.FileName = oldentry.FileName; m3aentry.ShortName = oldentry.ShortName; m3aentry._IsBlank = false; using (MemoryStream MAThreeStream = new MemoryStream(m3aentry.FullData)) { using (BinaryReader bnr = new BinaryReader(MAThreeStream)) { if (bnr.BaseStream.Length < 5) { MessageBox.Show("The entry you are trying to import is a blank one,\nso the replace command has been aborted.", "We have a problem here."); return(null); } int projdatlength = m3aentry.FullData.Length - 96; m3aentry.RawData = new byte[(projdatlength)]; Array.Copy(m3aentry.FullData, 0, m3aentry.RawData, 0, projdatlength); m3aentry.MotionData = new byte[96]; projdatlength = m3aentry.FullData.Length - 96; Array.Copy(m3aentry.FullData, projdatlength, m3aentry.MotionData, 0, 96); bnr.BaseStream.Position = (bnr.BaseStream.Length - 96); m3aentry.TrackPointer = bnr.ReadInt32(); bnr.BaseStream.Position = bnr.BaseStream.Position + 4; m3aentry.TrackCount = bnr.ReadInt32(); m3aentry.FrameCount = bnr.ReadInt32(); m3aentry._FrameTotal = m3aentry.FrameCount; m3aentry.IsBlank = false; m3aentry.LoopFrame = bnr.ReadInt32(); m3aentry.UnknownValue14 = ByteUtilitarian.BytesToString(bnr.ReadBytes(4), m3aentry.UnknownValue14); m3aentry.UnknownValue18 = ByteUtilitarian.BytesToString(bnr.ReadBytes(4), m3aentry.UnknownValue18); m3aentry.UnknownValue1C = ByteUtilitarian.BytesToString(bnr.ReadBytes(4), m3aentry.UnknownValue1C); m3aentry.EndFramesAdditiveScenePosition.W = bnr.ReadSingle(); m3aentry.EndFramesAdditiveScenePosition.X = bnr.ReadSingle(); m3aentry.EndFramesAdditiveScenePosition.Y = bnr.ReadSingle(); m3aentry.EndFramesAdditiveScenePosition.Z = bnr.ReadSingle(); m3aentry.EndFramesAdditiveSceneRotation.W = bnr.ReadSingle(); m3aentry.EndFramesAdditiveSceneRotation.X = bnr.ReadSingle(); m3aentry.EndFramesAdditiveSceneRotation.Y = bnr.ReadSingle(); m3aentry.EndFramesAdditiveSceneRotation.Z = bnr.ReadSingle(); m3aentry.AnimationFlags = bnr.ReadInt64(); m3aentry.EventClassesPointer = bnr.ReadInt32(); //m3aentry.EventClassesPointer = bnr.ReadInt32(); //bnr.BaseStream.Position = bnr.BaseStream.Position + 4; m3aentry.AnimDataSize = (m3aentry.EventClassesPointer - m3aentry.TrackPointer) + 352; m3aentry.AnimDataSize = m3aentry.FullData.Length - 448; m3aentry.FloatTracksPointer = bnr.ReadInt32(); bnr.BaseStream.Position = bnr.BaseStream.Position + 4; m3aentry.Unknown58 = bnr.ReadInt32(); m3aentry.Unknown5C = bnr.ReadSingle(); m3aentry.PrevOffsetThree = Convert.ToInt32(bnr.BaseStream.Position); bnr.BaseStream.Position = m3aentry.TrackPointer; m3aentry.RawData = new byte[m3aentry.AnimDataSize]; Array.Copy(m3aentry.FullData, m3aentry.RawData, m3aentry.AnimDataSize); m3aentry.MotionData = new byte[96]; bnr.BaseStream.Position = (m3aentry.FullData.Length - 96); m3aentry.MotionData = bnr.ReadBytes(96); bnr.BaseStream.Position = m3aentry.PrevOffsetThree; //Gets the Tracks. m3aentry.Tracks = new List <Track>(); bnr.BaseStream.Position = 0; for (int j = 0; j < m3aentry.TrackCount; j++) { Track track = new Track(); track.TrackNumber = j; track.BufferType = bnr.ReadByte(); BufferType type = (BufferType)track.BufferType; track.BufferKind = type.ToString(); track.TrackType = bnr.ReadByte(); track.BoneType = bnr.ReadByte(); track.BoneID = bnr.ReadByte(); track.Weight = bnr.ReadSingle(); track.BufferSize = bnr.ReadInt32(); bnr.BaseStream.Position = bnr.BaseStream.Position + 4; track.BufferPointer = bnr.ReadInt32(); bnr.BaseStream.Position = bnr.BaseStream.Position + 4; track.ReferenceData.W = bnr.ReadSingle(); track.ReferenceData.X = bnr.ReadSingle(); track.ReferenceData.Y = bnr.ReadSingle(); track.ReferenceData.Z = bnr.ReadSingle(); track.ExtremesPointer = bnr.ReadInt32(); bnr.BaseStream.Position = bnr.BaseStream.Position + 4; m3aentry.PrevOffset = Convert.ToInt32(bnr.BaseStream.Position); if (track.BufferSize != 0) { //MessageBox.Show("Track #" + j + " inside " + lmtentry.EntryName + "\nhas a buffer size that is NOT ZERO.", "Debug Note"); bnr.BaseStream.Position = track.BufferPointer; track.Buffer = bnr.ReadBytes(track.BufferSize); } if (track.ExtremesPointer != 0) { //MessageBox.Show("Track # " + j + " inside " + lmtentry.EntryName + "\nhas an actual extremes pointer.", "Debug Note"); bnr.BaseStream.Position = Convert.ToInt32(track.ExtremesPointer); track.Extremes = new Extremes(); track.Extremes.min.W = bnr.ReadSingle(); track.Extremes.min.X = bnr.ReadSingle(); track.Extremes.min.Y = bnr.ReadSingle(); track.Extremes.min.Z = bnr.ReadSingle(); track.Extremes.max.W = bnr.ReadSingle(); track.Extremes.max.X = bnr.ReadSingle(); track.Extremes.max.Y = bnr.ReadSingle(); track.Extremes.max.Z = bnr.ReadSingle(); } bnr.BaseStream.Position = m3aentry.PrevOffset; m3aentry.Tracks.Add(track); } bnr.BaseStream.Position = m3aentry.FullData.Length - 448; //Animation Events. m3aentry.Events = new List <AnimEvent>(); for (int k = 0; k < 4; k++) { AnimEvent animEvent = new AnimEvent(); for (int l = 0; l < 32; l++) { animEvent.EventRemap = new List <int>(); animEvent.EventRemap.Add(bnr.ReadInt16()); } animEvent.EventCount = bnr.ReadInt32(); bnr.BaseStream.Position = bnr.BaseStream.Position + 4; animEvent.EventsPointer = bnr.ReadInt32(); bnr.BaseStream.Position = bnr.BaseStream.Position + 4; m3aentry.PrevOffsetTwo = Convert.ToInt32(bnr.BaseStream.Position); bnr.BaseStream.Position = animEvent.EventsPointer; animEvent.EventBit = bnr.ReadInt32(); animEvent.FrameNumber = bnr.ReadInt32(); m3aentry.Events.Add(animEvent); bnr.BaseStream.Position = m3aentry.PrevOffsetTwo; } //Subtracts pointers in there by the data offset to get their base value. int OffTemp = 0; using (MemoryStream msm3a = new MemoryStream(m3aentry.RawData)) { using (BinaryReader brm3a = new BinaryReader(msm3a)) { using (BinaryWriter bwm3a = new BinaryWriter(msm3a)) { //Adjusts the offsets in the Rawdata of the m3a. bwm3a.BaseStream.Position = 0; for (int y = 0; y < m3aentry.TrackCount; y++) { bwm3a.BaseStream.Position = 0; bwm3a.BaseStream.Position = 16 + (48 * y); OffTemp = brm3a.ReadInt32(); bwm3a.BaseStream.Position = (bwm3a.BaseStream.Position - 4); if (OffTemp > 0) { OffTemp = OffTemp - m3aentry.TrackPointer; bwm3a.Write(OffTemp); } bwm3a.BaseStream.Position = 40 + (48 * y); OffTemp = brm3a.ReadInt32(); bwm3a.BaseStream.Position = (bwm3a.BaseStream.Position - 4); if (OffTemp > 0) { OffTemp = OffTemp - m3aentry.TrackPointer; bwm3a.Write(OffTemp); } } //Adjusts the offsets in the Events. bwm3a.BaseStream.Position = (bwm3a.BaseStream.Length - 280); OffTemp = m3aentry.RawData.Length - 32; bwm3a.Write(OffTemp); bwm3a.BaseStream.Position = bwm3a.BaseStream.Position + 76; OffTemp = m3aentry.RawData.Length - 24; bwm3a.Write(OffTemp); bwm3a.BaseStream.Position = bwm3a.BaseStream.Position + 76; OffTemp = m3aentry.RawData.Length - 16; bwm3a.Write(OffTemp); bwm3a.BaseStream.Position = bwm3a.BaseStream.Position + 76; OffTemp = m3aentry.RawData.Length - 8; bwm3a.Write(OffTemp); } } } //Appends the Animation Block Data to the FullData. m3aentry.FullData = new byte[(m3aentry.AnimDataSize + 96)]; m3aentry._FileLength = m3aentry.FullData.LongLength; Array.Copy(m3aentry.RawData, 0, m3aentry.FullData, 0, m3aentry.RawData.Length); Array.Copy(m3aentry.MotionData, 0, m3aentry.FullData, m3aentry.RawData.Length, m3aentry.MotionData.Length); } } try { using (BinaryReader bnr = new BinaryReader(File.OpenRead(filename))) { m3aentry.RawData = System.IO.File.ReadAllBytes(filename); /* * var tag = node.Tag; * if (tag is LMTM3AEntry) * { * oldentry = tag as LMTM3AEntry; * } */ tag = m3aentry; if (node.Tag is LMTM3AEntry) { node.Tag = m3aentry; } var aew = node as ArcEntryWrapper; string type = node.GetType().ToString(); if (type == "ThreeWorkTool.Resources.Wrappers.ArcEntryWrapper") { aew.entryfile = m3aentry; } node = aew; node.entryfile = m3aentry; /* * //ArcEntryWrapper aew = new ArcEntryWrapper(); * if (node is ArcEntryWrapper) * { * node.entryfile as ArcEntryWrapper = node.Tag; * } */ tree.EndUpdate(); node.ImageIndex = 18; node.SelectedImageIndex = 18; } } catch (Exception ex) { MessageBox.Show("Read error. Is the file readable?"); using (StreamWriter sw = File.AppendText("Log.txt")) { sw.WriteLine("Read Error! Here's the exception info:\n" + ex); } } return(node.entryfile as LMTM3AEntry); }
public LMTM3AEntry FillM3AProprties(LMTM3AEntry Anim, int datalength, int ID, int RowTotal, int SecondOffset, BinaryReader bnr, int SecondaryCount, LMTEntry lmtentry) { //Reads the AnnimBlock Header. LMTM3AEntry M3a = new LMTM3AEntry(); M3a.KeyFrames = new List <KeyFrame>(); M3a._FileType = ".m3a"; M3a.FileExt = M3a._FileType; bnr.BaseStream.Position = lmtentry.OffsetList[ID]; M3a.TrackPointer = bnr.ReadInt32(); bnr.BaseStream.Position = bnr.BaseStream.Position + 4; M3a.TrackCount = bnr.ReadInt32(); M3a.FrameCount = bnr.ReadInt32(); M3a._FrameTotal = M3a.FrameCount; M3a.LoopFrame = bnr.ReadInt32(); M3a.UnknownValue14 = ByteUtilitarian.BytesToString(bnr.ReadBytes(4), M3a.UnknownValue14); M3a.UnknownValue18 = ByteUtilitarian.BytesToString(bnr.ReadBytes(4), M3a.UnknownValue18); M3a.UnknownValue1C = ByteUtilitarian.BytesToString(bnr.ReadBytes(4), M3a.UnknownValue1C); M3a.EndFramesAdditiveScenePosition.W = bnr.ReadSingle(); M3a.EndFramesAdditiveScenePosition.X = bnr.ReadSingle(); M3a.EndFramesAdditiveScenePosition.Y = bnr.ReadSingle(); M3a.EndFramesAdditiveScenePosition.Z = bnr.ReadSingle(); M3a.EndFramesAdditiveSceneRotation.W = bnr.ReadSingle(); M3a.EndFramesAdditiveSceneRotation.X = bnr.ReadSingle(); M3a.EndFramesAdditiveSceneRotation.Y = bnr.ReadSingle(); M3a.EndFramesAdditiveSceneRotation.Z = bnr.ReadSingle(); M3a.AnimationFlags = bnr.ReadInt64(); M3a.EventClassesPointer = bnr.ReadInt32(); bnr.BaseStream.Position = bnr.BaseStream.Position + 4; M3a.AnimDataSize = (M3a.EventClassesPointer - M3a.TrackPointer) + 352; M3a.FloatTracksPointer = bnr.ReadInt32(); bnr.BaseStream.Position = bnr.BaseStream.Position + 4; M3a.Unknown58 = bnr.ReadInt32(); M3a.Unknown5C = bnr.ReadSingle(); PrevOffsetThree = Convert.ToInt32(bnr.BaseStream.Position); bnr.BaseStream.Position = M3a.TrackPointer; M3a.RawData = new byte[M3a.AnimDataSize]; M3a.RawData = bnr.ReadBytes(M3a.AnimDataSize); M3a.MotionData = new byte[96]; bnr.BaseStream.Position = lmtentry.OffsetList[ID]; M3a.MotionData = bnr.ReadBytes(96); bnr.BaseStream.Position = PrevOffsetThree; //Gets the Tracks. M3a.Tracks = new List <Track>(); bnr.BaseStream.Position = M3a.TrackPointer; for (int j = 0; j < M3a.TrackCount; j++) { Track track = new Track(); track.TrackNumber = j; track.ExtremesArray = new float[8]; track.BufferType = bnr.ReadByte(); BufferType type = (BufferType)track.BufferType; track.BufferKind = type.ToString(); track.TrackType = bnr.ReadByte(); track.BoneType = bnr.ReadByte(); track.BoneID = bnr.ReadByte(); track.Weight = bnr.ReadSingle(); track.BufferSize = bnr.ReadInt32(); bnr.BaseStream.Position = bnr.BaseStream.Position + 4; track.BufferPointer = bnr.ReadInt32(); bnr.BaseStream.Position = bnr.BaseStream.Position + 4; track.ReferenceData.W = bnr.ReadSingle(); track.ReferenceData.X = bnr.ReadSingle(); track.ReferenceData.Y = bnr.ReadSingle(); track.ReferenceData.Z = bnr.ReadSingle(); track.ExtremesPointer = bnr.ReadInt32(); bnr.BaseStream.Position = bnr.BaseStream.Position + 4; PrevOffset = Convert.ToInt32(bnr.BaseStream.Position); if (track.BufferSize != 0) { //MessageBox.Show("Track #" + j + " inside " + lmtentry.EntryName + "\nhas a buffer size that is NOT ZERO.", "Debug Note"); bnr.BaseStream.Position = track.BufferPointer; track.Buffer = bnr.ReadBytes(track.BufferSize); } else { track.Buffer = new byte[0]; } if (track.ExtremesPointer != 0) { //MessageBox.Show("Track # " + j + " inside " + lmtentry.EntryName + "\nhas an actual extremes pointer.", "Debug Note"); bnr.BaseStream.Position = Convert.ToInt32(track.ExtremesPointer); track.Extremes = new Extremes(); track.Extremes.min.W = bnr.ReadSingle(); track.Extremes.min.X = bnr.ReadSingle(); track.Extremes.min.Y = bnr.ReadSingle(); track.Extremes.min.Z = bnr.ReadSingle(); track.Extremes.max.W = bnr.ReadSingle(); track.Extremes.max.X = bnr.ReadSingle(); track.Extremes.max.Y = bnr.ReadSingle(); track.Extremes.max.Z = bnr.ReadSingle(); track.ExtremesArray[0] = track.Extremes.min.W; track.ExtremesArray[1] = track.Extremes.min.X; track.ExtremesArray[2] = track.Extremes.min.Y; track.ExtremesArray[3] = track.Extremes.min.Z; track.ExtremesArray[4] = track.Extremes.max.W; track.ExtremesArray[5] = track.Extremes.max.X; track.ExtremesArray[6] = track.Extremes.max.Y; track.ExtremesArray[7] = track.Extremes.max.Z; //Keyframes Take 1. IEnumerable <KeyFrame> Key = LMTM3ATrackBuffer.Convert(track.BufferType, track.Buffer, track.ExtremesArray, track.BoneID, track.BufferKind); M3a.KeyFrames.AddRange(Key.ToList()); } else { IEnumerable <KeyFrame> Key = LMTM3ATrackBuffer.Convert(track.BufferType, track.Buffer, track.ExtremesArray, track.BoneID, track.BufferKind); M3a.KeyFrames.AddRange(Key.ToList()); } bnr.BaseStream.Position = PrevOffset; M3a.Tracks.Add(track); } bnr.BaseStream.Position = M3a.EventClassesPointer; //Animation Events. M3a.Events = new List <AnimEvent>(); for (int k = 0; k < 4; k++) { AnimEvent animEvent = new AnimEvent(); for (int l = 0; l < 32; l++) { animEvent.EventRemap = new List <int>(); animEvent.EventRemap.Add(bnr.ReadInt16()); } animEvent.EventCount = bnr.ReadInt32(); bnr.BaseStream.Position = bnr.BaseStream.Position + 4; animEvent.EventsPointer = bnr.ReadInt32(); bnr.BaseStream.Position = bnr.BaseStream.Position + 4; PrevOffsetTwo = Convert.ToInt32(bnr.BaseStream.Position); bnr.BaseStream.Position = animEvent.EventsPointer; animEvent.EventBit = bnr.ReadInt32(); animEvent.FrameNumber = bnr.ReadInt32(); M3a.Events.Add(animEvent); bnr.BaseStream.Position = PrevOffsetTwo; } M3a.AnimationID = ID; M3a.FileName = "AnimationID" + M3a.AnimationID + ".m3a"; M3a.ShortName = "AnimationID" + M3a.AnimationID; M3a._IsBlank = false; Anim = M3a; //Subtracts pointers in there by the data offset to get their base value. int OffTemp = 0; using (MemoryStream msm3a = new MemoryStream(M3a.RawData)) { using (BinaryReader brm3a = new BinaryReader(msm3a)) { using (BinaryWriter bwm3a = new BinaryWriter(msm3a)) { //Adjusts the offsets in the Rawdata of the m3a. bwm3a.BaseStream.Position = 0; for (int y = 0; y < M3a.TrackCount; y++) { bwm3a.BaseStream.Position = 0; bwm3a.BaseStream.Position = 16 + (48 * y); OffTemp = brm3a.ReadInt32(); bwm3a.BaseStream.Position = (bwm3a.BaseStream.Position - 4); if (OffTemp > 0) { OffTemp = OffTemp - M3a.TrackPointer; bwm3a.Write(OffTemp); } bwm3a.BaseStream.Position = 40 + (48 * y); OffTemp = brm3a.ReadInt32(); bwm3a.BaseStream.Position = (bwm3a.BaseStream.Position - 4); if (OffTemp > 0) { OffTemp = OffTemp - M3a.TrackPointer; bwm3a.Write(OffTemp); } } //Adjusts the offsets in the Events. bwm3a.BaseStream.Position = (bwm3a.BaseStream.Length - 280); OffTemp = M3a.RawData.Length - 32; bwm3a.Write(OffTemp); bwm3a.BaseStream.Position = bwm3a.BaseStream.Position + 76; OffTemp = M3a.RawData.Length - 24; bwm3a.Write(OffTemp); bwm3a.BaseStream.Position = bwm3a.BaseStream.Position + 76; OffTemp = M3a.RawData.Length - 16; bwm3a.Write(OffTemp); bwm3a.BaseStream.Position = bwm3a.BaseStream.Position + 76; OffTemp = M3a.RawData.Length - 8; bwm3a.Write(OffTemp); } } } //Appends the Animation Block Data to the FullData. M3a.FullData = new byte[(M3a.AnimDataSize + 96)]; M3a._FileLength = M3a.FullData.LongLength; Array.Copy(M3a.RawData, 0, M3a.FullData, 0, M3a.RawData.Length); Array.Copy(M3a.MotionData, 0, M3a.FullData, M3a.RawData.Length, M3a.MotionData.Length); return(Anim); }
static void Benchmark(int entityCount, BufferType bufferType, bool randomComponents) { Console.WriteLine($"Benchmarking {entityCount} entities, {bufferType.ToString().Split('.').Last()} buffers, random insertion order: {randomComponents}"); EntityRegistry registry = new EntityRegistry(); registry.RegisterComponent <Int1>(bufferType); registry.RegisterComponent <Int2>(bufferType); registry.RegisterComponent <Int3>(bufferType); registry.RegisterComponent <Int4>(bufferType); registry.RegisterComponent <Int5>(bufferType); registry.RegisterComponent <Int6>(bufferType); for (int i = 0; i < entityCount; i++) { registry.CreateEntity(); } List <int> indices1 = new List <int>(); List <int> indices2 = new List <int>(); List <int> indices3 = new List <int>(); List <int> indices4 = new List <int>(); List <int> indices5 = new List <int>(); List <int> indices6 = new List <int>(); for (int i = 0; i < entityCount; i += (xorshift(1) + 1)) { indices1.Add(i); } for (int i = 0; i < entityCount; i += (xorshift(2) + 1)) { indices2.Add(i); } for (int i = 0; i < entityCount; i += (xorshift(3) + 1)) { indices3.Add(i); } for (int i = 0; i < entityCount; i += (xorshift(4) + 1)) { indices4.Add(i); } for (int i = 0; i < entityCount; i += (xorshift(5) + 1)) { indices5.Add(i); } for (int i = 0; i < entityCount; i += (xorshift(6) + 1)) { indices6.Add(i); } if (randomComponents) { xorshuffle(indices1); xorshuffle(indices2); xorshuffle(indices3); xorshuffle(indices4); xorshuffle(indices5); xorshuffle(indices6); } foreach (int i in indices1) { registry.AddComponent(registry.EntityUIDFromIdx(i), new Int1(xorshift())); } foreach (int i in indices2) { registry.AddComponent(registry.EntityUIDFromIdx(i), new Int2(i, xorshift())); } foreach (int i in indices3) { registry.AddComponent(registry.EntityUIDFromIdx(i), new Int3(i, i, xorshift())); } foreach (int i in indices4) { registry.AddComponent(registry.EntityUIDFromIdx(i), new Int4(i, i, i, xorshift())); } foreach (int i in indices5) { registry.AddComponent(registry.EntityUIDFromIdx(i), new Int5(i, i, i, i, xorshift())); } foreach (int i in indices6) { registry.AddComponent(registry.EntityUIDFromIdx(i), new Int6(i, i, i, i, i, xorshift())); } Measure(); registry.Loop((int index, ref Int1 int1, ref Int2 int2) => { int2.x = int1.x; }); Measure("Propagated x to Int2"); registry.Loop((int index, ref Int2 int2, ref Int3 int3) => { int3.x = int2.x; }); Measure("Propagated x to Int3"); registry.Loop((int index, ref Int3 int3, ref Int4 int4) => { int4.x = int3.x; }); Measure("Propagated x to Int4"); registry.Loop((int index, ref Int4 int4, ref Int5 int5) => { int5.x = int4.x; }); Measure("Propagated x to Int5"); registry.Loop((int index, ref Int5 int5, ref Int6 int6) => { int6.x = int5.x; }); Measure("Propagated x to Int6"); registry.Loop((int index, ref Int2 int2, ref Int3 int3, ref Int4 int4) => { int3.y = int2.y; int4.y = int3.y; }); Measure("Propagated y to Int3 and Int4"); registry.Loop((int index, ref Int3 int3, ref Int4 int4, ref Int5 int5) => { int4.y = int3.y; int5.y = int4.y; }); Measure("Propagated y to Int4 and Int5"); registry.Loop((int index, ref Int4 int4, ref Int5 int5, ref Int6 int6) => { int5.y = int4.y; int6.y = int5.y; }); Measure("Propagated y to Int5 and Int6"); ulong checkSum = 0; registry.Loop((int index, ref Int6 int6) => { checkSum ^= (ulong)(int6.x + int6.y); }); Console.WriteLine($"checksum: {checkSum}"); }