public ViewModelFuelBurningState( FuelBurningState fuelBurningState) { this.FuelBurningState = fuelBurningState; this.ContainerFuel = (IClientItemsContainer)fuelBurningState?.ContainerFuel; this.FuelBurningState.ClientSubscribe( _ => _.FuelUseTimeRemainsSeconds, secondsToBurn => this.RefreshFuelUsage(), this); this.FuelBurningState.ClientSubscribe( _ => _.CurrentFuelItemType, newFuelItemType => this.RefreshFuelUsage(), this); this.RefreshFuelUsage(); var character = ClientCurrentCharacterHelper.Character; ClientContainersExchangeManager.Register(this, this.ContainerFuel, allowedTargets: new[] { character.SharedGetPlayerContainerInventory(), character.SharedGetPlayerContainerHotbar() }); }
public static ViewModelBurningFuel Create( IStaticWorldObject worldObjectManufacturer, FuelBurningState fuelBurningState) { if (fuelBurningState is not null && fuelBurningState.ContainerFuel?.ProtoItemsContainer is IFuelItemsContainer fuelItemsContainer) { return(new ViewModelBurningFuel(worldObjectManufacturer, fuelItemsContainer)); } return(null); }
public ViewModelWindowLithiumOreExtractor( IStaticWorldObject worldObjectManufacturer, IStaticWorldObject worldObjectDeposit, ManufacturingState manufacturingState, ManufacturingConfig manufacturingConfig, FuelBurningState fuelBurningState, LiquidContainerState liquidContainerState, LiquidContainerConfig liquidContainerConfig) : base(worldObjectManufacturer, manufacturingState, manufacturingConfig, fuelBurningState) { this.ViewModelLiquidContainerState = new ViewModelLiquidContainerState(liquidContainerState, liquidContainerConfig); this.ViewModelDepositCapacityStatsControl = new ViewModelDepositCapacityStatsControl(worldObjectDeposit); }
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(); }
protected override void ServerInitialize(ServerInitializeData data) { base.ServerInitialize(data); var worldObject = data.GameObject; var privateState = data.PrivateState; // configure manufacturing state var manufacturingState = privateState.ManufacturingState; { var inputSlotsCount = this.ServerGetInputSlotsCount(worldObject); var outputSlotsCount = this.ServerGetOutputSlotsCount(worldObject); if (manufacturingState is null) { manufacturingState = new ManufacturingState( worldObject, containerInputSlotsCount: inputSlotsCount, containerOutputSlotsCount: outputSlotsCount); privateState.ManufacturingState = manufacturingState; } else { manufacturingState.SetSlotsCount( input: inputSlotsCount, output: outputSlotsCount); } Server.Items.SetContainerType <ItemsContainerOutput>( manufacturingState.ContainerOutput); } // configure fuel burning state var fuelBurningState = privateState.FuelBurningState; { if (fuelBurningState is null) { if (this.ContainerFuelSlotsCount > 0) { fuelBurningState = new FuelBurningState(worldObject, this.ContainerFuelSlotsCount); privateState.FuelBurningState = fuelBurningState; } } else if (this.ContainerFuelSlotsCount > 0) { fuelBurningState.SetSlotsCount(this.ContainerFuelSlotsCount); } else { // destroy fuel burning state privateState.FuelBurningState = fuelBurningState = null; } if (fuelBurningState is not null) { Server.Items.SetContainerType <ItemsContainerFuelSolid>( fuelBurningState.ContainerFuel); } } if (this.ManufacturingConfig.IsProduceByproducts) { if (fuelBurningState is null) { throw new Exception( $"No fuel container - please set {nameof(this.ContainerFuelSlotsCount)} higher than zero?"); } privateState.FuelBurningByproductsQueue ??= new CraftingQueue( fuelBurningState.ContainerFuel, manufacturingState.ContainerOutput); } else { privateState.FuelBurningByproductsQueue = null; } }
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; } }