MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / GetState

Method GetState

Source/Engine/AI/BehaviorTree.cs:95–110  ·  view source on GitHub ↗

Returns the typed node state at the given memory address.

(IntPtr memory)

Source from the content-addressed store, hash-verified

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.

Callers 15

SearchWithAnchoringMethod · 0.45
AddStateMethod · 0.45
FillMethod · 0.45
BindMethod · 0.45
BuildTileAsyncFunction · 0.45
RunMethod · 0.45
RebuildContextFunction · 0.45
PeekSamplesMethod · 0.45

Calls 4

GetTypeFunction · 0.85
ToPointerMethod · 0.80
FromIntPtrMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected