Exemplo n.º 1
0
        private void Snapshot()
        {
            var gameState = GetGameState();

            gameState.Time           = Game.ElapsedTime;
            gameState.SnapshotNumber = _snapshotNumber;

            for (int i = 0; i < Game.EntityManager.Entities.Count; i++)
            {
                var entity = Game.EntityManager.Entities[i];

                if (entity == null ||
                    entity.DisableLagCompensation ||
                    !entity.EntityGameObject)
                {
                    continue;
                }

                var state = _entStatePool.Get();
                state.EntityId = entity.EntityId;
                state.Origin   = entity.EntityGameObject.Position;
                state.Angles   = entity.EntityGameObject.Rotation;
                GetAnimState(entity.EntityGameObject, state.AnimState);

                gameState.EntityStates.Add(state);
            }

            _gameStates[_currentIndex] = gameState;
        }
        public void ProcessCommand(string commandInput)
        {
            string output = string.Empty;

            developerConsole.ProcessCommand(commandInput, ref output);

            TextMeshProUGUI outputTextElement = outputLogTextPool.Get().GetComponent <TextMeshProUGUI>();

            outputTextElement.text = $"({DateTime.Now}) - {output}";

            userInputField.text = string.Empty;
        }
        /// <summary>
        /// Adds an event.
        /// </summary>
        /// <param name="subscription">The event subscription.</param>
        /// <param name="eventMessage">The event message.</param>
        /// <returns><c>true</c> if the even has been added successfully; otherwise (if the scheduler
        /// does not accept events anymore, because it has been disposed), <c>false</c>.</returns>
        public bool Add(ClusterSubscription subscription, ClientMessage eventMessage)
        {
            var partitionId = eventMessage.PartitionId;
            var start       = false;

            var data = new EventData
            {
                PartitionId  = partitionId,
                Subscription = subscription,
                Message      = eventMessage
            };

            Queue queue;

            lock (_mutex)
            {
                if (_disposed)
                {
                    HConsole.WriteLine(this, $"Discard event, correlation:{eventMessage.CorrelationId}");
                    return(false);
                }

                HConsole.WriteLine(this, $"Enqueue event, correlation:{eventMessage.CorrelationId} queue:{partitionId}");

                if (!_queues.TryGetValue(partitionId, out queue))
                {
                    HConsole.WriteLine(this, $"Create queue:{partitionId}");
                    queue = _queues[partitionId] = _pool.Get();
                    start = true;
                }

                queue.Enqueue(data);
            }

            if (start)
            {
                queue.Task = Handle(partitionId, queue);
            }
            return(true);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Adds an event.
        /// </summary>
        /// <param name="subscription">The event subscription.</param>
        /// <param name="eventMessage">The event message.</param>
        /// <returns><c>true</c> if the even has been added successfully; otherwise (if the scheduler
        /// does not accept events anymore, because it has been disposed), <c>false</c>.</returns>
        public bool Add(ClusterSubscription subscription, ClientMessage eventMessage)
        {
            var partitionId = eventMessage.PartitionId;
            var start       = false;

            var data = new EventData
            {
                PartitionId  = partitionId,
                Subscription = subscription,
                Message      = eventMessage
            };

            Queue queue;

            lock (_mutex)
            {
                if (_disposed)
                {
                    return(false);
                }

                if (!_queues.TryGetValue(partitionId, out queue))
                {
                    queue = _queues[partitionId] = _pool.Get();
                    start = true;
                }

                queue.Enqueue(data);
            }

            if (start)
            {
                queue.Task = Handle(partitionId, queue);
            }
            return(true);
        }