using System; using System.Collections.Generic; using Code.Infrastructure.Camera; using Code.Infrastructure.UI; using Code.OfficeGame.BattleMode.Actions; using Code.OfficeGame.BattleMode.Health.UI; using Cysharp.Threading.Tasks; using Reflex.Attributes; namespace Code.OfficeGame.BattleMode.Health { public class HealthPanelsHolder : IDisposable { public List PanelList; [Inject] private void Construct(CameraStateMachine cameraStateMachine) { foreach (var panel in PanelList) panel.Construct(cameraStateMachine); } /// /// Список опрокинуть в контейнер /// /// /// /// public async UniTask SpawnHealthBars( IUIFactory factory, List entities) { PanelList = new List(); foreach (var entity in entities) { var healthBarTarget = entity.GetComponentInChildren(); if(!healthBarTarget) continue; var panel = (EntityHealthPanel) await factory.LoadPanel(UIPanelType.EntityHealthBar, false); panel.SetTarget(healthBarTarget.transform); panel.SubscribeHealthPanel(entity.EntityHealth); PanelList.Add(panel); } } public void Dispose() { foreach (var panel in PanelList) panel.Dispose(); } } }