Ejemplo n.º 1
0
    private static IEnumerator Execute(IPersonRoutine personRoutine)
    {
        personRoutine.Start();
        yield return(new WaitUntil(() => personRoutine.IsDone));

        personRoutine.OnFinish?.Invoke();
    }
Ejemplo n.º 2
0
 public PersonRoutineGoToDo(System.Func <bool> startCondition,
                            Person person, IPersonRoutine goThere, IPersonRoutine doWhat, System.Action doOnFinish = null)
 {
     CanStart = startCondition;
     OnFinish = doOnFinish;
     Person   = person;
     GoThere  = goThere;
     DoThat   = doWhat;
 }
Ejemplo n.º 3
0
    public static IEnumerator Execute(Person person, IPersonRoutine routine)
    {
        bool?canDo = routine?.CanStart?.Invoke();

        if (canDo.HasValue && canDo.Value)
        {
            person.PersonState = routine.PersonState;
            yield return(Execute(routine));
        }
        else
        {
            person.PersonState = PersonState.Nothing;
            yield return(waitIfNull);
        }
    }