using System; using System.Collections; using System.Collections.Generic; using System.Linq; using BITKit.Entities; using Cinemachine; using UnityEngine; namespace BITKit.Scene { public class CinemachineEntitiesGroup : MonoBehaviour { [SerializeField] private IEntitiesService _entitiesService; [SerializeField] private CinemachineTargetGroup targetGroup; [SerializeField] private Optional initialEntities; private void Update() { // foreach (var x in initialEntities.IfNotAllow(()=>_entitiesService.Query().Cast().ToArray())) // { // // } targetGroup.m_Targets = initialEntities.IfNotAllow(() => _entitiesService.Query().Cast().ToArray()) .Select(x => new CinemachineTargetGroup.Target() { target = x.transform, radius = 1, weight = x.TryGetComponent(out var heal) ? heal.IsAlive ? 1 : 0 : 0 }) .ToArray(); if (targetGroup.m_Targets.Length is 0) { targetGroup.m_Targets = initialEntities.IfNotAllow(() => _entitiesService.Query().Cast().ToArray()).Select( x=> new CinemachineTargetGroup.Target() { target = x.transform, radius = 1, weight = 1 } ).ToArray(); } } } }