long Solve(string input, bool hasNat) { var machines = ( from address in Enumerable.Range(0, 50) select Nic(input, address) ).ToList(); var natAddress = 255; if (hasNat) { machines.Add(Nat(natAddress)); } var packets = new Packets(); while (!packets.Any(packet => packet.address == natAddress)) { foreach (var machine in machines) { packets = machine(packets); } } return(packets.Single(packet => packet.address == natAddress).y); }
private void GeneratePathPoint(AreaTile current, AreaTile end) { while (activeTiles.Any()) { current = activeTiles.OrderBy(tile => tile.CostDistance).First(); // Destination reached. if ((System.Math.Round(current.position.X, 0) == System.Math.Round(end.position.X, 0)) && (System.Math.Round(current.position.Z, 0) == System.Math.Round(end.position.Z, 0))) { TracePath(current); return; } visitedTiles.Add(current); activeTiles.Remove(current); foreach (AreaTile tile in GetTileGrid(current, end)) { double currentTileX = System.Math.Round(tile.position.X, 0); double currentTileZ = System.Math.Round(tile.position.Z, 0); if (visitedTiles.Any(cTile => (System.Math.Round(cTile.position.X, 0) == currentTileX) && (System.Math.Round(cTile.position.Z, 0) == currentTileZ))) { continue; } if (activeTiles.Any(cTile => (System.Math.Round(cTile.position.X, 0) == currentTileX) && (System.Math.Round(cTile.position.Z, 0) == currentTileZ))) { AreaTile scannedTile = activeTiles.First(cTile => (System.Math.Round(cTile.position.X, 0) == currentTileX) && (System.Math.Round(cTile.position.Z, 0) == currentTileZ)); if (scannedTile.CostDistance > tile.CostDistance) { activeTiles.Remove(scannedTile); activeTiles.Add(tile); } } else { activeTiles.Add(tile); } } } }
void AddNativeLibrary (ArchiveFileList files, string path, string abi, string archiveFileName) { string fileName = string.IsNullOrEmpty (archiveFileName) ? Path.GetFileName (path) : archiveFileName; var item = (filePath: path, archivePath: $"lib/{abi}/{fileName}"); if (files.Any (x => x.archivePath == item.archivePath)) { Log.LogCodedWarning ("XA4301", path, 0, Properties.Resources.XA4301, item.archivePath); return; } files.Add (item); }
void AddNativeLibrary(ArchiveFileList files, string path, string abi) { var item = (filePath : path, archivePath : $"lib/{abi}"); string filename = "/" + Path.GetFileName(item.filePath); string inArchivePath = item.archivePath + filename; if (files.Any(x => (x.archivePath + "/" + Path.GetFileName(x.filePath)) == inArchivePath)) { Log.LogCodedWarning("XA4301", path, 0, $"Apk already contains the item {inArchivePath}; ignoring."); return; } files.Add(item); }
void AddNativeLibrary(ArchiveFileList files, string path, string abi) { var item = (filePath : path, archivePath : $"lib/{abi}"); string filename = "/" + Path.GetFileName(item.filePath); string inArchivePath = item.archivePath + filename; if (files.Any(x => (x.archivePath + "/" + Path.GetFileName(x.filePath)) == inArchivePath)) { Log.LogCodedWarning("XA4301", path, 0, Properties.Resources.XA4301, inArchivePath); return; } files.Add(item); }
static void SetGraphicsSettings() { Debug.Log("Setting Graphics Settings"); const string GraphicsSettingsAssetPath = "ProjectSettings/GraphicsSettings.asset"; SerializedObject graphicsManager = new SerializedObject(UnityEditor.AssetDatabase.LoadAllAssetsAtPath(GraphicsSettingsAssetPath)[0]); SerializedProperty deferred = graphicsManager.FindProperty("m_Deferred.m_Mode"); deferred.enumValueIndex = 1; SerializedProperty deferredReflections = graphicsManager.FindProperty("m_DeferredReflections.m_Mode"); deferredReflections.enumValueIndex = 1; SerializedProperty screenSpaceShadows = graphicsManager.FindProperty("m_ScreenSpaceShadows.m_Mode"); screenSpaceShadows.enumValueIndex = 1; SerializedProperty legacyDeferred = graphicsManager.FindProperty("m_LegacyDeferred.m_Mode"); legacyDeferred.enumValueIndex = 1; SerializedProperty depthNormals = graphicsManager.FindProperty("m_DepthNormals.m_Mode"); depthNormals.enumValueIndex = 1; SerializedProperty motionVectors = graphicsManager.FindProperty("m_MotionVectors.m_Mode"); motionVectors.enumValueIndex = 1; SerializedProperty lightHalo = graphicsManager.FindProperty("m_LightHalo.m_Mode"); lightHalo.enumValueIndex = 1; SerializedProperty lensFlare = graphicsManager.FindProperty("m_LensFlare.m_Mode"); lensFlare.enumValueIndex = 1; #if ENV_SET_INCLUDED_SHADERS && VRC_CLIENT SerializedProperty alwaysIncluded = graphicsManager.FindProperty("m_AlwaysIncludedShaders"); alwaysIncluded.arraySize = 0; // clear GraphicsSettings->Always Included Shaders - these cause a +5s app startup time increase on Quest. // include Shader objects as resources instead #if ENV_SEARCH_FOR_SHADERS Resources.LoadAll("", typeof(Shader)); System.Collections.Generic.List <Shader> foundShaders = Resources.FindObjectsOfTypeAll <Shader>() .Where(s => { string name = s.name.ToLower(); return(0 == (s.hideFlags & HideFlags.DontSave)); }) .GroupBy(s => s.name) .Select(g => g.First()) .ToList(); #else System.Collections.Generic.List <Shader> foundShaders = new System.Collections.Generic.List <Shader>(); #endif for (int shaderIdx = 0; shaderIdx < ensureTheseShadersAreAvailable.Length; ++shaderIdx) { if (foundShaders.Any(s => s.name == ensureTheseShadersAreAvailable[shaderIdx])) { continue; } Shader namedShader = Shader.Find(ensureTheseShadersAreAvailable[shaderIdx]); if (namedShader != null) { foundShaders.Add(namedShader); } } foundShaders.Sort((s1, s2) => s1.name.CompareTo(s2.name)); // populate Resources list of "always included shaders" ShaderAssetList alwaysIncludedShaders = AssetDatabase.LoadAssetAtPath <ShaderAssetList>("Assets/Resources/AlwaysIncludedShaders.asset"); alwaysIncludedShaders.Shaders = new Shader[foundShaders.Count]; for (int shaderIdx = 0; shaderIdx < foundShaders.Count; ++shaderIdx) { alwaysIncludedShaders.Shaders[shaderIdx] = foundShaders[shaderIdx]; } #endif SerializedProperty preloaded = graphicsManager.FindProperty("m_PreloadedShaders"); preloaded.ClearArray(); preloaded.arraySize = 0; SerializedProperty spritesDefaultMaterial = graphicsManager.FindProperty("m_SpritesDefaultMaterial"); spritesDefaultMaterial.objectReferenceValue = Shader.Find("Sprites/Default"); SerializedProperty renderPipeline = graphicsManager.FindProperty("m_CustomRenderPipeline"); renderPipeline.objectReferenceValue = null; SerializedProperty transparencySortMode = graphicsManager.FindProperty("m_TransparencySortMode"); transparencySortMode.enumValueIndex = 0; SerializedProperty transparencySortAxis = graphicsManager.FindProperty("m_TransparencySortAxis"); transparencySortAxis.vector3Value = Vector3.forward; SerializedProperty defaultRenderingPath = graphicsManager.FindProperty("m_DefaultRenderingPath"); defaultRenderingPath.intValue = 1; SerializedProperty defaultMobileRenderingPath = graphicsManager.FindProperty("m_DefaultMobileRenderingPath"); defaultMobileRenderingPath.intValue = 1; SerializedProperty tierSettings = graphicsManager.FindProperty("m_TierSettings"); tierSettings.ClearArray(); tierSettings.arraySize = 0; #if ENV_SET_LIGHTMAP SerializedProperty lightmapStripping = graphicsManager.FindProperty("m_LightmapStripping"); lightmapStripping.enumValueIndex = 1; SerializedProperty instancingStripping = graphicsManager.FindProperty("m_InstancingStripping"); instancingStripping.enumValueIndex = 2; SerializedProperty lightmapKeepPlain = graphicsManager.FindProperty("m_LightmapKeepPlain"); lightmapKeepPlain.boolValue = true; SerializedProperty lightmapKeepDirCombined = graphicsManager.FindProperty("m_LightmapKeepDirCombined"); lightmapKeepDirCombined.boolValue = true; SerializedProperty lightmapKeepDynamicPlain = graphicsManager.FindProperty("m_LightmapKeepDynamicPlain"); lightmapKeepDynamicPlain.boolValue = true; SerializedProperty lightmapKeepDynamicDirCombined = graphicsManager.FindProperty("m_LightmapKeepDynamicDirCombined"); lightmapKeepDynamicDirCombined.boolValue = true; SerializedProperty lightmapKeepShadowMask = graphicsManager.FindProperty("m_LightmapKeepShadowMask"); lightmapKeepShadowMask.boolValue = true; SerializedProperty lightmapKeepSubtractive = graphicsManager.FindProperty("m_LightmapKeepSubtractive"); lightmapKeepSubtractive.boolValue = true; #endif #if ENV_SET_FOG SerializedProperty fogStripping = graphicsManager.FindProperty("m_FogStripping"); fogStripping.enumValueIndex = 1; SerializedProperty fogKeepLinear = graphicsManager.FindProperty("m_FogKeepLinear"); fogKeepLinear.boolValue = true; SerializedProperty fogKeepExp = graphicsManager.FindProperty("m_FogKeepExp"); fogKeepExp.boolValue = true; SerializedProperty fogKeepExp2 = graphicsManager.FindProperty("m_FogKeepExp2"); fogKeepExp2.boolValue = true; #endif SerializedProperty albedoSwatchInfos = graphicsManager.FindProperty("m_AlbedoSwatchInfos"); albedoSwatchInfos.ClearArray(); albedoSwatchInfos.arraySize = 0; SerializedProperty lightsUseLinearIntensity = graphicsManager.FindProperty("m_LightsUseLinearIntensity"); lightsUseLinearIntensity.boolValue = true; SerializedProperty lightsUseColorTemperature = graphicsManager.FindProperty("m_LightsUseColorTemperature"); lightsUseColorTemperature.boolValue = true; graphicsManager.ApplyModifiedProperties(); }