using System; namespace ProjectI.Combat { // A recipient grants at most the strongest family amount per authored trigger window. public sealed class ShieldFamilyBudget { private double until; private float maximum; public float Request(float amount,double now,double interval) { if(float.IsNaN(amount)||float.IsInfinity(amount)||amount<=0||double.IsNaN(now)||double.IsInfinity(now)||now<0||double.IsNaN(interval)||double.IsInfinity(interval)||interval<=0||double.IsInfinity(now+interval))return 0; if(now>=until){maximum=0;until=now+interval;} float difference=Math.Max(0,amount-maximum);maximum=Math.Max(maximum,amount);return difference; } public void Clear(){until=0;maximum=0;} } }