Esempio n. 1
0
        public void Unregister(Game game)
        {
            TimedCallback updateCallback;
            _callbacks.TryRemove(game.ID, out updateCallback);
            _updateLoop.RemoveCallback(updateCallback);

            TryLoopStop();
        }
Esempio n. 2
0
        private TimedCallback CreateAndCacheCallback(Game game)
        {
            var updateCallback = new TimedCallback
            {
                Callback = game.PrepareUpdate
            };

            // Add the callback to the callback cache
            _callbacks.TryAdd(game.ID, updateCallback);

            return updateCallback;
        }
Esempio n. 3
0
        public Action<int> Register(Game game)
        {
            var updateCallback = CreateAndCacheCallback(game);

            // Try to start the loop prior to adding our games callback.  This callback may be the first, hence the "Try"
            TryLoopStart();

            // Add our callback to the game loop (which is now running), it will now be called on an interval dictated by updateCallback
            _updateLoop.AddCallback(updateCallback);

            // Updating the "updateRate" is an essential element to the game configuration.
            // If a game is running slowly we need to be able to slow down the update rate.
            return CreateUpdateRateSetter(updateCallback);
        }