コード例 #1
0
ファイル: SaveHelpers.cs プロジェクト: kaenganxt/Tango
        /// <summary>
        ///     Load the world byte array sent by the server
        /// </summary>
        public static void LoadLevel(byte[] world)
        {
            Log.Info($"Preparing to load world (of size {world.Length})...");

            // Load the package
            Package package = new Package(SYNC_NAME, world);

            // Ensure that the LoadingManager is ready.
            // Don't know if thats really necessary but doesn't hurt either. - root#0042
            Singleton <LoadingManager> .Ensure();

            // Get the meta data
            Package.Asset    asset    = package.Find(package.packageMainAsset);
            SaveGameMetaData metaData = asset.Instantiate <SaveGameMetaData>();

            // Build the simulation
            SimulationMetaData simulation = new SimulationMetaData()
            {
                m_CityName    = metaData.cityName,
                m_updateMode  = SimulationManager.UpdateMode.LoadGame,
                m_environment = UIView.GetAView().panelsLibrary.Get <LoadPanel>("LoadPanel").m_forceEnvironment
            };

            // Load the level
            Log.Info("Telling the loading manager to load the level");
            Singleton <LoadingManager> .instance.LoadLevel(metaData.assetRef, "Game", "InGame", simulation, false);
        }
コード例 #2
0
ファイル: Mod.cs プロジェクト: devenlil/Skylines-Multiplayer
        public static SaveGameMetaData GetMetaDataForDateTime(DateTime needle)
        {
            SaveGameMetaData result = null;

            foreach (Package.Asset current in PackageManager.FilterAssets(new Package.AssetType[]
            {
                UserAssetType.SaveGameMetaData
            }))
            {
                if (current != null && current.isEnabled)
                {
                    SaveGameMetaData saveGameMetaData = current.Instantiate <SaveGameMetaData>();
                    if (saveGameMetaData != null)
                    {
                        try
                        {
                            Stream             s         = saveGameMetaData.assetRef.GetStream();
                            SimulationMetaData mysimmeta = DataSerializer.Deserialize <SimulationMetaData>(s,
                                                                                                           DataSerializer.Mode.File);
                            if (mysimmeta.m_currentDateTime.Equals(needle))
                            {
                                return(saveGameMetaData);
                            }
                        }
                        catch (Exception ex)
                        {
                            ex.ToString();
                        }
                    }
                }
            }
            return(result);
        }
コード例 #3
0
        public SaveGameRowStruct(Package.Asset asset, SaveGameMetaData sgmd)
        {
            SaveName      = asset.name;
            CityName      = sgmd.cityName;
            SaveTimestamp = sgmd.timeStamp;
            PathOnDisk    = asset.pathOnDisk;

            saveMeta = sgmd;

            if (saveMeta != null && saveMeta.assetRef != null && saveMeta.assetRef.package != null && PackageManager.IsSteamCloudPath(saveMeta.assetRef.package.packagePath))
            {
                IsSteam = true;
            }
        }
コード例 #4
0
        void StartGame(Package.Asset package)
        {
            m_connectionInfoLabel.text = "Game Starting";

            SaveGameMetaData mmd = package.Instantiate <SaveGameMetaData>();

            SavePanel.lastLoadedName = package.name;
            Debug.Log(mmd.cityName);
            SimulationMetaData ngs = new SimulationMetaData
            {
                m_CityName            = mmd.cityName,
                m_updateMode          = SimulationManager.UpdateMode.LoadGame,
                m_environment         = "",
                m_disableAchievements = SimulationMetaData.MetaBool.True
            };

            Singleton <LoadingManager> .instance.LoadLevel(mmd.assetRef, "Game", "InGame", ngs);
        }
コード例 #5
0
        private void StartGame(Package.Asset package)
        {
            ConnectSettings.Ip   = m_serverList[m_selectedIndex]["ip"];
            ConnectSettings.Port = int.Parse(m_serverList[m_selectedIndex]["port"]);

            SaveGameMetaData mmd = package.Instantiate <SaveGameMetaData>();

            SavePanel.lastLoadedName = package.name;

            SimulationMetaData ngs = new SimulationMetaData
            {
                m_CityName            = mmd.cityName,
                m_updateMode          = SimulationManager.UpdateMode.LoadGame,
                m_environment         = "",
                m_disableAchievements = SimulationMetaData.MetaBool.True
            };

            Singleton <LoadingManager> .instance.LoadLevel(mmd.assetRef, "Game", "InGame", ngs);
        }
コード例 #6
0
        public void LoadSaveInformation()
        {
            GamesList.Clear();

            Package.AssetType[] assetTypeArray = new Package.AssetType[1];
            int index = 0;

            Package.AssetType assetType = UserAssetType.SaveGameMetaData;
            assetTypeArray[index] = assetType;
            foreach (Package.Asset asset in PackageManager.FilterAssets(assetTypeArray))
            {
                if (asset != (Package.Asset)null && asset.isEnabled)
                {
                    SaveGameMetaData mmd = asset.Instantiate <SaveGameMetaData>();

                    GamesList.Add(new SaveGameRowStruct(asset, mmd));
                }
            }
            using (List <Package.Asset> .Enumerator enumerator = SaveHelper.GetSavesOnDisk().GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Package.Asset    current          = enumerator.Current;
                    SaveGameMetaData saveGameMetaData = new SaveGameMetaData();
                    saveGameMetaData.assetRef = current;
                    SaveGameMetaData mmd = saveGameMetaData;

                    GamesList.Add(new SaveGameRowStruct(current, mmd));
                }
            }

            //this.m_SaveList.items = this.GetListingItems();
            //if (this.m_SaveList.items.Length > 0)
            //{
            //   int indexOf = this.FindIndexOf(LoadPanel.m_LastSaveName);
            //   this.m_SaveList.selectedIndex = indexOf == -1 ? 0 : indexOf;
            //   this.m_LoadButton.isEnabled = true;
            //}
            //else
            //   this.m_LoadButton.isEnabled = false;
        }
コード例 #7
0
        public void LaunchRowObject(UIComponent component)
        {
            UIPanel panel = component as UIPanel;

            if (panel != null)
            {
                SaveGameRowStruct sgrs = panel.objectUserData as SaveGameRowStruct;

                if (sgrs != null)
                {
                    if (SavePanel.isSaving || !Singleton <LoadingManager> .exists || Singleton <LoadingManager> .instance.m_currentlyLoading)
                    {
                        return;
                    }

                    //this.CloseEverything();
                    WorldInfoPanel.HideAllWorldInfoPanels();

                    SaveGameMetaData listingMetaData = sgrs.saveMeta;          // this.GetListingMetaData(this.m_SaveList.selectedIndex);
                    Package.Asset    listingData     = sgrs.saveMeta.assetRef; // this.GetListingData(this.m_SaveList.selectedIndex);

                    SimulationMetaData ngs = new SimulationMetaData()
                    {
                        m_CityName   = listingMetaData.cityName,
                        m_updateMode = SimulationManager.UpdateMode.LoadGame //,
                                                                             //m_environment = this.m_forceEnvironment
                    };

                    if (Singleton <PluginManager> .instance.enabledModCount > 0 || listingData.package.GetPublishedFileID() != PublishedFileId.invalid)
                    {
                        ngs.m_disableAchievements = SimulationMetaData.MetaBool.True;
                    }

                    Singleton <LoadingManager> .instance.LoadLevel(listingData, "Game", "InGame", ngs);

                    //UIView.library.Hide(this.GetType().Name, 1);
                    ParentBetterLoadPanelWrapper.Hide();
                }
            }
        }