Skip to content

Modify component Pt 2 - #3587

Open
Crepestrom wants to merge 8 commits into
PixelGuys:masterfrom
Crepestrom:Modify-Component
Open

Crepestrom wants to merge 8 commits into
PixelGuys:masterfrom
Crepestrom:Modify-Component

Conversation

@Crepestrom

@Crepestrom Crepestrom commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Adds a new sync command that allows sending small actions from client to server or server to client

Goal:

  • a system allows the client/server to send smaller messages to the server/client rather (apart from sending and overwriting the entire component data)

Method:

  • In each ECS component is defined a modifyComponent function
  • if a component wants to send a modify component command to the server (a taking damage command) the client will compress the message into a binary writer and send it with a syncCommand
  • the sync command checks what side it is on and interprets its messages (server side ignores load and unload commands because the client should not overwrite server data while the server should be able to override client data)
  • if the sync command is undone it will revert that component back to a previously saved state before the sync command was issued
  • if a component receives a modifyComponent Command from sync (Eg: server to client) then the side that recieves it will run modifyComponent (client will run it)
  • modifyComponent only allows what the component allows to be changed by it (eg: you cant change max health when you take damage)

Use case:

  • A inventory component (use a enum to determine the operation and then use the rest of the binary data to finish it)
  • A health component
  • Status effect component

@Crepestrom
Crepestrom marked this pull request as ready for review September 8, 2026 19:07
Comment thread src/sync.zig Outdated
std.log.debug("side {} actiontype {}", .{side, actionType});

inline for (@typeInfo(main.entity.components).@"struct".decls) |decl| {
if (@field(main.entity.components, decl.name).server.get(entityId)) |component| {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it still accesses the server on the client

@Crepestrom Crepestrom changed the title Modify component Modify component Pt 2 Sep 8, 2026
@Wunka Wunka moved this to WIP/not ready for review in PRs to review Sep 17, 2026
@Crepestrom

Copy link
Copy Markdown
Contributor Author

made a write up for the system and its goals

@Crepestrom

Copy link
Copy Markdown
Contributor Author

Goal:

  • a system allows the client/server to send smaller messages to the server/client rather (apart from sending and overwriting the entire component data)

Method:

  • In each ECS component is defined a modifyComponent function
  • if a component wants to send a modify component command to the server (a taking damage command) the client will compress the message into a binary writer and send it with a syncCommand
  • the sync command checks what side it is on and interprets its messages (server side ignores load and unload commands because the client should not overwrite server data while the server should be able to override client data)
  • if the sync command is undone it will revert that component back to a previously saved state before the sync command was issued
  • if a component receives a modifyComponent Command from sync (Eg: server to client) then the side that recieves it will run modifyComponent (client will run it)
  • modifyComponent only allows what the component allows to be changed by it (eg: you cant change max health when you take damage)

Use case:

  • A inventory component (use a enum to determine the operation and then use the rest of the binary data to finish it)
  • A health component
  • Status effect component

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: WIP/not ready for review

Development

Successfully merging this pull request may close these issues.

4 participants