Exemplo n.º 1
0
        void InitTickables()
        {
            _updater = new TaskUpdater <ITickable>(UpdateTickable);

            foreach (var type in _priorities.Select(x => x.First))
            {
                Assert.That(type.DerivesFrom <ITickable>(),
                            "Expected type '{0}' to drive from ITickable while checking priorities in TickableHandler", type.Name());
            }

            var priorityMap = _priorities.ToDictionary(x => x.First, x => x.Second);

            foreach (var tickable in _tickables)
            {
                int priority;

                if (priorityMap.TryGetValue(tickable.GetType(), out priority))
                {
                    _updater.AddTask(tickable, priority);
                }
                else
                {
                    _updater.AddTask(tickable);
                }
            }
        }
Exemplo n.º 2
0
        void InitTickables()
        {
            _updater = new TaskUpdater <ITickable>(UpdateTickable);

            foreach (var type in _priorities.Select(x => x.First))
            {
                Assert.That(type.DerivesFrom <ITickable>(),
                            "Expected type '{0}' to drive from ITickable while checking priorities in TickableHandler", type.Name());
            }

            foreach (var tickable in _tickables)
            {
                // Note that we use zero for unspecified priority
                // This is nice because you can use negative or positive for before/after unspecified
                var matches  = _priorities.Where(x => tickable.GetType().DerivesFromOrEqual(x.First)).Select(x => x.Second).ToList();
                int priority = matches.IsEmpty() ? 0 : matches.Single();

                _updater.AddTask(tickable, priority);
            }
        }
Exemplo n.º 3
0
 public void AddFixed(IFixedTickable tickable)
 {
     _fixedUpdater.AddTask(tickable);
 }
Exemplo n.º 4
0
 public void AddLate(ILateTickable tickable)
 {
     _lateUpdater.AddTask(tickable);
 }
Exemplo n.º 5
0
 public void Add(ITickable tickable)
 {
     _updater.AddTask(tickable);
 }
Exemplo n.º 6
0
 public void AddFixed(IFixedTickable tickable, int priority = 0)
 {
     _fixedUpdater.AddTask(tickable, priority);
 }
Exemplo n.º 7
0
 public void AddLate(ILateTickable tickable, int priority = 0)
 {
     _lateUpdater.AddTask(tickable, priority);
 }
Exemplo n.º 8
0
 public void Add(ITickable tickable, int priority = 0)
 {
     _updater.AddTask(tickable, priority);
 }