Releases: hmans/miniplex
miniplex@0.10.0
Minor Changes
- cc4032d: Breaking Change:
createEntitywill now, like in earlier versions of this library, mutate the first argument that is passed into it (and return it). This allows for patterns where you create the actual entity object before you actually convert it into an entity through createEntity.
Patch Changes
-
b93a831: The internal IDs that are being generated for entities have been changed slightly, as they now start at
0(instead of1) and are always equal to the position of the entity within the world'sentitiesarray. The behavior ofdestroyEntityhas also been changed tonullthe destroyed entity's entry in that array, instead of cutting the entity from it.This change allows you to confidently and reliably use the entity ID (found in the internal miniplex component,
entity.__miniplex.id) when integrating with non-miniplex systems, including storing data in TypedArrays (for which miniplex may gain built-in support at some point in the future; this change is also in preparation for that.)
miniplex-react@0.3.1
Patch Changes
- db987cd: Improve typings within
useEntities.
miniplex-react@0.3.0
Minor Changes
- cc4032d: New:
useEntitiesis a new hook that will create and return a specified number of entities, initialized through an optional entity factory.useEntitydoes the same, but just for a single entity.
miniplex-react@0.2.4
Patch Changes
- 68cff32: Fix React 18 Strict Mode compatibility in
<Component>.
miniplex@0.9.0
Minor Changes
-
b4cee80: Breaking Change:
createEntitywill now always return a new object, and not return the one passed to it. -
544f231: Typescript: You no longer need to mix in
IEntityinto your own entity types, as part of a wider refactoring of the library's typings. Also,createWorldwill now return aRegisteredEntity<YourEntity>type that reflects the presence of the automatically added internal__miniplexcomponent, and makes a lot of interactions with the world instance safer than it was previously. -
544f231: Breaking Change: Miniplex will no longer automatically add an
idcomponent to created entities. If your project has been making use of these automatically generated IDs, you will now need to add them yourself.Example:
let nextId = 0 /* Some component factories */ const id = () => ({ id: nextId++ }) const name = (name) => ({ name }) const world = new World() const entity = world.createEntity(id(), name("Alice"))
Note: Keep in mind that Miniplex doesn't care about entity IDs much, since all interactions with the world are done through object references. Your project may not need to add IDs to entities at all; if it does, this can now be done using any schema that your project requires (numerical IDs, UUIDs, ...).
Patch Changes
-
b4cee80:
createEntitynow allows you to pass multiple parameters, each representing a partial entity. This makes the use of component factory functions more convenient. Example:/* Provide a bunch of component factories */ const position = (x = 0, y = 0) => ({ position: { x, y } }) const velocity = (x = 0, y = 0) => ({ velocity: { x, y } }) const health = (initial) => ({ health: { max: initial, current: initial } }) const world = new World() const entity = world.createEntity( position(0, 0), velocity(5, 7), health(1000) )
Typescript Note: The first argument will always be typechecked against your entity type, so if your entity type has required components, you will need to pass a first argument that satisfies these. The remaining arguments are expected to be partials of your entity type.
-
b4cee80: Breaking Change:
world.queue.createEntityno longer returns an entity (which didn't make a whole lot of semantic sense to begin with.)
miniplex-react@0.2.1
Patch Changes
- 0c1ce64: Now uses
useEffectinstead ofuseLayoutEffect, which should make it easier to use the components in server-side React.