Esempio n. 1
0
        public Sprite GetMinimap()
        {
            if (minimap != null)
            {
                return(minimap);
            }

            if (!generatingMinimap && Status == MapStatus.Available)
            {
                generatingMinimap = true;
                cache.CacheMinimap(this);
            }

            return(null);
        }
Esempio n. 2
0
        public void UpdateRemoteSearch(MapStatus status, MiniYaml yaml)
        {
            // Update on the main thread to ensure consistency
            Game.RunAfterTick(() =>
            {
                if (status == MapStatus.DownloadAvailable)
                {
                    try
                    {
                        var r = FieldLoader.Load <RemoteMapData>(yaml);

                        // Map download has been disabled server side
                        if (!r.downloading)
                        {
                            Status = MapStatus.Unavailable;
                            return;
                        }

                        // Map is not useable by the current version
                        if (r.requires_upgrade)
                        {
                            RuleStatus = MapRuleStatus.Invalid;
                        }
                        else
                        {
                            RuleStatus = MapRuleStatus.Unknown;
                        }

                        Title       = r.title;
                        Type        = r.map_type;
                        Author      = r.author;
                        PlayerCount = r.players;
                        Bounds      = r.bounds;

                        var spawns = new List <CPos>();
                        for (var j = 0; j < r.spawnpoints.Length; j += 2)
                        {
                            spawns.Add(new CPos(r.spawnpoints[j], r.spawnpoints[j + 1]));
                        }
                        SpawnPoints = spawns;

                        CustomPreview = new Bitmap(new MemoryStream(Convert.FromBase64String(r.minimap)));
                    }
                    catch (Exception) {}

                    if (CustomPreview != null)
                    {
                        cache.CacheMinimap(this);
                    }
                }

                Status = status;
                Class  = MapClassification.Remote;
            });
        }