Ejemplo n.º 1
0
        public static void SetMapPreview(MapCache mapCache, Control mapWindow, Game game)
        {
            var mapPath   = FileSystem.NormalizeFilePath(mapCache.Name);
            var thumbPath = Path.ChangeExtension(mapPath, ".tga");

            // Set thumbnail
            var thumbTexture = game.AssetStore.GuiTextures.GetByName(thumbPath).Texture;

            mapWindow.Data["MapPreview"] = thumbTexture;

            // Hide all start positions
            for (var i = 0; i < 8; ++i)
            {
                mapWindow.Controls[i].Hide();
            }

            // Set starting positions
            for (var i = 0; i < mapCache.NumPlayers; ++i)
            {
                var startPosCtrl = mapWindow.Controls[i];
                startPosCtrl.Show();

                var relPos = GetRelativePosition(mapCache, i);

                var newPos = new Point2D((int)(relPos.X * mapWindow.Width) - 8, (int)((1.0 - relPos.Y) * mapWindow.Height) - 8);

                startPosCtrl.Bounds = new Rectangle(newPos, new Size(16));
            }
        }
Ejemplo n.º 2
0
        //---------------------------------------------------------------------
        // remove数据
        Task IGrainDCacheSlave.removeFromSlave(string key)
        {
            if (!HaveChild)
            {
                MapCache.Remove(key);
            }
            else
            {
                for (int i = 1; i <= Count; i++)
                {
                    SB.Clear();
                    SB.Append(MasterName);
                    SB.Append("_");
                    SB.Append(GrainDCache.SLAVE_MAP_NAME);
                    SB.Append("_");
                    SB.Append(CurDeep + 1);
                    SB.Append("_");
                    SB.Append(i);
                    var grain_slave = this.GrainFactory.GetGrain <IGrainDCacheSlave>(SB.ToString());
                    grain_slave.removeFromSlave(key);
                }
            }

            return(TaskDone.Done);
        }
Ejemplo n.º 3
0
        public static void CreateNextMenu()
        {
            var mission = game.MenuType;
            var save    = game.Save;

            finishAndLoad(new Game(save, MapCache.FindMap(mission, save), mission, InteractionMode.INGAME));
        }
Ejemplo n.º 4
0
        internal Radar(Scene3D scene, AssetStore assetStore, MapCache mapCache)
        {
            _scene = scene;

            if (mapCache != null)
            {
                var mapPath  = FileSystem.NormalizeFilePath(mapCache.Name);
                var basePath = Path.GetDirectoryName(mapPath) + "/" + Path.GetFileNameWithoutExtension(mapPath);

                // Minimap images drawn by an artist
                var mapArtPath = basePath + "_art.tga";
                _miniMapTexture = assetStore.GuiTextures.GetByName(mapArtPath)?.Texture;

                if (_miniMapTexture == null)
                {
                    // Fallback to minimap images generated by WorldBuilder
                    mapArtPath      = basePath + ".tga";
                    _miniMapTexture = assetStore.GuiTextures.GetByName(mapArtPath)?.Texture;
                }
            }

            _visibleItems = new RadarItemCollection();
            _hiddenItems  = new RadarItemCollection();

            _radarEvents = new List <RadarEvent>();

            // TODO: Bridges
            // TODO: Fog of war / shroud
        }
Ejemplo n.º 5
0
        public static void CreateFirst()
        {
            var mission = MissionType.MAIN_MENU;
            var mode    = InteractionMode.NONE;
            var map     = MapCache.FindMap(mission, 0, Program.SharedRandom);

            if (!string.IsNullOrEmpty(Program.Piece))
            {
                mode    = InteractionMode.INGAME;
                map     = MapType.FromPiece(PieceManager.GetPiece(Program.Piece));
                mission = MissionType.TEST;
            }
            else if (!string.IsNullOrEmpty(Program.MapType))
            {
                mode    = InteractionMode.INGAME;
                map     = MapCache.Types[Program.MapType];
                mission = map.MissionTypes.Length > 0 ? map.MissionTypes[0] : MissionType.TEST;
            }

            if (Program.StartEditor)
            {
                mode = InteractionMode.EDITOR;
            }


            game = new Game(GameSaveManager.DefaultSave.Copy(), map, mission, mode);
            game.Load();
        }
Ejemplo n.º 6
0
        void MapSelect_Load(object sender, EventArgs e)
        {
            MapList.Items.Clear();
            PathOutText.Text = MapFolderPath;

            if (DirectoryIsEmpty(MapFolderPath))
            {
                return;
            }

            foreach (var map in MapCache.FindMapsIn(MapFolderPath))
            {
                ListViewItem map1 = new ListViewItem();
                map1.Tag        = map;
                map1.Text       = Path.GetFileNameWithoutExtension(map);
                map1.ImageIndex = 0;
                MapList.Items.Add(map1);
            }

            // hack
            if (NewText.Text != "unnamed")
            {
                MapList.Items[0].Selected = true;
            }
        }
Ejemplo n.º 7
0
        /*** Functions for loading/checking the different pub/map files ***/

        //tries to load the map that MainPlayer.ActiveCharacter is hanging out on
        private bool _tryLoadMap(int mapID = -1)
        {
            try
            {
                if (mapID < 0)
                {
                    mapID = MainPlayer.ActiveCharacter.CurrentMap;
                }

                string mapFile = Path.Combine("maps", string.Format("{0,5:D5}.emf", mapID));

                if (!MapCache.ContainsKey(mapID))
                {
                    MapCache.Add(mapID, new MapFile(mapFile));
                }
                else
                {
                    MapCache[mapID] = new MapFile(mapFile);
                }

                //map renderer construction moved to be more closely coupled to loading of the map
                (m_mapRender ?? (m_mapRender = new EOMapRenderer(EOGame.Instance, m_api))).SetActiveMap(MapCache[mapID]);
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 8
0
        public static void SetMapPreview(MapCache mapCache, Control mapWindow, Game game)
        {
            var mapPath   = mapCache.Name;
            var basePath  = Path.GetDirectoryName(mapPath) + "\\" + Path.GetFileNameWithoutExtension(mapPath);
            var thumbPath = basePath + ".tga";

            // Set thumbnail
            mapWindow.BackgroundImage = game.ContentManager.WndImageLoader.CreateFileImage(thumbPath);

            // Hide all start positions
            for (int i = 0; i < 8; ++i)
            {
                mapWindow.Controls[i].Hide();
            }

            // Set starting positions
            for (int i = 0; i < mapCache.NumPlayers; ++i)
            {
                var startPosCtrl = mapWindow.Controls[i];
                startPosCtrl.BackgroundImage         = game.ContentManager.WndImageLoader.CreateNormalImage("PlayerStart");
                startPosCtrl.HoverBackgroundImage    = game.ContentManager.WndImageLoader.CreateNormalImage("PlayerStartHilite");
                startPosCtrl.DisabledBackgroundImage = game.ContentManager.WndImageLoader.CreateNormalImage("PlayerStartDisabled");
                startPosCtrl.Show();

                var relPos = GetRelativePosition(mapCache, i);

                var newPos = new Point2D((int)(relPos.X * mapWindow.Width) - 8, (int)((1.0 - relPos.Y) * mapWindow.Height) - 8);

                startPosCtrl.Bounds = new Rectangle(newPos, new Size(16));
            }
        }
Ejemplo n.º 9
0
        /*** Functions for loading/checking the different pub/map files ***/

        //tries to load the map that MainPlayer.ActiveCharacter is hanging out on
        private bool _tryLoadMap(int mapID = -1)
        {
            try
            {
                if (mapID < 0)
                {
                    mapID = MainPlayer.ActiveCharacter.CurrentMap;
                }

                string mapFile = Path.Combine("maps", string.Format("{0,5:D5}.emf", mapID));

                if (!MapCache.ContainsKey(mapID))
                {
                    MapCache.Add(mapID, new MapFile(mapFile));
                }
                else
                {
                    MapCache[mapID] = new MapFile(mapFile);
                }
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 10
0
 public void Reset(ISettings settings, ILogicSettings logicSettings)
 {
     Client = new Client(Settings, ApiFailureStrategy);
     // ferox wants us to set this manually
     Inventory  = new Inventory(Client, logicSettings);
     Navigation = new HumanNavigation(Client);
     MapCache   = new MapCache();
 }
Ejemplo n.º 11
0
        internal static void SetPreviewMap(MapCache mapCache)
        {
            _previewMap = mapCache;

            var mapPreview = _window.Controls.FindControl("LanMapSelectMenu.wnd:WinMapPreview");

            MapUtils.SetMapPreview(mapCache, mapPreview, _game);
        }
Ejemplo n.º 12
0
        //---------------------------------------------------------------------
        // 从Map中获取数据
        Task <byte[]> IGrainDCacheMap.getFromMap(string key)
        {
            byte[] values = null;

            MapCache.TryGetValue(key, out values);

            return(Task.FromResult(values));
        }
Ejemplo n.º 13
0
        public BaseTest()
        {
            HttpContext.Current = new HttpContext(
                new HttpRequest(string.Empty, "http://tempuri.org", string.Empty),
                new HttpResponse(new StringWriter())
                );

            MapCache.Clear();
        }
Ejemplo n.º 14
0
 public void Remap()
 {
     MapCache.Remove(MainPlayer.ActiveCharacter.CurrentMap);
     if (!_tryLoadMap())
     {
         throw new FileLoadException("Unable to load remapped map file!");
     }
     ActiveMapRenderer.SetActiveMap(MapCache[MainPlayer.ActiveCharacter.CurrentMap]);
 }
Ejemplo n.º 15
0
        /// <summary>
        ///     Constructor for expressive model validator.
        /// </summary>
        /// <param name="metadata">The model metadata instance.</param>
        /// <param name="context">The controller context instance.</param>
        /// <param name="attribute">The expressive attribute instance.</param>
        /// <exception cref="System.ComponentModel.DataAnnotations.ValidationException"></exception>
        protected ExpressiveValidator(ModelMetadata metadata, ControllerContext context, T attribute)
            : base(metadata, context, attribute)
        {
            try
            {
                var fieldId = $"{metadata.ContainerType.FullName}.{metadata.PropertyName}".ToLowerInvariant();
                AttributeFullId = $"{attribute.TypeId}.{fieldId}".ToLowerInvariant();
                AttributeWeakId = $"{typeof (T).FullName}.{fieldId}".ToLowerInvariant();
                FieldName       = metadata.PropertyName;

                ResetSuffixAllocation();

                var item = MapCache.GetOrAdd(AttributeFullId, _ => // map cache is based on static dictionary, set-up once for entire application instance
                {                                                  // (by design, no reason to recompile once compiled expressions)
                    var parser = new Parser();
                    parser.RegisterMethods();
                    parser.Parse(metadata.ContainerType, attribute.Expression);

                    FieldsMap  = parser.GetFields().ToDictionary(x => x.Key, x => Helper.GetCoarseType(x.Value));
                    ConstsMap  = parser.GetConsts();
                    ParsersMap = metadata.ContainerType.GetProperties()
                                 .Where(p => FieldsMap.Keys.Contains(p.Name) || metadata.PropertyName == p.Name) // narrow down number of parsers sent to client
                                 .Select(p => new
                    {
                        PropertyName    = p.Name,
                        ParserAttribute = p.GetAttributes <ValueParserAttribute>().SingleOrDefault()
                    }).Where(x => x.ParserAttribute != null)
                                 .ToDictionary(x => x.PropertyName, x => x.ParserAttribute.ParserName);

                    AssertNoNamingCollisionsAtCorrespondingSegments();
                    attribute.Compile(metadata.ContainerType); // compile expressions in attributes (to be cached for subsequent invocations)

                    return(new CacheItem
                    {
                        FieldsMap = FieldsMap,
                        ConstsMap = ConstsMap,
                        ParsersMap = ParsersMap
                    });
                });

                FieldsMap  = item.FieldsMap;
                ConstsMap  = item.ConstsMap;
                ParsersMap = item.ParsersMap;

                Expression = attribute.Expression;

                IDictionary <string, Guid> errFieldsMap;
                FormattedErrorMessage = attribute.FormatErrorMessage(metadata.GetDisplayName(), attribute.Expression, metadata.ContainerType, out errFieldsMap); // fields names, in contrast to values, do not change in runtime, so will be provided in message (less code in js)
                ErrFieldsMap          = errFieldsMap;
            }
            catch (Exception e)
            {
                throw new ValidationException(
                          $"{GetType().Name}: validation applied to {metadata.PropertyName} field failed.", e);
            }
        }
Ejemplo n.º 16
0
 public MapPreview(string uid, MapCache cache)
 {
     this.cache = cache;
     Uid = uid;
     Title = "Unknown Map";
     Type = "Unknown";
     Author = "Unknown Author";
     PlayerCount = 0;
     Bounds = Rectangle.Empty;
     SpawnPoints = NoSpawns;
     Status = MapStatus.Unavailable;
     Class = MapClassification.Unknown;
 }
Ejemplo n.º 17
0
        public static MapNode GetMapNode(this Entity entity)
        {
            Location location = entity.GetComponent <Location>();

            if (location == null)
            {
                return(null);
            }

            MapCache maps = WorldCache.GetCache(entity.EntityWorld).Maps;
            Map      map  = maps[location.Map];

            return(map[location.Position]);
        }
Ejemplo n.º 18
0
        public void Remap()
        {
            MapCache.Remove(MainPlayer.ActiveCharacter.CurrentMap);
            if (!_tryLoadMap(-1, true))
            {
                EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu();
                return;
            }

            EOGame.Instance.Hud.AddChat(ChatTab.Local, GetString(EOResourceID.STRING_SERVER), GetString(EOResourceID.SERVER_MESSAGE_MAP_MUTATION), ChatIcon.Exclamation, ChatColor.Server);
            EOGame.Instance.Hud.AddChat(ChatTab.System, GetString(EOResourceID.STRING_SERVER), GetString(EOResourceID.SERVER_MESSAGE_MAP_MUTATION), ChatIcon.Exclamation, ChatColor.Server);

            ActiveMapRenderer.SetActiveMap(MapCache[MainPlayer.ActiveCharacter.CurrentMap]);
        }
Ejemplo n.º 19
0
        public void SetCurrentMap(MapCache mapCache)
        {
            CurrentMap = mapCache;

            var mapWindow = _window.Controls.FindControl(_optionsPath + ":MapWindow");

            MapUtils.SetMapPreview(mapCache, mapWindow, _game);

            // Set map text
            var textEntryMap = _window.Controls.FindControl(_optionsPath + ":TextEntryMapDisplay");
            var mapKey       = mapCache.GetNameKey();

            textEntryMap.Text = mapKey.Translate();
        }
    private List <Gardarike.GetWorldMapResponse> GetServerChunks(int x, int y)
    {
        var chunks = new List <Gardarike.GetWorldMapResponse>();

        for (int i = -1; i < 2; i++)
        {
            for (int j = -1; j < 2; j++)
            {
                chunks.Add(MapCache.GetGlobalChunk(x + i, y + j));
            }
        }

        return(chunks);
    }
Ejemplo n.º 21
0
        public ModData(string mod, bool useLoadScreen = false)
        {
            Languages = new string[0];
            Manifest = new Manifest(mod);
            ObjectCreator = new ObjectCreator(Manifest);
            Manifest.LoadCustomData(ObjectCreator);

            if (useLoadScreen)
            {
                LoadScreen = ObjectCreator.CreateObject<ILoadScreen>(Manifest.LoadScreen.Value);
                LoadScreen.Init(Manifest, Manifest.LoadScreen.ToDictionary(my => my.Value));
                LoadScreen.Display();
            }

            WidgetLoader = new WidgetLoader(this);
            RulesetCache = new RulesetCache(this);
            RulesetCache.LoadingProgress += HandleLoadingProgress;
            MapCache = new MapCache(this);

            var spriteLoaders = new List<ISpriteLoader>();
            foreach (var format in Manifest.SpriteFormats)
            {
                var loader = ObjectCreator.FindType(format + "Loader");
                if (loader == null || !loader.GetInterfaces().Contains(typeof(ISpriteLoader)))
                    throw new InvalidOperationException("Unable to find a sprite loader for type '{0}'.".F(format));

                spriteLoaders.Add((ISpriteLoader)ObjectCreator.CreateBasic(loader));
            }

            SpriteLoaders = spriteLoaders.ToArray();

            var sequenceFormat = Manifest.Get<SpriteSequenceFormat>();
            var sequenceLoader = ObjectCreator.FindType(sequenceFormat.Type + "Loader");
            var ctor = sequenceLoader != null ? sequenceLoader.GetConstructor(new[] { typeof(ModData) }) : null;
            if (sequenceLoader == null || !sequenceLoader.GetInterfaces().Contains(typeof(ISpriteSequenceLoader)) || ctor == null)
                throw new InvalidOperationException("Unable to find a sequence loader for type '{0}'.".F(sequenceFormat.Type));

            SpriteSequenceLoader = (ISpriteSequenceLoader)ctor.Invoke(new[] { this });
            SpriteSequenceLoader.OnMissingSpriteError = s => Log.Write("debug", s);

            // HACK: Mount only local folders so we have a half-working environment for the asset installer
            GlobalFileSystem.UnmountAll();
            foreach (var dir in Manifest.Folders)
                GlobalFileSystem.Mount(dir);

            defaultRules = Exts.Lazy(() => RulesetCache.Load());

            initialThreadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
        }
Ejemplo n.º 22
0
        //---------------------------------------------------------------------
        public override Task OnDeactivateAsync()
        {
            if (MapCache != null)
            {
                MapCache.Clear();
                MapCache = null;
            }

            if (Random != null)
            {
                Random = null;
            }

            return(base.OnDeactivateAsync());
        }
Ejemplo n.º 23
0
    private void ProcessMapChunk(GetWorldMapResponse chunkInfo)
    {
        Debug.Log("Processing map chunk...");

        Debug.Log("Towns on the chunk: " + chunkInfo.Map.Towns.Count);
        Debug.Log("Trees on chank: " + chunkInfo.Map.Trees);
        Debug.Log("Plants on chank: " + chunkInfo.Map.Plants);
        Debug.Log("Stones on chank: " + chunkInfo.Map.Stones);

        PlayerPrefs.SetString("View", "Global");

        MapCache.StoreWorldChunk(chunkInfo);
        var heights = ProtoConverter.ToHeightsFromProto(chunkInfo.Map.Data);

        EventBus.instance.TerrainLoaded(heights, chunkInfo.Map.X, chunkInfo.Map.Y);
    }
Ejemplo n.º 24
0
        //---------------------------------------------------------------------
        public override Task OnDeactivateAsync()
        {
            if (MapCache != null)
            {
                MapCache.Clear();
                MapCache = null;
            }

            if (SB != null)
            {
                SB.Clear();
                SB = null;
            }

            return(base.OnDeactivateAsync());
        }
Ejemplo n.º 25
0
        public static void CreateNew(GameSave save, MissionType type = MissionType.NORMAL, InteractionMode mode = InteractionMode.INGAME, MapType custom = null, bool loadStatsMap = false)
        {
            if (loadStatsMap)
            {
                type = save.CurrentMission;
                try
                {
                    custom = MapType.FromSave(save);
                }
                catch (System.IO.FileNotFoundException)
                {
                    Log.Warning($"Unable to load saved map of save '{save.SaveName}'. Using a random map.");
                }
            }

            finishAndLoad(new Game(save, custom ?? MapCache.FindMap(type, save.Level, new Random(save.Seed + save.Level)), type, mode));
        }
Ejemplo n.º 26
0
        public void SetCurrentMap(MapCache mapCache)
        {
            _game.SkirmishManager.Settings.MapName = mapCache.Name;

            Logger.Info("Set current map to " + mapCache.Name);

            CurrentMap = mapCache;

            var mapWindow = _window.Controls.FindControl(_optionsPath + MapWindow);

            MapUtils.SetMapPreview(mapCache, mapWindow, _game);

            // Set map text
            var textEntryMap = _window.Controls.FindControl(_optionsPath + ":TextEntryMapDisplay");
            var mapKey       = mapCache.GetNameKey();

            textEntryMap.Text = mapKey.Translate();
        }
Ejemplo n.º 27
0
        public void ResetGameElements()
        {
            if (m_mapRender != null)
            {
                m_mapRender.Dispose();
                m_mapRender = null;
            }

            if (m_charRender != null)
            {
                m_charRender.Dispose();
                m_charRender = null;
            }

            if (MapCache != null)
            {
                MapCache.Clear();
            }
        }
Ejemplo n.º 28
0
        private static Vector2 GetRelativePosition(MapCache cache, int playerIndex)
        {
            var startPos = Vector3.Zero;

            switch (playerIndex)
            {
            case 0:
                startPos = cache.Player1Start;
                break;

            case 1:
                startPos = cache.Player2Start;
                break;

            case 2:
                startPos = cache.Player3Start;
                break;

            case 3:
                startPos = cache.Player4Start;
                break;

            case 4:
                startPos = cache.Player5Start;
                break;

            case 5:
                startPos = cache.Player6Start;
                break;

            case 6:
                startPos = cache.Player7Start;
                break;

            case 7:
                startPos = cache.Player8Start;
                break;
            }

            var relPos = startPos / cache.ExtentMax;

            return(new Vector2(relPos.X, relPos.Y));
        }
    private void FillChunksToLoadAndLoaded(int x, int y)
    {
        chunksToLoad.Clear();
        loadedChunks.Clear();

        for (int i = -1; i < 2; i++)
        {
            for (int j = -1; j < 2; j++)
            {
                var miss = MapCache.ChunkIsMissing(j + x, i + y, true);
                if (miss)
                {
                    chunksToLoad.Add(new Vector2Int(j + x, i + y));
                }
                else
                {
                    loadedChunks.Add(new Vector2Int(j + x, i + y));
                }
            }
        }
    }
Ejemplo n.º 30
0
        private static void RecalculateUserScores(int userId, int totalUsers)
        {
            Logger.Log($"Recalculating scores for user: {userId}...");

            var scores = FetchUserScores(userId);
            var sum    = 0;

            Parallel.ForEach(scores, score =>
            {
                var map = MapCache.Fetch(score.MapId);

                if (map == null)
                {
                    Console.WriteLine($"Skipping score: {score}. Failed to retrieve map!");
                    return;
                }

                var diff   = map.SolveDifficulty(score.Mods, true);
                var rating = new RatingProcessorKeys(diff.OverallDifficulty).CalculateRating(score.Accuracy);

                using var conn = new MySqlConnection(SqlDatabase.GetConnString(Configuration.Instance));
                using (var cmd = conn.CreateCommand())
                {
                    conn.Open();
                    cmd.CommandText = "UPDATE scores SET performance_rating = @r, difficulty_processor_version = @d, " +
                                      "performance_processor_version = @p " +
                                      "WHERE id = @i";

                    cmd.Parameters.AddWithValue("@r", rating);
                    cmd.Parameters.AddWithValue("@d", DifficultyProcessorKeys.Version);
                    cmd.Parameters.AddWithValue("@p", RatingProcessorKeys.Version);
                    cmd.Parameters.AddWithValue("@i", score.Id);

                    cmd.ExecuteNonQuery();
                }

                sum++;
                Console.WriteLine($"[{userId}/{totalUsers}] [{(float)sum / scores.Count:0.00%}%] #{score.Id} -> {rating}");
            });
        }
Ejemplo n.º 31
0
        public bool CheckMap(short mapID, byte[] mapRid, int mapFileSize)
        {
            NeedMap = -1;

            string mapFile = string.Format("maps\\{0,5:D5}.emf", mapID);

            if (!Directory.Exists("maps") || !File.Exists(mapFile))
            {
                Directory.CreateDirectory("maps");
                NeedMap = mapID;
                return(false);
            }

            //try to load the map if it isn't cached. on failure, set needmap
            if (!MapCache.ContainsKey(mapID))
            {
                NeedMap = _tryLoadMap(mapID) ? -1 : mapID;
            }

            //on success of file load, check the rid and the size of the file
            if (MapCache.ContainsKey(mapID))
            {
                for (int i = 0; i < 4; ++i)
                {
                    if (MapCache[mapID].Rid[i] != mapRid[i])
                    {
                        NeedMap = mapID;
                        break;
                    }
                }

                if (NeedMap == -1 && MapCache[mapID].FileSize != mapFileSize)
                {
                    NeedMap = mapID;
                }
            }

            //return true if the map is not needed
            return(NeedMap == -1);
        }
Ejemplo n.º 32
0
        private static void RecalculateMap(int id)
        {
            var map = MapCache.Fetch(id);

            if (map == null)
            {
                Console.WriteLine($"Could not fetch map: {id}");
                return;
            }

            var diff = map.SolveDifficulty().OverallDifficulty;

            using var conn = new MySqlConnection(SqlDatabase.GetConnString(Configuration.Instance));
            using var cmd  = conn.CreateCommand();
            conn.Open();
            cmd.CommandText = "UPDATE maps SET difficulty_rating = @d WHERE id = @i";
            cmd.Parameters.AddWithValue("@d", diff);
            cmd.Parameters.AddWithValue("@i", id);
            cmd.ExecuteNonQuery();

            Console.WriteLine($"#{id} -> {diff}");
        }
Ejemplo n.º 33
0
        public ModData(string mod)
        {
            Languages = new string[0];
            Manifest = new Manifest(mod);
            ObjectCreator = new ObjectCreator(Manifest);
            LoadScreen = ObjectCreator.CreateObject<ILoadScreen>(Manifest.LoadScreen.Value);
            LoadScreen.Init(Manifest, Manifest.LoadScreen.NodesDict.ToDictionary(x => x.Key, x => x.Value.Value));
            LoadScreen.Display();
            WidgetLoader = new WidgetLoader(this);
            RulesetCache = new RulesetCache(this);
            RulesetCache.LoadingProgress += HandleLoadingProgress;
            MapCache = new MapCache(this);

            // HACK: Mount only local folders so we have a half-working environment for the asset installer
            GlobalFileSystem.UnmountAll();
            foreach (var dir in Manifest.Folders)
                GlobalFileSystem.Mount(dir);

            defaultRules = Exts.Lazy(() => RulesetCache.LoadDefaultRules());

            initialThreadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
        }
Ejemplo n.º 34
0
        public MapPreview(ModData modData, string uid, MapGridType gridType, MapCache cache)
        {
            this.cache = cache;
            this.modData = modData;

            Uid = uid;
            innerData = new InnerData
            {
                Title = "Unknown Map",
                Categories = new[] { "Unknown" },
                Author = "Unknown Author",
                TileSet = "unknown",
                Players = null,
                PlayerCount = 0,
                SpawnPoints = NoSpawns,
                GridType = gridType,
                Bounds = Rectangle.Empty,
                Preview = null,
                Status = MapStatus.Unavailable,
                Class = MapClassification.Unknown,
                Visibility = MapVisibility.Lobby,
            };
        }