Elin Modding Docs Doc
Loading...
Searching...
No Matches
LayerEditHouse.cs
1using System;
2using System.Collections.Generic;
3using System.IO;
4using System.Linq;
5using SFB;
6using UnityEngine;
7
8// Token: 0x0200053D RID: 1341
9public class LayerEditHouse : ELayer
10{
11 // Token: 0x17000B1B RID: 2843
12 // (get) Token: 0x0600244D RID: 9293 RVA: 0x000CC7D4 File Offset: 0x000CA9D4
13 public TraitHouseBoard.Data data
14 {
15 get
16 {
17 return this.board.data;
18 }
19 }
20
21 // Token: 0x0600244E RID: 9294 RVA: 0x000CC7E1 File Offset: 0x000CA9E1
22 public override void OnInit()
23 {
24 this.windows[0].AddBottomButton("save", delegate
25 {
26 ELayer.core.WaitForEndOfFrame(delegate
27 {
28 string text = StandaloneFileBrowser.SaveFilePanel("Save Template", CorePath.LotTemplate, "new house", "tpl");
29 if (!string.IsNullOrEmpty(text))
30 {
31 IO.SaveFile(text, this.board.data, false, null);
32 this.RefreshTemplates();
33 }
34 });
35 }, false);
36 }
37
38 // Token: 0x0600244F RID: 9295 RVA: 0x000CC808 File Offset: 0x000CAA08
39 public void SetBoard(TraitHouseBoard b)
40 {
41 if (BuildMenu.Instance)
42 {
43 BuildMenu.Instance.SetActive(false);
44 }
45 ELayer.screen.tileMap.usingHouseBoard = true;
46 this.board = b2;
47 this.ddRoofStyle.SetList<RoofStyle>(this.data.idRoofStyle, ELayer.screen.tileMap.roofStyles, (RoofStyle a, int b) => a.GetName(b).lang(), delegate(int a, RoofStyle b)
48 {
49 this.data.idRoofStyle = a;
50 this.ApplyData();
51 this.RefreshBlockList();
52 }, true);
53 this.toggleReverse.SetToggle(this.data.reverse, delegate(bool on)
54 {
55 this.data.reverse = on;
56 this.ApplyData();
57 });
58 this.toggleAltRoof.SetToggle(this.data.altRoof, delegate(bool on)
59 {
60 this.data.altRoof = on;
61 this.ApplyData();
62 });
63 List<int> blocks = new List<int>();
64 blocks.Add(0);
65 foreach (SourceObj.Row row in ELayer.sources.objs.rows)
66 {
67 if (row.tileType == TileType.Roof && !row.tag.Contains("hidden"))
68 {
69 blocks.Add(row.id);
70 }
71 }
72 int num = blocks.IndexOf(this.data.idRoofTile);
73 if (num == -1)
74 {
75 num = 0;
76 }
77 this.sliderRoof.SetList<int>(num, blocks, delegate(int a, int b)
78 {
79 this.data.idRoofTile = b;
80 this.ApplyData();
81 }, (int a) => blocks.IndexOf(a).ToString() ?? "");
82 List<int> ramps = new List<int>();
83 foreach (SourceBlock.Row row2 in ELayer.sources.blocks.rows)
84 {
85 if (row2.tileType == TileType.Stairs || row2.tileType == TileType.Slope)
86 {
87 ramps.Add(row2.id);
88 }
89 }
90 int num2 = ramps.IndexOf(this.data.idRamp);
91 if (num2 == -1)
92 {
93 num2 = 0;
94 }
95 this.sliderRamp.SetList<int>(num2, ramps, delegate(int a, int b)
96 {
97 this.data.idRamp = b;
98 this.ApplyData();
99 }, (int a) => ramps.IndexOf(a).ToString() ?? "");
100 this.sliderWallHeight.SetSlider((float)this.data.height, delegate(float a)
101 {
102 this.data.height = (int)a;
103 this.ApplyData();
104 return a.ToString() ?? "";
105 }, 1, 20, true);
106 this.sliderHeightFix.SetSlider((float)this.data.heightFix, delegate(float a)
107 {
108 this.data.heightFix = (int)a;
109 this.ApplyData();
110 return a.ToString() ?? "";
111 }, 0, 60, true);
112 this.sliderDecoFix.SetSlider((float)this.data.decoFix, delegate(float a)
113 {
114 this.data.decoFix = (int)a;
115 this.ApplyData();
116 return a.ToString() ?? "";
117 }, -20, 20, true);
118 this.sliderDecoFix2.SetSlider((float)this.data.decoFix2, delegate(float a)
119 {
120 this.data.decoFix2 = (int)a;
121 this.ApplyData();
122 return a.ToString() ?? "";
123 }, -20, 400, true);
124 this.sliderDeco.SetSlider((float)this.data.idDeco, delegate(float a)
125 {
126 this.data.idDeco = (int)a;
127 this.ApplyData();
128 return a.ToString() ?? "";
129 }, 0, this.maxWallDeco, true);
130 this.sliderDeco2.SetSlider((float)this.data.idDeco2, delegate(float a)
131 {
132 this.data.idDeco2 = (int)a;
133 this.ApplyData();
134 return a.ToString() ?? "";
135 }, 0, this.maxWallDeco, true);
136 if (this.first)
137 {
138 this.RefreshTemplates();
139 }
140 this.RefreshBlockList();
141 this.first = false;
142 }
143
144 // Token: 0x06002450 RID: 9296 RVA: 0x000CCBA0 File Offset: 0x000CADA0
145 private void RefreshBlockList()
146 {
147 bool flag = ELayer.screen.tileMap.roofStyles[this.data.idRoofStyle].type != RoofStyle.Type.FlatFloor;
148 List<int> blocks = new List<int>();
149 if (flag)
150 {
151 using (List<SourceBlock.Row>.Enumerator enumerator = ELayer.sources.blocks.rows.GetEnumerator())
152 {
153 while (enumerator.MoveNext())
154 {
155 SourceBlock.Row row = enumerator.Current;
156 if (row.tileType == TileType.Block)
157 {
158 blocks.Add(row.id);
159 }
160 }
161 goto IL_E2;
162 }
163 }
164 foreach (SourceFloor.Row row2 in ELayer.sources.floors.rows)
165 {
166 blocks.Add(row2.id);
167 }
168 IL_E2:
169 int num = blocks.IndexOf(this.data.idBlock);
170 if (num == -1)
171 {
172 num = 0;
173 }
174 this.sliderBlock.SetList<int>(num, blocks, delegate(int a, int b)
175 {
176 this.data.idBlock = b;
177 this.ApplyData();
178 }, (int a) => blocks.IndexOf(a).ToString() ?? "");
179 this.buttonColorRoof.icon.color = IntColor.FromInt(this.data.colRoof);
180 Action<PickerState, Color> <>9__6;
181 this.buttonColorRoof.SetOnClick(delegate
182 {
183 LayerColorPicker layerColorPicker = ELayer.ui.AddLayer<LayerColorPicker>();
184 Color startColor = IntColor.FromInt(this.data.colRoof);
185 Color resetColor = IntColor.FromInt(this.data.colRoof);
186 Action<PickerState, Color> onChangeColor;
187 if ((onChangeColor = <>9__6) == null)
188 {
189 onChangeColor = (<>9__6 = delegate(PickerState state, Color c)
190 {
191 this.data.colRoof = IntColor.ToInt(c);
192 this.buttonColorRoof.icon.color = c;
193 this.board.ApplyData();
194 });
195 }
196 layerColorPicker.SetColor(startColor, resetColor, onChangeColor);
197 });
198 this.buttonColorBlock.icon.color = IntColor.FromInt(this.data.colBlock);
199 Action<PickerState, Color> <>9__7;
200 this.buttonColorBlock.SetOnClick(delegate
201 {
202 LayerColorPicker layerColorPicker = ELayer.ui.AddLayer<LayerColorPicker>();
203 Color startColor = IntColor.FromInt(this.data.colBlock);
204 Color resetColor = IntColor.FromInt(this.data.colBlock);
205 Action<PickerState, Color> onChangeColor;
206 if ((onChangeColor = <>9__7) == null)
207 {
208 onChangeColor = (<>9__7 = delegate(PickerState state, Color c)
209 {
210 this.data.colBlock = IntColor.ToInt(c);
211 this.buttonColorBlock.icon.color = c;
212 this.board.ApplyData();
213 });
214 }
215 layerColorPicker.SetColor(startColor, resetColor, onChangeColor);
216 });
217 this.buttonColorDeco.icon.color = IntColor.FromInt(this.data.colDeco);
218 Action<PickerState, Color> <>9__8;
219 this.buttonColorDeco.SetOnClick(delegate
220 {
221 LayerColorPicker layerColorPicker = ELayer.ui.AddLayer<LayerColorPicker>();
222 Color startColor = IntColor.FromInt(this.data.colDeco);
223 Color resetColor = IntColor.FromInt(this.data.colDeco);
224 Action<PickerState, Color> onChangeColor;
225 if ((onChangeColor = <>9__8) == null)
226 {
227 onChangeColor = (<>9__8 = delegate(PickerState state, Color c)
228 {
229 this.data.colDeco = IntColor.ToInt(c);
230 this.buttonColorDeco.icon.color = c;
231 this.board.ApplyData();
232 });
233 }
234 layerColorPicker.SetColor(startColor, resetColor, onChangeColor);
235 });
236 this.buttonColorDeco2.icon.color = IntColor.FromInt(this.data.colDeco2);
237 Action<PickerState, Color> <>9__9;
238 this.buttonColorDeco2.SetOnClick(delegate
239 {
240 LayerColorPicker layerColorPicker = ELayer.ui.AddLayer<LayerColorPicker>();
241 Color startColor = IntColor.FromInt(this.data.colDeco2);
242 Color resetColor = IntColor.FromInt(this.data.colDeco2);
243 Action<PickerState, Color> onChangeColor;
244 if ((onChangeColor = <>9__9) == null)
245 {
246 onChangeColor = (<>9__9 = delegate(PickerState state, Color c)
247 {
248 this.data.colDeco2 = IntColor.ToInt(c);
249 this.buttonColorDeco2.icon.color = c;
250 this.board.ApplyData();
251 });
252 }
253 layerColorPicker.SetColor(startColor, resetColor, onChangeColor);
254 });
255 }
256
257 // Token: 0x06002451 RID: 9297 RVA: 0x000CCDE4 File Offset: 0x000CAFE4
258 public void RefreshTemplates()
259 {
260 FileInfo[] list = (from a in new DirectoryInfo(CorePath.LotTemplate).GetFiles()
261 where a.Name.EndsWith(".tpl")
262 select a).ToArray<FileInfo>();
263 this.ddTemplate.SetList<FileInfo>(0, list, (FileInfo a, int b) => a.Name, delegate(int a, FileInfo b)
264 {
265 this.board.data = IO.LoadFile<TraitHouseBoard.Data>(b.FullName, false, null);
266 this.ApplyData();
267 this.SetBoard(this.board);
268 }, true);
269 }
270
271 // Token: 0x06002452 RID: 9298 RVA: 0x000CCE63 File Offset: 0x000CB063
272 public void ApplyData()
273 {
274 this.board.ApplyData();
275 this.toggleAltRoof.SetActive(this.board.data.idRoofTile != 0);
276 }
277
278 // Token: 0x06002453 RID: 9299 RVA: 0x000CCE8E File Offset: 0x000CB08E
279 public override void OnKill()
280 {
281 ELayer.screen.tileMap.usingHouseBoard = false;
282 if (BuildMenu.Instance)
283 {
284 BuildMenu.Instance.SetActive(true);
285 }
286 }
287
288 // Token: 0x040013BA RID: 5050
289 public TraitHouseBoard board;
290
291 // Token: 0x040013BB RID: 5051
292 public UISlider sliderBlock;
293
294 // Token: 0x040013BC RID: 5052
295 public UISlider sliderRoof;
296
297 // Token: 0x040013BD RID: 5053
298 public UISlider sliderRamp;
299
300 // Token: 0x040013BE RID: 5054
301 public UISlider sliderWallHeight;
302
303 // Token: 0x040013BF RID: 5055
304 public UISlider sliderHeightFix;
305
306 // Token: 0x040013C0 RID: 5056
307 public UISlider sliderDeco;
308
309 // Token: 0x040013C1 RID: 5057
310 public UISlider sliderDeco2;
311
312 // Token: 0x040013C2 RID: 5058
313 public UISlider sliderDecoFix;
314
315 // Token: 0x040013C3 RID: 5059
316 public UISlider sliderDecoFix2;
317
318 // Token: 0x040013C4 RID: 5060
319 public UIDropdown ddRoofStyle;
320
321 // Token: 0x040013C5 RID: 5061
322 public UIDropdown ddTemplate;
323
324 // Token: 0x040013C6 RID: 5062
325 public UIButton toggleReverse;
326
327 // Token: 0x040013C7 RID: 5063
328 public UIButton toggleAltRoof;
329
330 // Token: 0x040013C8 RID: 5064
331 public UIButton buttonColorRoof;
332
333 // Token: 0x040013C9 RID: 5065
334 public UIButton buttonColorBlock;
335
336 // Token: 0x040013CA RID: 5066
337 public UIButton buttonColorDeco;
338
339 // Token: 0x040013CB RID: 5067
340 public UIButton buttonColorDeco2;
341
342 // Token: 0x040013CC RID: 5068
343 public UIButton toggleAtrium;
344
345 // Token: 0x040013CD RID: 5069
346 public int maxWallDeco;
347
348 // Token: 0x040013CE RID: 5070
349 private bool first = true;
350}