protected override void OnEnableAction()
        {
            var electricityConsumer = SelectedHardpointEquipment.GetComponent <ElectricityConsumer>();

            electricityConsumer.ConsumingPowerChanged += OnConsumingPowerChanged;
            UpdateText(electricityConsumer.ConsumingPower);
        }
        private void OnProducingPowerChanged(ElectricityProducer sender, PowerValueChangedEventArgs args)
        {
            Int64 value = SelectedHardpointEquipment.GetComponent <ElectricityProducer>().ProducingPower;

            if ((Int64)_slider.value != value)
            {
                _slider.value = value;
            }
        }
        protected override void OnDisableAction()
        {
            var electricityProducer = SelectedHardpointEquipment.GetComponent <ElectricityProducer>();

            electricityProducer.ProducingPowerChanged -= OnProducingPowerChanged;
            SelectedHardpointEquipment.EnabledChanged -= OnEquipmentEnabledChanged;

            _slider.onValueChanged.RemoveAllListeners();
        }
        private void OnSliderValueChanged(Single value)
        {
            if (!SelectedHardpointEquipment.Enabled)
            {
                return;
            }
            //Changing TargetEnabled to false leads slider to move at minimal position.
            //Without this check it will override TargetProducingPower to MinPower. We don't need that.

            var electricityProducer = SelectedHardpointEquipment.GetComponent <ElectricityProducer>();

            electricityProducer.TargetProducingPower = (Int64)value;
        }
        protected override void OnEnableAction()
        {
            _slider = GetComponent <Slider>();

            var electricityProducer = SelectedHardpointEquipment.GetComponent <ElectricityProducer>();

            electricityProducer.ProducingPowerChanged += OnProducingPowerChanged;
            SelectedHardpointEquipment.EnabledChanged += OnEquipmentEnabledChanged;

            _slider.minValue = electricityProducer.MinPower;
            _slider.maxValue = electricityProducer.MaxPower;

            _slider.onValueChanged.AddListener(OnSliderValueChanged);

            OnProducingPowerChanged(null, null);
            OnEquipmentEnabledChanged(SelectedHardpointEquipment, SelectedHardpointEquipment.Enabled);
        }
 protected override void OnDisableAction()
 {
     SelectedHardpointEquipment.GetComponent <ElectricityConsumer>().ConsumingPowerChanged -= OnConsumingPowerChanged;
 }
Пример #7
0
 protected override void OnDisableAction()
 {
     SelectedHardpointEquipment.GetComponent <ElectricityProducer>().ProducingPowerChanged -= OnProducingPowerChanged;
 }
Пример #8
0
 protected override void OnEnableAction()
 {
     SelectedHardpointEquipment.GetComponent <ElectricityProducer>().ProducingPowerChanged += OnProducingPowerChanged;
     UpdateValue(SelectedHardpointEquipment.GetComponent <ElectricityProducer>().ProducingPower);
 }