/// <summary> /// Adds a world entity to the list of assigned entities. /// </summary> /// <param name="name">The name of the world entity.</param> /// <param name="raiseChangeEvent">Whether or not to raise the assigned change event.</param> public virtual void AddAssigned(string name, bool raiseChangeEvent = true) { if (!Assigned.Contains(name) && Assigned.Count < MaxAssigned) { Assigned.Add(name); if (raiseChangeEvent) { RaiseChangeEvent(WorldEntityListType.Assigned); } } }
public bool AddAssigned(User user) { if (!Assigned.Contains(user)) { return(false); } if (Assigned.Count == assignedLimit) { return(false); } Assigned.Add(user); return(true); }
/// <summary> /// Adds a piece of equipment to the assigned list. /// </summary> /// <param name="name">The name of the equipment to assign.</param> /// <param name="raiseChangeEvent">Whether or not the raise an event about the change.</param> public override void AddAssigned(string name, bool raiseChangeEvent = true) { var equipmentObject = GetEntityObject(name) as Equipment; var slot = equipmentObject.EquipmentSlot; var listToRemove = new List <string>(); foreach (var equipment in Assigned) { var checkEquipment = GetEntityObject(equipment) as Equipment; var checkSlot = checkEquipment.EquipmentSlot; if (slot == EquipmentSlot.TwoHand) { if (checkSlot == EquipmentSlot.LeftHand || checkSlot == EquipmentSlot.RightHand) { listToRemove.Add(equipment); } } else { if (checkSlot == slot || (checkSlot == EquipmentSlot.TwoHand && (slot == EquipmentSlot.LeftHand || slot == EquipmentSlot.RightHand))) { listToRemove.Add(equipment); } } } foreach (var equipment in listToRemove) { RemoveAssigned(equipment, false); } if (!Assigned.Contains(name) && Assigned.Count < MaxAssigned) { Assigned.Add(name); if (raiseChangeEvent) { RaiseChangeEvent(WorldEntityListType.Assigned); } } }