32 lines
675 B
C#
32 lines
675 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using BITKit;
|
|
using BITKit.Entities;
|
|
using UnityEngine;
|
|
|
|
namespace BITFALL.Feel
|
|
{
|
|
public sealed class EntityHealthBlender : EntityBehavior
|
|
{
|
|
[SerializeField] private Renderer[] _renderers;
|
|
[Inject] private IHealth _health;
|
|
private static readonly int Blend = Shader.PropertyToID("_Blend");
|
|
|
|
public override void OnAwake()
|
|
{
|
|
base.OnAwake();
|
|
_health.OnSetHealthPoint += OnSetHealthPoint;
|
|
}
|
|
|
|
private void OnSetHealthPoint(int obj)
|
|
{
|
|
var blend =1- Mathf.Clamp01(obj / (float)_health.MaxHealthPoint);
|
|
foreach (var x in _renderers)
|
|
{
|
|
x.material.SetFloat(Blend, blend);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|