-
-
Notifications
You must be signed in to change notification settings - Fork 15
It's documentation time #78
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't have a tonne of time to look through this, but put down a few comments
In general, I think some of the additions are useful to add context (especially for me coming in new to this project), but there are a significant number of internal comments (//
) that are just stating what a single line is doing... I'd suggest avoiding those as they tend to just add bloat
/// queried via the `archetype_has_component` function. | ||
pub(crate) fn matches_archetype<F>(&self, mut archetype_has_component: F) -> bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mega-nit:
/// queried via the `archetype_has_component` function. | |
pub(crate) fn matches_archetype<F>(&self, mut archetype_has_component: F) -> bool | |
/// queried via the given function. | |
pub(crate) fn matches_archetype<F>(&self, mut does_archetype_have_component: F) -> bool |
@@ -97,17 +100,24 @@ impl Archetypes { | |||
pub(crate) fn spawn(&mut self, id: EntityId) -> EntityLocation { | |||
let empty = self.empty_mut(); | |||
|
|||
let rellocated = unsafe { empty.reserve_one() }; | |||
// Reserve space for the spawned entity. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably have a // SAFETY
comment
// Remove the archetype. | ||
let mut arch = self.archetypes.remove(arch_idx.0 as usize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think this comment is adding any value over the method name
// The archetype already exists, insert it into the | ||
// map and return it. | ||
*vacant_insert_components.insert(*entry.get()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think this is comment is adding any value, it just restates how insert
works
I documented all over the place!
Specifically these modules:
access
archetype
bit_set
component
entities
event
(and submodules)fetch
handler
world
All public API was already documented, but not many internal functions. I added docs for most of them. I also added comments inside of some functions to explain their implementation. I added notes and TODOs whenever I saw something that I thought could be improved or optimized. However, apart from one test I added, the code itself was left untouched - no functionality changed, not even implementation details.
I hope this makes the codebase more navigable and understandable. I'm open to feedback, additions, changes and critique!