internal GameHandle(RegistrationTargetBase target, LinkedListNode <UpdateContainer> updateableNode, RenderContainer renderableItem) { this.target = target; target.ChangesApplied += ChangesAppliedHandler; this.updateableNode = updateableNode; this.renderableItem = renderableItem; }
/// <summary> /// Creates a new layer. /// </summary> /// <param name="parent">Optional. The parent of the layer (this can be another layer, too). /// If this parameter is not specified or null is passed the game loop will be used as the parent.</param> protected Layer(RegistrationTargetBase parent = null) { context = new LayerContext <TState, TRenderer>(this); if (parent == null) { parent = GameEngine.QueryComponent <GameLoop>(); } handle = parent.Register(context); context.CurrentStateChanged += (sender, e) => Parallel.ForEach(Updateables, updateable => updateable.SetCurrentBufferIndex(context.CurrentState.BufferIndex)); }
private void ChangesAppliedHandler(object sender, EventArgs e) { if (disposed) { updateableNode.Value.Dispose(); updateableNode = null; target.ChangesApplied -= ChangesAppliedHandler; target = null; } }