-
Notifications
You must be signed in to change notification settings - Fork 41
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
RollbackIdProvider needs a smarter solution #11
Comments
Why not use the Is the rollback ID used as a mapping of entity->entity between different hosts? If so, I would discourage using |
When entities are respawned or deleted after a rollback (and newly created when replaying frames after a rollback), they will have a different Entity component compared to before, making impossible to keep track of them when having to rollback again. For this, another id is necessary that is able to track entities over time. All of this is handled in the plugin, but the solution of handing out the networking Ids is very minimal currently. The RollbackId is not meant to be consistent between clients. |
Thank you for the quick answer. I was looking at a way to get a unique id for the |
Maybe we could use Bevy's Side question: if the entities are different while rolling back and forward, does that mean I can't depend on entities uniquely representing my entities if I use this plugin? For instance, if I had an ( Yeah, I'm thinking that's fine after typing that out... ) |
To answer your side question: GGRS rewinds by loading an old state and overwriting current values. When loading a snapshot, items that have been deleted will have to be recreated and thus get a new entity id. In the same time, your inventory will be overwritten with the entity id vector it had at that point in time. These IDs will then probably be invalid. |
Since a Bevy Yes this means the /// Add this component to all entities you want to be loaded/saved on rollback.
#[derive(Component, Hash, PartialEq, Eq, Clone, Copy, Debug)]
pub struct RollbackFlag(Entity);
/// An `EntityCommand` which adds a `RollbackFlag` component to an entity.
pub struct Rollback;
impl EntityCommand for Rollback {
fn write(self, id: Entity, world: &mut World) {
world.entity_mut(id).insert(RollbackFlag(id));
}
}
/* snip */
app
// ...
.add_startup_system(|mut commands: Commands| {
commands
.spawn(TransformBundle::from_transform(Transform::from_xyz(
1., 2., 3.,
)))
.add(Rollback);
})
// ... This would defer the ID problem back to how Bevy itself handles running out of entity IDs, which seems like a more appropriate location to deal with this issue. |
That sounds exactly like the smart solution this issue asked for! |
Thanks! I've created a pull request with the change as I described above. Please feel free to make any changes you think are appropriate to better align with the rest of the project. |
Is your feature request related to a problem? Please describe.
Currently, when the RollbackIdProvider reaches
u32::MAX
, it simply panics. Since no sensible application should have that many rollbackable entitites at the same time, there should be a smarter way to provide unique (within the rollback frame window) IDs for entities.Additional context
The relevant code is found here.
The text was updated successfully, but these errors were encountered: