/// <summary> /// Removes the specified DrawableInstance from this DrawableSet. This will only work if the /// DrawableInstance belongs to this DrawableSet - it will not work if it belongs to another. /// Returns a true boolean value if the specified instance was found within this set and removed. /// If nothing was removed, a false value is returned. /// </summary> public bool Remove(DrawableInstance drawableInstance) { bool result = true; result &= _stateDictionary[drawableInstance._associatedState].Remove(drawableInstance); result &= _groupDictionary[drawableInstance._associatedGroup].Remove(drawableInstance); return result; }
/// <summary> /// Adds the specified IGameDrawable to this DrawableSet under the specified *state*. Optionally, the /// IGameDrawable being added can also be associated with a *group*. When an IGameDrawable is added to /// a DrawableSet, it is wrapped around a DrawableInstance class that allows properties about the /// drawable to be set such as its Color, Rotation, Visibility etc... This DrawableInstance that is /// created to wrap the IGameDrawable is returned by this method. /// </summary> public DrawableInstance Add(string state, IGameDrawable drawable, string group="") { if (!_stateDictionary.ContainsKey(state)) AddState(state); if (!_groupDictionary.ContainsKey(group)) AddGroup(group); DrawableInstance instance = new DrawableInstance(drawable); instance._associatedGroup = group; instance._associatedState = state; _stateDictionary[state].Add(instance); _groupDictionary[group].Add(instance); return instance; }