Elin Modding Docs Doc
Loading...
Searching...
No Matches
UIMapPreview.cs
1using System;
2using System.Collections.Generic;
3using System.Threading;
4using UnityEngine;
5using UnityEngine.UI;
6
7// Token: 0x02000623 RID: 1571
8public class UIMapPreview : EMono
9{
10 // Token: 0x06002BF6 RID: 11254 RVA: 0x000F6DB2 File Offset: 0x000F4FB2
11 private void Awake()
12 {
13 if (this.image)
14 {
15 this.texDefault = this.image.texture;
16 }
17 }
18
19 // Token: 0x06002BF7 RID: 11255 RVA: 0x000F6DD4 File Offset: 0x000F4FD4
20 public void GenerateMap(ZoneBlueprint bp)
21 {
22 if (this.thread == null)
23 {
24 this.thread = new UIMapPreview.GenThread();
25 this.thread.Init();
26 }
27 else
28 {
29 if (!this.thread.done)
30 {
31 return;
32 }
33 this.image.texture = this.texDefault;
34 this.thread.Reset();
35 }
36 this.thread.bp.genSetting = bp.genSetting;
37 this.thread.bp.zoneProfile = bp.zoneProfile;
38 this.thread.bp.genSetting.seed = EMono.rnd(20000);
39 ThreadPool.QueueUserWorkItem(delegate(object a)
40 {
41 this.thread.Start();
42 });
43 base.CancelInvoke();
44 base.InvokeRepeating("CheckThread", 0f, 0.1f);
45 }
46
47 // Token: 0x06002BF8 RID: 11256 RVA: 0x000F6EA3 File Offset: 0x000F50A3
48 public void CheckThread()
49 {
50 if (this.thread.done)
51 {
52 this.SetMap(this.thread.bp.map);
53 base.CancelInvoke();
54 }
55 }
56
57 // Token: 0x06002BF9 RID: 11257 RVA: 0x000F6ED0 File Offset: 0x000F50D0
58 public void SetMap(Map _map)
59 {
60 this.map = _map;
61 if (_map == null)
62 {
63 this.image.texture = this.texDefault;
64 return;
65 }
66 this.cells = this.map.cells;
67 int num = this.limitBounds ? ((this.map.bounds.Width > this.map.bounds.Height) ? this.map.bounds.Width : this.map.bounds.Height) : this.map.Size;
68 this.Size = num;
69 this.offsetX = ((this.map.bounds.Width > this.map.bounds.Height) ? 0 : ((num - _map.bounds.Width) / 2));
70 this.offsetZ = ((this.map.bounds.Width > this.map.bounds.Height) ? ((num - _map.bounds.Height) / 2) : 0);
71 this.px = new Color[this.Size * this.Size];
72 if (this.tex)
73 {
74 UnityEngine.Object.DestroyImmediate(this.tex);
75 }
76 this.tex = new Texture2D(this.Size, this.Size)
77 {
78 filterMode = this.filter,
79 wrapMode = TextureWrapMode.Clamp
80 };
81 for (int i = 0; i < this.Size * this.Size; i++)
82 {
83 this.px[i].a = this.voidAlpha;
84 }
85 this.tex.SetPixels(this.px);
86 if (this.limitBounds)
87 {
88 for (int j = 0; j < this.map.bounds.Height; j++)
89 {
90 for (int k = 0; k < this.map.bounds.Width; k++)
91 {
92 this._RefreshPoint(this.map.bounds.x + k, this.map.bounds.z + j, false);
93 }
94 }
95 }
96 else
97 {
98 for (int l = 0; l < this.Size; l++)
99 {
100 for (int m = 0; m < this.Size; m++)
101 {
102 this._RefreshPoint(m, l, false);
103 }
104 }
105 }
106 this.tex.SetPixels(this.px);
107 this.tex.Apply();
108 if (this.matMap)
109 {
110 this.matMap.SetTexture("_MainTex", this.tex);
111 }
112 if (this.image)
113 {
114 this.image.texture = this.tex;
115 }
116 }
117
118 // Token: 0x06002BFA RID: 11258 RVA: 0x000F7176 File Offset: 0x000F5376
119 public void UpdateMap(int x, int z)
120 {
121 this._RefreshPoint(x, z, true);
122 this.tex.Apply();
123 }
124
125 // Token: 0x06002BFB RID: 11259 RVA: 0x000F718C File Offset: 0x000F538C
126 public void UpdateMap(List<Cell> newPoints)
127 {
128 foreach (Cell cell in newPoints)
129 {
130 this._RefreshPoint((int)cell.x, (int)cell.z, true);
131 }
132 this.tex.Apply();
133 }
134
135 // Token: 0x06002BFC RID: 11260 RVA: 0x000F71F4 File Offset: 0x000F53F4
136 public void _RefreshPoint(int x, int z, bool apply = true)
137 {
138 if (x >= EMono._map.Size || z >= EMono._map.Size)
139 {
140 return;
141 }
142 Cell cell = this.cells[x, z];
143 int num = x;
144 int num2 = z;
145 if (this.limitBounds)
146 {
147 num = x - EMono._map.bounds.x + this.offsetX;
148 num2 = z - EMono._map.bounds.z + this.offsetZ;
149 }
150 int num3 = num2 * this.Size + num;
151 if (num3 >= this.px.Length || num3 < 0)
152 {
153 return;
154 }
155 if (this.monoColor)
156 {
157 if (!cell.isSeen)
158 {
159 this.px[num3] = this.colorSurround;
160 }
161 else if (cell.isSurrounded)
162 {
163 this.px[num3] = this.colorSurround;
164 }
165 else if (cell.IsTopWater)
166 {
167 this.px[num3] = this.colorWater;
168 }
169 else if (cell.HasBlock)
170 {
171 this.px[num3] = this.colorEdge;
172 }
173 else
174 {
175 this.px[num3] = this.colorDefault;
176 }
177 }
178 else if (!cell.isSeen)
179 {
180 this.px[num3] = this.colorSurround;
181 }
182 else if (cell.HasZoneStairs(true))
183 {
184 this.px[num3] = this.colorStairs;
185 }
186 else if (cell.isSurrounded)
187 {
188 this.px[num3] = this.colorSurround;
189 }
190 else if (cell.HasBlock)
191 {
192 this.px[num3] = cell.matBlock.GetColor();
193 }
194 else
195 {
196 SourceMaterial.Row row = (cell.bridgeHeight != 0) ? cell.matBridge : cell.matFloor;
197 if (!Application.isEditor && !EMono._zone.IsRegion && cell.IsSnowTile)
198 {
199 row = MATERIAL.sourceSnow;
200 }
201 Color color = cell.IsSky ? this.colorSky : row.GetColor();
202 if (color.r > this.maxColor)
203 {
204 color.r = this.maxColor;
205 }
206 else if (color.r < this.minColor)
207 {
208 color.r = this.minColor;
209 }
210 if (color.g > this.maxColor)
211 {
212 color.g = this.maxColor;
213 }
214 else if (color.g < this.minColor)
215 {
216 color.g = this.minColor;
217 }
218 if (color.b > this.maxColor)
219 {
220 color.b = this.maxColor;
221 }
222 else if (color.b < this.minColor)
223 {
224 color.b = this.minColor;
225 }
226 this.px[num3] = color;
227 }
228 if (cell.isSeen)
229 {
230 if (cell.HasBlock)
231 {
232 this.px[num3] *= 0.4f;
233 }
234 else if (cell.room != null)
235 {
236 this.px[num3] *= 0.9f;
237 }
238 }
239 if (!EMono._map.bounds.Contains(x, z))
240 {
241 this.px[num3].a = this.voidAlpha;
242 }
243 else
244 {
245 this.px[num3].a = 1f;
246 }
247 if (!apply)
248 {
249 return;
250 }
251 this.tex.SetPixel(num, num2, this.px[num3]);
252 }
253
254 // Token: 0x04001886 RID: 6278
255 public Color colorDefault;
256
257 // Token: 0x04001887 RID: 6279
258 public Color colorWater;
259
260 // Token: 0x04001888 RID: 6280
261 public Color colorSurround;
262
263 // Token: 0x04001889 RID: 6281
264 public Color colorEdge;
265
266 // Token: 0x0400188A RID: 6282
267 public Color colorFog;
268
269 // Token: 0x0400188B RID: 6283
270 public Color colorSky;
271
272 // Token: 0x0400188C RID: 6284
273 public Color colorStairs;
274
275 // Token: 0x0400188D RID: 6285
276 public Material matMap;
277
278 // Token: 0x0400188E RID: 6286
279 public RawImage image;
280
281 // Token: 0x0400188F RID: 6287
282 public UIButton button;
283
284 // Token: 0x04001890 RID: 6288
285 private Texture texDefault;
286
287 // Token: 0x04001891 RID: 6289
288 private Texture2D tex;
289
290 // Token: 0x04001892 RID: 6290
291 private Color[] px;
292
293 // Token: 0x04001893 RID: 6291
294 private Cell[,] cells;
295
296 // Token: 0x04001894 RID: 6292
297 [NonSerialized]
298 public int Size;
299
300 // Token: 0x04001895 RID: 6293
301 [NonSerialized]
302 public int offsetX;
303
304 // Token: 0x04001896 RID: 6294
305 [NonSerialized]
306 public int offsetZ;
307
308 // Token: 0x04001897 RID: 6295
309 public FilterMode filter = FilterMode.Bilinear;
310
311 // Token: 0x04001898 RID: 6296
312 public Map map;
313
314 // Token: 0x04001899 RID: 6297
315 public bool monoColor;
316
317 // Token: 0x0400189A RID: 6298
318 public bool createNewMaterial;
319
320 // Token: 0x0400189B RID: 6299
321 public bool limitBounds;
322
323 // Token: 0x0400189C RID: 6300
324 public UIMapPreview.GenThread thread;
325
326 // Token: 0x0400189D RID: 6301
327 public float voidAlpha;
328
329 // Token: 0x0400189E RID: 6302
330 public float minColor;
331
332 // Token: 0x0400189F RID: 6303
333 public float maxColor;
334
335 // Token: 0x02000B96 RID: 2966
336 public class GenThread : EClass
337 {
338 // Token: 0x060044A9 RID: 17577 RVA: 0x0015CB78 File Offset: 0x0015AD78
339 public void Init()
340 {
341 this.bp = new ZoneBlueprint();
342 this.bp.Create();
343 this.Reset();
344 }
345
346 // Token: 0x060044AA RID: 17578 RVA: 0x0015CB96 File Offset: 0x0015AD96
347 public void Reset()
348 {
349 this.done = false;
350 }
351
352 // Token: 0x060044AB RID: 17579 RVA: 0x0015CB9F File Offset: 0x0015AD9F
353 public void Start()
354 {
355 this.done = true;
356 }
357
358 // Token: 0x04002E74 RID: 11892
359 public ZoneBlueprint bp;
360
361 // Token: 0x04002E75 RID: 11893
362 public Map map;
363
364 // Token: 0x04002E76 RID: 11894
365 public bool done = true;
366 }
367}
Definition Cell.cs:10
Definition EMono.cs:6
Definition Map.cs:15