Health System

This commit is contained in:
ThomasCharester committed 2026-11-17 18:44:54 +03:00
1 parent 329cc98ade
commit cb05da5e89
87 files changed
+568550 -155362

No files matched your search

@@ -0,0 +1,56 @@
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<EntityHealthPanel> PanelList;
[Inject]
private void Construct(CameraStateMachine cameraStateMachine)
{
foreach (var panel in PanelList) panel.Construct(cameraStateMachine);
}
/// <summary>
/// Список опрокинуть в контейнер
/// </summary>
/// <param name="factory"></param>
/// <param name="entities"></param>
/// <returns></returns>
public async UniTask SpawnHealthBars(
IUIFactory factory,
List<EntityProperties> entities)
{
PanelList = new List<EntityHealthPanel>();
foreach (var entity in entities)
{
var healthBarTarget = entity.GetComponentInChildren<HealthBarTarget>();
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();
}
}
}