Elin Decompiled Documentation EA 23.339.0 Nightly
Loading...
Searching...
No Matches
SurvivalManager.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Runtime.Serialization;
5using Newtonsoft.Json;
6using UnityEngine;
7
8public class SurvivalManager : EClass
9{
10 public class Flags : EClass
11 {
12 [JsonProperty]
13 public int[] ints = new int[50];
14
16
17 public int spawnedFloor
18 {
19 get
20 {
21 return ints[3];
22 }
23 set
24 {
25 ints[3] = value;
26 }
27 }
28
29 public int floors
30 {
31 get
32 {
33 return ints[4];
34 }
35 set
36 {
37 ints[4] = value;
38 }
39 }
40
41 public int searchWreck
42 {
43 get
44 {
45 return ints[5];
46 }
47 set
48 {
49 ints[5] = value;
50 }
51 }
52
53 public int dateNextRaid
54 {
55 get
56 {
57 return ints[6];
58 }
59 set
60 {
61 ints[6] = value;
62 }
63 }
64
65 public int raidRound
66 {
67 get
68 {
69 return ints[7];
70 }
71 set
72 {
73 ints[7] = value;
74 }
75 }
76
77 public int raidLv
78 {
79 get
80 {
81 return ints[8];
82 }
83 set
84 {
85 ints[8] = value;
86 }
87 }
88
89 public bool raid
90 {
91 get
92 {
93 return bits[0];
94 }
95 set
96 {
97 bits[0] = value;
98 }
99 }
100
101 public bool gotTaxChest
102 {
103 get
104 {
105 return bits[1];
106 }
107 set
108 {
109 bits[1] = value;
110 }
111 }
112
113 public bool gotGaragara
114 {
115 get
116 {
117 return bits[2];
118 }
119 set
120 {
121 bits[2] = value;
122 }
123 }
124
125 public bool gotSkyWorkbench
126 {
127 get
128 {
129 return bits[4];
130 }
131 set
132 {
133 bits[4] = value;
134 }
135 }
136
137 [OnSerializing]
138 private void _OnSerializing(StreamingContext context)
139 {
140 ints[0] = (int)bits.Bits;
141 }
142
143 [OnDeserialized]
144 private void _OnDeserialized(StreamingContext context)
145 {
146 bits.Bits = (uint)ints[0];
147 }
148 }
149
150 [JsonProperty]
151 public Flags flags = new Flags();
152
153 [JsonProperty]
154 public List<string> listReward = new List<string>();
155
156 [JsonProperty]
158
159 [JsonProperty]
160 public List<Zone> listGateZone = new List<Zone>();
161
162 public bool IsInRaid => GetRaidEvent() != null;
163
165 {
166 return EClass._zone.events.GetEvent<ZoneEventRaid>();
167 }
168
169 public void Meteor(Point pos, Action action)
170 {
171 EffectMeteor.Create(pos, 0, 1, delegate
172 {
173 action();
174 });
175 }
176
177 public void MeteorThing(Point pos, string id, bool install = false)
178 {
179 Meteor(pos, delegate
180 {
182 if (card.id == "rod_wish")
183 {
184 card.SetCharge(1);
185 }
186 if (install)
187 {
188 card.Install();
189 }
190 });
191 }
192
193 public void MeteorThing(Point pos, Thing t, bool install = false)
194 {
195 Meteor(pos, delegate
196 {
197 Card card = EClass._zone.AddCard(t, pos);
198 if (install)
199 {
200 card.Install();
201 }
202 });
203 }
204
205 public void OnAdvanceHour()
206 {
208 {
209 Point point = new Point(EClass._map.CenterX + 1, EClass._map.CenterZ + 1);
210 if (!point.HasObj)
211 {
212 point.SetObj(46);
213 }
214 }
215 if (EClass.world.date.hour == 0 || EClass.debug.enable)
216 {
218 }
219 }
220
221 public void RefreshGateZones()
222 {
223 listGateZone.ForeachReverse(delegate(Zone z)
224 {
225 if (z == null || z.destryoed)
226 {
227 listGateZone.Remove(z);
228 }
229 });
230 if (listGateZone.Count == 0)
231 {
232 for (int num = 0; num < 3; num++)
233 {
234 if (EClass.rnd(4) == 0)
235 {
236 IEnumerable<Spatial> enumerable = EClass.game.spatials.map.Values.Where((Spatial a) => a.source.costSkyTravel > 0 && !listGateZone.Contains(a) && a != gateZone);
237 if (enumerable.Count() > 0)
238 {
239 listGateZone.Add(enumerable.RandomItem() as Zone);
240 }
241 }
242 else
243 {
244 Zone item = EClass.world.region.CreateRandomSite(new Point(1, 1), (EClass.rnd(5) == 0) ? "dungeon_water" : null, updateMesh: false);
245 listGateZone.Add(item);
246 }
247 }
248 }
249 foreach (Zone item2 in listGateZone)
250 {
251 if (item2.dateExpire > 0)
252 {
253 item2.dateExpire = EClass.world.date.GetRaw() + 10080;
254 }
255 }
256 }
257
258 public void RefreshRewards()
259 {
260 if (listReward.Count <= 0)
261 {
262 Add(new string[7] { "659", "758", "759", "806", "828", "1190", "1191" });
263 if (flags.raidLv < 50)
264 {
265 Add(new string[7] { "pillow_jure", "pillow_ehekatl", "pillow_opatos", "pillow_kumiromi", "pillow_lulwy", "pillow_mani", "pillow_itzpalt" });
266 }
267 else
268 {
269 Add(new string[1] { "rod_wish" });
270 }
271 }
272 void Add(string[] ids)
273 {
274 foreach (string item in ids)
275 {
276 listReward.Add(item);
277 }
278 }
279 }
280
281 public void OnExpandFloor(Point pos)
282 {
283 int n = 0;
284 bool done = false;
285 EClass._map.ForeachCell(delegate(Cell c)
286 {
287 if (!c.sourceFloor.tileType.IsSkipFloor)
288 {
289 n++;
290 }
291 });
292 Check(6, delegate
293 {
294 EClass._zone.ClaimZone(debug: false, pos);
295 });
296 Check(9, delegate
297 {
299 });
300 Check(20, delegate
301 {
302 AddMemeber("fiama");
303 });
304 Check(40, delegate
305 {
306 AddMemeber("nino");
307 });
308 Check(60, delegate
309 {
310 AddMemeber("loytel");
312 });
313 Check(80, delegate
314 {
315 AddMemeber("farris");
316 });
317 Check(100, delegate
318 {
319 EClass._zone.AddCard(ThingGen.Create("core_defense"), pos).Install();
320 });
321 void AddMemeber(string id)
322 {
323 if (EClass.game.cards.globalCharas.Find(id) == null)
324 {
326 }
327 }
328 void Check(int a, Action action)
329 {
330 if (!done && flags.floors < a && n >= a)
331 {
332 Meteor(pos, action);
333 EClass.game.survival.flags.floors = a;
334 done = true;
335 }
336 }
337 }
338
339 public void CheckLoytelDebt()
340 {
341 if (EClass.game.cards.globalCharas.Find("loytel") != null && !EClass.game.quests.IsAdded<QuestDebt>())
342 {
343 Quest quest = EClass.game.quests.Add("debt", "loytel");
344 EClass.game.quests.globalList.Remove(quest);
345 EClass.game.quests.Start(quest);
346 }
347 }
348
349 public bool OnMineWreck(Point point)
350 {
351 if (EClass._zone.events.GetEvent<ZoneEventSurvival>() == null)
352 {
354 }
356 SourceObj.Row sourceObj = point.cell.sourceObj;
357 int searchWreck = EClass.game.survival.flags.searchWreck;
358 string[] array = new string[6] { "log", "rock", "branch", "bone", "grass", "vine" };
359 int chanceChange = 25;
360 int num = searchWreck / 50 + 1;
361 if (searchWreck == 0)
362 {
363 Thing t = ThingGen.CreateParcel(null, ThingGen.Create("log").SetNum(6), ThingGen.Create("rock").SetNum(4), ThingGen.Create("resin").SetNum(2), ThingGen.Create("money2").SetNum(10), ThingGen.Create("1267"), ThingGen.CreateRod(50311, 8));
364 Pop(t);
365 }
366 switch (sourceObj.alias)
367 {
368 case "nest_bird":
369 chanceChange = 65;
370 return Pop(ThingGen.Create((EClass.rnd(10) == 0) ? "egg_fertilized" : "_egg").TryMakeRandomItem(num));
371 case "wreck_wood":
372 array = new string[8] { "log", "log", "branch", "grass", "vine", "resin", "leaf", "chunk" };
373 break;
374 case "wreck_junk":
375 chanceChange = 100;
376 return Pop(ThingGen.CreateFromFilter("wreck_junk", num));
377 case "wreck_stone":
378 chanceChange = 30;
379 array = new string[4] { "rock", "rock", "stone", "bone" };
380 break;
381 case "wreck_scrap":
382 chanceChange = 75;
383 array = new string[1] { "scrap" };
384 break;
385 case "wreck_cloth":
386 chanceChange = 75;
387 array = new string[1] { "fiber" };
388 break;
389 case "wreck_precious":
390 chanceChange = 100;
391 return Pop(ThingGen.CreateFromFilter("shop_magic", num));
392 default:
393 return false;
394 }
396 {
399 {
400 case 5:
401 case 6:
402 return Pop(ThingGen.CreateFloor(33, 97).SetNum(3));
403 case 7:
404 case 8:
405 return Pop(ThingGen.CreateFloor(43, 66).SetNum(3));
406 default:
407 return Pop(ThingGen.CreateFloor(40, 45).SetNum(3));
408 }
409 }
410 if (EClass.rnd(20) == 0)
411 {
412 return Pop(TraitSeed.MakeRandomSeed());
413 }
414 if (EClass.rnd(12 + num / 5) == 0)
415 {
416 return Pop(ThingGen.Create("money2"));
417 }
418 if (searchWreck > 10 && EClass.rnd(40 + num) == 0)
419 {
420 TreasureType treasureType = ((EClass.rnd(10) == 0) ? TreasureType.BossNefia : ((EClass.rnd(10) == 0) ? TreasureType.Map : TreasureType.RandomChest));
421 Thing t2 = ThingGen.Create(treasureType switch
422 {
423 TreasureType.Map => "chest_treasure",
424 TreasureType.BossNefia => "chest_boss",
425 _ => "chest3",
426 });
427 ThingGen.CreateTreasureContent(t2, num, treasureType, clearContent: true);
428 MeteorThing(GetRandomPoint(), t2, install: true);
429 }
430 if (EClass.rnd(12) == 0)
431 {
432 Point pos = point.GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: false, ignoreCenter: true) ?? point;
433 if (searchWreck < 100 || EClass.rnd(3) != 0)
434 {
436 }
437 else
438 {
439 EClass._zone.SpawnMob(pos, SpawnSetting.HomeEnemy(Mathf.Max(num - 5, 1)));
440 }
441 }
442 return Pop(ThingGen.Create(array.RandomItem()).SetNum(1 + EClass.rnd(3)));
443 bool Next()
444 {
446 int searchWreck2 = EClass.game.survival.flags.searchWreck;
447 Point pos2 = point.GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: false, ignoreCenter: true) ?? point;
448 if (searchWreck2 == 20)
449 {
450 Thing container = ThingGen.CreateParcel(null, ThingGen.CreateRecipe("container_shipping"), ThingGen.CreateRecipe("stonecutter"), ThingGen.CreateRecipe("workbench2"), ThingGen.Create("crystal_earth").SetNum(3));
451 Meteor(pos2, delegate
452 {
453 EClass._zone.AddCard(container, pos2);
454 });
455 }
456 if (searchWreck2 > (EClass.debug.enable ? 5 : 100) && !flags.gotTaxChest)
457 {
458 MeteorThing(pos2, "chest_tax", install: true);
459 flags.gotTaxChest = true;
460 }
461 else if (searchWreck2 > (EClass.debug.enable ? 10 : 200) && !flags.gotGaragara)
462 {
463 MeteorThing(pos2, "rolling_fortune", install: true);
464 flags.gotGaragara = true;
465 }
466 else if (EClass.player.stats.days > 1 && !flags.gotSkyWorkbench)
467 {
468 MeteorThing(pos2, ThingGen.CreateRecipe("workbench_sky"));
469 flags.gotSkyWorkbench = true;
470 }
471 NextObj();
472 return true;
473 }
474 void NextObj()
475 {
476 if (EClass.rnd(100) < chanceChange)
477 {
478 string[] source = new string[12]
479 {
480 "nest_bird", "wreck_wood", "wreck_wood", "wreck_wood", "wreck_wood", "wreck_wood", "wreck_stone", "wreck_stone", "wreck_scrap", "wreck_junk",
481 "wreck_cloth", "wreck_precious"
482 };
483 EClass._map.SetObj(point.x, point.z, EClass.sources.objs.alias[source.RandomItem()].id);
484 }
485 }
486 bool Pop(Thing t3)
487 {
488 EClass._map.TrySmoothPick(point, t3, EClass.pc);
489 Next();
490 return true;
491 }
492 }
493
495 {
497 Point point = ((traitCoreZone != null) ? traitCoreZone.owner.pos : EClass._map.GetCenterPos());
498 List<Cell> list = new List<Cell>();
499 EClass._map.ForeachSphere(point.x, point.z, 50f, delegate(Point p)
500 {
501 if (!p.IsSky && !p.IsBlocked && !p.HasObj && !p.HasThing)
502 {
503 list.Add(p.cell);
504 }
505 });
506 if (list.Count == 0)
507 {
508 return null;
509 }
510 return list.RandomItem().GetPoint();
511 }
512
514 {
515 return EClass.sources.charas.rows.Where(delegate(SourceChara.Row r)
516 {
517 if (r.quality != 4 || r.race == "god" || r.size.Length != 0)
518 {
519 return false;
520 }
521 switch (r.id)
522 {
523 case "fiama":
524 case "loytel":
525 case "nino":
526 case "big_daddy":
527 case "big_daddy2":
528 case "littleOne":
529 case "mamani":
530 return false;
531 default:
532 if (EClass.game.cards.globalCharas.Find(r.id) == null)
533 {
534 return r.LV < flags.raidLv + 10;
535 }
536 return false;
537 }
538 }).ToList();
539 }
540
541 public void OnUpdateRecruit(FactionBranch branch)
542 {
543 List<SourceChara.Row> list = ListUnrecruitedUniques();
544 for (int i = 0; i < (EClass.debug.enable ? 10 : 2); i++)
545 {
546 SourceChara.Row row = list.RandomItem();
547 if (row != null)
548 {
549 Chara chara = CharaGen.Create(row.id);
550 chara.RemoveEditorTag(EditorTag.AINoMove);
551 branch.AddRecruit(chara);
552 list.Remove(row);
553 }
554 }
555 }
556
557 public void StartRaid()
558 {
559 flags.raid = true;
560 Point pos = EClass.pc.pos.GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: false, ignoreCenter: true) ?? EClass.pc.pos;
561 Meteor(pos, delegate
562 {
563 EClass._zone.AddCard(ThingGen.Create("teleporter_demon"), pos).Install();
564 });
565 flags.dateNextRaid = EClass.world.date.GetRaw(72);
566 }
567}
if(!match.Success)
EditorTag
Definition: EditorTag.cs:2
TreasureType
Definition: TreasureType.cs:2
Chara Find(string id)
Definition: CardManager.cs:20
GlobalCharaList globalCharas
Definition: CardManager.cs:46
string id
Definition: CardRow.cs:7
Definition: Card.cs:11
Thing TryMakeRandomItem(int lv=-1, TryMakeRandomItemSource itemSource=TryMakeRandomItemSource.Default, Chara crafter=null)
Definition: Card.cs:5751
void RemoveEditorTag(EditorTag tag)
Definition: Card.cs:2743
virtual Chara Chara
Definition: Card.cs:2122
Thing SetNum(int a)
Definition: Card.cs:3673
Point pos
Definition: Card.cs:60
Card Install()
Definition: Card.cs:3919
Definition: Cell.cs:7
SourceFloor.Row sourceFloor
Definition: Cell.cs:1076
SourceObj.Row sourceObj
Definition: Cell.cs:1096
static Chara Create(string id, int lv=-1)
Definition: CharaGen.cs:17
Definition: Chara.cs:10
FactionBranch homeBranch
Definition: Chara.cs:1113
Definition: Check.cs:5
bool enable
Definition: CoreDebug.cs:301
int hour
Definition: Date.cs:74
int GetRaw(int offsetHours=0)
Definition: Date.cs:328
Definition: EClass.cs:6
static Game game
Definition: EClass.cs:9
static Zone _zone
Definition: EClass.cs:21
static World world
Definition: EClass.cs:41
static Map _map
Definition: EClass.cs:19
static int rnd(long a)
Definition: EClass.cs:59
static SourceManager sources
Definition: EClass.cs:43
static Player player
Definition: EClass.cs:13
static Chara pc
Definition: EClass.cs:15
static CoreDebug debug
Definition: EClass.cs:49
static void Create(Point center, int radius, int count, Action< int, Point > onComplete)
Definition: EffectMeteor.cs:40
void AddRecruit(Chara c)
void AddMemeber(Chara c)
SurvivalManager survival
Definition: Game.cs:228
SpatialManager spatials
Definition: Game.cs:153
CardManager cards
Definition: Game.cs:156
QuestManager quests
Definition: Game.cs:183
int CenterZ
Definition: MapBounds.cs:24
Point GetCenterPos()
Definition: MapBounds.cs:52
int CenterX
Definition: MapBounds.cs:22
new void ForeachCell(Action< Cell > action)
Definition: Map.cs:2403
Thing FindThing(Func< Thing, bool > func)
Definition: Map.cs:2669
void ForeachSphere(int _x, int _z, float r, Action< Point > action)
Definition: Map.cs:2437
void TrySmoothPick(Cell cell, Thing t, Chara c)
Definition: Map.cs:1848
void SetObj(int x, int z, int id=0, int value=1, int dir=0)
Definition: Map.cs:1579
int days
Definition: Player.cs:75
Stats stats
Definition: Player.cs:1083
Definition: Point.cs:9
void SetObj(int id=0, int value=1, int dir=0)
Definition: Point.cs:934
bool IsSky
Definition: Point.cs:224
bool IsBlocked
Definition: Point.cs:363
int x
Definition: Point.cs:36
Point GetNearestPoint(bool allowBlock=false, bool allowChara=true, bool allowInstalled=true, bool ignoreCenter=false, int minRadius=0)
Definition: Point.cs:624
int z
Definition: Point.cs:39
bool HasThing
Definition: Point.cs:251
bool HasObj
Definition: Point.cs:137
Cell cell
Definition: Point.cs:51
bool IsAdded(string id)
Quest Add(string id, string idGlobalChara=null)
Definition: QuestManager.cs:29
Quest Start(string id, string idGlobalChara)
Definition: QuestManager.cs:41
List< Quest > globalList
Definition: QuestManager.cs:14
Definition: Quest.cs:7
Zone CreateRandomSite(Zone center, int radius=8, string idSource=null, bool updateMesh=true, int lv=0)
Definition: Region.cs:140
SourceObj objs
SourceChara charas
GlobalSpatialList map
SourceZone.Row source
Definition: Spatial.cs:453
bool destryoed
Definition: Spatial.cs:45
int dateExpire
Definition: Spatial.cs:166
static SpawnSetting HomeWild(int lv)
static SpawnSetting HomeEnemy(int lv)
void _OnSerializing(StreamingContext context)
void _OnDeserialized(StreamingContext context)
List< string > listReward
bool OnMineWreck(Point point)
ZoneEventRaid GetRaidEvent()
void OnUpdateRecruit(FactionBranch branch)
void Meteor(Point pos, Action action)
void OnExpandFloor(Point pos)
void MeteorThing(Point pos, Thing t, bool install=false)
void MeteorThing(Point pos, string id, bool install=false)
List< Zone > listGateZone
List< SourceChara.Row > ListUnrecruitedUniques()
static Thing CreateFromFilter(string id, int lv=-1)
Definition: ThingGen.cs:63
static Thing CreateParcel(string idLang=null, params Thing[] things)
Definition: ThingGen.cs:42
static void CreateTreasureContent(Thing t, int lv, TreasureType type, bool clearContent)
Definition: ThingGen.cs:271
static Thing CreateFloor(int id, int idMat, bool platform=false)
Definition: ThingGen.cs:108
static Thing CreateRecipe(string id)
Definition: ThingGen.cs:152
static Thing CreateRod(int ele, int charge=-1)
Definition: ThingGen.cs:217
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
Definition: Thing.cs:8
string alias
Definition: TileRow.cs:12
static Thing MakeRandomSeed(bool enc=false)
Definition: TraitSeed.cs:97
Card owner
Definition: Trait.cs:28
Region region
Definition: World.cs:23
GameDate date
Definition: World.cs:6
void Add(ZoneEvent e, bool allowDuplicate=false)
Definition: Zone.cs:12
ZoneEventManager events
Definition: Zone.cs:40
void ClaimZone(bool debug=false, Point pos=null)
Definition: Zone.cs:1837
Chara SpawnMob(string id, Point pos=null)
Definition: Zone.cs:2914
Card AddCard(Card t, Point point)
Definition: Zone.cs:2102
uint Bits
Definition: BitArray32.cs:6