Skip to content

Commit

Permalink
feat: minor refactor, jsdoc fix
Browse files Browse the repository at this point in the history
  • Loading branch information
isaac-mason committed Nov 26, 2023
1 parent 400370e commit c1b67ea
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changeset/chilled-rules-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@arancini/core": patch
"arancini": patch
---

feat: minor refactor, jsdoc fix
19 changes: 15 additions & 4 deletions packages/arancini-core/src/world.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,17 @@ export class World<E extends AnyEntity = any> extends EntityContainer<E> {
/**
* Creates a new entity
* @param entity
* @returns a proxied entity that
* @returns the created entity
*
* @example
* ```ts
* const entity = {
* position: { x: 0, y: 0 },
* velocity: { x: 0, y: 0 },
* }
*
* world.create(entity)
* ```
*
* @example
* ```ts
Expand All @@ -146,12 +155,14 @@ export class World<E extends AnyEntity = any> extends EntityContainer<E> {
create(entity: E): E {
addEntityToContainer(this, entity)

const internal = entity as EntityWithMetadata<E>
internal[ARANCINI_SYMBOL] = this.entityMetadataPool.request()
internal[ARANCINI_SYMBOL].bitset.add(
const metadata = this.entityMetadataPool.request()
metadata.bitset.add(
...Object.keys(entity).map((c) => this.componentRegistry[c])
)

const internal = entity as EntityWithMetadata<E>
internal[ARANCINI_SYMBOL] = metadata

this.index(entity)

return entity
Expand Down

2 comments on commit c1b67ea

@vercel
Copy link

@vercel vercel bot commented on c1b67ea Nov 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on c1b67ea Nov 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.