-
Notifications
You must be signed in to change notification settings - Fork 26
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
Support enum in Config::Input
#40
Comments
Easing the trait bounds on |
I would not consider this closed until we support enum with fields 😈 ; supporting « only » fieldless enum is still quite a big restriction. It might be possible to support enum with fields currently, but it requires unsafe code which can be hard to write, so I’m advocating for considering:
|
I'm not very familiar with p2p networks. But why cant we allow sending any kind of data? Why cant we just serialize it and then deserialize? |
The constraints on the data come mostly from the compression algorithm being used. If your usecase does not fit the restrictions directly, you can always serialize your inputs outside of GGRS and create Inputs based on your serialization. One important aspect is that all inputs need to have exactly the same number of bits. |
Is there an example of such serialization? |
This input encoding example is from a much older version of GGRS, but the main idea holds: Basically, if you can encode your input into a single fixed-size sequence of bits, then you are good to go. With the current GGRS you can simply define the input as a u8/u16/etc that holds these bits. |
The problem is that I want to send a position where a thing should be spawned. (I use bevy) And I have no idea how to send this position. Ans as I understand its impossible todo, because it cannot be fixed. Right? |
GGRS was built with the assumption that each client sends their inputs each frame (e.g. button inputs from a controller) and that nothing else is necessary to keep the gamestate synchronized. The framework does not have a convenient way to sync the gamestate via occasional events. It is assumed that all gamestate logic can be derived from the controller inputs (aka an input from a player under specific condition leads to an object spawning). If you are looking for more general networking frameworks (that work via events), I recommend asking in the networking channel of the bevy discord. There are lots of great people there that can help you much better than I could! |
Okay, Thank You! |
I would like to use enums in
Config::Input
to differentiate different possible inputs.Config::Input
is requiring onPod
, which has a lot of constraints, main one is that any bit patterns should be correct, making most enum potentially unfit.The trait
Pod
has been split in different traits in this PR: Lokathor/bytemuck#91 ; If I'm not mistaken, ideallyCheckedBitPattern
should be enough.This should enable us to have enums within
Config::Input
.Somewhat related issue: Lokathor/bytemuck#84
As noted #41 (comment), I think we're dependent on bytemuck to support more than fieldless enums.
The text was updated successfully, but these errors were encountered: