//private static string _lastBuffCast = string.Empty; //private static System.Diagnostics.Stopwatch _castTimer = new System.Diagnostics.Stopwatch(); /// <summary> /// Creates a behavior to cast a buff by name, with special requirements, on a specific unit. Returns /// RunStatus.Success if successful, RunStatus.Failure otherwise. /// </summary> /// <remarks> /// Created 5/2/2011. /// </remarks> /// <param name = "name">The name of the buff</param> /// <param name = "myBuff">Check for self debuffs or not</param> /// <param name = "onUnit">The on unit</param> /// <param name = "requirements">The requirements.</param> /// <returns></returns> public static Composite Buff(string name, bool myBuff, UnitSelectionDelegate onUnit, SimpleBooleanDelegate requirements, params string[] buffNames) { //if (name == _lastBuffCast && _castTimer.IsRunning && _castTimer.ElapsedMilliseconds < 250) //{ // return new Action(ret => RunStatus.Success); //} //if (name == _lastBuffCast && StyxWoW.Me.IsCasting) //{ // _castTimer.Reset(); // _castTimer.Start(); // return new Action(ret => RunStatus.Success); //} return (new Decorator( ret => onUnit(ret) != null && !DoubleCastPreventionDict.ContainsKey(name) && buffNames.All(b => myBuff ? !onUnit(ret).HasMyAura(b) : !onUnit(ret).HasAura(b)), new Sequence( // new Action(ctx => _lastBuffCast = name), Cast(name, onUnit, requirements), new DecoratorContinue( ret => SpellManager.Spells[name].CastTime > 0, new Sequence( new WaitContinue( 1, ret => StyxWoW.Me.IsCasting, new Action(ret => UpdateDoubleCastDict(name)))) )) )); }
public static void UpdateDoubleCastDict(string spellName, GameObject unit) { if (unit == null) { return; } SpellData spellData; ActionManager.CurrentActions.TryGetValue(spellName, out spellData); if (spellData == null) { return; } DateTime expir = DateTime.UtcNow + spellData.AdjustedCastTime + TimeSpan.FromSeconds(3); string key = DoubleCastKey(unit.ObjectId, spellName); if (DoubleCastPreventionDict.ContainsKey(key)) { DoubleCastPreventionDict[key] = expir; } DoubleCastPreventionDict.Add(key, expir); }
private static void UpdateDoubleCastDict(string spellName) { if (DoubleCastPreventionDict.ContainsKey(spellName)) { DoubleCastPreventionDict[spellName] = DateTime.UtcNow; } DoubleCastPreventionDict.Add(spellName, DateTime.UtcNow); }