Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
SubsystemCellChangeQueue.cs
浏览该文件的文档.
1using Engine;
4
5namespace Game {
7 struct CellChange {
8 public int RequiredValue;
9
10 public int Value;
11 }
12
14
16
17 Dictionary<Point3, CellChange> m_toChange = new();
18
20
21 public override void Load(ValuesDictionary valuesDictionary) {
22 m_subsystemTime = Project.FindSubsystem<SubsystemTime>(true);
23 m_subsystemTerrain = Project.FindSubsystem<SubsystemTerrain>(true);
24 }
25
26 public void QueueCellChange(int x, int y, int z, int value, bool applyImmediately = false) {
27 if (applyImmediately) {
28 m_subsystemTerrain.ChangeCell(x, y, z, value);
29 }
30 else {
31 m_toChange[new Point3(x, y, z)] = new CellChange { Value = value, RequiredValue = m_subsystemTerrain.Terrain.GetCellValue(x, y, z) };
32 }
33 if (m_toChange.Count >= 10000) {
35 }
36 }
37
38 void IUpdateable.Update(float dt) {
39 if (m_subsystemTime.PeriodicGameTimeEvent(20.0, 0.0)) {
41 }
42 }
43
45 foreach (KeyValuePair<Point3, CellChange> item in m_toChange) {
46 Point3 key = item.Key;
47 if (Terrain.ReplaceLight(m_subsystemTerrain.Terrain.GetCellValue(key.X, key.Y, key.Z), 0)
48 == Terrain.ReplaceLight(item.Value.RequiredValue, 0)) {
49 m_subsystemTerrain.ChangeCell(key.X, key.Y, key.Z, item.Value.Value);
50 }
51 }
52 m_toChange.Clear();
53 }
54 }
55}
Dictionary< Point3, CellChange > m_toChange
void QueueCellChange(int x, int y, int z, int value, bool applyImmediately=false)
override void Load(ValuesDictionary valuesDictionary)
static int ReplaceLight(int value, int light)
ValuesDictionary ValuesDictionary
UpdateOrder UpdateOrder
void Update(float dt)