used DI for forge managers where possible
This commit is contained in:
@@ -10,11 +10,14 @@ using Gamesmiths.Forge.Tags;
|
||||
using Movementtests.interfaces;
|
||||
using Movementtests.tools;
|
||||
|
||||
[GlobalClass, Icon("res://assets/ui/IconGodotNode/control/icon_text_panel.png"), Meta(typeof(IAutoOn), typeof(IAutoConnect))]
|
||||
[GlobalClass, Icon("res://assets/ui/IconGodotNode/control/icon_text_panel.png"), Meta(typeof(IAutoNode))]
|
||||
public partial class PlayerUi : Control
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
|
||||
[Dependency]
|
||||
public TagsManager TagsManager => this.DependOn<TagsManager>();
|
||||
|
||||
#region Utils
|
||||
|
||||
public enum TargetState
|
||||
@@ -44,12 +47,19 @@ public partial class PlayerUi : Control
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public void Initialize(EntityAttribute health, EntityAttribute mana)
|
||||
private EntityAttribute? _health;
|
||||
private EntityAttribute? _mana;
|
||||
public void Init(EntityAttribute health, EntityAttribute mana)
|
||||
{
|
||||
var tagsManager = ForgeManagers.Instance.TagsManager;
|
||||
Healthbar.Initialize(health, Tag.RequestTag(tagsManager, "cues.resources.health"));
|
||||
Manabar.Initialize(mana, Tag.RequestTag(tagsManager, "cues.resources.mana"));
|
||||
_health = health;
|
||||
_mana = mana;
|
||||
}
|
||||
|
||||
public void OnResolved()
|
||||
{
|
||||
if (_health == null || _mana == null) throw new Exception("Health and mana attributes are not set");
|
||||
Healthbar.Init(_health, Tag.RequestTag(TagsManager, "cues.resources.health"));
|
||||
Manabar.Init(_mana, Tag.RequestTag(TagsManager, "cues.resources.mana"));
|
||||
}
|
||||
|
||||
public void SetEnemyTargetProperties(TargetProperties targetProperties)
|
||||
|
||||
Reference in New Issue
Block a user