/// <summary> /// Returns how many of a certain carrier component type are assigned to the current instance. /// </summary> /// <param name="type"></param> /// <returns></returns> public int GetTypeCount(CarrierComponentType type) { HashSet <string> set; if (!_components.TryGetValue(type, out set)) { return(0); } return(set.Count); }
/// <summary> /// Iterates through the current instances's components of the specified type. /// </summary> /// <param name="type">The type of component to iterate through.</param> /// <returns></returns> public IEnumerable <string> GetComponentsOfType(CarrierComponentType type) { HashSet <string> set; if (!_components.TryGetValue(type, out set)) { yield break; } foreach (string value in set) { yield return(value); } }
/// <summary> /// Adds a component of the specified type and name to the current instance. /// </summary> /// <param name="type">The type of carrier to add.</param> /// <param name="values">The names to assign to the component type.</param> public void AddComponent(CarrierComponentType type, params string[] values) { HashSet <string> set; if (!_components.TryGetValue(type, out set)) { _components[type] = new HashSet <string>(values); return; } foreach (string value in values) { set.Add(value); } }
public void RemoveType(CarrierComponentType type, string name) { if (type == CarrierComponentType.Rhyme) { DeleteRhyme(name); } else if (type == CarrierComponentType.Unique) { DeleteUnique(name); } else if ( type == CarrierComponentType.Associative || type == CarrierComponentType.Relational || type == CarrierComponentType.Dissociative || type == CarrierComponentType.Divergent) { DeleteAssociation(name); } else { DeleteMatch(name); } }