示例#1
0
        public static Result <GameStateHolderModule> Create()
        {
            var module = new GameStateHolderModule();

            return(ModulesRegister.Get <IUnityNetworkClientProvider>()
                   .Specify($"Cannot get {nameof(IUnityNetworkClientProvider)}")
                   .Then(module, (networkClient, _this) => _this._networkClient = networkClient)
                   .Then(_ => module));
        }
示例#2
0
        private void InitModuleReferences()
        {
            _blockItemsPoolModule = ModulesRegister.Get <IBlockItemsPoolModule>()
                                    .ThrowIfError(() => $"Cannot initialize module references at {nameof(GameLevelInitializer)}")
                                    .Value;

            _gameStateModule = ModulesRegister.Get <IGameStateModule>()
                               .ThrowIfError(() => $"Cannot initialize module references at {nameof(GameLevelInitializer)}")
                               .Value;
        }
示例#3
0
        public Result <IUnityNetworkMiddlewareSchema> BuildUnityNetworkClientPipeline(
            NetworkClientMiddlewareManifests manifest)
        {
            var coroutineRunner = ModulesRegister.Get <ICoroutineRunner>();

            if (coroutineRunner.IsError)
            {
                return(Result <IUnityNetworkMiddlewareSchema> .FromError(
                           $"Unable to get {nameof(coroutineRunner)} at {nameof(UnityNetworkClientPipelineBuilder<T>)}"));
            }

            var compositionManifest = manifest.RequestComposition;

            var requestProcessor = UnityWebRequestProcessorMiddleware <T> .Create(Option <T> .None,
                                                                                  coroutineRunner.Value, manifest.RequestProcessor);

            var statusCodeValidator = StatusCodeValidationMiddleware <T> .Create(
                ((T)(IUnityNetworkMiddlewareSchema)requestProcessor).ToSome());

            var compositionMiddleware = UnityRequestCompositionMiddleware <T> .Create(
                ((T)(IUnityNetworkMiddlewareSchema)statusCodeValidator).ToSome(), compositionManifest);

            return(((IUnityNetworkMiddlewareSchema)compositionMiddleware).ToValue());
        }
示例#4
0
 protected override Task <Result <Unit> > SetInitialAsync()
 => ModulesRegister.Get <IGameStateModule>()
 .Then(this, (gameStateModule, _this) => _this._gameStateModule = gameStateModule)
 .ToUnit()
 .ToTask();