Guest User

Untitled

a guest
Apr 22nd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. Option 1:
  2.  
  3. Receive event information through a delegate
  4.  
  5. List<Hero> pickedHeroes;
  6. while(pickedHeroes.Count < NumberOfHeroesNeeded) {
  7. yield return WaitFor.Event("set-hero",
  8. (player, h) => {
  9. pickedHeroes.Add(h);
  10. }
  11. );
  12. |}
  13.  
  14. Pro: Doesn't have seemingly "unclean" object-level state; everything stays local to the method.
  15. Con: Having to create a handler method, even if it's anonymous, partially defeats the
  16. purpose of a co-routine.
  17.  
  18.  
  19. Option 2:
  20.  
  21. Receive event information through object state
  22.  
  23. List<Hero> pickedHeroes;
  24. while(pickedHeroes.Count < NumberOfHeroesNeeded) {
  25. yield return WaitFor.Event("set-hero");
  26. pickedHeroes.Add(this.CurrentEvent.Get<Hero>(0));
  27. }
  28.  
  29. Pro: No handler method, anonymous or otherwise;
  30. Con: This SEEMS to cause problems with concurrency and/or re-entrancy. In reality, it does
  31. not; as no game logic is re-entrant or runs concurrently. So, the downside is the perception
  32. of "unclean" state. Also, this doesn't do the work of deserializing to method parameters
  33. behind the scenes, so it is not consistent with normal [Handles] marked methods.
  34.  
  35. Option 3:
  36.  
  37. Can you think of anything else?
Add Comment
Please, Sign In to add comment