Elin Decompiled Documentation EA 23.130 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.IsCompleted("exploration"))
197 {
200 {
201 EClass.player.flags.magicChestSent = true;
202 Thing thing = ThingGen.Create("parchment");
203 thing.SetStr(53, "letter_magic_chest");
204 Thing p = ThingGen.CreateParcel(null, ThingGen.Create("container_magic"), thing);
206 }
207 }
208 if (base.day == 25 && base.month == 12)
209 {
211 }
212 }
213
214 public void AdvanceMonth()
215 {
216 base.month++;
217 if (base.month > 12)
218 {
219 base.month = 1;
220 AdvanceYear();
221 }
224 if (base.month % 2 == 0)
225 {
227 }
229 foreach (Thing thing in EClass._map.things)
230 {
231 if (thing.renderer.hasActor)
232 {
233 thing.renderer.RefreshSprite();
234 }
235 }
237 }
238
239 public void AdvanceYear()
240 {
241 base.year++;
242 EClass.player.wellWished = false;
244 EClass.world.SendPackage(ThingGen.Create("gift_newyear"));
245 }
246
247 public void ShipGoods()
248 {
249 Thing container_shipping = EClass.game.cards.container_shipping;
250 if (container_shipping.things.Count == 0)
251 {
252 return;
253 }
254 int num = 0;
255 int num2 = 0;
256 int num3 = 0;
257 int num4 = 0;
258 List<Thing> list = new List<Thing>();
259 List<string> list2 = new List<string>();
261 if (zone == null || zone.branch == null)
262 {
263 zone = EClass.pc.homeZone;
264 }
265 ShippingResult shippingResult = new ShippingResult();
266 shippingResult.rawDate = EClass.world.date.GetRaw();
267 shippingResult.uidZone = zone.uid;
269 {
270 EClass.player.stats.shipMoney = 2147483647L;
271 }
272 shippingResult.total = EClass.player.stats.shipMoney;
273 shippingResult.hearthLv = zone.branch.lv;
274 shippingResult.hearthExp = zone.branch.exp;
275 shippingResult.debt = EClass.player.debt;
276 foreach (Thing thing3 in container_shipping.things)
277 {
278 if (thing3.trait.CanBeShipped)
279 {
280 int price = thing3.GetPrice(CurrencyType.Money, sell: true, PriceType.Shipping);
281 int num5 = price * thing3.Num;
282 num3 += num5;
283 num += thing3.Num;
284 num2 += EClass.rndHalf(thing3.Num * Mathf.Min(15 + price, 10000) / 100 + 1);
285 list.Add(thing3);
286 shippingResult.items.Add(new ShippingResult.Item
287 {
288 text = thing3.Name,
289 income = num5
290 });
291 }
292 }
293 if (list.Count == 0)
294 {
295 return;
296 }
297 num2 = num2 / 2 + 1;
298 if (zone.branch.policies.IsActive(2515))
299 {
300 num2 = 0;
301 }
302 shippingResult.hearthExpGained = num2;
303 EClass.pc.homeBranch.log.Add(Msg.Say("shipped_collect"));
304 foreach (string item in list2)
305 {
307 }
309 EClass.player.stats.shipNum += num;
310 EClass.player.stats.shipMoney += num3;
312 if (shippingBonus2 > shippingBonus)
313 {
314 num4 = shippingBonus2 - shippingBonus;
315 }
316 foreach (Thing item2 in list)
317 {
318 item2.Destroy();
319 }
320 Thing thing = null;
321 Thing thing2 = null;
322 string text = "";
323 if (num3 != 0)
324 {
325 thing = ThingGen.Create("money").SetNum(num3);
326 }
327 if (num4 != 0)
328 {
329 thing2 = ThingGen.Create("money2").SetNum(num4);
330 }
331 if (thing != null && thing2 != null)
332 {
333 text = "_and".lang(thing.Name, thing2.Name);
334 SE.Pay();
335 }
336 else if (thing != null || thing2 != null)
337 {
338 text = ((thing != null) ? thing : thing2).Name;
339 }
340 EClass.pc.homeBranch.log.Add(Msg.Say((text == "") ? "shipped_none" : "shipped", num.ToString() ?? "", text), FontColor.Good);
341 EClass.player.shippingResults.Add(shippingResult);
342 EClass.player.showShippingResult = EClass.core.config.game.showShippingResult;
343 for (int i = 0; i < EClass.player.shippingResults.Count - 10; i++)
344 {
345 EClass.player.shippingResults.RemoveAt(0);
346 }
347 zone.branch.statistics.ship += num3;
348 zone.branch.ModExp(num2);
349 if (thing != null)
350 {
351 EClass.pc.Pick(thing);
352 }
353 if (thing2 != null)
354 {
355 EClass.pc.Pick(thing2);
356 }
357 }
358
359 public void ShipPackages()
360 {
361 Thing container_deliver = EClass.game.cards.container_deliver;
362 if (container_deliver.things.Count == 0)
363 {
364 return;
365 }
366 int num = 0;
367 while (container_deliver.things.Count > 0)
368 {
369 num++;
370 if (num > 100)
371 {
372 Debug.Log("too many tries");
373 break;
374 }
375 int uidZone = 0;
376 foreach (Thing thing2 in container_deliver.things)
377 {
378 int @int = thing2.GetInt(102);
379 if (@int != 0)
380 {
381 uidZone = @int;
382 thing2.SetInt(102);
383 break;
384 }
385 }
386 int num2 = 20;
387 Thing thing = ThingGen.CreateCardboardBox(uidZone);
388 for (int num3 = container_deliver.things.Count - 1; num3 >= 0; num3--)
389 {
390 Thing c = container_deliver.things[num3];
391 thing.AddCard(c);
392 num2 += 5;
393 if (thing.things.IsFull())
394 {
395 break;
396 }
397 }
398 EClass.world.SendPackage(thing);
399 Thing bill = ThingGen.CreateBill(num2, tax: false);
401 }
402 }
403
404 public void ShipLetter()
405 {
406 int num = -1;
407 int lutz = EClass.player.flags.lutz;
408 if (EClass.player.stats.days >= 2 && lutz <= 0)
409 {
410 num = 1;
411 }
412 else if (EClass.player.stats.days >= 5 && lutz <= 1)
413 {
414 num = 2;
415 }
416 else if (EClass.player.stats.days >= 8 && lutz <= 2)
417 {
418 num = 3;
419 }
420 else if (EClass.player.stats.days >= 11 && lutz <= 3)
421 {
422 num = 4;
423 }
424 else if (EClass.player.stats.days >= 15 && lutz <= 4)
425 {
426 num = 5;
427 }
428 else if (EClass.player.stats.days >= 17 && lutz <= 5)
429 {
430 num = 6;
431 }
432 else if (EClass.player.stats.days >= 30 && lutz <= 6)
433 {
434 num = 7;
435 }
436 else if (EClass.player.stats.days >= 50 && lutz <= 7)
437 {
438 num = 8;
439 }
440 if (num != -1)
441 {
442 EClass.player.flags.lutz = num;
443 Thing thing = ThingGen.Create("letter");
444 thing.SetStr(53, "lutz_" + num);
445 EClass.world.SendPackage(thing);
446 }
447 }
448
449 public void ShipRandomPackages()
450 {
452 TraitContainer traitContainer = box.trait as TraitContainer;
453 bool flag = EClass.pc.homeBranch.policies.IsActive(2708);
454 if (EClass.rnd(EClass.debug.enable ? 1 : 100) == 0 && !EClass.player.flags.statueShipped)
455 {
456 EClass.player.flags.statueShipped = true;
457 Add("statue_weird", 1);
458 flag = false;
459 }
460 else if (EClass.rnd(10) == 0)
461 {
462 Add("234", 1);
463 }
464 else if (EClass.rnd(5) == 0)
465 {
466 AddThing(ThingGen.CreateFromCategory("junk"), 1);
467 }
468 else if (EClass.rnd(10) == 0)
469 {
470 AddThing(ThingGen.CreateFromTag("garbage"), 1);
471 }
472 else if (EClass.rnd(8) == 0)
473 {
474 CardRow cardRow = SpawnList.Get("chara").Select(EClass.pc.LV + 10);
475 traitContainer.PutChara(cardRow.id);
476 flag = false;
477 }
478 else if (EClass.rnd(8) == 0)
479 {
480 Add("plat", 1 + EClass.rnd(4));
481 flag = false;
482 }
483 else if (EClass.rnd(8) == 0)
484 {
485 Add("money2", 1 + EClass.rnd(4));
486 flag = false;
487 }
488 else
489 {
490 string id2 = "trash2";
491 if (EClass.rnd(3) == 0)
492 {
493 id2 = "trash1";
494 }
495 if (EClass.rnd(3) == 0)
496 {
497 id2 = ((EClass.rnd(3) == 0) ? "529" : "1170");
498 }
499 if (EClass.rnd(5) == 0)
500 {
501 id2 = "_poop";
502 }
503 if (EClass.rnd(100) == 0)
504 {
505 id2 = "goodness";
506 flag = false;
507 }
508 Add(id2, 1);
509 }
510 if (!flag)
511 {
513 }
514 void Add(string id, int num)
515 {
516 AddThing(ThingGen.Create(id), num);
517 }
518 void AddThing(Thing t, int num)
519 {
520 t.SetNum(num);
521 box.AddCard(t);
522 }
523 }
524}
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:6676
Card AddCard(Card c)
Definition: Card.cs:2936
string Name
Definition: Card.cs:2037
Thing SetNum(int a)
Definition: Card.cs:3286
void RecalculateFOV()
Definition: Card.cs:5797
Trait trait
Definition: Card.cs:49
void Destroy()
Definition: Card.cs:4680
ThingContainer things
Definition: Card.cs:34
int Evalue(int ele)
Definition: Card.cs:2471
int Num
Definition: Card.cs:154
CardRenderer renderer
Definition: Card.cs:57
int LV
Definition: Card.cs:370
Footmark footmark
Definition: CellDetail.cs:17
void TryDespawnDetail()
Definition: Cell.cs:1538
Definition: Chara.cs:10
new TraitChara trait
Definition: Chara.cs:493
Faction faction
Definition: Chara.cs:417
override bool IsPCParty
Definition: Chara.cs:605
void OnAdvanceDay()
Definition: Chara.cs:9256
override bool IsPCFaction
Definition: Chara.cs:661
Zone currentZone
Definition: Chara.cs:245
GlobalData global
Definition: Chara.cs:76
Zone homeZone
Definition: Chara.cs:257
FactionBranch homeBranch
Definition: Chara.cs:894
Thing Pick(Thing t, bool msg=true, bool tryStack=true)
Definition: Chara.cs:3940
new GameConfig game
Definition: CoreConfig.cs:598
GraphicSetting graphic
Definition: CoreConfig.cs:596
bool enable
Definition: CoreDebug.cs:285
CoreConfig config
Definition: Core.cs:70
Definition: Date.cs:4
int GetRaw(int offsetHours=0)
Definition: Date.cs:322
Definition: EClass.cs:5
static Game game
Definition: EClass.cs:8
static Scene scene
Definition: EClass.cs:30
static int rnd(int a)
Definition: EClass.cs:58
static Core core
Definition: EClass.cs:6
static Zone _zone
Definition: EClass.cs:20
static World world
Definition: EClass.cs:40
static Map _map
Definition: EClass.cs:18
static BaseGameScreen screen
Definition: EClass.cs:32
static int rndHalf(int a)
Definition: EClass.cs:82
static Player player
Definition: EClass.cs:12
static Chara pc
Definition: EClass.cs:14
static CoreDebug debug
Definition: EClass.cs:48
static SoundManager Sound
Definition: EClass.cs:46
PolicyManager policies
void TryPayBill(Thing bill)
Definition: FACTION.cs:407
void OnAdvanceDay()
Definition: FACTION.cs:362
void OnAdvanceMonth()
Definition: FACTION.cs:370
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:247
void ShipPackages()
Definition: GameDate.cs:359
void AdvanceDay()
Definition: GameDate.cs:145
void ShipRandomPackages()
Definition: GameDate.cs:449
void ShipLetter()
Definition: GameDate.cs:404
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:214
void AdvanceHour()
Definition: GameDate.cs:71
void AdvanceYear()
Definition: GameDate.cs:239
SpatialManager spatials
Definition: Game.cs:152
CardManager cards
Definition: Game.cs:155
Zone activeZone
Definition: Game.cs:245
RelationManager relations
Definition: Game.cs:182
QuestManager quests
Definition: Game.cs:179
Zone StartZone
Definition: Game.cs:269
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:2086
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:498
bool magicChestSent
Definition: Player.cs:402
bool statueShipped
Definition: Player.cs:318
int daysAfterQuestExploration
Definition: Player.cs:510
long shipMoney
Definition: Player.cs:98
int GetShippingBonus(long _a)
Definition: Player.cs:106
int days
Definition: Player.cs:68
int months
Definition: Player.cs:70
int debt
Definition: Player.cs:766
Flags flags
Definition: Player.cs:910
void OnAdvanceDay()
Definition: Player.cs:2183
Stats stats
Definition: Player.cs:832
int countNewline
Definition: Player.cs:1003
int holyWell
Definition: Player.cs:736
void OnAdvanceHour()
Definition: Player.cs:2163
bool prayed
Definition: Player.cs:802
List< ShippingResult > shippingResults
Definition: Player.cs:940
int questRerollCost
Definition: Player.cs:781
int uidLastShippedZone
Definition: Player.cs:721
NumLogManager nums
Definition: Player.cs:835
CellDetail detail
Definition: Point.cs:71
Cell cell
Definition: Point.cs:51
bool IsActive(int id, int days=-1)
void OnAdvanceHour()
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:231
void CheckRandomSites()
Definition: Region.cs:53
void UpdateRelations()
void OnChangeHour()
Definition: Scene.cs:767
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:501
Faction mainFaction
Definition: Spatial.cs:430
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:205
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:312
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:1124
Region Region
Definition: Zone.cs:160