Returns the typed node state at the given memory address.
(IntPtr memory)
| 93 | /// Returns the typed node state at the given memory address. |
| 94 | /// </summary> |
| 95 | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| 96 | public ref T GetState<T>(IntPtr memory) where T : struct |
| 97 | { |
| 98 | var ptr = Unsafe.Read<IntPtr>(IntPtr.Add(memory, _memoryOffset).ToPointer()); |
| 99 | #if !BUILD_RELEASE |
| 100 | if (ptr == IntPtr.Zero) |
| 101 | throw new Exception($"Missing state '{typeof(T).FullName}' for node '{GetType().FullName}'"); |
| 102 | #endif |
| 103 | var handle = GCHandle.FromIntPtr(ptr); |
| 104 | var state = handle.Target; |
| 105 | #if !BUILD_RELEASE |
| 106 | if (state == null) |
| 107 | throw new Exception($"Missing state '{typeof(T).FullName}' for node '{GetType().FullName}'"); |
| 108 | #endif |
| 109 | return ref Unsafe.Unbox<T>(state); |
| 110 | } |
| 111 | |
| 112 | /// <summary> |
| 113 | /// Frees the allocated node state at the given memory address. |
no test coverage detected