BaseBehaviorParams
This struct is passed into all behaviors. It has information about the entities matched by the BaseSteeringSystem's main entity query. There are several arrays, each containing EntityCount elements (with the exception of ArchetypeChunks and ChunkBaseIndexArray). Each array element has some information about an entity at index i in the query. The BaseBehaviorParams struct contains these fields:
LocalToWorlds[EntityInQueryIndex]- Entity's postion, rotation and scale.Velocities[EntityInQueryIndex]- Entity's current velocity fromVelocityComponent.CachedSpeeds[EntityInQueryIndex]- Magnitude of entity's current velocity.MaxSpeeds[EntityInQueryIndex]- Entity's maximum speed fromMaxSpeedComponentadded by movement authoring.Radii[EntityInQueryIndex]- Entity's radius fromRadiusComponent.IndexesArray[EntityInQueryIndex]- Entity'sIndexes.ChunkBaseIndexArray[ChunkIndex]- Chunk base index array.ArchetypeChunks[ChunkIndex]- Archetype chunks.EntityCount- Number of entities in the entity query.DeltaTime- Time since last frame.
You can use ArchetypeChunks to lookup any component on an entity.
public struct BaseBehaviorParams
{
public NativeArray<LocalToWorld> LocalToWorlds;
public NativeArray<VelocityComponent> Velocities;
public int EntityCount;
...
}
public struct Indexes
{
public int ChunkIndex; // index of chunk in `ArchetypeChunks`
public int EntityInChunkIndex; // index of entity inside chunk
public int EntityInQueryIndex; // index of entity in query
}
Indexing ArchetypeChunk
The ArchetypeChunks gives access to all archetype chunks of the entities. This can be used to look up any arbitrary component on them. ArchetypeChunk containing an entity can be found at it's ChunkIndex. It's archetype inside the chunk is at EntityInChunkIndex. The following example shows looking up LocalToWorld on an entity.
int i = ... // EntityInQueryIndex
int chunkIndex = Indexes[i].ChunkIndex;
int entityInChunkIndex = Indexes[i].EntityInChunkIndex;
ArchetypeChunk chunk = ArchetypeChunks[chunkIndex];
NativeArray<LocalToWorld> transforms = chunk.GetNativeArray(ref Handle);
LocalToWorld transform = transforms[entityInChunkIndex]