/// <summary> /// Remove the first instance of an actor corresponding to the predicate /// </summary> /// <param name="predicate">Lambda function which allows ObjectManager to uniquely identify an actor</param> /// <returns>True if successful, otherwise false</returns> public bool RemoveFirstIf(Predicate <OurDrawnActor3D> predicate) { //to do...improve efficiency by adding DrawType enum int position = -1; bool wasRemoved = false; position = OpaqueList.FindIndex(predicate); if (position != -1) { OpaqueList.RemoveAt(position); wasRemoved = true; } position = TransparentList.FindIndex(predicate); if (position != -1) { TransparentList.RemoveAt(position); wasRemoved = true; } if (wasRemoved) { isDirty = true; } return(wasRemoved); }
/// <summary> /// Remove all occurences of any actors corresponding to the predicate /// </summary> /// <param name="predicate">Lambda function which allows ObjectManager to uniquely identify one or more actors</param> /// <returns>Count of the number of removed actors</returns> public int RemoveAll(Predicate <OurDrawnActor3D> predicate) { //to do...improve efficiency by adding DrawType enum int count = 0; count = OpaqueList.RemoveAll(predicate); count += TransparentList.RemoveAll(predicate); if (count > 0) { isDirty = true; } return(count); }
/// <summary> /// Add the actor to the appropriate list based on actor transparency /// </summary> /// <param name="actor"></param> public void Add(OurDrawnActor3D actor) { if (actor.EffectParameters.GetAlpha() < 1) { TransparentList.Add(actor); } else { OpaqueList.Add(actor); } isDirty = true; }
private void ApplyBatchRemove() { foreach (OurDrawnActor3D actor in removeList) { if (actor.EffectParameters.GetAlpha() < 1) { TransparentList.Remove(actor); } else { OpaqueList.Remove(actor); } } removeList.Clear(); }
private void HandleObjectCategoryEvent(EventData eventData) { switch (eventData.EventActionType) { case EventActionType.OnRemoveActor: { OurDrawnActor3D removeObject = eventData.Parameters[0] as OurDrawnActor3D; OpaqueList.Remove(removeObject); break; } case EventActionType.OnAddActor: { if (eventData.Parameters[0] is OurModelObject modelObject) { Add(modelObject); } break; } } }