Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
Zone_Dungeon.cs
Go to the documentation of this file.
1using System.Linq;
2using Algorithms;
3using UnityEngine;
4
5public class Zone_Dungeon : Zone
6{
7 public enum RailType
8 {
9 Mine,
10 Factoy
11 }
12
13 public override string IDGenerator => "Dungeon";
14
15 public override bool DisableRooms => !base.IsPCFaction;
16
17 public override bool UseFog => true;
18
19 public override bool ShowDangerLv => true;
20
21 public override float PrespawnRate
22 {
23 get
24 {
25 if (!idExport.IsEmpty())
26 {
27 return 0f;
28 }
29 return 1f;
30 }
31 }
32
33 public override bool IsReturnLocation => GetDeepestLv() == base.lv;
34
35 public override int StartLV => -1;
36
37 public override bool BlockBorderExit => true;
38
39 public override float EvolvedChance
40 {
41 get
42 {
43 if (!EClass.debug.test)
44 {
45 return 0.08f;
46 }
47 return 1f;
48 }
49 }
50
51 public override float BigDaddyChance
52 {
53 get
54 {
55 if (!EClass.debug.test)
56 {
57 return 0.08f;
58 }
59 return 1f;
60 }
61 }
62
63 public override float ShrineChance
64 {
65 get
66 {
67 if (!EClass.debug.test)
68 {
69 return 0.35f;
70 }
71 return 1f;
72 }
73 }
74
75 public override bool IsSnowCovered => false;
76
77 public override bool CountDeepestLevel => true;
78
80
81 public override string GetDungenID()
82 {
83 if (EClass.rnd(2) == 0)
84 {
85 return "DungeonRuins";
86 }
87 if (EClass.rnd(4) == 0)
88 {
89 return "Cavern";
90 }
91 if (EClass.rnd(8) == 0)
92 {
93 return "RoundRooms";
94 }
95 return "Dungeon";
96 }
97
98 public override void OnGenerateMap()
99 {
100 if (idExport.IsEmpty())
101 {
106 }
107 }
108
109 public void PlaceRail(RailType railType = RailType.Mine)
110 {
111 int idRail = 31;
112 string idTrolley = "390";
113 bool placeStopper = true;
114 int num = 8;
115 if (railType == RailType.Factoy)
116 {
117 idRail = 110;
118 placeStopper = false;
119 num = EClass.rnd(4) + 1;
120 }
121 PathManager.Instance._pathfinder.PunishChangeDirection = true;
122 PathManager.Instance._pathfinder.Diagonals = false;
125 if (traitStairsDown != null && traitStairsUp != null)
126 {
127 TryPlaceRail(traitStairsDown.owner.pos, traitStairsUp.owner.pos);
128 }
129 int num2 = 0;
130 for (int i = 0; i < 200; i++)
131 {
133 {
134 num2++;
135 if (num2 > num)
136 {
137 break;
138 }
139 }
140 }
141 PathManager.Instance._pathfinder.Diagonals = true;
142 bool TryPlaceRail(Point p1, Point p2)
143 {
144 if (p1.Distance(p2) < 20)
145 {
146 return false;
147 }
149 if (!pathProgress.HasPath)
150 {
151 return false;
152 }
153 Point point = new Point();
154 Point point2 = new Point();
155 bool flag = false;
156 int num3 = 0;
157 foreach (PathFinderNode node in pathProgress.nodes)
158 {
159 Point shared = Point.GetShared(node.X, node.Z);
160 for (int j = -1; j < 2; j++)
161 {
162 for (int k = -1; k < 2; k++)
163 {
164 point2.Set(shared.x + k, shared.z + j);
165 if ((Mathf.Abs(k) != 1 || Mathf.Abs(j) != 1) && point2.IsValid && point2.sourceObj.id == 31 && !point2.Equals(point))
166 {
167 flag = true;
168 if (num3 != 0)
169 {
170 break;
171 }
172 return false;
173 }
174 }
175 }
176 if (shared.sourceObj.id == idRail)
177 {
178 break;
179 }
180 shared.SetBlock();
181 shared.SetObj(idRail);
182 shared.Things.ForeachReverse(delegate(Thing t)
183 {
184 if (t.trait.CanBeDestroyed)
185 {
186 t.Destroy();
187 }
188 });
189 if (flag)
190 {
191 break;
192 }
193 num3++;
194 point.Set(shared);
195 }
196 if (!flag && placeStopper)
197 {
198 Point shared2 = Point.GetShared(pathProgress.nodes.LastItem().X, pathProgress.nodes.LastItem().Z);
199 Cell cell = shared2.cell;
200 int dir = ((cell.Front.obj != 31) ? ((cell.Right.obj == 31) ? 1 : ((cell.Back.obj == 31) ? 2 : 3)) : 0);
201 if (!shared2.HasThing)
202 {
203 EClass._zone.AddCard(ThingGen.Create("1208"), shared2).Install().dir = dir;
204 }
205 }
206 if (num3 > 2)
207 {
208 Point shared3 = Point.GetShared(pathProgress.nodes.First().X, pathProgress.nodes.First().Z);
209 if (!shared3.HasThing)
210 {
211 EClass._zone.AddCard(ThingGen.Create(idTrolley), shared3).Install();
212 }
213 }
214 return true;
215 }
216 }
217}
Point pos
Definition: Card.cs:55
Trait trait
Definition: Card.cs:49
int dir
Definition: Card.cs:142
Definition: Cell.cs:7
byte obj
Definition: Cell.cs:38
Cell Right
Definition: Cell.cs:141
bool test
Definition: CoreDebug.cs:169
Definition: EClass.cs:5
static int rnd(int a)
Definition: EClass.cs:50
static Zone _zone
Definition: EClass.cs:20
static Map _map
Definition: EClass.cs:18
static Chara pc
Definition: EClass.cs:14
static CoreDebug debug
Definition: EClass.cs:48
Point GetRandomSurface(int x, int z, int radius, bool walkable=true, bool allowWater=false)
Definition: MapBounds.cs:182
Thing FindThing(Func< Thing, bool > func)
Definition: Map.cs:2570
MapBounds bounds
Definition: Map.cs:52
void RequestPathImmediate(PathProgress progress)
Definition: PathManager.cs:41
static PathManager Instance
Definition: PathManager.cs:16
Definition: Point.cs:9
static Point GetShared(int x, int z)
Definition: Point.cs:366
void SetObj(int id=0, int value=1, int dir=0)
Definition: Point.cs:892
Point Set(int _x, int _z)
Definition: Point.cs:479
List< Thing > Things
Definition: Point.cs:314
int x
Definition: Point.cs:36
int z
Definition: Point.cs:39
bool HasThing
Definition: Point.cs:239
SourceObj.Row sourceObj
Definition: Point.cs:69
void SetBlock(int idMat=0, int idBlock=0)
Definition: Point.cs:882
int Distance(Point p)
Definition: Point.cs:953
Cell cell
Definition: Point.cs:51
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
Definition: Thing.cs:8
virtual bool CanBeDestroyed
Definition: Trait.cs:285
Card owner
Definition: Trait.cs:26
override bool IsReturnLocation
Definition: Zone_Dungeon.cs:33
override bool BlockBorderExit
Definition: Zone_Dungeon.cs:37
override float EvolvedChance
Definition: Zone_Dungeon.cs:40
override bool UseFog
Definition: Zone_Dungeon.cs:17
override float PrespawnRate
Definition: Zone_Dungeon.cs:22
override float ShrineChance
Definition: Zone_Dungeon.cs:64
void PlaceRail(RailType railType=RailType.Mine)
override string IDGenerator
Definition: Zone_Dungeon.cs:13
override bool CountDeepestLevel
Definition: Zone_Dungeon.cs:77
override bool IsSnowCovered
Definition: Zone_Dungeon.cs:75
override void OnGenerateMap()
Definition: Zone_Dungeon.cs:98
override ZoneTransition.EnterState RegionEnterState
Definition: Zone_Dungeon.cs:79
override string GetDungenID()
Definition: Zone_Dungeon.cs:81
override bool DisableRooms
Definition: Zone_Dungeon.cs:15
override int StartLV
Definition: Zone_Dungeon.cs:35
override float BigDaddyChance
Definition: Zone_Dungeon.cs:52
override bool ShowDangerLv
Definition: Zone_Dungeon.cs:19
Definition: Zone.cs:12
virtual string idExport
Definition: Zone.cs:147
Chara TryGenerateEvolved(bool force=false, Point p=null)
Definition: Zone.cs:2436
int GetDeepestLv()
Definition: Zone.cs:2815
void TryGenerateShrine()
Definition: Zone.cs:2473
void TryGenerateOre()
Definition: Zone.cs:2409
void TryGenerateBigDaddy()
Definition: Zone.cs:2455
Card AddCard(Card t, Point point)
Definition: Zone.cs:1893