Elin Decompiled Documentation EA 23.153 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
79 public override int BaseElectricity => 100;
80
82
83 public override string GetDungenID()
84 {
85 if (EClass.rnd(2) == 0)
86 {
87 return "DungeonRuins";
88 }
89 if (EClass.rnd(4) == 0)
90 {
91 return "Cavern";
92 }
93 if (EClass.rnd(8) == 0)
94 {
95 return "RoundRooms";
96 }
97 return "Dungeon";
98 }
99
100 public override void OnGenerateMap()
101 {
102 if (idExport.IsEmpty())
103 {
108 }
109 }
110
111 public void PlaceRail(RailType railType = RailType.Mine)
112 {
113 int idRail = 31;
114 string idTrolley = "390";
115 bool placeStopper = true;
116 int num = 8;
117 if (railType == RailType.Factoy)
118 {
119 idRail = 110;
120 placeStopper = false;
121 num = EClass.rnd(4) + 1;
122 }
123 PathManager.Instance._pathfinder.PunishChangeDirection = true;
124 PathManager.Instance._pathfinder.Diagonals = false;
127 if (traitStairsDown != null && traitStairsUp != null)
128 {
129 TryPlaceRail(traitStairsDown.owner.pos, traitStairsUp.owner.pos);
130 }
131 int num2 = 0;
132 for (int i = 0; i < 200; i++)
133 {
135 {
136 num2++;
137 if (num2 > num)
138 {
139 break;
140 }
141 }
142 }
143 PathManager.Instance._pathfinder.Diagonals = true;
144 bool TryPlaceRail(Point p1, Point p2)
145 {
146 if (p1.Distance(p2) < 20)
147 {
148 return false;
149 }
151 if (!pathProgress.HasPath)
152 {
153 return false;
154 }
155 Point point = new Point();
156 Point point2 = new Point();
157 bool flag = false;
158 int num3 = 0;
159 foreach (PathFinderNode node in pathProgress.nodes)
160 {
161 Point shared = Point.GetShared(node.X, node.Z);
162 for (int j = -1; j < 2; j++)
163 {
164 for (int k = -1; k < 2; k++)
165 {
166 point2.Set(shared.x + k, shared.z + j);
167 if ((Mathf.Abs(k) != 1 || Mathf.Abs(j) != 1) && point2.IsValid && point2.sourceObj.id == 31 && !point2.Equals(point))
168 {
169 flag = true;
170 if (num3 != 0)
171 {
172 break;
173 }
174 return false;
175 }
176 }
177 }
178 if (shared.sourceObj.id == idRail)
179 {
180 break;
181 }
182 shared.SetBlock();
183 shared.SetObj(idRail);
184 shared.Things.ForeachReverse(delegate(Thing t)
185 {
186 if (t.trait.CanBeDestroyed)
187 {
188 t.Destroy();
189 }
190 });
191 if (flag)
192 {
193 break;
194 }
195 num3++;
196 point.Set(shared);
197 }
198 if (!flag && placeStopper)
199 {
200 Point shared2 = Point.GetShared(pathProgress.nodes.LastItem().X, pathProgress.nodes.LastItem().Z);
201 Cell cell = shared2.cell;
202 int dir = ((cell.Front.obj != 31) ? ((cell.Right.obj == 31) ? 1 : ((cell.Back.obj == 31) ? 2 : 3)) : 0);
203 if (!shared2.HasThing)
204 {
205 EClass._zone.AddCard(ThingGen.Create("1208"), shared2).Install().dir = dir;
206 }
207 }
208 if (num3 > 2)
209 {
210 Point shared3 = Point.GetShared(pathProgress.nodes.First().X, pathProgress.nodes.First().Z);
211 if (!shared3.HasThing)
212 {
213 EClass._zone.AddCard(ThingGen.Create(idTrolley), shared3).Install();
214 }
215 }
216 return true;
217 }
218 }
219}
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:58
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:378
void SetObj(int id=0, int value=1, int dir=0)
Definition: Point.cs:908
Point Set(int _x, int _z)
Definition: Point.cs:491
List< Thing > Things
Definition: Point.cs:326
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:898
int Distance(Point p)
Definition: Point.cs:969
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:289
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 int BaseElectricity
Definition: Zone_Dungeon.cs:79
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()
override ZoneTransition.EnterState RegionEnterState
Definition: Zone_Dungeon.cs:81
override string GetDungenID()
Definition: Zone_Dungeon.cs:83
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:2538
int GetDeepestLv()
Definition: Zone.cs:2919
void TryGenerateShrine()
Definition: Zone.cs:2575
void TryGenerateOre()
Definition: Zone.cs:2511
void TryGenerateBigDaddy()
Definition: Zone.cs:2557
Card AddCard(Card t, Point point)
Definition: Zone.cs:1910