Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option 1:
- Receive event information through a delegate
- List<Hero> pickedHeroes;
- while(pickedHeroes.Count < NumberOfHeroesNeeded) {
- yield return WaitFor.Event("set-hero",
- (player, h) => {
- pickedHeroes.Add(h);
- }
- );
- |}
- Pro: Doesn't have seemingly "unclean" object-level state; everything stays local to the method.
- Con: Having to create a handler method, even if it's anonymous, partially defeats the
- purpose of a co-routine.
- Option 2:
- Receive event information through object state
- List<Hero> pickedHeroes;
- while(pickedHeroes.Count < NumberOfHeroesNeeded) {
- yield return WaitFor.Event("set-hero");
- pickedHeroes.Add(this.CurrentEvent.Get<Hero>(0));
- }
- Pro: No handler method, anonymous or otherwise;
- Con: This SEEMS to cause problems with concurrency and/or re-entrancy. In reality, it does
- not; as no game logic is re-entrant or runs concurrently. So, the downside is the perception
- of "unclean" state. Also, this doesn't do the work of deserializing to method parameters
- behind the scenes, so it is not consistent with normal [Handles] marked methods.
- Option 3:
- Can you think of anything else?
Add Comment
Please, Sign In to add comment