A ๐ฉโ๐ป developer-friendly entity management system for ๐น games and similarly demanding applications, based on ๐ ECS architecture.
MIT License
Bot releases are visible (Hide)
Published by github-actions[bot] about 2 years ago
useIsomorphicLayoutEffect
.Published by github-actions[bot] about 2 years ago
useEffect
where it should have been useLayoutEffect
.Published by github-actions[bot] about 2 years ago
Published by github-actions[bot] about 2 years ago
Published by github-actions[bot] about 2 years ago
createEntity
.Published by github-actions[bot] about 2 years ago
<ArchetypeEntities>
, a new component that (reactively) renders all entities of the specified archetype.Published by github-actions[bot] about 2 years ago
Published by github-actions[bot] about 2 years ago
createECS
function now allows you to pass in an existing World
instance as its first argument. If no world is passed, it will create a new one (using the specified type, if any), as it has previously.Published by github-actions[bot] about 2 years ago
Published by github-actions[bot] about 2 years ago
410e0f6: The World
class can now be instantiated with an initial list of entities like so:
const world = new World({ entities: [entity1, entity2] })
Published by github-actions[bot] about 2 years ago
769dba7: Major Breaking Change: The signature of addComponent
has been simplified to accept an entity, a component name, and the value of the component:
/* Before */
world.addComponent(entity, { position: { x: 0, y: 0 } })
/* After */
world.addComponent(entity, "position", { x: 0, y: 0 })
The previous API for addComponent
is now available as extendEntity
, but marked as deprecated.
b8b2c9b: Breaking Change: The API signature of createEntity
has been simplified in order to improve clarity of the API and reduce complexity in both implementation and types. createEntity
now only supports a single argument, which must satisfy the world's entity type.
This will only affect you if you have been using createEntity
with more than one argument in order to compose entities from partial entities, like so:
const entity = createEntity(position(0, 0), velocity(1, 1), health(100))
This always had the issue of createEntity
not checking the initial state of the entity against the world's entity type. Theoretically, the library could invest some additional effort into complex type assembly to ensure that the entity is valid, but there are enough object composition tools available already, so it felt like an unneccessary duplication.
Instead, composition is now deferred into userland, where one of the most simple tools is the spread operator:
const entity = createEntity({
...position(0, 0),
...velocity(1, 1),
...health(100)
})
cb6d078: Breaking Change: When destroying entities, they are now removed from the world's global list of entities as well as the archetypes' lists of entities using the shuffle-and-pop pattern. This has the following side-effects that may impact your code:
__miniplex
component no longer corresponds to its index in the entities
array.This change provides significantly improved performance in situations where a large number of entities are continuously being created and destroyed.
4d9e51b: Breaking Change: Removed the EntityID
and ComponentData
types.
Published by github-actions[bot] about 2 years ago
miniplex
as a direct dependency; it is no longer necessary to install miniplex as a peer dependency.Published by github-actions[bot] about 2 years ago
useArchetype
.Published by github-actions[bot] about 2 years ago
Published by github-actions[bot] about 2 years ago
Published by github-actions[bot] about 2 years ago
1cee12c: Typing improvements, thanks to @benwest.
65d2b77: Added: Archtypes now implement a [Symbol.iterator]
, meaning they can be iterated over directly:
const withVelocity = world.archetype("velocity")
for (const { velocity } of withVelocity) {
/* ... */
}
(Thanks @benwest.)
Published by github-actions[bot] over 2 years ago
Published by github-actions[bot] over 2 years ago
cca39cd: New: Archetypes now expose a first
getter that returns the first of the entities in the archetype (or null
if it doesn't have any entities.) This streamlines situations where you deal with singleton entities (like a player, camera, and so on.) For example, in miniplex-react
, you can now do the following:
export const CameraRigSystem: FC = () => {
const player = ECS.useArchetype("isPlayer").first
const camera = ECS.useArchetype("isCamera").first
/* Do things with player and camera */
}
Published by github-actions[bot] over 2 years ago
<Component>
, you were not able to set a ref
on it. This has now been fixed.Published by github-actions[bot] over 2 years ago
<Collection>
has been renamed to <ManagedEntities>
.useEntity
has been changed back to its original functionality of returning the current entity context. useEntities
has been removed.