public GameStateUpdater(PlayableGameState gameState, IGameTimeService gameTimeService, float updateInterval) { _gameState = gameState; _gameTimeService = gameTimeService; UpdateTimer = new Timer(updateInterval); UpdateTimer.Elapsed += Update; UpdateTimer.AutoReset = false;//DO NOT SET THIS TO TRUE, OTHERWISE EVENT MIGHT FIRE BEFORE PREVIOUS EVENT COMPLETES AND WE'LL GET CONCURRENCY ERRORS UpdateTimer.Start(); }
void FinalizeNewState(PlayableGameState newState, int areaID) { newState.IncreaseUpdateInterval += _increaseUpdateInterval; newState.DecreaseUpdateInterval += _decreaseUpdateInterval; _areaIDToUpdater.Add(areaID, new GameStateUpdater(newState, _gameTimeService, _simulatorConfig.EmptyGameStateUpdateIntervalMS)); newState.Activate(newState); _gameStates.Add(areaID, newState); }