Example #1
0
    protected virtual void Start()
    {
        //Resolve disposableManager
        dManager = Container.Resolve <DisposableManager>();
        //Let the program know, that Kernel has finished loading


        // first start rxStartup-queue
        // if this is finished, start initial gamestate
        rxStartup
        .RxExecute()
        .SelectMany(_ => {
            string initialGameStateName = GetInitialGamestateName();
            Service.GameStateService.GSContext initialGameStateCtx = GetInitialGamestateContext();
            if (initialGameStateName == null)
            {
                Debug.LogWarning("No inital gamestate specified!");
                return(Observable.Return(true));
            }
            else
            {
                Service.GameStateService.IGameStateService gameStateService = Container.Resolve <Service.GameStateService.IGameStateService>();
                Service.GameStateService.GameState initialGameState         = gameStateService.GetGameState(initialGameStateName);
                if (initialGameState == null)
                {
                    Debug.LogWarning("Could not find initial gamestate with name:" + initialGameStateName);
                    return(Observable.Return(true));
                }
                return(gameStateService.StartGameState(initialGameState, initialGameStateCtx).Do(__ => { Debug.Log("Started initial gamestate:" + initialGameStateName); }));
            }
        })
        .Last()
        .Take(1)
        .Subscribe(_ => {
            KernelReady = true;
            Debug.LogWarning("Startup done!");
            OnKernelReady();
        });
    }