Quantum 3 3.0.5

Public Member Functions | List of all members
Quantum.Core.FrameBase.FrameBaseUnsafe Struct Reference

Frame API to give access to C# unsafe pointers and advanced immediate operations. More...

Inherits IDisposable.

Public Member Functions

 FrameBaseUnsafe (FrameBase frame)
 Create FrameBaseUnsafe from a FrameBase. More...
 
void CommitAllCommands ()
 Trigger the execution of entity and component deletion. More...
 
ComponentGetter< T > ComponentGetter< T > ()
 Retrieves a ComponentGetter instance for the specified component type T from a FrameBaseUnsafe object. More...
 
void Dispose ()
 Dispose the FrameBaseUnsafe instance. More...
 
ComponentFilterStruct< T > FilterStruct< T > (ComponentSet without=default, ComponentSet any=default, Int32? offset=null, Int32? count=null)
 Returns a filtered ComponentFilterStruct instance for the specified type T. More...
 
ComponentBlockIterator< T > GetComponentBlockIterator< T > ()
 Get a component iterator that cycles blocks of component pointers. More...
 
ComponentBlockIterator< T > GetComponentBlockIterator< T > (int offset, int count)
 Get a component iterator that cycles blocks of component pointers, using a start offset and count More...
 
void * GetOrAddSingletonPointer (int componentIndex, EntityRef optionalAddTarget=default)
 Retrieves a pointer to the specified singleton component, creating it if it doesn't exist. More...
 
T * GetOrAddSingletonPointer< T > (EntityRef optionalAddTarget=default)
 Get or add a pointer to the singleton component of type T in the Frame. More...
 
void * GetPointer (EntityRef entityRef, int componentIndex)
 Gets a pointer to a component that can be changed directly without writing the component back with Set<T>(EntityRef, T). More...
 
T * GetPointer< T > (EntityRef entityRef)
 Gets a pointer to a component that can be changed directly without writing the component back with Set<T>(EntityRef, T). More...
 
void * GetPointerSingleton (int componentIndex)
 Get a pointer to the singleton instance of the specified component type. More...
 
void * GetPointerSingleton (Type componentType)
 Returns a pointer to the singleton component of type T. More...
 
T * GetPointerSingleton< T > ()
 
bool TryGetPointer (EntityRef entityRef, int componentIndex, out void *value)
 Similar to GetPointer(EntityRef, int) but does not throw an exception if the component is not present. More...
 
bool TryGetPointer< T > (EntityRef entityRef, out T *value)
 Similar to GetPointer<T>(EntityRef) but does not throw an exception if the component is not present. More...
 
bool TryGetPointerSingleton (int componentIndex, out void *component)
 Try to get a pointer to the specified component singleton in the current frame. More...
 
bool TryGetPointerSingleton< T > (out T *component)
 Tries to get a pointer to a component singleton of type T. More...
 
bool TryGetPointerSingleton< T > (Type componentType, out void *component)
 Tries to get a pointer to the singleton component of type T. More...
 

Detailed Description

Frame API to give access to C# unsafe pointers and advanced immediate operations.

Usage: Frame.Unsafe.Get

Constructor & Destructor Documentation

◆ FrameBaseUnsafe()

Quantum.Core.FrameBase.FrameBaseUnsafe.FrameBaseUnsafe ( FrameBase  frame)
inline

Create FrameBaseUnsafe from a FrameBase.

Parameters
frameFrame

Member Function Documentation

◆ GetComponentBlockIterator< T >() [1/2]

ComponentBlockIterator<T> Quantum.Core.FrameBase.FrameBaseUnsafe.GetComponentBlockIterator< T > ( )
inline

Get a component iterator that cycles blocks of component pointers.

Template Parameters
TComponent type
Returns
Block iterator
var region = 1UL << 1;
var navMeshAgents = f.Unsafe.GetComponentBlockIterator<NavMeshAgent>();
while (navMeshAgents.NextBlock(out EntityRef* entities, out NavMeshAgent* agents, out int count)) {
for (int i = 0; i<count; i++) {
var entity = entities[i];
var agent = &amp;agents[i];
agent->SetNavMeshRegionActive(region, !agent->IsNavMeshRegionActive(region));
}
}
Type Constraints
T :unmanaged 
T :IComponent 

◆ GetComponentBlockIterator< T >() [2/2]

ComponentBlockIterator<T> Quantum.Core.FrameBase.FrameBaseUnsafe.GetComponentBlockIterator< T > ( int  offset,
int  count 
)
inline

Get a component iterator that cycles blocks of component pointers, using a start offset and count

Template Parameters
TComponent type
Parameters
offsetOffset of entities we want
countHow many entities we want
Returns
Block iterator
var region = 1UL << 1;
var navMeshAgents = f.Unsafe.GetComponentBlockIterator<NavMeshAgent>(32, 16);
while (navMeshAgents.NextBlock(out EntityRef* entities, out NavMeshAgent* agents, out int count)) {
for (int i = 0; i<count; i++) {
var entity = entities[i];
var agent = &amp;agents[i];
agent->SetNavMeshRegionActive(region, !agent->IsNavMeshRegionActive(region));
}
}
Type Constraints
T :unmanaged 
T :IComponent 

◆ FilterStruct< T >()

ComponentFilterStruct<T> Quantum.Core.FrameBase.FrameBaseUnsafe.FilterStruct< T > ( ComponentSet  without = default,
ComponentSet  any = default,
Int32?  offset = null,
Int32?  count = null 
)
inline

Returns a filtered ComponentFilterStruct instance for the specified type T.

Parameters
withoutThe ComponentSet specifying components that the filtering should exclude.
anyThe ComponentSet specifying components that at least one of them should be present in the filtering result.
offsetThe optional offset specifying the starting index of the filtering result.
countThe optional count specifying the number of elements in the filtering result.
Template Parameters
TThe type of components to filter.
Returns
A ComponentFilterStruct instance representing the filtered component collection.
Type Constraints
T :unmanaged 

◆ ComponentGetter< T >()

ComponentGetter<T> Quantum.Core.FrameBase.FrameBaseUnsafe.ComponentGetter< T > ( )
inline

Retrieves a ComponentGetter instance for the specified component type T from a FrameBaseUnsafe object.

Template Parameters
TThe type of the component to retrieve
Returns
A ComponentGetter instance for the specified component type T
Type Constraints
T :unmanaged 

◆ GetPointer()

void* Quantum.Core.FrameBase.FrameBaseUnsafe.GetPointer ( EntityRef  entityRef,
int  componentIndex 
)
inline

Gets a pointer to a component that can be changed directly without writing the component back with Set<T>(EntityRef, T).

Parameters
entityRefEntity reference
componentIndexComponent index defined by ComponentTypeId{T}.Id.
Returns
Pointer to the requested component
Exceptions
InvalidOperationExceptionThrown when the entity does not exist
InvalidOperationExceptionThrown when the requested component index is invalid.

◆ CommitAllCommands()

void Quantum.Core.FrameBase.FrameBaseUnsafe.CommitAllCommands ( )
inline

Trigger the execution of entity and component deletion.

◆ GetPointerSingleton() [1/2]

void* Quantum.Core.FrameBase.FrameBaseUnsafe.GetPointerSingleton ( Type  componentType)
inline

Returns a pointer to the singleton component of type T.

Parameters
componentTypeThe type of the singleton component.
Returns
A pointer to the singleton component.

The component type T must implement the IComponentSingleton interface and be unmanaged.

◆ GetPointerSingleton() [2/2]

void* Quantum.Core.FrameBase.FrameBaseUnsafe.GetPointerSingleton ( int  componentIndex)
inline

Get a pointer to the singleton instance of the specified component type.

Parameters
componentIndexThe index of the component type.
Returns
A pointer to the singleton instance of the component.

◆ TryGetPointerSingleton< T >() [1/2]

bool Quantum.Core.FrameBase.FrameBaseUnsafe.TryGetPointerSingleton< T > ( out T *  component)
inline

Tries to get a pointer to a component singleton of type T.

Template Parameters
TThe type of the component singleton.
Parameters
componentThe pointer to the component singleton if found, otherwise null.
Returns
true if the pointer to the component singleton was successfully obtained, otherwise false.
Type Constraints
T :unmanaged 
T :IComponentSingleton 

◆ TryGetPointerSingleton< T >() [2/2]

bool Quantum.Core.FrameBase.FrameBaseUnsafe.TryGetPointerSingleton< T > ( Type  componentType,
out void *  component 
)
inline

Tries to get a pointer to the singleton component of type T.

Parameters
componentTypeThe type of the singleton component.
componentA pointer to the singleton component.
Returns
true if the singleton component was successfully found and the pointer was obtained, false otherwise.

◆ TryGetPointerSingleton()

bool Quantum.Core.FrameBase.FrameBaseUnsafe.TryGetPointerSingleton ( int  componentIndex,
out void *  component 
)
inline

Try to get a pointer to the specified component singleton in the current frame.

Parameters
componentIndexThe index of the component singleton.
componentA pointer to the component, if it exists; otherwise, null.
Returns
true if the component singleton exists and a pointer is successfully obtained; otherwise, false.

◆ GetOrAddSingletonPointer< T >()

T* Quantum.Core.FrameBase.FrameBaseUnsafe.GetOrAddSingletonPointer< T > ( EntityRef  optionalAddTarget = default)
inline

Get or add a pointer to the singleton component of type T in the Frame.

Template Parameters
TType of the singleton component
Parameters
optionalAddTargetOptional entity reference to add the singleton component to, if it doesn't already exist
Returns
Pointer to the singleton component
Type Constraints
T :unmanaged 
T :IComponentSingleton 

◆ GetOrAddSingletonPointer()

void* Quantum.Core.FrameBase.FrameBaseUnsafe.GetOrAddSingletonPointer ( int  componentIndex,
EntityRef  optionalAddTarget = default 
)
inline

Retrieves a pointer to the specified singleton component, creating it if it doesn't exist.

Parameters
componentIndexThe index of the component.
optionalAddTargetThe entity reference to add the singleton component if it doesn't exist.
Returns
A pointer to the singleton component.

◆ Dispose()

void Quantum.Core.FrameBase.FrameBaseUnsafe.Dispose ( )
inline

Dispose the FrameBaseUnsafe instance.