Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
WorldSettings.cs
浏览该文件的文档.
1using Engine;
3
4namespace Game {
5 public class WorldSettings {
6 public string Name = string.Empty;
7
8 public string OriginalSerializationVersion = string.Empty;
9
10 public string Seed = string.Empty;
11
12 public GameMode GameMode = GameMode.Survival;
13
15
17
18 public bool AreSeasonsChanging = true;
19
20 public float YearDays = 24f;
21
23
25
26 public bool AreWeatherEffectsEnabled = true;
27
28 public bool IsAdventureRespawnAllowed = true;
29
31
33
34 public bool IsFriendlyFireEnabled = true;
35
37
38 public Vector2 IslandSize = new(400f, 400f);
39
40 public float BiomeSize = 1f;
41
42 public int TerrainLevel = 64;
43
44 public float ShoreRoughness = 0.5f;
45
46 public int TerrainBlockIndex = 8;
47
48 public int TerrainOceanBlockIndex = 18;
49
50 public float TemperatureOffset;
51
52 public float HumidityOffset;
53
54 public int SeaLevelOffset;
55
56 public string BlocksTextureName = string.Empty;
57
58 public WorldPalette Palette = new();
59
60 public bool CustomWorldSeed;
61
62 public int WorldSeed;
63
64 public void ResetOptionsForNonCreativeMode(WorldSettings originalWorldSettings) {
65 if (TerrainGenerationMode == TerrainGenerationMode.FlatContinent) {
67 }
70 }
71 EnvironmentBehaviorMode environmentBehaviorModeBefore = EnvironmentBehaviorMode;
73 TimeOfDayMode timeOfDayModeBefore = TimeOfDayMode;
75 bool areWeatherEffectsEnabledBefore = AreWeatherEffectsEnabled;
77 bool areSurvivalMechanicsEnabledBefore = AreAdventureSurvivalMechanicsEnabled;
80 TerrainLevel = 64;
81 ShoreRoughness = 0.5f;
83 if (originalWorldSettings != null) {
84 AreSeasonsChanging = originalWorldSettings.AreSeasonsChanging;
85 YearDays = originalWorldSettings.YearDays;
86 TimeOfYear = originalWorldSettings.TimeOfYear;
87 }
89 "ResetOptionsForNonCreativeMode",
90 loader => {
91 loader.ResetOptionsForNonCreativeMode(
92 this,
93 environmentBehaviorModeBefore,
94 timeOfDayModeBefore,
95 areWeatherEffectsEnabledBefore,
96 areSurvivalMechanicsEnabledBefore
97 );
98 return false;
99 }
100 );
101 }
102
103 public void Load(ValuesDictionary valuesDictionary) {
104 Name = valuesDictionary.GetValue<string>("WorldName");
105 OriginalSerializationVersion = valuesDictionary.GetValue("OriginalSerializationVersion", string.Empty);
106 Seed = valuesDictionary.GetValue("WorldSeedString", string.Empty);
107 GameMode = valuesDictionary.GetValue("GameMode", GameMode.Challenging);
108 EnvironmentBehaviorMode = valuesDictionary.GetValue("EnvironmentBehaviorMode", EnvironmentBehaviorMode.Living);
109 TimeOfDayMode = valuesDictionary.GetValue("TimeOfDayMode", TimeOfDayMode.Changing);
110 AreSeasonsChanging = valuesDictionary.GetValue("AreSeasonsChanging", true);
111 YearDays = valuesDictionary.GetValue("YearDays", 24f);
112 TimeOfYear = valuesDictionary.GetValue("TimeOfYear", SubsystemSeasons.MidSummer);
113 StartingPositionMode = valuesDictionary.GetValue("StartingPositionMode", StartingPositionMode.Easy);
114 AreWeatherEffectsEnabled = valuesDictionary.GetValue("AreWeatherEffectsEnabled", true);
115 IsAdventureRespawnAllowed = valuesDictionary.GetValue("IsAdventureRespawnAllowed", true);
116 AreAdventureSurvivalMechanicsEnabled = valuesDictionary.GetValue("AreAdventureSurvivalMechanicsEnabled", true);
117 AreSupernaturalCreaturesEnabled = valuesDictionary.GetValue("AreSupernaturalCreaturesEnabled", true);
118 IsFriendlyFireEnabled = valuesDictionary.GetValue("IsFriendlyFireEnabled", true);
119 TerrainGenerationMode = valuesDictionary.GetValue("TerrainGenerationMode", TerrainGenerationMode.Continent);
120 IslandSize = valuesDictionary.GetValue("IslandSize", new Vector2(200f, 200f));
121 TerrainLevel = valuesDictionary.GetValue("TerrainLevel", 64);
122 ShoreRoughness = valuesDictionary.GetValue("ShoreRoughness", 0f);
123 TerrainBlockIndex = valuesDictionary.GetValue("TerrainBlockIndex", 8);
124 TerrainOceanBlockIndex = valuesDictionary.GetValue("TerrainOceanBlockIndex", 18);
125 TemperatureOffset = valuesDictionary.GetValue("TemperatureOffset", 0f);
126 HumidityOffset = valuesDictionary.GetValue("HumidityOffset", 0f);
127 SeaLevelOffset = valuesDictionary.GetValue("SeaLevelOffset", 0);
128 BiomeSize = valuesDictionary.GetValue("BiomeSize", 1f);
129 BlocksTextureName = valuesDictionary.GetValue("BlockTextureName", string.Empty);
130 Palette = new WorldPalette(valuesDictionary.GetValue("Palette", new ValuesDictionary()));
131 WorldSeed = valuesDictionary.GetValue("WorldSeed", 0);
132 }
133
134 public void Save(ValuesDictionary valuesDictionary, bool liveModifiableParametersOnly) {
135 valuesDictionary.SetValue("WorldName", Name);
136 valuesDictionary.SetValue("OriginalSerializationVersion", OriginalSerializationVersion);
137 valuesDictionary.SetValue("GameMode", GameMode);
138 valuesDictionary.SetValue("EnvironmentBehaviorMode", EnvironmentBehaviorMode);
139 valuesDictionary.SetValue("TimeOfDayMode", TimeOfDayMode);
140 valuesDictionary.SetValue("AreSeasonsChanging", AreSeasonsChanging);
141 valuesDictionary.SetValue("YearDays", YearDays);
142 valuesDictionary.SetValue("TimeOfYear", TimeOfYear);
143 valuesDictionary.SetValue("AreWeatherEffectsEnabled", AreWeatherEffectsEnabled);
144 valuesDictionary.SetValue("IsAdventureRespawnAllowed", IsAdventureRespawnAllowed);
145 valuesDictionary.SetValue("AreAdventureSurvivalMechanicsEnabled", AreAdventureSurvivalMechanicsEnabled);
146 valuesDictionary.SetValue("AreSupernaturalCreaturesEnabled", AreSupernaturalCreaturesEnabled);
147 valuesDictionary.SetValue("IsFriendlyFireEnabled", IsFriendlyFireEnabled);
148 if (!liveModifiableParametersOnly) {
149 valuesDictionary.SetValue("WorldSeedString", Seed);
150 valuesDictionary.SetValue("TerrainGenerationMode", TerrainGenerationMode);
151 valuesDictionary.SetValue("IslandSize", IslandSize);
152 valuesDictionary.SetValue("TerrainLevel", TerrainLevel);
153 valuesDictionary.SetValue("ShoreRoughness", ShoreRoughness);
154 valuesDictionary.SetValue("TerrainBlockIndex", TerrainBlockIndex);
155 valuesDictionary.SetValue("TerrainOceanBlockIndex", TerrainOceanBlockIndex);
156 valuesDictionary.SetValue("TemperatureOffset", TemperatureOffset);
157 valuesDictionary.SetValue("HumidityOffset", HumidityOffset);
158 valuesDictionary.SetValue("SeaLevelOffset", SeaLevelOffset);
159 valuesDictionary.SetValue("BiomeSize", BiomeSize);
160 valuesDictionary.SetValue("StartingPositionMode", StartingPositionMode);
161 }
162 valuesDictionary.SetValue("BlockTextureName", BlocksTextureName);
163 valuesDictionary.SetValue("Palette", Palette.Save());
164 }
165 }
166}
EnvironmentBehaviorMode EnvironmentBehaviorMode
void Save(ValuesDictionary valuesDictionary, bool liveModifiableParametersOnly)
TimeOfDayMode TimeOfDayMode
TerrainGenerationMode TerrainGenerationMode
void ResetOptionsForNonCreativeMode(WorldSettings originalWorldSettings)
void Load(ValuesDictionary valuesDictionary)
StartingPositionMode StartingPositionMode
static void HookAction(string HookName, Func< ModLoader, bool > action)
执行Hook