Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
SubsystemStairsBlockBehavior.cs
浏览该文件的文档.
1using Engine;
2
3namespace Game {
5 public int[] m_handledBlocks;
6
7 public override int[] HandledBlocks => m_handledBlocks;
8
10 List<int> list = new();
11 list.AddRange(from b in BlocksManager.Blocks where b is StairsBlock select b.BlockIndex);
12 m_handledBlocks = list.ToArray();
13 }
14
15 public override void OnNeighborBlockChanged(int x, int y, int z, int neighborX, int neighborY, int neighborZ) {
16 int cellValue = SubsystemTerrain.Terrain.GetCellValue(x, y, z);
17 UpdateIsCorner(cellValue, x, y, z, true);
18 }
19
20 public override void OnBlockGenerated(int value, int x, int y, int z, bool isLoaded) {
21 UpdateIsCorner(value, x, y, z, false);
22 }
23
24 public override void OnBlockAdded(int value, int oldValue, int x, int y, int z) {
25 UpdateIsCorner(value, x, y, z, true);
26 }
27
28 public virtual void UpdateIsCorner(int value, int x, int y, int z, bool updateModificationCounter) {
29 int value2 = Terrain.ExtractContents(value);
30 if (!HandledBlocks.Contains(value2)) {
31 return;
32 }
33 int data = Terrain.ExtractData(value);
34 if (StairsBlock.GetCornerType(data) != 0) {
35 return;
36 }
37 int rotation = StairsBlock.GetRotation(data);
38 bool isUpsideDown = StairsBlock.GetIsUpsideDown(data);
39 Point3 point = StairsBlock.RotationToDirection(rotation);
40 int cellValue = SubsystemTerrain.Terrain.GetCellValue(x + point.X, y + point.Y, z + point.Z);
41 int num = Terrain.ExtractContents(cellValue);
42 if (BlocksManager.Blocks[num] is StairsBlock) {
43 int data2 = Terrain.ExtractData(cellValue);
44 bool isUpsideDown2 = StairsBlock.GetIsUpsideDown(data2);
46 int num2 = -1;
47 if (isUpsideDown2 == isUpsideDown) {
48 int rotation2 = StairsBlock.GetRotation(data2);
49 if (rotation == 0
50 && rotation2 == 1
51 && cornerType != StairsBlock.CornerType.ThreeQuarters) {
52 num2 = 1;
53 }
54 if (rotation == 0
55 && rotation2 == 3
56 && cornerType != StairsBlock.CornerType.ThreeQuarters) {
57 num2 = 0;
58 }
59 if (rotation == 1
60 && rotation2 == 0
61 && cornerType != StairsBlock.CornerType.ThreeQuarters) {
62 num2 = 1;
63 }
64 if (rotation == 1
65 && rotation2 == 2
66 && cornerType != StairsBlock.CornerType.ThreeQuarters) {
67 num2 = 2;
68 }
69 if (rotation == 2
70 && rotation2 == 1
71 && cornerType != StairsBlock.CornerType.ThreeQuarters) {
72 num2 = 2;
73 }
74 if (rotation == 2
75 && rotation2 == 3
76 && cornerType != StairsBlock.CornerType.ThreeQuarters) {
77 num2 = 3;
78 }
79 if (rotation == 3
80 && rotation2 == 0
81 && cornerType != StairsBlock.CornerType.ThreeQuarters) {
82 num2 = 0;
83 }
84 if (rotation == 3
85 && rotation2 == 2
86 && cornerType != StairsBlock.CornerType.ThreeQuarters) {
87 num2 = 3;
88 }
89 }
90 if (num2 >= 0) {
91 int data3 = StairsBlock.SetRotation(StairsBlock.SetCornerType(data, StairsBlock.CornerType.OneQuarter), num2);
92 int value3 = Terrain.ReplaceData(value, data3);
93 SubsystemTerrain.ChangeCell(x, y, z, value3, updateModificationCounter);
94 }
95 return;
96 }
97 cellValue = SubsystemTerrain.Terrain.GetCellValue(x - point.X, y - point.Y, z - point.Z);
98 num = Terrain.ExtractContents(cellValue);
99 if (!(BlocksManager.Blocks[num] is StairsBlock)) {
100 return;
101 }
102 int data4 = Terrain.ExtractData(cellValue);
103 bool isUpsideDown3 = StairsBlock.GetIsUpsideDown(data4);
105 int num3 = -1;
106 if (isUpsideDown3 == isUpsideDown) {
107 int rotation3 = StairsBlock.GetRotation(data4);
108 if (rotation == 0
109 && rotation3 == 1
110 && cornerType2 == StairsBlock.CornerType.None) {
111 num3 = 1;
112 }
113 if (rotation == 0
114 && rotation3 == 3
115 && cornerType2 == StairsBlock.CornerType.None) {
116 num3 = 0;
117 }
118 if (rotation == 0
119 && rotation3 == 2
120 && cornerType2 == StairsBlock.CornerType.ThreeQuarters) {
121 num3 = 1;
122 }
123 if (rotation == 0
124 && rotation3 == 3
125 && cornerType2 == StairsBlock.CornerType.ThreeQuarters) {
126 num3 = 0;
127 }
128 if (rotation == 1
129 && rotation3 == 0
130 && cornerType2 == StairsBlock.CornerType.None) {
131 num3 = 1;
132 }
133 if (rotation == 1
134 && rotation3 == 2
135 && cornerType2 == StairsBlock.CornerType.None) {
136 num3 = 2;
137 }
138 if (rotation == 1
139 && rotation3 == 3
140 && cornerType2 == StairsBlock.CornerType.ThreeQuarters) {
141 num3 = 2;
142 }
143 if (rotation == 1
144 && rotation3 == 0
145 && cornerType2 == StairsBlock.CornerType.ThreeQuarters) {
146 num3 = 1;
147 }
148 if (rotation == 2
149 && rotation3 == 1
150 && cornerType2 == StairsBlock.CornerType.None) {
151 num3 = 2;
152 }
153 if (rotation == 2
154 && rotation3 == 3
155 && cornerType2 == StairsBlock.CornerType.None) {
156 num3 = 3;
157 }
158 if (rotation == 2
159 && rotation3 == 0
160 && cornerType2 == StairsBlock.CornerType.ThreeQuarters) {
161 num3 = 3;
162 }
163 if (rotation == 2
164 && rotation3 == 1
165 && cornerType2 == StairsBlock.CornerType.ThreeQuarters) {
166 num3 = 2;
167 }
168 if (rotation == 3
169 && rotation3 == 0
170 && cornerType2 == StairsBlock.CornerType.None) {
171 num3 = 0;
172 }
173 if (rotation == 3
174 && rotation3 == 2
175 && cornerType2 == StairsBlock.CornerType.None) {
176 num3 = 3;
177 }
178 if (rotation == 3
179 && rotation3 == 2
180 && cornerType2 == StairsBlock.CornerType.ThreeQuarters) {
181 num3 = 3;
182 }
183 if (rotation == 3
184 && rotation3 == 1
185 && cornerType2 == StairsBlock.CornerType.ThreeQuarters) {
186 num3 = 0;
187 }
188 }
189 if (num3 >= 0) {
190 int data5 = StairsBlock.SetRotation(StairsBlock.SetCornerType(data, StairsBlock.CornerType.ThreeQuarters), num3);
191 int value4 = Terrain.ReplaceData(value, data5);
192 SubsystemTerrain.ChangeCell(x, y, z, value4, updateModificationCounter);
193 }
194 }
195 }
196}
int BlockIndex
定义 Block.cs:6
static CornerType GetCornerType(int data)
static int SetRotation(int data, int rotation)
static bool GetIsUpsideDown(int data)
static int GetRotation(int data)
static int SetCornerType(int data, CornerType cornerType)
static Point3 RotationToDirection(int rotation)
override void OnNeighborBlockChanged(int x, int y, int z, int neighborX, int neighborY, int neighborZ)
override void OnBlockAdded(int value, int oldValue, int x, int y, int z)
virtual void UpdateIsCorner(int value, int x, int y, int z, bool updateModificationCounter)
override void OnBlockGenerated(int value, int x, int y, int z, bool isLoaded)
static int ExtractContents(int value)
static int ReplaceData(int value, int data)
static int ExtractData(int value)