Exemplo n.º 1
0
        internal GameHandle(RegistrationTargetBase target, LinkedListNode <UpdateContainer> updateableNode, RenderContainer renderableItem)
        {
            this.target            = target;
            target.ChangesApplied += ChangesAppliedHandler;

            this.updateableNode = updateableNode;
            this.renderableItem = renderableItem;
        }
Exemplo n.º 2
0
        /// <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));
        }
Exemplo n.º 3
0
        private void ChangesAppliedHandler(object sender, EventArgs e)
        {
            if (disposed)
            {
                updateableNode.Value.Dispose();
                updateableNode = null;

                target.ChangesApplied -= ChangesAppliedHandler;
                target = null;
            }
        }