Elin Decompiled Documentation EA 23.277 Nightly Patch 1
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 OnAdvanceHour()
188 {
190 {
191 Point point = new Point(EClass._map.CenterX + 1, EClass._map.CenterZ + 1);
192 if (!point.HasObj)
193 {
194 point.SetObj(46);
195 }
196 }
197 }
198
199 public void RefreshRewards()
200 {
201 if (listReward.Count <= 0)
202 {
203 Add(new string[7] { "659", "758", "759", "806", "828", "1190", "1191" });
204 if (flags.raidLv < 50)
205 {
206 Add(new string[7] { "pillow_jure", "pillow_ehekatl", "pillow_opatos", "pillow_kumiromi", "pillow_lulwy", "pillow_mani", "pillow_itzpalt" });
207 }
208 else
209 {
210 Add(new string[1] { "rod_wish" });
211 }
212 }
213 void Add(string[] ids)
214 {
215 foreach (string item in ids)
216 {
217 listReward.Add(item);
218 }
219 }
220 }
221
222 public void OnExpandFloor(Point pos)
223 {
224 int i = 0;
225 bool done = false;
226 EClass._map.ForeachCell(delegate(Cell c)
227 {
228 if (!c.sourceFloor.tileType.IsSkipFloor)
229 {
230 i++;
231 }
232 });
233 Check(6, delegate
234 {
235 EClass._zone.ClaimZone(debug: false, pos);
236 });
237 Check(9, delegate
238 {
240 });
241 Check(20, delegate
242 {
243 AddMemeber("fiama");
244 });
245 Check(40, delegate
246 {
247 AddMemeber("nino");
248 });
249 Check(60, delegate
250 {
251 AddMemeber("loytel");
253 });
254 Check(80, delegate
255 {
256 AddMemeber("farris");
257 });
258 Check(100, delegate
259 {
260 EClass._zone.AddCard(ThingGen.Create("core_defense"), pos).Install();
261 });
262 void AddMemeber(string id)
263 {
264 if (EClass.game.cards.globalCharas.Find(id) == null)
265 {
267 }
268 }
269 void Check(int a, Action action)
270 {
271 if (!done && flags.floors < a && i >= a)
272 {
273 Meteor(pos, action);
274 EClass.game.survival.flags.floors = a;
275 done = true;
276 }
277 }
278 }
279
280 public void CheckLoytelDebt()
281 {
282 if (EClass.game.cards.globalCharas.Find("loytel") != null && !EClass.game.quests.IsAdded<QuestDebt>())
283 {
284 Quest quest = EClass.game.quests.Add("debt", "loytel");
285 EClass.game.quests.globalList.Remove(quest);
286 EClass.game.quests.Start(quest);
287 }
288 }
289
290 public bool OnMineWreck(Point point)
291 {
292 if (EClass._zone.events.GetEvent<ZoneEventSurvival>() == null)
293 {
295 }
297 SourceObj.Row sourceObj = point.cell.sourceObj;
298 int searchWreck = EClass.game.survival.flags.searchWreck;
299 string[] array = new string[6] { "log", "rock", "branch", "bone", "grass", "vine" };
300 int chanceChange = 25;
301 int num = searchWreck / 50 + 1;
302 if (searchWreck == 0)
303 {
304 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));
305 Pop(t2);
306 }
307 switch (sourceObj.alias)
308 {
309 case "nest_bird":
310 chanceChange = 65;
311 return Pop(ThingGen.Create((EClass.rnd(10) == 0) ? "egg_fertilized" : "_egg").TryMakeRandomItem(num));
312 case "wreck_wood":
313 array = new string[8] { "log", "log", "branch", "grass", "vine", "resin", "leaf", "chunk" };
314 break;
315 case "wreck_junk":
316 chanceChange = 100;
317 return Pop(ThingGen.CreateFromFilter("wreck_junk", num));
318 case "wreck_stone":
319 chanceChange = 30;
320 array = new string[4] { "rock", "rock", "stone", "bone" };
321 break;
322 case "wreck_scrap":
323 chanceChange = 75;
324 array = new string[1] { "scrap" };
325 break;
326 case "wreck_cloth":
327 chanceChange = 75;
328 array = new string[1] { "fiber" };
329 break;
330 case "wreck_precious":
331 chanceChange = 100;
332 return Pop(ThingGen.CreateFromFilter("shop_magic", num));
333 default:
334 return false;
335 }
337 {
340 {
341 case 5:
342 case 6:
343 return Pop(ThingGen.CreateFloor(33, 97).SetNum(3));
344 case 7:
345 case 8:
346 return Pop(ThingGen.CreateFloor(43, 66).SetNum(3));
347 default:
348 return Pop(ThingGen.CreateFloor(40, 45).SetNum(3));
349 }
350 }
351 if (EClass.rnd(20) == 0)
352 {
353 return Pop(TraitSeed.MakeRandomSeed());
354 }
355 if (EClass.rnd(12 + num / 5) == 0)
356 {
357 return Pop(ThingGen.Create("money2"));
358 }
359 if (searchWreck > 10 && EClass.rnd(40 + num) == 0)
360 {
361 TreasureType treasureType = ((EClass.rnd(10) == 0) ? TreasureType.BossNefia : ((EClass.rnd(10) == 0) ? TreasureType.Map : TreasureType.RandomChest));
362 Thing t3 = ThingGen.Create(treasureType switch
363 {
364 TreasureType.Map => "chest_treasure",
365 TreasureType.BossNefia => "chest_boss",
366 _ => "chest3",
367 });
368 ThingGen.CreateTreasureContent(t3, num, treasureType, clearContent: true);
369 MeteorThing(GetRandomPoint(), t3, install: true);
370 }
371 if (EClass.rnd(12) == 0)
372 {
373 Point pos = point.GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: false, ignoreCenter: true) ?? point;
374 if (searchWreck < 100 || EClass.rnd(3) != 0)
375 {
377 }
378 else
379 {
380 EClass._zone.SpawnMob(pos, SpawnSetting.HomeEnemy(Mathf.Max(num - 5, 1)));
381 }
382 }
383 return Pop(ThingGen.Create(array.RandomItem()).SetNum(1 + EClass.rnd(3)));
384 bool Next()
385 {
387 int searchWreck2 = EClass.game.survival.flags.searchWreck;
388 Point pos2 = point.GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: false, ignoreCenter: true) ?? point;
389 if (searchWreck2 == 20)
390 {
391 Thing container = ThingGen.CreateParcel(null, ThingGen.CreateRecipe("container_shipping"), ThingGen.CreateRecipe("stonecutter"), ThingGen.CreateRecipe("workbench2"));
392 Meteor(pos2, delegate
393 {
394 EClass._zone.AddCard(container, pos2);
395 });
396 }
397 if (searchWreck2 > (EClass.debug.enable ? 5 : 100) && !flags.gotTaxChest)
398 {
399 MeteorThing(pos2, "chest_tax");
400 flags.gotTaxChest = true;
401 }
402 if (searchWreck2 > (EClass.debug.enable ? 10 : 200) && !flags.gotGaragara)
403 {
404 MeteorThing(pos2, "rolling_fortune");
405 flags.gotGaragara = true;
406 }
407 NextObj();
408 return true;
409 }
410 void NextObj()
411 {
412 if (EClass.rnd(100) < chanceChange)
413 {
414 string[] source = new string[12]
415 {
416 "nest_bird", "wreck_wood", "wreck_wood", "wreck_wood", "wreck_wood", "wreck_wood", "wreck_stone", "wreck_stone", "wreck_scrap", "wreck_junk",
417 "wreck_cloth", "wreck_precious"
418 };
419 EClass._map.SetObj(point.x, point.z, EClass.sources.objs.alias[source.RandomItem()].id);
420 }
421 }
422 bool Pop(Thing t)
423 {
424 EClass._map.TrySmoothPick(point, t, EClass.pc);
425 Next();
426 return true;
427 }
428 }
429
431 {
433 Point point = ((traitCoreZone != null) ? traitCoreZone.owner.pos : EClass._map.GetCenterPos());
434 List<Cell> list = new List<Cell>();
435 EClass._map.ForeachSphere(point.x, point.z, 50f, delegate(Point p)
436 {
437 if (!p.IsSky && !p.IsBlocked && !p.HasObj && !p.HasThing)
438 {
439 list.Add(p.cell);
440 }
441 });
442 if (list.Count == 0)
443 {
444 return null;
445 }
446 return list.RandomItem().GetPoint();
447 }
448
450 {
451 return EClass.sources.charas.rows.Where(delegate(SourceChara.Row r)
452 {
453 if (r.quality != 4 || r.race == "god" || r.size.Length != 0)
454 {
455 return false;
456 }
457 switch (r.id)
458 {
459 case "fiama":
460 case "loytel":
461 case "nino":
462 case "big_daddy":
463 case "littleOne":
464 case "sorin":
465 case "vesda":
466 case "azzrasizzle":
467 return false;
468 default:
469 if (EClass.game.cards.globalCharas.Find(r.id) == null)
470 {
471 return r.LV < flags.raidLv + 10;
472 }
473 return false;
474 }
475 }).ToList();
476 }
477
478 public void OnUpdateRecruit(FactionBranch branch)
479 {
480 List<SourceChara.Row> list = ListUnrecruitedUniques();
481 for (int i = 0; i < (EClass.debug.enable ? 10 : 2); i++)
482 {
483 SourceChara.Row row = list.RandomItem();
484 if (row != null)
485 {
486 Chara chara = CharaGen.Create(row.id);
487 chara.RemoveEditorTag(EditorTag.AINoMove);
488 branch.AddRecruit(chara);
489 list.Remove(row);
490 }
491 }
492 }
493
494 public void StartRaid()
495 {
496 flags.raid = true;
497 Point pos = EClass.pc.pos.GetNearestPoint(allowBlock: false, allowChara: false, allowInstalled: false, ignoreCenter: true) ?? EClass.pc.pos;
498 Meteor(pos, delegate
499 {
500 EClass._zone.AddCard(ThingGen.Create("teleporter_demon"), pos).Install();
501 });
502 flags.dateNextRaid = EClass.world.date.GetRaw(72);
503 }
504}
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:5507
void RemoveEditorTag(EditorTag tag)
Definition: Card.cs:2638
virtual Chara Chara
Definition: Card.cs:2096
Thing SetNum(int a)
Definition: Card.cs:3549
Point pos
Definition: Card.cs:60
Card Install()
Definition: Card.cs:3795
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:1080
Definition: Check.cs:5
bool enable
Definition: CoreDebug.cs:286
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 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:33
void AddRecruit(Chara c)
void AddMemeber(Chara c)
SurvivalManager survival
Definition: Game.cs:228
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: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
void SetObj(int id=0, int value=1, int dir=0)
Definition: Point.cs:928
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:619
int z
Definition: Point.cs:39
bool HasThing
Definition: Point.cs:251
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:192
Card owner
Definition: Trait.cs:28
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:1729
Chara SpawnMob(string id, Point pos=null)
Definition: Zone.cs:2775
Card AddCard(Card t, Point point)
Definition: Zone.cs:1994
uint Bits
Definition: BitArray32.cs:6