/// <summary> /// Add all the objects in ObjectsToAdd to ActiveObjects, then update ActiveObjects before deleting objects in ObjectsToRemove /// </summary> /// <param name="elapsedGameTime">The seconds that have elapsed since the last update loop</param> public override void Update(float elapsedGameTime) { // Always call the super class' function - it will deal with whether it should run it itself base.Update(elapsedGameTime); // Add the objects and then clear the list - it is only a temporary holder ActiveObjects.AddRange(ObjectsToAdd); ObjectsToAdd.Clear(); // Loop through the active object foreach (T obj in ActiveObjects) { if (obj.ShouldUpdate) { // Update the object obj.Update(elapsedGameTime); } } // Remove all the objects that are no longer alive ActiveObjects.RemoveAll(x => x.IsAlive == false); // Remove all the objects we have marked to remove foreach (T obj in ObjectsToRemove) { ActiveObjects.Remove(obj); } ObjectsToRemove.Clear(); // Clear the list - it is only a temporary holder }
public static void RemoveObjects() { foreach (var obj in ObjectsToRemove) { RemoveObject(obj); if (obj.Type == WorldObjectType.BonusBox) { spawnedBonuses -= 1; } } ObjectsToRemove.Clear(); }
public void RemoveObjects() { string[] name = { "WpnMineThrown", "SupplyCrate00", "MetalRailing00", "WpnGrenadesThrown" }; IObject[] objects = GlobalGame.GetObjectsByName(name); for (int i = 0; i < objects.Length; i++) { objects[i].Remove(); } for (int i = 0; i < ObjectsToRemove.Count; i++) { if (ObjectsToRemove[i] != null) { ObjectsToRemove[i].Remove(); } } ObjectsToRemove.Clear(); }
public void Clear() { ObjectsToAdd.Clear(); ObjectsToRemove.Clear(); ObjectsToUpdate.Clear(); }