Elin Decompiled Documentation EA 23.188 Stable Patch 2
Loading...
Searching...
No Matches
FactionBranch.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using Newtonsoft.Json;
5using UnityEngine;
6
7public class FactionBranch : EClass
8{
9 public class Statistics : EClass
10 {
11 [JsonProperty]
12 public int ship;
13
14 [JsonProperty]
15 public int inn;
16
17 [JsonProperty]
18 public int tourism;
19
20 [JsonProperty]
21 public int shop;
22
23 [JsonProperty]
24 public int numSold;
25
26 [JsonProperty]
27 public int visitor;
28
29 [JsonProperty]
30 public int tax;
31 }
32
33 [JsonProperty]
34 public int lv = 1;
35
36 [JsonProperty]
37 public int rank;
38
39 [JsonProperty]
40 public int exp;
41
42 [JsonProperty]
43 public int seedPlan;
44
45 [JsonProperty]
46 public int temper;
47
48 [JsonProperty]
49 public int uidMaid;
50
51 [JsonProperty]
53
54 [JsonProperty]
55 public int incomeShop;
56
57 [JsonProperty]
58 public bool luckyMonth;
59
60 [JsonProperty]
61 public bool luckyMonthDone;
62
63 [JsonProperty]
65 {
66 value = 1
67 };
68
69 [JsonProperty]
71
72 [JsonProperty]
74
75 [JsonProperty]
77
78 [JsonProperty]
80
81 [JsonProperty]
83
84 [JsonProperty]
85 public Thing stash;
86
87 [JsonProperty]
88 public MsgLog log = new MsgLog
89 {
90 id = "log"
91 };
92
93 [JsonProperty]
95
96 [JsonProperty]
98
99 [JsonProperty]
100 public List<HireInfo> listRecruit = new List<HireInfo>();
101
102 [JsonProperty]
103 public int dateFound;
104
105 [JsonProperty]
106 public int tourism;
107
108 [JsonProperty]
110
111 [JsonProperty]
113
114 public Zone owner;
115
116 public int incomeInn;
117
118 public int incomeTourism;
119
120 public int efficiency = 100;
121
122 public List<Chara> members = new List<Chara>();
123
124 public int Money => resources.money.value;
125
126 public int Worth => resources.worth.value;
127
128 public int NumHeirloom => 4 + Evalue(2120);
129
130 public int MaxAP => 4 + Evalue(2115) + Evalue(3900) * 5 + Evalue(3709) * lv;
131
132 public int MaxPopulation => 5 + Evalue(2204);
133
134 public int MaxSoil => ((int)(Mathf.Sqrt(EClass._map.bounds.Width * EClass._map.bounds.Height) * 3f) + Evalue(2200) * 5) * (100 + Evalue(3700) * 25) / 100;
135
136 public int ContentLV => Mathf.Max(1, lv * 4 + EClass.scene.elomap.GetRoadDist(EClass._zone.x, EClass._zone.y) - 4 + (int)Mathf.Sqrt(Evalue(2706)) * 4);
137
138 public int DangerLV => Mathf.Max(1, ContentLV - (int)Mathf.Sqrt(Evalue(2704)) * 2);
139
140 public bool HasItemProtection => lv >= 3;
141
142 public bool HasNetwork => lv >= 5;
143
144 public bool IsTaxFree => policies.IsActive(2514);
145
146 public string RankText => (0.01f * (float)exp + (float)rank).ToString("F2");
147
148 public string TextLv => lv + " (" + (100f * (float)exp / (float)GetNextExp()).ToString("F1") + ")";
149
150 public bool IsStartBranch => owner.id == "startSite";
151
153
154 public int MaxLv => 7;
155
156 public int GetNextExp(int _lv = -1)
157 {
158 if (_lv == -1)
159 {
160 _lv = lv;
161 }
162 return _lv * _lv * 100 + 100;
163 }
164
165 public int Evalue(int ele)
166 {
168 if (row.category == "policy")
169 {
170 return policies.GetValue(ele);
171 }
172 if (HasNetwork && row.tag.Contains("network"))
173 {
174 return EClass.pc.faction.elements.Value(ele) + elements.Value(ele);
175 }
176 return elements.Value(ele);
177 }
178
179 public int GetProductBonus(Chara c)
180 {
181 if (c.isDead || c.IsPCParty)
182 {
183 return 0;
184 }
185 if (c.memberType == FactionMemberType.Livestock)
186 {
187 return 100;
188 }
189 return Mathf.Max(1, (90 + Evalue(2116) / 2) * efficiency / 100);
190 }
191
192 public void RefreshEfficiency()
193 {
194 int num = 100;
195 int num2 = CountMembers(FactionMemberType.Default);
196 int ration = 0;
197 foreach (Chara member in members)
198 {
199 if (member.memberType != 0 || member.IsPCParty || member.homeBranch == null || member.homeBranch.owner == null)
200 {
201 continue;
202 }
203 foreach (Hobby item in member.ListHobbies())
204 {
205 TryAdd(item);
206 }
207 foreach (Hobby item2 in member.ListWorks())
208 {
209 TryAdd(item2);
210 }
211 }
212 if (num2 > MaxPopulation)
213 {
214 num -= (num2 - MaxPopulation) * 20 * 100 / (100 + 20 * (int)Mathf.Sqrt(ration));
215 }
216 if (efficiency < 0)
217 {
218 efficiency = 0;
219 }
220 efficiency = num;
221 void TryAdd(Hobby h)
222 {
223 if (!h.source.elements.IsEmpty())
224 {
225 for (int i = 0; i < h.source.elements.Length; i += 2)
226 {
227 if (h.source.elements[i] == 2207)
228 {
229 ration += h.source.elements[i + 1];
230 }
231 }
232 }
233 }
234 }
235
236 public void Abandon()
237 {
238 }
239
240 public void OnCreate(Zone zone)
241 {
242 SetOwner(zone);
243 stash = ThingGen.Create("container_salary");
247 }
248
249 public void SetOwner(Zone zone)
250 {
251 owner = zone;
252 resources.SetOwner(this);
253 researches.SetOwner(this);
254 policies.SetOwner(this);
255 happiness.SetOwner(this);
256 expeditions.SetOwner(this);
257 meetings.SetOwner(this);
258 foreach (Chara value in EClass.game.cards.globalCharas.Values)
259 {
260 if (value == null)
261 {
262 Debug.LogError("exception: c==null");
263 }
264 else if (EClass.pc == null)
265 {
266 Debug.LogError("exception: pc==null");
267 }
268 else if (value.homeZone == zone && value.faction == EClass.pc.faction)
269 {
270 members.Add(value);
272 }
273 }
275 }
276
277 public void OnActivateZone()
278 {
279 incomeInn = 0;
280 incomeTourism = 0;
281 foreach (Chara member in members)
282 {
283 if (member.IsAliveInCurrentZone && !member.pos.IsInBounds)
284 {
286 }
288 }
290 }
291
292 public void OnAfterSimulate()
293 {
294 if (!EClass.game.isLoading)
295 {
297 }
298 foreach (Chara chara in EClass._map.charas)
299 {
300 if (!chara.IsPCParty && !chara.noMove)
301 {
302 if ((chara.pos.cell.HasBlock || chara.pos.cell.hasDoor) && !chara.isRestrained && !chara.HasCondition<ConSuspend>())
303 {
304 chara.MoveImmediate(chara.pos.GetNearestPoint(allowBlock: false, allowChara: false) ?? chara.pos);
305 }
307 {
308 EClass.pc.party.AddMemeber(chara, showMsg: true);
309 }
310 }
311 }
312 }
313
314 public void OnUnloadMap()
315 {
316 }
317
318 public void OnSimulateHour(VirtualDate date)
319 {
320 int num = CountMembers(FactionMemberType.Default, onlyAlive: true);
321 int starveChance = Mathf.Max(num - MaxPopulation, 0);
322 members.ForeachReverse(delegate(Chara c)
323 {
324 if (!c.IsPCParty && c.IsAliveInCurrentZone && !c.noMove)
325 {
326 if (EClass.rnd(24 * members.Count) < starveChance)
327 {
328 starveChance--;
329 }
330 else
331 {
332 c.TickWork(date);
333 }
334 if (!date.IsRealTime && EClass.rnd(3) != 0 && c.memberType == FactionMemberType.Default)
335 {
336 c.hunger.Mod(1);
337 if (c.hunger.GetPhase() >= 3)
338 {
339 Thing meal = GetMeal(c);
340 if (meal != null)
341 {
342 FoodEffect.Proc(c, meal);
343 }
344 else
345 {
346 c.hunger.Mod(-50);
347 }
348 }
349 }
350 }
351 });
352 expeditions.OnSimulateHour();
353 meetings.OnSimulateHour(date);
354 policies.OnSimulateHour(date);
355 int num2 = Evalue(3707);
356 int num3 = Evalue(3705) + Evalue(3710) * 2;
357 int num4 = 4 + num3 * 4;
358 int num5 = Mathf.Max(1, (100 + Evalue(2205) * 5 + Evalue(3703) * 100 - num2 * 80) / 10);
359 int num6 = 10;
360 if (policies.IsActive(2709))
361 {
362 num6 = 0;
363 }
365 {
366 num5 /= 2;
367 }
368 if ((date.IsRealTime || num2 > 0) && !EClass.debug.enable && EClass.rnd(num5) == 0 && !EClass.pc.IsDeadOrSleeping && EClass._map.CountHostile() < num4)
369 {
370 int num7 = 1 + EClass.rnd(num2 + num3 + 1);
371 for (int i = 0; i < num7; i++)
372 {
373 EClass._zone.SpawnMob(null, SpawnSetting.HomeEnemy(DangerLV));
374 }
375 }
376 if ((date.IsRealTime || num2 == 0) && num6 != 0 && EClass.rnd(num6) == 0 && EClass._map.CountWildAnimal() < num4)
377 {
379 }
380 if (EClass.rnd(5) == 0 && policies.IsActive(2810))
381 {
382 int num8 = 3 + lv + Evalue(2206) / 5 + Evalue(3702) * 2 + Evalue(2202) / 2;
383 num8 = num8 * (100 + Evalue(3702) * 20 + Evalue(2206)) / 100;
384 num8 = num8 * (100 + (int)Mathf.Sqrt(Evalue(2811)) * 3) / 100;
385 if (luckyMonth)
386 {
387 num8 = num8 * 2 + 5;
388 }
389 if (EClass._map.CountGuest() < num8)
390 {
391 Chara chara;
392 if (luckyMonth || (policies.IsActive(2822) && Mathf.Sqrt(Evalue(2822) / 2) + 5f >= (float)EClass.rnd(100)))
393 {
394 chara = CharaGen.CreateWealthy(ContentLV);
396 }
397 else
398 {
399 chara = EClass._zone.SpawnMob(null, SpawnSetting.HomeGuest(ContentLV));
400 }
401 if (chara != null && (chara.id == "nun_mother" || chara.id == "prostitute") && policies.IsActive(2710))
402 {
403 chara.Destroy();
404 chara = null;
405 }
406 if (chara != null)
407 {
408 statistics.visitor++;
409 chara.memberType = FactionMemberType.Guest;
410 chara.SetInt(34, EClass.world.date.GetRaw());
411 chara.c_allowance = chara.LV * 100;
412 if (chara.IsWealthy)
413 {
414 chara.c_allowance *= 10;
415 }
416 if (date.IsRealTime)
417 {
418 Msg.Say("guestArrive", chara.Name);
419 }
420 else
421 {
422 chara.TryAssignBed();
423 }
424 }
425 }
426 }
427 foreach (Chara chara3 in EClass._map.charas)
428 {
429 if (chara3.memberType != FactionMemberType.Guest || ((chara3.c_allowance > 0 || EClass.rnd(2) != 0) && chara3.GetInt(34) + 10080 >= EClass.world.date.GetRaw()))
430 {
431 continue;
432 }
433 foreach (Chara item in EClass._zone.ListMinions(chara3))
434 {
435 item.Destroy();
436 }
437 if (!chara3.IsGlobal)
438 {
439 chara3.Destroy();
440 }
441 chara3.ClearBed();
442 break;
443 }
444 if (date.hour == 5)
445 {
446 for (int j = 0; j < ((!luckyMonth) ? 1 : 2); j++)
447 {
448 DailyOutcome(date);
449 }
450 GenerateGarbage(date);
451 if (!date.IsRealTime)
452 {
453 AutoClean();
454 }
455 CalcTourismIncome();
456 CalcInnIncome();
457 if (date.IsRealTime)
458 {
459 GetDailyIncome();
460 }
461 }
462 if (!EClass.player.simulatingZone && date.hour == 6)
463 {
464 ReceivePackages(date);
465 }
466 if (!date.IsRealTime && date.hour % 8 == 0)
467 {
468 foreach (Chara item2 in EClass._map.charas.Where((Chara c) => c.memberType == FactionMemberType.Guest).ToList())
469 {
470 for (int k = 0; k < 3; k++)
471 {
472 AI_Shopping.TryShop(item2, realtime: false);
473 }
474 }
475 AI_Shopping.TryRestock(EClass.pc, realtime: false);
476 }
477 if (EClass.rnd(24) == 0 || EClass.debug.enable)
478 {
479 foreach (Thing thing in EClass._map.things)
480 {
481 if (EClass.rnd(20) == 0 && thing.trait is TraitFoodEggFertilized && thing.pos.FindThing<TraitBed>() != null)
482 {
483 Chara chara2 = TraitFoodEggFertilized.Incubate(thing, thing.pos);
484 thing.ModNum(-1);
485 if (date.IsRealTime)
486 {
487 chara2.PlaySound("egg");
488 }
489 break;
490 }
491 }
492 }
493 resources.SetDirty();
494 }
495
496 public void AutoClean()
497 {
498 foreach (Chara member in members)
499 {
500 if (member.IsPCParty || !member.ExistsOnMap || member.memberType != 0)
501 {
502 continue;
503 }
504 Hobby hobby = member.GetWork("Clean") ?? member.GetWork("Chore");
505 if (hobby == null)
506 {
507 continue;
508 }
509 int num = (5 + EClass.rnd(5)) * hobby.GetEfficiency(member) / 100;
510 for (int i = 0; i < num; i++)
511 {
512 Thing thingToClean = AI_Haul.GetThingToClean(member);
513 if (thingToClean == null)
514 {
515 break;
516 }
518 }
519 }
520 }
521
522 public void OnSimulateDay(VirtualDate date)
523 {
524 if (owner == null || owner.mainFaction != EClass.Home)
525 {
526 return;
527 }
528 researches.OnSimulateDay();
529 resources.OnSimulateDay();
530 happiness.OnSimulateDay();
531 if (!date.IsRealTime)
532 {
533 BranchMap branchMap = date.GetBranchMap();
534 foreach (Chara member in members)
535 {
536 if (!member.IsPCParty && member.memberType != FactionMemberType.Livestock && !member.faith.IsEyth && !member.c_isPrayed && branchMap.altarMap.Contains(member.faith.id))
537 {
538 AI_Pray.Pray(member, silent: true);
539 }
540 }
541 }
542 foreach (Chara member2 in members)
543 {
544 member2.c_isPrayed = false;
545 member2.c_isTrained = false;
546 }
547 if (date.day != 1)
548 {
549 return;
550 }
551 luckyMonth = false;
552 if (date.month == 1)
553 {
554 luckyMonthDone = false;
555 }
556 if (!luckyMonthDone)
557 {
558 bool flag = EClass.pc.faith == EClass.game.religions.Luck;
559 luckyMonth = (float)(flag ? 30 : 5) + Mathf.Sqrt(Evalue(2118)) * (float)(flag ? 4 : 2) > (float)EClass.rnd(720);
560 if (EClass.debug.enable)
561 {
562 luckyMonth = true;
563 }
564 if (luckyMonth)
565 {
566 Log("lucky_month", EClass._zone.Name);
567 Msg.Say("lucky_month", EClass._zone.Name);
568 Msg.Say("umi");
569 SE.Play("godbless");
570 EClass.world.SendPackage(ThingGen.Create("book_kumiromi"));
571 luckyMonthDone = true;
572 }
573 }
574 }
575
576 public void OnAdvanceDay()
577 {
578 int num = 0;
579 foreach (Chara member in members)
580 {
581 if (member.IsPC || member.isDead)
582 {
583 continue;
584 }
585 if (member.IsPCParty || member.currentZone == EClass.pc.currentZone)
586 {
587 member.c_daysWithPC++;
588 }
589 if (member.memberType == FactionMemberType.Default)
590 {
591 if (EClass.rnd(3) == 0)
592 {
593 num++;
594 }
595 if (member.GetWork("Pioneer") != null)
596 {
597 num += 3;
598 }
599 }
600 }
601 ModExp(num);
602 }
603
604 public void OnSimulateMonth(VirtualDate date)
605 {
606 lastStatistics = statistics;
607 statistics = new Statistics();
608 }
609
610 public void GenerateGarbage(VirtualDate date)
611 {
612 int sortChance = 40 + GetCivility();
613 int unsortedCount = 0;
614 foreach (Chara member in members)
615 {
616 if (!member.IsPCParty && member.ExistsOnMap)
617 {
618 Hobby hobby = member.GetWork("Clean") ?? member.GetWork("Chore");
619 if (hobby != null)
620 {
621 sortChance += 20 * hobby.GetEfficiency(member) / 100;
622 }
623 }
624 }
625 int num = Evalue(2702);
626 int num2 = EClass.rnd(2);
627 for (int i = 0; i < num2; i++)
628 {
629 if (num == 0 || EClass.rnd(num + (EClass.debug.enable ? 100000 : 10)) == 0)
630 {
631 Generate(null);
632 }
633 }
634 foreach (Chara member2 in members)
635 {
636 if (!member2.IsPCParty && member2.ExistsOnMap && (num == 0 || EClass.rnd(num + (EClass.debug.enable ? 100000 : 10)) == 0))
637 {
638 Generate(member2);
639 }
640 }
641 void Generate(Chara c)
642 {
643 if (c == null || EClass.rnd(5) == 0)
644 {
645 if (EClass.rnd(80) == 0)
646 {
648 }
649 else if (EClass.rnd(40) == 0)
650 {
651 Thing thing;
652 Add(thing = ThingGen.CreateFromTag("garbage"));
653 }
654 else
655 {
656 string id = "trash2";
657 if (EClass.rnd(3) == 0)
658 {
659 id = "trash1";
660 }
661 if (EClass.rnd(10) == 0)
662 {
663 id = ((EClass.rnd(3) == 0) ? "529" : "1170");
664 }
665 if (c != null && (!c.IsUnique || c.memberType == FactionMemberType.Livestock) && EClass.rnd((c.memberType == FactionMemberType.Livestock) ? 2 : 50) == 0)
666 {
667 id = "_poop";
668 }
669 if (EClass.rnd(200000) == 0)
670 {
671 id = "goodness";
672 }
673 Add(ThingGen.Create(id));
674 }
675 }
676 void Add(Thing t)
677 {
678 if (sortChance < EClass.rnd(100))
679 {
680 EClass._zone.TryAddThing(t, (c != null) ? (c.pos.GetRandomPoint(2) ?? c.pos).GetNearestPoint() : EClass._zone.bounds.GetRandomSurface(), destroyIfFail: true);
681 }
682 else
683 {
684 if (t.id == "_poop" && EClass.rnd(150) == 0)
685 {
686 t.ChangeMaterial((EClass.rnd(2) == 0) ? "silver" : "gold");
687 }
688 if (!TryTrash(t))
689 {
690 unsortedCount++;
691 if (unsortedCount >= 5)
692 {
693 Tutorial.Reserve("garbage");
694 }
695 }
696 }
697 }
698 }
699 }
700
701 public bool TryTrash(Thing t)
702 {
703 Thing thing = ((t.id == "_poop" || t.source._origin == "dish") ? EClass._map.props.installed.FindEmptyContainer<TraitContainerCompost>(t) : (t.isFireproof ? EClass._map.props.installed.FindEmptyContainer<TraitContainerUnburnable>(t) : EClass._map.props.installed.FindEmptyContainer<TraitContainerBurnable>(t)));
704 if (thing != null)
705 {
706 thing.AddCard(t);
707 return true;
708 }
709 return EClass._zone.TryAddThingInSpot<TraitSpotGarbage>(t, useContainer: false);
710 }
711
712 public void ReceivePackages(VirtualDate date)
713 {
715 {
716 return;
717 }
718 List<Thing> listPackage = EClass.game.cards.listPackage;
719 if (EClass.player.stats.days >= 2 && !EClass.player.flags.elinGift && Steam.HasDLC(ID_DLC.BackerReward))
720 {
721 listPackage.Add(ThingGen.Create("gift"));
722 EClass.player.flags.elinGift = true;
723 }
724 if (listPackage.Count == 0)
725 {
726 return;
727 }
728 SE.Play("notice");
729 int num = 0;
730 foreach (Thing item in listPackage)
731 {
732 if (item.id != "bill")
733 {
734 num++;
735 }
736 PutInMailBox(item, item.id == "cardboard_box" || item.id == "gift");
737 WidgetPopText.Say("popDeliver".lang(item.Name));
738 }
739 Msg.Say("deliver_arrive", num.ToString() ?? "");
740 listPackage.Clear();
741 }
742
743 public void DailyOutcome(VirtualDate date)
744 {
745 Thing thing = null;
746 foreach (Chara member in members)
747 {
748 Chara i = member;
749 if (EClass.rnd(EClass.debug.enable ? 2 : (360 * members.Count)) == 0 && !i.IsPC && EClass.pc.faction.IsGlobalPolicyActive(2712) && i.things.Find((Thing t) => t.id == "panty" && t.c_idRefCard == i.id) == null && !i.things.IsFull())
750 {
751 Thing thing2 = ThingGen.Create("panty");
752 thing2.c_idRefCard = i.id;
753 i.AddThing(thing2);
754 }
755 if (i.IsPCParty || !i.ExistsOnMap)
756 {
757 continue;
758 }
759 i.RefreshWorkElements(elements);
760 if (i.memberType == FactionMemberType.Livestock)
761 {
762 if (thing == null)
763 {
764 thing = EClass._map.Stocked.Find("pasture", -1, -1, shared: true) ?? EClass._map.Installed.Find("pasture");
765 }
766 if (thing == null)
767 {
768 continue;
769 }
770 if (i.race.breeder >= EClass.rnd(2500 - (int)Mathf.Sqrt(Evalue(2827) * 100)))
771 {
772 if (EClass.rnd(3) != 0)
773 {
774 Thing t2 = i.MakeEgg(date.IsRealTime, 1, date.IsRealTime);
775 if (!date.IsRealTime)
776 {
777 i.TryPutShared(t2);
778 }
779 }
780 else
781 {
782 Thing t3 = i.MakeMilk(date.IsRealTime, 1, date.IsRealTime);
783 if (!date.IsRealTime)
784 {
785 i.TryPutShared(t3);
786 }
787 }
788 }
789 if (i.HaveFur())
790 {
791 if (i.HasElement(1533))
792 {
793 i.c_fur = 0;
794 }
795 else
796 {
797 i.c_fur++;
798 if (EClass.rnd(4) == 0 && i.HasElement(1532))
799 {
800 i.c_fur++;
801 }
802 }
803 }
804 thing.ModNum(-1);
805 if (thing.isDestroyed || thing.Num == 0)
806 {
807 thing = null;
808 }
809 continue;
810 }
811 foreach (Hobby item in i.ListHobbies())
812 {
813 GetOutcome(item);
814 }
815 foreach (Hobby item2 in i.ListWorks())
816 {
817 GetOutcome(item2);
818 }
819 void GetOutcome(Hobby h)
820 {
821 int num3 = h.GetEfficiency(i) * GetProductBonus(i) / 100;
822 int num4 = h.GetLv(i);
823 int id = EClass.sources.elements.alias[h.source.skill].id;
824 if (!i.elements.HasBase(id))
825 {
826 i.elements.SetBase(id, 1);
827 }
828 i.ModExp(id, 100);
829 for (int j = 0; j < h.source.things.Length; j += 2)
830 {
831 string text = h.source.things[j];
832 int num5 = Mathf.Max(1, h.source.things[j + 1].ToInt() * num3 / 1000);
833 Debug.Log(i.Name + "/" + num3 + "/" + num5);
834 int num6 = num5 / 1000;
835 if (num5 % 1000 > EClass.rnd(1000))
836 {
837 num6++;
838 }
839 if (num6 != 0)
840 {
841 if (!(text == "_egg"))
842 {
843 if (text == "milk")
844 {
845 i.MakeMilk(date.IsRealTime, num6);
846 }
847 else
848 {
849 Thing thing4 = ((!text.StartsWith("#")) ? ThingGen.Create(h.source.things[j], -1, num4) : ThingGen.CreateFromCategory(text.Replace("#", ""), num4));
850 if (thing4 != null)
851 {
852 num6 *= thing4.trait.CraftNum;
853 if (thing4.category.id == "fish" && EClass.rnd(EClass.debug.enable ? 1 : 5) == 0)
854 {
855 int num7 = Mathf.Min(EClass.rnd(EClass.rnd(EClass.rnd(EClass.curve(num4, 100, 50, 70) + 50))) / 50, 3);
856 if (num7 > 0)
857 {
858 thing4.SetTier(num7);
859 num6 /= num7 + 1;
860 }
861 }
862 if (num6 < 1)
863 {
864 num6 = 1;
865 }
866 if (!thing4.trait.CanStack)
867 {
868 num6 = 1;
869 }
870 thing4.SetNum(num6);
871 thing4.SetBlessedState(BlessedState.Normal);
872 thing4.TryMakeRandomItem(num4);
873 if (thing4.IsAmmo)
874 {
875 thing4.ChangeMaterial("iron");
876 thing4.c_IDTState = 0;
877 }
878 bool flag = thing4.category.id == "garbage";
879 if (thing4.trait is TraitFoodMeal)
880 {
881 if (thing4.HasTag(CTAG.dish_fail))
882 {
883 flag = true;
884 }
885 else
886 {
887 CraftUtil.MakeDish(thing4, num4 + 10, i);
888 if (thing4.id == "lunch_dystopia")
889 {
890 flag = true;
891 }
892 }
893 }
894 if (flag)
895 {
896 TryTrash(thing4);
897 }
898 else
899 {
900 i.TryPutShared(thing4);
901 }
902 }
903 }
904 }
905 else
906 {
907 i.MakeEgg(date.IsRealTime, num6);
908 }
909 }
910 }
911 switch (h.source.alias)
912 {
913 case "Nurse":
914 {
915 foreach (Chara member2 in members)
916 {
917 if (!member2.IsPCParty)
918 {
919 if (member2.isDead && member2.CanRevive() && EClass.rnd(num3) > EClass.rnd(100))
920 {
921 Log("bNurse", i, member2);
922 member2.Revive(member2.pos, msg: true);
923 if (date.IsRealTime && member2.c_wasInPcParty)
924 {
925 EClass.pc.party.AddMemeber(member2, showMsg: true);
926 }
927 break;
928 }
929 if (EClass.rnd(num3) > EClass.rnd(100))
930 {
931 member2.CureHost(CureType.HealComplete);
932 }
933 }
934 }
935 break;
936 }
937 case "Chore":
938 case "Clean":
939 {
940 for (int k = 0; k < num3 / 2; k++)
941 {
942 Point randomPoint = EClass._map.bounds.GetRandomPoint();
943 if (randomPoint.HasDecal)
944 {
945 EClass._map.SetDecal(randomPoint.x, randomPoint.z);
946 }
947 }
948 break;
949 }
950 case "TreasureHunt":
951 if (EClass.rnd(num3) > EClass.rnd(EClass.debug.enable ? 100 : 5000))
952 {
954 if (thing5 != null)
955 {
956 Thing thing6 = ThingGen.CreateTreasure("chest_treasure", thing5.LV);
957 i.TryPutShared(thing6);
958 thing5.Destroy();
959 WidgetPopText.Say("foundTreasure".lang(thing6.Name));
960 }
961 }
962 break;
963 }
964 }
965 }
966 int soilCost = EClass._zone.GetSoilCost();
967 int num = Mathf.Min(100, 70 + (MaxSoil - soilCost));
968 int flower = 5;
969 int lv = 1;
970 EClass._map.bounds.ForeachCell(delegate(Cell cell)
971 {
972 if (cell.obj != 0 && cell.sourceObj.tag.Contains("flower"))
973 {
974 PlantData plantData = cell.TryGetPlant();
975 if (plantData != null && plantData.seed != null)
976 {
977 lv += plantData.seed.encLV + 1;
978 }
979 else
980 {
981 lv++;
982 }
983 flower++;
984 }
985 });
986 lv /= flower;
987 int num2 = 0;
988 foreach (Thing thing7 in EClass._map.things)
989 {
990 if (thing7.IsInstalled && thing7.trait is TraitBeekeep && !thing7.things.IsFull())
991 {
992 flower -= 3 + EClass.rnd(5 + num2 * 4);
993 num2++;
994 if (flower < 0)
995 {
996 break;
997 }
998 if (EClass.rnd(100) <= num)
999 {
1000 Thing thing3 = ThingGen.Create("honey");
1001 thing3.SetEncLv(lv / 10);
1002 thing3.elements.SetBase(2, EClass.curve(lv, 50, 10, 80));
1003 thing7.AddThing(thing3);
1004 }
1005 }
1006 }
1007 }
1008
1009 public void PutInMailBox(Thing t, bool outside = false, bool install = true)
1010 {
1011 if (!outside)
1012 {
1013 Thing mailBox = GetMailBox();
1014 if (mailBox != null)
1015 {
1016 mailBox.AddCard(t);
1017 return;
1018 }
1019 }
1020 Point mailBoxPos = GetMailBoxPos();
1021 EClass._zone.AddCard(t, mailBoxPos);
1022 if (install)
1023 {
1024 t.Install();
1025 }
1026 }
1027
1029 {
1030 return EClass._map.props.installed.FindEmptyContainer<TraitMailPost>();
1031 }
1032
1034 {
1035 Thing thing = GetMailBox();
1036 if (thing == null)
1037 {
1039 }
1040 if (thing != null)
1041 {
1042 return thing.pos.GetNearestPoint(allowBlock: false, allowChara: true, allowInstalled: false, ignoreCenter: true).Clamp(useBounds: true);
1043 }
1044 return EClass._map.GetCenterPos();
1045 }
1046
1047 public int GetResidentTax()
1048 {
1049 if (!policies.IsActive(2512, 30))
1050 {
1051 return 0;
1052 }
1053 int num = 0;
1054 int num2 = (policies.IsActive(2500, 30) ? Evalue(2500) : 0);
1055 int num3 = (policies.IsActive(2501, 30) ? Evalue(2501) : 0);
1056 int num4 = 50 + (int)Mathf.Sqrt(Evalue(2512)) * 5;
1057 foreach (Chara member in members)
1058 {
1059 if (member.IsPC || member.memberType != 0)
1060 {
1061 continue;
1062 }
1063 bool isWealthy = member.IsWealthy;
1064 int num5 = 0;
1065 foreach (Hobby item in member.ListWorks().Concat(member.ListHobbies()))
1066 {
1067 int num6 = item.source.tax * 100 / 100;
1068 if (num6 > num5)
1069 {
1070 num5 = num6;
1071 }
1072 }
1073 int num7 = ((isWealthy ? 50 : 10) + member.LV * 2) * num5 / 100 * num4 / 100;
1074 if (isWealthy && num2 > 0)
1075 {
1076 num7 = num7 * (150 + (int)Mathf.Sqrt(num2) * 5) / 100;
1077 }
1078 if (num3 > 0)
1079 {
1080 num7 += (80 + (int)Mathf.Sqrt(num3) * 5) * member.faith.source.tax / 100;
1081 }
1082 num7 = num7 * efficiency / (IsTaxFree ? 100 : 1000);
1083 num += num7;
1084 if (num7 > 0)
1085 {
1086 Log("bTax", num7.ToString() ?? "", member.Name);
1087 }
1088 }
1089 statistics.tax += num;
1090 return num;
1091 }
1092
1093 public void CalcInnIncome()
1094 {
1095 int num = CountGuests();
1096 if (num == 0)
1097 {
1098 return;
1099 }
1100 int num2 = 0;
1101 int num3 = 0;
1102 foreach (Thing thing in EClass._map.things)
1103 {
1104 if (thing.IsInstalled && thing.trait is TraitBed traitBed && traitBed.owner.c_bedType == BedType.guest)
1105 {
1106 int maxHolders = traitBed.MaxHolders;
1107 num2 += maxHolders;
1108 num3 += traitBed.owner.LV * (100 + traitBed.owner.Quality / 2 + traitBed.owner.Evalue(750) / 2) / 100 * maxHolders;
1109 }
1110 }
1111 num = Mathf.Min(num, num2);
1112 if (num != 0)
1113 {
1114 num3 /= num2;
1115 num3 = num3 * (100 + 5 * (int)Mathf.Sqrt(Evalue(2812))) / 100;
1116 float num4 = 10f + Mathf.Sqrt(num) * 10f;
1117 if (policies.IsActive(2813))
1118 {
1119 num4 += Mathf.Sqrt(CountWealthyGuests()) * 50f * (80f + 5f * Mathf.Sqrt(Evalue(2813))) / 100f;
1120 }
1121 if (policies.IsActive(2812))
1122 {
1123 num4 = num4 * (float)(100 + num3) / 100f;
1124 }
1125 num4 = Mathf.Min(num4, Mathf.Sqrt(Worth) / 15f + 5f);
1126 incomeInn += EClass.rndHalf((int)num4) + EClass.rndHalf((int)num4);
1127 }
1128 }
1129
1130 public void CalcTourismIncome()
1131 {
1132 int num = CountGuests();
1133 if (num != 0)
1134 {
1135 float num2 = 10f + Mathf.Sqrt(num) * 10f;
1136 if (policies.IsActive(2815))
1137 {
1138 num2 += Mathf.Sqrt(CountWealthyGuests()) * 50f * (80f + 5f * Mathf.Sqrt(Evalue(2815))) / 100f;
1139 }
1140 num2 = Mathf.Min(num2, Mathf.Sqrt(tourism) / 5f);
1141 incomeTourism += EClass.rndHalf((int)num2) + EClass.rndHalf((int)num2);
1142 }
1143 }
1144
1145 public void GetDailyIncome()
1146 {
1147 GetIncome(ref incomeShop, ref statistics.shop, "getIncomeShop", tax: false);
1148 GetIncome(ref incomeInn, ref statistics.inn, "getIncomeInn", tax: true);
1149 GetIncome(ref incomeTourism, ref statistics.tourism, "getIncomeTourism", tax: true);
1150 void GetIncome(ref int n, ref int stat, string lang, bool tax)
1151 {
1152 if (tax && !IsTaxFree)
1153 {
1154 n = n * 10 / 100;
1155 }
1156 if (n != 0)
1157 {
1158 Msg.Say(lang, Lang._currency(n, "money"), owner.Name);
1159 Thing t = ThingGen.Create("money").SetNum(n);
1160 EClass.pc.Pick(t);
1161 stat += n;
1162 n = 0;
1163 }
1164 }
1165 }
1166
1168 {
1169 if (c.things.IsFull())
1170 {
1171 return null;
1172 }
1173 Thing thing = EClass._zone.TryGetThingFromSharedContainer((Thing t) => c.CanEat(t, shouldEat: true) && !t.c_isImportant);
1174 if (thing != null)
1175 {
1176 thing = thing.Split(1);
1177 }
1178 return thing;
1179 }
1180
1181 public void OnClaimZone()
1182 {
1184 {
1185 foreach (SourceElement.Row item in EClass.sources.elements.rows.Where((SourceElement.Row a) => a.category == "tech"))
1186 {
1187 elements.SetBase(item.id, 1);
1188 }
1189 foreach (SourceElement.Row item2 in EClass.sources.elements.rows.Where((SourceElement.Row a) => a.category == "policy" && !a.tag.Contains("hidden")))
1190 {
1191 policies.AddPolicy(item2.id);
1192 }
1193 }
1194 else
1195 {
1196 elements.SetBase(2003, 1);
1197 elements.SetBase(4002, 1);
1198 elements.SetBase(2115, 1);
1199 elements.SetBase(2204, 1);
1200 elements.SetBase(2120, 1);
1201 policies.AddPolicy(2512);
1202 policies.AddPolicy(2702);
1203 policies.AddPolicy(2703);
1204 policies.AddPolicy(2516);
1205 policies.AddPolicy(2515);
1206 policies.AddPolicy(2514);
1207 }
1209 {
1210 policies.Activate(2514);
1211 }
1212 Element element = EClass._zone.ListLandFeats()[0];
1213 elements.SetBase(element.id, 1);
1214 switch (element.id)
1215 {
1216 case 3604:
1217 elements.SetBase(2206, 10);
1218 break;
1219 case 3602:
1220 elements.SetBase(2206, 15);
1221 break;
1222 }
1223 if (EClass.game.StartZone == owner || owner is Zone_Vernis)
1224 {
1225 AddMemeber(EClass.pc);
1226 }
1228 {
1229 foreach (SourceElement.Row item3 in EClass.sources.elements.rows.Where((SourceElement.Row a) => a.category == "policy"))
1230 {
1231 policies.AddPolicy(item3.id);
1232 }
1233 }
1234 ValidateUpgradePolicies();
1235 }
1236
1237 public void OnUnclaimZone()
1238 {
1239 List<Element> source = owner.ListLandFeats();
1240 if (lv >= 5)
1241 {
1242 foreach (Element item in source.Where((Element a) => a.HasTag("network")).ToList())
1243 {
1245 }
1246 }
1247 Element[] array = elements.dict.Values.ToArray();
1248 foreach (Element element in array)
1249 {
1250 elements.SetBase(element.id, 0);
1251 }
1252 owner.landFeats = null;
1253 owner.ListLandFeats();
1254 owner.branch = null;
1255 }
1256
1258 {
1259 if (lv >= 2)
1260 {
1261 if (!policies.HasPolicy(2705))
1262 {
1263 policies.AddPolicy(2705);
1265 }
1266 if (!policies.HasPolicy(2708))
1267 {
1268 policies.AddPolicy(2708);
1270 }
1271 if (!policies.HasPolicy(2707))
1272 {
1273 policies.AddPolicy(2707);
1274 }
1275 if (!policies.HasPolicy(2709))
1276 {
1277 policies.AddPolicy(2709);
1278 }
1279 if (!policies.HasPolicy(2715))
1280 {
1281 policies.AddPolicy(2715);
1282 }
1283 }
1284 foreach (int globalPolicy in EClass.pc.faction.globalPolicies)
1285 {
1286 if (!policies.HasPolicy(globalPolicy))
1287 {
1288 policies.AddPolicy(globalPolicy, show: false);
1290 }
1291 }
1292 }
1293
1294 public void Upgrade()
1295 {
1296 List<Element> list = owner.ListLandFeats();
1297 if (owner.IsActiveZone)
1298 {
1299 TraitCoreZone traitCoreZone = EClass._map.FindThing<TraitCoreZone>();
1300 if (traitCoreZone != null)
1301 {
1302 SE.Play("godbless");
1303 traitCoreZone.owner.PlayEffect("aura_heaven");
1304 }
1305 }
1306 lv++;
1307 exp = 0;
1308 int admin = 4;
1309 int food = 4;
1310 Set(4, 3);
1311 switch (list[0].id)
1312 {
1313 case 3500:
1314 Set(5, 3);
1315 break;
1316 case 3604:
1317 Set(4, 3);
1318 break;
1319 case 3600:
1320 Set(5, 3);
1321 break;
1322 case 3601:
1323 Set(4, 4);
1324 break;
1325 case 3603:
1326 Set(6, 2);
1327 break;
1328 case 3602:
1329 Set(5, 2);
1330 break;
1331 }
1332 elements.SetBase(2003, Mathf.Min((lv - 1) * 2 + 1, 10));
1333 elements.SetBase(2115, (lv - 1) * admin + 1);
1334 elements.SetBase(2204, (lv - 1) * food + 1);
1335 elements.GetElement(2003).CheckLevelBonus(elements);
1336 ValidateUpgradePolicies();
1337 if (lv == 4)
1338 {
1339 elements.SetBase(list[1].id, 1);
1340 }
1341 if (lv == 7)
1342 {
1343 elements.SetBase(list[2].id, 1);
1344 }
1345 if (lv >= 5)
1346 {
1347 List<Element> list2 = elements.dict.Values.Where((Element a) => a.source.category == "landfeat" && a.HasTag("network")).ToList();
1348 foreach (Element item in list2)
1349 {
1351 }
1352 foreach (Element item2 in list2)
1353 {
1354 elements.Remove(item2.id);
1355 }
1356 }
1357 Msg.Say("upgrade_hearth", lv.ToString() ?? "", owner.Name);
1358 LogRaw("upgrade_hearth".langGame(lv.ToString() ?? "", owner.Name), "Good");
1359 Tutorial.Reserve("stone");
1360 void Set(int a, int f)
1361 {
1362 admin = a;
1363 food = f;
1364 }
1365 }
1366
1367 public bool CanUpgrade()
1368 {
1369 if (lv < MaxLv)
1370 {
1371 if (exp < GetNextExp())
1372 {
1373 return EClass.debug.enable;
1374 }
1375 return true;
1376 }
1377 return false;
1378 }
1379
1380 public int GetUpgradeCost()
1381 {
1382 return lv * lv * lv * 1000;
1383 }
1384
1385 public void ModExp(int a)
1386 {
1387 if (policies.IsActive(2515))
1388 {
1389 return;
1390 }
1391 if (policies.IsActive(2516))
1392 {
1393 a = a * 150 / 100 + EClass.rnd(2);
1394 }
1395 exp += a;
1396 if (exp >= GetNextExp() && CanUpgrade())
1397 {
1398 if (EClass.core.version.demo && lv >= 3)
1399 {
1400 exp = 0;
1401 Msg.Say("demoLimit2");
1402 }
1403 else
1404 {
1405 Upgrade();
1406 }
1407 }
1408 }
1409
1410 public string GetHearthHint(int a)
1411 {
1412 if (a <= 1)
1413 {
1414 return "hearth1".lang();
1415 }
1416 string text = "";
1417 for (int i = 1; i < a; i++)
1418 {
1419 string text2 = ("hearth" + (i + 1)).lang();
1420 if (!text2.IsEmpty())
1421 {
1422 text = text + text2 + Environment.NewLine;
1423 }
1424 }
1425 return text.TrimEnd(Environment.NewLine.ToCharArray());
1426 }
1427
1428 public void AddFeat(int ele, int v)
1429 {
1430 elements.ModBase(ele, v);
1431 WidgetPopText.Say("rewardElement".lang(EClass.sources.elements.map[ele].GetName()));
1432 }
1433
1434 public void AddMemeber(Chara c)
1435 {
1436 if (members.Contains(c))
1437 {
1438 return;
1439 }
1442 c.SetGlobal();
1444 c.SetHomeZone(owner);
1445 foreach (Thing item in c.things.List((Thing a) => a.HasTag(CTAG.godArtifact)).Copy())
1446 {
1448 }
1449 if (c.OriginalHostility <= Hostility.Ally)
1450 {
1451 c.c_originalHostility = Hostility.Ally;
1452 }
1453 c.hostility = Hostility.Ally;
1454 c.enemy = null;
1455 c.orgPos = null;
1456 if (c.memberType != 0 && c.memberType != FactionMemberType.Livestock)
1457 {
1458 c.memberType = FactionMemberType.Default;
1459 }
1460 if (c.hp > c.MaxHP)
1461 {
1462 c.hp = c.MaxHP;
1463 }
1464 if (c.mana.value > c.mana.max)
1465 {
1466 c.mana.value = c.mana.max;
1467 }
1468 if (c.stamina.value > c.stamina.max)
1469 {
1470 c.stamina.value = c.stamina.max;
1471 }
1472 members.Add(c);
1474 RefreshEfficiency();
1475 c.RefreshWorkElements(elements);
1476 if (uidMaid == 0 && c.id == "maid")
1477 {
1478 uidMaid = c.uid;
1479 }
1480 }
1481
1483 {
1484 c.ClearBed();
1485 c.memberType = type;
1486 c.c_wasInPcParty = false;
1487 RefreshEfficiency();
1488 c.RefreshWorkElements(elements);
1489 policies.Validate();
1490 }
1491
1492 public void BanishMember(Chara c, bool skipMsg = false)
1493 {
1494 RemoveMemeber(c);
1495 if (!skipMsg)
1496 {
1497 Msg.Say("banish", c, EClass._zone.Name);
1498 }
1499 if (c.IsGlobal)
1500 {
1501 c.OnBanish();
1502 }
1503 else
1504 {
1505 c.Destroy();
1506 }
1507 }
1508
1509 public void RemoveMemeber(Chara c)
1510 {
1511 c.isSale = false;
1512 if (c.currentZone != null && c.currentZone.map != null)
1513 {
1515 c.currentZone.map.props.sales.Remove(c);
1516 }
1518 c.RemoveGlobal();
1519 members.Remove(c);
1522 policies.Validate();
1523 RefreshEfficiency();
1524 }
1525
1527 {
1528 float num = 0f;
1529 if (members.Count == 0)
1530 {
1531 return 0;
1532 }
1533 foreach (Chara member in members)
1534 {
1535 num += (float)member.happiness;
1536 }
1537 return (int)(num / (float)members.Count);
1538 }
1539
1540 public bool IsAllDead()
1541 {
1542 foreach (Chara member in members)
1543 {
1544 if (!member.isDead)
1545 {
1546 return false;
1547 }
1548 }
1549 return true;
1550 }
1551
1552 public void Recruit(Chara c)
1553 {
1554 RemoveRecruit(c);
1555 AddMemeber(c);
1556 c.isRestrained = false;
1557 if (c.currentZone != EClass._zone && !c.isDead)
1558 {
1560 EClass._zone.AddCard(c, point);
1561 }
1562 RefreshEfficiency();
1564 Msg.Say("hire".langGame(c.Name));
1565 }
1566
1568 {
1569 foreach (Chara member in members)
1570 {
1571 if (member.IsAliveInCurrentZone && member.IsMaid)
1572 {
1573 return member;
1574 }
1575 }
1576 return null;
1577 }
1578
1579 public string GetRandomName()
1580 {
1581 if (EClass.rnd(4) == 0 || members.Count == 0)
1582 {
1583 return EClass.player.title;
1584 }
1585 return members.RandomItem().Name;
1586 }
1587
1588 public int CountMembers(FactionMemberType type, bool onlyAlive = false)
1589 {
1590 int num = 0;
1591 foreach (Chara member in members)
1592 {
1593 if (member.memberType == type && (!onlyAlive || !member.isDead) && (type != 0 || member.trait.IsCountAsResident))
1594 {
1595 num++;
1596 }
1597 }
1598 return num;
1599 }
1600
1601 public int CountGuests()
1602 {
1603 int num = 0;
1604 foreach (Chara chara in EClass._map.charas)
1605 {
1606 if (chara.memberType == FactionMemberType.Guest)
1607 {
1608 num++;
1609 }
1610 }
1611 return num;
1612 }
1613
1615 {
1616 int num = 0;
1617 foreach (Chara chara in EClass._map.charas)
1618 {
1619 if (chara.memberType == FactionMemberType.Guest && chara.IsWealthy)
1620 {
1621 num++;
1622 }
1623 }
1624 return num;
1625 }
1626
1627 public void UpdateReqruits(bool clear = false)
1628 {
1629 resources.Refresh();
1630 if (clear)
1631 {
1632 listRecruit.ForeachReverse(delegate(HireInfo i)
1633 {
1634 if (!i.chara.IsGlobal)
1635 {
1636 i.chara.Destroy();
1637 }
1638 if (i.chara.isDestroyed)
1639 {
1640 listRecruit.Remove(i);
1641 }
1642 });
1643 listRecruit.Clear();
1644 lastUpdateReqruit = -1;
1645 }
1646 else
1647 {
1648 listRecruit.ForeachReverse(delegate(HireInfo i)
1649 {
1650 if (i.Hours < 0)
1651 {
1652 if (!i.chara.IsGlobal)
1653 {
1654 i.chara.Destroy();
1655 }
1656 listRecruit.Remove(i);
1657 }
1658 });
1659 }
1660 if (lastUpdateReqruit == EClass.world.date.day)
1661 {
1662 return;
1663 }
1664 lastUpdateReqruit = EClass.world.date.day;
1665 int num = 2 + (int)Mathf.Sqrt(Evalue(2513)) / 2;
1666 int num2 = EClass.rnd(3 + (int)Mathf.Sqrt(Evalue(2513)) / 2) + num - listRecruit.Count;
1667 if (num2 <= 0)
1668 {
1669 return;
1670 }
1671 new List<Chara>(EClass.game.cards.globalCharas.Values).Shuffle();
1672 for (int j = 0; j < num2; j++)
1673 {
1674 Chara chara = CharaGen.CreateFromFilter("c_neutral", ContentLV + Mathf.Min(EClass.player.stats.days, 10));
1675 if (chara.isBackerContent || chara.source.quality != 0)
1676 {
1677 j--;
1678 }
1679 else
1680 {
1681 AddRecruit(chara);
1682 }
1683 }
1685 {
1687 }
1688 }
1689
1690 public void AddRecruit(Chara c)
1691 {
1692 HireInfo hireInfo = new HireInfo
1693 {
1694 chara = c,
1695 isNew = true
1696 };
1697 hireInfo.deadline = EClass.world.date.GetRaw() + (EClass.rnd(5) + 1) * 1440 + EClass.rnd(24) * 60;
1698 listRecruit.Add(hireInfo);
1699 }
1700
1701 public void RemoveRecruit(Chara c)
1702 {
1703 listRecruit.ForeachReverse(delegate(HireInfo i)
1704 {
1705 if (i.chara == c)
1706 {
1707 listRecruit.Remove(i);
1708 }
1709 });
1710 }
1711
1712 public int CountNewRecruits()
1713 {
1714 int num = 0;
1715 foreach (HireInfo item in listRecruit)
1716 {
1717 if (item.isNew)
1718 {
1719 num++;
1720 }
1721 }
1722 return num;
1723 }
1724
1725 public void ClearNewRecruits()
1726 {
1727 foreach (HireInfo item in listRecruit)
1728 {
1729 item.isNew = false;
1730 }
1731 }
1732
1733 public bool IsRecruit(Chara c)
1734 {
1735 foreach (HireInfo item in listRecruit)
1736 {
1737 if (item.chara == c)
1738 {
1739 return true;
1740 }
1741 }
1742 return false;
1743 }
1744
1745 public int CountPasture()
1746 {
1747 return EClass._map.Stocked.GetNum("pasture", onlyShared: true) + EClass._map.Installed.GetNum("pasture");
1748 }
1749
1750 public int GetPastureCost()
1751 {
1752 return CountMembers(FactionMemberType.Livestock);
1753 }
1754
1755 public int GetCivility()
1756 {
1757 int num = 10 + Evalue(2203);
1758 if (Evalue(2701) > 0)
1759 {
1760 num += 10 + (int)Mathf.Sqrt(Evalue(2701));
1761 }
1762 if (Evalue(2702) > 0)
1763 {
1764 num -= 10 + (int)Mathf.Sqrt(Evalue(2702));
1765 }
1766 return num;
1767 }
1768
1769 public float GetHearthIncome()
1770 {
1771 float num = 0f;
1772 foreach (Element value in elements.dict.Values)
1773 {
1774 if (value.source.category == "culture")
1775 {
1776 num += GetHearthIncome(value.source.alias);
1777 }
1778 }
1779 return num;
1780 }
1781
1782 public float GetHearthIncome(string id)
1783 {
1784 int num = 0;
1785 foreach (KeyValuePair<int, Element> item in elements.dict)
1786 {
1787 if (item.Value.source.aliasParent == id)
1788 {
1789 num++;
1790 }
1791 }
1792 return 0.2f * (float)num;
1793 }
1794
1796 {
1797 int valueWithoutLink = e.ValueWithoutLink;
1798 valueWithoutLink += e.CostLearn;
1799 if (e.source.max != 0 && e.ValueWithoutLink >= e.source.max)
1800 {
1801 return 0;
1802 }
1803 return valueWithoutLink;
1804 }
1805
1806 public string Log(string idLang, string ref1 = null, string ref2 = null, string ref3 = null, string ref4 = null)
1807 {
1808 Msg.alwaysVisible = true;
1809 return LogRaw(Msg.GetRawText(idLang, ref1, ref2, ref3, ref4), EClass.sources.langGame.map[idLang].logColor);
1810 }
1811
1812 public string Log(string idLang, Card c1, Card c2, string ref1 = null, string ref2 = null)
1813 {
1814 Msg.alwaysVisible = true;
1815 return LogRaw(Msg.GetRawText(idLang, c1, c2, ref1, ref2), EClass.sources.langGame.map[idLang].logColor);
1816 }
1817
1818 public string Log(string idLang, Card c1, string ref1 = null, string ref2 = null, string ref3 = null)
1819 {
1820 Msg.alwaysVisible = true;
1821 return LogRaw(Msg.GetRawText(idLang, c1, ref1, ref2, ref3), EClass.sources.langGame.map[idLang].logColor);
1822 }
1823
1824 public string LogRaw(string text, string col = null)
1825 {
1826 log.Add(text, col.IsEmpty() ? null : col);
1827 Msg.alwaysVisible = false;
1828 Msg.SetColor();
1829 return text;
1830 }
1831}
BedType
Definition: BedType.cs:2
BlessedState
Definition: BlessedState.cs:2
CTAG
Definition: CTAG.cs:2
@ tourism
CureType
Definition: CureType.cs:2
FactionMemberType
Hostility
Definition: Hostility.cs:2
ID_DLC
Definition: ID_DLC.cs:2
SpawnPosition
Definition: SpawnPosition.cs:2
if(item3.idFile==idFirstFile &&item3.id==idFirstTopic)
Definition: UIBook.cs:627
list. Add(item3)
static Thing GetThingToClean(Chara c=null)
Definition: AI_Haul.cs:34
static void Pray(Chara c, bool silent=false)
Definition: AI_Pray.cs:52
static bool TryRestock(Chara c, bool realtime)
Definition: AI_Shopping.cs:94
static bool TryShop(Chara c, bool realtime)
Definition: AI_Shopping.cs:10
void Add(Act a, string s="")
Definition: ActPlan.cs:11
int GetInt(int id, int? defaultInt=null)
Definition: BaseCard.cs:25
void SetInt(int id, int value=0)
Definition: BaseCard.cs:39
Version version
Definition: BaseCore.cs:17
GlobalCharaList globalCharas
Definition: CardManager.cs:46
List< Thing > listPackage
Definition: CardManager.cs:61
Definition: Card.cs:11
void SetTier(int a, bool setTraits=true)
Definition: Card.cs:3761
bool isDestroyed
Definition: Card.cs:73
Thing TryMakeRandomItem(int lv=-1, TryMakeRandomItemSource itemSource=TryMakeRandomItemSource.Default, Chara crafter=null)
Definition: Card.cs:5204
void PurgeDuplicateArtifact(Thing af)
Definition: Card.cs:3175
bool IsAmmo
Definition: Card.cs:2209
Thing Split(int a)
Definition: Card.cs:3382
ElementContainerCard elements
Definition: Card.cs:39
bool c_wasInPcParty
Definition: Card.cs:986
string id
Definition: Card.cs:33
bool IsUnique
Definition: Card.cs:2053
bool HasElement(int ele, int req=1)
Definition: Card.cs:5638
bool isRestrained
Definition: Card.cs:552
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:5852
Card ChangeMaterial(int idNew, bool ignoreFixedMaterial=false)
Definition: Card.cs:2994
Card AddCard(Card c)
Definition: Card.cs:3043
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:3057
int hp
Definition: Card.cs:228
string Name
Definition: Card.cs:2099
bool ExistsOnMap
Definition: Card.cs:2047
bool c_isPrayed
Definition: Card.cs:1046
Thing SetNum(int a)
Definition: Card.cs:3393
virtual void SetBlessedState(BlessedState s)
Definition: Card.cs:3787
bool HasTag(CTAG tag)
Definition: Card.cs:2557
Point pos
Definition: Card.cs:57
int uid
Definition: Card.cs:120
Effect PlayEffect(string id, bool useRenderPos=true, float range=0f, Vector3 fix=default(Vector3))
Definition: Card.cs:5886
Trait trait
Definition: Card.cs:51
int c_allowance
Definition: Card.cs:1291
Thing MakeMilk(bool effect=true, int num=1, bool addToZone=true, BlessedState? state=null)
Definition: Card.cs:5491
void SetEncLv(int a)
Definition: Card.cs:3756
void Destroy()
Definition: Card.cs:4850
bool c_isImportant
Definition: Card.cs:998
bool noMove
Definition: Card.cs:756
bool HaveFur()
Definition: Card.cs:7520
ThingContainer things
Definition: Card.cs:36
bool IsInstalled
Definition: Card.cs:2343
int c_daysWithPC
Definition: Card.cs:1459
BedType c_bedType
Definition: Card.cs:914
void MoveImmediate(Point p, bool focus=true, bool cancelAI=true)
Definition: Card.cs:5551
Card Install()
Definition: Card.cs:3633
int Num
Definition: Card.cs:156
SourceCategory.Row category
Definition: Card.cs:2011
void ModNum(int a, bool notify=true)
Definition: Card.cs:3413
int c_fur
Definition: Card.cs:1303
int LV
Definition: Card.cs:372
bool isBackerContent
Definition: Card.cs:899
string c_idRefCard
Definition: Card.cs:1711
Thing MakeEgg(bool effect=true, int num=1, bool addToZone=true, int fertChance=20, BlessedState? state=null)
Definition: Card.cs:5475
void RemoveThings()
Definition: Card.cs:3208
Definition: Cell.cs:7
bool HasBlock
Definition: Cell.cs:643
byte obj
Definition: Cell.cs:38
SourceObj.Row sourceObj
Definition: Cell.cs:1072
bool hasDoor
Definition: Cell.cs:258
static Chara CreateWealthy(int lv=-1)
Definition: CharaGen.cs:53
static Chara CreateFromFilter(string id, int lv=-1, int levelRange=-1)
Definition: CharaGen.cs:22
Definition: Chara.cs:10
void SetHomeZone(Zone zone)
Definition: Chara.cs:1408
override bool IsAliveInCurrentZone
Definition: Chara.cs:559
new TraitChara trait
Definition: Chara.cs:501
Hostility OriginalHostility
Definition: Chara.cs:469
void RemoveGlobal()
Definition: Chara.cs:1472
void SetFaction(Faction f)
Definition: Chara.cs:1401
bool IsWealthy
Definition: Chara.cs:1041
bool CanRevive()
Definition: Chara.cs:4896
void TryPutShared(Thing t, List< Thing > containers=null, bool dropIfFail=true)
Definition: Chara.cs:4321
void CureHost(CureType type, int p=100, BlessedState state=BlessedState.Normal)
Definition: Chara.cs:9042
void RefreshWorkElements(ElementContainer parent=null)
Definition: Chara.cs:8579
Faction faction
Definition: Chara.cs:425
override bool IsPC
Definition: Chara.cs:610
bool IsMaid
Definition: Chara.cs:1013
override bool IsGlobal
Definition: Chara.cs:608
override bool IsPCParty
Definition: Chara.cs:613
Party party
Definition: Chara.cs:43
TraitBed TryAssignBed()
Definition: Chara.cs:7013
bool HasCondition(string alias)
Definition: Chara.cs:8976
int happiness
Definition: Chara.cs:108
Chara SetGlobal(Zone _home, int x, int z)
Definition: Chara.cs:1444
void OnBanish()
Definition: Chara.cs:1414
bool CanEat(Thing t, bool shouldEat=false)
Definition: Chara.cs:7258
override int MaxHP
Definition: Chara.cs:706
Zone currentZone
Definition: Chara.cs:253
override bool IsDeadOrSleeping
Definition: Chara.cs:571
List< Hobby > ListHobbies(bool useMemberType=true)
Definition: Chara.cs:8540
SourceChara.Row source
Definition: Chara.cs:156
Stats mana
Definition: Chara.cs:1136
FactionMemberType memberType
Definition: Chara.cs:46
Stats stamina
Definition: Chara.cs:1128
List< Hobby > ListWorks(bool useMemberType=true)
Definition: Chara.cs:8513
void Revive(Point p=null, bool msg=false)
Definition: Chara.cs:4922
Zone homeZone
Definition: Chara.cs:265
Hobby GetWork(string id)
Definition: Chara.cs:8560
Religion faith
Definition: Chara.cs:437
void ClearBed(Map map=null)
Definition: Chara.cs:6986
FactionBranch homeBranch
Definition: Chara.cs:1052
bool isDead
Definition: Chara.cs:387
Thing Pick(Thing t, bool msg=true, bool tryStack=true)
Definition: Chara.cs:4187
SourceRace.Row race
Definition: Chara.cs:462
bool allPolicy
Definition: CoreDebug.cs:237
bool allHomeSkill
Definition: CoreDebug.cs:195
bool enable
Definition: CoreDebug.cs:286
static void MakeDish(Thing food, int lv, Chara crafter=null)
Definition: CraftUtil.cs:61
int GetRaw(int offsetHours=0)
Definition: Date.cs:322
int day
Definition: Date.cs:62
bool IsNight
Definition: Date.cs:112
Definition: EClass.cs:5
static Game game
Definition: EClass.cs:8
static Scene scene
Definition: EClass.cs:30
static Faction Home
Definition: EClass.cs:26
static int curve(int a, int start, int step, int rate=75)
Definition: EClass.cs:68
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 int rnd(long a)
Definition: EClass.cs:58
static SourceManager sources
Definition: EClass.cs:42
static int rndHalf(int a)
Definition: EClass.cs:87
static Player player
Definition: EClass.cs:12
static Chara pc
Definition: EClass.cs:14
static CoreDebug debug
Definition: EClass.cs:48
int Value(int ele)
Element ModBase(int ele, int v)
Element SetBase(string alias, int v, int potential=0)
int ValueWithoutLink
Definition: ELEMENT.cs:292
int id
Definition: ELEMENT.cs:248
SourceElement.Row source
Definition: ELEMENT.cs:271
bool HasTag(string tag)
Definition: ELEMENT.cs:471
virtual int CostLearn
Definition: ELEMENT.cs:312
int GetRoadDist(int gx, int gy)
Definition: EloMap.cs:466
void SetOwner(FactionBranch _branch)
MeetingManager meetings
string GetRandomName()
int GetProductBonus(Chara c)
void OnAfterSimulate()
string Log(string idLang, Card c1, Card c2, string ref1=null, string ref2=null)
void AddRecruit(Chara c)
ExpeditionManager expeditions
Thing GetMailBox()
void RefreshEfficiency()
void DailyOutcome(VirtualDate date)
Thing GetMeal(Chara c)
HappinessManager happiness
string Log(string idLang, Card c1, string ref1=null, string ref2=null, string ref3=null)
void RemoveRecruit(Chara c)
void OnSimulateMonth(VirtualDate date)
int CountNewRecruits()
int CountMembers(FactionMemberType type, bool onlyAlive=false)
void OnActivateZone()
void ChangeMemberType(Chara c, FactionMemberType type)
void AddFeat(int ele, int v)
void CalcInnIncome()
GStability stability
Point GetMailBoxPos()
int Evalue(int ele)
void OnCreate(Zone zone)
void ModExp(int a)
bool IsRecruit(Chara c)
void ClearNewRecruits()
bool TryTrash(Thing t)
Statistics lastStatistics
ResearchManager researches
Religion faith
string GetHearthHint(int a)
float GetHearthIncome()
Statistics statistics
void OnUnclaimZone()
int GetTechUpgradeCost(Element e)
void OnSimulateDay(VirtualDate date)
int GetNextExp(int _lv=-1)
float GetHearthIncome(string id)
void CalcTourismIncome()
List< Chara > members
void GenerateGarbage(VirtualDate date)
void RemoveMemeber(Chara c)
void SetOwner(Zone zone)
void UpdateReqruits(bool clear=false)
void OnSimulateHour(VirtualDate date)
void OnAdvanceDay()
List< HireInfo > listRecruit
int CountWealthyGuests()
string LogRaw(string text, string col=null)
void Recruit(Chara c)
void PutInMailBox(Thing t, bool outside=false, bool install=true)
PolicyManager policies
void OnUnloadMap()
void ReceivePackages(VirtualDate date)
string Log(string idLang, string ref1=null, string ref2=null, string ref3=null, string ref4=null)
bool HasItemProtection
HomeResourceManager resources
int GetHappiness(FactionMemberType type)
ElementContainerZone elements
void GetDailyIncome()
void BanishMember(Chara c, bool skipMsg=false)
void AddMemeber(Chara c)
void ValidateUpgradePolicies()
new Faction Wilds
FactionBranch FindBranch(Chara c)
Definition: FACTION.cs:425
ElementContainerFaction charaElements
Definition: FACTION.cs:146
bool IsGlobalPolicyActive(int id)
Definition: FACTION.cs:442
int CountTaxFreeLand()
Definition: FACTION.cs:550
ElementContainerZone elements
Definition: FACTION.cs:141
HashSet< int > globalPolicies
Definition: FACTION.cs:144
void RemoveReserve(Chara c)
Definition: FACTION.cs:357
void SetGlobalPolicyActive(int id, bool active)
Definition: FACTION.cs:455
bool isLoading
Definition: Game.cs:238
SurvivalManager survival
Definition: Game.cs:224
ReligionManager religions
Definition: Game.cs:158
CardManager cards
Definition: Game.cs:155
bool IsSurvival
Definition: Game.cs:272
FactionManager factions
Definition: Game.cs:161
Zone StartZone
Definition: Game.cs:274
void SetOwner(FactionBranch _owner)
Chara chara
Definition: HireInfo.cs:6
int Hours
Definition: HireInfo.cs:26
Definition: Hobby.cs:5
SourceHobby.Row source
Definition: Hobby.cs:8
int GetEfficiency(Chara c)
Definition: Hobby.cs:31
int GetLv(Chara c)
Definition: Hobby.cs:22
void SetOwner(FactionBranch _owner)
HomeResourceWorth worth
Definition: Lang.cs:6
static string _currency(object a, string IDCurrency)
Definition: Lang.cs:162
Definition: Log.cs:4
void ForeachCell(Action< Cell > action)
Definition: MapBounds.cs:279
Point GetRandomSurface(int x, int z, int radius, bool walkable=true, bool allowWater=false)
Definition: MapBounds.cs:182
int Width
Definition: MapBounds.cs:26
Point GetCenterPos()
Definition: MapBounds.cs:52
int Height
Definition: MapBounds.cs:28
Point GetRandomPoint()
Definition: MapBounds.cs:97
Thing FindThing(Func< Thing, bool > func)
Definition: Map.cs:2592
PropsInstalled Installed
Definition: Map.cs:123
void SetDecal(int x, int z, int id=0, int amount=1, bool refresh=true)
Definition: Map.cs:2051
int CountHostile()
Definition: Map.cs:2467
List< Thing > things
Definition: Map.cs:49
int CountGuest()
Definition: Map.cs:2454
PropsManager props
Definition: Map.cs:91
int CountWildAnimal()
Definition: Map.cs:2480
PropsStocked Stocked
Definition: Map.cs:121
List< Chara > charas
Definition: Map.cs:81
MapBounds bounds
Definition: Map.cs:52
void OnSimulateHour(VirtualDate date)
void SetOwner(FactionBranch _branch)
Definition: MsgLog.cs:7
void Add(Data data)
Definition: MsgLog.cs:53
Definition: Msg.cs:5
static string GetRawText(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:37
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:58
static void SetColor()
Definition: Msg.cs:22
void AddMemeber(Chara c, bool showMsg=false)
Definition: Party.cs:56
bool elinGift
Definition: Player.cs:374
int days
Definition: Player.cs:75
Flags flags
Definition: Player.cs:1014
Stats stats
Definition: Player.cs:936
string title
Definition: Player.cs:924
bool simulatingZone
Definition: Player.cs:1099
Definition: Point.cs:9
bool HasDecal
Definition: Point.cs:139
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
Point Clamp(bool useBounds=false)
Definition: Point.cs:992
bool IsInBounds
Definition: Point.cs:104
Cell cell
Definition: Point.cs:51
Thing FindThing(Func< Thing, bool > func)
Definition: Point.cs:1124
Point GetRandomPoint(int radius, bool requireLos=true, bool allowChara=true, bool allowBlocked=false, int tries=100)
Definition: Point.cs:757
int GetValue(int id)
void Activate(int id)
void AddPolicy(string id)
bool HasPolicy(int id)
bool IsActive(int id, int days=-1)
void OnSimulateHour(VirtualDate date)
void SetOwner(FactionBranch _owner)
PropsInstalled installed
Definition: PropsManager.cs:8
List< Card > sales
Definition: PropsManager.cs:14
TraitManager traits
Definition: Props.cs:18
Thing Find(int uid)
Definition: Props.cs:389
int GetNum(string id, bool onlyShared=false)
Definition: Props.cs:427
ReligionEyth Eyth
ReligionLuck Luck
bool IsEyth
Definition: Religion.cs:44
SourceReligion.Row source
Definition: Religion.cs:32
virtual string id
Definition: Religion.cs:26
void SetOwner(FactionBranch _branch)
EloMap elomap
Definition: Scene.cs:149
LangGame langGame
SourceElement elements
virtual string Name
Definition: Spatial.cs:497
Faction mainFaction
Definition: Spatial.cs:430
int y
Definition: Spatial.cs:106
int x
Definition: Spatial.cs:94
static SpawnSetting HomeWild(int lv)
Definition: SpawnSetting.cs:91
static SpawnSetting HomeEnemy(int lv)
static SpawnSetting HomeGuest(int lv)
virtual int value
Definition: Stats.cs:56
virtual int max
Definition: Stats.cs:68
Definition: Steam.cs:8
static bool HasDLC(ID_DLC id)
Definition: Steam.cs:39
void OnUpdateRecruit(FactionBranch branch)
List< Thing > List(Func< Thing, bool > func, bool onlyAccessible=false)
Thing Find(int uid)
bool IsFull(int y=0)
static Thing CreateTreasure(string id, int lv, TreasureType type=TreasureType.Map)
Definition: ThingGen.cs:233
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 Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
Definition: Thing.cs:8
virtual bool IsCountAsResident
Definition: TraitChara.cs:67
static Chara Incubate(Thing egg, Point pos, Card incubator=null)
TraitSet GetTraitSet(Type t)
Definition: TraitManager.cs:94
virtual int CraftNum
Definition: Trait.cs:132
Point GetPoint()
Definition: Trait.cs:725
Card owner
Definition: Trait.cs:27
virtual bool CanStack
Definition: Trait.cs:150
static void Reserve(string idStep, Action onBeforePlay=null)
Definition: Tutorial.cs:55
BranchMap GetBranchMap()
Definition: VirtualDate.cs:44
bool IsRealTime
Definition: VirtualDate.cs:7
static void Say(string text, FontColor fontColor=FontColor.Default, Sprite sprite=null)
GameDate date
Definition: World.cs:6
void SendPackage(Thing p)
Definition: World.cs:68
Definition: Zone.cs:12
List< Chara > ListMinions(Chara c)
Definition: Zone.cs:3562
Thing TryGetThingFromSharedContainer(Func< Thing, bool > func)
Definition: Zone.cs:2203
ElementContainerZone elements
Definition: Zone.cs:43
Chara SpawnMob(Point pos=null, SpawnSetting setting=null)
Definition: Zone.cs:2691
MapBounds bounds
Definition: Zone.cs:46
bool TryAddThingInSharedContainer(Thing t, List< Thing > containers=null, bool add=true, bool msg=false, Chara chara=null, bool sharedOnly=true)
Definition: Zone.cs:2080
bool TryAddThing(Thing target, Point p, bool destroyIfFail=false)
Definition: Zone.cs:2177
bool IsActiveZone
Definition: Zone.cs:492
List< Element > ListLandFeats()
Definition: Zone.cs:2989
int GetSoilCost()
Definition: Zone.cs:3588
Card AddCard(Card t, Point point)
Definition: Zone.cs:1937
Map map
Definition: Zone.cs:60
Point GetSpawnPos(Chara c, ZoneTransition.EnterState destState=ZoneTransition.EnterState.Auto)
Definition: Zone.cs:1323
bool demo
Definition: Version.cs:14