Table of Contents

Class World

Namespace
Frent
Assembly
Frent.dll

A collection of entities that can be updated and queried.

public class World : IDisposable
Inheritance
World
Implements
Inherited Members

Constructors

World(IUniformProvider?, Config?)

Creates a world with zero entities and a uniform provider.

public World(IUniformProvider? uniformProvider = null, Config? config = null)

Parameters

uniformProvider IUniformProvider

The initial uniform provider to be used.

config Config

The inital config to use. If not provided, Singlethreaded is used.

Properties

CurrentConfig

The current world config.

public Config CurrentConfig { get; set; }

Property Value

Config

EntityCount

Gets the current number of entities managed by the world.

public int EntityCount { get; }

Property Value

int

UniformProvider

The current uniform provider used when updating components/queries with uniforms.

public IUniformProvider UniformProvider { get; set; }

Property Value

IUniformProvider

Methods

Create()

Creates an Entity with zero components.

public Entity Create()

Returns

Entity

The entity that was created.

CreateFromHandles(ReadOnlySpan<ComponentHandle>, ReadOnlySpan<TagID>)

Creates an Entity from a set of component handles. The handles are not disposed.

public Entity CreateFromHandles(ReadOnlySpan<ComponentHandle> componentHandles, ReadOnlySpan<TagID> tags = default)

Parameters

componentHandles ReadOnlySpan<ComponentHandle>
tags ReadOnlySpan<TagID>

Returns

Entity

The created entity.

CreateFromObjects(ReadOnlySpan<object>)

Creates an Entity.

public Entity CreateFromObjects(ReadOnlySpan<object> components)

Parameters

components ReadOnlySpan<object>

The components to use.

Returns

Entity

The created entity.

CreateMany<T>(int)

Creates a large amount of entities quickly

public ChunkTuple<T> CreateMany<T>(int count)

Parameters

count int

The number of entities to create

Returns

ChunkTuple<T>

The entities created and their component spans

Type Parameters

T

CreateQuery()

Returns a query builder that can be used to create a query with the specified rules.

public QueryBuilder CreateQuery()

Returns

QueryBuilder

Create<T>(in T)

Creates an Entity with the given component(s)

public Entity Create<T>(in T comp)

Parameters

comp T

Returns

Entity

An Entity that can be used to acsess the component data

Type Parameters

T

Dispose()

Disposes of the World.

public void Dispose()

EnsureCapacity(EntityType, int)

Allocates memory sufficient to store count entities of a type

public void EnsureCapacity(EntityType entityType, int count)

Parameters

entityType EntityType

The types of the entity to allocate for

count int

Number of entity spaces to allocate

Remarks

Use this method when creating a large number of entities

Update()

Updates all component instances in the world that implement a component interface, e.g., IComponent

public void Update()

Update(Type)

Updates all component instances in the world that implement a component interface and have update methods with an attribute of type attributeType

public void Update(Type attributeType)

Parameters

attributeType Type

The attribute type to filter

UpdateComponent(ComponentID)

Updates all instances of a specific component type.

public void UpdateComponent(ComponentID componentType)

Parameters

componentType ComponentID

Update<T>()

Updates all component instances in the world that implement a component interface and have update methods with the T attribute

public void Update<T>() where T : UpdateTypeAttribute

Type Parameters

T

The type of attribute to filter

Events

ComponentAdded

Invoked whenever a component is added to an entity.

public event Action<Entity, ComponentID> ComponentAdded

Event Type

Action<Entity, ComponentID>

ComponentRemoved

Invoked whenever a component is removed from an entity.

public event Action<Entity, ComponentID> ComponentRemoved

Event Type

Action<Entity, ComponentID>

EntityCreated

Invoked whenever an entity is created on this world.

public event Action<Entity> EntityCreated

Event Type

Action<Entity>

EntityDeleted

Invoked whenever an entity belonging to this world is deleted.

public event Action<Entity> EntityDeleted

Event Type

Action<Entity>

TagDetached

Invoked whenever a tag is removed from an entity.

public event Action<Entity, TagID> TagDetached

Event Type

Action<Entity, TagID>

TagTagged

Invoked whenever a tag is added to an entity.

public event Action<Entity, TagID> TagTagged

Event Type

Action<Entity, TagID>