Elin Modding Docs Doc
Loading...
Searching...
No Matches
GenBounds.cs
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4
5// Token: 0x0200066A RID: 1642
6public class GenBounds : EClass
7{
8 // Token: 0x06002E00 RID: 11776 RVA: 0x00101410 File Offset: 0x000FF610
9 private bool IsSub(BiomeProfile.Tile g, int x, int y)
10 {
11 BiomeProfile.BaseTile.SubType subType = g.subType;
12 switch (subType)
13 {
14 case BiomeProfile.BaseTile.SubType.Rnd5:
15 return EClass.rnd(5) == 0;
16 case BiomeProfile.BaseTile.SubType.Rnd10:
17 return EClass.rnd(10) == 0;
18 case BiomeProfile.BaseTile.SubType.Rnd20:
19 return EClass.rnd(20) == 0;
20 default:
21 return subType == BiomeProfile.BaseTile.SubType.Pattern && (x + y % 2) % 2 == 0;
22 }
23 }
24
25 // Token: 0x06002E01 RID: 11777 RVA: 0x0010146C File Offset: 0x000FF66C
26 public void SetFloor(BiomeProfile.Tile t, int x, int z)
27 {
28 bool flag = this.IsSub(t, x, z);
29 this.SetFloor(x, z, flag ? t.matSub : t.mat, flag ? t.idSub : t.id, EClass.rnd(EClass.rnd(8) + 1));
30 }
31
32 // Token: 0x06002E02 RID: 11778 RVA: 0x001014BC File Offset: 0x000FF6BC
33 public void SetBlock(BiomeProfile.Tile t, int x, int z)
34 {
35 bool flag = this.IsSub(t, x, z);
36 this.SetBlock(x, z, flag ? t.matSub : t.mat, flag ? t.idSub : t.id, 0);
37 }
38
39 // Token: 0x06002E03 RID: 11779 RVA: 0x001014FE File Offset: 0x000FF6FE
40 public void SetFloor(int x, int z, int idMat, int idFloor, int direction = 0)
41 {
42 Cell cell = this.map.cells[x, z];
43 cell._floorMat = (byte)idMat;
44 cell._floor = (byte)idFloor;
45 cell.floorDir = direction;
46 }
47
48 // Token: 0x06002E04 RID: 11780 RVA: 0x0010152A File Offset: 0x000FF72A
49 public void SetBlock(int x, int z, int idMat, int idBlock, int direction = 0)
50 {
51 Cell cell = this.map.cells[x, z];
52 cell._blockMat = (byte)idMat;
53 cell._block = (byte)idBlock;
54 cell.blockDir = direction;
55 cell.effect = null;
56 }
57
58 // Token: 0x06002E05 RID: 11781 RVA: 0x00101560 File Offset: 0x000FF760
59 public bool IsEmpty()
60 {
61 for (int i = this.y - this.marginPartial; i < this.y + this.height + this.marginPartial; i++)
62 {
63 if (i < 0 || i >= EClass._map.Size)
64 {
65 return false;
66 }
67 for (int j = this.x - this.marginPartial; j < this.x + this.width + this.marginPartial; j++)
68 {
69 if (j < 0 || j >= EClass._map.Size)
70 {
71 return false;
72 }
73 Cell cell = this.map.cells[j, i];
74 if (this.FuncCheckEmpty != null && !this.FuncCheckEmpty(cell))
75 {
76 return false;
77 }
78 if (cell.blocked || cell.HasBlock || cell.Installed != null)
79 {
80 return false;
81 }
82 }
83 }
84 return true;
85 }
86
87 // Token: 0x06002E06 RID: 11782 RVA: 0x00101638 File Offset: 0x000FF838
88 public List<Point> ListEmptyPoint()
89 {
90 List<Point> list = new List<Point>();
91 for (int i = this.y; i < this.y + this.height; i++)
92 {
93 if (i >= 0 && i < EClass._map.Size)
94 {
95 for (int j = this.x; j < this.x + this.width; j++)
96 {
97 if (j >= 0 && j < EClass._map.Size)
98 {
99 Cell cell = this.map.cells[j, i];
100 if (!cell.blocked && !cell.HasBlock && (cell.Installed == null || !cell.Installed.trait.IsBlockPath))
101 {
102 Point point = new Point(j, i);
103 if (!point.HasChara)
104 {
105 list.Add(point);
106 }
107 }
108 }
109 }
110 }
111 }
112 return list;
113 }
114
115 // Token: 0x06002E07 RID: 11783 RVA: 0x0010170C File Offset: 0x000FF90C
116 public static GenBounds Create(Zone z)
117 {
118 MapBounds bounds = z.map.bounds;
119 return new GenBounds
120 {
121 zone = z,
122 map = z.map,
123 x = bounds.x,
124 y = bounds.z,
125 width = bounds.Width,
126 height = bounds.Height
127 };
128 }
129
130 // Token: 0x06002E08 RID: 11784 RVA: 0x00101770 File Offset: 0x000FF970
131 public GenBounds GetBounds(int w, int h, bool ignoreBlock)
132 {
133 return this.GetBounds(this.map, this.zone, this.x, this.y, this.width, this.height, w, h, ignoreBlock);
134 }
135
136 // Token: 0x06002E09 RID: 11785 RVA: 0x001017AC File Offset: 0x000FF9AC
137 public GenBounds GetBounds(Map map, Zone zone, int x, int y, int width, int height, int dw, int dh, bool ignoreBlock)
138 {
139 if (dw >= width || dh >= height)
140 {
141 return null;
142 }
143 GenBounds genBounds = new GenBounds
144 {
145 x = x,
146 y = y,
147 width = dw,
148 height = dh,
149 map = map,
150 zone = zone,
151 marginPartial = this.marginPartial,
152 FuncCheckEmpty = this.FuncCheckEmpty
153 };
154 for (int i = 0; i < 200; i++)
155 {
156 if (ignoreBlock)
157 {
158 genBounds.x = EClass.rnd(width - dw) + x - dw / 2;
159 genBounds.y = EClass.rnd(height - dh) + y - dh / 2;
160 if (genBounds.x > 0 && genBounds.y > 0)
161 {
162 return genBounds;
163 }
164 }
165 else
166 {
167 genBounds.x = EClass.rnd(width - dw) + x;
168 genBounds.y = EClass.rnd(height - dh) + y;
169 if (genBounds.IsEmpty())
170 {
171 return genBounds;
172 }
173 }
174 }
175 return null;
176 }
177
178 // Token: 0x06002E0A RID: 11786 RVA: 0x0010189C File Offset: 0x000FFA9C
179 public PartialMap TryAddMapPiece(MapPiece.Type type = MapPiece.Type.Any, float ruin = -1f, string tags = null, Action<PartialMap, GenBounds> onCreate = null)
180 {
181 if (ruin == -1f)
182 {
183 ruin = this.zone.RuinChance;
184 }
185 PartialMap partialMap = MapPiece.Instance.GetMap(type, tags.IsEmpty(this.zone.biome.tags), ruin);
186 if (partialMap == null)
187 {
188 Debug.Log("TryAddMap Piece: no map");
189 return null;
190 }
191 bool flag = partialMap.dir == 1 || partialMap.dir == 3;
192 GenBounds bounds = this.GetBounds(flag ? partialMap.h : partialMap.w, flag ? partialMap.w : partialMap.h, partialMap.ignoreBlock);
193 if (bounds == null)
194 {
195 return null;
196 }
197 partialMap.Apply(new Point(bounds.x, bounds.y), PartialMap.ApplyMode.Apply);
198 if (onCreate != null)
199 {
200 onCreate(partialMap, bounds);
201 }
202 Debug.Log(partialMap.path);
203 return partialMap;
204 }
205
206 // Token: 0x04001A14 RID: 6676
207 public Map map;
208
209 // Token: 0x04001A15 RID: 6677
210 public Zone zone;
211
212 // Token: 0x04001A16 RID: 6678
213 public int Size;
214
215 // Token: 0x04001A17 RID: 6679
216 public int x;
217
218 // Token: 0x04001A18 RID: 6680
219 public int y;
220
221 // Token: 0x04001A19 RID: 6681
222 public int width;
223
224 // Token: 0x04001A1A RID: 6682
225 public int height;
226
227 // Token: 0x04001A1B RID: 6683
228 public int marginPartial;
229
230 // Token: 0x04001A1C RID: 6684
231 public Func<Cell, bool> FuncCheckEmpty;
232}
Definition Cell.cs:10
Definition Map.cs:15
Definition Point.cs:11
Definition Zone.cs:14