Elin Decompiled Documentation EA 23.334 Nightly
Loading...
Searching...
No Matches
FACTION.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using Newtonsoft.Json;
3using UnityEngine;
4
5public class FACTION
6{
7 public const int bfGum = 3803;
8
9 public const int actBuildAnywhere = 4003;
10
11 public const int bfIce = 3804;
12
13 public const int actBuildTerrain = 4002;
14
15 public const int actBuildMine = 4001;
16
17 public const int actBuildCut = 4000;
18
19 public const int bfStart = 3900;
20
21 public const int bfSilica = 3802;
22
23 public const int bfChitin = 3805;
24
25 public const int fFood = 2204;
26
27 public const int fSafety = 2205;
28
29 public const int bfMushroom = 3801;
30
31 public const int fMoral = 2203;
32
33 public const int fPromo = 2202;
34
35 public const int fElec = 2201;
36
37 public const int fSoil = 2200;
38
39 public const int fHeirloom = 2120;
40
41 public const int fTaxEvasion = 2119;
42
43 public const int fLuck = 2118;
44
45 public const int fLoyal = 2117;
46
47 public const int fEducation = 2116;
48
49 public const int fAdmin = 2115;
50
51 public const int fConstruction = 2003;
52
53 public const int fRation = 2207;
54
55 public const int bfCoal = 3800;
56
57 public const int fAttraction = 2206;
58
59 public const int bfLandmark4 = 3783;
60
61 public const int bfLandmark5 = 3784;
62
63 public const int bfFish = 3706;
64
65 public const int bfHunt = 3705;
66
67 public const int bfVolcano = 3704;
68
69 public const int bfMonster = 3707;
70
71 public const int bfTranquil = 3703;
72
73 public const int bfRuin = 3702;
74
75 public const int bfGeyser = 3701;
76
77 public const int bfUndersea = 3606;
78
79 public const int bfSea = 3605;
80
81 public const int bfBeach = 3604;
82
83 public const int bfHill = 3603;
84
85 public const int bfSnow = 3602;
86
87 public const int bfFertile = 3700;
88
89 public const int bfPlain = 3600;
90
91 public const int bfCave = 3500;
92
93 public const int actBuildInspect = 4006;
94
95 public const int bfLandmark3 = 3782;
96
97 public const int actBuildRecipe = 4005;
98
99 public const int actBuildCollect = 4004;
100
101 public const int bfFreshAir = 3708;
102
103 public const int bfBasin = 3709;
104
105 public const int bfBreed = 3710;
106
107 public const int bfLandmark1 = 3780;
108
109 public const int bfForest = 3601;
110
111 public const int bfLandmark2 = 3781;
112
113 public static readonly int[] IDS = new int[53]
114 {
115 3803, 4003, 3804, 4002, 4001, 4000, 3900, 3802, 3805, 2204,
116 2205, 3801, 2203, 2202, 2201, 2200, 2120, 2119, 2118, 2117,
117 2116, 2115, 2003, 2207, 3800, 2206, 3783, 3784, 3706, 3705,
118 3704, 3707, 3703, 3702, 3701, 3606, 3605, 3604, 3603, 3602,
119 3700, 3600, 3500, 4006, 3782, 4005, 4004, 3708, 3709, 3710,
120 3780, 3601, 3781
121 };
122}
123public class Faction : EClass
124{
125 [JsonProperty]
127
128 [JsonProperty]
129 public string id;
130
131 [JsonProperty]
132 public string uid;
133
134 [JsonProperty]
135 public string name;
136
137 [JsonProperty]
138 public List<HireInfo> listReserve = new List<HireInfo>();
139
140 [JsonProperty]
142
143 [JsonProperty]
144 public HashSet<int> globalPolicies = new HashSet<int>();
145
147
149
150 public string Name => name;
151
153
154 public virtual string TextType => "sub_faction".lang();
155
157 {
158 Faction obj = ClassCache.Create<Faction>(r.type, "Elin") ?? new Faction();
159 obj.id = r.id;
160 obj.Init();
161 return obj;
162 }
163
164 public void Init()
165 {
167 relation.faction = this;
168 relation.affinity = source.relation;
169 name = source.GetText();
170 }
171
172 public void OnLoad()
173 {
174 relation.faction = this;
175 }
176
177 public float GetHappiness()
178 {
179 return 50f;
180 }
181
182 public Sprite GetSprite()
183 {
184 return ResourceCache.Load<Sprite>("Media/Graphics/Image/Faction/" + source.id);
185 }
186
187 public int CountTax()
188 {
189 return (int)((float)CountWealth() * 0.1f);
190 }
191
192 public int GetMaxReserve()
193 {
194 int num = 2;
195 foreach (FactionBranch child in GetChildren())
196 {
197 num += child.lv;
198 }
199 return num;
200 }
201
202 public List<FactionBranch> GetChildren()
203 {
204 List<FactionBranch> list = new List<FactionBranch>();
205 foreach (Spatial value in EClass.game.spatials.map.Values)
206 {
207 if (value?.mainFaction == this)
208 {
209 list.Add((value as Zone).branch);
210 }
211 }
212 return list;
213 }
214
215 public int CountWealth()
216 {
218 {
220 }
221 int num = 0;
222 foreach (FactionBranch child in GetChildren())
223 {
224 num += child.Worth;
225 }
226 return num;
227 }
228
229 public int CountTerritories()
230 {
231 int num = 0;
232 foreach (Spatial value in EClass.game.spatials.map.Values)
233 {
234 if (value.mainFaction == this)
235 {
236 num++;
237 }
238 }
239 return num;
240 }
241
242 public int CountMembers()
243 {
244 int num = 0;
245 foreach (Chara value in EClass.game.cards.globalCharas.Values)
246 {
247 if (value.Chara.faction == this)
248 {
249 num++;
250 }
251 }
252 return num;
253 }
254
256 {
257 if (this == EClass.Home || relation.affinity >= 200)
258 {
259 return Hostility.Ally;
260 }
261 if (relation.affinity >= 100)
262 {
263 return Hostility.Friend;
264 }
265 if (relation.affinity <= -100)
266 {
267 return Hostility.Enemy;
268 }
269 return Hostility.Neutral;
270 }
271
272 public void ModRelation(int a)
273 {
274 relation.affinity += a;
275 }
276
277 public bool HasMember(string id, bool includeReserve = true)
278 {
279 foreach (Chara value in EClass.game.cards.globalCharas.Values)
280 {
281 if (value.id == id && value.IsHomeMember())
282 {
283 return true;
284 }
285 }
286 if (includeReserve)
287 {
288 foreach (HireInfo item in listReserve)
289 {
290 if (item.chara.id == id)
291 {
292 return true;
293 }
294 }
295 }
296 return false;
297 }
298
299 public bool IsWearingPanty(Chara c)
300 {
301 if ((!c.IsUnique || c.bio.gender != 2) && (c.IsHuman || c.IsFairy) && !(c.trait is TraitMerchant))
302 {
303 return true;
304 }
305 if (IsGlobalPolicyActive(2712))
306 {
307 foreach (Chara value in EClass.game.cards.globalCharas.Values)
308 {
309 if (value.id == c.id && value.IsHomeMember())
310 {
311 return true;
312 }
313 }
314 }
315 return false;
316 }
317
318 public void AddContribution(int a)
319 {
320 if (a != 0 && relation.type == FactionRelation.RelationType.Member)
321 {
322 if (relation.exp < 0)
323 {
324 relation.exp = 0;
325 }
326 if ((long)relation.exp + (long)a >= 100000000)
327 {
328 relation.exp = 100000000;
329 }
330 else
331 {
332 relation.exp += a;
333 }
334 Msg.Say("contribute", a.ToString() ?? "", Name);
335 }
336 }
337
338 public void AddReserve(Chara c)
339 {
340 if (c.IsPCParty)
341 {
343 }
344 if (c.memberType == FactionMemberType.Livestock)
345 {
346 c.SetInt(36, EClass.world.date.GetRaw() + 14400);
347 }
348 if (c.IsHomeMember())
349 {
351 }
352 if (c.currentZone != null)
353 {
355 }
356 if (EClass.Branch.uidMaid == c.uid)
357 {
358 EClass.Branch.uidMaid = 0;
359 }
361 {
362 chara = c,
363 isNew = true
364 };
365 listReserve.Add(item);
366 }
367
368 public void RemoveReserve(Chara c)
369 {
370 listReserve.ForeachReverse(delegate(HireInfo i)
371 {
372 if (i.chara == c || i.chara.uid == c.uid)
373 {
374 listReserve.Remove(i);
375 }
376 });
377 }
378
379 public void OnAdvanceDay()
380 {
381 foreach (FactionBranch child in GetChildren())
382 {
383 child.OnAdvanceDay();
384 }
385 }
386
387 public void OnAdvanceMonth()
388 {
389 if (GetChildren().Count == 0)
390 {
391 return;
392 }
393 int num = 0;
394 num += GetResidentTax();
395 num += GetRankIncome();
396 num += GetFactionSalary();
397 if (num > 0)
398 {
399 Thing container_deposit = EClass.game.cards.container_deposit;
400 if (EClass.pc.homeBranch.policies.IsActive(2711) && (container_deposit.GetCurrency() > 0 || !container_deposit.things.IsFull()))
401 {
402 container_deposit.ModCurrency(num);
403 Msg.Say("bankIncome", Lang._currency(num, "money"));
404 }
405 else
406 {
407 Thing thing = ThingGen.Create("money").SetNum(num);
408 Thing p = ThingGen.CreateParcel("parcel_salary", thing);
410 }
411 }
412 num = GetTotalTax(evasion: true);
413 Thing thing2 = ThingGen.CreateBill(num, tax: true);
414 thing2.SetInt(35, EClass.player.extraTax);
415 Msg.Say("getBill", Lang._currency(num, "money"));
416 TryPayBill(thing2);
417 Msg.Say("bills", EClass.player.taxBills.ToString() ?? "");
419 {
421 }
422 }
423
424 public void TryPayBill(Thing bill)
425 {
427 {
428 InvOwnerDeliver.PayBill(bill, fromBank: true);
429 }
430 else
431 {
433 }
434 }
435
437 {
438 foreach (FactionBranch child in GetChildren())
439 {
440 if (child.members.Contains(c))
441 {
442 return child;
443 }
444 }
445 return null;
446 }
447
448 public Chara FindChara(string id, bool inclurdeReserve = true)
449 {
450 foreach (FactionBranch child in GetChildren())
451 {
452 foreach (Chara member in child.members)
453 {
454 if (member.id == id)
455 {
456 return member;
457 }
458 }
459 }
460 if (inclurdeReserve)
461 {
462 foreach (HireInfo item in listReserve)
463 {
464 if (item.chara.id == id)
465 {
466 return item.chara;
467 }
468 }
469 }
470 return null;
471 }
472
473 public void AddGlobalPolicy(int id)
474 {
475 globalPolicies.Add(id);
476 }
477
478 public bool IsGlobalPolicyActive(int id)
479 {
480 bool result = false;
481 foreach (FactionBranch child in GetChildren())
482 {
483 if (child.policies.IsActive(id))
484 {
485 result = true;
486 }
487 }
488 return result;
489 }
490
491 public void SetGlobalPolicyActive(int id, bool active)
492 {
493 foreach (FactionBranch child in GetChildren())
494 {
495 child.policies.SetActive(id, active);
496 }
497 }
498
499 public int GetResidentTax()
500 {
501 int num = 0;
502 foreach (FactionBranch child in GetChildren())
503 {
504 num += child.GetResidentTax();
505 }
506 if (num > 0)
507 {
508 Msg.Say("getResidentTax", Lang._currency(num, "money"));
509 }
510 return num;
511 }
512
513 public int GetRankIncome()
514 {
515 int num = 0;
516 foreach (FactionBranch child in GetChildren())
517 {
518 num += EClass.game.spatials.ranks.GetIncome(child.owner);
519 }
520 if (num > 0)
521 {
522 Msg.Say("getRankIncome", Lang._currency(num, "money"));
523 }
524 return num;
525 }
526
527 public int GetFactionSalary()
528 {
529 int num = 0;
530 foreach (Faction value in EClass.game.factions.dictAll.Values)
531 {
532 num += value.relation.GetSalary();
533 }
534 if (num > 0)
535 {
536 Msg.Say("getFactionSalary", Lang._currency(num, "money"));
537 }
538 return num;
539 }
540
541 public int GetTotalTax(bool evasion)
542 {
543 return GetBaseTax(evasion) + GetFameTax(evasion) + EClass.player.extraTax;
544 }
545
546 public int GetBaseTax(bool evasion)
547 {
548 int a = EClass.world.date.year - EClass.game.Prologue.year;
549 int v = 500 + Mathf.Min(a, 10) * 500;
550 return EvadeTax(v, evasion);
551 }
552
553 public int GetFameTax(bool evasion)
554 {
555 int num = EClass.curve(EClass.player.fame * 2, 10000, 2000, 80);
556 if (num > 1000000 || num < 0)
557 {
558 num = 1000000;
559 }
560 return EvadeTax(num, evasion);
561 }
562
563 public int EvadeTax(int v, bool evasion)
564 {
565 if (!evasion)
566 {
567 return v;
568 }
569 int num = 0;
570 foreach (FactionBranch child in GetChildren())
571 {
572 num += child.Evalue(2119);
573 }
574 return (int)(long)((float)(v * 100) / (100f + Mathf.Sqrt(num * 5)));
575 }
576
577 public void SetTaxTooltip(UINote n)
578 {
579 n.AddHeader("tax");
580 n.AddTopic("tax_base", Lang._currency(GetBaseTax(evasion: true), showUnit: true) + " (" + Lang._currency(GetBaseTax(evasion: false)) + ")");
581 n.AddTopic("tax_fame", Lang._currency(GetFameTax(evasion: true), showUnit: true) + " (" + Lang._currency(GetFameTax(evasion: false)) + ")");
582 n.AddTopic("tax_extra", Lang._currency(EClass.player.extraTax, showUnit: true));
583 }
584
585 public int CountTaxFreeLand()
586 {
587 int num = 0;
588 foreach (FactionBranch child in GetChildren())
589 {
590 if (child.policies.IsActive(2514))
591 {
592 num++;
593 }
594 }
595 return num;
596 }
597}
FactionMemberType
Hostility
Definition: Hostility.cs:2
int gender
Definition: Biography.cs:29
GlobalCharaList globalCharas
Definition: CardManager.cs:46
Thing container_deposit
Definition: CardManager.cs:58
virtual Chara Chara
Definition: Card.cs:2122
string id
Definition: Card.cs:36
bool IsUnique
Definition: Card.cs:2143
void SetInt(string id, int value=0)
Definition: Card.cs:2586
Biography bio
Definition: Card.cs:45
Thing SetNum(int a)
Definition: Card.cs:3673
int GetCurrency(string id="money")
Definition: Card.cs:4153
int uid
Definition: Card.cs:125
void ModCurrency(int a, string id="money")
Definition: Card.cs:4139
ThingContainer things
Definition: Card.cs:39
Definition: Chara.cs:10
new TraitChara trait
Definition: Chara.cs:509
Faction faction
Definition: Chara.cs:431
override bool IsPCParty
Definition: Chara.cs:633
Party party
Definition: Chara.cs:43
bool IsHuman
Definition: Chara.cs:926
Zone currentZone
Definition: Chara.cs:259
bool IsFairy
Definition: Chara.cs:986
FactionMemberType memberType
Definition: Chara.cs:46
bool IsHomeMember()
Definition: Chara.cs:6939
FactionBranch homeBranch
Definition: Chara.cs:1113
bool godMode
Definition: CoreDebug.cs:188
int GetRaw(int offsetHours=0)
Definition: Date.cs:328
Definition: EClass.cs:6
static Game game
Definition: EClass.cs:9
static int curve(long _a, int start, int step, int rate=75)
Definition: EClass.cs:69
static Faction Home
Definition: EClass.cs:27
static Zone _zone
Definition: EClass.cs:21
static World world
Definition: EClass.cs:41
static SourceManager sources
Definition: EClass.cs:43
static FactionBranch Branch
Definition: EClass.cs:23
static Player player
Definition: EClass.cs:13
static Chara pc
Definition: EClass.cs:15
static CoreDebug debug
Definition: EClass.cs:49
const int fHeirloom
Definition: FACTION.cs:39
const int bfLandmark1
Definition: FACTION.cs:107
const int bfHill
Definition: FACTION.cs:83
const int bfStart
Definition: FACTION.cs:19
const int fSafety
Definition: FACTION.cs:27
const int bfLandmark4
Definition: FACTION.cs:59
const int bfTranquil
Definition: FACTION.cs:71
const int bfChitin
Definition: FACTION.cs:23
const int fLoyal
Definition: FACTION.cs:45
const int bfBeach
Definition: FACTION.cs:81
const int bfGum
Definition: FACTION.cs:7
const int fConstruction
Definition: FACTION.cs:51
const int bfMonster
Definition: FACTION.cs:69
const int actBuildRecipe
Definition: FACTION.cs:97
const int bfLandmark2
Definition: FACTION.cs:111
const int fLuck
Definition: FACTION.cs:43
const int bfRuin
Definition: FACTION.cs:73
const int fFood
Definition: FACTION.cs:25
const int bfSea
Definition: FACTION.cs:79
const int fMoral
Definition: FACTION.cs:31
const int fElec
Definition: FACTION.cs:35
const int bfFish
Definition: FACTION.cs:63
const int bfVolcano
Definition: FACTION.cs:67
const int actBuildInspect
Definition: FACTION.cs:93
const int actBuildCollect
Definition: FACTION.cs:99
const int bfSilica
Definition: FACTION.cs:21
const int bfCoal
Definition: FACTION.cs:55
const int bfBasin
Definition: FACTION.cs:103
const int bfLandmark5
Definition: FACTION.cs:61
const int fSoil
Definition: FACTION.cs:37
const int fRation
Definition: FACTION.cs:53
const int bfHunt
Definition: FACTION.cs:65
const int fTaxEvasion
Definition: FACTION.cs:41
const int bfFertile
Definition: FACTION.cs:87
const int fEducation
Definition: FACTION.cs:47
const int fPromo
Definition: FACTION.cs:33
const int actBuildCut
Definition: FACTION.cs:17
const int bfCave
Definition: FACTION.cs:91
const int bfSnow
Definition: FACTION.cs:85
const int bfMushroom
Definition: FACTION.cs:29
const int actBuildAnywhere
Definition: FACTION.cs:9
const int bfFreshAir
Definition: FACTION.cs:101
const int fAttraction
Definition: FACTION.cs:57
const int bfPlain
Definition: FACTION.cs:89
const int bfForest
Definition: FACTION.cs:109
const int actBuildTerrain
Definition: FACTION.cs:13
const int bfGeyser
Definition: FACTION.cs:75
const int bfBreed
Definition: FACTION.cs:105
const int bfIce
Definition: FACTION.cs:11
const int bfLandmark3
Definition: FACTION.cs:95
static readonly int[] IDS
Definition: FACTION.cs:113
const int fAdmin
Definition: FACTION.cs:49
const int actBuildMine
Definition: FACTION.cs:15
const int bfUndersea
Definition: FACTION.cs:77
int Evalue(int ele)
List< Chara > members
void RemoveMemeber(Chara c)
void OnAdvanceDay()
PolicyManager policies
HomeResourceManager resources
void AssignUID(Faction s)
Dictionary< string, Faction > dictAll
RelationType type
int GetFactionSalary()
Definition: FACTION.cs:527
Sprite GetSprite()
Definition: FACTION.cs:182
List< FactionBranch > GetChildren()
Definition: FACTION.cs:202
void AddGlobalPolicy(int id)
Definition: FACTION.cs:473
FactionBranch FindBranch(Chara c)
Definition: FACTION.cs:436
virtual string TextType
Definition: FACTION.cs:154
ElementContainerFaction charaElements
Definition: FACTION.cs:146
int CountWealth()
Definition: FACTION.cs:215
void Init()
Definition: FACTION.cs:164
void SetTaxTooltip(UINote n)
Definition: FACTION.cs:577
bool IsGlobalPolicyActive(int id)
Definition: FACTION.cs:478
int GetTotalTax(bool evasion)
Definition: FACTION.cs:541
bool IsWearingPanty(Chara c)
Definition: FACTION.cs:299
void TryPayBill(Thing bill)
Definition: FACTION.cs:424
string uid
Definition: FACTION.cs:132
int GetFameTax(bool evasion)
Definition: FACTION.cs:553
Hostility GetHostility()
Definition: FACTION.cs:255
int CountTaxFreeLand()
Definition: FACTION.cs:585
ElementContainerZone elements
Definition: FACTION.cs:141
Chara FindChara(string id, bool inclurdeReserve=true)
Definition: FACTION.cs:448
string name
Definition: FACTION.cs:135
bool HasMember(string id, bool includeReserve=true)
Definition: FACTION.cs:277
int CountMembers()
Definition: FACTION.cs:242
HashSet< int > globalPolicies
Definition: FACTION.cs:144
void AddReserve(Chara c)
Definition: FACTION.cs:338
List< HireInfo > listReserve
Definition: FACTION.cs:138
int EvadeTax(int v, bool evasion)
Definition: FACTION.cs:563
void RemoveReserve(Chara c)
Definition: FACTION.cs:368
SourceFaction.Row _source
Definition: FACTION.cs:148
void ModRelation(int a)
Definition: FACTION.cs:272
int CountTax()
Definition: FACTION.cs:187
int GetResidentTax()
Definition: FACTION.cs:499
int GetBaseTax(bool evasion)
Definition: FACTION.cs:546
string Name
Definition: FACTION.cs:150
SourceFaction.Row source
Definition: FACTION.cs:152
float GetHappiness()
Definition: FACTION.cs:177
void OnAdvanceDay()
Definition: FACTION.cs:379
string id
Definition: FACTION.cs:129
int GetRankIncome()
Definition: FACTION.cs:513
void OnAdvanceMonth()
Definition: FACTION.cs:387
static Faction Create(SourceFaction.Row r)
Definition: FACTION.cs:156
void SetGlobalPolicyActive(int id, bool active)
Definition: FACTION.cs:491
void AddContribution(int a)
Definition: FACTION.cs:318
void OnLoad()
Definition: FACTION.cs:172
int CountTerritories()
Definition: FACTION.cs:229
int GetMaxReserve()
Definition: FACTION.cs:192
FactionRelation relation
Definition: FACTION.cs:126
GamePrincipal principal
Definition: Game.cs:225
SpatialManager spatials
Definition: Game.cs:153
Prologue Prologue
Definition: Game.cs:264
CardManager cards
Definition: Game.cs:156
FactionManager factions
Definition: Game.cs:162
Chara chara
Definition: HireInfo.cs:6
static void PayBill(Thing t, bool fromBank=false)
Definition: Lang.cs:7
static string _currency(object a, string IDCurrency)
Definition: Lang.cs:161
Definition: Msg.cs:5
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:58
void RemoveMember(Chara c)
Definition: Party.cs:112
void ModKarma(int a)
Definition: Player.cs:2610
int extraTax
Definition: Player.cs:999
int fame
Definition: Player.cs:948
int taxBills
Definition: Player.cs:975
void SetActive(int id, bool active)
bool IsActive(int id, int days=-1)
int year
Definition: Prologue.cs:15
int GetIncome(Zone z)
SourceFaction factions
GlobalSpatialList map
RankedZoneManager ranks
Faction mainFaction
Definition: Spatial.cs:442
bool IsFull(int y=0)
static Thing CreateParcel(string idLang=null, params Thing[] things)
Definition: ThingGen.cs:42
static Thing CreateBill(int pay, bool tax)
Definition: ThingGen.cs:85
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
Definition: Thing.cs:8
Definition: UINote.cs:6
UIItem AddHeader(string text, Sprite sprite=null)
Definition: UINote.cs:79
UIItem AddTopic(string id, string text, string value=null)
Definition: UINote.cs:144
GameDate date
Definition: World.cs:6
void SendPackage(Thing p)
Definition: World.cs:68
Definition: Zone.cs:12
FactionBranch branch
Definition: Zone.cs:34
void RemoveCard(Card t)
Definition: Zone.cs:2138
bool IsPCFaction
Definition: Zone.cs:477