/// <summary> /// Delete the object named key from existence. /// </summary> public static void DeleteObject(string key) { if (!Objects.ContainsKey(key)) { return; } GameObject del = (CollidableObject)Objects[key]; if (CollidableObjects.Contains(del)) { CollidableObjects.Remove((CollidableObject)del); } if (UIObjects.Contains(del)) { UIObjects.Remove((UIObject)del); } if (NonUIObjects.Contains(del)) { NonUIObjects.Remove(del); } if (Backgrounds.Contains(del)) { Backgrounds.Remove((Background)(del)); } Objects.Remove(key); }
/// <summary> /// Adds the given background to the song's background list if it doesn't already exist (can be undone). /// </summary> /// <param name="bg">The background to add.</param> /// <param name="forceAdd">if set to <c>true</c> the background will be added even if it already exists.</param> /// <returns> /// The index of the new background. /// </returns> public int AddBackground(SongBackground bg, bool forceAdd = false) { bool contains = !forceAdd && Backgrounds.Contains(bg); Action redo = () => { if (!contains) { backgrounds.Add(bg); } }; Action undo = () => { if (!contains) { backgrounds.Remove(bg); } }; Undo.ChangeFactory.OnChanging(this, undo, redo, "AddBackground"); if (contains) { return(Backgrounds.IndexOf(bg)); } else { backgrounds.Add(bg); return(Backgrounds.Count - 1); } }