public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_subsystemPlayers   = base.Project.FindSubsystem <SubsystemPlayers>(throwOnError: true);
     m_subsystemTime      = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_subsystemUpdate    = base.Project.FindSubsystem <SubsystemUpdate>(throwOnError: true);
     m_subsystemGameInfo  = base.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true);
     m_subsystemTimeOfDay = base.Project.FindSubsystem <SubsystemTimeOfDay>(throwOnError: true);
     m_subsystemTerrain   = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
     m_componentPlayer    = base.Entity.FindComponent <ComponentPlayer>(throwOnError: true);
     m_sleepStartTime     = valuesDictionary.GetValue <double>("SleepStartTime");
     m_allowManualWakeUp  = valuesDictionary.GetValue <bool>("AllowManualWakeUp");
     if (m_sleepStartTime == 0.0)
     {
         m_sleepStartTime = null;
     }
     if (m_sleepStartTime.HasValue)
     {
         m_sleepFactor = 1f;
         m_minWetness  = float.MaxValue;
     }
     m_componentPlayer.ComponentHealth.Attacked += delegate
     {
         if (IsSleeping && m_componentPlayer.ComponentVitalStats.Sleep > 0.25f)
         {
             WakeUp();
         }
     };
 }
Exemple #2
0
 public static void DisposeProject()
 {
     if (m_project != null)
     {
         m_project.Dispose();
         m_project         = null;
         m_subsystemUpdate = null;
         m_worldInfo       = null;
         GC.Collect();
     }
 }
Exemple #3
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();
 }
 public override void Load(ValuesDictionary valuesDictionary)
 {
     m_subsystemPlayers = base.Project.FindSubsystem <SubsystemPlayers>(throwOnError: true);
     m_subsystemUpdate  = base.Project.FindSubsystem <SubsystemUpdate>(throwOnError: true);
 }