public void Update_MainThread(double?elapsedTime = null) { if (_isDisposed) { return; } double elapsedActual = elapsedTime ?? _clockMainThread.Update(); if (_typesMainUnchecked != null) { #region Get intervals for types Tuple <Type, int>[] checkedTypes = GetTypeIntervals(_typesMainUnchecked, _map, true); if (checkedTypes != null) { var transfer = TransferTypes(_typesMainUnchecked, _typesMain, checkedTypes); _typesMainUnchecked = transfer.Item1; _typesMain = transfer.Item2; } #endregion } _updateCount_Main++; #region non map items foreach (var item in _nonmapItemsMain) { if (_updateCount_Main % (item.Item1 + 1) != 0) { continue; } item.Item2.Update_MainThread(elapsedActual + (elapsedActual * item.Item1)); // if skips is greater than zero, then approximate how much time elapsed based on this tick's elapsed time } #endregion #region items in map if (_typesMain != null) { foreach (var type in _typesMain) { if (type.Item2 > 0 && _updateCount_Main % (type.Item2 + 1) != 0) { continue; } // Update all the live instances foreach (IPartUpdatable item in _map.GetItems(type.Item1, false)) // Not bothering to call these in random order, because main thread should just be graphics { item.Update_MainThread(elapsedActual + (elapsedActual * type.Item2)); // if skips is greater than zero, then approximate how much time elapsed based on this tick's elapsed time } } } #endregion }
public void Update_AnyThread(double?elapsedTime = null) { if (_timerAnyThread != null) { throw new InvalidOperationException("Can't explicitly call Update_AnyThread when the constructor was told to use a timer"); } // Figure out how much time has elapsed since the last update //NOTE: Calling this update every time so if this method is sometimes called with a null and sometimes non null, the elapsed time will be somewhat accurate double elapsedActual = _clockAnyThread.Update(); if (elapsedTime != null) { elapsedActual = elapsedTime.Value; } Update_AnyThread_private(elapsedActual); }