Elin Decompiled Documentation EA 23.240 Nightly
Loading...
Searching...
No Matches
GameDate.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using Newtonsoft.Json;
3using UnityEngine;
4
5public class GameDate : Date
6{
7 [JsonProperty]
8 public bool shaken;
9
10 public const int minPerRound = 5;
11
12 public void AdvanceSec(int a)
13 {
14 base.sec += a;
15 if (base.sec >= 60)
16 {
17 AdvanceMin(base.sec / 60);
18 base.sec %= 60;
19 }
20 }
21
22 public void AdvanceMin(int a)
23 {
24 EClass.game.sessionMin += a;
25 EClass.player.stats.mins += a;
26 base.min += a;
27 if (base.min >= 60)
28 {
29 while (base.min >= 60)
30 {
31 base.min -= 60;
33 }
35 }
36 else if (base.min % 3 == 2)
37 {
39 }
40 if (EClass._map.footmarks.Count > 0)
41 {
42 for (int num = EClass._map.footmarks.Count - 1; num >= 0; num--)
43 {
44 Footmark footmark = EClass._map.footmarks[num];
45 footmark.remaining--;
46 if (footmark.remaining <= 0)
47 {
48 CellDetail detail = footmark.pos.detail;
49 if (detail != null && detail.footmark == footmark)
50 {
51 detail.footmark = null;
52 footmark.pos.cell.TryDespawnDetail();
53 }
54 EClass._map.footmarks.RemoveAt(num);
55 }
56 }
57 }
60 {
61 Msg.NewLine();
62 EClass.player.countNewline = 0;
63 }
66 {
67 item.minElapsed += a;
68 }
69 }
70
71 public void AdvanceHour()
72 {
73 VirtualDate virtualDate = new VirtualDate();
74 virtualDate.IsRealTime = true;
75 virtualDate.SimulateHour();
76 base.hour++;
77 if (base.hour >= 24)
78 {
79 base.hour = 0;
80 AdvanceDay();
81 }
82 if (!shaken && EClass.rnd(24) == 0 && !EClass._zone.IsRegion)
83 {
84 Msg.Say("earthquake");
86 {
87 Shaker.ShakeCam("earthquake");
88 }
89 shaken = true;
90 }
97 {
99 }
100 foreach (Chara value in EClass.game.cards.globalCharas.Values)
101 {
102 if (!value.IsPCParty && value.currentZone != EClass.game.activeZone && value.trait.UseGlobalGoal)
103 {
104 if (value.global.goal == null && !value.IsPCFaction)
105 {
106 GlobalGoalAdv globalGoalAdv = new GlobalGoalAdv();
107 globalGoalAdv.SetOwner(value);
108 globalGoalAdv.Start();
109 }
110 if (value.global.goal != null)
111 {
112 value.global.goal.AdvanceHour();
113 }
114 }
115 }
117 if (base.hour == 5)
118 {
119 ShipGoods();
120 ShipPackages();
121 ShipLetter();
122 if (EClass.rnd(30) == 0 && EClass.game.cards.listPackage.Count <= 2)
123 {
125 }
126 if (base.month == 10)
127 {
128 Tutorial.Reserve("season");
129 }
130 if (base.month == 11)
131 {
132 Tutorial.Reserve("season2");
133 }
134 else
135 {
136 Tutorial.Remove("season2");
137 }
138 if (base.year >= 2500)
139 {
140 Tutorial.Reserve("worldend");
141 }
142 }
143 }
144
145 public void AdvanceDay()
146 {
147 base.day++;
148 base.min = 0;
150 EClass.player.questRerollCost -= 3;
152 {
153 EClass.player.questRerollCost = 0;
154 }
155 if (EClass.player.stats.days >= 90)
156 {
157 Tutorial.Reserve("death_penalty");
158 }
159 if (base.day > 30)
160 {
161 base.day = 1;
162 AdvanceMonth();
163 }
165 EClass.Sound.Play("owl");
166 if (!EClass.player.prayed && EClass.pc.Evalue(1655) > 0)
167 {
168 ActPray.TryPray(EClass.pc, passive: true);
169 }
170 Msg.Say("endDay");
171 shaken = false;
175 foreach (Chara item in EClass.game.cards.listAdv)
176 {
177 if (!item.IsPCFaction && EClass.rnd(10) == 0 && (item.isDead || item.currentZone == null || item.currentZone.id == "somewhere"))
178 {
179 item.SetHomeZone(EClass.world.region.ListTowns().RandomItem());
180 item.Revive();
181 item.MoveZone(item.homeZone);
182 }
183 }
184 foreach (Chara value in EClass.game.cards.globalCharas.Values)
185 {
186 value.OnAdvanceDay();
187 }
189 {
191 }
192 if (EClass.player.stats.days >= 7 && EClass.game.cards.globalCharas.Find("fiama").currentZone == EClass.game.StartZone && EClass.game.quests.GetGlobal("fiama_starter_gift") == null && !EClass.game.quests.IsCompleted("fiama_starter_gift"))
193 {
194 EClass.game.quests.Add("fiama_starter_gift", "fiama");
195 }
196 if (EClass.game.quests.completedIDs.Contains("demitas_spellwriter") && !EClass.game.quests.IsAdded<QuestNegotiationDarkness>())
197 {
198 EClass.game.quests.Add("negotiation_darkness", "loytel");
199 }
200 if (EClass.game.quests.IsCompleted("exploration"))
201 {
204 {
205 EClass.player.flags.magicChestSent = true;
206 Thing thing = ThingGen.Create("parchment");
207 thing.SetStr(53, "letter_magic_chest");
208 Thing p = ThingGen.CreateParcel(null, ThingGen.Create("container_magic"), thing);
210 }
211 }
212 if (base.day == 1 && base.month == 11 && (EClass.game.quests.IsStarted<QuestDebt>() || EClass.debug.enable))
213 {
214 Thing thing2 = ThingGen.Create("parchment");
215 thing2.SetStr(53, "letter_crimale");
216 Thing p2 = ThingGen.CreateParcel(null, ThingGen.Create("crimale2"), thing2);
218 }
219 if (base.day == 25 && base.month == 12)
220 {
222 }
223 }
224
225 public void AdvanceMonth()
226 {
227 base.month++;
228 if (base.month > 12)
229 {
230 base.month = 1;
231 AdvanceYear();
232 }
235 if (base.month % 2 == 0)
236 {
238 }
240 foreach (Thing thing in EClass._map.things)
241 {
242 if (thing.renderer.hasActor)
243 {
244 thing.renderer.RefreshSprite();
245 }
246 }
248 }
249
250 public void AdvanceYear()
251 {
252 base.year++;
253 EClass.player.flags.santa = 0;
254 EClass.player.wellWished = false;
256 EClass.world.SendPackage(ThingGen.Create("gift_newyear"));
257 }
258
259 public void ShipGoods()
260 {
261 Thing container_shipping = EClass.game.cards.container_shipping;
262 if (container_shipping.things.Count == 0)
263 {
264 return;
265 }
266 int num = 0;
267 int num2 = 0;
268 int num3 = 0;
269 int num4 = 0;
270 List<Thing> list = new List<Thing>();
271 List<string> list2 = new List<string>();
273 if (zone == null || zone.branch == null)
274 {
275 zone = EClass.pc.homeZone;
276 }
277 ShippingResult shippingResult = new ShippingResult();
278 shippingResult.rawDate = EClass.world.date.GetRaw();
279 shippingResult.uidZone = zone.uid;
281 {
282 EClass.player.stats.shipMoney = 2147483647L;
283 }
284 shippingResult.total = EClass.player.stats.shipMoney;
285 shippingResult.hearthLv = zone.branch.lv;
286 shippingResult.hearthExp = zone.branch.exp;
287 shippingResult.debt = EClass.player.debt;
288 foreach (Thing thing3 in container_shipping.things)
289 {
290 if (thing3.trait.CanBeShipped)
291 {
292 int price = thing3.GetPrice(CurrencyType.Money, sell: true, PriceType.Shipping);
293 int num5 = price * thing3.Num;
294 num3 += num5;
295 num += thing3.Num;
296 num2 += EClass.rndHalf(thing3.Num * Mathf.Min(15 + price, 10000) / 100 + 1);
297 list.Add(thing3);
298 shippingResult.items.Add(new ShippingResult.Item
299 {
300 text = thing3.Name,
301 income = num5
302 });
303 }
304 }
305 if (list.Count == 0)
306 {
307 return;
308 }
309 num2 = num2 / 2 + 1;
310 if (zone.branch.policies.IsActive(2515))
311 {
312 num2 = 0;
313 }
314 shippingResult.hearthExpGained = num2;
315 EClass.pc.homeBranch.log.Add(Msg.Say("shipped_collect"));
316 foreach (string item in list2)
317 {
319 }
321 EClass.player.stats.shipNum += num;
322 EClass.player.stats.shipMoney += num3;
324 if (shippingBonus2 > shippingBonus)
325 {
326 num4 = shippingBonus2 - shippingBonus;
327 }
328 foreach (Thing item2 in list)
329 {
330 item2.Destroy();
331 }
332 Thing thing = null;
333 Thing thing2 = null;
334 string text = "";
335 if (num3 != 0)
336 {
337 thing = ThingGen.Create("money").SetNum(num3);
338 }
339 if (num4 != 0)
340 {
341 thing2 = ThingGen.Create("money2").SetNum(num4);
342 }
343 if (thing != null && thing2 != null)
344 {
345 text = "_and".lang(thing.Name, thing2.Name);
346 SE.Pay();
347 }
348 else if (thing != null || thing2 != null)
349 {
350 text = ((thing != null) ? thing : thing2).Name;
351 }
352 EClass.pc.homeBranch.log.Add(Msg.Say((text == "") ? "shipped_none" : "shipped", num.ToString() ?? "", text), FontColor.Good);
353 EClass.player.shippingResults.Add(shippingResult);
354 EClass.player.showShippingResult = EClass.core.config.game.showShippingResult;
355 for (int i = 0; i < EClass.player.shippingResults.Count - 10; i++)
356 {
357 EClass.player.shippingResults.RemoveAt(0);
358 }
359 zone.branch.statistics.ship += num3;
360 zone.branch.ModExp(num2);
361 if (thing != null)
362 {
363 EClass.pc.Pick(thing);
364 }
365 if (thing2 != null)
366 {
367 EClass.pc.Pick(thing2);
368 }
369 }
370
371 public void ShipPackages()
372 {
373 Thing container_deliver = EClass.game.cards.container_deliver;
374 if (container_deliver.things.Count == 0)
375 {
376 return;
377 }
378 int num = 0;
379 while (container_deliver.things.Count > 0)
380 {
381 num++;
382 if (num > 100)
383 {
384 Debug.Log("too many tries");
385 break;
386 }
387 int uidZone = 0;
388 foreach (Thing thing2 in container_deliver.things)
389 {
390 int @int = thing2.GetInt(102);
391 if (@int != 0)
392 {
393 uidZone = @int;
394 thing2.SetInt(102);
395 break;
396 }
397 }
398 int num2 = 20;
399 Thing thing = ThingGen.CreateCardboardBox(uidZone);
400 for (int num3 = container_deliver.things.Count - 1; num3 >= 0; num3--)
401 {
402 Thing c = container_deliver.things[num3];
403 thing.AddCard(c);
404 num2 += 5;
405 if (thing.things.IsFull())
406 {
407 break;
408 }
409 }
410 EClass.world.SendPackage(thing);
411 Thing bill = ThingGen.CreateBill(num2, tax: false);
413 }
414 }
415
416 public void ShipLetter()
417 {
418 int num = -1;
419 int lutz = EClass.player.flags.lutz;
420 if (EClass.player.stats.days >= 2 && lutz <= 0)
421 {
422 num = 1;
423 }
424 else if (EClass.player.stats.days >= 5 && lutz <= 1)
425 {
426 num = 2;
427 }
428 else if (EClass.player.stats.days >= 8 && lutz <= 2)
429 {
430 num = 3;
431 }
432 else if (EClass.player.stats.days >= 11 && lutz <= 3)
433 {
434 num = 4;
435 }
436 else if (EClass.player.stats.days >= 15 && lutz <= 4)
437 {
438 num = 5;
439 }
440 else if (EClass.player.stats.days >= 17 && lutz <= 5)
441 {
442 num = 6;
443 }
444 else if (EClass.player.stats.days >= 30 && lutz <= 6)
445 {
446 num = 7;
447 }
448 else if (EClass.player.stats.days >= 50 && lutz <= 7)
449 {
450 num = 8;
451 }
452 if (num != -1)
453 {
454 EClass.player.flags.lutz = num;
455 Thing thing = ThingGen.Create("letter");
456 thing.SetStr(53, "lutz_" + num);
457 EClass.world.SendPackage(thing);
458 }
459 }
460
461 public void ShipRandomPackages()
462 {
464 TraitContainer traitContainer = box.trait as TraitContainer;
465 bool flag = EClass.pc.homeBranch.policies.IsActive(2708);
466 if (EClass.rnd(EClass.debug.enable ? 1 : 100) == 0 && !EClass.player.flags.statueShipped)
467 {
468 EClass.player.flags.statueShipped = true;
469 Add("statue_weird", 1);
470 flag = false;
471 }
472 else if (EClass.rnd(10) == 0)
473 {
474 Add("234", 1);
475 }
476 else if (EClass.rnd(5) == 0)
477 {
478 AddThing(ThingGen.CreateFromCategory("junk"), 1);
479 }
480 else if (EClass.rnd(10) == 0)
481 {
482 AddThing(ThingGen.CreateFromTag("garbage"), 1);
483 }
484 else if (EClass.rnd(8) == 0)
485 {
486 CardRow cardRow = SpawnList.Get("chara").Select(EClass.pc.LV + 10);
487 traitContainer.PutChara(cardRow.id);
488 flag = false;
489 }
490 else if (EClass.rnd(8) == 0)
491 {
492 Add("plat", 1 + EClass.rnd(4));
493 flag = false;
494 }
495 else if (EClass.rnd(8) == 0)
496 {
497 Add("money2", 1 + EClass.rnd(4));
498 flag = false;
499 }
500 else
501 {
502 string id2 = "trash2";
503 if (EClass.rnd(3) == 0)
504 {
505 id2 = "trash1";
506 }
507 if (EClass.rnd(3) == 0)
508 {
509 id2 = ((EClass.rnd(3) == 0) ? "529" : "1170");
510 }
511 if (EClass.rnd(5) == 0)
512 {
513 id2 = "_poop";
514 }
515 if (EClass.rnd(100) == 0)
516 {
517 id2 = "goodness";
518 flag = false;
519 }
520 Add(id2, 1);
521 }
522 if (!flag)
523 {
525 }
526 void Add(string id, int num)
527 {
528 AddThing(ThingGen.Create(id), num);
529 }
530 void AddThing(Thing t, int num)
531 {
532 t.SetNum(num);
533 box.AddCard(t);
534 }
535 }
536}
CurrencyType
Definition: CurrencyType.cs:2
FontColor
Definition: FontColor.cs:2
PriceType
Definition: PriceType.cs:2
list. Add(item3)
static bool TryPray(Chara c, bool passive=false)
Definition: ActPray.cs:12
void SetStr(int id, string value=null)
Definition: BaseCard.cs:63
int GetInt(int id, int? defaultInt=null)
Definition: BaseCard.cs:25
void SetInt(int id, int value=0)
Definition: BaseCard.cs:39
Chara Find(string id)
Definition: CardManager.cs:20
Thing container_shipping
Definition: CardManager.cs:52
List< Chara > listAdv
Definition: CardManager.cs:64
GlobalCharaList globalCharas
Definition: CardManager.cs:46
List< Thing > listPackage
Definition: CardManager.cs:61
Thing container_deliver
Definition: CardManager.cs:55
void RefreshSprite()
string id
Definition: CardRow.cs:7
virtual int GetPrice(CurrencyType currency=CurrencyType.Money, bool sell=false, PriceType priceType=PriceType.Default, Chara c=null)
Definition: Card.cs:7233
Card AddCard(Card c)
Definition: Card.cs:3087
string Name
Definition: Card.cs:2137
Thing SetNum(int a)
Definition: Card.cs:3492
void RecalculateFOV()
Definition: Card.cs:6341
Trait trait
Definition: Card.cs:53
void Destroy()
Definition: Card.cs:5067
ThingContainer things
Definition: Card.cs:38
int Evalue(int ele)
Definition: Card.cs:2571
int Num
Definition: Card.cs:158
CardRenderer renderer
Definition: Card.cs:61
int LV
Definition: Card.cs:386
Footmark footmark
Definition: CellDetail.cs:17
void TryDespawnDetail()
Definition: Cell.cs:1542
Definition: Chara.cs:10
new TraitChara trait
Definition: Chara.cs:503
Faction faction
Definition: Chara.cs:427
override bool IsPCParty
Definition: Chara.cs:615
void OnAdvanceDay()
Definition: Chara.cs:10022
override bool IsPCFaction
Definition: Chara.cs:671
Zone currentZone
Definition: Chara.cs:255
GlobalData global
Definition: Chara.cs:76
Zone homeZone
Definition: Chara.cs:267
FactionBranch homeBranch
Definition: Chara.cs:1066
Thing Pick(Thing t, bool msg=true, bool tryStack=true)
Definition: Chara.cs:4263
new GameConfig game
Definition: CoreConfig.cs:609
GraphicSetting graphic
Definition: CoreConfig.cs:607
bool enable
Definition: CoreDebug.cs:286
CoreConfig config
Definition: Core.cs:70
Definition: Date.cs:4
int GetRaw(int offsetHours=0)
Definition: Date.cs:326
Definition: EClass.cs:6
static Game game
Definition: EClass.cs:9
static Scene scene
Definition: EClass.cs:31
static Core core
Definition: EClass.cs:7
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 BaseGameScreen screen
Definition: EClass.cs:33
static int rndHalf(int a)
Definition: EClass.cs:88
static Player player
Definition: EClass.cs:13
static Chara pc
Definition: EClass.cs:15
static CoreDebug debug
Definition: EClass.cs:49
static SoundManager Sound
Definition: EClass.cs:47
PolicyManager policies
void TryPayBill(Thing bill)
Definition: FACTION.cs:424
void OnAdvanceDay()
Definition: FACTION.cs:379
void OnAdvanceMonth()
Definition: FACTION.cs:387
int remaining
Definition: Footmark.cs:5
Point pos
Definition: Footmark.cs:3
void AdvanceMin(int a)
Definition: GameDate.cs:22
void ShipGoods()
Definition: GameDate.cs:259
void ShipPackages()
Definition: GameDate.cs:371
void AdvanceDay()
Definition: GameDate.cs:145
void ShipRandomPackages()
Definition: GameDate.cs:461
void ShipLetter()
Definition: GameDate.cs:416
const int minPerRound
Definition: GameDate.cs:10
void AdvanceSec(int a)
Definition: GameDate.cs:12
bool shaken
Definition: GameDate.cs:8
void AdvanceMonth()
Definition: GameDate.cs:225
void AdvanceHour()
Definition: GameDate.cs:71
void AdvanceYear()
Definition: GameDate.cs:250
SpatialManager spatials
Definition: Game.cs:152
CardManager cards
Definition: Game.cs:155
Zone activeZone
Definition: Game.cs:251
RelationManager relations
Definition: Game.cs:185
QuestManager quests
Definition: Game.cs:182
Zone StartZone
Definition: Game.cs:277
GlobalGoal goal
Definition: GlobalData.cs:9
void Start()
Definition: GlobalGoal.cs:16
void SetOwner(Chara c)
Definition: GlobalGoal.cs:10
void AdvanceHour()
Definition: GlobalGoal.cs:25
List< Thing > things
Definition: Map.cs:49
List< Footmark > footmarks
Definition: Map.cs:99
void RefreshAllTiles()
Definition: Map.cs:2108
void Add(Data data)
Definition: MsgLog.cs:53
Definition: Msg.cs:5
static void NewLine()
Definition: Msg.cs:318
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:58
void OnAdvanceYear()
void OnAdvanceMonth()
void OnChangeMin()
Definition: PCOrbit.cs:19
int lutz
Definition: Player.cs:635
bool magicChestSent
Definition: Player.cs:515
bool statueShipped
Definition: Player.cs:431
int daysAfterQuestExploration
Definition: Player.cs:647
long shipMoney
Definition: Player.cs:129
int GetShippingBonus(long _a)
Definition: Player.cs:219
int days
Definition: Player.cs:75
int months
Definition: Player.cs:78
int debt
Definition: Player.cs:947
Flags flags
Definition: Player.cs:1094
void OnAdvanceDay()
Definition: Player.cs:2384
Stats stats
Definition: Player.cs:1016
int countNewline
Definition: Player.cs:1187
int holyWell
Definition: Player.cs:917
void OnAdvanceHour()
Definition: Player.cs:2364
bool prayed
Definition: Player.cs:986
List< ShippingResult > shippingResults
Definition: Player.cs:1124
int questRerollCost
Definition: Player.cs:962
int uidLastShippedZone
Definition: Player.cs:902
NumLogManager nums
Definition: Player.cs:1019
CellDetail detail
Definition: Point.cs:71
Cell cell
Definition: Point.cs:51
bool IsActive(int id, int days=-1)
void OnAdvanceHour()
HashSet< string > completedIDs
Definition: QuestManager.cs:17
Quest Add(string id, string idGlobalChara=null)
Definition: QuestManager.cs:29
bool IsCompleted(string id)
Quest GetGlobal(string id)
List< Zone > ListTowns()
Definition: Region.cs:270
void CheckRandomSites()
Definition: Region.cs:75
void UpdateRelations()
void OnChangeHour()
Definition: Scene.cs:780
Definition: Shaker.cs:5
static void ShakeCam(string id="default", float magnitude=1f)
Definition: Shaker.cs:25
Zone Find(string id)
int uid
Definition: Spatial.cs:70
virtual bool IsRegion
Definition: Spatial.cs:515
Faction mainFaction
Definition: Spatial.cs:442
static SpawnList Get(string id, string parent=null, CardFilter filter=null)
Definition: SpawnList.cs:18
CardRow Select(int lv=-1, int levelRange=-1)
Definition: SpawnList.cs:139
bool IsFull(int y=0)
static Thing CreateParcel(string idLang=null, params Thing[] things)
Definition: ThingGen.cs:42
static Thing CreateFromTag(string idTag, int lv=-1)
Definition: ThingGen.cs:80
static Thing CreateFromCategory(string idCat, int lv=-1)
Definition: ThingGen.cs:75
static Thing CreateBill(int pay, bool tax)
Definition: ThingGen.cs:85
static Thing CreateCardboardBox(int uidZone=-1)
Definition: ThingGen.cs:244
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
Definition: Thing.cs:8
void PutChara(string id)
virtual bool UseGlobalGoal
Definition: TraitChara.cs:93
virtual bool CanBeShipped
Definition: Trait.cs:317
static void Reserve(string idStep, Action onBeforePlay=null)
Definition: Tutorial.cs:55
static void Remove(string idStep)
Definition: Tutorial.cs:49
void SimulateHour()
Definition: VirtualDate.cs:66
void OnChangeHour()
Definition: Weather.cs:197
static void Add(BaseSticky sticky, bool animate=true)
Definition: WidgetSticky.cs:52
void CreateDayData()
Definition: World.cs:43
Region region
Definition: World.cs:23
GameDate date
Definition: World.cs:6
void SendPackage(Thing p)
Definition: World.cs:68
Weather weather
Definition: World.cs:12
List< ZoneEvent > list
Definition: Zone.cs:12
ZoneEventManager events
Definition: Zone.cs:40
FactionBranch branch
Definition: Zone.cs:34
virtual void OnAdvanceHour()
Definition: Zone.cs:1164
Region Region
Definition: Zone.cs:160