public ViewModelWindowManufacturer( IStaticWorldObject worldObjectManufacturer, ObjectManufacturerPrivateState privateState, ManufacturingConfig manufacturingConfig) { this.WorldObjectManufacturer = worldObjectManufacturer; var fuelBurningState = privateState.FuelBurningState; var manufacturingState = privateState.ManufacturingState; // please note - the order of creating these view models is important for the proper container exchange order this.ViewModelFuelBurningState = fuelBurningState is not null ? new ViewModelFuelBurningState(fuelBurningState) : null; this.ViewModelManufacturingState = new ViewModelManufacturingState( worldObjectManufacturer, manufacturingState, manufacturingConfig); this.ViewModelBurningFuel = ViewModelBurningFuel.Create(worldObjectManufacturer, fuelBurningState); this.ViewModelManufacturingState.SubscribePropertyChange( _ => _.SelectedRecipe, this.RefreshIsNeedFuel); this.ViewModelManufacturingState.SubscribePropertyChange( _ => _.IsInputMatchSelectedRecipe, this.RefreshIsNeedFuel); this.ViewModelBurningFuel?.SubscribePropertyChange( _ => _.IsActive, this.RefreshIsNeedFuel); this.ViewModelFuelBurningState?.SubscribePropertyChange( _ => _.FuelUsageCurrentValue, this.RefreshIsNeedFuel); this.ViewModelManufacturingState.ContainerInput.StateHashChanged += this.ContainerInputStateChanged; this.RefreshIsNeedFuel(); this.publicState = worldObjectManufacturer.GetPublicState <ObjectManufacturerPublicState>(); this.publicState.ClientSubscribe(_ => _.IsActive, _ => this.NotifyPropertyChanged(nameof(this.IsManufacturingActive)), this); }
public ViewModelWindowManufacturer( IStaticWorldObject worldObjectManufacturer, ManufacturingState manufacturingState, ManufacturingConfig manufacturingConfig, FuelBurningState fuelBurningState) { this.WorldObjectManufacturer = worldObjectManufacturer; // please note - the order of creating these view models is important for the proper container exchange order this.ViewModelFuelBurningState = fuelBurningState != null ? new ViewModelFuelBurningState(fuelBurningState) : null; this.ViewModelManufacturingState = new ViewModelManufacturingState( worldObjectManufacturer, manufacturingState, manufacturingConfig); this.VisibilityFuelControls = this.ViewModelFuelBurningState != null ? Visibility.Visible : Visibility.Collapsed; this.ViewModelBurningFuel = ViewModelBurningFuel.Create(worldObjectManufacturer, fuelBurningState); this.ViewModelManufacturingState.SubscribePropertyChange( _ => _.SelectedRecipe, this.RefreshIsNeedFuel); this.ViewModelManufacturingState.SubscribePropertyChange( _ => _.IsInputMatchSelectedRecipe, this.RefreshIsNeedFuel); this.ViewModelBurningFuel?.SubscribePropertyChange( _ => _.IsActive, this.RefreshIsNeedFuel); this.ViewModelFuelBurningState?.SubscribePropertyChange( _ => _.FuelUsageCurrentValue, this.RefreshIsNeedFuel); this.ViewModelManufacturingState.ContainerInput.StateHashChanged += this.ContainerInputStateChanged; this.RefreshIsNeedFuel(); }
public ViewModelWindowOilRefinery( IStaticWorldObject worldObject, ManufacturingState manufacturingState, ManufacturingState manufacturingStateProcessedGasoline, ManufacturingState manufacturingStateProcessedMineralOil, ManufacturingConfig manufacturingConfig, ManufacturingConfig manufacturingConfigProcessedGasoline, ManufacturingConfig manufacturingConfigProcessedMineralOil, FuelBurningState fuelBurningState, LiquidContainerState liquidStateRawPetroleum, LiquidContainerState liquidStateProcessedGasoline, LiquidContainerState liquidStateProcessedMineralOil, LiquidContainerConfig liquidConfigRawPetroleum, LiquidContainerConfig liquidConfigProcessedGasoline, LiquidContainerConfig liquidConfigProcessedMineralOil) { this.WorldObjectManufacturer = worldObject; // please note - the order of creating these view models is important for the proper container exchange order this.ViewModelFuelBurningState = new ViewModelFuelBurningState(fuelBurningState); this.ViewModelBurningFuel = ViewModelBurningFuel.Create(this.WorldObjectManufacturer, fuelBurningState); this.ViewModelManufacturingStateRawPetroleum = new ViewModelManufacturingState( worldObject, manufacturingState, manufacturingConfig); this.ViewModelManufacturingStateProcessedGasoline = new ViewModelManufacturingState( worldObject, manufacturingStateProcessedGasoline, manufacturingConfigProcessedGasoline); this.ViewModelManufacturingStateProcessedMineralOil = new ViewModelManufacturingState( worldObject, manufacturingStateProcessedMineralOil, manufacturingConfigProcessedMineralOil); this.ViewModelLiquidStateRawPetroleum = new ViewModelLiquidContainerState( liquidStateRawPetroleum, liquidConfigRawPetroleum); this.ViewModelLiquidStateProcessedGasoline = new ViewModelLiquidContainerState( liquidStateProcessedGasoline, liquidConfigProcessedGasoline); this.ViewModelLiquidStateProcessedMineralOil = new ViewModelLiquidContainerState( liquidStateProcessedMineralOil, liquidConfigProcessedMineralOil); // prepare active state property var manufacturerPublicState = worldObject.GetPublicState <ObjectManufacturerPublicState>(); manufacturerPublicState.ClientSubscribe(_ => _.IsManufacturingActive, _ => RefreshIsManufacturerActive(), this); RefreshIsManufacturerActive(); void RefreshIsManufacturerActive() { this.IsManufacturerActive = manufacturerPublicState.IsManufacturingActive; } }
public ViewModelWindowManufacturer( IStaticWorldObject worldObjectManufacturer, ObjectManufacturerPrivateState privateState, ManufacturingConfig manufacturingConfig) { this.WorldObjectManufacturer = worldObjectManufacturer; var fuelBurningState = privateState.FuelBurningState; var manufacturingState = privateState.ManufacturingState; // please note - the order of creating these view models is important for the proper container exchange order this.ViewModelFuelBurningState = fuelBurningState != null ? new ViewModelFuelBurningState(fuelBurningState) : null; this.ViewModelManufacturingState = new ViewModelManufacturingState( worldObjectManufacturer, manufacturingState, manufacturingConfig); this.ViewModelBurningFuel = ViewModelBurningFuel.Create(worldObjectManufacturer, fuelBurningState); this.ViewModelManufacturingState.SubscribePropertyChange( _ => _.SelectedRecipe, this.RefreshIsNeedFuel); this.ViewModelManufacturingState.SubscribePropertyChange( _ => _.IsInputMatchSelectedRecipe, this.RefreshIsNeedFuel); this.ViewModelBurningFuel?.SubscribePropertyChange( _ => _.IsActive, this.RefreshIsNeedFuel); this.ViewModelFuelBurningState?.SubscribePropertyChange( _ => _.FuelUsageCurrentValue, this.RefreshIsNeedFuel); this.ViewModelManufacturingState.ContainerInput.StateHashChanged += this.ContainerInputStateChanged; this.RefreshIsNeedFuel(); this.publicState = worldObjectManufacturer.GetPublicState <ObjectManufacturerPublicState>(); this.publicState.ClientSubscribe(_ => _.IsActive, _ => this.NotifyPropertyChanged(nameof(this.IsManufacturingActive)), this); var insertIfInputEmpty = worldObjectManufacturer.ProtoStaticWorldObject switch { ProtoObjectWell _ => true, ProtoObjectOilPump _ => true, ObjectGeneratorEngine _ => true, _ => false }; viewModelManufacturerExchange = new ViewModelManufacturerExchange( privateState.ManufacturingState.ContainerOutput, new List <IItemsContainer> { privateState.ManufacturingState.ContainerInput }, insertIfInputEmpty); }