14 return this.x + this.y * this.Size;
20 public virtual bool PopulateCluster
30 public virtual bool IsBigRoom
39 public void Init(Dungen.Room room)
43 this.width = room.width;
44 this.height = room.height;
45 this.Size = this.width * this.height;
49 public void Init(
int _x,
int _y,
int w,
int h)
55 this.Size = this.width * this.height;
59 public void Populate()
64 if (biome.style.lights.Count > 0 && (partialMap ==
null || !partialMap.result.hasLight))
68 if (Rand.Range(0f, 1f) <= itemThing.chance)
75 if (!thing.TileType.UseMountHeight)
77 int a = Mathf.Min(i / 3 + 2, this.width / 2);
78 int a2 = Mathf.Min(i / 3 + 2, this.height / 2);
79 point.Set(this.x + this.width / 2 +
EClass.rnd(a) -
EClass.rnd(a),
this.y +
this.height / 2 +
EClass.rnd(a2) -
EClass.rnd(a2));
82 point.Set(this.x +
EClass.rnd(
this.width),
this.y +
EClass.rnd(
this.height));
83 global::Cell cell = point.cell;
84 if (!cell.Left.hasDoor && !cell.Right.hasDoor && !cell.Front.hasDoor && !cell.Back.hasDoor)
86 if (cell.Left.HasBlock || cell.Right.HasBlock || cell.Front.HasBlock || cell.Back.HasBlock)
95 if (!point.cell.blocked && !point.HasBlock && !point.HasObj && point.Installed ==
null)
97 int desiredDir = thing.TileType.GetDesiredDir(point, 0);
100 thing.dir = desiredDir;
102 this.zone.AddCard(thing, point).Install();
111 if (this.PopulateCluster)
114 for (
int j = this.x; j < this.x + this.width; j++)
116 for (
int k = this.y; k < this.y + this.height; k++)
119 if (!point2.cell.isModified && !point2.cell.blocked)
121 biome.Populate(point2,
true);
129 public void SpawnMob(
Point p)
131 if (
EClass.rnd(100) > 55 +
this.zone.DangerLv * 3)
135 this.zone.SpawnMob(p,
null);
139 public virtual void OnPopulate()
141 for (
int i = 0; i <
EClass.rnd(3 + this.Size / 8) + 1; i++)
143 this.SetRandomPoint(delegate(
Point p)
156 this.map.SetObj(p.x, p.z,
GenRoom.ListWrecks.RandomItem<
int>(), 1, 0);
159 this.map.SetObj(p.x, p.z, 82, 1, 0);
162 this.map.ApplyBackerObj(p, -1);
167 else if (this.zone.biome.spawn.thing.Count > 0)
169 Thing thing =
ThingGen.CreateFromFilter(this.zone.biome.spawn.GetRandomThingId(),
EClass._zone.DangerLv);
172 this.zone.AddCard(thing, p);
180 for (
int j = 0; j < this.Size / 25 +
EClass.rnd(this.Size / 25); j++)
182 this.SetRandomPoint(delegate(
Point p)
186 Thing thing =
ThingGen.CreateFromFilter(this.zone.biome.spawn.GetRandomThingId(),
EClass._zone.DangerLv);
189 this.zone.AddCard(thing, p);
207 for (
int i = this.x; i < this.x + this.width; i++)
209 for (
int j = this.y; j < this.y + this.height; j++)
211 if (this.map.cells[i, j]._block != 0)
213 base.SetBlock(i, j, block.mat, block.id,
EClass.rnd(
EClass.rnd(4) + 1));
215 base.SetFloor(i, j, floor.mat, floor.id,
EClass.rnd(
EClass.rnd(8) + 1));
221 public void SetRandomPoint(Action<Point> action)
223 int a = Mathf.Max(this.width - 2, 1);
224 int a2 = Mathf.Max(this.height - 2, 1);
225 for (
int i = 0; i < 100; i++)
227 this._p.x = this.x + 1 +
EClass.rnd(a);
228 this._p.z = this.y + 1 +
EClass.rnd(a2);
229 this._c = this.map.cells[this._p.x, this._p.z];
230 if (!this._c.blocked && !
this._c.HasBlock && !
this._p.HasThing && !
this._p.HasChara)
239 public void SetRandomPointCentered(Action<Point> action)
241 int a = Mathf.Max(this.width / 2 - 1, 1);
242 int a2 = Mathf.Max(this.height / 2 - 1, 1);
243 for (
int i = 0; i < 100; i++)
247 this._c = this.map.cells[this._p.x, this._p.z];
248 if (!this._c.blocked && !
this._c.HasBlock && !
this._p.HasThing && !
this._p.HasChara)
263 public static int[] ListWrecks =
new int[]
277 private global::Cell _c;