Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
MapGenDungen Class Reference
Inheritance diagram for MapGenDungen:
BaseMapGen GenBounds EClass

Public Member Functions

GenRoom ChooseRoom ()
 
- Public Member Functions inherited from BaseMapGen
void SetSize (int size, int _poiSize)
 
void Generate (ZoneBlueprint _bp)
 
- 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)
 

Protected Member Functions

override bool OnGenerateTerrain ()
 
- Protected Member Functions inherited from BaseMapGen
virtual void GenerateTerrain ()
 
virtual bool OnGenerateTerrain ()
 

Properties

static MapGenDungen Instance [get]
 
- Properties inherited from BaseMapGen
bool extraBiome [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]
 

Static Private Attributes

static MapGenDungen _Instance
 

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)
 
- Public Attributes inherited from BaseMapGen
NoiseLayer layerHeight
 
NoiseLayer layerRiver
 
NoiseLayer layerStratum
 
NoiseLayer layerBiome
 
BiomeProfile[] biomeProfiles
 
BiomeProfile biomeShore
 
BiomeProfile biomeSand
 
BiomeProfile biomeWater
 
Crawler[] crawlers
 
ZoneBlueprint bp
 
ZoneProfile zp
 
int blockHeight
 
int seed
 
int lastSize
 
int OX
 
int OZ
 
BiomeProfile[,] biomes
 
bool[,] subBiomes
 
MapGenVariation variation
 
MapHeight hSetting
 
- 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 inherited from BaseMapGen
static string err
 
- Static Public Attributes inherited from EClass
static Core core
 
- Protected Attributes inherited from BaseMapGen
bool skipWater
 
float[,] heights1
 
float[,] heights2
 
float[,] heights3
 
float[,] waters
 
float[,] heights3d
 
float waterCount
 

Detailed Description

Definition at line 5 of file MapGenDungen.cs.

Member Function Documentation

◆ ChooseRoom()

GenRoom MapGenDungen.ChooseRoom ( )
inline

Definition at line 275 of file MapGenDungen.cs.

276 {
277 if (EClass.rnd(100) < 5)
278 {
279 return new GenRoomMonsterHouse();
280 }
281 return new GenRoom();
282 }
Definition: EClass.cs:5
static int rnd(int a)
Definition: EClass.cs:50

References EClass.rnd().

Referenced by OnGenerateTerrain().

◆ OnGenerateTerrain()

override bool MapGenDungen.OnGenerateTerrain ( )
inlineprotectedvirtual

Reimplemented from BaseMapGen.

Definition at line 11 of file MapGenDungen.cs.

12 {
13 DunGen.Init();
14 MapGenerator generator = zone.Generator;
15 MapData mapData = DunGen.Generate(generator);
16 width = mapData.size_X + 2;
17 height = mapData.size_Y + 2;
18 SetSize(Mathf.Max(width, height), 10);
22 map.config.blockHeight = EClass.core.gameSetting.gen.defaultBlockHeight;
23 BiomeProfile biome = zone.biome;
24 if (zone is Zone_Void)
25 {
26 biome = biome.Instantiate();
27 biome.interior.block.mat = MATERIAL.GetRandomMaterialFromCategory(zone.lv % 50 + 10, "rock", EClass.sources.materials.alias["granite"]).id;
28 biome.interior.block.matSub = MATERIAL.GetRandomMaterialFromCategory(zone.lv % 50 + 10, "rock", EClass.sources.materials.alias["granite"]).id;
29 biome.interior.floor.mat = MATERIAL.GetRandomMaterialFromCategory(zone.lv % 50 + 10, "rock", EClass.sources.materials.alias["granite"]).id;
30 biome.interior.floor.matSub = MATERIAL.GetRandomMaterialFromCategory(zone.lv % 50 + 10, "rock", EClass.sources.materials.alias["granite"]).id;
31 biome.exterior.block.mat = MATERIAL.GetRandomMaterialFromCategory(zone.lv % 50 + 10, "rock", EClass.sources.materials.alias["granite"]).id;
32 biome.exterior.block.matSub = MATERIAL.GetRandomMaterialFromCategory(zone.lv % 50 + 10, "rock", EClass.sources.materials.alias["granite"]).id;
33 biome.exterior.floor.mat = MATERIAL.GetRandomMaterialFromCategory(zone.lv % 50 + 10, "rock", EClass.sources.materials.alias["granite"]).id;
34 biome.exterior.floor.matSub = MATERIAL.GetRandomMaterialFromCategory(zone.lv % 50 + 10, "rock", EClass.sources.materials.alias["granite"]).id;
35 }
38 int idMat = -1;
39 if (zone is Zone_RandomDungeonNature && EClass.rnd(3) != 0)
40 {
41 block = EClass.core.refs.biomes.dict["Dungeon_Forest"].exterior.block;
43 {
44 idMat = 5;
45 }
46 }
47 bool flag = zone.lv <= 0;
48 bool flag2 = false;
49 bool flag3 = false;
50 Point point = new Point();
51 Thing thing = null;
52 Thing thing2 = null;
53 for (int i = 0; i < mapData.size_X + 2; i++)
54 {
55 for (int j = 0; j < mapData.size_Y + 2; j++)
56 {
57 if (i == 0 || j == 0 || i >= mapData.size_X || j >= mapData.size_Y)
58 {
59 SetFloor(floor, i, j);
60 SetBlock(block, i, j, idMat);
61 continue;
62 }
63 Dungen.Cell cell = mapData.cellsOnMap[i - 1, j - 1];
64 CellType type = cell.type;
65 point.Set(i, j);
66 SetFloor(floor, i, j);
67 switch (type.name)
68 {
69 case "Entrance":
70 {
71 if (flag2)
72 {
73 Debug.LogError("exception: already created entrance");
74 break;
75 }
76 flag2 = true;
77 Thing thing4 = ThingGen.Create(biome.style.GetIdStairs(flag), biome.style.matStairs);
78 if (!flag)
79 {
80 thing = thing4;
81 }
82 else
83 {
84 thing2 = thing4;
85 }
86 zone.AddCard(thing4, i, j).Install();
87 break;
88 }
89 case "Exit":
90 {
92 {
93 break;
94 }
95 if (flag3)
96 {
97 Debug.LogError("exception: already created exit");
98 break;
99 }
100 flag3 = true;
101 Thing thing3 = ThingGen.Create(EClass._zone.LockExit ? "stairs_locked" : biome.style.GetIdStairs(!flag), zone.LockExit ? (-1) : biome.style.matStairs);
102 if (flag)
103 {
104 thing = thing3;
105 }
106 else
107 {
108 thing2 = thing3;
109 }
110 zone.AddCard(thing3, i, j).Install();
111 break;
112 }
113 case "Door":
114 if (!(biome.style.doorChance < Rand.Range(0f, 1f)))
115 {
116 SetBlock(block, i, j, idMat);
117 Thing t2 = ThingGen.Create(biome.style.GetIdDoor(), biome.style.matDoor);
118 zone.AddCard(t2, i, j).Install();
119 }
120 break;
121 case "Abyss":
122 SetBlock(block, i, j, idMat);
123 break;
124 default:
125 if (type.passable == generator.reversePassage)
126 {
127 SetBlock(block, i, j, idMat);
128 }
129 break;
130 }
131 if (!cell.isRoomCell)
132 {
133 biome.Populate(point);
134 }
135 }
136 }
137 if (!flag2)
138 {
139 Debug.LogError("exception: Failed to create entrance:");
140 return false;
141 }
142 if (zone.ShouldMakeExit && !flag3)
143 {
144 Debug.LogError("exception: Failed to create exist:");
145 return false;
146 }
147 if (thing2 != null)
148 {
149 thing2.pos.cell._block = 0;
150 thing2.pos.cell.obj = 0;
151 }
152 if (thing != null)
153 {
154 thing.pos.cell._block = 0;
155 thing.pos.cell.obj = 0;
156 }
157 Dictionary<int, GenRoom> rooms = new Dictionary<int, GenRoom>();
158 int count = 0;
159 int num = 0;
160 foreach (Dungen.Room room in mapData.rooms)
161 {
162 if (room.width != 0 && room.height != 0)
163 {
164 num++;
165 }
166 }
167 if (num == 0)
168 {
169 mapData.rooms.Clear();
170 }
171 if (mapData.rooms.Count == 0)
172 {
173 GenRoomBig genRoomBig = new GenRoomBig();
174 genRoomBig.Init(1, 1, width - 1, height - 1);
175 SetRoom(genRoomBig);
176 }
177 else
178 {
179 foreach (Dungen.Room room2 in mapData.rooms)
180 {
181 GenRoom genRoom = ChooseRoom();
182 genRoom.Init(room2);
183 SetRoom(genRoom);
184 }
185 }
187 foreach (GenRoom value in rooms.Values)
188 {
189 value.Populate();
190 }
191 zone.OnGenerateRooms(this);
192 map.ReloadRoom();
193 Debug.Log("Dungen: room:" + rooms.Count + "/" + mapData.rooms.Count + " width:" + width + " height:" + height);
194 int num2 = EClass.rnd(Size * Size / 50 + EClass.rnd(20)) + 5;
195 num2 = num2 * Mathf.Min(20 + zone.DangerLv * 5, 100) / 100;
197 {
198 num2 /= 5;
199 }
200 for (int k = 0; k < num2; k++)
201 {
202 point = EClass._map.GetRandomPoint();
203 if (!point.cell.isModified && !point.HasThing && !point.HasBlock && !point.HasObj)
204 {
206 EClass._zone.AddCard(t3, point).Install();
207 }
208 }
210 {
211 Crawler crawler = Crawler.Create("pasture");
212 int tries = 3;
213 crawler.CrawlUntil(EClass._map, () => EClass._map.GetRandomPoint(), tries, delegate(Crawler.Result r)
214 {
215 int id = ((EClass.rnd(3) == 0) ? 108 : 105);
216 foreach (Point point2 in r.points)
217 {
218 if (!point2.cell.isModified && !point2.HasThing && !point2.HasBlock && !point2.HasObj)
219 {
220 map.SetObj(point2.x, point2.z, id);
221 int num3 = 3;
222 if (EClass.rnd(6) == 0)
223 {
224 num3++;
225 }
226 point2.growth.SetStage(num3);
227 }
228 }
229 return false;
230 });
231 }
232 map.things.ForeachReverse(delegate(Thing t)
233 {
234 if (t.trait is TraitDoor traitDoor && !traitDoor.IsValid())
235 {
236 Debug.Log("Purging Door:" + t.Name + "/" + t.pos);
237 t.Destroy();
238 }
239 });
240 if (thing != null)
241 {
242 ClearPos(thing);
243 }
244 if (thing2 != null)
245 {
246 ClearPos(thing2);
247 }
248 return true;
249 static void ClearPos(Thing t)
250 {
251 foreach (Card item in t.pos.ListCards())
252 {
253 if (item != t && item.isThing)
254 {
255 item.Destroy();
256 }
257 }
258 t.pos.SetObj();
259 t.pos.SetBlock();
260 t.pos.cell.height = 0;
261 }
262 void SetRoom(GenRoom room)
263 {
264 room.map = map;
265 room.zone = zone;
266 room.gen = this;
267 room.group = ((zone is Zone_RandomDungeonNature) ? biome.exterior : biome.interior);
268 rooms[room.Index] = room;
269 room.Fill();
270 Debug.Log("Room" + count + " " + room.width + "*" + room.height + " " + room);
271 count++;
272 }
273 }
void SetSize(int size, int _poiSize)
Definition: BaseMapGen.cs:91
string GetIdStairs(bool upstairs)
TileGroup exterior
TileGroup interior
void Populate(Point point, bool interior=false)
Definition: Card.cs:11
Point pos
Definition: Card.cs:55
Trait trait
Definition: Card.cs:49
Card Install()
Definition: Card.cs:3448
bool isModified
Definition: Cell.cs:438
UD_Biome dict
Definition: CoreRef.cs:142
Biomes biomes
Definition: CoreRef.cs:325
CoreRef refs
Definition: Core.cs:51
GameSetting gameSetting
Definition: Core.cs:47
static Crawler Create(string id)
Definition: Crawler.cs:190
bool CrawlUntil(Map map, Func< Point > onStart, int tries, Func< Result, bool > canComplete, Action onFail=null)
Definition: Crawler.cs:57
static Core core
Definition: EClass.cs:6
static Zone _zone
Definition: EClass.cs:20
static Map _map
Definition: EClass.cs:18
static SourceManager sources
Definition: EClass.cs:42
GenSetting gen
Definition: GameSetting.cs:311
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
int Size
Definition: GenBounds.cs:11
Map map
Definition: GenBounds.cs:7
void SetFloor(BiomeProfile.Tile t, int x, int z)
Definition: GenBounds.cs:37
void Fill()
Definition: GenRoom.cs:176
void Populate()
Definition: GenRoom.cs:41
int Index
Definition: GenRoom.cs:17
void Init(Dungen.Room room)
Definition: GenRoom.cs:23
static SourceMaterial.Row GetRandomMaterialFromCategory(int lv, string cat, SourceMaterial.Row fallback)
Definition: MATERIAL.cs:81
GenRoom ChooseRoom()
Point GetRandomPoint(Point center, int radius, int tries=100, bool mustBeWalkable=true, bool requireLos=true)
Definition: Map.cs:2193
void SetZone(Zone _zone)
Definition: Map.cs:181
List< Thing > things
Definition: Map.cs:49
POIMap poiMap
Definition: Map.cs:97
void ReloadRoom()
Definition: Map.cs:325
void CreateNew(int size, bool setReference=true)
Definition: Map.cs:153
void RefreshAllTiles()
Definition: Map.cs:2086
void Reset()
Definition: POIMap.cs:35
Definition: Point.cs:9
void SetObj(int id=0, int value=1, int dir=0)
Definition: Point.cs:892
List< Card > ListCards(bool includeMasked=false)
Definition: Point.cs:1015
Point Set(int _x, int _z)
Definition: Point.cs:479
bool HasThing
Definition: Point.cs:239
void SetBlock(int idMat=0, int idBlock=0)
Definition: Point.cs:882
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
SourceMaterial materials
int lv
Definition: Spatial.cs:142
static Thing CreateFromCategory(string idCat, int lv=-1)
Definition: ThingGen.cs:75
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
Definition: Thing.cs:8
bool IsValid(bool shouldLookGood=true)
Definition: TraitDoor.cs:115
virtual bool LockExit
Definition: Zone.cs:268
BiomeProfile biome
Definition: Zone.cs:126
virtual bool ShouldMakeExit
Definition: Zone.cs:359
MapGenerator Generator
Definition: Zone.cs:134
virtual void OnGenerateRooms(BaseMapGen gen)
Definition: Zone.cs:2525
override int DangerLv
Definition: Zone.cs:107
Card AddCard(Card t, Point point)
Definition: Zone.cs:1893

References EClass._map, EClass._zone, Zone.AddCard(), Zone.biome, CoreRef.biomes, BiomeProfile.TileGroup.block, block, ChooseRoom(), EClass.core, Crawler.CrawlUntil(), Crawler.Create(), ThingGen.Create(), ThingGen.CreateFromCategory(), Map.CreateNew(), Zone.DangerLv, Debug, GameSetting.GenSetting.defaultBlockHeight, CoreRef.Biomes.dict, BiomeProfile.Style.doorChance, BiomeProfile.exterior, BiomeProfile.TileGroup.floor, Core.gameSetting, GameSetting.gen, Zone.Generator, BiomeProfile.Style.GetIdDoor(), BiomeProfile.Style.GetIdStairs(), MATERIAL.GetRandomMaterialFromCategory(), Map.GetRandomPoint(), GenBounds.height, GenRoom.Init(), Card.Install(), Zone.LockExit, Spatial.lv, GenBounds.map, BiomeProfile.Style.matDoor, SourceManager.materials, BiomeProfile.Style.matStairs, Zone.OnGenerateRooms(), Map.poiMap, GenRoom.Populate(), BiomeProfile.Populate(), Rand.Range(), Map.RefreshAllTiles(), Core.refs, Map.ReloadRoom(), POIMap.Reset(), EClass.rnd(), Point.Set(), GenBounds.SetBlock(), GenBounds.SetFloor(), BaseMapGen.SetSize(), Map.SetZone(), Zone.ShouldMakeExit, GenBounds.Size, EClass.sources, BiomeProfile.style, GenBounds.width, and GenBounds.zone.

Member Data Documentation

◆ _Instance

MapGenDungen MapGenDungen._Instance
staticprivate

Definition at line 7 of file MapGenDungen.cs.

Property Documentation

◆ Instance

MapGenDungen MapGenDungen.Instance
staticget

Definition at line 9 of file MapGenDungen.cs.

Referenced by ZoneBlueprint.GenerateMap().


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