sobinist

LinkedList_NoPreviousPointersForDouble_ElementPointerFirst_R

Jun 7th, 2020
910
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. using Ray2Mod.Components.Types;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Runtime.InteropServices;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace Ray2Mod.Game.Structs.LinkedLists {
  10.  
  11.     // All LinkedLists in Rayman 2 are double
  12.  
  13.     [StructLayout(LayoutKind.Sequential)]
  14.     public unsafe struct LinkedList_NoPreviousPointersForDouble_ElementPointerFirst_ReadAtPointer<T> where T : unmanaged {
  15.         public int * Head;
  16.         public int * Tail;
  17.         public int Count;
  18.  
  19.         public unsafe Pointer<T>[] Read()
  20.         {
  21.             Pointer<T>[] results = new Pointer<T>[Count];
  22.  
  23.             int* Next = Head;
  24.            
  25.             for(int i=0;i<Count;i++) {
  26.                 int* Element = Next;
  27.                 Next = (int*)(*Next);
  28.                 // No Previous Pointer
  29.  
  30.                 results[i] = new Pointer<T>((int)(*Element));
  31.                 Next += 4;
  32.             }
  33.  
  34.             return results;
  35.         }
  36.     }
  37. }
Add Comment
Please, Sign In to add comment