public MoveUnitSectionCommand(MoveUnitSectionCommandData data,
                               ICommandFactory commandFactory,
                               IUnitRegistry unitRegistry,
                               IMapSectionEntryTileFinder entryTileFinder,
                               IUnitDataIndexResolver unitDataIndexResolver,
                               ILogger logger,
                               MapStoreId mapStoreId)
 {
     _data                  = data;
     _commandFactory        = commandFactory;
     _unitRegistry          = unitRegistry;
     _entryTileFinder       = entryTileFinder;
     _unitDataIndexResolver = unitDataIndexResolver;
     _logger                = logger;
     _mapStoreId            = mapStoreId;
 }
        public IObservable <Unit> Run()
        {
            _modalViewController.Show("Loading Assets...");
            // TODO: Commands to use unitask. this should just be all async / await
            MapStoreId mapStoreId = new MapStoreId(_data.mapIndex);
            IObservable <IMutableMapData> mapDataObservable = _mapStore.LoadMap(mapStoreId).ToObservable();

            mapDataObservable.Subscribe(mapData => {
                _sceneLoader.LoadSceneAsync(_data.SceneName,
                                            LoadSceneMode.Additive,
                                            container => {
                    HandleMapSceneLoaded(container, mapData, mapStoreId);
                });
            });

            return(_sceneLoadedSubject);
        }
Esempio n. 3
0
 public void Construct(MapStoreId mapStoreId,
                       [Inject(Id = MapEditorInstaller.SECTION_TILE_EDITOR_ID)]
                       IMapEditorTool sectionTileEditor,
                       [Inject(Id = MapEditorInstaller.UNIT_TILE_EDITOR_ID)]
                       IMapEditorTool unitTileEditor,
                       [Inject(Id = MapEditorInstaller.PLAYER_UNITS_TILE_EDITOR_ID)]
                       IMapEditorTool playerUnitsTileEditor,
                       IMapDataStore mapDataStore,
                       IInputLock inputLock,
                       IInputEvents inputEvents,
                       ILogger logger)
 {
     _mapStoreId            = mapStoreId;
     _sectionTileEditor     = sectionTileEditor;
     _playerUnitsTileEditor = playerUnitsTileEditor;
     _unitTileEditor        = unitTileEditor;
     _mapDataStore          = mapDataStore;
     _inputLock             = inputLock;
     _inputEvents           = inputEvents;
     _logger = logger;
 }
        private void HandleMapSceneLoaded(DiContainer container, IMutableMapData mapData, MapStoreId mapStoreId)
        {
            // MapSection command may inject mutable map data if on editor mode.
            container.Bind <IMapData>().FromInstance(mapData);
            container.Bind <MapStoreId>().FromInstance(mapStoreId);
            container.Bind <IMutableMapData>().FromInstance(mapData).WhenInjectedInto <LoadMapSectionCommand>();
            container.Bind <LoadMapCommandData>().FromInstance(_data);

            // This needs to happen after 1 frame because we are currently still loading the next scene.
            // Otherwise, the dependency graph cannot be yet built.
            Observable.NextFrame().Subscribe(onNext => {
                // This needs to be created directly since the section command is dependant on this command.
                LoadMapSectionCommandData loadMapSectionCommandData = new LoadMapSectionCommandData(0, _data);
                ICommand loadMapSectionCommand = _commandFactory.Create(typeof(LoadMapSectionCommand),
                                                                        typeof(LoadMapSectionCommandData),
                                                                        loadMapSectionCommandData);
                loadMapSectionCommand.Run().Subscribe(next => {
                    _modalViewController.Hide();
                    _sceneLoadedSubject.OnNext(Unit.Default);
                });
            });
        }