-
Notifications
You must be signed in to change notification settings - Fork 49
Coroutine
Peter Shih edited this page Nov 15, 2016
·
8 revisions
- Coroutine
- https://blogs.msdn.microsoft.com/vcblog/2015/11/30/coroutines-in-visual-studio-2015-update-1/
- http://www.crystalclearsoftware.com/soc/coroutine/coroutine/tutorial.html
- Usage
- Acquire additional action during a normal action
- Choose where to put minion
- Choose spell target
- Choose One effect
- Discover effect
- Acquire additional action during a normal action
- Alternatives
- Hand-crafted state machine
- Pass a functor/callback to acquire additional action parameters
- Note
- Coroutine saved state cannot be copied
- So, the game state cannot be copied during a coroutine call
- We can still make it copyable
- Save the last-copyable state 'State A'
- Save all the function calls after 'State A'
- Coroutine saved state cannot be copied
- And make it comparable
- In the resumable functions...
- All local variables influences engine/decisions should be on the state obejct
- In the resumable functions...
- Final decision
- Pass a functor/callback to provide additional action parameters
- Coroutine needs to run on a separated stack, which might slow things down
- It's not really necessary to use the coroutines. We can do all stuffs using callbacks
- Pass a functor/callback to provide additional action parameters