Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ classic: added definePrefab and registerPrefab #138

Merged
merged 8 commits into from
May 29, 2024

Conversation

pietrovismara
Copy link

@pietrovismara pietrovismara commented May 22, 2024

Unfortunately there are several formatting changes included as prettier took over a bunch of unformatted code.

The gist of the changes is the following:

  • definePrefab returns a PrefabToken, containing a list of components and a Map<World, eid>
  • registerPrefab assigns an eid to the prefab by internally calling addPrefab, and pairs the eid with the world in the PrefabToken world -> eid map
  • Calling IsA (or any other relation) on a PrefabToken stores it in the relation's $pairsMap and the component's $pairTarget, as it would for an eid
  • getRelationTargets checks if $pairTarget is a PrefabToken and converts it to an eid, using the world -> eid map of PrefabToken

I left the definition of the Prefab component in Entity.ts, as moving it out of there would cause circular dependency issues. I suggest a separate refactor to prevent such issues.

See the included integration test (Prefab.test.ts) for usage.

Copy link
Owner

@NateTheGreatt NateTheGreatt left a comment

Choose a reason for hiding this comment

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

great job! thanks for this 🙏

@NateTheGreatt NateTheGreatt merged commit 70dadfb into NateTheGreatt:next May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants