public static string Id(this IBuff ability) { var descriptor = ability.GetType() .GetCustomAttributes(typeof(BuffXivDbAttribute), false).Cast <BuffXivDbAttribute>() .SingleOrDefault(); return(descriptor?.BuffId.ToString()); }
public void AddBuff(IBuff buff) { var alreadyHasBuff = ActiveBuffs.Where(b => b.Buff.GetType() == buff.GetType()).Any(); if (!alreadyHasBuff) { var activeBuff = BuffFactory.GetActiveBuff(buff, this); activeBuff.Trigger <IBuffApplyTrigger>(); ActiveBuffs.Add(activeBuff); } }
public void RemoveBuff(IBuff buff) { var presentBuff = ActiveBuffs .Where(b => b.Buff.GetType() == buff.GetType()) .FirstOrDefault(); if (presentBuff != null) { presentBuff.Trigger <IBuffRemoveTrigger>(); ActiveBuffs.Remove(presentBuff); } }
public void RemoveBuff(IBuff buff) { if (buff == null) { throw new ArgumentNullException(); } Type buffType = buff.GetType(); if (buffMap[buffType].Equals(buff)) { buffMap.Remove(buffType); } }
//TODO: the registration collection should be created inside here!!! Not passed in. public void AddBuff(IBuff buff, BuffRegistrationCollection eventSet) { //Fire the event! We want to fire it even if it gets ignored. It fires everytime someone tries to add one. if (BuffAdded != null) { BuffAdded(buff); } Type buffType = buff.GetType(); if (buffMap.ContainsKey(buffType)) { if (!buffMap[buffType].OnOverwrite(buff)) { return; } } buffMap[buffType] = buff; buff.RegisterForEvents(eventSet); }
private static List <Type> GetTriggers(IBuff buff) { return(buff.GetType().GetInterfaces() .Where(i => i.GetInterfaces().Contains(typeof(IBuffTrigger))) .ToList()); }
public bool HasBuff(IBuff buff) { return(ActiveBuffs.Where(b => b.Buff.GetType() == buff.GetType()).Any()); }
public void ShowBuffTrigger(IBuff buff, BattleCharacter before, BattleCharacter after) { Console.WriteLine($"{before.Name} feels the effect of {buff.GetType().Name}"); ShowStatDifferences(before, after); }
private IBuff GetBuff(IBuff newBuff) { return(_buffs.FirstOrDefault(buff => buff.GetType() == newBuff.GetType())); }
private bool HasBuff(IBuff newBuff) { return(_buffs.Any(buff => buff.GetType() == newBuff.GetType())); }