private void UpdateLightState(ushort step, bool updateBuilding) { ushort first = (ushort)(step * BuildingStepSize); ushort last = (ushort)(((step + 1) * BuildingStepSize) - 1); for (ushort i = first; i <= last; ++i) { buildingManager.GetBuildingService(i, out ItemClass.Service service, out ItemClass.SubService subService); bool lightsOn = !ShouldSwitchBuildingLightsOff(i, service, subService); if (lightsOn == lightStates[i]) { continue; } lightStates[i] = lightsOn; if (updateBuilding) { buildingManager.UpdateBuildingColors(i); if (!lightsOn) { buildingManager.DeactivateVisually(i); } } } }