Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
GenRoom Class Reference
Inheritance diagram for GenRoom:
GenBounds EClass GenRoomBig GenRoomMonsterHouse

Public Member Functions

void Init (Dungen.Room room)
 
void Init (int _x, int _y, int w, int h)
 
void Populate ()
 
void SpawnMob (Point p)
 
virtual void OnPopulate ()
 
void Fill ()
 
void SetRandomPoint (Action< Point > action)
 
void SetRandomPointCentered (Action< Point > action)
 
- Public Member Functions inherited from GenBounds
void SetFloor (BiomeProfile.Tile t, int x, int z)
 
void SetBlock (BiomeProfile.Tile t, int x, int z, int idMat=-1)
 
void SetFloor (int x, int z, int idMat, int idFloor, int direction=0)
 
void SetBlock (int x, int z, int idMat, int idBlock, int direction=0)
 
bool IsEmpty ()
 
List< PointListEmptyPoint ()
 
GenBounds GetBounds (int w, int h, bool ignoreBlock)
 
GenBounds GetBounds (Map map, Zone zone, int x, int y, int width, int height, int dw, int dh, bool ignoreBlock)
 
PartialMap TryAddMapPiece (MapPiece.Type type=MapPiece.Type.Any, float ruin=-1f, string tags=null, Action< PartialMap, GenBounds > onCreate=null)
 

Public Attributes

BiomeProfile.TileGroup group
 
MapGenDungen gen
 
- Public Attributes inherited from GenBounds
Map map
 
Zone zone
 
int Size
 
int x
 
int y
 
int width
 
int height
 
int marginPartial
 
Func< Cell, bool > FuncCheckEmpty
 

Static Public Attributes

static int[] ListWrecks = new int[6] { 34, 46, 83, 85, 86, 87 }
 
- Static Public Attributes inherited from EClass
static Core core
 

Properties

int Index [get]
 
virtual bool PopulateCluster [get]
 
virtual bool IsBigRoom [get]
 
- Properties inherited from EClass
static Game game [get]
 
static bool AdvMode [get]
 
static Player player [get]
 
static Chara pc [get]
 
static UI ui [get]
 
static Map _map [get]
 
static Zone _zone [get]
 
static FactionBranch Branch [get]
 
static FactionBranch BranchOrHomeBranch [get]
 
static Faction Home [get]
 
static Faction Wilds [get]
 
static Scene scene [get]
 
static BaseGameScreen screen [get]
 
static GameSetting setting [get]
 
static GameData gamedata [get]
 
static ColorProfile Colors [get]
 
static World world [get]
 
static SourceManager sources [get]
 
static SourceManager editorSources [get]
 
static SoundManager Sound [get]
 
static CoreDebug debug [get]
 

Private Attributes

Point _p = new Point()
 
Cell _c
 

Additional Inherited Members

- Static Public Member Functions inherited from GenBounds
static GenBounds Create (Zone z)
 
- Static Public Member Functions inherited from EClass
static int rnd (int a)
 
static int curve (int a, int start, int step, int rate=75)
 
static int rndHalf (int a)
 
static float rndf (float a)
 
static int rndSqrt (int a)
 
static void Wait (float a, Card c)
 
static void Wait (float a, Point p)
 
static int Bigger (int a, int b)
 
static int Smaller (int a, int b)
 

Detailed Description

Definition at line 5 of file GenRoom.cs.

Member Function Documentation

◆ Fill()

void GenRoom.Fill ( )
inline

Definition at line 176 of file GenRoom.cs.

177 {
178 BiomeProfile.TileFloor floor = group.floor;
180 int idMat = block.mat;
181 if (zone is Zone_RandomDungeonNature && EClass.rnd(3) != 0)
182 {
183 block = EClass.core.refs.biomes.dict["Dungeon_Forest"].exterior.block;
185 {
186 idMat = 5;
187 }
188 }
189 for (int i = x; i < x + width; i++)
190 {
191 for (int j = y; j < y + height; j++)
192 {
193 if (map.cells[i, j]._block != 0)
194 {
195 SetBlock(i, j, idMat, block.id, EClass.rnd(EClass.rnd(4) + 1));
196 }
197 SetFloor(i, j, floor.mat, floor.id, EClass.rnd(EClass.rnd(8) + 1));
198 }
199 }
200 }
byte _block
Definition: Cell.cs:30
UD_Biome dict
Definition: CoreRef.cs:142
Biomes biomes
Definition: CoreRef.cs:325
CoreRef refs
Definition: Core.cs:51
Definition: EClass.cs:5
static int rnd(int a)
Definition: EClass.cs:50
static Core core
Definition: EClass.cs:6
int height
Definition: GenBounds.cs:19
void SetBlock(BiomeProfile.Tile t, int x, int z, int idMat=-1)
Definition: GenBounds.cs:43
int width
Definition: GenBounds.cs:17
Zone zone
Definition: GenBounds.cs:9
Map map
Definition: GenBounds.cs:7
void SetFloor(BiomeProfile.Tile t, int x, int z)
Definition: GenBounds.cs:37
BiomeProfile.TileGroup group
Definition: GenRoom.cs:7
Cell[,] cells
Definition: Map.cs:85

References CoreRef.biomes, block, EClass.core, CoreRef.Biomes.dict, BiomeProfile.Tile.id, BiomeProfile.Tile.mat, Core.refs, and EClass.rnd().

◆ Init() [1/2]

void GenRoom.Init ( Dungen::Room  room)
inline

Definition at line 23 of file GenRoom.cs.

24 {
25 x = room.x + 1;
26 y = room.y + 1;
27 width = room.width;
28 height = room.height;
29 Size = width * height;
30 }
int Size
Definition: GenBounds.cs:11

References GenBounds.height, GenBounds.Size, GenBounds.width, GenBounds.x, and GenBounds.y.

Referenced by MapGenDungen.OnGenerateTerrain().

◆ Init() [2/2]

void GenRoom.Init ( int  _x,
int  _y,
int  w,
int  h 
)
inline

Definition at line 32 of file GenRoom.cs.

33 {
34 x = _x;
35 y = _y;
36 width = w;
37 height = h;
38 Size = width * height;
39 }

References GenBounds.height, GenBounds.Size, GenBounds.width, GenBounds.x, and GenBounds.y.

◆ OnPopulate()

virtual void GenRoom.OnPopulate ( )
inlinevirtual

Reimplemented in GenRoomMonsterHouse.

Definition at line 113 of file GenRoom.cs.

114 {
115 for (int i = 0; i < EClass.rnd(3 + Size / 8) + 1; i++)
116 {
117 SetRandomPoint(delegate(Point p)
118 {
119 switch (EClass.rnd(7))
120 {
121 case 0:
122 case 1:
123 if (zone.biome.spawn.thing.Count > 0)
124 {
125 Thing thing2 = ThingGen.CreateFromFilter(zone.biome.spawn.GetRandomThingId(), EClass._zone.DangerLv);
126 if (thing2 != null)
127 {
128 zone.AddCard(thing2, p);
129 }
130 }
131 break;
132 case 2:
133 if (EClass.rnd(5) == 0)
134 {
135 map.SetObj(p.x, p.z, 82);
136 if (EClass.rnd(2) == 0)
137 {
138 map.ApplyBackerObj(p);
139 }
140 }
141 else
142 {
143 map.SetObj(p.x, p.z, ListWrecks.RandomItem());
144 }
145 break;
146 default:
147 SpawnMob(p);
148 break;
149 }
150 });
151 }
152 if (Size <= 25)
153 {
154 return;
155 }
156 for (int j = 0; j < Size / 25 + EClass.rnd(Size / 25); j++)
157 {
158 SetRandomPoint(delegate(Point p)
159 {
160 if (EClass.rnd(3) == 0)
161 {
162 Thing thing = ThingGen.CreateFromFilter(zone.biome.spawn.GetRandomThingId(), EClass._zone.DangerLv);
163 if (thing != null)
164 {
165 zone.AddCard(thing, p);
166 }
167 }
168 else
169 {
170 SpawnMob(p);
171 }
172 });
173 }
174 }
if(item3.idFile==idFirstFile &&item3.id==idFirstTopic)
Definition: UIBook.cs:627
void SetRandomPoint(Action< Point > action)
Definition: GenRoom.cs:202
static int[] ListWrecks
Definition: GenRoom.cs:11
void SpawnMob(Point p)
Definition: GenRoom.cs:105
void SetObj(int x, int z, int id=0, int value=1, int dir=0)
Definition: Map.cs:1522
Definition: Point.cs:9
int x
Definition: Point.cs:36
int z
Definition: Point.cs:39

References if(), ListWrecks, GenBounds.map, EClass.rnd(), Map.SetObj(), SetRandomPoint(), GenBounds.Size, SpawnMob(), Point.x, and Point.z.

Referenced by Populate().

◆ Populate()

void GenRoom.Populate ( )
inline

Definition at line 41 of file GenRoom.cs.

42 {
43 PartialMap partialMap = TryAddMapPiece();
44 OnPopulate();
45 BiomeProfile biome = zone.biome;
46 if (biome.style.lights.Count > 0 && (partialMap == null || !partialMap.result.hasLight))
47 {
48 foreach (BiomeProfile.Cluster.ItemThing light in biome.style.lights)
49 {
50 if (Rand.Range(0f, 1f) > light.chance)
51 {
52 continue;
53 }
54 Thing thing = ThingGen.Create(light.id);
55 Point point = new Point();
56 for (int i = 0; i < 100; i++)
57 {
58 if (thing.TileType.UseMountHeight)
59 {
60 point.Set(x + EClass.rnd(width), y + EClass.rnd(height));
61 Cell cell = point.cell;
62 if (cell.Left.hasDoor || cell.Right.hasDoor || cell.Front.hasDoor || cell.Back.hasDoor || (!cell.Left.HasBlock && !cell.Right.HasBlock && !cell.Front.HasBlock && !cell.Back.HasBlock))
63 {
64 continue;
65 }
66 }
67 else
68 {
69 int a = Mathf.Min(i / 3 + 2, width / 2);
70 int a2 = Mathf.Min(i / 3 + 2, height / 2);
71 point.Set(x + width / 2 + EClass.rnd(a) - EClass.rnd(a), y + height / 2 + EClass.rnd(a2) - EClass.rnd(a2));
72 }
73 if (!point.cell.blocked && !point.HasBlock && !point.HasObj && point.Installed == null)
74 {
75 int desiredDir = thing.TileType.GetDesiredDir(point, 0);
76 if (desiredDir != -1)
77 {
78 thing.dir = desiredDir;
79 }
80 zone.AddCard(thing, point).Install();
81 break;
82 }
83 }
84 break;
85 }
86 }
87 if (!PopulateCluster)
88 {
89 return;
90 }
91 Point point2 = new Point();
92 for (int j = x; j < x + width; j++)
93 {
94 for (int k = y; k < y + height; k++)
95 {
96 point2.Set(j, k);
97 if (!point2.cell.isModified && !point2.cell.blocked)
98 {
99 biome.Populate(point2, interior: true);
100 }
101 }
102 }
103 }
List< Cluster.ItemThing > lights
void Populate(Point point, bool interior=false)
TileType TileType
Definition: Card.cs:2011
Card Install()
Definition: Card.cs:3448
Definition: Cell.cs:7
bool HasBlock
Definition: Cell.cs:643
Cell Back
Definition: Cell.cs:153
Cell Front
Definition: Cell.cs:129
bool isModified
Definition: Cell.cs:438
Cell Left
Definition: Cell.cs:165
Cell Right
Definition: Cell.cs:141
bool hasDoor
Definition: Cell.cs:258
PartialMap TryAddMapPiece(MapPiece.Type type=MapPiece.Type.Any, float ruin=-1f, string tags=null, Action< PartialMap, GenBounds > onCreate=null)
Definition: GenBounds.cs:183
virtual bool PopulateCluster
Definition: GenRoom.cs:19
virtual void OnPopulate()
Definition: GenRoom.cs:113
Result result
Definition: PartialMap.cs:84
Thing Installed
Definition: Point.cs:303
Point Set(int _x, int _z)
Definition: Point.cs:479
bool HasObj
Definition: Point.cs:137
bool HasBlock
Definition: Point.cs:141
Cell cell
Definition: Point.cs:51
Definition: Rand.cs:4
static int Range(int min, int max)
Definition: Rand.cs:42
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
Definition: Thing.cs:8
virtual int GetDesiredDir(Point p, int d)
Definition: TileType.cs:362
virtual bool UseMountHeight
Definition: TileType.cs:209
BiomeProfile biome
Definition: Zone.cs:126
Card AddCard(Card t, Point point)
Definition: Zone.cs:1893

References Zone.AddCard(), Cell.Back, Zone.biome, Algorithms.WeightCell.blocked, Point.cell, ThingGen.Create(), Cell.Front, TileType.GetDesiredDir(), Cell.HasBlock, Point.HasBlock, Cell.hasDoor, PartialMap.Result.hasLight, Point.HasObj, GenBounds.height, Card.Install(), Point.Installed, Cell.isModified, Cell.Left, BiomeProfile.Style.lights, OnPopulate(), BiomeProfile.Populate(), PopulateCluster, Rand.Range(), PartialMap.result, Cell.Right, EClass.rnd(), Point.Set(), BiomeProfile.style, Card.TileType, GenBounds.TryAddMapPiece(), TileType.UseMountHeight, GenBounds.width, GenBounds.x, GenBounds.y, and GenBounds.zone.

Referenced by MapGenDungen.OnGenerateTerrain().

◆ SetRandomPoint()

void GenRoom.SetRandomPoint ( Action< Point action)
inline

Definition at line 202 of file GenRoom.cs.

203 {
204 int a = Mathf.Max(width - 2, 1);
205 int a2 = Mathf.Max(height - 2, 1);
206 for (int i = 0; i < 100; i++)
207 {
208 _p.x = x + 1 + EClass.rnd(a);
209 _p.z = y + 1 + EClass.rnd(a2);
210 _c = map.cells[_p.x, _p.z];
211 if (!_c.blocked && !_c.HasBlock && !_p.HasThing && !_p.HasChara)
212 {
213 action(_p);
214 break;
215 }
216 }
217 }
Point _p
Definition: GenRoom.cs:13
Cell _c
Definition: GenRoom.cs:15
bool HasThing
Definition: Point.cs:239
bool HasChara
Definition: Point.cs:226

References EClass.rnd().

Referenced by OnPopulate(), and GenRoomMonsterHouse.OnPopulate().

◆ SetRandomPointCentered()

void GenRoom.SetRandomPointCentered ( Action< Point action)
inline

Definition at line 219 of file GenRoom.cs.

220 {
221 int a = Mathf.Max(width / 2 - 1, 1);
222 int a2 = Mathf.Max(height / 2 - 1, 1);
223 for (int i = 0; i < 100; i++)
224 {
225 _p.x = x + width / 2 + EClass.rnd(EClass.rnd(a) + 1) - EClass.rnd(EClass.rnd(a) + 1);
226 _p.z = y + height / 2 + EClass.rnd(EClass.rnd(a2) + 1) - EClass.rnd(EClass.rnd(a2) + 1);
227 _c = map.cells[_p.x, _p.z];
228 if (!_c.blocked && !_c.HasBlock && !_p.HasThing && !_p.HasChara)
229 {
230 action(_p);
231 break;
232 }
233 }
234 }

References EClass.rnd().

◆ SpawnMob()

void GenRoom.SpawnMob ( Point  p)
inline

Definition at line 105 of file GenRoom.cs.

106 {
107 if (EClass.rnd(100) <= 55 + zone.DangerLv * 3)
108 {
109 zone.SpawnMob(p);
110 }
111 }
Chara SpawnMob(Point pos=null, SpawnSetting setting=null)
Definition: Zone.cs:2543
override int DangerLv
Definition: Zone.cs:107

References Zone.DangerLv, EClass.rnd(), Zone.SpawnMob(), and GenBounds.zone.

Referenced by OnPopulate(), and GenRoomMonsterHouse.OnPopulate().

Member Data Documentation

◆ _c

Cell GenRoom._c
private

Definition at line 15 of file GenRoom.cs.

◆ _p

Point GenRoom._p = new Point()
private

Definition at line 13 of file GenRoom.cs.

◆ gen

MapGenDungen GenRoom.gen

Definition at line 9 of file GenRoom.cs.

◆ group

BiomeProfile.TileGroup GenRoom.group

Definition at line 7 of file GenRoom.cs.

◆ ListWrecks

int [] GenRoom.ListWrecks = new int[6] { 34, 46, 83, 85, 86, 87 }
static

Definition at line 11 of file GenRoom.cs.

Referenced by OnPopulate().

Property Documentation

◆ Index

int GenRoom.Index
get

Definition at line 17 of file GenRoom.cs.

◆ IsBigRoom

virtual bool GenRoom.IsBigRoom
get

Definition at line 21 of file GenRoom.cs.

◆ PopulateCluster

virtual bool GenRoom.PopulateCluster
get

Definition at line 19 of file GenRoom.cs.

Referenced by Populate().


The documentation for this class was generated from the following file: