CTT/Server/Hotfix/Module/Numeric/NumericWatcher_MaxHp.cs

28 lines
742 B
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

namespace ET
{
/// <summary>
/// 监视hp数值变化改变血条值
/// </summary>
[NumericWatcher(NumericType.MaxHp)]
public class NumericWatcher_MaxHp : INumericWatcher
{
public async ETTask Run(Entity unit, float old, float value)
{
if (!unit) return;
NumericComponent num = unit.GetComponent<NumericComponent>();
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;
}
}
}