-
Notifications
You must be signed in to change notification settings - Fork 19
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
feat: Add Session commands to modify sessions from game code #379
Conversation
What if we just added the queue as a field to |
This was my first attempt: I think I found that the current session did not have the values in queue - but reviewing code again I am thinking that the game session is not inside its session lists when currently running (I might've done if let Some(game_session)... game_session.add_session_command) and not added it (if it was indeed None from within system in game session). Or the issue is that the session I added it to was not accessed correctly in the context of how we swap sessions in/out of resource + remove and reinsert current session. Some sort of bug like that - but maybe can make that work. I do like that this removes burden of SessionCommands shared resource init. Will take another look and follow up on if there is a blocker here or if I just got it wrong. |
@zicklag The issue with putting command queue on Session is that the current running session is not in the Sessions resource. Game session cannot insert session command into its own session, only other sessions. So probably makes sense to have session commands exist outside of sessions themselves. |
But the current running session doesn't need to be in the sessions resource when the command is inserted, because the command is only run after the current session is put back into the sessions resource. |
I'm not understanding how this is to be used though: // sessions = ResMut<Sessions>
if let Some(game_session) = sessions.get_mut(SessionNames::Game) {
game_sessions.session_commands.push_back(<command>);
} This does nothing because game session is not found in sessions, due to it being removed during execution. |
Oh, I'm saying that we put the queue in // sessions = ResMut<Sessions>
sessions.commands.push_back(<command>); |
@zicklag updated so commands are on |
Add SessionCommands which may be inserted as shared resource. Runs after session execution, before the "after_session" GameSystems.
One thing I don't like about this is it only works as shared resource, if user does not insert shared resource, and tries to do ResMutInit, they run into trouble. Not sure what the best way to avoid that is.