public static bool AddImbuedEffect(Player player, WorldObject target, ImbuedEffectType effect) { var imbuedEffects = GetImbuedEffects(target); if (imbuedEffects.HasFlag(effect)) { return(false); // already present } imbuedEffects |= effect; if (target.GetProperty(PropertyInt.ImbuedEffect) == null) { target.SetProperty(PropertyInt.ImbuedEffect, (int)effect); } else if (target.GetProperty(PropertyInt.ImbuedEffect2) == null) { target.SetProperty(PropertyInt.ImbuedEffect2, (int)effect); } else if (target.GetProperty(PropertyInt.ImbuedEffect3) == null) { target.SetProperty(PropertyInt.ImbuedEffect3, (int)effect); } else if (target.GetProperty(PropertyInt.ImbuedEffect4) == null) { target.SetProperty(PropertyInt.ImbuedEffect4, (int)effect); } else if (target.GetProperty(PropertyInt.ImbuedEffect5) == null) { target.SetProperty(PropertyInt.ImbuedEffect5, (int)effect); } else { return(false); } if (IconUnderlay.TryGetValue(effect, out var icon)) { target.SetProperty(PropertyDataId.IconUnderlay, icon); player.Session.Network.EnqueueSend(new GameMessagePublicUpdatePropertyDataID(target, PropertyDataId.IconUnderlay, icon)); } return(true); }
/// <summary> /// Returns the number of equipped items with a particular imbue type /// </summary> public int GetDefenseImbues(ImbuedEffectType imbuedEffectType) { return(EquippedObjects.Values.Count(i => i.GetImbuedEffects().HasFlag(imbuedEffectType))); }