internal bool AddElement(IUnitElement_Ltd element) { var isAdded = _elements.Add(element); isAdded = isAdded & _items.Add(element); if (!isAdded) { //D.Log("{0} tried to add Element {1} it already has.", DebugName, element.DebugName); return false; } element.isHQChanged += ElementIsHQChangedEventHandler; element.deathOneShot += ItemDeathEventHandler; // 8.21.16 was missing? if (element.IsHQ) { AddCommand(element.Command); } return true; }
/// <summary> /// Removes the element from this player's knowledge. Element's are /// removed when they lose all <c>Player</c> detection. Losing all /// detection by <c>Player</c> occurs for 1 reason - no Player Cmds /// in sensor range. Removal because of death is handled by this Knowledge. /// </summary> /// <param name="element">The element.</param> internal void RemoveElement(IUnitElement_Ltd element) { var isRemoved = _elements.Remove(element); isRemoved = isRemoved & _items.Remove(element); D.Assert(isRemoved, element.DebugName); if (element.IsOperational && (element as IUnitElement).Owner.IsRelationshipWith(Owner, DiplomaticRelationship.Alliance)) { D.Error("{0}: {1} is alive and being removed while in Alliance!", DebugName, element.DebugName); } element.isHQChanged -= ElementIsHQChangedEventHandler; element.deathOneShot -= ItemDeathEventHandler; if (element.IsHQ) { RemoveCommand(element.Command); } }
public AUnitElementReport(AUnitElementData data, Player player, IUnitElement_Ltd item) : base(data, player, item) { }