protected SubProcess <O> Get <I, O>(ProcessFactoryRef <I, O> factory, I args)
    {
        var sp = new SubProcess <O>();

        factory.Get <I, O>(args, (s, e) => Callback <O>(sp, e), this);
        return(sp);
    }
Exemple #2
0
 public static IProcess GetNested <I, O>(this ProcessFactoryRef <IProcessGetter, O> fact, ProcessFactoryRef <I, O> inner, I input, ProcessExitCallback <O> callback, IProcess parent)
 {
     return(fact.Get <IProcessGetter, O>(
                new ProcessGetter <I, O>(inner, input),
                callback,
                parent));
 }
Exemple #3
0
    public static IProcess Get <I, O>(this ProcessFactoryRef <I, O> fact, I input, ProcessExitCallback <O> callback, IProcess parent)
    {
        if (fact == null)
        {
            Debug.LogError(string.Format("Factory reference has not been intialized. ({0})", fact));
            return(null);
        }

        IProcess <I> process = null;

        if (fact == null)
        {
            Debug.LogWarning(string.Format("Factory instance has not been intialized. Using temporary process. ({0})", fact));
            process = new TempProcess <I, O>();
        }
        else
        {
            process = fact.Factory.GetInstance(input, parent);
        }

        if (fact.Factory is IProcessModifier <I> )
        {
            ((IProcessModifier <I>)fact.Factory).ModifyProcess(process);
        }

        process.Run_Internal(input, callback, parent);
        return(process);
        //if (process is ISettableParent) {
        //    ((ISettableParent)process).SetParent(parent);
        //}

        //ProcessExitCallback castCallback = null;
        //if (parent != null) {
        //    ProcessExitCallback forceChildExit = (s, e) => {
        //        process.OnExit -= castCallback;
        //        process.ForceExit();
        //    };
        //    ProcessExitCallback detachChild = (s, e) => parent.OnExit -= forceChildExit;
        //    process.OnExit += detachChild;
        //    process.OnExit += (s, e) => RemoveAllEvents(process);
        //    parent.OnExit += forceChildExit;
        //}

        //if (callback != null) {
        //    castCallback = (s, e) => callback(s, (O)e);
        //    process.OnExit += castCallback;
        //}

        //if (process is IDebugMethods) {
        //    var methods = ((IDebugMethods)process).GetMethods().ToArray();
        //    DebugMenuListener.AddContextMethods(methods);
        //    process.OnExit += (s, e) => DebugMenuListener.RemoveContextMethods(methods);
        //}

        ////CoroutineManager.Instance.WaitAndDo(() =>
        //process.Initialize(input);
        //return process;
    }
    public void InsertTutorial <T>(string name) where T : IProcess <object, object>, new()
    {
        var r = new ProcessFactoryRef <object, object>();

        r.Set <T>();
        var inserted = new InsertProcessFactory <I, O>(new ProcessGetter <object, object>(r, null), Factory);

        AddSelector(new TutorialProcessSelector <I>(name, inserted));
    }
Exemple #5
0
 public ProcessGetter(ProcessFactoryRef <I, O> factoryRef, I input)
 {
     this.factoryRef = factoryRef;
     this.input      = input;
 }
Exemple #6
0
 public static IProcess GetNullOutput <I, O>(this ProcessFactoryRef <I, O> fact, I input, ProcessExitCallback callback, IProcess parent)
 {
     return(fact.Get <I, O>(input, (s, e) => callback(s, e), parent));
 }
Exemple #7
0
 public static IProcessGetter Getter <I, O>(this ProcessFactoryRef <I, O> fact, I input)
 {
     return(new ProcessGetter <I, O>(fact, input));
 }