示例#1
0
 public static void Initialize()
 {
     Log.Information($"Survivalcraft starting up at {DateTime.Now}, Version={VersionsManager.Version}, BuildConfiguration={VersionsManager.BuildConfiguration}, Platform={VersionsManager.Platform}, DeviceModel={DeviceManager.DeviceModel}, OSVersion={DeviceManager.OperatingSystemVersion}, Storage.AvailableFreeSpace={Storage.FreeSpace / 1024 / 1024}MB, ApproximateScreenDpi={ScreenResolutionManager.ApproximateScreenDpi:0.0}, ApproxScreenInches={ScreenResolutionManager.ApproximateScreenInches:0.0}, ScreenResolution={Window.Size}, ProcessorsCount={Environment.ProcessorCount}, RAM={Utilities.GetTotalAvailableMemory() / 1024 / 1024}MB, 64bit={Marshal.SizeOf<IntPtr>() == 8}");
     MarketplaceManager.Initialize();
     SettingsManager.Initialize();
     AnalyticsManager.Initialize();
     VersionsManager.Initialize();
     ExternalContentManager.Initialize();
     ContentManager.Initialize();
     ScreensManager.Initialize();
 }
示例#2
0
 public static void LoadProject(WorldInfo worldInfo, ContainerWidget gamesWidget)
 {
     DisposeProject();
     WorldsManager.RepairWorldIfNeeded(worldInfo.DirectoryName);
     VersionsManager.UpgradeWorld(worldInfo.DirectoryName);
     using (Stream stream = Storage.OpenFile(Storage.CombinePaths(worldInfo.DirectoryName, "Project.xml"), OpenFileMode.Read))
     {
         ValuesDictionary valuesDictionary  = new ValuesDictionary();
         ValuesDictionary valuesDictionary2 = new ValuesDictionary();
         valuesDictionary.SetValue("GameInfo", valuesDictionary2);
         valuesDictionary2.SetValue("WorldDirectoryName", worldInfo.DirectoryName);
         ValuesDictionary valuesDictionary3 = new ValuesDictionary();
         valuesDictionary.SetValue("Views", valuesDictionary3);
         valuesDictionary3.SetValue("GamesWidget", gamesWidget);
         XElement    projectNode = XmlUtils.LoadXmlFromStream(stream, null, throwOnError: true);
         ProjectData projectData = new ProjectData(DatabaseManager.GameDatabase, projectNode, valuesDictionary, ignoreInvalidEntities: true);
         m_project         = new Project(DatabaseManager.GameDatabase, projectData);
         m_subsystemUpdate = m_project.FindSubsystem <SubsystemUpdate>(throwOnError: true);
     }
     m_worldInfo = worldInfo;
     Log.Information("Loaded world, GameMode={0}, StartingPosition={1}, WorldName={2}, VisibilityRange={3}, Resolution={4}", worldInfo.WorldSettings.GameMode, worldInfo.WorldSettings.StartingPositionMode, worldInfo.WorldSettings.Name, SettingsManager.VisibilityRange.ToString(), SettingsManager.ResolutionMode.ToString());
     AnalyticsManager.LogEvent("[GameManager] Loaded world", new AnalyticsParameter("GameMode", worldInfo.WorldSettings.GameMode.ToString()), new AnalyticsParameter("EnvironmentBehaviorMode", worldInfo.WorldSettings.EnvironmentBehaviorMode.ToString()), new AnalyticsParameter("TerrainGenerationMode", worldInfo.WorldSettings.TerrainGenerationMode.ToString()), new AnalyticsParameter("WorldDirectory", worldInfo.DirectoryName), new AnalyticsParameter("WorldName", worldInfo.WorldSettings.Name), new AnalyticsParameter("WorldSeedString", worldInfo.WorldSettings.Seed), new AnalyticsParameter("VisibilityRange", SettingsManager.VisibilityRange.ToString()), new AnalyticsParameter("Resolution", SettingsManager.ResolutionMode.ToString()));
     GC.Collect();
 }
示例#3
0
        public static WorldInfo GetWorldInfo(string directoryName)
        {
            WorldInfo worldInfo = new WorldInfo();

            worldInfo.DirectoryName = directoryName;
            worldInfo.LastSaveTime  = DateTime.MinValue;
            List <string> list = new List <string>();

            RecursiveEnumerateDirectory(directoryName, list, null, null);
            if (list.Count > 0)
            {
                foreach (string item in list)
                {
                    DateTime fileLastWriteTime = Storage.GetFileLastWriteTime(item);
                    if (fileLastWriteTime > worldInfo.LastSaveTime)
                    {
                        worldInfo.LastSaveTime = fileLastWriteTime;
                    }
                    try
                    {
                        worldInfo.Size += Storage.GetFileSize(item);
                    }
                    catch (Exception e2)
                    {
                        Log.Error(ExceptionManager.MakeFullErrorMessage($"Error getting size of file \"{item}\".", e2));
                    }
                }
                string text = Storage.CombinePaths(directoryName, "Project.xml");
                try
                {
                    if (Storage.FileExists(text))
                    {
                        using (Stream stream = Storage.OpenFile(text, OpenFileMode.Read))
                        {
                            XElement xElement = XmlUtils.LoadXmlFromStream(stream, null, throwOnError: true);
                            worldInfo.SerializationVersion = XmlUtils.GetAttributeValue(xElement, "Version", "1.0");
                            VersionsManager.UpgradeProjectXml(xElement);
                            XElement         gameInfoNode     = GetGameInfoNode(xElement);
                            ValuesDictionary valuesDictionary = new ValuesDictionary();
                            valuesDictionary.ApplyOverrides(gameInfoNode);
                            worldInfo.WorldSettings.Load(valuesDictionary);
                            foreach (XElement item2 in (from e in GetPlayersNode(xElement).Elements()
                                                        where XmlUtils.GetAttributeValue <string>(e, "Name") == "Players"
                                                        select e).First().Elements())
                            {
                                PlayerInfo playerInfo = new PlayerInfo();
                                worldInfo.PlayerInfos.Add(playerInfo);
                                XElement xElement2 = (from e in item2.Elements()
                                                      where XmlUtils.GetAttributeValue(e, "Name", string.Empty) == "CharacterSkinName"
                                                      select e).FirstOrDefault();
                                if (xElement2 != null)
                                {
                                    playerInfo.CharacterSkinName = XmlUtils.GetAttributeValue(xElement2, "Value", string.Empty);
                                }
                            }
                            return(worldInfo);
                        }
                    }
                    return(worldInfo);
                }
                catch (Exception e3)
                {
                    Log.Error(ExceptionManager.MakeFullErrorMessage($"Error getting data from project file \"{text}\".", e3));
                    return(worldInfo);
                }
            }
            return(null);
        }
示例#4
0
 public static void Initialize()
 {
     VisibilityRange       = 128;
     m_resolutionMode      = ResolutionMode.High;
     ViewAngleMode         = ViewAngleMode.Normal;
     SkyRenderingMode      = SkyRenderingMode.Full;
     TerrainMipmapsEnabled = false;
     ObjectsShadowsEnabled = true;
     m_soundsVolume        = 0.5f;
     m_musicVolume         = 0.5f;
     m_brightness          = 0.5f;
     PresentationInterval  = 1;
     ShowGuiInScreenshots  = false;
     ShowLogoInScreenshots = true;
     ScreenshotSize        = ScreenshotSize.ScreenSize;
     MoveControlMode       = MoveControlMode.Pad;
     HideMoveLookPads      = false;
     BlocksTextureFileName = string.Empty;
     LookControlMode       = LookControlMode.EntireScreen;
     FlipVerticalAxis      = false;
     MoveSensitivity       = 0.5f;
     LookSensitivity       = 0.5f;
     GamepadDeadZone       = 0.16f;
     GamepadCursorSpeed    = 1f;
     CreativeDigTime       = 0.2f;
     CreativeReach         = 7.5f;
     MinimumHoldDuration   = 0.5f;
     MinimumDragDistance   = 10f;
     AutoJump = true;
     HorizontalCreativeFlight = false;
     DropboxAccessToken       = string.Empty;
     ScpboxAccessToken        = string.Empty;
     MotdUpdateUrl            = "https://scmod.aijiajia.xyz/com/motd?v={0}&l={1}";
     MotdBackupUpdateUrl      = "https://scmod.aijiajia.xyz/com/motd?v={0}&l={1}";
     MotdUpdatePeriodHours    = 12.0;
     MotdLastUpdateTime       = DateTime.MinValue;
     MotdLastDownloadedData   = string.Empty;
     UserId = string.Empty;
     LastLaunchedVersion        = string.Empty;
     CommunityContentMode       = CommunityContentMode.Normal;
     MultithreadedTerrainUpdate = true;
     NewYearCelebrationLastYear = 2020;
     ScreenLayout1 = ScreenLayout.Single;
     ScreenLayout2 = ScreenLayout.DoubleOpposite;
     ScreenLayout3 = (((float)Window.ScreenSize.X / (float)Window.ScreenSize.Y > 1.33333337f) ? ScreenLayout.TripleVertical : ScreenLayout.TripleHorizontal);
     ScreenLayout4 = ScreenLayout.Quadruple;
     GuiSize       = ((!(ScreenResolutionManager.ApproximateScreenInches > 6.5f)) ? GuiSize.Normal : ((!(ScreenResolutionManager.ApproximateScreenInches > 9f)) ? GuiSize.Smaller : GuiSize.Smallest));
     LoadSettings();
     VersionsManager.CompareVersions(LastLaunchedVersion, "1.29");
     _ = 0;
     if (VersionsManager.CompareVersions(LastLaunchedVersion, "2.1") < 0)
     {
         MinimumDragDistance = 10f;
     }
     if (VersionsManager.CompareVersions(LastLaunchedVersion, "2.2") < 0)
     {
         if (Utilities.GetTotalAvailableMemory() < 524288000)
         {
             VisibilityRange = MathUtils.Min(64, VisibilityRange);
         }
         else if (Utilities.GetTotalAvailableMemory() < 1048576000)
         {
             VisibilityRange = MathUtils.Min(112, VisibilityRange);
         }
     }
     Window.Deactivated += delegate
     {
         SaveSettings();
     };
 }