internal void UpdateVisuals(PowercellData data) { var charge = data.GetCharge() < 1 ? 0f : data.GetCapacity(); float percent = charge / data.GetCapacity(); QuickLogger.Debug($"Percent: {percent}"); if (_batteryPercent != null) { _batteryPercent.text = ((data.GetCharge() < 0f) ? Language.main.Get("ChargerSlotEmpty") : $"{Mathf.CeilToInt(percent * 100)}%"); } if (_batteryFill != null) { if (data.GetCharge() >= 0f) { Color value = (percent >= 0.5f) ? Color.Lerp(this.colorHalf, this.colorFull, 2f * percent - 1f) : Color.Lerp(this.colorEmpty, this.colorHalf, 2f * percent); _batteryFill.color = value; _batteryFill.fillAmount = percent; } else { _batteryFill.color = colorEmpty; _batteryFill.fillAmount = 0f; } } }
public float GetDevicePowerCharge() { return(_powercellData.GetCharge()); }