Elin Decompiled Documentation EA 23.153 Nightly
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 meal.Destroy();
344 }
345 else
346 {
347 c.hunger.Mod(-50);
348 }
349 }
350 }
351 }
352 });
353 expeditions.OnSimulateHour();
354 meetings.OnSimulateHour(date);
355 policies.OnSimulateHour(date);
356 int num2 = Evalue(3707);
357 int num3 = Evalue(3705) + Evalue(3710) * 2;
358 int num4 = 4 + num3 * 4;
359 int num5 = Mathf.Max(1, (100 + Evalue(2205) * 5 + Evalue(3703) * 100 - num2 * 80) / 10);
360 int num6 = 10;
361 if (policies.IsActive(2709))
362 {
363 num6 = 0;
364 }
366 {
367 num5 /= 2;
368 }
369 if ((date.IsRealTime || num2 > 0) && !EClass.debug.enable && EClass.rnd(num5) == 0 && !EClass.pc.IsDeadOrSleeping && EClass._map.CountHostile() < num4)
370 {
371 int num7 = 1 + EClass.rnd(num2 + num3 + 1);
372 for (int i = 0; i < num7; i++)
373 {
374 EClass._zone.SpawnMob(null, SpawnSetting.HomeEnemy(DangerLV));
375 }
376 }
377 if ((date.IsRealTime || num2 == 0) && num6 != 0 && EClass.rnd(num6) == 0 && EClass._map.CountWildAnimal() < num4)
378 {
380 }
381 if (EClass.rnd(5) == 0 && policies.IsActive(2810))
382 {
383 int num8 = 3 + lv + Evalue(2206) / 5 + Evalue(3702) * 2 + Evalue(2202) / 2;
384 num8 = num8 * (100 + Evalue(3702) * 20 + Evalue(2206)) / 100;
385 num8 = num8 * (100 + (int)Mathf.Sqrt(Evalue(2811)) * 3) / 100;
386 if (luckyMonth)
387 {
388 num8 = num8 * 2 + 5;
389 }
390 if (EClass._map.CountGuest() < num8)
391 {
392 Chara chara;
393 if (luckyMonth || (policies.IsActive(2822) && Mathf.Sqrt(Evalue(2822) / 2) + 5f >= (float)EClass.rnd(100)))
394 {
395 chara = CharaGen.CreateWealthy(ContentLV);
397 }
398 else
399 {
400 chara = EClass._zone.SpawnMob(null, SpawnSetting.HomeGuest(ContentLV));
401 }
402 if (chara != null && (chara.id == "nun_mother" || chara.id == "prostitute") && policies.IsActive(2710))
403 {
404 chara.Destroy();
405 chara = null;
406 }
407 if (chara != null)
408 {
409 statistics.visitor++;
410 chara.memberType = FactionMemberType.Guest;
411 chara.SetInt(34, EClass.world.date.GetRaw());
412 chara.c_allowance = chara.LV * 100;
413 if (chara.IsWealthy)
414 {
415 chara.c_allowance *= 10;
416 }
417 if (date.IsRealTime)
418 {
419 Msg.Say("guestArrive", chara.Name);
420 }
421 else
422 {
423 chara.TryAssignBed();
424 }
425 }
426 }
427 }
428 foreach (Chara chara3 in EClass._map.charas)
429 {
430 if (chara3.memberType != FactionMemberType.Guest || ((chara3.c_allowance > 0 || EClass.rnd(2) != 0) && chara3.GetInt(34) + 10080 >= EClass.world.date.GetRaw()))
431 {
432 continue;
433 }
434 foreach (Chara item in EClass._zone.ListMinions(chara3))
435 {
436 item.Destroy();
437 }
438 if (!chara3.IsGlobal)
439 {
440 chara3.Destroy();
441 }
442 chara3.ClearBed();
443 break;
444 }
445 if (date.hour == 5)
446 {
447 for (int j = 0; j < ((!luckyMonth) ? 1 : 2); j++)
448 {
449 DailyOutcome(date);
450 }
451 GenerateGarbage(date);
452 if (!date.IsRealTime)
453 {
454 AutoClean();
455 }
456 CalcTourismIncome();
457 CalcInnIncome();
458 if (date.IsRealTime)
459 {
460 GetDailyIncome();
461 }
462 }
463 if (!EClass.player.simulatingZone && date.hour == 6)
464 {
465 ReceivePackages(date);
466 }
467 if (!date.IsRealTime && date.hour % 8 == 0)
468 {
469 foreach (Chara item2 in EClass._map.charas.Where((Chara c) => c.memberType == FactionMemberType.Guest).ToList())
470 {
471 for (int k = 0; k < 3; k++)
472 {
473 AI_Shopping.TryShop(item2, realtime: false);
474 }
475 }
476 AI_Shopping.TryRestock(EClass.pc, realtime: false);
477 }
478 if (EClass.rnd(24) == 0 || EClass.debug.enable)
479 {
480 foreach (Thing thing in EClass._map.things)
481 {
482 if (EClass.rnd(20) == 0 && thing.trait is TraitFoodEggFertilized && thing.pos.FindThing<TraitBed>() != null)
483 {
484 Chara chara2 = TraitFoodEggFertilized.Incubate(thing, thing.pos);
485 thing.ModNum(-1);
486 if (date.IsRealTime)
487 {
488 chara2.PlaySound("egg");
489 }
490 break;
491 }
492 }
493 }
494 resources.SetDirty();
495 }
496
497 public void AutoClean()
498 {
499 foreach (Chara member in members)
500 {
501 if (member.IsPCParty || !member.ExistsOnMap || member.memberType != 0)
502 {
503 continue;
504 }
505 Hobby hobby = member.GetWork("Clean") ?? member.GetWork("Chore");
506 if (hobby == null)
507 {
508 continue;
509 }
510 int num = (5 + EClass.rnd(5)) * hobby.GetEfficiency(member) / 100;
511 for (int i = 0; i < num; i++)
512 {
513 Thing thingToClean = AI_Haul.GetThingToClean(member);
514 if (thingToClean == null)
515 {
516 break;
517 }
519 }
520 }
521 }
522
523 public void OnSimulateDay(VirtualDate date)
524 {
525 if (owner == null || owner.mainFaction != EClass.Home)
526 {
527 return;
528 }
529 researches.OnSimulateDay();
530 resources.OnSimulateDay();
531 happiness.OnSimulateDay();
532 if (!date.IsRealTime)
533 {
534 BranchMap branchMap = date.GetBranchMap();
535 foreach (Chara member in members)
536 {
537 if (!member.IsPCParty && member.memberType != FactionMemberType.Livestock && !member.faith.IsEyth && !member.c_isPrayed && branchMap.altarMap.Contains(member.faith.id))
538 {
539 AI_Pray.Pray(member, silent: true);
540 }
541 }
542 }
543 foreach (Chara member2 in members)
544 {
545 member2.c_isPrayed = false;
546 member2.c_isTrained = false;
547 }
548 if (date.day != 1)
549 {
550 return;
551 }
552 luckyMonth = false;
553 if (date.month == 1)
554 {
555 luckyMonthDone = false;
556 }
557 if (!luckyMonthDone)
558 {
559 bool flag = EClass.pc.faith == EClass.game.religions.Luck;
560 luckyMonth = (float)(flag ? 30 : 5) + Mathf.Sqrt(Evalue(2118)) * (float)(flag ? 4 : 2) > (float)EClass.rnd(720);
561 if (EClass.debug.enable)
562 {
563 luckyMonth = true;
564 }
565 if (luckyMonth)
566 {
567 Log("lucky_month", EClass._zone.Name);
568 Msg.Say("lucky_month", EClass._zone.Name);
569 Msg.Say("umi");
570 SE.Play("godbless");
571 EClass.world.SendPackage(ThingGen.Create("book_kumiromi"));
572 luckyMonthDone = true;
573 }
574 }
575 }
576
577 public void OnAdvanceDay()
578 {
579 int num = 0;
580 foreach (Chara member in members)
581 {
582 if (member.IsPC || member.isDead)
583 {
584 continue;
585 }
586 if (member.IsPCParty || member.currentZone == EClass.pc.currentZone)
587 {
588 member.c_daysWithPC++;
589 }
590 if (member.memberType == FactionMemberType.Default)
591 {
592 if (EClass.rnd(3) == 0)
593 {
594 num++;
595 }
596 if (member.GetWork("Pioneer") != null)
597 {
598 num += 3;
599 }
600 }
601 }
602 ModExp(num);
603 }
604
605 public void OnSimulateMonth(VirtualDate date)
606 {
607 lastStatistics = statistics;
608 statistics = new Statistics();
609 }
610
611 public void GenerateGarbage(VirtualDate date)
612 {
613 int sortChance = 40 + GetCivility();
614 int unsortedCount = 0;
615 foreach (Chara member in members)
616 {
617 if (!member.IsPCParty && member.ExistsOnMap)
618 {
619 Hobby hobby = member.GetWork("Clean") ?? member.GetWork("Chore");
620 if (hobby != null)
621 {
622 sortChance += 20 * hobby.GetEfficiency(member) / 100;
623 }
624 }
625 }
626 int num = Evalue(2702);
627 int num2 = EClass.rnd(2);
628 for (int i = 0; i < num2; i++)
629 {
630 if (num == 0 || EClass.rnd(num + (EClass.debug.enable ? 100000 : 10)) == 0)
631 {
632 Generate(null);
633 }
634 }
635 foreach (Chara member2 in members)
636 {
637 if (!member2.IsPCParty && member2.ExistsOnMap && (num == 0 || EClass.rnd(num + (EClass.debug.enable ? 100000 : 10)) == 0))
638 {
639 Generate(member2);
640 }
641 }
642 void Generate(Chara c)
643 {
644 if (c == null || EClass.rnd(5) == 0)
645 {
646 if (EClass.rnd(80) == 0)
647 {
649 }
650 else if (EClass.rnd(40) == 0)
651 {
652 Thing thing;
653 Add(thing = ThingGen.CreateFromTag("garbage"));
654 }
655 else
656 {
657 string id = "trash2";
658 if (EClass.rnd(3) == 0)
659 {
660 id = "trash1";
661 }
662 if (EClass.rnd(10) == 0)
663 {
664 id = ((EClass.rnd(3) == 0) ? "529" : "1170");
665 }
666 if (c != null && (!c.IsUnique || c.memberType == FactionMemberType.Livestock) && EClass.rnd((c.memberType == FactionMemberType.Livestock) ? 2 : 50) == 0)
667 {
668 id = "_poop";
669 }
670 if (EClass.rnd(200000) == 0)
671 {
672 id = "goodness";
673 }
674 Add(ThingGen.Create(id));
675 }
676 }
677 void Add(Thing t)
678 {
679 if (sortChance < EClass.rnd(100))
680 {
681 EClass._zone.TryAddThing(t, (c != null) ? (c.pos.GetRandomPoint(2) ?? c.pos).GetNearestPoint() : EClass._zone.bounds.GetRandomSurface(), destroyIfFail: true);
682 }
683 else
684 {
685 if (t.id == "_poop" && EClass.rnd(150) == 0)
686 {
687 t.ChangeMaterial((EClass.rnd(2) == 0) ? "silver" : "gold");
688 }
689 if (!TryTrash(t))
690 {
691 unsortedCount++;
692 if (unsortedCount >= 5)
693 {
694 Tutorial.Reserve("garbage");
695 }
696 }
697 }
698 }
699 }
700 }
701
702 public bool TryTrash(Thing t)
703 {
704 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)));
705 if (thing != null)
706 {
707 thing.AddCard(t);
708 return true;
709 }
710 return EClass._zone.TryAddThingInSpot<TraitSpotGarbage>(t, useContainer: false);
711 }
712
713 public void ReceivePackages(VirtualDate date)
714 {
716 {
717 return;
718 }
719 List<Thing> listPackage = EClass.game.cards.listPackage;
720 if (EClass.player.stats.days >= 2 && !EClass.player.flags.elinGift && Steam.HasDLC(ID_DLC.BackerReward))
721 {
722 listPackage.Add(ThingGen.Create("gift"));
723 EClass.player.flags.elinGift = true;
724 }
725 if (listPackage.Count == 0)
726 {
727 return;
728 }
729 SE.Play("notice");
730 int num = 0;
731 foreach (Thing item in listPackage)
732 {
733 if (item.id != "bill")
734 {
735 num++;
736 }
737 PutInMailBox(item, item.id == "cardboard_box" || item.id == "gift");
738 WidgetPopText.Say("popDeliver".lang(item.Name));
739 }
740 Msg.Say("deliver_arrive", num.ToString() ?? "");
741 listPackage.Clear();
742 }
743
744 public void DailyOutcome(VirtualDate date)
745 {
746 Thing thing = null;
747 foreach (Chara member in members)
748 {
749 Chara i = member;
750 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())
751 {
752 Thing thing2 = ThingGen.Create("panty");
753 thing2.c_idRefCard = i.id;
754 i.AddThing(thing2);
755 }
756 if (i.IsPCParty || !i.ExistsOnMap)
757 {
758 continue;
759 }
760 i.RefreshWorkElements(elements);
761 if (i.memberType == FactionMemberType.Livestock)
762 {
763 if (thing == null)
764 {
765 thing = EClass._map.Stocked.Find("pasture", -1, -1, shared: true) ?? EClass._map.Installed.Find("pasture");
766 }
767 if (thing == null)
768 {
769 continue;
770 }
771 if (i.race.breeder >= EClass.rnd(2500 - (int)Mathf.Sqrt(Evalue(2827) * 100)))
772 {
773 if (EClass.rnd(3) != 0)
774 {
775 Thing t2 = i.MakeEgg(date.IsRealTime, 1, date.IsRealTime);
776 if (!date.IsRealTime)
777 {
778 i.TryPutShared(t2);
779 }
780 }
781 else
782 {
783 Thing t3 = i.MakeMilk(date.IsRealTime, 1, date.IsRealTime);
784 if (!date.IsRealTime)
785 {
786 i.TryPutShared(t3);
787 }
788 }
789 }
790 if (i.HaveFur())
791 {
792 if (i.HasElement(1533))
793 {
794 i.c_fur = 0;
795 }
796 else
797 {
798 i.c_fur++;
799 if (EClass.rnd(4) == 0 && i.HasElement(1532))
800 {
801 i.c_fur++;
802 }
803 }
804 }
805 thing.ModNum(-1);
806 if (thing.isDestroyed || thing.Num == 0)
807 {
808 thing = null;
809 }
810 continue;
811 }
812 foreach (Hobby item in i.ListHobbies())
813 {
814 GetOutcome(item);
815 }
816 foreach (Hobby item2 in i.ListWorks())
817 {
818 GetOutcome(item2);
819 }
820 void GetOutcome(Hobby h)
821 {
822 int num3 = h.GetEfficiency(i) * GetProductBonus(i) / 100;
823 int num4 = h.GetLv(i);
824 int id = EClass.sources.elements.alias[h.source.skill].id;
825 if (!i.elements.HasBase(id))
826 {
827 i.elements.SetBase(id, 1);
828 }
829 i.ModExp(id, 100);
830 for (int j = 0; j < h.source.things.Length; j += 2)
831 {
832 string text = h.source.things[j];
833 int num5 = Mathf.Max(1, h.source.things[j + 1].ToInt() * num3 / 1000);
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 }
889 }
890 if (flag)
891 {
892 TryTrash(thing4);
893 }
894 else
895 {
896 i.TryPutShared(thing4);
897 }
898 }
899 }
900 }
901 else
902 {
903 i.MakeEgg(date.IsRealTime, num6);
904 }
905 }
906 }
907 switch (h.source.alias)
908 {
909 case "Nurse":
910 {
911 foreach (Chara member2 in members)
912 {
913 if (!member2.IsPCParty)
914 {
915 if (member2.isDead && member2.CanRevive() && EClass.rnd(num3) > EClass.rnd(100))
916 {
917 Log("bNurse", i, member2);
918 member2.Revive(member2.pos, msg: true);
919 if (date.IsRealTime && member2.c_wasInPcParty)
920 {
921 EClass.pc.party.AddMemeber(member2, showMsg: true);
922 }
923 break;
924 }
925 if (EClass.rnd(num3) > EClass.rnd(100))
926 {
927 member2.CureHost(CureType.HealComplete);
928 }
929 }
930 }
931 break;
932 }
933 case "Chore":
934 case "Clean":
935 {
936 for (int k = 0; k < num3 / 2; k++)
937 {
938 Point randomPoint = EClass._map.bounds.GetRandomPoint();
939 if (randomPoint.HasDecal)
940 {
941 EClass._map.SetDecal(randomPoint.x, randomPoint.z);
942 }
943 }
944 break;
945 }
946 case "TreasureHunt":
947 if (EClass.rnd(num3) > EClass.rnd(EClass.debug.enable ? 100 : 5000))
948 {
950 if (thing5 != null)
951 {
952 Thing thing6 = ThingGen.CreateTreasure("chest_treasure", thing5.LV);
953 i.TryPutShared(thing6);
954 thing5.Destroy();
955 WidgetPopText.Say("foundTreasure".lang(thing6.Name));
956 }
957 }
958 break;
959 }
960 }
961 }
962 int soilCost = EClass._zone.GetSoilCost();
963 int num = Mathf.Min(100, 70 + (MaxSoil - soilCost));
964 int flower = 5;
965 int lv = 1;
966 EClass._map.bounds.ForeachCell(delegate(Cell cell)
967 {
968 if (cell.obj != 0 && cell.sourceObj.tag.Contains("flower"))
969 {
970 PlantData plantData = cell.TryGetPlant();
971 if (plantData != null && plantData.seed != null)
972 {
973 lv += plantData.seed.encLV + 1;
974 }
975 else
976 {
977 lv++;
978 }
979 flower++;
980 }
981 });
982 lv /= flower;
983 int num2 = 0;
984 foreach (Thing thing7 in EClass._map.things)
985 {
986 if (thing7.IsInstalled && thing7.trait is TraitBeekeep && !thing7.things.IsFull())
987 {
988 flower -= 3 + EClass.rnd(5 + num2 * 4);
989 num2++;
990 if (flower < 0)
991 {
992 break;
993 }
994 if (EClass.rnd(100) <= num)
995 {
996 Thing thing3 = ThingGen.Create("honey");
997 thing3.SetEncLv(lv / 10);
998 thing3.elements.SetBase(2, EClass.curve(lv, 50, 10, 80));
999 thing7.AddThing(thing3);
1000 }
1001 }
1002 }
1003 }
1004
1005 public void PutInMailBox(Thing t, bool outside = false, bool install = true)
1006 {
1007 if (!outside)
1008 {
1009 Thing mailBox = GetMailBox();
1010 if (mailBox != null)
1011 {
1012 mailBox.AddCard(t);
1013 return;
1014 }
1015 }
1016 Point mailBoxPos = GetMailBoxPos();
1017 EClass._zone.AddCard(t, mailBoxPos);
1018 if (install)
1019 {
1020 t.Install();
1021 }
1022 }
1023
1025 {
1026 return EClass._map.props.installed.FindEmptyContainer<TraitMailPost>();
1027 }
1028
1030 {
1031 Thing thing = GetMailBox();
1032 if (thing == null)
1033 {
1035 }
1036 if (thing != null)
1037 {
1038 return thing.pos.GetNearestPoint(allowBlock: false, allowChara: true, allowInstalled: false, ignoreCenter: true).Clamp(useBounds: true);
1039 }
1040 return EClass._map.GetCenterPos();
1041 }
1042
1043 public int GetResidentTax()
1044 {
1045 if (!policies.IsActive(2512, 30))
1046 {
1047 return 0;
1048 }
1049 int num = 0;
1050 int num2 = (policies.IsActive(2500, 30) ? Evalue(2500) : 0);
1051 int num3 = (policies.IsActive(2501, 30) ? Evalue(2501) : 0);
1052 int num4 = 50 + (int)Mathf.Sqrt(Evalue(2512)) * 5;
1053 foreach (Chara member in members)
1054 {
1055 if (member.IsPC || member.memberType != 0)
1056 {
1057 continue;
1058 }
1059 bool isWealthy = member.IsWealthy;
1060 int num5 = 0;
1061 foreach (Hobby item in member.ListWorks().Concat(member.ListHobbies()))
1062 {
1063 int num6 = item.source.tax * 100 / 100;
1064 if (num6 > num5)
1065 {
1066 num5 = num6;
1067 }
1068 }
1069 int num7 = ((isWealthy ? 50 : 10) + member.LV * 2) * num5 / 100 * num4 / 100;
1070 if (isWealthy && num2 > 0)
1071 {
1072 num7 = num7 * (150 + (int)Mathf.Sqrt(num2) * 5) / 100;
1073 }
1074 if (num3 > 0)
1075 {
1076 num7 += (80 + (int)Mathf.Sqrt(num3) * 5) * member.faith.source.tax / 100;
1077 }
1078 num7 = num7 * efficiency / (IsTaxFree ? 100 : 1000);
1079 num += num7;
1080 if (num7 > 0)
1081 {
1082 Log("bTax", num7.ToString() ?? "", member.Name);
1083 }
1084 }
1085 statistics.tax += num;
1086 return num;
1087 }
1088
1089 public void CalcInnIncome()
1090 {
1091 int num = CountGuests();
1092 if (num == 0)
1093 {
1094 return;
1095 }
1096 int num2 = 0;
1097 int num3 = 0;
1098 foreach (Thing thing in EClass._map.things)
1099 {
1100 if (thing.IsInstalled && thing.trait is TraitBed traitBed && traitBed.owner.c_bedType == BedType.guest)
1101 {
1102 int maxHolders = traitBed.MaxHolders;
1103 num2 += maxHolders;
1104 num3 += traitBed.owner.LV * (100 + traitBed.owner.Quality / 2 + traitBed.owner.Evalue(750) / 2) / 100 * maxHolders;
1105 }
1106 }
1107 num = Mathf.Min(num, num2);
1108 if (num != 0)
1109 {
1110 num3 /= num2;
1111 num3 = num3 * (100 + 5 * (int)Mathf.Sqrt(Evalue(2812))) / 100;
1112 float num4 = 10f + Mathf.Sqrt(num) * 10f;
1113 if (policies.IsActive(2813))
1114 {
1115 num4 += Mathf.Sqrt(CountWealthyGuests()) * 50f * (80f + 5f * Mathf.Sqrt(Evalue(2813))) / 100f;
1116 }
1117 if (policies.IsActive(2812))
1118 {
1119 num4 = num4 * (float)(100 + num3) / 100f;
1120 }
1121 num4 = Mathf.Min(num4, Mathf.Sqrt(Worth) / 15f + 5f);
1122 incomeInn += EClass.rndHalf((int)num4) + EClass.rndHalf((int)num4);
1123 }
1124 }
1125
1126 public void CalcTourismIncome()
1127 {
1128 int num = CountGuests();
1129 if (num != 0)
1130 {
1131 float num2 = 10f + Mathf.Sqrt(num) * 10f;
1132 if (policies.IsActive(2815))
1133 {
1134 num2 += Mathf.Sqrt(CountWealthyGuests()) * 50f * (80f + 5f * Mathf.Sqrt(Evalue(2815))) / 100f;
1135 }
1136 num2 = Mathf.Min(num2, Mathf.Sqrt(tourism) / 5f);
1137 incomeTourism += EClass.rndHalf((int)num2) + EClass.rndHalf((int)num2);
1138 }
1139 }
1140
1141 public void GetDailyIncome()
1142 {
1143 GetIncome(ref incomeShop, ref statistics.shop, "getIncomeShop", tax: false);
1144 GetIncome(ref incomeInn, ref statistics.inn, "getIncomeInn", tax: true);
1145 GetIncome(ref incomeTourism, ref statistics.tourism, "getIncomeTourism", tax: true);
1146 void GetIncome(ref int n, ref int stat, string lang, bool tax)
1147 {
1148 if (tax && !IsTaxFree)
1149 {
1150 n = n * 10 / 100;
1151 }
1152 if (n != 0)
1153 {
1154 Msg.Say(lang, Lang._currency(n, "money"), owner.Name);
1155 Thing t = ThingGen.Create("money").SetNum(n);
1156 EClass.pc.Pick(t);
1157 stat += n;
1158 n = 0;
1159 }
1160 }
1161 }
1162
1164 {
1165 if (c.things.IsFull())
1166 {
1167 return null;
1168 }
1169 Thing thing = EClass._zone.TryGetThingFromSharedContainer((Thing t) => c.CanEat(t, shouldEat: true) && !t.c_isImportant);
1170 if (thing != null)
1171 {
1172 thing = thing.Split(1);
1173 }
1174 return thing;
1175 }
1176
1177 public void OnClaimZone()
1178 {
1180 {
1181 foreach (SourceElement.Row item in EClass.sources.elements.rows.Where((SourceElement.Row a) => a.category == "tech"))
1182 {
1183 elements.SetBase(item.id, 1);
1184 }
1185 foreach (SourceElement.Row item2 in EClass.sources.elements.rows.Where((SourceElement.Row a) => a.category == "policy" && !a.tag.Contains("hidden")))
1186 {
1187 policies.AddPolicy(item2.id);
1188 }
1189 }
1190 else
1191 {
1192 elements.SetBase(2003, 1);
1193 elements.SetBase(4002, 1);
1194 elements.SetBase(2115, 1);
1195 elements.SetBase(2204, 1);
1196 elements.SetBase(2120, 1);
1197 policies.AddPolicy(2512);
1198 policies.AddPolicy(2702);
1199 policies.AddPolicy(2703);
1200 policies.AddPolicy(2516);
1201 policies.AddPolicy(2515);
1202 policies.AddPolicy(2514);
1203 }
1205 {
1206 policies.Activate(2514);
1207 }
1208 Element element = EClass._zone.ListLandFeats()[0];
1209 elements.SetBase(element.id, 1);
1210 switch (element.id)
1211 {
1212 case 3604:
1213 elements.SetBase(2206, 10);
1214 break;
1215 case 3602:
1216 elements.SetBase(2206, 15);
1217 break;
1218 }
1219 if (EClass.game.StartZone == owner || owner is Zone_Vernis)
1220 {
1221 AddMemeber(EClass.pc);
1222 }
1224 {
1225 foreach (SourceElement.Row item3 in EClass.sources.elements.rows.Where((SourceElement.Row a) => a.category == "policy"))
1226 {
1227 policies.AddPolicy(item3.id);
1228 }
1229 }
1230 ValidateUpgradePolicies();
1231 }
1232
1233 public void OnUnclaimZone()
1234 {
1235 List<Element> source = owner.ListLandFeats();
1236 if (lv >= 5)
1237 {
1238 foreach (Element item in source.Where((Element a) => a.HasTag("network")).ToList())
1239 {
1241 }
1242 }
1243 Element[] array = elements.dict.Values.ToArray();
1244 foreach (Element element in array)
1245 {
1246 elements.SetBase(element.id, 0);
1247 }
1248 owner.landFeats = null;
1249 owner.ListLandFeats();
1250 }
1251
1253 {
1254 if (lv >= 2)
1255 {
1256 if (!policies.HasPolicy(2705))
1257 {
1258 policies.AddPolicy(2705);
1260 }
1261 if (!policies.HasPolicy(2708))
1262 {
1263 policies.AddPolicy(2708);
1265 }
1266 if (!policies.HasPolicy(2707))
1267 {
1268 policies.AddPolicy(2707);
1269 }
1270 if (!policies.HasPolicy(2709))
1271 {
1272 policies.AddPolicy(2709);
1273 }
1274 if (!policies.HasPolicy(2715))
1275 {
1276 policies.AddPolicy(2715);
1277 }
1278 }
1279 foreach (int globalPolicy in EClass.pc.faction.globalPolicies)
1280 {
1281 if (!policies.HasPolicy(globalPolicy))
1282 {
1283 policies.AddPolicy(globalPolicy, show: false);
1285 }
1286 }
1287 }
1288
1289 public void Upgrade()
1290 {
1291 List<Element> list = owner.ListLandFeats();
1292 if (owner.IsActiveZone)
1293 {
1294 TraitCoreZone traitCoreZone = EClass._map.FindThing<TraitCoreZone>();
1295 if (traitCoreZone != null)
1296 {
1297 SE.Play("godbless");
1298 traitCoreZone.owner.PlayEffect("aura_heaven");
1299 }
1300 }
1301 lv++;
1302 exp = 0;
1303 int admin = 4;
1304 int food = 4;
1305 Set(4, 3);
1306 switch (list[0].id)
1307 {
1308 case 3500:
1309 Set(5, 3);
1310 break;
1311 case 3604:
1312 Set(4, 3);
1313 break;
1314 case 3600:
1315 Set(5, 3);
1316 break;
1317 case 3601:
1318 Set(4, 4);
1319 break;
1320 case 3603:
1321 Set(6, 2);
1322 break;
1323 case 3602:
1324 Set(5, 2);
1325 break;
1326 }
1327 elements.SetBase(2003, Mathf.Min((lv - 1) * 2 + 1, 10));
1328 elements.SetBase(2115, (lv - 1) * admin + 1);
1329 elements.SetBase(2204, (lv - 1) * food + 1);
1330 elements.GetElement(2003).CheckLevelBonus(elements);
1331 ValidateUpgradePolicies();
1332 if (lv == 4)
1333 {
1334 elements.SetBase(list[1].id, 1);
1335 }
1336 if (lv == 7)
1337 {
1338 elements.SetBase(list[2].id, 1);
1339 }
1340 if (lv >= 5)
1341 {
1342 List<Element> list2 = elements.dict.Values.Where((Element a) => a.source.category == "landfeat" && a.HasTag("network")).ToList();
1343 foreach (Element item in list2)
1344 {
1346 }
1347 foreach (Element item2 in list2)
1348 {
1349 elements.Remove(item2.id);
1350 }
1351 }
1352 Msg.Say("upgrade_hearth", lv.ToString() ?? "", owner.Name);
1353 LogRaw("upgrade_hearth".langGame(lv.ToString() ?? "", owner.Name), "Good");
1354 Tutorial.Reserve("stone");
1355 void Set(int a, int f)
1356 {
1357 admin = a;
1358 food = f;
1359 }
1360 }
1361
1362 public bool CanUpgrade()
1363 {
1364 if (lv < MaxLv)
1365 {
1366 if (exp < GetNextExp())
1367 {
1368 return EClass.debug.enable;
1369 }
1370 return true;
1371 }
1372 return false;
1373 }
1374
1375 public int GetUpgradeCost()
1376 {
1377 return lv * lv * lv * 1000;
1378 }
1379
1380 public void ModExp(int a)
1381 {
1382 if (policies.IsActive(2515))
1383 {
1384 return;
1385 }
1386 if (policies.IsActive(2516))
1387 {
1388 a = a * 150 / 100 + EClass.rnd(2);
1389 }
1390 exp += a;
1391 if (exp >= GetNextExp() && CanUpgrade())
1392 {
1393 if (EClass.core.version.demo && lv >= 3)
1394 {
1395 exp = 0;
1396 Msg.Say("demoLimit2");
1397 }
1398 else
1399 {
1400 Upgrade();
1401 }
1402 }
1403 }
1404
1405 public string GetHearthHint(int a)
1406 {
1407 if (a <= 1)
1408 {
1409 return "hearth1".lang();
1410 }
1411 string text = "";
1412 for (int i = 1; i < a; i++)
1413 {
1414 string text2 = ("hearth" + (i + 1)).lang();
1415 if (!text2.IsEmpty())
1416 {
1417 text = text + text2 + Environment.NewLine;
1418 }
1419 }
1420 return text.TrimEnd(Environment.NewLine.ToCharArray());
1421 }
1422
1423 public void AddFeat(int ele, int v)
1424 {
1425 elements.ModBase(ele, v);
1426 WidgetPopText.Say("rewardElement".lang(EClass.sources.elements.map[ele].GetName()));
1427 }
1428
1429 public void AddMemeber(Chara c)
1430 {
1431 if (members.Contains(c))
1432 {
1433 return;
1434 }
1437 c.SetGlobal();
1439 c.SetHomeZone(owner);
1440 foreach (Thing item in c.things.List((Thing a) => a.HasTag(CTAG.godArtifact)).Copy())
1441 {
1443 }
1444 if (c.OriginalHostility <= Hostility.Ally)
1445 {
1446 c.c_originalHostility = Hostility.Ally;
1447 }
1448 c.hostility = Hostility.Ally;
1449 c.enemy = null;
1450 c.orgPos = null;
1451 if (c.memberType != 0 && c.memberType != FactionMemberType.Livestock)
1452 {
1453 c.memberType = FactionMemberType.Default;
1454 }
1455 if (c.hp > c.MaxHP)
1456 {
1457 c.hp = c.MaxHP;
1458 }
1459 if (c.mana.value > c.mana.max)
1460 {
1461 c.mana.value = c.mana.max;
1462 }
1463 if (c.stamina.value > c.stamina.max)
1464 {
1465 c.stamina.value = c.stamina.max;
1466 }
1467 members.Add(c);
1469 RefreshEfficiency();
1470 c.RefreshWorkElements(elements);
1471 if (uidMaid == 0 && c.id == "maid")
1472 {
1473 uidMaid = c.uid;
1474 }
1475 }
1476
1478 {
1479 c.ClearBed();
1480 c.memberType = type;
1481 c.c_wasInPcParty = false;
1482 RefreshEfficiency();
1483 c.RefreshWorkElements(elements);
1484 policies.Validate();
1485 }
1486
1487 public void BanishMember(Chara c, bool skipMsg = false)
1488 {
1489 RemoveMemeber(c);
1490 if (!skipMsg)
1491 {
1492 Msg.Say("banish", c, EClass._zone.Name);
1493 }
1494 if (c.IsGlobal)
1495 {
1496 c.OnBanish();
1497 }
1498 else
1499 {
1500 c.Destroy();
1501 }
1502 }
1503
1504 public void RemoveMemeber(Chara c)
1505 {
1506 c.isSale = false;
1507 if (c.currentZone != null && c.currentZone.map != null)
1508 {
1510 c.currentZone.map.props.sales.Remove(c);
1511 }
1513 c.RemoveGlobal();
1514 members.Remove(c);
1517 policies.Validate();
1518 RefreshEfficiency();
1519 }
1520
1522 {
1523 float num = 0f;
1524 if (members.Count == 0)
1525 {
1526 return 0;
1527 }
1528 foreach (Chara member in members)
1529 {
1530 num += (float)member.happiness;
1531 }
1532 return (int)(num / (float)members.Count);
1533 }
1534
1535 public bool IsAllDead()
1536 {
1537 foreach (Chara member in members)
1538 {
1539 if (!member.isDead)
1540 {
1541 return false;
1542 }
1543 }
1544 return true;
1545 }
1546
1547 public void Recruit(Chara c)
1548 {
1549 RemoveRecruit(c);
1550 AddMemeber(c);
1551 c.isRestrained = false;
1552 if (c.currentZone != EClass._zone && !c.isDead)
1553 {
1555 EClass._zone.AddCard(c, point);
1556 }
1557 RefreshEfficiency();
1559 Msg.Say("hire".langGame(c.Name));
1560 }
1561
1563 {
1564 foreach (Chara member in members)
1565 {
1566 if (member.IsAliveInCurrentZone && member.IsMaid)
1567 {
1568 return member;
1569 }
1570 }
1571 return null;
1572 }
1573
1574 public string GetRandomName()
1575 {
1576 if (EClass.rnd(4) == 0 || members.Count == 0)
1577 {
1578 return EClass.player.title;
1579 }
1580 return members.RandomItem().Name;
1581 }
1582
1583 public int CountMembers(FactionMemberType type, bool onlyAlive = false)
1584 {
1585 int num = 0;
1586 foreach (Chara member in members)
1587 {
1588 if (member.memberType == type && (!onlyAlive || !member.isDead) && (type != 0 || member.trait.IsCountAsResident))
1589 {
1590 num++;
1591 }
1592 }
1593 return num;
1594 }
1595
1596 public int CountGuests()
1597 {
1598 int num = 0;
1599 foreach (Chara chara in EClass._map.charas)
1600 {
1601 if (chara.memberType == FactionMemberType.Guest)
1602 {
1603 num++;
1604 }
1605 }
1606 return num;
1607 }
1608
1610 {
1611 int num = 0;
1612 foreach (Chara chara in EClass._map.charas)
1613 {
1614 if (chara.memberType == FactionMemberType.Guest && chara.IsWealthy)
1615 {
1616 num++;
1617 }
1618 }
1619 return num;
1620 }
1621
1622 public void UpdateReqruits(bool clear = false)
1623 {
1624 resources.Refresh();
1625 if (clear)
1626 {
1627 listRecruit.ForeachReverse(delegate(HireInfo i)
1628 {
1629 if (!i.chara.IsGlobal)
1630 {
1631 i.chara.Destroy();
1632 }
1633 if (i.chara.isDestroyed)
1634 {
1635 listRecruit.Remove(i);
1636 }
1637 });
1638 listRecruit.Clear();
1639 lastUpdateReqruit = -1;
1640 }
1641 else
1642 {
1643 listRecruit.ForeachReverse(delegate(HireInfo i)
1644 {
1645 if (i.Hours < 0)
1646 {
1647 if (!i.chara.IsGlobal)
1648 {
1649 i.chara.Destroy();
1650 }
1651 listRecruit.Remove(i);
1652 }
1653 });
1654 }
1655 if (lastUpdateReqruit == EClass.world.date.day)
1656 {
1657 return;
1658 }
1659 lastUpdateReqruit = EClass.world.date.day;
1660 int num = 2 + (int)Mathf.Sqrt(Evalue(2513)) / 2;
1661 int num2 = EClass.rnd(3 + (int)Mathf.Sqrt(Evalue(2513)) / 2) + num - listRecruit.Count;
1662 if (num2 <= 0)
1663 {
1664 return;
1665 }
1666 new List<Chara>(EClass.game.cards.globalCharas.Values).Shuffle();
1667 for (int j = 0; j < num2; j++)
1668 {
1669 Chara chara = CharaGen.CreateFromFilter("c_neutral", ContentLV + Mathf.Min(EClass.player.stats.days, 10));
1670 if (chara.isBackerContent || chara.source.quality != 0)
1671 {
1672 j--;
1673 }
1674 else
1675 {
1676 AddRecruit(chara);
1677 }
1678 }
1679 }
1680
1681 public void AddRecruit(Chara c)
1682 {
1683 HireInfo hireInfo = new HireInfo
1684 {
1685 chara = c,
1686 isNew = true
1687 };
1688 hireInfo.deadline = EClass.world.date.GetRaw() + (EClass.rnd(5) + 1) * 1440 + EClass.rnd(24) * 60;
1689 listRecruit.Add(hireInfo);
1690 }
1691
1692 public void RemoveRecruit(Chara c)
1693 {
1694 listRecruit.ForeachReverse(delegate(HireInfo i)
1695 {
1696 if (i.chara == c)
1697 {
1698 listRecruit.Remove(i);
1699 }
1700 });
1701 }
1702
1703 public int CountNewRecruits()
1704 {
1705 int num = 0;
1706 foreach (HireInfo item in listRecruit)
1707 {
1708 if (item.isNew)
1709 {
1710 num++;
1711 }
1712 }
1713 return num;
1714 }
1715
1716 public void ClearNewRecruits()
1717 {
1718 foreach (HireInfo item in listRecruit)
1719 {
1720 item.isNew = false;
1721 }
1722 }
1723
1724 public bool IsRecruit(Chara c)
1725 {
1726 foreach (HireInfo item in listRecruit)
1727 {
1728 if (item.chara == c)
1729 {
1730 return true;
1731 }
1732 }
1733 return false;
1734 }
1735
1736 public int CountPasture()
1737 {
1738 return EClass._map.Stocked.GetNum("pasture", onlyShared: true) + EClass._map.Installed.GetNum("pasture");
1739 }
1740
1741 public int GetPastureCost()
1742 {
1743 return CountMembers(FactionMemberType.Livestock);
1744 }
1745
1746 public int GetCivility()
1747 {
1748 int num = 10 + Evalue(2203);
1749 if (Evalue(2701) > 0)
1750 {
1751 num += 10 + (int)Mathf.Sqrt(Evalue(2701));
1752 }
1753 if (Evalue(2702) > 0)
1754 {
1755 num -= 10 + (int)Mathf.Sqrt(Evalue(2702));
1756 }
1757 return num;
1758 }
1759
1760 public float GetHearthIncome()
1761 {
1762 float num = 0f;
1763 foreach (Element value in elements.dict.Values)
1764 {
1765 if (value.source.category == "culture")
1766 {
1767 num += GetHearthIncome(value.source.alias);
1768 }
1769 }
1770 return num;
1771 }
1772
1773 public float GetHearthIncome(string id)
1774 {
1775 int num = 0;
1776 foreach (KeyValuePair<int, Element> item in elements.dict)
1777 {
1778 if (item.Value.source.aliasParent == id)
1779 {
1780 num++;
1781 }
1782 }
1783 return 0.2f * (float)num;
1784 }
1785
1787 {
1788 int valueWithoutLink = e.ValueWithoutLink;
1789 valueWithoutLink += e.CostLearn;
1790 if (e.source.max != 0 && e.ValueWithoutLink >= e.source.max)
1791 {
1792 return 0;
1793 }
1794 return valueWithoutLink;
1795 }
1796
1797 public string Log(string idLang, string ref1 = null, string ref2 = null, string ref3 = null, string ref4 = null)
1798 {
1799 Msg.alwaysVisible = true;
1800 return LogRaw(Msg.GetRawText(idLang, ref1, ref2, ref3, ref4), EClass.sources.langGame.map[idLang].logColor);
1801 }
1802
1803 public string Log(string idLang, Card c1, Card c2, string ref1 = null, string ref2 = null)
1804 {
1805 Msg.alwaysVisible = true;
1806 return LogRaw(Msg.GetRawText(idLang, c1, c2, ref1, ref2), EClass.sources.langGame.map[idLang].logColor);
1807 }
1808
1809 public string Log(string idLang, Card c1, string ref1 = null, string ref2 = null, string ref3 = null)
1810 {
1811 Msg.alwaysVisible = true;
1812 return LogRaw(Msg.GetRawText(idLang, c1, ref1, ref2, ref3), EClass.sources.langGame.map[idLang].logColor);
1813 }
1814
1815 public string LogRaw(string text, string col = null)
1816 {
1817 log.Add(text, col.IsEmpty() ? null : col);
1818 Msg.alwaysVisible = false;
1819 Msg.SetColor();
1820 return text;
1821 }
1822}
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:3714
bool isDestroyed
Definition: Card.cs:71
void PurgeDuplicateArtifact(Thing af)
Definition: Card.cs:3138
bool IsAmmo
Definition: Card.cs:2183
Thing Split(int a)
Definition: Card.cs:3345
ElementContainerCard elements
Definition: Card.cs:37
bool c_wasInPcParty
Definition: Card.cs:984
string id
Definition: Card.cs:31
bool IsUnique
Definition: Card.cs:2027
bool HasElement(int ele, int req=1)
Definition: Card.cs:5566
bool isRestrained
Definition: Card.cs:550
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:5776
Card ChangeMaterial(int idNew, bool ignoreFixedMaterial=false)
Definition: Card.cs:2957
Card AddCard(Card c)
Definition: Card.cs:3006
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:3020
int hp
Definition: Card.cs:226
string Name
Definition: Card.cs:2073
bool ExistsOnMap
Definition: Card.cs:2021
bool c_isPrayed
Definition: Card.cs:1044
Thing SetNum(int a)
Definition: Card.cs:3356
virtual void SetBlessedState(BlessedState s)
Definition: Card.cs:3740
bool HasTag(CTAG tag)
Definition: Card.cs:2531
Point pos
Definition: Card.cs:55
int uid
Definition: Card.cs:118
Effect PlayEffect(string id, bool useRenderPos=true, float range=0f, Vector3 fix=default(Vector3))
Definition: Card.cs:5810
Trait trait
Definition: Card.cs:49
int c_allowance
Definition: Card.cs:1289
Thing MakeMilk(bool effect=true, int num=1, bool addToZone=true, BlessedState? state=null)
Definition: Card.cs:5419
void SetEncLv(int a)
Definition: Card.cs:3709
void Destroy()
Definition: Card.cs:4783
bool c_isImportant
Definition: Card.cs:996
bool noMove
Definition: Card.cs:754
bool HaveFur()
Definition: Card.cs:7440
ThingContainer things
Definition: Card.cs:34
bool IsInstalled
Definition: Card.cs:2317
int c_daysWithPC
Definition: Card.cs:1445
BedType c_bedType
Definition: Card.cs:912
void MoveImmediate(Point p, bool focus=true, bool cancelAI=true)
Definition: Card.cs:5479
Thing TryMakeRandomItem(int lv=-1)
Definition: Card.cs:5138
Card Install()
Definition: Card.cs:3590
int Num
Definition: Card.cs:154
SourceCategory.Row category
Definition: Card.cs:1985
void ModNum(int a, bool notify=true)
Definition: Card.cs:3376
int c_fur
Definition: Card.cs:1301
int LV
Definition: Card.cs:370
bool isBackerContent
Definition: Card.cs:897
string c_idRefCard
Definition: Card.cs:1697
Thing MakeEgg(bool effect=true, int num=1, bool addToZone=true, int fertChance=20, BlessedState? state=null)
Definition: Card.cs:5403
void RemoveThings()
Definition: Card.cs:3171
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:1278
override bool IsAliveInCurrentZone
Definition: Chara.cs:557
new TraitChara trait
Definition: Chara.cs:499
Hostility OriginalHostility
Definition: Chara.cs:467
void RemoveGlobal()
Definition: Chara.cs:1342
void SetFaction(Faction f)
Definition: Chara.cs:1271
bool IsWealthy
Definition: Chara.cs:921
bool CanRevive()
Definition: Chara.cs:4720
void TryPutShared(Thing t, List< Thing > containers=null, bool dropIfFail=true)
Definition: Chara.cs:4151
void CureHost(CureType type, int p=100, BlessedState state=BlessedState.Normal)
Definition: Chara.cs:8782
void RefreshWorkElements(ElementContainer parent=null)
Definition: Chara.cs:8319
Faction faction
Definition: Chara.cs:423
override bool IsPC
Definition: Chara.cs:608
bool IsMaid
Definition: Chara.cs:893
override bool IsGlobal
Definition: Chara.cs:606
override bool IsPCParty
Definition: Chara.cs:611
Party party
Definition: Chara.cs:43
TraitBed TryAssignBed()
Definition: Chara.cs:6805
bool HasCondition(string alias)
Definition: Chara.cs:8716
int happiness
Definition: Chara.cs:108
Chara SetGlobal(Zone _home, int x, int z)
Definition: Chara.cs:1314
void OnBanish()
Definition: Chara.cs:1284
bool CanEat(Thing t, bool shouldEat=false)
Definition: Chara.cs:7051
override int MaxHP
Definition: Chara.cs:704
Zone currentZone
Definition: Chara.cs:251
override bool IsDeadOrSleeping
Definition: Chara.cs:569
List< Hobby > ListHobbies(bool useMemberType=true)
Definition: Chara.cs:8280
SourceChara.Row source
Definition: Chara.cs:154
Stats mana
Definition: Chara.cs:1006
FactionMemberType memberType
Definition: Chara.cs:46
Stats stamina
Definition: Chara.cs:998
List< Hobby > ListWorks(bool useMemberType=true)
Definition: Chara.cs:8253
void Revive(Point p=null, bool msg=false)
Definition: Chara.cs:4746
Zone homeZone
Definition: Chara.cs:263
Hobby GetWork(string id)
Definition: Chara.cs:8300
Religion faith
Definition: Chara.cs:435
void ClearBed(Map map=null)
Definition: Chara.cs:6778
FactionBranch homeBranch
Definition: Chara.cs:932
bool isDead
Definition: Chara.cs:385
Thing Pick(Thing t, bool msg=true, bool tryStack=true)
Definition: Chara.cs:4017
SourceRace.Row race
Definition: Chara.cs:460
bool allPolicy
Definition: CoreDebug.cs:236
bool allHomeSkill
Definition: CoreDebug.cs:194
bool enable
Definition: CoreDebug.cs:285
static void MakeDish(Thing food, int lv, Chara crafter=null)
Definition: CraftUtil.cs:55
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:63
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 SourceManager sources
Definition: EClass.cs:42
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
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:467
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:235
ReligionManager religions
Definition: Game.cs:158
CardManager cards
Definition: Game.cs:155
FactionManager factions
Definition: Game.cs:161
Zone StartZone
Definition: Game.cs:269
void SetOwner(FactionBranch _owner)
Chara chara
Definition: HireInfo.cs:6
int Hours
Definition: HireInfo.cs:26
Definition: Hobby.cs:4
SourceHobby.Row source
Definition: Hobby.cs:7
int GetEfficiency(Chara c)
Definition: Hobby.cs:30
int GetLv(Chara c)
Definition: Hobby.cs:21
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:2570
PropsInstalled Installed
Definition: Map.cs:123
void SetDecal(int x, int z, int id=0, int amount=1, bool refresh=true)
Definition: Map.cs:2029
int CountHostile()
Definition: Map.cs:2445
List< Thing > things
Definition: Map.cs:49
int CountGuest()
Definition: Map.cs:2432
PropsManager props
Definition: Map.cs:91
int CountWildAnimal()
Definition: Map.cs:2458
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:270
int days
Definition: Player.cs:68
Flags flags
Definition: Player.cs:910
Stats stats
Definition: Player.cs:832
string title
Definition: Player.cs:820
bool simulatingZone
Definition: Player.cs:995
Definition: Point.cs:9
bool HasDecal
Definition: Point.cs:139
int x
Definition: Point.cs:36
int z
Definition: Point.cs:39
Point Clamp(bool useBounds=false)
Definition: Point.cs:988
bool IsInBounds
Definition: Point.cs:104
Cell cell
Definition: Point.cs:51
Thing FindThing(Func< Thing, bool > func)
Definition: Point.cs:1120
Point GetNearestPoint(bool allowBlock=false, bool allowChara=true, bool allowInstalled=true, bool ignoreCenter=false)
Definition: Point.cs:607
Point GetRandomPoint(int radius, bool requireLos=true, bool allowChara=true, bool allowBlocked=false, int tries=100)
Definition: Point.cs:753
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:357
int GetNum(string id, bool onlyShared=false)
Definition: Props.cs:395
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:495
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
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:217
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:131
Point GetPoint()
Definition: Trait.cs:722
Card owner
Definition: Trait.cs:26
virtual bool CanStack
Definition: Trait.cs:149
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:3511
Thing TryGetThingFromSharedContainer(Func< Thing, bool > func)
Definition: Zone.cs:2176
ElementContainerZone elements
Definition: Zone.cs:43
Chara SpawnMob(Point pos=null, SpawnSetting setting=null)
Definition: Zone.cs:2645
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:2053
bool TryAddThing(Thing target, Point p, bool destroyIfFail=false)
Definition: Zone.cs:2150
bool IsActiveZone
Definition: Zone.cs:488
List< Element > ListLandFeats()
Definition: Zone.cs:2938
int GetSoilCost()
Definition: Zone.cs:3537
Card AddCard(Card t, Point point)
Definition: Zone.cs:1910
Map map
Definition: Zone.cs:60
Point GetSpawnPos(Chara c, ZoneTransition.EnterState destState=ZoneTransition.EnterState.Auto)
Definition: Zone.cs:1299
bool demo
Definition: Version.cs:14