Exemplo n.º 1
0
        /// <inheritdoc />
        public void Load()
        {
            var worldsPaths = new Dictionary <string, string>();

            using (var textFile = new TextFile(GameResources.WorldScriptPath))
            {
                foreach (var text in textFile.Texts)
                {
                    worldsPaths.Add(text.Key, text.Value.Replace('"', ' ').Trim());
                }
            }

            foreach (string mapDefineName in this._worldConfiguration.Maps)
            {
                if (!worldsPaths.TryGetValue(mapDefineName, out string mapName))
                {
                    this._logger.LogWarning(GameResources.UnableLoadMapMessage, mapDefineName, $"map is not declared inside '{GameResources.WorldScriptPath}' file");
                    continue;
                }

                if (!this._defines.Defines.TryGetValue(mapDefineName, out int mapId))
                {
                    this._logger.LogWarning(GameResources.UnableLoadMapMessage, mapDefineName, $"map has no define id inside '{GameResources.DataSub0Path}/defineWorld.h' file");
                    continue;
                }

                if (_maps.ContainsKey(mapId))
                {
                    this._logger.LogWarning(GameResources.UnableLoadMapMessage, mapDefineName, $"another map with id '{mapId}' already exist.");
                    continue;
                }

                IMapInstance map = MapInstance.Create(Path.Combine(GameResources.MapsPath, mapName), mapName, mapId);

                _maps.Add(mapId, map);
                map.StartUpdateTask(50);
            }

            this._logger.LogInformation("-> {0} maps loaded.", _maps.Count);
        }