//tries to add a context with a delay public static void AddContext(Mobile m, DelayContextType type,TimeSpan delay) { DelayContextArray array; if(!UseDelayMain.TryGetValue(m,out array)) { //Console.WriteLine("Cant find array, adding...");//debug array = new DelayContextArray(); UseDelayMain[m] = array; } array.Add(type,delay); }
//Main functions //============ //checks if m is still being delayed by "type" context (ex: need to wait again to use that ability type) public static bool CheckContext(Mobile m, DelayContextType type) { DelayContextArray array; if(UseDelayMain.TryGetValue(m,out array)) { if(array==null)return false; bool ans = array.Contains(type); if(!ans && array.IsEmpty())UseDelayMain.Remove(m); return ans; } return false; }
public bool Remove(DelayContextType dct) { DateTime context; if(Contexts.TryGetValue(dct,out context)) { if(context>DateTime.Now) { Contexts.Remove(dct); return true; } } return false; }
public bool Contains(DelayContextType dct) { DateTime context; if(Contexts.TryGetValue(dct,out context)) { //Console.WriteLine("context: {0}",context);//debug if(context>DateTime.Now)return true; else Contexts.Remove(dct); } //Console.WriteLine("-context: {0}",context);//debug return false; }
public void Add(DelayContextType dct,TimeSpan delay) { DateTime context; if(Contexts.TryGetValue(dct,out context)) { //Console.WriteLine("contains {0}, removing... {1}",dct,context);//debug Contexts.Remove(dct); } //Console.WriteLine("Adding...{0} {1}",dct,delay);//debug Contexts[dct] = DateTime.Now+delay; }
//removes context. Returns true if it did exist, or false if it did not public static bool RemoveContext(Mobile m,DelayContextType type) { DelayContextArray array; if(UseDelayMain.TryGetValue(m,out array)) { if(array.Remove(type)) return true; } return false; }