public override void Update(float elapsed) { for (int i = this.AlwaysUpdate.Count - 1; i >= 0; i--) { Component e = this.AlwaysUpdate[i]; if (!e.Ghost) { e.Update(elapsed); if (e.Destroyed) { this.RemoveComponent(e); } } } EntityRenderer r = this.renderer as EntityRenderer; if (r != null) { foreach (Entity e in this.integrator.GetEntitiesInRect(r.TopLeft, r.BottomRight, true)) { if (!e.Ghost && e.UpdateBehaviour == Entity.UpdateBehaviours.UpdateWhenVisible) { e.Update(elapsed); if (e.Destroyed) { this.RemoveComponent(e); } } } } // DO NOT CALL BASE UPDATE! WE ARE OVERRIDING THIS BEHAVIOUR!! //base.Update(elapsed); }
/// <summary> /// The generic Update method is called once every frame. Override this method to implement behavior that needs to be updated every frame. /// </summary> /// <param name="elapsed">The time between the current frame and the previous frame, measured in seconds.</param> public virtual void Update(float elapsed) { for (int i = this.components.Count - 1; i >= 0; i--) { Component component = this.components[i]; if (component != null && !component.Ghost) { component.Update(elapsed); if (component.Destroyed) { this.RemoveComponent(component); } } } }