11 BiomeProfile.BaseTile.SubType subType = g.subType;
17 return EClass.rnd(10) == 0;
19 return EClass.rnd(20) == 0;
21 return subType == BiomeProfile.BaseTile.SubType.Pattern && (x + y % 2) % 2 == 0;
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));
35 bool flag = this.IsSub(t, x, z);
36 this.SetBlock(x, z, flag ? t.matSub : t.mat, flag ? t.idSub : t.id, 0);
40 public void SetFloor(
int x,
int z,
int idMat,
int idFloor,
int direction = 0)
42 Cell cell = this.map.cells[x, z];
43 cell._floorMat = (byte)idMat;
44 cell._floor = (byte)idFloor;
45 cell.floorDir = direction;
49 public void SetBlock(
int x,
int z,
int idMat,
int idBlock,
int direction = 0)
51 Cell cell = this.map.cells[x, z];
52 cell._blockMat = (byte)idMat;
53 cell._block = (byte)idBlock;
54 cell.blockDir = direction;
61 for (
int i = this.y - this.marginPartial; i < this.y + this.height + this.marginPartial; i++)
63 if (i < 0 || i >=
EClass._map.Size)
67 for (
int j = this.x - this.marginPartial; j < this.x + this.width + this.marginPartial; j++)
69 if (j < 0 || j >=
EClass._map.Size)
73 Cell cell = this.map.cells[j, i];
74 if (this.FuncCheckEmpty !=
null && !this.FuncCheckEmpty(cell))
78 if (cell.blocked || cell.HasBlock || cell.Installed !=
null)
88 public List<Point> ListEmptyPoint()
90 List<Point> list =
new List<Point>();
91 for (
int i = this.y; i < this.y + this.height; i++)
93 if (i >= 0 && i <
EClass._map.Size)
95 for (
int j = this.x; j < this.x + this.width; j++)
97 if (j >= 0 && j <
EClass._map.Size)
99 Cell cell = this.map.cells[j, i];
100 if (!cell.blocked && !cell.HasBlock && (cell.Installed ==
null || !cell.Installed.trait.IsBlockPath))
125 width = bounds.Width,
126 height = bounds.Height
131 public GenBounds GetBounds(
int w,
int h,
bool ignoreBlock)
133 return this.GetBounds(this.map, this.zone, this.x, this.y, this.width, this.height, w, h, ignoreBlock);
137 public GenBounds GetBounds(
Map map,
Zone zone,
int x,
int y,
int width,
int height,
int dw,
int dh,
bool ignoreBlock)
139 if (dw >= width || dh >= height)
151 marginPartial = this.marginPartial,
152 FuncCheckEmpty = this.FuncCheckEmpty
154 for (
int i = 0; i < 200; i++)
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)
167 genBounds.x =
EClass.rnd(width - dw) + x;
168 genBounds.y =
EClass.rnd(height - dh) + y;
169 if (genBounds.IsEmpty())
179 public PartialMap TryAddMapPiece(
MapPiece.Type type =
MapPiece.Type.Any,
float ruin = -1f,
string tags =
null, Action<PartialMap, GenBounds> onCreate =
null)
183 ruin = this.zone.RuinChance;
185 PartialMap partialMap =
MapPiece.Instance.GetMap(type, tags.IsEmpty(
this.zone.biome.tags), ruin);
186 if (partialMap ==
null)
188 Debug.Log(
"TryAddMap Piece: no map");
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);
197 partialMap.Apply(
new Point(bounds.x, bounds.y),
PartialMap.ApplyMode.Apply);
198 if (onCreate !=
null)
200 onCreate(partialMap, bounds);
202 Debug.Log(partialMap.path);
228 public int marginPartial;
231 public Func<Cell, bool> FuncCheckEmpty;