BP_StatBar is a template widget that is showing extended stats as progress bars.
It has variable of type E_StatType which is used on widget construct to find ExtendedStatComponent in owning pawn and initialize widget.
Event Initialize binds new event to OnValueChanged dispatcher, it means that whenever value of this stat changes, this event will be called.
Whenever value of stat changes, this function simply updates percent of progress bar and it’s width (depends on max value of stat).
For player it’s simple to setup stat bar widgets, because he uses it in widget blueprint (WB_InGame), so all we have to do here is set AdvnacedStatType value to Health / Stamina and set FillColor.
For AI which is using widget component we need to initialize them manually (because for widget components Event Construct is not being called).