public ViewModelPowerStateOverlay(IObjectElectricityConsumerPublicState consumerPublicState) { this.consumerPublicState = consumerPublicState; this.consumerPublicState.ClientSubscribe(_ => _.ElectricityConsumerState, _ => this.Refresh(), this); this.Refresh(); this.Update(); ClientUpdateHelper.UpdateCallback += this.Update; }
public ViewModelWindowFridge( IStaticWorldObject worldObjectFridge, ObjectCratePrivateState privateState, Action callbackCloseWindow) { this.WorldObjectFridge = worldObjectFridge; this.ViewModelItemsContainerExchange = new ViewModelItemsContainerExchange( privateState.ItemsContainer, callbackTakeAllItemsSuccess: callbackCloseWindow); if (this.WorldObjectFridge.ProtoStaticWorldObject is IProtoObjectElectricityConsumer) { this.publicStatePowerConsumer = this.WorldObjectFridge .GetPublicState <IObjectElectricityConsumerPublicState>(); this.publicStatePowerConsumer?.ClientSubscribe( _ => _.ElectricityConsumerState, _ => this.NotifyPropertyChanged(nameof(this.IsActive)), this); } }