private void FixedUpdate()
        {
            if (m_engine == null)
            {
                Debug.LogError("Enabled before Engine initialization");
                return;
            }

            while ((Time.realtimeSinceStartup - m_prevTickTime) >= GameConstants.MatchEngineTick)
            {
                m_replay.Tick(m_engine, m_tick);

                CommandsBundle commands;
                if (m_engine.Tick(m_tick, out commands))
                {
                    commands.Tick = m_tick;
                    if (Tick != null)
                    {
                        Error error = new Error(StatusCode.OK);
                        Tick(error, commands);
                    }
                }

                m_tick++;
                m_prevTickTime += GameConstants.MatchEngineTick;
            }
        }
Пример #2
0
        protected void RunEngine(int ticks = MAX_TICKS)
        {
            for (int i = 0; i < ticks; ++i)
            {
                m_engine.Update();

                m_replay.Tick(m_engine, m_tick);
                CommandsBundle commands;
                if (m_engine.Tick(m_tick, out commands))
                {
                    commands.Tick = m_tick;
                }

                m_tick++;
                m_prevTickTime += GameConstants.MatchEngineTick;
            }
        }
Пример #3
0
        private void FixedUpdate()
        {
            if (m_engine == null)
            {
                return;
            }

            while ((m_time.Time - m_prevTickTime) >= GameConstants.MatchEngineTick)
            {
                m_replay.Tick(m_engine, m_tick);

                CommandsBundle commands;
                if (m_engine.Tick(m_tick, out commands))
                {
                    commands.Tick = m_tick;
                    if (Tick != null)
                    {
                        Error error = new Error(StatusCode.OK);
                        m_tickArgs.Except = Guid.Empty;
                        m_tickArgs.Arg    = commands;
                        Tick(error, m_tickArgs);
                    }
                }

                m_tick++;
                m_prevTickTime += GameConstants.MatchEngineTick;

                for (int i = m_readyToBeUnregisteredClients.Count - 1; i >= 0; --i)
                {
                    DisconnectedClient disconnectedClient = m_readyToBeUnregisteredClients[i];
                    if (disconnectedClient.Time < m_time.Time)
                    {
                        m_readyToBeUnregisteredClients.RemoveAt(i);
                        UnregisterClient(disconnectedClient.ClientId);
                    }
                }
            }
        }