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
Published by github-actions[bot] about 2 years ago
<Property>
encounters an entity that has the property already set, it will not add or remove the proprty on mount or unmount, but it will still update the property if the value changes. When unmounting, it will restore the property to the value it had before the component was mounted.Published by github-actions[bot] about 2 years ago
Bucket.dispose
, which will also dispose of derived buckets properly.Bucket.onCleared
event, which is emitted when the bucket's clear
function is invoked.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
World.setProperty
.Published by github-actions[bot] about 2 years ago
World.setProperty
.Published by github-actions[bot] about 2 years ago
@miniplex/core
and @miniplex/react
, with a main miniplex
package re-exporting these.Published by github-actions[bot] about 2 years ago
@miniplex/core
and @miniplex/react
, with a main miniplex
package re-exporting these.Published by github-actions[bot] about 2 years ago
@miniplex/core
and @miniplex/react
, with a main miniplex
package re-exporting these.Published by github-actions[bot] about 2 years ago
EntityPredicate
type has been renamed to just Predicate
.EntityWith
type has been renamed to WithRequiredKeys
.Bucket
can represent any type, not just types extending IEntity
, so its type parameter has been changed to reflect this.Published by github-actions[bot] about 2 years ago
EntityPredicate
type has been renamed to just Predicate
.EntityWith
type has been renamed to WithRequiredKeys
.Published by github-actions[bot] about 2 years ago
useArchetype
export that takes a world as its first argument.Published by github-actions[bot] about 2 years ago
useArchetype
.useBucket
, it didn't do anything useful. Just use useEntities
.Published by github-actions[bot] about 2 years ago
World.archetype()
.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
a43c734: Fixed: When <Component>
re-renders, it is expected to reactively update the component's data to the value of its data
prop, or the ref
of its React child. It has so far been doing that by removing and re-adding the entire component, which had the side-effect of making the entity disappear from and then reappear in archetypes indexing that component. This has now been fixed.
The component will only be added and removed once (at the beginning and the end of the React component's lifetime, respectively); in re-renders during its lifetime, the data will simply be updated directly when a change is detected. This allows you to connect a <Component>
to the usual reactive mechanisms in React.
Published by github-actions[bot] about 2 years ago
useEntity
hook has been renamed to useCurrentEntity
to better express what it does, and to make way for future useEntity
and useEntities
hooks that will create and destroy entities.c102f2d: New: <ArchetypeEntities>
, a new component that (reactively) renders all entities of the specified archetype. This can be used as a replacement for the combination of useArchetype
and <Entities>
, except now your component won't re-render when entities appear or disappear, because the subscription will be scoped to <ArchetypeEntities>
.
Where before you may have done this:
const MyComponent = () => {
const { entities } = useArchetype("my-archetype")
/* This component will now re-render every time the archetype is updated */
return <Entities entities={entities} />
}
You can now do this:
const MyComponent = () => {
/* This component will not rerender */
return <ArchetypeEntities archetype="my-archetype" />
}
The component will also accept arrays of component names:
const EnemyShips = () => {
return <ArchetypeEntities archetype={["ship", "enemy"]} />
}
c38d7e5: Fixed: A couple of components were using useEffect
where it should have been useLayoutEffect
.
54bb5ef: Fixed: no longer re-renders once after mounting.
551dcd9: New: The 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
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
, with the caveat that it now only accepts two arguments, the entity and the component object:
world.extendEntity(entity, {
position: { x: 0, y: 0 },
velocity: { x: 10, y: 20 }
})
b8b2c9b: Major 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)
})
54c59c8: Breaking Change: The Archetype.first
getter has been removed in the interest of reducing API surface where things can also be expressed using common JavaScript constructs:
/* Before: */
const player = world.archetype("player").first
/* Now: */
const [player] = world.archetype("player")
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.
c08f39a: Breaking Change: The ComponentName<T>
type has been removed in favor of just using keyof T
.
410e0f6: New: The World
class can now be instantiated with an initial list of entities like so:
const world = new World({ entities: [entity1, entity2] })
c12dfc1: Fixed: createEntity
was not checking against the world's entity type; this has been fixed.