private static partial DefaultMap UpdateDefaultMap(DefaultMap defaultMap, AddDefaultMap addDefaultMap) => new DefaultMap( EnsureInventories: defaultMap.EnsureInventories.AddRange(addDefaultMap.EnsureInventories), SpecialActions: defaultMap.SpecialActions.AddRange(addDefaultMap.SpecialActions), BorderTexture: addDefaultMap.BorderTexture ?? defaultMap.BorderTexture, Cluster: addDefaultMap.Cluster ?? defaultMap.Cluster, CompletionString: addDefaultMap.CompletionString ?? defaultMap.CompletionString, DeathCam: addDefaultMap.DeathCam ?? defaultMap.DeathCam, DefaultCeiling: addDefaultMap.DefaultCeiling ?? defaultMap.DefaultCeiling, DefaultFloor: addDefaultMap.DefaultFloor ?? defaultMap.DefaultFloor, ExitFade: addDefaultMap.ExitFade ?? defaultMap.ExitFade, FloorNumber: addDefaultMap.FloorNumber ?? defaultMap.FloorNumber, HighScoresGraphic: addDefaultMap.HighScoresGraphic ?? defaultMap.HighScoresGraphic, LevelBonus: addDefaultMap.LevelBonus ?? defaultMap.LevelBonus, LevelNum: addDefaultMap.LevelNum ?? defaultMap.LevelNum, Music: addDefaultMap.Music ?? defaultMap.Music, SpawnWithWeaponRaised: addDefaultMap.SpawnWithWeaponRaised ?? defaultMap.SpawnWithWeaponRaised, SecretDeathSounds: addDefaultMap.SecretDeathSounds ?? defaultMap.SecretDeathSounds, Next: addDefaultMap.Next ?? defaultMap.Next, SecretNext: addDefaultMap.SecretNext ?? defaultMap.SecretNext, VictoryNext: addDefaultMap.VictoryNext ?? defaultMap.VictoryNext, NoIntermission: addDefaultMap.NoIntermission ?? defaultMap.NoIntermission, Par: addDefaultMap.Par ?? defaultMap.Par, Translator: addDefaultMap.Translator ?? defaultMap.Translator );
private static partial Map ParseMap( ILookup <Identifier, VariableAssignment> assignmentLookup, string mapLump, string?mapName, bool isMapNameLookup, DefaultMap defaultMap) => new Map( MapLump: mapLump, EnsureInventories: ReadListAssignment(assignmentLookup, "ensureInventory").AddRange(defaultMap.EnsureInventories), SpecialActions: ReadSpecialActionAssignments(assignmentLookup).AddRange(defaultMap.SpecialActions), MapName: mapName, IsMapNameLookup: isMapNameLookup, BorderTexture: ReadStringAssignment(assignmentLookup, "borderTexture") ?? defaultMap.BorderTexture, Cluster: ReadIntAssignment(assignmentLookup, "cluster") ?? defaultMap.Cluster, CompletionString: ReadStringAssignment(assignmentLookup, "completionString") ?? defaultMap.CompletionString, DeathCam: ReadBoolAssignment(assignmentLookup, "deathCam") ?? defaultMap.DeathCam, DefaultCeiling: ReadStringAssignment(assignmentLookup, "defaultCeiling") ?? defaultMap.DefaultCeiling, DefaultFloor: ReadStringAssignment(assignmentLookup, "defaultFloor") ?? defaultMap.DefaultFloor, ExitFade: ReadExitFadeInfoAssignment(assignmentLookup, "exitFade") ?? defaultMap.ExitFade, FloorNumber: ReadIntAssignment(assignmentLookup, "floorNumber") ?? defaultMap.FloorNumber, HighScoresGraphic: ReadStringAssignment(assignmentLookup, "highScoresGraphic") ?? defaultMap.HighScoresGraphic, LevelBonus: ReadIntAssignment(assignmentLookup, "levelBonus") ?? defaultMap.LevelBonus, LevelNum: ReadIntAssignment(assignmentLookup, "levelNum") ?? defaultMap.LevelNum, Music: ReadStringAssignment(assignmentLookup, "music") ?? defaultMap.Music, SpawnWithWeaponRaised: ReadFlag(assignmentLookup, "spawnWithWeaponRaised") ?? defaultMap.SpawnWithWeaponRaised, SecretDeathSounds: ReadBoolAssignment(assignmentLookup, "secretDeathSounds") ?? defaultMap.SecretDeathSounds, Next: ReadNextMapInfoAssignment(assignmentLookup, "next") ?? defaultMap.Next, SecretNext: ReadNextMapInfoAssignment(assignmentLookup, "secretNext") ?? defaultMap.SecretNext, VictoryNext: ReadNextMapInfoAssignment(assignmentLookup, "victoryNext") ?? defaultMap.VictoryNext, NoIntermission: ReadFlag(assignmentLookup, "noIntermission") ?? defaultMap.NoIntermission, Par: ReadIntAssignment(assignmentLookup, "par") ?? defaultMap.Par, Translator: ReadStringAssignment(assignmentLookup, "translator") ?? defaultMap.Translator );
void Start() { LuaLibrariesIniter.PostInit(); PathCalcManager.PreSetup(); LanguageTextManager.Init(); var map = new DefaultMap(); SetupNewChunk(map); var center = CurrentChunk.Ground[0][(int)(StaticMapSize / 2f)][(int)(StaticMapSize / 2f)].CurrentPos; //SetCameraAt(new Vector2Int(center.x, center.y)); PlayersManager.SetupPlayer(); }
private static void Main(string[] args) { Console.WriteLine("***** Fun with Map *****"); var simpleMap = new DefaultMap <int, string>(100); simpleMap.Add(new Item <int, string>(1, "Homer")); simpleMap.Add(new Item <int, string>(2, "Marge")); simpleMap.Add(new Item <int, string>(3, "Bard")); simpleMap.Add(new Item <int, string>(3, "Bard")); simpleMap.Add(new Item <int, string>(4, "Liza")); foreach (var item in simpleMap) { Console.WriteLine(item); } }
public static IReadOnlyDictionary <string, Map> ReadMapDeclarations(IEnumerator <Token> tokenStream) { var defaultMap = new DefaultMap(EnsureInventories: ImmutableArray <string> .Empty, SpecialActions: ImmutableArray <SpecialAction> .Empty); var lumpToMap = new Dictionary <string, Map>(); while (tokenStream.MoveNext()) { switch (tokenStream.Current) { case IdentifierToken mapId when mapId.Id == "map": { var(mapLump, mapName, isMapNameLookup) = ParseMapHeader(mapId, tokenStream); var assignmentLookup = GetAssignmentLookup(tokenStream, alreadyOpened: true); var map = ParseMap(assignmentLookup, mapLump, mapName, isMapNameLookup, defaultMap); lumpToMap.Add( mapLump.ToUpperInvariant(), map); } break; case IdentifierToken defaultMapId when defaultMapId.Id == "defaultMap": { var assignmentLookup = GetAssignmentLookup(tokenStream); defaultMap = ParseDefaultMap(assignmentLookup); } break; case IdentifierToken addDefaultMapId when addDefaultMapId.Id == "addDefaultMap": { var assignmentLookup = GetAssignmentLookup(tokenStream); var addDefaultMap = ParseAddDefaultMap(assignmentLookup); defaultMap = UpdateDefaultMap(defaultMap, addDefaultMap); } break; } } return(lumpToMap); }
private static partial Map ParseMap( ILookup <Identifier, VariableAssignment> assignmentLookup, string mapLump, string?mapName, bool isMapNameLookup, DefaultMap defaultMap);
private static partial DefaultMap UpdateDefaultMap(DefaultMap defaultMap, AddDefaultMap addDefaultMap);
public async Task Build() { while (FlickrConfig.Instance.BaseDirectory == null) { Console.Write("Base Directory: "); var dir = Console.ReadLine().Trim(); if (Directory.Exists(dir)) { FlickrConfig.Instance.BaseDirectory = dir; FlickrConfig.Save(); } } var photos = new List <LocalFile> (); var videos = new List <LocalFile> (); var others = new List <LocalFile> (); var byDesc = new DefaultMap <string, LocalFile> (); var baseDir = FlickrConfig.Instance.BaseDirectory; var baseDirNormalized = baseDir.NormalizePath(); foreach (string fullPath in Directory.EnumerateFiles(baseDir, "*.*", SearchOption.AllDirectories)) { var fullPathNormalized = fullPath.NormalizePath(); var relativePathNormalized = fullPathNormalized.Replace(baseDirNormalized, string.Empty).NormalizePath(); var file = new LocalFile(fullPath: fullPath, relativePathNormalized: relativePathNormalized); var ext = Path.GetExtension(fullPath); if (ext.IsAny(".jpg", ".png" /*, ".gif"*/)) { photos.Add(file); } else if (ext.IsAny(".mp4", ".mkv")) { videos.Add(file); } else { others.Add(file); //Console.WriteLine (file); } byDesc [file.Description] = file; } Photos = photos.ToArray(); Videos = videos.ToArray(); Others = others.ToArray(); ByDesc = byDesc; // geo location? var photosJpeg = photos.Where(p => p.FullPath.EndsWithAny("jpg", "jpeg")).ToArray(); var photosJpegWithoutGeo = new List <LocalFile> (); foreach (var file in photosJpeg) { string geoStr; if (LocalDatabase.Instance.GeoLocations.TryGetValue(file.Description, out geoStr)) { file.GeoLocation = GeoLocation.Deserialize(geoStr); } else { photosJpegWithoutGeo.Add(file); } } Console.WriteLine("Local photos without geo location: " + photosJpegWithoutGeo.Count + " of " + photosJpeg.Length); var parallelism = 4; var i = 0; var tasks = new Task[parallelism]; var timeStart = DateTime.Now; for (int m = 0; m < parallelism; m++) { tasks [m] = parallel(photosJpegWithoutGeo, parallelism, m, (file) => { var geo = ExifHelper.GetLatlngFromImage(file.FullPath); file.GeoLocation = geo; LocalDatabase.RunLocked(() => { i++; LocalDatabase.Instance.GeoLocations [file.Description] = geo.Serialize(); }); if (i % 200 == 0) { LocalDatabase.RunLocked(() => { var timeNow = DateTime.Now; var speed = (timeNow - timeStart).TotalMilliseconds / Math.Max(i, 1); var timeRemaining = TimeSpan.FromMilliseconds(speed * (photosJpegWithoutGeo.Count - i)); LocalDatabase.Save(); Console.WriteLine(" " + i + " of " + photosJpegWithoutGeo.Count + " (" + Math.Round(10000.0 / (double)photosJpegWithoutGeo.Count * (double)i) / 100 + "%, remaining: " + new DateTime(timeRemaining.Ticks).ToString("HH:mm:ss") + ")"); }); } }); } await Task.WhenAll(tasks); LocalDatabase.Save(); }
public string Get(string key) { return(Map.ContainsKey(key) ? Map[key] : DefaultMap.ContainsKey(key) ? DefaultMap[key] : ""); }
private void Awake() { // Init Default Map DefaultMap.Clear(); for (int i = 0; i < m_DefaultData.Length - 1; i += 2) { var key = m_DefaultData[i]; if (DefaultMap.ContainsKey(key)) { DefaultMap.Add(key, m_DefaultData[i + 1]); } } m_DefaultData = null; // Init Index if (LanguageIndex < 0) { LanguageIndex.Value = (int)Application.systemLanguage; } // Load Language var language = (SystemLanguage)LanguageIndex.Value; if (language == SystemLanguage.Chinese) { language = SystemLanguage.ChineseSimplified; } bool success = LoadLanguage(language); if (!success) { switch (language) { case SystemLanguage.Chinese: success = LoadLanguage(SystemLanguage.ChineseSimplified); if (!success) { success = LoadLanguage(SystemLanguage.ChineseTraditional); } break; case SystemLanguage.ChineseSimplified: success = LoadLanguage(SystemLanguage.Chinese); if (!success) { success = LoadLanguage(SystemLanguage.ChineseTraditional); } break; case SystemLanguage.ChineseTraditional: success = LoadLanguage(SystemLanguage.Chinese); if (!success) { success = LoadLanguage(SystemLanguage.ChineseSimplified); } break; } } if (!success) { LoadLanguage(SystemLanguage.English); } }
public FastCGIRequest() { Params = new DefaultMap<string, FastCGIParam>(FastCGIParam.Empty); }