protected Entity(Range <EntityID> in_bounds, EntityID in_id, string in_name) { if (!in_id.IsValidForRange(in_bounds)) { throw new ArgumentOutOfRangeException(nameof(in_id)); } if (string.IsNullOrEmpty(in_name)) { throw new ArgumentNullException(nameof(in_name)); } ID = in_id; Name = in_name; }
/// <summary> /// Returns the specified <see cref="Entity"/>. /// </summary> /// <param name="in_id">A valid, defined <see cref="Entity"/> identifier.</param> /// <typeparam name="T">The type of <see cref="Entity"/> sought. Must correspond to the given ID.</typeparam> /// <returns>The specified <see cref="Entity"/>.</returns> public Entity Get(EntityID in_id) { return(Entities[in_id]); }
/// <summary> /// Determines whether the <see cref="EntityCollection"/> contains the specified <see cref="Entity"/>. /// </summary> /// <param name="in_id">The <see cref="EntityID"/> of the <see cref="Entity"/> to find.</param> /// <returns><c>true</c> if the <see cref="EntityID"/> was found; <c>false</c> otherwise.</returns> /// <remarks>This method is equivalent to <see cref="Dictionary{EntityID, Entity}.ContainsKey"/>.</remarks> public bool Contains(EntityID in_id) { return(Entities.ContainsKey(in_id)); }
/// <summary> /// Removes the <see cref="Entity"/> with the specified <see cref="EntityID"/> from the <see cref="EntityCollection"/>. /// </summary> /// <param name="in_id">The <see cref="EntityID"/> of the <see cref="Entity"/> to remove.</param> /// <returns> /// <c>true</c> if the <see cref="Entity"/> is successfully found and removed; otherwise, <c>false</c>. /// This method returns <c>false</c> if <see cref="EntityID"/> is not found. /// </returns> /// <remarks> /// From the perspective of the game and tools client code, removing an <see cref="Entity"/> from its associated /// <see cref="EntityCollection"/> is the same as undefining it. /// </remarks> public bool Remove(EntityID in_id) { return(Entities.Remove(in_id)); }