-
Notifications
You must be signed in to change notification settings - Fork 20
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
Serialize the player's inventory in save files #431
base: master
Are you sure you want to change the base?
Conversation
server/src/sim.rs
Outdated
) | ||
.unwrap(); | ||
entities.push(repr); | ||
let reprs = self.snapshot_entity_and_children(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.
Are child entities not also in graph_entities
?
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.
Not currently, although given how tricky this implementation is, I would consider this to be a mistake on my part.
There's a distinction between entities that have an inherent position (which is managed with a Position
component) and nodes that don't, such as inventory items. For the latter, they belong to an entity that does have a position.
I had decided that graph_entities
would only contain entities that have a position, but I have a good reason to second-guess that, since that doesn't correspond with how save files are organized at all. I'll go ahead and fix this before my next push to this branch.
EDIT: Actually, I might have to think about this some more.
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.
I've updated the PR so that child entities are now in graph_entities
. To accomplish this (what I believe to be) the most understandable way possible, I've made NodeId
into its own component intrinsically linked with graph_entities
so that inventory items can be associated with a NodeId
without needing a Position
.
This is helpful because Position
has a bunch of other functionality, such as syncing with clients, so separating this functionality is important.
I'll resolve this thread for now, as child entities now are in graph_entities
, but the resolution may be controversial, and I'm definitely open to feedback.
c1b6e2a
to
f59d7d3
Compare
f59d7d3
to
719d02e
Compare
This completes part of #428.
Allows users to exit and re-open Hypermine while keeping the contents of their inventory, as previously, the inventory was cleared every time the game was loaded.