miniplex

A ๐Ÿ‘ฉโ€๐Ÿ’ป developer-friendly entity management system for ๐Ÿ•น games and similarly demanding applications, based on ๐Ÿ›  ECS architecture.

MIT License

Downloads
15.2K
Stars
764
Committers
10

Bot releases are visible (Hide)

miniplex - [email protected]

Published by github-actions[bot] about 2 years ago

Patch Changes

miniplex - @miniplex/[email protected]

Published by github-actions[bot] about 2 years ago

Patch Changes

  • 3fcc79a: When <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.
miniplex - @miniplex/[email protected]

Published by github-actions[bot] about 2 years ago

Patch Changes

  • 10c60f8: Implemented Bucket.dispose, which will also dispose of derived buckets properly.
  • f92b5f7: Added the Bucket.onCleared event, which is emitted when the bucket's clear function is invoked.
miniplex - [email protected]

Published by github-actions[bot] about 2 years ago

Patch Changes

miniplex - [email protected]

Published by github-actions[bot] about 2 years ago

Patch Changes

miniplex - @miniplex/[email protected]

Published by github-actions[bot] about 2 years ago

Patch Changes

  • 16cef4e: Massive performance improvements!
  • 1c63f90: Added World.setProperty.
miniplex - @miniplex/[email protected]

Published by github-actions[bot] about 2 years ago

Patch Changes

  • 1c63f90: Added World.setProperty.
miniplex - @miniplex/[email protected]

Published by github-actions[bot] about 2 years ago

Patch Changes

  • 1d26060: Restructured the packages into @miniplex/core and @miniplex/react, with a main miniplex package re-exporting these.
miniplex - [email protected]

Published by github-actions[bot] about 2 years ago

Patch Changes

  • 1d26060: Restructured the packages into @miniplex/core and @miniplex/react, with a main miniplex package re-exporting these.
  • Updated dependencies [1d26060]
miniplex - @miniplex/[email protected]

Published by github-actions[bot] about 2 years ago

Patch Changes

  • 1d26060: Restructured the packages into @miniplex/core and @miniplex/react, with a main miniplex package re-exporting these.
miniplex - [email protected]

Published by github-actions[bot] about 2 years ago

Patch Changes

  • f81bf3e: The EntityPredicate type has been renamed to just Predicate.
  • cf0212e: Iterating over a bucket will now iterate over its entities in reverse order, which makes it a little safer to synchronously remove entities from within a system.
  • 2af57a6: The EntityWith type has been renamed to WithRequiredKeys.
  • aa3d6d2: Bucket can represent any type, not just types extending IEntity, so its type parameter has been changed to reflect this.
miniplex - [email protected]

Published by github-actions[bot] about 2 years ago

Patch Changes

  • f81bf3e: The EntityPredicate type has been renamed to just Predicate.
  • 2af57a6: The EntityWith type has been renamed to WithRequiredKeys.
miniplex - [email protected]

Published by github-actions[bot] about 2 years ago

Patch Changes

  • 87a8b8c: Added a global useArchetype export that takes a world as its first argument.
miniplex - [email protected]

Published by github-actions[bot] about 2 years ago

Patch Changes

  • 41ccab7: now reactively changes a property's value without removing and re-adding the property.
  • 86c2fdb: Added useArchetype.
  • 40cf138: Removed useBucket, it didn't do anything useful. Just use useEntities.
miniplex - [email protected]

Published by github-actions[bot] about 2 years ago

Patch Changes

  • da62d8c: Fixed the return type of World.archetype().
miniplex - [email protected]

Published by github-actions[bot] about 2 years ago

Major Changes

  • f2406db: 2.0!

Patch Changes

miniplex - [email protected]

Published by github-actions[bot] about 2 years ago

Major Changes

  • f2406db: 2.0!
miniplex - [email protected]

Published by github-actions[bot] about 2 years ago

Patch Changes

  • 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.

miniplex - [email protected]

Published by github-actions[bot] about 2 years ago

Major Changes

  • ce9cfb4: Breaking Change: The 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.

Patch Changes

  • 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.

miniplex - [email protected]

Published by github-actions[bot] about 2 years ago

Major Changes

  • 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:

    • Entities are no longer guaranteed to stay in the same order.
    • The entity ID storied in its internal __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.

Patch Changes

  • 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.