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

Complete Refactor: Brand New Level Architecture #77

Closed
10 tasks done
sunjay opened this issue Nov 9, 2018 · 0 comments
Closed
10 tasks done

Complete Refactor: Brand New Level Architecture #77

sunjay opened this issue Nov 9, 2018 · 0 comments
Labels
refactoring Something needs improvement (doesn't change functionality)

Comments

@sunjay
Copy link
Owner

sunjay commented Nov 9, 2018

Had the realization that I have not been fully utilizing the ECS. Having such a heavyweight map resource has been causing more and more of the state to go into that instead of into entities and components. This has led to code duplication (copying logic for components and for things on the map) and code smells like FloorMap getting increasingly complex.

To solve this issue, we need to refactor/rearchitect the app as follows:

  • Level generator is a top-level module (folder) that produces a vector of specs::World structs
  • Each World is populated with the following: a resource with the bare-bones map (defined below), components for each enemy, item, door, etc. (Should be no reason to query the map anymore other than to find adjacent tiles that are walls)
    • Having a separate World per level removes the need to remove and readd enemies every time the level switches
  • The bare-bones map is just the rooms and their tiles which are now either Wall or Floor tiles -- no tile objects or wall decorations stored in the map (represented with components now)
    • This removes all the special cases we had for updating animations in the map
  • Copy player components between level World structs every time the player changes levels
  • Will need to print the debug representation of the map from the World now -- this is even more powerful for debugging now (Printable debug representation for checking map generation #88)
    • Saving the current level as an image should still work
  • A bunch of the module hierarchy will change and a lot more things will now be represented as components
  • Having sprites and the animation manager (animation set) deduped will come naturally since we won't want to store such a large component
  • Probably good to have some sort of shared resource manager and never clone anything anymore -- will be super helpful when we start rendering text too
  • Merge Position and BoundingBox No, because there are things that only have positions and no bounding boxes (e.g. wall decorations, tile objects, etc.)
@sunjay sunjay mentioned this issue Nov 10, 2018
@sunjay sunjay added the refactoring Something needs improvement (doesn't change functionality) label Dec 3, 2018
@sunjay sunjay pinned this issue Dec 13, 2018
@sunjay sunjay unpinned this issue Dec 24, 2018
@sunjay sunjay mentioned this issue Dec 29, 2018
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Something needs improvement (doesn't change functionality)
Projects
None yet
Development

No branches or pull requests

1 participant