Marsbar 228 Posted April 23, 2019 Share Posted April 23, 2019 Mainly targeted @Droidz but if anyone else has input, you're welcome to contribute. The state interface has BeforeStates and NextStates. My question is when do they run and does their "Need To Run" condition get checked? If you add the state into the list of before or after states are they in the main engine list of states or are they only considered if the state you added the before/afterstates to, is triggered? Link to comment https://wrobot.eu/forums/topic/11103-how-do-the-beforestates-and-nextstates-work/ Share on other sites More sharing options...
Droidz 2738 Posted April 23, 2019 Share Posted April 23, 2019 Hello, like that (in simplified): bool RunState(State currentState) { if (currentState.NeedToRun) { foreach (var beforeState in currentState.BeforeStates) { RunState(beforeState); } currentState.Run(); foreach (var nextState in state.NextStates) { RunState(nextState); } return true; } return false; } Matenia and Marsbar 1 1 Link to comment https://wrobot.eu/forums/topic/11103-how-do-the-beforestates-and-nextstates-work/#findComment-52981 Share on other sites More sharing options...
Marsbar 228 Posted April 23, 2019 Author Share Posted April 23, 2019 Ah okay, thanks. One more thing though does the RunState(beforeState); check the beforeStates NeedToRun or does it just run it anyway? Link to comment https://wrobot.eu/forums/topic/11103-how-do-the-beforestates-and-nextstates-work/#findComment-52983 Share on other sites More sharing options...
Droidz 2738 Posted April 23, 2019 Share Posted April 23, 2019 Method check if needtorun return true (it is the method than I shared code) Marsbar 1 Link to comment https://wrobot.eu/forums/topic/11103-how-do-the-beforestates-and-nextstates-work/#findComment-52985 Share on other sites More sharing options...
Marsbar 228 Posted April 23, 2019 Author Share Posted April 23, 2019 7 minutes ago, Droidz said: Method check if needtorun return true (it is the method than I shared code) Oh yeah sorry lol. Thanks Link to comment https://wrobot.eu/forums/topic/11103-how-do-the-beforestates-and-nextstates-work/#findComment-52986 Share on other sites More sharing options...
Avvi 98 Posted April 23, 2019 Share Posted April 23, 2019 I sort of talked about this in my post: Link to comment https://wrobot.eu/forums/topic/11103-how-do-the-beforestates-and-nextstates-work/#findComment-52995 Share on other sites More sharing options...
Marsbar 228 Posted April 24, 2019 Author Share Posted April 24, 2019 9 hours ago, Avvi said: I sort of talked about this in my post: Yeah I saw that, very useful. I was more wondering about the actual states interface implementation of Before/NextStates rather than the events though. Link to comment https://wrobot.eu/forums/topic/11103-how-do-the-beforestates-and-nextstates-work/#findComment-53005 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now