1
This commit is contained in:
@@ -4,7 +4,9 @@
|
||||
"references": [
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:4307f53044263cf4b835bd812fc161a4",
|
||||
"GUID:49b49c76ee64f6b41bf28ef951cb0e50"
|
||||
"GUID:49b49c76ee64f6b41bf28ef951cb0e50",
|
||||
"GUID:709caf8d7fb6ef24bbba0ab9962a3ad0",
|
||||
"GUID:7efac18f239530141802fb139776f333"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
@@ -0,0 +1,46 @@
|
||||
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<Entity[]> initialEntities;
|
||||
private void Update()
|
||||
{
|
||||
// foreach (var x in initialEntities.IfNotAllow(()=>_entitiesService.Query<IHealth>().Cast<Entity>().ToArray()))
|
||||
// {
|
||||
//
|
||||
// }
|
||||
targetGroup.m_Targets =
|
||||
initialEntities.IfNotAllow(() => _entitiesService.Query<IHealth>().Cast<Entity>().ToArray())
|
||||
.Select(x => new CinemachineTargetGroup.Target()
|
||||
{
|
||||
target = x.transform,
|
||||
radius = 1,
|
||||
weight = x.TryGetComponent<IHealth>(out var heal) ? heal.IsAlive ? 1 : 0 : 0
|
||||
})
|
||||
.ToArray();
|
||||
if (targetGroup.m_Targets.Length is 0)
|
||||
{
|
||||
targetGroup.m_Targets = initialEntities.IfNotAllow(() => _entitiesService.Query<IHealth>().Cast<Entity>().ToArray()).Select(
|
||||
x=>
|
||||
new CinemachineTargetGroup.Target()
|
||||
{
|
||||
target = x.transform,
|
||||
radius = 1,
|
||||
weight = 1
|
||||
}
|
||||
).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b26ced1633dbe440872ebd032cbc997
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user