Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
SubsystemGameInfo.cs
浏览该文件的文档.
3
4namespace Game {
7
9
11 public WorldSettings WorldSettings { get; set; }
12
13 public string DirectoryName { get; set; }
14
15 public double TotalElapsedGameTime { get; set; }
16
17 public float TotalElapsedGameTimeDelta { get; set; }
18
19 public int WorldSeed { get; set; }
20
22
23 public IEnumerable<ActiveExternalContentInfo> GetActiveExternalContent() {
25 if (!string.IsNullOrEmpty(downloadedContentAddress)) {
26 yield return new ActiveExternalContentInfo {
27 Address = downloadedContentAddress, DisplayName = WorldSettings.Name, Type = ExternalContentType.World
28 };
29 }
30 if (!BlocksTexturesManager.IsBuiltIn(WorldSettings.BlocksTextureName)) {
32 ExternalContentType.BlocksTexture,
33 WorldSettings.BlocksTextureName
34 );
35 if (!string.IsNullOrEmpty(downloadedContentAddress)) {
36 yield return new ActiveExternalContentInfo {
37 Address = downloadedContentAddress,
38 DisplayName = BlocksTexturesManager.GetDisplayName(WorldSettings.BlocksTextureName),
40 };
41 }
42 }
43 SubsystemPlayers subsystemPlayers = Project.FindSubsystem<SubsystemPlayers>(true);
44 foreach (PlayerData playersDatum in subsystemPlayers.PlayersData) {
47 ExternalContentType.CharacterSkin,
48 playersDatum.CharacterSkinName
49 );
50 if (!string.IsNullOrEmpty(downloadedContentAddress)) {
51 yield return new ActiveExternalContentInfo {
52 Address = downloadedContentAddress,
53 DisplayName = CharacterSkinsManager.GetDisplayName(playersDatum.CharacterSkinName),
55 };
56 }
57 }
58 }
59 SubsystemFurnitureBlockBehavior subsystemFurnitureBlockBehavior = Project.FindSubsystem<SubsystemFurnitureBlockBehavior>(true);
60 foreach (FurnitureSet furnitureSet in subsystemFurnitureBlockBehavior.FurnitureSets) {
61 if (furnitureSet.ImportedFrom != null) {
63 ExternalContentType.FurniturePack,
64 furnitureSet.ImportedFrom
65 );
66 if (!string.IsNullOrEmpty(downloadedContentAddress)) {
67 yield return new ActiveExternalContentInfo {
68 Address = downloadedContentAddress,
69 DisplayName = FurniturePacksManager.GetDisplayName(furnitureSet.ImportedFrom),
71 };
72 }
73 }
74 }
75 }
76
77 public override void Load(ValuesDictionary valuesDictionary) {
78 m_subsystemTime = Project.FindSubsystem<SubsystemTime>(true);
79 m_subsystemTimeOfDay = Project.FindSubsystem<SubsystemTimeOfDay>(true);
81 WorldSettings.Load(valuesDictionary);
82 DirectoryName = valuesDictionary.GetValue<string>("WorldDirectoryName");
83 TotalElapsedGameTime = valuesDictionary.GetValue<double>("TotalElapsedGameTime");
84 WorldSeed = valuesDictionary.GetValue<int>("WorldSeed");
85 }
86
87 public override void Save(ValuesDictionary valuesDictionary) {
88 WorldSettings.Save(valuesDictionary, false);
89 valuesDictionary.SetValue("WorldSeed", WorldSeed);
90 valuesDictionary.SetValue("TotalElapsedGameTime", TotalElapsedGameTime);
91 }
92
93 public virtual void Update(float dt) {
95 TotalElapsedGameTimeDelta = m_lastTotalElapsedGameTime.HasValue ? (float)(TotalElapsedGameTime - m_lastTotalElapsedGameTime.Value) : 0f;
97 if (WorldSettings.AreSeasonsChanging
98 && m_subsystemTime.PeriodicGameTimeEvent(10.0, 5.0)) {
99 float num = WorldSettings.YearDays * m_subsystemTimeOfDay.DayDuration;
101 }
102 if (m_subsystemTime.GameTime >= 600.0
103 && m_subsystemTime.GameTime - m_subsystemTime.GameTimeDelta < 600.0
104 && UserManager.ActiveUser != null) {
107 item.Address,
109 m_subsystemTime.GameTime,
110 null,
111 delegate { },
112 delegate { }
113 );
114 }
115 }
116 }
117 }
118}
static string GetDisplayName(string name)
static string GetDisplayName(string name)
static string GetDownloadedContentAddress(ExternalContentType type, string name)
static void SendPlayTime(string address, string userId, double time, CancellableProgress progress, Action success, Action< Exception > failure)
static string GetDisplayName(string name)
static float Normalize(float t)
override void Save(ValuesDictionary valuesDictionary)
virtual void Update(float dt)
SubsystemTimeOfDay m_subsystemTimeOfDay
IEnumerable< ActiveExternalContentInfo > GetActiveExternalContent()
override void Load(ValuesDictionary valuesDictionary)
readonly string UniqueId
static UserInfo ActiveUser
ValuesDictionary ValuesDictionary