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

Player inventory (initial version) #408

Merged
merged 4 commits into from
Jun 24, 2024
Merged

Conversation

patowen
Copy link
Collaborator

@patowen patowen commented Jun 23, 2024

Partial fix for #397

This PR adds the initial version of an inventory component for players to store blocks they break. The following features exist:

  • An ability to turn itself on and off, controlled by the gameplay_enabled sim_config property
  • The GUI that tells you the quantity of the selected material you have. Since not all materials are selectable yet, if you break an unselectable material, it effectively disappears into the void.
  • A server-authoritative inventory that gets synchronized with the client

The following features are left to future work:

  • The ability to select any material you have on you
  • A GUI that shows you everything you're holding at once
  • Serialization of the inventory for saving
  • Prediction of inventory contents (Required for the player to be able to place more than one block of the same material before receiving server confirmation. This feature likely should be added together with prediction of the world's block updates.)

client/src/graphics/gui.rs Outdated Show resolved Hide resolved
client/src/sim.rs Outdated Show resolved Hide resolved
common/src/node.rs Show resolved Hide resolved
common/src/sim_config.rs Show resolved Hide resolved
server/src/lib.rs Outdated Show resolved Hide resolved
server/src/sim.rs Outdated Show resolved Hide resolved
server/src/sim.rs Outdated Show resolved Hide resolved
While the server is making changes to the world, it keeps a record of
these changes for one frame, which is later transmitted to exiting
clients in a Spawns struct. Rather than storing these changes ad-hoc in
several fields and local variables, this change combines them all into a
single struct to enhance readability and hopefully avoid mistakes.
Breaking blocks adds them to the inventory, and placing blocks removes
them from the inventory, failing if no such item can be found.
Gameplay features, such as an inventory and the need to collect
resources, can unnecessarily restrict creative freedom, so while
gameplay features are being developed, it would be good to keep them
behind a flag to avoid interrupting people who just want to build.
client/src/sim.rs Outdated Show resolved Hide resolved
server/src/sim.rs Outdated Show resolved Hide resolved
@patowen patowen merged commit b95f693 into Ralith:master Jun 24, 2024
4 checks passed
@patowen patowen deleted the player-inventory branch June 24, 2024 18:28
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