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