Example #1
0
    private void LoadScenario(PublishedFileId_t item)
    {
        SteamUGC.GetItemInstallInfo(item, out ulong punSizeOnDisk, out string pchFolder, 1024u, out uint punTimeStamp);
        DebugUtil.LogArgs("LoadScenario", pchFolder, punSizeOnDisk, punTimeStamp);
        System.DateTime lastModified;
        byte[]          bytesFromZip = SteamUGCService.GetBytesFromZip(item, new string[1]
        {
            ".sav"
        }, out lastModified, false);
        string text = Path.Combine(SaveLoader.GetSavePrefix(), "scenario.sav");

        File.WriteAllBytes(text, bytesFromZip);
        SaveLoader.SetActiveSaveFilePath(text);
        Time.timeScale = 0f;
        App.LoadScene("backend");
    }
Example #2
0
 private static string GetLanguageFileFromSteam(PublishedFileId_t item, out System.DateTime lastModified)
 {
     lastModified = System.DateTime.MinValue;
     if (item == PublishedFileId_t.Invalid)
     {
         Debug.LogWarning("Cant get INVALID file id from Steam");
         return(null);
     }
     SteamUGCService.Mod mod = SteamUGCService.Instance.FindMod(item);
     if (mod == null)
     {
         Debug.LogWarning("Mod is not in published list");
         return(null);
     }
     byte[] bytesFromZip = SteamUGCService.GetBytesFromZip(item, poFile, out lastModified, false);
     if (bytesFromZip == null || bytesFromZip.Length == 0)
     {
         Debug.LogWarning("Failed to read from Steam mod installation");
         return(null);
     }
     return(Encoding.UTF8.GetString(bytesFromZip));
 }
        /// <summary>
        /// Tries to load the preview image directly from the mod zip if unavailable.
        /// </summary>
        /// <param name="id">The mod ID to load.</param>
        /// <param name="rawData">The preview image data downloaded from Steam, or null if the Steam download failed.</param>
        private void TryLoadPreview(PublishedFileId_t id, byte[] rawData)
        {
            var mod = SteamUGCServiceFixed.Instance.GetInfo(id);

            if (rawData == null)
            {
                rawData = SteamUGCService.GetBytesFromZip(id, PREVIEW_FILE_NAMES, out _);
            }
            if (rawData != null)
            {
                if (mod != null)
                {
                    var texture = new Texture2D(1, 1);
                    texture.LoadImage(rawData);
                    mod.Enhance(texture);
                }
            }
            else
            {
#if DEBUG
                PUtil.LogWarning("Failed to download preview: {0:D}".F(id.m_PublishedFileId));
#endif
            }
        }