@ -10,7 +10,10 @@ namespace UI.Level.StateBar;
|
||||
public class UBusyWidgetStateBar : UPW_MinimalWidget
|
||||
{
|
||||
protected UBusyWidgetHealthBar? WBP_HealthBar { get { return GetWidget("WBP_HealthBar") as UBusyWidgetHealthBar; } }
|
||||
protected UBusyWidgetSatietyBar? WBP_SatietyBar { get { return GetWidget("WBP_SatietyBar") as UBusyWidgetSatietyBar; } }
|
||||
// protected UBusyWidgetSatietyBar? WBP_SatietyBar { get { return GetWidget("WBP_SatietyBar") as UBusyWidgetSatietyBar; } }
|
||||
|
||||
protected List<UBusyWidgetSatietyBar> SatietyBars = new();
|
||||
protected List<UBusyWidgetHealthBar> HealthBars = new();
|
||||
|
||||
protected UBusyRoleStateController? UIController;
|
||||
|
||||
@ -18,13 +21,26 @@ public class UBusyWidgetStateBar : UPW_MinimalWidget
|
||||
public override void Construct()
|
||||
{
|
||||
base.Construct();
|
||||
WBP_SatietyBar.SetSatietyConfig(100, 200);
|
||||
|
||||
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
if (GetWidget($"WBP_SatietyBar_{i}") is UBusyWidgetSatietyBar Bar)
|
||||
{
|
||||
SatietyBars.Add(Bar);
|
||||
}
|
||||
if (GetWidget("WBP_HealthBar") is UBusyWidgetHealthBar HpBar)
|
||||
{
|
||||
HealthBars.Add(HpBar);
|
||||
}
|
||||
}
|
||||
|
||||
UIController = UUIFunctionLibrary.GetUIController(this, "RoleState") as UBusyRoleStateController;
|
||||
|
||||
InitRoleAttribute();
|
||||
UIController.OnAttributeChangeDelegate += OnAttributeChanged;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void InitRoleAttribute()
|
||||
@ -34,7 +50,12 @@ public class UBusyWidgetStateBar : UPW_MinimalWidget
|
||||
float CurSatiety = UIController.GetControlledAttribute("Hunger");
|
||||
float MaxSatiety = UIController.GetControlledAttribute("MaxHunger");
|
||||
WBP_HealthBar.SetHpConfig(CurHealth, MaxHealth);
|
||||
WBP_SatietyBar.SetSatietyConfig(CurSatiety, MaxSatiety);
|
||||
|
||||
foreach (UBusyWidgetSatietyBar Bar in SatietyBars)
|
||||
{
|
||||
Bar.SetSatietyConfig(CurSatiety, MaxSatiety);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void Destruct()
|
||||
@ -43,13 +64,22 @@ public class UBusyWidgetStateBar : UPW_MinimalWidget
|
||||
UIController.OnAttributeChangeDelegate -= OnAttributeChanged;
|
||||
}
|
||||
|
||||
public void SetSatiety(float Satiety)
|
||||
{
|
||||
foreach(UBusyWidgetSatietyBar Bar in SatietyBars)
|
||||
{
|
||||
Bar.OnSatietyChanged(Satiety);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
[UFunction()]
|
||||
protected void OnAttributeChanged(FName AttributeName, float NewValue, float OldValue)
|
||||
{
|
||||
if (AttributeName == "Hunger")
|
||||
{
|
||||
WBP_SatietyBar.OnSatietyChanged(NewValue);
|
||||
SetSatiety(NewValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user