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
IUniformProviderThe initial uniform provider to be used.
config
ConfigThe inital config to use. If not provided, Singlethreaded is used.
Properties
CurrentConfig
The current world config.
public Config CurrentConfig { get; set; }
Property Value
EntityCount
Gets the current number of entities managed by the world.
public int EntityCount { get; }
Property Value
UniformProvider
The current uniform provider used when updating components/queries with uniforms.
public IUniformProvider UniformProvider { get; set; }
Property Value
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
intThe 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
Create<T>(in T)
Creates an Entity with the given component(s)
public Entity Create<T>(in T comp)
Parameters
comp
T
Returns
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
EntityTypeThe types of the entity to allocate for
count
intNumber 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
TypeThe 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
ComponentRemoved
Invoked whenever a component is removed from an entity.
public event Action<Entity, ComponentID> ComponentRemoved
Event Type
EntityCreated
Invoked whenever an entity is created on this world.
public event Action<Entity> EntityCreated
Event Type
EntityDeleted
Invoked whenever an entity belonging to this world is deleted.
public event Action<Entity> EntityDeleted
Event Type
TagDetached
Invoked whenever a tag is removed from an entity.
public event Action<Entity, TagID> TagDetached
Event Type
TagTagged
Invoked whenever a tag is added to an entity.
public event Action<Entity, TagID> TagTagged