Beispiel #1
0
        public MapSpawnDatabaseInfo LoadSpawnInfo()
        {
            var mapSpawns = new MapSpawnDatabaseInfo();

            mapSpawns.MapSpawnEntries = new Dictionary <string, List <MapSpawnEntry> >();

            using var tr  = new StreamReader(@"Data/MapSpawns.csv") as TextReader;
            using var csv = new CsvReader(tr, CultureInfo.CurrentCulture);

            var spawns = csv.GetRecords <CsvMapSpawnEntry>().ToList();

            var entryCount = 0;

            foreach (var spawn in spawns)
            {
                if (string.IsNullOrWhiteSpace(spawn.Map) || spawn.Map.StartsWith("//") || spawn.Map.StartsWith("#"))
                {
                    continue;
                }


                var entry = new MapSpawnEntry()
                {
                    X             = spawn.X,
                    Y             = spawn.Y,
                    Width         = spawn.Width,
                    Height        = spawn.Height,
                    Count         = spawn.Count,
                    Class         = spawn.Class,
                    SpawnTime     = spawn.SpawnTime,
                    SpawnVariance = spawn.Variance
                };


                if (!mapSpawns.MapSpawnEntries.ContainsKey(spawn.Map))
                {
                    mapSpawns.MapSpawnEntries.Add(spawn.Map, new List <MapSpawnEntry>());
                }

                mapSpawns.MapSpawnEntries[spawn.Map].Add(entry);
                entryCount++;
            }

            ServerLogger.Log($"Loading map spawn sets: {entryCount}");

            return(mapSpawns);
        }
Beispiel #2
0
        public static void Initialize()
        {
            var loader = new DataLoader();

            configValues       = loader.LoadServerConfig();
            mapList            = loader.LoadMaps();
            mapConnectorLookup = loader.LoadConnectors(mapList);
            monsterStats       = loader.LoadMonsterStats();
            mapSpawnInfo       = loader.LoadSpawnInfo();
            monsterAiList      = loader.LoadAiStateMachines();

            monsterIdLookup   = new Dictionary <int, MonsterDatabaseInfo>(monsterStats.Count);
            monsterCodeLookup = new Dictionary <string, MonsterDatabaseInfo>(monsterStats.Count);


            foreach (var m in monsterStats)
            {
                monsterIdLookup.Add(m.Id, m);
                monsterCodeLookup.Add(m.Code, m);
            }
        }