Elin Decompiled Documentation EA 23.219 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 [OnSerializing]
126 private void _OnSerializing(StreamingContext context)
127 {
128 ints[0] = (int)bits.Bits;
129 }
130
131 [OnDeserialized]
132 private void _OnDeserialized(StreamingContext context)
133 {
134 bits.Bits = (uint)ints[0];
135 }
136 }
137
138 [JsonProperty]
139 public Flags flags = new Flags();
140
141 [JsonProperty]
142 public List<string> listReward = new List<string>();
143
144 public bool IsInRaid => GetRaidEvent() != null;
145
147 {
148 return EClass._zone.events.GetEvent<ZoneEventRaid>();
149 }
150
151 public void Meteor(Point pos, Action action)
152 {
153 EffectMeteor.Create(pos, 0, 1, delegate
154 {
155 action();
156 });
157 }
158
159 public void MeteorThing(Point pos, string id, bool install = false)
160 {
161 Meteor(pos, delegate
162 {
164 if (card.id == "rod_wish")
165 {
166 card.SetCharge(1);
167 }
168 if (install)
169 {
170 card.Install();
171 }
172 });
173 }
174
175 public void MeteorThing(Point pos, Thing t, bool install = false)
176 {
177 Meteor(pos, delegate
178 {
179 Card card = EClass._zone.AddCard(t, pos);
180 if (install)
181 {
182 card.Install();
183 }
184 });
185 }
186
187 public void RefreshRewards()
188 {
189 if (listReward.Count <= 0)
190 {
191 Add(new string[7] { "659", "758", "759", "806", "828", "1190", "1191" });
192 if (flags.raidLv < 50)
193 {
194 Add(new string[7] { "pillow_jure", "pillow_ehekatl", "pillow_opatos", "pillow_kumiromi", "pillow_lulwy", "pillow_mani", "pillow_itzpalt" });
195 }
196 else
197 {
198 Add(new string[1] { "rod_wish" });
199 }
200 }
201 void Add(string[] ids)
202 {
203 foreach (string item in ids)
204 {
205 listReward.Add(item);
206 }
207 }
208 }
209
210 public void OnExpandFloor(Point pos)
211 {
212 int i = 0;
213 bool done = false;
214 EClass._map.ForeachCell(delegate(Cell c)
215 {
216 if (!c.sourceFloor.tileType.IsSkipFloor)
217 {
218 i++;
219 }
220 });
221 Check(6, delegate
222 {
223 EClass._zone.ClaimZone(debug: false, pos);
224 });
225 Check(9, delegate
226 {
228 });
229 Check(20, delegate
230 {
232 });
233 Check(40, delegate
234 {
236 });
237 Check(60, delegate
238 {
241 });
242 Check(80, delegate
243 {
244 EClass._zone.AddCard(ThingGen.Create("core_defense"), pos).Install();
245 });
246 void Check(int a, Action action)
247 {
248 if (!done && flags.floors < a && i >= a)
249 {
250 Meteor(pos, action);
251 EClass.game.survival.flags.floors = a;
252 done = true;
253 }
254 }
255 }
256
257 public void CheckLoytelDebt()
258 {
259 if (EClass.game.cards.globalCharas.Find("loytel") != null && !EClass.game.quests.IsAdded<QuestDebt>())
260 {
261 Quest quest = EClass.game.quests.Add("debt", "loytel");
262 EClass.game.quests.globalList.Remove(quest);
263 EClass.game.quests.Start(quest);
264 }
265 }
266
267 public bool OnMineWreck(Point point)
268 {
269 if (EClass._zone.events.GetEvent<ZoneEventSurvival>() == null)
270 {
272 }
274 SourceObj.Row sourceObj = point.cell.sourceObj;
275 int searchWreck = EClass.game.survival.flags.searchWreck;
276 string[] array = new string[6] { "log", "rock", "branch", "bone", "grass", "vine" };
277 int chanceChange = 25;
278 int num = searchWreck / 50 + 1;
279 if (searchWreck == 0)
280 {
281 Thing t2 = 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));
282 Pop(t2);
283 }
284 switch (sourceObj.alias)
285 {
286 case "nest_bird":
287 chanceChange = 65;
288 return Pop(ThingGen.Create((EClass.rnd(10) == 0) ? "egg_fertilized" : "_egg").TryMakeRandomItem(num));
289 case "wreck_wood":
290 array = new string[8] { "log", "log", "branch", "grass", "vine", "resin", "leaf", "chunk" };
291 break;
292 case "wreck_junk":
293 chanceChange = 100;
294 return Pop(ThingGen.CreateFromFilter("shop_junk", num));
295 case "wreck_stone":
296 chanceChange = 30;
297 array = new string[4] { "rock", "rock", "stone", "bone" };
298 break;
299 case "wreck_scrap":
300 chanceChange = 75;
301 array = new string[1] { "scrap" };
302 break;
303 case "wreck_cloth":
304 chanceChange = 75;
305 array = new string[1] { "fiber" };
306 break;
307 case "wreck_precious":
308 chanceChange = 100;
309 return Pop(ThingGen.CreateFromFilter("shop_magic", num));
310 default:
311 return false;
312 }
314 {
317 {
318 case 5:
319 case 6:
320 return Pop(ThingGen.CreateFloor(33, 97).SetNum(3));
321 case 7:
322 case 8:
323 return Pop(ThingGen.CreateFloor(43, 66).SetNum(3));
324 default:
325 return Pop(ThingGen.CreateFloor(40, 45).SetNum(3));
326 }
327 }
328 if (EClass.rnd(20) == 0)
329 {
330 return Pop(TraitSeed.MakeRandomSeed());
331 }
332 if (EClass.rnd(12 + num / 5) == 0)
333 {
334 return Pop(ThingGen.Create("money2"));
335 }
336 if (searchWreck > 10 && EClass.rnd(40 + num) == 0)
337 {
338 TreasureType treasureType = ((EClass.rnd(10) == 0) ? TreasureType.BossNefia : ((EClass.rnd(10) == 0) ? TreasureType.Map : TreasureType.RandomChest));
339 Thing t3 = ThingGen.Create(treasureType switch
340 {
341 TreasureType.Map => "chest_treasure",
342 TreasureType.BossNefia => "chest_boss",
343 _ => "chest3",
344 });
345 ThingGen.CreateTreasureContent(t3, num, treasureType, clearContent: true);
346 MeteorThing(GetRandomPoint(), t3, install: true);
347 }
348 if (EClass.rnd(12) == 0)
349 {
350 Point pos = point.GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: false, ignoreCenter: true) ?? point;
351 if (searchWreck < 100 || EClass.rnd(3) != 0)
352 {
354 }
355 else
356 {
357 EClass._zone.SpawnMob(pos, SpawnSetting.HomeEnemy(Mathf.Max(num - 5, 1)));
358 }
359 }
360 return Pop(ThingGen.Create(array.RandomItem()).SetNum(1 + EClass.rnd(3)));
361 bool Next()
362 {
364 int searchWreck2 = EClass.game.survival.flags.searchWreck;
365 Point pos2 = point.GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: false, ignoreCenter: true) ?? point;
366 if (searchWreck2 == 20)
367 {
368 Thing container = ThingGen.CreateParcel(null, ThingGen.CreateRecipe("container_shipping"), ThingGen.CreateRecipe("stonecutter"), ThingGen.CreateRecipe("workbench2"));
369 Meteor(pos2, delegate
370 {
371 EClass._zone.AddCard(container, pos2);
372 });
373 }
374 if (searchWreck2 > (EClass.debug.enable ? 5 : 100) && !flags.gotTaxChest)
375 {
376 MeteorThing(pos2, "chest_tax");
377 flags.gotTaxChest = true;
378 }
379 if (searchWreck2 > (EClass.debug.enable ? 10 : 200) && !flags.gotGaragara)
380 {
381 MeteorThing(pos2, "rolling_fortune");
382 flags.gotGaragara = true;
383 }
384 NextObj();
385 return true;
386 }
387 void NextObj()
388 {
389 if (EClass.rnd(100) < chanceChange)
390 {
391 string[] source = new string[12]
392 {
393 "nest_bird", "wreck_wood", "wreck_wood", "wreck_wood", "wreck_wood", "wreck_wood", "wreck_stone", "wreck_stone", "wreck_scrap", "wreck_junk",
394 "wreck_cloth", "wreck_precious"
395 };
396 EClass._map.SetObj(point.x, point.z, EClass.sources.objs.alias[source.RandomItem()].id);
397 }
398 }
399 bool Pop(Thing t)
400 {
401 EClass._map.TrySmoothPick(point, t, EClass.pc);
402 Next();
403 return true;
404 }
405 }
406
408 {
410 Point point = ((traitCoreZone != null) ? traitCoreZone.owner.pos : EClass._map.GetCenterPos());
411 List<Cell> list = new List<Cell>();
412 EClass._map.ForeachSphere(point.x, point.z, 50f, delegate(Point p)
413 {
414 if (!p.IsSky && !p.IsBlocked && !p.HasObj && !p.HasThing)
415 {
416 list.Add(p.cell);
417 }
418 });
419 if (list.Count == 0)
420 {
421 return null;
422 }
423 return list.RandomItem().GetPoint();
424 }
425
427 {
428 return EClass.sources.charas.rows.Where(delegate(SourceChara.Row r)
429 {
430 if (r.quality != 4 || r.race == "god" || r.size.Length != 0)
431 {
432 return false;
433 }
434 switch (r.id)
435 {
436 case "fiama":
437 case "loytel":
438 case "nino":
439 case "big_daddy":
440 case "littleOne":
441 case "sorin":
442 case "vesda":
443 case "azzrasizzle":
444 return false;
445 default:
446 if (EClass.game.cards.globalCharas.Find(r.id) == null)
447 {
448 return r.LV < flags.raidLv + 10;
449 }
450 return false;
451 }
452 }).ToList();
453 }
454
455 public void OnUpdateRecruit(FactionBranch branch)
456 {
457 List<SourceChara.Row> list = ListUnrecruitedUniques();
458 for (int i = 0; i < (EClass.debug.enable ? 10 : 2); i++)
459 {
460 SourceChara.Row row = list.RandomItem();
461 if (row != null)
462 {
463 Chara chara = CharaGen.Create(row.id);
464 chara.RemoveEditorTag(EditorTag.AINoMove);
465 branch.AddRecruit(chara);
466 list.Remove(row);
467 }
468 }
469 }
470
471 public void StartRaid()
472 {
473 flags.raid = true;
474 Point pos = EClass.pc.pos.GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: false, ignoreCenter: true) ?? EClass.pc.pos;
475 Meteor(pos, delegate
476 {
477 EClass._zone.AddCard(ThingGen.Create("teleporter_demon"), pos).Install();
478 });
479 flags.dateNextRaid = EClass.world.date.GetRaw(72);
480 }
481}
EditorTag
Definition: EditorTag.cs:2
TreasureType
Definition: TreasureType.cs:2
if(item3.idFile==idFirstFile &&item3.id==idFirstTopic)
Definition: UIBook.cs:627
list. Add(item3)
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:5341
void RemoveEditorTag(EditorTag tag)
Definition: Card.cs:2598
virtual Chara Chara
Definition: Card.cs:2058
Thing SetNum(int a)
Definition: Card.cs:3425
Point pos
Definition: Card.cs:59
Card Install()
Definition: Card.cs:3671
Definition: Cell.cs:7
SourceFloor.Row sourceFloor
Definition: Cell.cs:1054
SourceObj.Row sourceObj
Definition: Cell.cs:1072
static Chara Create(string id, int lv=-1)
Definition: CharaGen.cs:17
Definition: Chara.cs:10
FactionBranch homeBranch
Definition: Chara.cs:1064
Definition: Check.cs:5
bool enable
Definition: CoreDebug.cs:286
int GetRaw(int offsetHours=0)
Definition: Date.cs:322
Definition: EClass.cs:5
static Game game
Definition: EClass.cs:8
static Zone _zone
Definition: EClass.cs:20
static World world
Definition: EClass.cs:40
static Map _map
Definition: EClass.cs:18
static int rnd(long a)
Definition: EClass.cs:58
static SourceManager sources
Definition: EClass.cs:42
static Chara pc
Definition: EClass.cs:14
static CoreDebug debug
Definition: EClass.cs:48
static void Create(Point center, int radius, int count, Action< int, Point > onComplete)
Definition: EffectMeteor.cs:33
void AddRecruit(Chara c)
void AddMemeber(Chara c)
SurvivalManager survival
Definition: Game.cs:224
CardManager cards
Definition: Game.cs:155
QuestManager quests
Definition: Game.cs:179
Point GetCenterPos()
Definition: MapBounds.cs:52
new void ForeachCell(Action< Cell > action)
Definition: Map.cs:2346
Thing FindThing(Func< Thing, bool > func)
Definition: Map.cs:2592
void ForeachSphere(int _x, int _z, float r, Action< Point > action)
Definition: Map.cs:2380
void TrySmoothPick(Cell cell, Thing t, Chara c)
Definition: Map.cs:1804
void SetObj(int x, int z, int id=0, int value=1, int dir=0)
Definition: Map.cs:1535
Definition: Point.cs:9
bool IsSky
Definition: Point.cs:212
bool IsBlocked
Definition: Point.cs:351
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:607
int z
Definition: Point.cs:39
bool HasThing
Definition: Point.cs:239
bool HasObj
Definition: Point.cs:137
Cell cell
Definition: Point.cs:51
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
SourceObj objs
SourceChara charas
static SpawnSetting HomeWild(int lv)
Definition: SpawnSetting.cs:93
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< 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:263
static Thing CreateFloor(int id, int idMat, bool platform=false)
Definition: ThingGen.cs:108
static Thing CreateRecipe(string id)
Definition: ThingGen.cs:144
static Thing CreateRod(int ele, int charge=-1)
Definition: ThingGen.cs:209
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:187
Card owner
Definition: Trait.cs:27
GameDate date
Definition: World.cs:6
void Add(ZoneEvent e, bool allowDuplicate=false)
ZoneEventManager events
Definition: Zone.cs:40
void ClaimZone(bool debug=false, Point pos=null)
Definition: Zone.cs:1694
Chara SpawnMob(Point pos=null, SpawnSetting setting=null)
Definition: Zone.cs:2712
Card AddCard(Card t, Point point)
Definition: Zone.cs:1948
uint Bits
Definition: BitArray32.cs:6