2021-04-08 20:09:59 +08:00
|
|
|
|
namespace ET
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 监视hp数值变化,改变血条值
|
|
|
|
|
/// </summary>
|
|
|
|
|
[NumericWatcher(NumericType.MaxHp)]
|
|
|
|
|
public class NumericWatcher_MaxHp : INumericWatcher
|
|
|
|
|
{
|
|
|
|
|
public async ETTask Run(Entity unit, float old, float value)
|
|
|
|
|
{
|
2021-04-18 15:54:51 +08:00
|
|
|
|
if (!unit) return;
|
2021-04-11 19:50:39 +08:00
|
|
|
|
NumericComponent num = unit.GetComponent<NumericComponent>();
|
2021-04-08 20:09:59 +08:00
|
|
|
|
|
|
|
|
|
if (value <= 0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (value < num.GetAsInt(NumericType.Hp))
|
|
|
|
|
{
|
|
|
|
|
num.Set(NumericType.Hp, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DelaySendSyncAttributeComponent.instance.Add(unit .As<Unit>(), NumericType.MaxHp, value);
|
|
|
|
|
await ETTask.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|